{"version":3,"file":"dnd5e.mjs","sources":["module/applications/advancement/advancement-config.mjs","module/applications/advancement/advancement-flow.mjs","module/data/fields.mjs","module/data/advancement/base-advancement.mjs","module/documents/advancement/advancement.mjs","module/applications/advancement/hit-points-config.mjs","module/applications/advancement/hit-points-flow.mjs","module/utils.mjs","module/documents/advancement/hit-points.mjs","module/applications/advancement/item-grant-config.mjs","module/applications/advancement/item-grant-flow.mjs","module/data/advancement/spell-config.mjs","module/data/advancement/item-grant.mjs","module/documents/advancement/item-grant.mjs","module/applications/advancement/item-choice-config.mjs","module/documents/actor/proficiency.mjs","module/dice/dice.mjs","module/applications/actor/short-rest.mjs","module/applications/actor/long-rest.mjs","module/documents/actor/trait.mjs","module/documents/actor/actor.mjs","module/applications/advancement/item-choice-flow.mjs","module/data/advancement/item-choice.mjs","module/documents/advancement/item-choice.mjs","module/data/advancement/scale-value.mjs","module/applications/advancement/scale-value-config.mjs","module/applications/advancement/scale-value-flow.mjs","module/documents/advancement/scale-value.mjs","module/config.mjs","module/module-art.mjs","module/settings.mjs","module/documents/active-effect.mjs","module/dice/simplify-roll-formula.mjs","module/applications/item/ability-use-dialog.mjs","module/documents/item.mjs","module/applications/actor/base-config.mjs","module/applications/actor/ability-config.mjs","module/applications/actor/armor-config.mjs","module/applications/actor/hit-dice-config.mjs","module/applications/actor/hit-points-config.mjs","module/applications/actor/initiative-config.mjs","module/applications/actor/movement-config.mjs","module/applications/actor/senses-config.mjs","module/applications/actor/sheet-flags.mjs","module/applications/actor/type-config.mjs","module/applications/advancement/advancement-confirmation-dialog.mjs","module/applications/advancement/advancement-manager.mjs","module/applications/property-attribution.mjs","module/applications/actor/trait-selector.mjs","module/applications/actor/proficiency-config.mjs","module/applications/actor/tool-selector.mjs","module/applications/actor/base-sheet.mjs","module/applications/actor/character-sheet.mjs","module/applications/actor/npc-sheet.mjs","module/applications/actor/vehicle-sheet.mjs","module/applications/actor/group-sheet.mjs","module/applications/actor/skill-config.mjs","module/applications/advancement/advancement-migration-dialog.mjs","module/applications/advancement/advancement-selection.mjs","module/applications/combat/combat-tracker.mjs","module/applications/trait-selector.mjs","module/applications/item/item-sheet.mjs","module/applications/journal/journal-editor.mjs","module/applications/journal/class-sheet.mjs","module/applications/journal/srd-compendium.mjs","module/applications/damage-trait-selector.mjs","module/applications/proficiency-selector.mjs","module/canvas/ability-template.mjs","module/canvas/token.mjs","module/canvas/grid.mjs","module/data/abstract.mjs","module/data/actor/templates/attributes.mjs","module/data/shared/currency.mjs","module/data/actor/templates/common.mjs","module/data/actor/templates/creature.mjs","module/data/actor/templates/details.mjs","module/data/actor/templates/traits.mjs","module/data/actor/character.mjs","module/data/actor/group.mjs","module/data/actor/npc.mjs","module/data/actor/vehicle.mjs","module/data/actor/_module.mjs","module/data/item/templates/item-description.mjs","module/data/item/background.mjs","module/data/item/class.mjs","module/data/item/templates/action.mjs","module/data/item/templates/activated-effect.mjs","module/data/item/templates/equippable-item.mjs","module/data/item/templates/physical-item.mjs","module/data/item/consumable.mjs","module/data/item/container.mjs","module/data/item/templates/mountable.mjs","module/data/item/equipment.mjs","module/data/item/feat.mjs","module/data/item/loot.mjs","module/data/item/spell.mjs","module/data/item/subclass.mjs","module/data/item/tool.mjs","module/data/item/weapon.mjs","module/data/item/_module.mjs","module/data/journal/class.mjs","module/data/journal/_module.mjs","module/dice/d20-roll.mjs","module/dice/damage-roll.mjs","module/documents/token.mjs","module/documents/chat-message.mjs","module/documents/combat.mjs","module/documents/macro.mjs","module/documents/_module.mjs","module/migration.mjs","dnd5e.mjs"],"sourcesContent":["/**\n * Base configuration application for advancements that can be extended by other types to implement custom\n * editing interfaces.\n *\n * @param {Advancement} advancement The advancement item being edited.\n * @param {object} [options={}] Additional options passed to FormApplication.\n * @param {string} [options.dropKeyPath=null] Path within advancement configuration where dropped items are stored.\n * If populated, will enable default drop & delete behavior.\n */\nexport default class AdvancementConfig extends FormApplication {\n constructor(advancement, options={}) {\n super(advancement, options);\n this.#advancementId = advancement.id;\n this.item = advancement.item;\n }\n\n /* -------------------------------------------- */\n\n /**\n * The ID of the advancement being created or edited.\n * @type {string}\n */\n #advancementId;\n\n /* -------------------------------------------- */\n\n /**\n * Parent item to which this advancement belongs.\n * @type {Item5e}\n */\n item;\n\n /* -------------------------------------------- */\n\n /** @inheritDoc */\n static get defaultOptions() {\n return foundry.utils.mergeObject(super.defaultOptions, {\n classes: [\"dnd5e\", \"advancement\", \"dialog\"],\n template: \"systems/dnd5e/templates/advancement/advancement-config.hbs\",\n width: 400,\n height: \"auto\",\n submitOnChange: true,\n closeOnSubmit: false,\n dropKeyPath: null\n });\n }\n\n /* -------------------------------------------- */\n\n /**\n * The advancement being created or edited.\n * @type {Advancement}\n */\n get advancement() {\n return this.item.advancement.byId[this.#advancementId];\n }\n\n /* -------------------------------------------- */\n\n /** @inheritDoc */\n get title() {\n const type = this.advancement.constructor.metadata.title;\n return `${game.i18n.format(\"DND5E.AdvancementConfigureTitle\", { item: this.item.name })}: ${type}`;\n }\n\n /* -------------------------------------------- */\n\n /** @inheritdoc */\n async close(options={}) {\n await super.close(options);\n delete this.advancement.apps[this.appId];\n }\n\n /* -------------------------------------------- */\n\n /** @inheritdoc */\n getData() {\n const levels = Object.fromEntries(Array.fromRange(CONFIG.DND5E.maxLevel + 1).map(l => [l, l]));\n if ( [\"class\", \"subclass\"].includes(this.item.type) ) delete levels[0];\n else levels[0] = game.i18n.localize(\"DND5E.AdvancementLevelAnyHeader\");\n const context = {\n CONFIG: CONFIG.DND5E,\n ...this.advancement.toObject(false),\n src: this.advancement.toObject(),\n default: {\n title: this.advancement.constructor.metadata.title,\n icon: this.advancement.constructor.metadata.icon\n },\n levels,\n showClassRestrictions: this.item.type === \"class\",\n showLevelSelector: !this.advancement.constructor.metadata.multiLevel\n };\n return context;\n }\n\n /* -------------------------------------------- */\n\n /**\n * Perform any changes to configuration data before it is saved to the advancement.\n * @param {object} configuration Configuration object.\n * @returns {object} Modified configuration.\n */\n async prepareConfigurationUpdate(configuration) {\n return configuration;\n }\n\n /* -------------------------------------------- */\n\n /** @inheritdoc */\n activateListeners(html) {\n super.activateListeners(html);\n\n // Remove an item from the list\n if ( this.options.dropKeyPath ) html.on(\"click\", \"[data-action='delete']\", this._onItemDelete.bind(this));\n }\n\n /* -------------------------------------------- */\n\n /** @inheritdoc */\n render(force=false, options={}) {\n this.advancement.apps[this.appId] = this;\n return super.render(force, options);\n }\n\n /* -------------------------------------------- */\n\n /** @inheritdoc */\n async _updateObject(event, formData) {\n let updates = foundry.utils.expandObject(formData);\n if ( updates.configuration ) updates.configuration = await this.prepareConfigurationUpdate(updates.configuration);\n await this.advancement.update(updates);\n }\n\n /* -------------------------------------------- */\n\n /**\n * Helper method to take an object and apply updates that remove any empty keys.\n * @param {object} object Object to be cleaned.\n * @returns {object} Copy of object with only non false-ish values included and others marked\n * using `-=` syntax to be removed by update process.\n * @protected\n */\n static _cleanedObject(object) {\n return Object.entries(object).reduce((obj, [key, value]) => {\n if ( value ) obj[key] = value;\n else obj[`-=${key}`] = null;\n return obj;\n }, {});\n }\n\n /* -------------------------------------------- */\n /* Drag & Drop for Item Pools */\n /* -------------------------------------------- */\n\n /**\n * Handle deleting an existing Item entry from the Advancement.\n * @param {Event} event The originating click event.\n * @returns {Promise ${art.credit} ${game.i18n.format(\"DND5E.AbilityPromptText\", {ability: label})}