From 8607dcaa9e103bd8c730760cf58a41764e6d0659 Mon Sep 17 00:00:00 2001 From: Jan Weigmann Date: Fri, 8 Sep 2023 13:59:40 +0200 Subject: [PATCH] 5.1.1 --- bundle/dsa5.bundle.js | 2 +- lang/de.json | 2 +- lazy/patchhtml/news_de_5.1.0.html | 28 +++++++++++++++++++++++--- modules/hooks/configuration.js | 1 + modules/system/itemlibrary.js | 2 +- modules/system/migrakel.js | 33 ++++++++++++++++++++----------- system.json | 8 ++++---- 7 files changed, 55 insertions(+), 21 deletions(-) diff --git a/bundle/dsa5.bundle.js b/bundle/dsa5.bundle.js index e59f2586..679220e3 100644 --- a/bundle/dsa5.bundle.js +++ b/bundle/dsa5.bundle.js @@ -1,2 +1,2 @@ /*! For license information please see dsa5.bundle.js.LICENSE.txt */ -(()=>{"use strict";var __webpack_modules__={369:(t,r,a)=>{a.d(r,{Z:()=>S});var o=a(491),i=a(577),c=a(562),u=a(600),l=a(538),p=a(272),d=a(173),h=a(973),m=a(839),y=a(101),g=a(122),v=a(707),_=a(702),b=a(61),k=a(803),w=a(472),x=a(169);function _typeof(t){return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},_typeof(t)}function ownKeys(t,r){var a=Object.keys(t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);r&&(o=o.filter((function(r){return Object.getOwnPropertyDescriptor(t,r).enumerable}))),a.push.apply(a,o)}return a}function _objectSpread(t){for(var r=1;r=0;--o){var i=this.tryEntries[o],c=i.completion;if("root"===i.tryLoc)return handle("end");if(i.tryLoc<=this.prev){var u=a.call(i,"catchLoc"),l=a.call(i,"finallyLoc");if(u&&l){if(this.prev=0;--o){var i=this.tryEntries[o];if(i.tryLoc<=this.prev&&a.call(i,"finallyLoc")&&this.prev=0;--r){var a=this.tryEntries[r];if(a.finallyLoc===t)return this.complete(a.completion,a.afterLoc),resetTryEntry(a),l}},catch:function _catch(t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc===t){var o=a.completion;if("throw"===o.type){var i=o.arg;resetTryEntry(a)}return i}}throw new Error("illegal catch attempt")},delegateYield:function delegateYield(t,r,a){return this.delegate={iterator:values(t),resultName:r,nextLoc:a},"next"===this.method&&(this.arg=void 0),l}},t}function asyncGeneratorStep(t,r,a,o,i,c,u){try{var l=t[c](u),p=l.value}catch(t){return void a(t)}l.done?r(p):Promise.resolve(p).then(o,i)}function _asyncToGenerator(t){return function(){var r=this,a=arguments;return new Promise((function(o,i){var c=t.apply(r,a);function _next(t){asyncGeneratorStep(c,o,i,_next,_throw,"next",t)}function _throw(t){asyncGeneratorStep(c,o,i,_next,_throw,"throw",t)}_next(void 0)}))}}function _createForOfIteratorHelper(t,r){var a="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!a){if(Array.isArray(t)||(a=_unsupportedIterableToArray(t))||r&&t&&"number"==typeof t.length){a&&(t=a);var o=0,i=function F(){};return{s:i,n:function n(){return o>=t.length?{done:!0}:{done:!1,value:t[o++]}},e:function e(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var c,u=!0,l=!1;return{s:function s(){a=a.call(t)},n:function n(){var t=a.next();return u=t.done,t},e:function e(t){l=!0,c=t},f:function f(){try{u||null==a.return||a.return()}finally{if(l)throw c}}}}function _unsupportedIterableToArray(t,r){if(t){if("string"==typeof t)return _arrayLikeToArray(t,r);var a=Object.prototype.toString.call(t).slice(8,-1);return"Object"===a&&t.constructor&&(a=t.constructor.name),"Map"===a||"Set"===a?Array.from(t):"Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a)?_arrayLikeToArray(t,r):void 0}}function _arrayLikeToArray(t,r){(null==r||r>t.length)&&(r=t.length);for(var a=0,o=new Array(r);ar.reduce((function(t,r){return t+Number(r.system.encumbrance.value)}),0))for(var o=0,i=[game.i18n.localize("CHARAbbrev.GS"),game.i18n.localize("CHARAbbrev.INI")];o0&&(r+=p.Z.vantageStep(this,game.i18n.localize("LocalizedIDs.sensitiveToPain"))+p.Z.vantageStep(this,game.i18n.localize("LocalizedIDs.fragileAnimal"))),r=Math.clamped(r,0,4),t.condition.inpain=r}},{key:"woundPain",value:function woundPain(t){var r=0;t.status.wounds.max>0&&("creature"!=this.type||t.status.wounds.max>=20?(r=Math.floor(4*(1-t.status.wounds.value/t.status.wounds.max)),t.status.wounds.value<=5&&(r=4)):r=Math.floor(5-5*t.status.wounds.value/t.status.wounds.max));return Math.clamped(r,0,4)}},{key:"calcSpeed",value:function calcSpeed(t,r,a){if(a){if(t.status.speed.max=a.system.status.speed.max,!t.status.speed.max){var o=a.system;a.calcSpeed(o,a.hasCondition("fixated"))}t.status.speed.max=a.system.status.speed.max}else{var i;t.status.speed.max=t.status.speed.initial+(t.status.speed.modifier||0)+(t.status.speed.gearmodifier||0),t.status.speed.max=Math.round(Math.max(0,t.status.speed.max-Math.min(4,this.calcEncumbrance(t)))*t.status.speed.multiplier),this.hasCondition("bloodrush")||(t.status.speed.max=Math.max(0,t.status.speed.max-((null===(i=t.condition)||void 0===i?void 0:i.inpain)||0)));var c=this.hasCondition("paralysed");c&&(t.status.speed.max=Math.round(t.status.speed.max*(1-.25*c.flags.dsa5.value))),r||this.hasCondition("rooted")||this.hasCondition("incapacitated")?t.status.speed.max=0:this.hasCondition("prone")&&(t.status.speed.max=Math.min(1,t.status.speed.max)),x.Z.updateRiderSpeed(this,t.status.speed.max)}}},{key:"calcEncumbrance",value:function calcEncumbrance(t){var r;return Math.clamped((null===(r=t.condition)||void 0===r?void 0:r.encumbered)||0,0,4)}},{key:"calcInitiative",value:function calcInitiative(t,r,a){if("character"==this.type||"npc"==this.type?t.status.initiative.value=Math.round((t.characteristics.mu.value+t.characteristics.ge.value)/2)+(t.status.initiative.modifier||0):t.status.initiative.value=t.status.initiative.current+(t.status.initiative.modifier||0),a){if(t.status.initiative.value=a.system.status.initiative.value,!t.status.initiative.value){var o=a.system;a.calcInitiative(o,a.calcEncumbrance(o)),t.status.initiative.value=o.status.initiative.value}}else{t.status.initiative.value+=(t.status.initiative.gearmodifier||0)-Math.min(4,r);var i=Number((.01*t.status.initiative.value).toFixed(2));t.status.initiative.value*=t.status.initiative.multiplier||1,t.status.initiative.value=Math.round(t.status.initiative.value)+i}}},{key:"creatureType",get:function get(){return w.Z.creatureTypeName(this)}},{key:"prepareMerchant",value:(X=_asyncToGenerator(_regeneratorRuntime().mark((function _callee(){var t;return _regeneratorRuntime().wrap((function _callee$(r){for(;;)switch(r.prev=r.next){case 0:if("loot"!=getProperty(this,"system.merchant.merchantType")){r.next=11;break}if(!getProperty(this,"system.merchant.locked")||this.hasCondition("locked")){r.next=6;break}return r.next=4,this.addCondition(Actordsa5.lockedCondition());case 4:r.next=11;break;case 6:if(getProperty(this,"system.merchant.locked")){r.next=11;break}if(!(t=this.effects.find((function(t){return t.statuses.has("locked")})))){r.next=11;break}return r.next=11,this.deleteEmbeddedDocuments("ActiveEffect",[t.id]);case 11:case"end":return r.stop()}}),_callee,this)}))),function prepareMerchant(){return X.apply(this,arguments)})},{key:"applyActiveEffects",value:function applyActiveEffects(){var t,r=this,a={};null!==(t=this.statuses)&&void 0!==t||(this.statuses=new Set);for(var o=new Map,i=0,c=Object.values(CONFIG.specialStatusEffects);i2&&void 0!==l[2]&&l[2],o=!(l.length>3&&void 0!==l[3])||l[3],i=foundry.utils.getProperty(this.system,t),o?(a&&(r=Math.clamped(i.min||0,Number(i.value)+r,i.max)),c=_defineProperty({},"system.".concat(t,".value"),r)):(a&&(r=Number(i)+r),c=_defineProperty({},"system.".concat(t),r)),u=Hooks.call("modifyTokenAttribute",{attribute:t,value:r,isDelta:a,isBar:o},c),p.abrupt("return",!1!==u?this.update(c):this);case 6:case"end":return p.stop()}}),_callee2,this)}))),function modifyTokenAttribute(t,r){return Q.apply(this,arguments)})},{key:"schipshtml",value:function schipshtml(){for(var t=[],r=1;r<=Number(this.system.status.fatePoints.max);r++)t.push({value:r,cssClass:r<=Number(this.system.status.fatePoints.value)?"fullSchip":"emptySchip"});return t}},{key:"prepareItems",value:function prepareItems(t){var r,a,c,u,l,p,d=this,h=this.toObject(!1),m=[],y=[],v=[],b=[],k=[],w=[],S=[],T=[],A=[],O=[],P=Object.fromEntries(Object.keys(i.Z.specialAbilityCategories).map((function(t){return[t,[]]}))),E=Object.fromEntries(Object.keys(i.Z.traitCategories).map((function(t){return[t,[]]}))),C=[],D=[],I=[],R=[],L={hasSpells:this.system.isMage,hasPrayers:this.system.isPriest,liturgy:[],spell:[],ritual:[],ceremony:[],blessing:[],magictrick:[],magicalsign:[]},G={spell:{},ritual:{},ceremony:{},liturgy:{}},M=this.hasPlayerOwner?g.Z.getGroupSchips():[],j=this.schipshtml(),z={meleeweapons:{items:[],show:!1,dataType:"meleeweapon"},rangeweapons:{items:[],show:!1,dataType:"rangeweapon"},armor:{items:[],show:!1,dataType:"armor"},ammunition:{items:[],show:!1,dataType:"ammunition"},plant:{items:[],show:!1,dataType:"plant"},poison:{items:[],show:!1,dataType:"poison"}};for(var N in i.Z.equipmentTypes)z[N]={items:[],show:!1,dataType:N};z.misc.show=!0;var H={coins:[],total:0,show:!0};h.items=h.items.sort((function(t,r){return t.name.localeCompare(r.name)}));var $,Z=h.system.totalArmor||0,W={body:[],social:[],knowledge:[],trade:[],nature:[]},B=new Map,q=_createForOfIteratorHelper(h.items.filter((function(t){return"equipment"==t.type&&"bags"==t.system.equipmentType.value})));try{for(q.s();!($=q.n()).done;){var U=$.value;B.set(U._id,[])}}catch(t){q.e(t)}finally{q.f()}var Y,V=new Map,K=[],J=!1,Q=x.Z.getHorse(this,!0),X=_createForOfIteratorHelper(h.items);try{for(X.s();!(Y=X.n()).done;){var ee=Y.value;try{var te=getProperty(ee,"system.parent_id");if("ammunition"==ee.type&&K.push(Actordsa5._prepareitemStructure(ee)),te&&te!=ee._id&&B.has(te)){B.get(te).push(ee);continue}switch(t.details&&t.details.includes(ee._id)&&(ee.detailed="shown"),ee.system.isArtifact&&(ee.volume=i.Z.traditionArtifacts[ee.system.artifact]||0,ee.volumeFinal=0,R.push(ee)),ee.type){case"skill":W[ee.system.group.value].push(this._perpareItemAdvancementCost(ee));break;case"information":T.push(ee);break;case"aggregatedTest":b.push(ee);break;case"spellextension":G[ee.system.category][ee.system.source]?G[ee.system.category][ee.system.source].push(ee.name):G[ee.system.category][ee.system.source]=[ee.name];break;case"ritual":case"spell":case"liturgy":case"ceremony":L[ee.type].push(Actordsa5.buildSpellChargeProgress(this._perpareItemAdvancementCost(ee)));break;case"magicalsign":case"magictrick":case"blessing":L[ee.type].push(ee);break;case"trait":switch(ee.system.traitType.value){case"rangeAttack":ee=Actordsa5._prepareRangeTrait(ee);break;case"meleeAttack":ee=Actordsa5._prepareMeleetrait(ee);break;case"armor":Z+=Number(ee.system.at.value)}E[ee.system.traitType.value].push(ee),J=!0;break;case"combatskill":m.push(Actordsa5._calculateCombatSkillValues(ee,this.system));break;case"ammunition":z.ammunition.items.push(Actordsa5.prepareMag(ee)),z.ammunition.show=!0;break;case"meleeweapon":ee.toggleValue=ee.system.worn.value||!1,ee.toggle=!0,this._setOnUseEffect(ee),z.meleeweapons.items.push(Actordsa5._prepareitemStructure(ee)),z.meleeweapons.show=!0,ee.toggleValue&&S.push(ee);break;case"rangeweapon":ee.toggleValue=ee.system.worn.value||!1,ee.toggle=!0,this._setOnUseEffect(ee),z.rangeweapons.items.push(Actordsa5._prepareitemStructure(ee)),z.rangeweapons.show=!0;break;case"armor":ee.toggleValue=ee.system.worn.value||!1,z.armor.items.push(Actordsa5._prepareitemStructure(ee)),z.armor.show=!0,ee.toggle=!0,this._setOnUseEffect(ee),ee.system.worn.value&&(ee.system.protection.value=_.Z.armorWearModifier(ee,ee.system.protection.value),Z+=Number(ee.system.protection.value),C.push(ee));break;case"poison":case"plant":z[ee.type].items.push(ee),z[ee.type].show=!0;break;case"consumable":z[ee.system.equipmentType.value].items.push(Actordsa5._prepareConsumable(ee)),z[ee.system.equipmentType.value].show=!0;break;case"equipment":ee.toggle=getProperty(ee,"system.worn.wearable")||!1,ee.toggle&&(ee.toggleValue=ee.system.worn.value||!1),this._setOnUseEffect(ee),z[ee.system.equipmentType.value].items.push(Actordsa5._prepareitemStructure(ee)),z[ee.system.equipmentType.value].show=!0;break;case"money":H.coins.push(ee),H.total+=ee.system.quantity.value*ee.system.price.value;break;case"advantage":this._setOnUseEffect(ee),y.push(ee);break;case"disadvantage":this._setOnUseEffect(ee),v.push(ee);break;case"specialability":this._setOnUseEffect(ee),this._setAEPayments(ee),P[ee.system.category.value].push(ee);break;case"disease":k.push(ee);break;case"patron":P.magical.push(ee);break;case"demonmark":w.push(ee);break;case"essence":A.push(ee);break;case"imprint":O.push(ee);break;case"application":V.has(ee.system.skill)?V.get(ee.system.skill).push(ee):V.set(ee.system.skill,[ee])}}catch(t){this._itemPreparationError(ee,t)}}}catch(t){X.e(t)}finally{X.f()}var re,ne=_createForOfIteratorHelper(z.bags.items);try{for(ne.s();!(re=ne.n()).done;){var ae=re.value;this._setBagContent(ae,B)}}catch(t){ne.e(t)}finally{ne.f()}for(var oe=0,ie=Object.entries(G);oer.system.price.value?-1:1})),(r=P.magical).push.apply(r,_toConsumableArray(P.pact)),(a=P.clerical).push.apply(a,_toConsumableArray(P.ceremonial));var Se,Te=_createForOfIteratorHelper(P.staff);try{var Ae=function _loop6(){var t=Se.value,r=R.find((function(r){return r.system.artifact==t.system.artifact}));if(r){null==r.abilities&&(r.abilities=[]),r.abilities.push(t);var a=Number(t.system.volume)||0;r[a>0?"volumeFinal":"volume"]+=Math.abs(a)*Number(t.system.step.value)}else P.magical.push(t)};for(Te.s();!(Se=Te.n()).done;)Ae()}catch(t){Te.e(t)}finally{Te.f()}var Oe=duplicate(i.Z.characteristics);return Oe["-"]="-",{totalWeight:parseFloat(this.system.totalWeight.toFixed(3)),traditionArtifacts:R,armorSum:Z,spellArmor:h.system.spellArmor||0,liturgyArmor:h.system.liturgyArmor||0,money:H,encumbrance:(null===(c=this.system.condition)||void 0===c?void 0:c.encumbered)||0,carrycapacity:this.system.carrycapacity,isSwarm:this.isSwarm(),canSwarm:!this.prototypeToken.actorLink,wornRangedWeapons:D,wornMeleeWeapons:I,horseActor:Q,advantages:y,disadvantages:v,specAbs:P,information:T,aggregatedtests:b,wornArmor:C,essence:A,imprint:O,inventory:z,hasTrait:J,demonmarks:w,diseases:k,canBuild:game.dsa5.sheets.DSACharBuilder&&!(null!==(u=h.system.details.species)&&void 0!==u&&u.value),itemModifiers:this.system.itemModifiers,languagePoints:{used:(null===(l=h.system.freeLanguagePoints)||void 0===l?void 0:l.used)||0,available:(null===(p=h.system.freeLanguagePoints)||void 0===p?void 0:p.value)||0},schips:j,groupschips:M,guidevalues:Oe,magic:L,traits:E,combatskills:m,canAdvance:this.canAdvance,sheetLocked:h.system.sheetLocked.value,bodyAttrs:["ff","ge","ko","kk"],mentalAttrs:["mu","kl","in","ch"],allSkillsLeft:{body:W.body,social:W.social,nature:W.nature},allSkillsRight:{knowledge:W.knowledge,trade:W.trade}}}},{key:"isSwarm",value:function isSwarm(){return this.system.swarm.count>1&&!this.prototypeToken.actorLink}},{key:"getArmorEncumbrance",value:function getArmorEncumbrance(t,r){var a=r.reduce((function(t,r){return r.system.calculatedEncumbrance=Number(r.system.encumbrance.value)+_.Z.armorEncumbranceModifier(r),r.system.damageToolTip=_.Z.damageTooltip(r),t+r.system.calculatedEncumbrance}),0),o=x.Z.isRiding(this)?-1:0;return Math.max(0,a-d.Z.abilityStep(t,game.i18n.localize("LocalizedIDs.inuredToEncumbrance"))+o)}},{key:"_calcBagweight",value:function _calcBagweight(t,r){var a=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],o=0;if(r.has(t._id)){var i=0;!t.system.worn.value&&a&&(o-=t.system.preparedWeight);var c,u=_createForOfIteratorHelper(r.get(t._id));try{for(u.s();!(c=u.n()).done;){var l=c.value;l.system.preparedWeight=Number(parseFloat((l.system.weight.value*l.system.quantity.value).toFixed(3))),r.has(l._id)?i+=this._calcBagweight(l,r,!1):i+=l.system.preparedWeight}}catch(t){u.e(t)}finally{u.f()}a?t.system.worn.value&&(o+=i):o+=i+t.system.preparedWeight,t.system.bagweight="".concat(i.toFixed(3),"/").concat(t.system.capacity)}return o}},{key:"_setBagContent",value:function _setBagContent(t,r){if(r.has(t._id)){t.children=[];var a,o=_createForOfIteratorHelper(r.get(t._id));try{for(o.s();!(a=o.n()).done;){var i=a.value;t.children.push(Actordsa5._prepareitemStructure(Actordsa5._prepareConsumable(i))),r.has(i._id)&&this._setBagContent(i,r)}}catch(t){o.e(t)}finally{o.f()}}}},{key:"isMerchant",value:function isMerchant(){return["merchant","loot"].includes(getProperty(this,"system.merchant.merchantType"))}},{key:"_itemPreparationError",value:function _itemPreparationError(t,r){console.error("Something went wrong with preparing item "+t.name+": "+r),console.warn(r),console.warn(t),ui.notifications.error("Something went wrong with preparing item "+t.name+": "+r)}},{key:"_applyModiferTransformations",value:function _applyModiferTransformations(t){this.system.itemModifiers={};for(var r=0,a=Object.keys(t);r1&&void 0!==c[1]?c[1]:{},a=c.length>2&&void 0!==c[2]?c[2]:{},!Actordsa5.canAdvance(this)){u.next=13;break}if(isNaN(t)||null==t){u.next=12;break}return o=Number(t),r["system.details.experience.spent"]=Number(this.system.details.experience.spent)+o,u.next=8,this.update(r,a);case 8:i=game.i18n.format(o>0?"advancementCost":"refundCost",{cost:Math.abs(o)}),(0,v.p0)(i),u.next=13;break;case 12:ui.notifications.error(game.i18n.localize("DSAError.APUpdateError"));case 13:case"end":return u.stop()}}),_callee3,this)}))),function _updateAPs(t){return J.apply(this,arguments)})},{key:"checkEnoughXP",value:(K=_asyncToGenerator(_regeneratorRuntime().mark((function _callee4(t){var r,a,o,c,u;return _regeneratorRuntime().wrap((function _callee4$(l){for(;;)switch(l.prev=l.next){case 0:if(Actordsa5.canAdvance(this)){l.next=2;break}return l.abrupt("return",!0);case 2:if(!isNaN(t)&&null!=t){l.next=4;break}return l.abrupt("return",!0);case 4:if(!(Number(this.system.details.experience.total)-Number(this.system.details.experience.spent)>=t)){l.next=8;break}return l.abrupt("return",!0);case 8:if(0!=Number(this.system.details.experience.total)){l.next=24;break}return l.next=11,renderTemplate("systems/dsa5/templates/dialog/parts/expChoices.html",{entries:i.Z.startXP});case 11:return r=l.sent,a=0,o=!1,l.next=16,new Promise((function(t,a){new Dialog({title:game.i18n.localize("DSAError.NotEnoughXP"),content:r,default:"yes",buttons:{Yes:{icon:'',label:game.i18n.localize("yes"),callback:function callback(r){t([!0,r.find(".APsel")[0].value])}},cancel:{icon:'',label:game.i18n.localize("cancel"),callback:function callback(){t([!1,0])}}}}).render(!0)}));case 16:if(c=l.sent,u=_slicedToArray(c,2),o=u[0],a=u[1],!o){l.next=24;break}return l.next=23,this.update({"system.details.experience.total":Number(a)});case 23:return l.abrupt("return",!0);case 24:return ui.notifications.error(game.i18n.localize("DSAError.NotEnoughXP")),l.abrupt("return",!1);case 26:case"end":return l.stop()}}),_callee4,this)}))),function checkEnoughXP(t){return K.apply(this,arguments)})},{key:"setupWeapon",value:function setupWeapon(t,r,a,o){return a.mode=r,m.Z.getSubClass(t.type).setupDialog(null,a,t,this,o)}},{key:"setupWeaponless",value:function setupWeaponless(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},a=arguments.length>2?arguments[2]:void 0,o=foundry.utils.duplicate(i.Z.defaultWeapon);o.name=game.i18n.localize("".concat(t,"Weaponless")),o.system.combatskill={value:game.i18n.localize("LocalizedIDs.wrestle")},o.system.damageThreshold.value=14;var c=[];return d.Z.hasAbility(this,game.i18n.localize("LocalizedIDs.mightyAstralBody"))&&c.push(game.i18n.localize("magical")),d.Z.hasAbility(this,game.i18n.localize("LocalizedIDs.mightyKarmalBody"))&&c.push(game.i18n.localize("blessed")),mergeObject(o,{system:{effect:{attributes:c.join(", ")}}}),r.mode=t,m.Z.getSubClass(o.type).setupDialog(null,r,o,this,a)}},{key:"setupSpell",value:function setupSpell(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},a=arguments.length>2?arguments[2]:void 0;return m.Z.getSubClass(t.type).setupDialog(null,r,t,this,a)}},{key:"setupSkill",value:function setupSkill(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},a=arguments.length>2?arguments[2]:void 0;return m.Z.getSubClass(t.type).setupDialog(null,r,t,this,a)}},{key:"tokenScrollingText",value:function tokenScrollingText(t){var r,a,o=_createForOfIteratorHelper(this.isToken?[null===(r=this.token)||void 0===r?void 0:r.object]:this.getActiveTokens(!0));try{for(o.s();!(a=o.n()).done;){var i=a.value;if(i){var c,u=0,l=_createForOfIteratorHelper(t);try{for(l.s();!(c=l.n()).done;){var p=c.value;canvas.interface.createScrollingText(i.center,p.value,{anchor:u,direction:p.value>0?2:1,fontSize:game.settings.get("dsa5","scrollingFontsize"),stroke:p.stroke,strokeThickness:1,jitter:.25,duration:1e3}),u+=1}}catch(t){l.e(t)}finally{l.f()}}}}catch(t){o.e(t)}finally{o.f()}}},{key:"_preUpdate",value:(V=_asyncToGenerator(_regeneratorRuntime().mark((function _callee5(t,r,a){var o,i,c,u,l,p,d,h,m,y;return _regeneratorRuntime().wrap((function _callee5$(g){for(;;)switch(g.prev=g.next){case 0:return g.next=2,_get(_getPrototypeOf(Actordsa5.prototype),"_preUpdate",this).call(this,t,r,a);case 2:for(o={wounds:9109504,astralenergy:723929,karmaenergy:303670},i=[],c=0,u=Object.keys(o);c=0)){i.next=8;break}return i.next=5,this.update(_defineProperty({},"data.status.".concat(a,".value"),o));case 5:return i.abrupt("return",!0);case 8:return ui.notifications.error(game.i18n.localize("DSAError.NotEnough".concat(r))),i.abrupt("return",!1);case 10:case"end":return i.stop()}}),_callee8,this)}))),function applyMana(t,r){return q.apply(this,arguments)})},{key:"preparePostRollAction",value:function preparePostRollAction(t){var r=t.flags.data,a={flags:{img:t.flags.img},rollMode:r.rollMode,speaker:t.speaker,template:r.template,title:r.title,user:t.user};return r.attackerMessage&&(a.attackerMessage=r.attackerMessage),r.defenderMessage&&(a.defenderMessage=r.defenderMessage),r.unopposedStartMessage&&(a.unopposedStartMessage=r.unopposedStartMessage),a}},{key:"resetTargetAndMessage",value:function resetTargetAndMessage(t,r){var a;null!==(a=t.originalTargets)&&void 0!==a&&a.size&&(game.user.targets=t.originalTargets,game.user.targets.user=game.user),!t.defenderMessage&&t.startMessagesList&&(r.startMessagesList=t.startMessagesList)}},{key:"fatererollDamage",value:(B=_asyncToGenerator(_regeneratorRuntime().mark((function _callee9(t,r,a,i,u,l){var p,d,h;return _regeneratorRuntime().wrap((function _callee9$(m){for(;;)switch(m.prev=m.next){case 0:return r.fatePointDamageRerollUsed=!0,this.resetTargetAndMessage(u,r),p=u.postData.damageRoll,m.t0=c.Z,m.next=6,new Roll(p.formula||p._formula).evaluate({async:!0});case 6:return m.t1=m.sent,m.next=9,m.t0.manualRolls.call(m.t0,m.t1,"CHATCONTEXT.rerollDamage");case 9:for(d=m.sent,h=0;h'.concat(game.i18n.localize("CHATFATE.fatepointUsed"),"\n ").concat(game.i18n.format("CHATFATE.isTalented",{character:""+this.name+""}),"
"),h.next=5,renderTemplate("systems/dsa5/templates/dialog/isTalentedReroll-dialog.html",{testData:a,postData:u.postData});case 5:p=h.sent,new l.Z({title:game.i18n.localize("CHATFATE.selectDice"),content:p,buttons:{Yes:{icon:'',label:game.i18n.localize("Ok"),callback:function(){var l=_asyncToGenerator(_regeneratorRuntime().mark((function _callee10(l){var p,h,m,y,g,v,_,b,k,w,x,S,T;return _regeneratorRuntime().wrap((function _callee10$(A){for(;;)switch(A.prev=A.next){case 0:if(!((p=l.find(".dieSelected").map((function(){return Number($(this).attr("data-index"))})).get()).length>0)){A.next=23;break}h=[],m=_createForOfIteratorHelper(p);try{for(m.s();!(y=m.n()).done;)g=y.value,v=a.roll.terms[2*g],h.push(v.number+"d"+v.faces+"["+v.options.colorset+"]")}catch(t){m.e(t)}finally{m.f()}return A.t0=c.Z,A.next=8,new Roll(h.join("+")).evaluate({async:!0});case 8:return A.t1=A.sent,A.next=11,A.t0.manualRolls.call(A.t0,A.t1,"CHATCONTEXT.talentedReroll");case 11:return h=A.sent,A.next=14,c.Z.showDiceSoNice(h,a.rollMode);case 14:_=0,b=[],k=_createForOfIteratorHelper(p);try{for(k.s();!(w=k.n()).done;)x=w.value,S=a.source.system["characteristic".concat(x+1)],T=S?game.i18n.localize("CHARAbbrev.".concat(S.value.toUpperCase()))+" - ":"",b.push("".concat(T).concat(a.roll.terms[2*x].results[0].result,"/").concat(h.terms[2*_].results[0].result)),a.roll.terms[2*x].results[0].result=Math.min(h.terms[2*_].results[0].result,a.roll.terms[2*x].results[0].result),_+=1}catch(t){k.e(t)}finally{k.f()}return t+="".concat(game.i18n.localize("Roll"),": ").concat(b.join(", ")),ChatMessage.create(o.Z.chatDataSetup(t)),d["".concat(u.postData.postFunction)]({testData:a,cardOptions:r},{rerenderMessage:i}),A.next=23,i.update({"flags.data.talentedRerollUsed":!0});case 23:case"end":return A.stop()}}),_callee10)})));return function callback(t){return l.apply(this,arguments)}}()},cancel:{icon:'',label:game.i18n.localize("cancel")}},default:"Yes"}).render(!0);case 7:case"end":return h.stop()}}),_callee11,this)}))),function fateisTalented(t,r,a,o,i){return W.apply(this,arguments)})},{key:"fatereroll",value:(Z=_asyncToGenerator(_regeneratorRuntime().mark((function _callee13(t,r,a,i,u,p){var d,h=this;return _regeneratorRuntime().wrap((function _callee13$(m){for(;;)switch(m.prev=m.next){case 0:return r.fatePointDamageRerollUsed=!0,this.resetTargetAndMessage(u,r),m.next=4,renderTemplate("systems/dsa5/templates/dialog/fateReroll-dialog.html",{testData:a,postData:u.postData,singleDie:1==u.postData.characteristics.length});case 4:d=m.sent,new l.Z({title:game.i18n.localize("CHATFATE.selectDice"),content:d,buttons:{Yes:{icon:'',label:game.i18n.localize("Ok"),callback:function(){var l=_asyncToGenerator(_regeneratorRuntime().mark((function _callee12(l){var d,m,y,g,v,_,b,k,w,x,S,T,A,O,P,E;return _regeneratorRuntime().wrap((function _callee12$(C){for(;;)switch(C.prev=C.next){case 0:if(!((d=l.find(".dieSelected").map((function(){return Number($(this).attr("data-index"))})).get()).length>0)){C.next=28;break}m=[],y=_createForOfIteratorHelper(d);try{for(y.s();!(g=y.n()).done;)v=g.value,_=a.roll.terms[2*v],m.push(_.number+"d"+_.faces+"["+_.options.colorset+"]")}catch(t){y.e(t)}finally{y.f()}return C.t0=c.Z,C.next=8,new Roll(m.join("+")).evaluate({async:!0});case 8:return C.t1=C.sent,C.next=11,C.t0.manualRolls.call(C.t0,C.t1,"CHATCONTEXT.Reroll");case 11:return m=C.sent,C.next=14,c.Z.showDiceSoNice(m,a.rollMode);case 14:b=0,k=[],w=o.Z.getSpeaker(a.extra.speaker),x=game.i18n.localize("LocalizedIDs.traditionPhex"),S=w.items.some((function(t){return"specialability"==t.type&&t.name==x})),T=_createForOfIteratorHelper(d);try{for(T.s();!(A=T.n()).done;)O=A.value,P=a.source.system["characteristic".concat(O+1)],E=P?"".concat(game.i18n.localize("CHARAbbrev.".concat(P.value.toUpperCase()))," - "):"",k.push("".concat(E).concat(a.roll.terms[2*O].results[0].result,"/").concat(m.terms[2*b].results[0].result)),a.roll.terms[2*O].results[0].result=S?Math.min(m.terms[2*b].results[0].result,a.roll.terms[2*O].results[0].result):m.terms[2*b].results[0].result,b+=1}catch(t){T.e(t)}finally{T.f()}return t+="
".concat(game.i18n.localize("Roll"),": ").concat(k.join(", ")),ChatMessage.create(o.Z.chatDataSetup(t)),h["".concat(u.postData.postFunction)]({testData:a,cardOptions:r},{rerenderMessage:i}),C.next=26,i.update({"flags.data.fatePointRerollUsed":!0});case 26:return C.next=28,h.reduceSchips(p);case 28:case"end":return C.stop()}}),_callee12)})));return function callback(t){return l.apply(this,arguments)}}()},cancel:{icon:'',label:game.i18n.localize("cancel")}},default:"Yes"}).render(!0);case 6:case"end":return m.stop()}}),_callee13,this)}))),function fatereroll(t,r,a,o,i,c){return Z.apply(this,arguments)})},{key:"fateaddQS",value:(H=_asyncToGenerator(_regeneratorRuntime().mark((function _callee14(t,r,a,i,c,u){return _regeneratorRuntime().wrap((function _callee14$(l){for(;;)switch(l.prev=l.next){case 0:return ChatMessage.create(o.Z.chatDataSetup(t)),game.user.targets.forEach((function(t){return t.setTarget(!1,{user:game.user,releaseOthers:!1,groupSelection:!0})})),r.fatePointAddQSUsed=!0,a.qualityStep=1,this["".concat(c.postData.postFunction)]({testData:a,cardOptions:r},{rerenderMessage:i}),l.next=7,i.update({"flags.data.fatePointAddQSUsed":!0});case 7:return l.next=9,this.reduceSchips(u);case 9:case"end":return l.stop()}}),_callee14,this)}))),function fateaddQS(t,r,a,o,i,c){return H.apply(this,arguments)})},{key:"fateImprove",value:(N=_asyncToGenerator(_regeneratorRuntime().mark((function _callee16(t,r,a,i,c,u){var p,d,h,m=this;return _regeneratorRuntime().wrap((function _callee16$(y){for(;;)switch(y.prev=y.next){case 0:if(ChatMessage.create(o.Z.chatDataSetup(t)),this.resetTargetAndMessage(c,r),p=i.flags.data.preData.source.type,!["spell","liturgy","ceremony","ritual","skill"].includes(p)){y.next=10;break}return y.next=6,renderTemplate("systems/dsa5/templates/dialog/fateImprove-dialog.html",{testData:a,postData:c.postData});case 6:d=y.sent,new l.Z({title:game.i18n.localize("CHATFATE.selectDice"),content:d,buttons:{Yes:{icon:'',label:game.i18n.localize("Ok"),callback:function(){var t=_asyncToGenerator(_regeneratorRuntime().mark((function _callee15(t){var o,l,p;return _regeneratorRuntime().wrap((function _callee15$(d){for(;;)switch(d.prev=d.next){case 0:if(o=[0,0,0],1!=(l=t.find(".dieSelected").map((function(){return Number($(this).attr("data-index"))})).get()).length){d.next=12;break}return o[l]=2,p={name:game.i18n.localize("CHATCONTEXT.improveFate"),value:o.join("|"),type:"roll"},a.roll.terms[2*l].results[0].result=Math.max(1,a.roll.terms[2*l].results[0].result-2),a.situationalModifiers.push(p),m["".concat(c.postData.postFunction)]({testData:a,cardOptions:r},{rerenderMessage:i}),d.next=10,i.update({"flags.data.fateImproved":!0});case 10:return d.next=12,m.reduceSchips(u);case 12:case"end":return d.stop()}}),_callee15)})));return function callback(r){return t.apply(this,arguments)}}()},cancel:{icon:'',label:game.i18n.localize("cancel")}},default:"Yes"}).render(!0),y.next=18;break;case 10:return h={name:game.i18n.localize("CHATCONTEXT.improveFate"),value:2,type:"roll"},a.situationalModifiers.push(h),a.roll.terms[0].results[0].result=Math.max(1,a.roll.terms[0].results[0].result-2),this["".concat(c.postData.postFunction)]({testData:a,cardOptions:r},{rerenderMessage:i}),y.next=16,i.update({"flags.data.fateImproved":!0});case 16:return y.next=18,this.reduceSchips(u);case 18:case"end":return y.stop()}}),_callee16,this)}))),function fateImprove(t,r,a,o,i,c){return N.apply(this,arguments)})},{key:"reduceSchips",value:(z=_asyncToGenerator(_regeneratorRuntime().mark((function _callee17(t){return _regeneratorRuntime().wrap((function _callee17$(r){for(;;)switch(r.prev=r.next){case 0:if(0!=t){r.next=5;break}return r.next=3,this.update({"system.status.fatePoints.value":this.system.status.fatePoints.value-1});case 3:r.next=7;break;case 5:return r.next=7,Actordsa5.reduceGroupSchip();case 7:case"end":return r.stop()}}),_callee17,this)}))),function reduceSchips(t){return z.apply(this,arguments)})},{key:"useFateOnRoll",value:(j=_asyncToGenerator(_regeneratorRuntime().mark((function _callee18(t,r,a){var i,c,u,l,p,d;return _regeneratorRuntime().wrap((function _callee18$(h){for(;;)switch(h.prev=h.next){case 0:("isTalented"==r||o.Z.fateAvailable(this,1==a))&&(i=t.flags.data,c=this.preparePostRollAction(t),0==a?(u=this.system.status.fatePoints.value-1,l="PointsRemaining"):(u=game.settings.get("dsa5","groupschips").split("/")[0],l="GroupPointsRemaining"),p='

'.concat(game.i18n.localize("CHATFATE.fatepointUsed"),"

\n ").concat(game.i18n.format("CHATFATE."+r,{character:""+this.name+""}),"
\n ").concat(game.i18n.localize("CHATFATE.".concat(l)),": ").concat(u),(d=i.preData).extra.actor=o.Z.getSpeaker(d.extra.speaker).toObject(!1),this["fate".concat(r)](p,c,d,t,i,a));case 1:case"end":return h.stop()}}),_callee18,this)}))),function useFateOnRoll(t,r,a){return j.apply(this,arguments)})},{key:"horseSpeed",get:function get(){return x.Z.getHorseSpeed(this)}},{key:"setupFallingDamage",value:function setupFallingDamage(t,r){var a=this,o=game.i18n.localize("fallingDamage"),i=this.items.find((function(t){return"skill"==t.type&&t.name==game.i18n.localize("LocalizedIDs.bodyControl")})).toObject(),u={subtitle:" (".concat(o,")"),postFunction:{functionName:"game.dsa5.entities.Actordsa5.updateFallingDamage",options:t,tokenId:r,speaker:m.Z.buildSpeaker(this,r)}};this.setupSkill(i,u,r).then(function(){var t=_asyncToGenerator(_regeneratorRuntime().mark((function _callee19(t){var r;return _regeneratorRuntime().wrap((function _callee19$(o){for(;;)switch(o.prev=o.next){case 0:return t.testData.opposable=!1,o.next=3,a.basicTest(t,{suppressMessage:!0});case 3:return r=o.sent,o.next=6,Actordsa5.updateFallingDamage(u.postFunction,r);case 6:return o.next=8,c.Z.renderRollCard(r.cardOptions,r.result,r.options.rerenderMessage);case 8:case"end":return o.stop()}}),_callee19)})));return function(r){return t.apply(this,arguments)}}())}},{key:"_setupFallingHeight",value:function _setupFallingHeight(t,r){var a=game.i18n.localize("fallingDamage"),o={source:{type:"fallingDamage"},opposable:!1,extra:{actor:this.toObject(!1),options:t,speaker:m.Z.buildSpeaker(this,r)}},u={title:a,template:"/systems/dsa5/templates/dialog/fallingdamage-dialog.html",data:{rollMode:t.rollMode,situationalModifiers:[],fallingFloorOptions:i.Z.fallingConditions,modifier:t.modifier||0},callback:function callback(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return o.situationalModifiers=[],o.situationalModifiers.push({name:game.i18n.localize("fallingFloor"),value:t.find('[name="fallingFloor"]').val()}),l.rollMode=t.find('[name="rollMode"]').val(),o.fallingHeight=t.find('[name="testModifier"]').val(),mergeObject(o.extra.options,r),{testData:o,cardOptions:l}}},l=this._setupCardOptions("systems/dsa5/templates/chat/roll/fallingdamage-card.html",a,r);return c.Z.setupDialog({dialogOptions:u,testData:o,cardOptions:l})}},{key:"setupRegeneration",value:function setupRegeneration(t){var r=this,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=arguments.length>2?arguments[2]:void 0,u=game.i18n.localize("regenerationTest"),l={source:{type:"regenerate",system:{}},opposable:!1,extra:{statusId:t,actor:this.toObject(!1),options:a,speaker:m.Z.buildSpeaker(this,o)}};l.extra.actor.isMage=this.system.isMage,l.extra.actor.isPriest=this.system.isPriest;var p=h.Z.getRollModifiers(l.extra.actor,l.source),d={title:u,template:"/systems/dsa5/templates/dialog/regeneration-dialog.html",data:{rollMode:a.rollMode,regenerationInterruptOptions:i.Z.regenerationInterruptOptions,regnerationCampLocations:i.Z.regnerationCampLocations,showAspModifier:this.system.isMage,showKapModifier:this.system.isPriest,situationalModifiers:p,modifier:a.modifier||0},callback:function callback(t){var a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};l.situationalModifiers=Actordsa5._parseModifiers(t),y.rollMode=t.find('[name="rollMode"]').val(),l.situationalModifiers.push({name:game.i18n.localize("camplocation")+" - "+t.find('[name="regnerationCampLocations"] option:selected').text(),value:t.find('[name="regnerationCampLocations"]').val()},{name:game.i18n.localize("interruption")+" - "+t.find('[name="regenerationInterruptOptions"] option:selected').text(),value:t.find('[name="regenerationInterruptOptions"]').val()}),l.regenerationFactor=t.find('[name="badEnvironment"]').is(":checked")?.5:1;for(var o=["LeP","KaP","AsP"],i={},c=0,u=o;c0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1?arguments[1]:void 0,a="dodge",o=this.system.status[a],i=game.i18n.localize(a)+" "+game.i18n.localize("Test"),u={source:{system:o,type:a},opposable:!1,extra:{statusId:a,actor:this.toObject(!1),options:t,speaker:m.Z.buildSpeaker(this,r)}},l=[game.i18n.localize(a),game.i18n.localize("LocalizedIDs.wrestle")],p=m.Z.buildCombatSpecAbs(this,["Combat"],l,"parry"),d=h.Z.getRollModifiers(u.extra.actor,u.source),y=m.Z.getDefenseMalus(d,this),v=g.Z.multipleDefenseValue(this,u.source),_={title:i,template:"/systems/dsa5/templates/dialog/combatskill-enhanced-dialog.html",data:{rollMode:t.rollMode,combatSpecAbs:p,showDefense:!0,situationalModifiers:d,isRangeAttack:y,defenseCountString:game.i18n.format("defenseCount",{malus:v}),isDodge:!0},callback:function callback(t){var r,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return b.rollMode=t.find('[name="rollMode"]').val(),u.situationalModifiers=Actordsa5._parseModifiers(t),(r=u.situationalModifiers).push.apply(r,_toConsumableArray(m.Z.getSpecAbModifiers(t,"parry"))),u.situationalModifiers.push({name:game.i18n.localize("attackFromBehind"),value:t.find('[name="attackFromBehind"]').is(":checked")?-4:0},{name:game.i18n.format("defenseCount",{malus:v}),value:(Number(t.find('[name="defenseCount"]').val())||0)*v},{name:game.i18n.localize("advantageousPosition"),value:t.find('[name="advantageousPosition"]').is(":checked")?2:0}),mergeObject(u.extra.options,a),{testData:u,cardOptions:b}}},b=this._setupCardOptions("systems/dsa5/templates/chat/roll/status-card.html",i,r);return c.Z.setupDialog({dialogOptions:_,testData:u,cardOptions:b})}},{key:"setupCharacteristic",value:function setupCharacteristic(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},a=arguments.length>2?arguments[2]:void 0,u=duplicate(this.system.characteristics[t]),l=o.Z.attributeLocalization(t)+" "+game.i18n.localize("Test");u.attr=t;var p={opposable:!1,source:{type:"char",system:u},extra:{characteristicId:t,actor:this.toObject(!1),options:r,speaker:m.Z.buildSpeaker(this,a)}},d={title:l,template:"/systems/dsa5/templates/dialog/characteristic-dialog.html",data:{rollMode:r.rollMode,difficultyLabels:i.Z.attributeDifficultyLabels,modifier:r.modifier||0},callback:function callback(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return h.rollMode=t.find('[name="rollMode"]').val(),p.testDifficulty=i.Z.attributeDifficultyModifiers[t.find('[name="testDifficulty"]').val()],p.situationalModifiers=Actordsa5._parseModifiers(t),mergeObject(p.extra.options,r),{testData:p,cardOptions:h}}},h=this._setupCardOptions("systems/dsa5/templates/chat/roll/characteristic-card.html",l,a);return c.Z.setupDialog({dialogOptions:d,testData:p,cardOptions:h})}},{key:"actorEffects",value:(M=_asyncToGenerator(_regeneratorRuntime().mark((function _callee20(){var t,r;return _regeneratorRuntime().wrap((function _callee20$(a){for(;;)switch(a.prev=a.next){case 0:return t=["dead"],r=game.user.isGM||this.testUserPermission(game.user,"OBSERVER")||!game.settings.get("dsa5","hideEffects"),a.abrupt("return",r?this.effects.filter((function(t){return t.isVisibleEffect()})):this.effects.filter((function(r){return t.some((function(t){return r.statuses.has(t)}))})));case 3:case"end":return a.stop()}}),_callee20,this)}))),function actorEffects(){return M.apply(this,arguments)})},{key:"_preCreate",value:(G=_asyncToGenerator(_regeneratorRuntime().mark((function _callee21(t,r,a){var o;return _regeneratorRuntime().wrap((function _callee21$(i){for(;;)switch(i.prev=i.next){case 0:return i.next=2,_get(_getPrototypeOf(Actordsa5.prototype),"_preCreate",this).call(this,t,r,a);case 2:o={},t.img||(o.img="icons/svg/mystery-man-black.svg"),"character"==t.type&&mergeObject(o,{prototypeToken:{sight:{enabled:!0},actorLink:!0}}),this.updateSource(o);case 6:case"end":return i.stop()}}),_callee21,this)}))),function _preCreate(t,r,a){return G.apply(this,arguments)})},{key:"_setupCardOptions",value:function _setupCardOptions(t,r,a){var o,i,c=null===(o=game.canvas)||void 0===o||null===(i=o.tokens)||void 0===i?void 0:i.get(a),u={speaker:{alias:c?c.name:this.prototypeToken.name,actor:this.id},title:r,template:t,flags:{img:this.prototypeToken.randomImg?this.img:this.prototypeToken.img}};if(this.token)u.speaker.alias=this.token.name,u.speaker.token=this.token.id,u.speaker.scene=canvas.scene.id,u.flags.img=this.token.img;else{var l=ChatMessage.getSpeaker();l.actor==this.id&&(u.speaker.alias=l.alias,u.speaker.token=l.token,u.speaker.scene=l.scene,u.flags.img=l.token?canvas.tokens.get(l.token).img:u.flags.img)}return u}},{key:"swapMag",value:(L=_asyncToGenerator(_regeneratorRuntime().mark((function _callee22(t){var r,a;return _regeneratorRuntime().wrap((function _callee22$(o){for(;;)switch(o.prev=o.next){case 0:if(r=this.items.get(t),!((a=this.items.get(r.system.currentAmmo.value))&&a.system.quantity.value>1)){o.next=7;break}return o.next=5,this.updateEmbeddedDocuments("Item",[{_id:a.id,"system.quantity.value":a.system.quantity.value-1,"system.mag.value":a.system.mag.max}]);case 5:return k.Z.playEquipmentWearStatusChange(a),o.abrupt("return",a);case 7:return ui.notifications.error(game.i18n.localize("DSAError.NoAmmo")),o.abrupt("return",void 0);case 9:case"end":return o.stop()}}),_callee22,this)}))),function swapMag(t){return L.apply(this,arguments)})},{key:"payMiracles",value:(R=_asyncToGenerator(_regeneratorRuntime().mark((function _callee23(t){var r,a,o;return _regeneratorRuntime().wrap((function _callee23$(i){for(;;)switch(i.prev=i.next){case 0:if(t.extra.miraclePaid){i.next=8;break}if(t.extra.miraclePaid=!0,r=t.situationalModifiers.some((function(t){return t.name.trim()==game.i18n.localize("LocalizedIDs.miracleMight")})),a=t.situationalModifiers.some((function(t){return t.name.trim()==game.i18n.localize("LocalizedIDs.miracle")})),!(o=r?6:a?4:0)){i.next=8;break}return i.next=8,this.update({"system.status.karmaenergy.value":this.system.status.karmaenergy.value-o});case 8:case"end":return i.stop()}}),_callee23,this)}))),function payMiracles(t){return R.apply(this,arguments)})},{key:"consumeAmmunition",value:(I=_asyncToGenerator(_regeneratorRuntime().mark((function _callee24(t){var r;return _regeneratorRuntime().wrap((function _callee24$(a){for(;;)switch(a.prev=a.next){case 0:if(!t.extra.ammo||t.extra.ammoDecreased){a.next=9;break}if(t.extra.ammoDecreased=!0,!t.extra.ammo._id){a.next=7;break}return r={_id:t.extra.ammo._id},"mag"==t.extra.ammo.system.ammunitiongroup.value?t.extra.ammo.system.mag.value<=0?(t.extra.ammo.system.quantity.value--,r["system.quantity.value"]=t.extra.ammo.system.quantity.value,r["system.mag.value"]=t.extra.ammo.system.mag.max-1):r["system.mag.value"]=t.extra.ammo.system.mag.value-1:(t.extra.ammo.system.quantity.value--,r["system.quantity.value"]=t.extra.ammo.system.quantity.value),a.next=7,this.updateEmbeddedDocuments("Item",[r,{_id:t.source._id,"system.reloadTime.progress":0}]);case 7:case 13:a.next=18;break;case 9:if("rangeweapon"!=t.source.type&&("trait"!=t.source.type||"rangeAttack"!=t.source.system.traitType.value)||t.extra.ammoDecreased){a.next=15;break}return t.extra.ammoDecreased=!0,a.next=13,this.updateEmbeddedDocuments("Item",[{_id:t.source._id,"system.reloadTime.progress":0}]);case 15:if(!["spell","liturgy"].includes(t.source.type)||"emptyActor"==t.extra.speaker.token){a.next=18;break}return a.next=18,this.updateEmbeddedDocuments("Item",[{_id:t.source._id,"system.castingTime.progress":0,"system.castingTime.modified":0}]);case 18:case"end":return a.stop()}}),_callee24,this)}))),function consumeAmmunition(t){return I.apply(this,arguments)})},{key:"_checkMaximumItemAdvancement",value:function _checkMaximumItemAdvancement(t,r){var a=this,o=0;switch(t.type){case"combatskill":o=Math.max.apply(Math,_toConsumableArray(t.system.guidevalue.value.split("/").map((function(t){return a.system.characteristics[t].value}))))+2+p.Z.vantageStep(this,"".concat(game.i18n.localize("LocalizedIDs.exceptionalCombatTechnique")," (").concat(t.name,")"));break;case"spell":case"ritual":var i,c=0,u=_createForOfIteratorHelper(t.system.feature.replace(/\(a-z äöü\-\)/gi,"").split(",").map((function(t){return t.trim()})));try{for(u.s();!(i=u.n()).done;){var l=i.value;if(d.Z.hasAbility(this,"".concat(game.i18n.localize("LocalizedIDs.propertyKnowledge")," (").concat(l,")"))){c=this.maxByAttr(t);break}}}catch(t){u.e(t)}finally{u.f()}o=Math.max(14+p.Z.vantageStep(this,"".concat(game.i18n.localize("LocalizedIDs.exceptionalSkill")," (").concat(t.name,")")),c);break;case"liturgy":case"ceremony":var h=new RegExp("^".concat(game.i18n.localize("LocalizedIDs.aspectKnowledge"))),m=0;this.items.filter((function(t){return"specialability"==t.type&&h.test(t.name)})).some((function(r){return t.system.distribution.value.includes(r.name.split("(")[1].split(")")[0])}))&&(m=this.maxByAttr(t)),o=Math.max(14+p.Z.vantageStep(this,"".concat(game.i18n.localize("LocalizedIDs.exceptionalSkill")," (").concat(t.name,")")),m);break;case"skill":o=this.maxByAttr(t)}var y=r<=o;return y||ui.notifications.error(game.i18n.localize("DSAError.AdvanceMaximumReached")),{result:y,max:o}}},{key:"maxByAttr",value:function maxByAttr(t){return Math.max.apply(Math,[this.system.characteristics[t.system.characteristic1.value].value,this.system.characteristics[t.system.characteristic2.value].value,this.system.characteristics[t.system.characteristic3.value].value])+2+p.Z.vantageStep(this,"".concat(game.i18n.localize("LocalizedIDs.exceptionalSkill")," (").concat(t.name,")"))}},{key:"basicTest",value:(D=_asyncToGenerator(_regeneratorRuntime().mark((function _callee25(t){var r,a,o,i,l,p,d,h=arguments;return _regeneratorRuntime().wrap((function _callee25$(m){for(;;)switch(m.prev=m.next){case 0:return r=t.testData,a=t.cardOptions,o=h.length>1&&void 0!==h[1]?h[1]:{},m.next=4,c.Z.rollDices(r,a);case 4:return r=m.sent,m.next=7,c.Z.rollTest(r);case 7:return i=m.sent,r.extra.options.other&&(i.other||(i.other=[]),(l=i.other).push.apply(l,_toConsumableArray(r.extra.options.other))),i.postFunction="basicTest",game.user.targets.size&&(a.isOpposedTest=r.opposable,p=" - ".concat(game.i18n.localize("Opposed")),a.isOpposedTest&&a.title.match(p+"$")!=p&&(a.title+=p)),m.next=13,this.consumeAmmunition(r);case 13:return m.next=15,this.payMiracles(r);case 15:if(o.suppressMessage){m.next=22;break}return m.next=18,c.Z.renderRollCard(a,i,o.rerenderMessage);case 18:return d=m.sent,m.next=21,u.Z.handleOpposedTarget(d);case 21:i.messageId=d.id;case 22:return m.abrupt("return",{result:i,cardOptions:a,options:o});case 23:case"end":return m.stop()}}),_callee25,this)}))),function basicTest(t){return D.apply(this,arguments)})},{key:"addCondition",value:(C=_asyncToGenerator(_regeneratorRuntime().mark((function _callee26(t){var r,a,o,i,c=arguments;return _regeneratorRuntime().wrap((function _callee26$(u){for(;;)switch(u.prev=u.next){case 0:if(a=c.length>1&&void 0!==c[1]?c[1]:1,o=c.length>2&&void 0!==c[2]&&c[2],i=!(c.length>3&&void 0!==c[3])||c[3],"bleeding"!=t&&"bleeding"!=t.id){u.next=7;break}return u.next=6,g.Z.bleedingMessage(this);case 6:case 12:return u.abrupt("return",u.sent);case 7:if(!this.isToken||null!==(r=this.token)&&void 0!==r&&r.object){u.next=10;break}return console.warn("Actor token object is null for",this.name),u.abrupt("return");case 10:return u.next=12,h.Z.addCondition(this,t,a,o,i);case 13:case"end":return u.stop()}}),_callee26,this)}))),function addCondition(t){return C.apply(this,arguments)})},{key:"addTimedCondition",value:(E=_asyncToGenerator(_regeneratorRuntime().mark((function _callee27(t){var r,a,o,i,c=arguments;return _regeneratorRuntime().wrap((function _callee27$(u){for(;;)switch(u.prev=u.next){case 0:if(r=c.length>1&&void 0!==c[1]?c[1]:1,a=c.length>2&&void 0!==c[2]&&c[2],o=!(c.length>3&&void 0!==c[3])||c[3],i=c.length>4&&void 0!==c[4]?c[4]:{},"bleeding"!=t&&"bleeding"!=t.id){u.next=8;break}return u.next=7,g.Z.bleedingMessage(this);case 7:case 11:return u.abrupt("return",u.sent);case 8:return"string"==typeof t&&i.duration&&((t=duplicate(CONFIG.statusEffects.find((function(r){return r.id==t})))).flags.dsa5.description=game.i18n.localize(t.name),t.name=game.i18n.localize(t.name),delete t.description,delete t.flags.dsa5.value,delete t.flags.dsa5.max,delete t.id,mergeObject(t,i)),u.next=11,h.Z.addCondition(this,t,r,a,o);case 12:case"end":return u.stop()}}),_callee27,this)}))),function addTimedCondition(t){return E.apply(this,arguments)})},{key:"initResistPainRoll",value:(P=_asyncToGenerator(_regeneratorRuntime().mark((function _callee28(t){var r,a;return _regeneratorRuntime().wrap((function _callee28$(t){for(;;)switch(t.prev=t.next){case 0:if(r=game.settings.get("dsa5","selfControlOnPain"),!this.hasCondition("incapacitated")){t.next=3;break}return t.abrupt("return");case 3:if(2!=r&&(1!=r||this.hasPlayerOwner)){t.next=7;break}return t.next=6,this.addCondition("incapacitated");case 6:return t.abrupt("return");case 7:return t.next=9,renderTemplate("systems/dsa5/templates/chat/roll/resist-pain.html",{actor:this});case 9:return a=t.sent,t.next=12,ChatMessage.create(o.Z.chatDataSetup(a));case 12:case"end":return t.stop()}}),_callee28,this)}))),function initResistPainRoll(t){return P.apply(this,arguments)})},{key:"finishResistPainRoll",value:(O=_asyncToGenerator(_regeneratorRuntime().mark((function _callee30(){var t,r,a=this;return _regeneratorRuntime().wrap((function _callee30$(o){for(;;)switch(o.prev=o.next){case 0:r=this.items.find((function(t){return t.name==game.i18n.localize("LocalizedIDs.selfControl")&&"skill"==t.type})),this.setupSkill(r,{subtitle:" (".concat(game.i18n.localize("ActiveEffects.resistRoll"),")")},null===(t=this.token)||void 0===t?void 0:t.id).then(function(){var t=_asyncToGenerator(_regeneratorRuntime().mark((function _callee29(t){return _regeneratorRuntime().wrap((function _callee29$(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,a.basicTest(t);case 2:(r.sent.result.successLevel||0)<1&&a.addCondition("incapacitated");case 5:case"end":return r.stop()}}),_callee29)})));return function(r){return t.apply(this,arguments)}}());case 2:case"end":return o.stop()}}),_callee30,this)}))),function finishResistPainRoll(){return O.apply(this,arguments)})},{key:"removeCondition",value:(A=_asyncToGenerator(_regeneratorRuntime().mark((function _callee31(t){var r,a,o,i=arguments;return _regeneratorRuntime().wrap((function _callee31$(c){for(;;)switch(c.prev=c.next){case 0:return r=i.length>1&&void 0!==i[1]?i[1]:1,a=!(i.length>2&&void 0!==i[2])||i[2],o=i.length>3&&void 0!==i[3]&&i[3],c.next=5,h.Z.removeCondition(this,t,r,a,o);case 5:return c.abrupt("return",c.sent);case 6:case"end":return c.stop()}}),_callee31,this)}))),function removeCondition(t){return A.apply(this,arguments)})},{key:"hasCondition",value:function hasCondition(t){return h.Z.hasCondition(this,t)}},{key:"markDead",value:(T=_asyncToGenerator(_regeneratorRuntime().mark((function _callee32(t){var r,a,o,i;return _regeneratorRuntime().wrap((function _callee32$(c){for(;;)switch(c.prev=c.next){case 0:r=this.getActiveTokens(),a=_createForOfIteratorHelper(r),c.prev=2,a.s();case 4:if((o=a.n()).done){c.next=11;break}if(!(i=o.value).combatant){c.next=9;break}return c.next=9,i.combatant.update({defeated:t});case 9:c.next=4;break;case 11:c.next=16;break;case 13:c.prev=13,c.t0=c.catch(2),a.e(c.t0);case 16:return c.prev=16,a.f(),c.finish(16);case 19:case"end":return c.stop()}}),_callee32,this,[[2,13,16,19]])}))),function markDead(t){return T.apply(this,arguments)})}],[{key:"create",value:(S=_asyncToGenerator(_regeneratorRuntime().mark((function _callee33(t,r){var a,i,c;return _regeneratorRuntime().wrap((function _callee33$(u){for(;;)switch(u.prev=u.next){case 0:if(!(t instanceof Array||t.items)){u.next=4;break}return u.next=3,_get(_getPrototypeOf(Actordsa5),"create",this).call(this,t,r);case 3:return u.abrupt("return",u.sent);case 4:return t.img&&"icons/svg/mystery-man.svg"!=t.img||(t.img="icons/svg/mystery-man-black.svg"),u.next=7,o.Z.allSkills();case 7:if(u.t0=u.sent,u.t0){u.next=10;break}u.t0=[];case 10:return a=u.t0,u.next=13,o.Z.allCombatSkills();case 13:if(u.t1=u.sent,u.t1){u.next=16;break}u.t1=[];case 16:return i=u.t1,u.next=19,o.Z.allMoneyItems();case 19:if(u.t2=u.sent,u.t2){u.next=22;break}u.t2=[];case 22:return c=u.t2,t.items=[].concat(_toConsumableArray(a),_toConsumableArray(i),_toConsumableArray(c)),"character"!=t.type&&(t.system={status:{fatePoints:{current:0,value:0}}}),"creature"!=t.type&&[void 0,0].includes(getProperty(t,"system.status.wounds.value"))&&mergeObject(t,{system:{status:{wounds:{value:16}}}}),u.next=28,_get(_getPrototypeOf(Actordsa5),"create",this).call(this,t,r);case 28:return u.abrupt("return",u.sent);case 29:case"end":return u.stop()}}),_callee33,this)}))),function create(t,r){return S.apply(this,arguments)})},{key:"lockedCondition",value:function lockedCondition(){return{id:"locked",name:game.i18n.localize("MERCHANT.locked"),icon:"icons/svg/padlock.svg",flags:{dsa5:{value:null,editable:!0,noEffect:!0,hidePlayers:!0,description:game.i18n.localize("MERCHANT.locked"),custom:!0}}}}},{key:"canAdvance",value:function canAdvance(t){return t.canAdvance}},{key:"armorValue",value:function armorValue(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},a=t.items.filter((function(t){return"armor"==t.type&&1==t.system.worn.value}));r.origin&&(a=a.map((function(a){var o=mergeObject(duplicate(r),{armor:a});return b.Z.applyRollTransformation(t,o,4).options.armor})));var o=a.reduce((function(t,r){return t+_.Z.armorWearModifier(r,r.system.protection.value)}),0),i=t.items.filter((function(t){return"trait"==t.type&&"armor"==t.system.traitType.value})).reduce((function(t,r){return t+Number(r.system.at.value)}),0);return{wornArmor:a,armor:o+i+(t.system.totalArmor||0)}}},{key:"_calculateCombatSkillValues",value:function _calculateCombatSkillValues(t,r){if("melee"==t.system.weapontype.value){var a=t.system.guidevalue.value.split("/").map((function(t){return Number(r.characteristics[t].initial)+Number(r.characteristics[t].modifier)+Number(r.characteristics[t].advances)+Number(r.characteristics[t].gearmodifier)})),i=Math.max.apply(Math,_toConsumableArray(a));t.system.parry.value=Math.ceil(t.system.talentValue.value/2)+Math.max(0,Math.floor((i-8)/3))+Number(game.settings.get("dsa5","higherDefense"));var c=r.characteristics.mu.initial+r.characteristics.mu.modifier+r.characteristics.mu.advances+r.characteristics.mu.gearmodifier;t.system.attack.value=t.system.talentValue.value+Math.max(0,Math.floor((c-8)/3))}else{t.system.parry.value=0;var u=r.characteristics.ff.initial+r.characteristics.ff.modifier+r.characteristics.ff.advances+r.characteristics.ff.gearmodifier;t.system.attack.value=t.system.talentValue.value+Math.max(0,Math.floor((u-8)/3))}return t.cost=game.i18n.format("advancementCost",{cost:o.Z._calculateAdvCost(t.system.talentValue.value,t.system.StF.value)}),t}},{key:"reduceGroupSchip",value:(a=_asyncToGenerator(_regeneratorRuntime().mark((function _callee34(){var t;return _regeneratorRuntime().wrap((function _callee34$(r){for(;;)switch(r.prev=r.next){case 0:if(!game.user.isGM){r.next=7;break}return(t=game.settings.get("dsa5","groupschips").split("/").map((function(t){return Number(t)})))[0]=t[0]-1,r.next=5,game.settings.set("dsa5","groupschips",t.join("/"));case 5:r.next=8;break;case 7:game.socket.emit("system.dsa5",{type:"reduceGroupSchip",payload:{}});case 8:case"end":return r.stop()}}),_callee34)}))),function reduceGroupSchip(){return a.apply(this,arguments)})},{key:"updateFallingDamage",value:(r=_asyncToGenerator(_regeneratorRuntime().mark((function _callee35(t,r,a){var i,c,u,l,p;return _regeneratorRuntime().wrap((function _callee35$(a){for(;;)switch(a.prev=a.next){case 0:return i=2*(r.result.qualityStep||0),mergeObject(t.options,{availableQs:i}),c=o.Z.getSpeaker(t.speaker),a.next=5,c._setupFallingHeight(t.options,t.tokenId);case 5:return u=a.sent,a.next=8,c.basicTest(u,{suppressMessage:!0});case 8:return l=a.sent,a.next=11,renderTemplate("systems/dsa5/templates/chat/roll/fallingdamage-card.html",l);case 11:p=a.sent,r.result.other||(r.result.other=[]),r.result.other.push(p),r.chatData&&(r.chatData.other=[p]);case 15:case"end":return a.stop()}}),_callee35)}))),function updateFallingDamage(t,a,o){return r.apply(this,arguments)})},{key:"_parseModifiers",value:function _parseModifiers(t,r){var a=[];return t.find('[name="situationalModifiers"] option:selected').each((function(){var t=$(this).val(),r={name:$(this).text().trim().split("[")[0],value:isNaN(t)?t:Number(t),type:$(this).attr("data-type")};"dmg"==r.type&&(r.damageBonus=r.value,r.value=0),$(this).attr("data-specAbId")&&(r.specAbId=$(this).attr("data-specAbId")),$(this).attr("data-armorPen")&&(r.armorPen=$(this).attr("data-armorPen")),a.push(r)})),a.push({name:game.i18n.localize("manual"),value:Number(t.find('[name="testModifier"]').val()),type:""}),a}},{key:"_prepareConsumable",value:function _prepareConsumable(t){return t.system.maxCharges&&(t.consumable=!0,t.structureMax=t.system.maxCharges,t.structureCurrent=t.system.charges),t}},{key:"prepareMag",value:function prepareMag(t){return"mag"==t.system.ammunitiongroup.value&&(t.structureMax=t.system.mag.max,t.structureCurrent=t.system.mag.value),t}},{key:"_prepareitemStructure",value:function _prepareitemStructure(t){t.system.structure&&0!=t.system.structure.max&&(t.structureMax=t.system.structure.max,t.structureCurrent=t.system.structure.value);var r=getProperty(t,"flags.dsa5.enchantments");if(r&&r.length>0)t.enchantClass="rar";else if(t.effects.length>0)t.enchantClass="common";else if(t.system.effect&&""!=t.system.effect.value)if("armor"==t.type){var a,o=_createForOfIteratorHelper(t.system.effect.value.split(/,|;/).map((function(t){return t.trim()})));try{for(o.s();!(a=o.n()).done;){var i=a.value.replace(/(\s+)/g," ").trim().split(" ");if(2!=i.length||![game.i18n.localize("CHARAbbrev.INI").toLowerCase(),game.i18n.localize("CHARAbbrev.GS").toLowerCase()].includes(i[1].toLowerCase())||isNaN(i[0])||-1!=i[0]){t.enchantClass="common";break}}}catch(t){o.e(t)}finally{o.f()}}else t.enchantClass="common";return t}},{key:"_prepareMeleetrait",value:function _prepareMeleetrait(t){return t.attack=Number(t.system.at.value),0!=t.system.pa&&(t.parry=t.system.pa),this._parseDmg(t)}},{key:"_prepareMeleeWeapon",value:function _prepareMeleeWeapon(t,r,a){var o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,i=r.find((function(r){return r.name==t.system.combatskill.value}));if(i){t.attack=Number(i.system.attack.value)+Number(t.system.atmod.value);var c=t.system.guidevalue.value.split("/").map((function(t){return a.system.characteristics[t]?Number(a.system.characteristics[t].initial)+Number(a.system.characteristics[t].modifier)+Number(a.system.characteristics[t].advances)+Number(a.system.characteristics[t].gearmodifier):0})),u=Math.ceil(i.system.talentValue.value/2)+Math.max(0,Math.floor((Math.max.apply(Math,_toConsumableArray(c))-8)/3))+Number(game.settings.get("dsa5","higherDefense"));t.parry=u+Number(t.system.pamod.value)+(g.Z.isShield(t)?Number(t.system.pamod.value):0),t.yieldedTwoHand=g.Z.isYieldedTwohanded(t),t.yieldedTwoHand||(o||(o=duplicate(a.items).filter((function(r){return"meleeweapon"==r.type&&r.system.worn.value&&r._id!=t._id&&!g.Z.isYieldedTwohanded(r)}))),o.length>0&&(t.parry+=Math.max.apply(Math,_toConsumableArray(o.map((function(t){return t.system.pamod.offhandMod})))),t.attack+=Math.max.apply(Math,_toConsumableArray(o.map((function(t){return t.system.atmod.offhandMod}))))));var l=0;if(t.system.worn.wrongGrip)if(t.yieldedTwoHand)t.parry-=1,l=1;else{t.system.reach.value="medium";var p=game.i18n.localize("LocalizedCTs.".concat(t.system.combatskill.value));switch(p){case"Two-Handed Impact Weapons":case"Two-Handed Swords":t.parry-=3;var d=new RegExp(game.i18n.localize("wrongGrip.wrongGripBastardRegex"));if(d.test(t.name))l=-2;else{var h=game.i18n.localize("wrongGrip.oneHanded");t.gripDamageText=" (".concat(h," * 0.5)"),t.dmgMultipliers=[{name:h,val:"0.5"}]}break;default:t.parry-=1,l=-1}}if("-"!=(t=this._parseDmg(t)).system.guidevalue.value){var m=Math.max.apply(Math,_toConsumableArray(t.system.guidevalue.value.split("/").map((function(t){return Number(a.system.characteristics[t].value)})))),y=Math.max(m-Number(t.system.damageThreshold.value),0)+l;y>0&&(t.extraDamage=y,t.damageAdd=Roll.safeEval(t.damageAdd+" + "+Number(y)),t.damageAdd=(t.damageAdd>0?"+":"")+t.damageAdd)}_.Z.weaponWearModifier(t),t.system.damageToolTip=_.Z.damageTooltip(t)}else ui.notifications.error(game.i18n.format("DSAError.unknownCombatSkill",{skill:t.system.combatskill.value,item:t.name}));return t}},{key:"_prepareRangeTrait",value:function _prepareRangeTrait(t){return t.attack=Number(t.system.at.value),t.LZ=Number(t.system.reloadTime.value),t.LZ>0&&Actordsa5.buildReloadProgress(t),this._parseDmg(t)}},{key:"calcLZ",value:function calcLZ(t,r){var a=1,i=0;t.system.combatskill.value==game.i18n.localize("LocalizedIDs.Throwing Weapons")?i=-1*d.Z.abilityStep(r,game.i18n.localize("LocalizedIDs.quickdraw")):t.system.combatskill.value==game.i18n.localize("LocalizedIDs.Crossbows")&&d.Z.hasAbility(r,"".concat(game.i18n.localize("LocalizedIDs.quickload")," (").concat(game.i18n.localize("LocalizedIDs.Crossbows"),")"))?a=.5:i=-1*d.Z.abilityStep(r,"".concat(game.i18n.localize("LocalizedIDs.quickload")," (").concat(game.i18n.localize(t.system.combatskill.value),")"));var c="".concat(t.system.reloadTime.value).split("/");if("mag"==t.system.ammunitiongroup.value){var u=r.items.find((function(r){return r.id==t.system.currentAmmo.value||r._id==t.system.currentAmmo.value})),l=0;u&&(u=o.Z.toObjectIfPossible(u)).system.mag.value<=0&&(l=1),c=c[l]||c[0]}else c=c[0];return Math.max(0,Math.round(Number(c)*a)+i)}},{key:"_parseDmg",value:function _parseDmg(t){var r,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:void 0,o=new Roll(t.system.damage.value.replace(/[Ww]/g,"d"),{async:!1}),i="",c="",u="+",l=_createForOfIteratorHelper(o.terms);try{for(l.s();!(r=l.n()).done;){var p=r.value;p.faces?i=p.number+"d"+p.faces:p.operator?u=p.operator:p.number&&(c+=Number("".concat(u).concat(p.number)))}}catch(t){l.e(t)}finally{l.f()}if(a){var d=getProperty(a,"system.damageMod");Number(d)?c+="+".concat(Number(d)):d&&(t.damageBonusDescription=", ".concat(d," ").concat(game.i18n.localize("CHARAbbrev.damage")," ").concat(a.name))}return c&&(c=Roll.safeEval(c)),t.damagedie=i||"0d6",t.damageAdd=""!=c?(Number(c)>=0?"+":"")+c:"",t}},{key:"buildReloadProgress",value:function buildReloadProgress(t){var r=t.system.reloadTime.progress/t.LZ;t.title=game.i18n.format("WEAPON.loading",{status:"".concat(t.system.reloadTime.progress,"/").concat(t.LZ)}),t.progress="".concat(t.system.reloadTime.progress,"/").concat(t.LZ),r>=1&&(t.title=game.i18n.localize("WEAPON.loaded")),this.progressTransformation(t,r)}},{key:"progressTransformation",value:function progressTransformation(t,r){r>=.5?(t.transformRight="181deg",t.transformLeft="".concat(Math.round(360*r-179),"deg")):(t.transformRight="".concat(Math.round(360*r+1),"deg"),t.transformLeft=0)}},{key:"buildSpellChargeProgress",value:function buildSpellChargeProgress(t){if(t.LZ=Number(t.system.castingTime.modified)||0,t.LZ>1){var r=t.system.castingTime.progress/t.LZ;t.title=game.i18n.format("SPELL.loading",{status:"".concat(t.system.castingTime.progress,"/").concat(t.LZ)}),t.progress="".concat(t.system.castingTime.progress,"/").concat(t.LZ),this.progressTransformation(t,r)}return t}},{key:"_prepareRangeWeapon",value:function _prepareRangeWeapon(t,r,a,o){var i,c=a.find((function(r){return r.name==t.system.combatskill.value}));if(t.calculatedRange=t.system.reach.value,c){if(t.attack=Number(c.system.attack.value),"-"!=t.system.ammunitiongroup.value&&(t.ammo=r.filter((function(r){return r.system.ammunitiongroup.value==t.system.ammunitiongroup.value})),i=r.find((function(r){return r._id==t.system.currentAmmo.value})))){var u=Number(i.system.rangeMultiplier)||1;t.calculatedRange=t.calculatedRange.split("/").map((function(t){return Math.round(Number(t)*u)})).join("/"),t.attack+=Number(i.system.atmod)||0,"mag"==i.system.ammunitiongroup.value&&(t.ammoMax=i.system.mag.max,t.ammoCurrent=i.system.mag.value)}t.LZ=Actordsa5.calcLZ(t,o),t.LZ>0&&Actordsa5.buildReloadProgress(t),_.Z.weaponWearModifier(t),t.system.damageToolTip=_.Z.damageTooltip(t)}else ui.notifications.error(game.i18n.format("DSAError.unknownCombatSkill",{skill:t.system.combatskill.value,item:t.name}));return this._parseDmg(t,i)}}]),Actordsa5}();_defineProperty(S,"_baseCarryItems",new Set(["armor","meleeweapon","ammunition","rangeweapon","plant","poison","money","consumable","equipment"])),_defineProperty(S,"_mageSpecs",new Set(["magical","staff","pact"])),_defineProperty(S,"_clericSpecs",new Set(["ceremonial","clerical"]))},416:(t,r,a)=>{a.d(r,{TB:()=>l,Z0:()=>u,xb:()=>c});var o=a(565),i=a(491);function _typeof(t){return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},_typeof(t)}function _regeneratorRuntime(){_regeneratorRuntime=function _regeneratorRuntime(){return t};var t={},r=Object.prototype,a=r.hasOwnProperty,o="function"==typeof Symbol?Symbol:{},i=o.iterator||"@@iterator",c=o.asyncIterator||"@@asyncIterator",u=o.toStringTag||"@@toStringTag";function define(t,r,a){return Object.defineProperty(t,r,{value:a,enumerable:!0,configurable:!0,writable:!0}),t[r]}try{define({},"")}catch(t){define=function define(t,r,a){return t[r]=a}}function wrap(t,r,a,o){var i=r&&r.prototype instanceof Generator?r:Generator,c=Object.create(i.prototype),u=new Context(o||[]);return c._invoke=function(t,r,a){var o="suspendedStart";return function(i,c){if("executing"===o)throw new Error("Generator is already running");if("completed"===o){if("throw"===i)throw c;return doneResult()}for(a.method=i,a.arg=c;;){var u=a.delegate;if(u){var p=maybeInvokeDelegate(u,a);if(p){if(p===l)continue;return p}}if("next"===a.method)a.sent=a._sent=a.arg;else if("throw"===a.method){if("suspendedStart"===o)throw o="completed",a.arg;a.dispatchException(a.arg)}else"return"===a.method&&a.abrupt("return",a.arg);o="executing";var d=tryCatch(t,r,a);if("normal"===d.type){if(o=a.done?"completed":"suspendedYield",d.arg===l)continue;return{value:d.arg,done:a.done}}"throw"===d.type&&(o="completed",a.method="throw",a.arg=d.arg)}}}(t,a,u),c}function tryCatch(t,r,a){try{return{type:"normal",arg:t.call(r,a)}}catch(t){return{type:"throw",arg:t}}}t.wrap=wrap;var l={};function Generator(){}function GeneratorFunction(){}function GeneratorFunctionPrototype(){}var p={};define(p,i,(function(){return this}));var d=Object.getPrototypeOf,h=d&&d(d(values([])));h&&h!==r&&a.call(h,i)&&(p=h);var m=GeneratorFunctionPrototype.prototype=Generator.prototype=Object.create(p);function defineIteratorMethods(t){["next","throw","return"].forEach((function(r){define(t,r,(function(t){return this._invoke(r,t)}))}))}function AsyncIterator(t,r){function invoke(o,i,c,u){var l=tryCatch(t[o],t,i);if("throw"!==l.type){var p=l.arg,d=p.value;return d&&"object"==_typeof(d)&&a.call(d,"__await")?r.resolve(d.__await).then((function(t){invoke("next",t,c,u)}),(function(t){invoke("throw",t,c,u)})):r.resolve(d).then((function(t){p.value=t,c(p)}),(function(t){return invoke("throw",t,c,u)}))}u(l.arg)}var o;this._invoke=function(t,a){function callInvokeWithMethodAndArg(){return new r((function(r,o){invoke(t,a,r,o)}))}return o=o?o.then(callInvokeWithMethodAndArg,callInvokeWithMethodAndArg):callInvokeWithMethodAndArg()}}function maybeInvokeDelegate(t,r){var a=t.iterator[r.method];if(void 0===a){if(r.delegate=null,"throw"===r.method){if(t.iterator.return&&(r.method="return",r.arg=void 0,maybeInvokeDelegate(t,r),"throw"===r.method))return l;r.method="throw",r.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var o=tryCatch(a,t.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,l;var i=o.arg;return i?i.done?(r[t.resultName]=i.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=void 0),r.delegate=null,l):i:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,l)}function pushTryEntry(t){var r={tryLoc:t[0]};1 in t&&(r.catchLoc=t[1]),2 in t&&(r.finallyLoc=t[2],r.afterLoc=t[3]),this.tryEntries.push(r)}function resetTryEntry(t){var r=t.completion||{};r.type="normal",delete r.arg,t.completion=r}function Context(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(pushTryEntry,this),this.reset(!0)}function values(t){if(t){var r=t[i];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var o=-1,c=function next(){for(;++o=0;--o){var i=this.tryEntries[o],c=i.completion;if("root"===i.tryLoc)return handle("end");if(i.tryLoc<=this.prev){var u=a.call(i,"catchLoc"),l=a.call(i,"finallyLoc");if(u&&l){if(this.prev=0;--o){var i=this.tryEntries[o];if(i.tryLoc<=this.prev&&a.call(i,"finallyLoc")&&this.prev=0;--r){var a=this.tryEntries[r];if(a.finallyLoc===t)return this.complete(a.completion,a.afterLoc),resetTryEntry(a),l}},catch:function _catch(t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc===t){var o=a.completion;if("throw"===o.type){var i=o.arg;resetTryEntry(a)}return i}}throw new Error("illegal catch attempt")},delegateYield:function delegateYield(t,r,a){return this.delegate={iterator:values(t),resultName:r,nextLoc:a},"next"===this.method&&(this.arg=void 0),l}},t}function asyncGeneratorStep(t,r,a,o,i,c,u){try{var l=t[c](u),p=l.value}catch(t){return void a(t)}l.done?r(p):Promise.resolve(p).then(o,i)}function _asyncToGenerator(t){return function(){var r=this,a=arguments;return new Promise((function(o,i){var c=t.apply(r,a);function _next(t){asyncGeneratorStep(c,o,i,_next,_throw,"next",t)}function _throw(t){asyncGeneratorStep(c,o,i,_next,_throw,"throw",t)}_next(void 0)}))}}function _classCallCheck(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}function _defineProperties(t,r){for(var a=0;a',label:game.i18n.localize("yes"),callback:function callback(r){a.postContent(r,t)}},cancel:{icon:'',label:game.i18n.localize("cancel")}},o.t4={title:o.t1,content:o.t2,default:"yes",buttons:o.t3},new o.t0(o.t4).render(!0);case 9:case"end":return o.stop()}}),_callee5)}))),function getDialog(t){return a.apply(this,arguments)})},{key:"postContent",value:(r=_asyncToGenerator(_regeneratorRuntime().mark((function _callee6(t,r){var a,o;return _regeneratorRuntime().wrap((function _callee6$(c){for(;;)switch(c.prev=c.next){case 0:a=i.Z.chatDataSetup(r),t.find("#sel_all").is(":checked")||(o=[],t.find(".usersel:checked").each((function(){o.push($(this).val())})),a.whisper=o),ChatMessage.create(a);case 3:case"end":return c.stop()}}),_callee6)}))),function postContent(t,a){return r.apply(this,arguments)})}]),UserMultipickDialog}()},70:(t,r,a)=>{a.d(r,{Z:()=>v});var o=a(369),i=a(839),c=a(577),u=a(562),l=a(169),p=a(122),d=a(491),h=a(538),m=a(5),y=a(973),g=a(565);function _typeof(t){return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},_typeof(t)}function _toConsumableArray(t){return function _arrayWithoutHoles(t){if(Array.isArray(t))return _arrayLikeToArray(t)}(t)||function _iterableToArray(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||_unsupportedIterableToArray(t)||function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function _regeneratorRuntime(){_regeneratorRuntime=function _regeneratorRuntime(){return t};var t={},r=Object.prototype,a=r.hasOwnProperty,o="function"==typeof Symbol?Symbol:{},i=o.iterator||"@@iterator",c=o.asyncIterator||"@@asyncIterator",u=o.toStringTag||"@@toStringTag";function define(t,r,a){return Object.defineProperty(t,r,{value:a,enumerable:!0,configurable:!0,writable:!0}),t[r]}try{define({},"")}catch(t){define=function define(t,r,a){return t[r]=a}}function wrap(t,r,a,o){var i=r&&r.prototype instanceof Generator?r:Generator,c=Object.create(i.prototype),u=new Context(o||[]);return c._invoke=function(t,r,a){var o="suspendedStart";return function(i,c){if("executing"===o)throw new Error("Generator is already running");if("completed"===o){if("throw"===i)throw c;return doneResult()}for(a.method=i,a.arg=c;;){var u=a.delegate;if(u){var p=maybeInvokeDelegate(u,a);if(p){if(p===l)continue;return p}}if("next"===a.method)a.sent=a._sent=a.arg;else if("throw"===a.method){if("suspendedStart"===o)throw o="completed",a.arg;a.dispatchException(a.arg)}else"return"===a.method&&a.abrupt("return",a.arg);o="executing";var d=tryCatch(t,r,a);if("normal"===d.type){if(o=a.done?"completed":"suspendedYield",d.arg===l)continue;return{value:d.arg,done:a.done}}"throw"===d.type&&(o="completed",a.method="throw",a.arg=d.arg)}}}(t,a,u),c}function tryCatch(t,r,a){try{return{type:"normal",arg:t.call(r,a)}}catch(t){return{type:"throw",arg:t}}}t.wrap=wrap;var l={};function Generator(){}function GeneratorFunction(){}function GeneratorFunctionPrototype(){}var p={};define(p,i,(function(){return this}));var d=Object.getPrototypeOf,h=d&&d(d(values([])));h&&h!==r&&a.call(h,i)&&(p=h);var m=GeneratorFunctionPrototype.prototype=Generator.prototype=Object.create(p);function defineIteratorMethods(t){["next","throw","return"].forEach((function(r){define(t,r,(function(t){return this._invoke(r,t)}))}))}function AsyncIterator(t,r){function invoke(o,i,c,u){var l=tryCatch(t[o],t,i);if("throw"!==l.type){var p=l.arg,d=p.value;return d&&"object"==_typeof(d)&&a.call(d,"__await")?r.resolve(d.__await).then((function(t){invoke("next",t,c,u)}),(function(t){invoke("throw",t,c,u)})):r.resolve(d).then((function(t){p.value=t,c(p)}),(function(t){return invoke("throw",t,c,u)}))}u(l.arg)}var o;this._invoke=function(t,a){function callInvokeWithMethodAndArg(){return new r((function(r,o){invoke(t,a,r,o)}))}return o=o?o.then(callInvokeWithMethodAndArg,callInvokeWithMethodAndArg):callInvokeWithMethodAndArg()}}function maybeInvokeDelegate(t,r){var a=t.iterator[r.method];if(void 0===a){if(r.delegate=null,"throw"===r.method){if(t.iterator.return&&(r.method="return",r.arg=void 0,maybeInvokeDelegate(t,r),"throw"===r.method))return l;r.method="throw",r.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var o=tryCatch(a,t.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,l;var i=o.arg;return i?i.done?(r[t.resultName]=i.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=void 0),r.delegate=null,l):i:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,l)}function pushTryEntry(t){var r={tryLoc:t[0]};1 in t&&(r.catchLoc=t[1]),2 in t&&(r.finallyLoc=t[2],r.afterLoc=t[3]),this.tryEntries.push(r)}function resetTryEntry(t){var r=t.completion||{};r.type="normal",delete r.arg,t.completion=r}function Context(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(pushTryEntry,this),this.reset(!0)}function values(t){if(t){var r=t[i];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var o=-1,c=function next(){for(;++o=0;--o){var i=this.tryEntries[o],c=i.completion;if("root"===i.tryLoc)return handle("end");if(i.tryLoc<=this.prev){var u=a.call(i,"catchLoc"),l=a.call(i,"finallyLoc");if(u&&l){if(this.prev=0;--o){var i=this.tryEntries[o];if(i.tryLoc<=this.prev&&a.call(i,"finallyLoc")&&this.prev=0;--r){var a=this.tryEntries[r];if(a.finallyLoc===t)return this.complete(a.completion,a.afterLoc),resetTryEntry(a),l}},catch:function _catch(t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc===t){var o=a.completion;if("throw"===o.type){var i=o.arg;resetTryEntry(a)}return i}}throw new Error("illegal catch attempt")},delegateYield:function delegateYield(t,r,a){return this.delegate={iterator:values(t),resultName:r,nextLoc:a},"next"===this.method&&(this.arg=void 0),l}},t}function asyncGeneratorStep(t,r,a,o,i,c,u){try{var l=t[c](u),p=l.value}catch(t){return void a(t)}l.done?r(p):Promise.resolve(p).then(o,i)}function _asyncToGenerator(t){return function(){var r=this,a=arguments;return new Promise((function(o,i){var c=t.apply(r,a);function _next(t){asyncGeneratorStep(c,o,i,_next,_throw,"next",t)}function _throw(t){asyncGeneratorStep(c,o,i,_next,_throw,"throw",t)}_next(void 0)}))}}function _createForOfIteratorHelper(t,r){var a="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!a){if(Array.isArray(t)||(a=_unsupportedIterableToArray(t))||r&&t&&"number"==typeof t.length){a&&(t=a);var o=0,i=function F(){};return{s:i,n:function n(){return o>=t.length?{done:!0}:{done:!1,value:t[o++]}},e:function e(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var c,u=!0,l=!1;return{s:function s(){a=a.call(t)},n:function n(){var t=a.next();return u=t.done,t},e:function e(t){l=!0,c=t},f:function f(){try{u||null==a.return||a.return()}finally{if(l)throw c}}}}function _unsupportedIterableToArray(t,r){if(t){if("string"==typeof t)return _arrayLikeToArray(t,r);var a=Object.prototype.toString.call(t).slice(8,-1);return"Object"===a&&t.constructor&&(a=t.constructor.name),"Map"===a||"Set"===a?Array.from(t):"Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a)?_arrayLikeToArray(t,r):void 0}}function _arrayLikeToArray(t,r){(null==r||r>t.length)&&(r=t.length);for(var a=0,o=new Array(r);a0),o.find(".step").text(m.Z.roman[i]),r.checkCounterAttack(a),r.calculateModifier()}})),t.find(".opportunityAttack").change((function(r){if($(r.currentTarget).is(":checked")){var a,o=_createForOfIteratorHelper(t.find(".specAbs"));try{for(o.s();!(a=o.n()).done;){var i=a.value;$(i).removeClass("active").attr("data-step",0).find(".step").text("")}}catch(t){o.e(t)}finally{o.f()}}})),t.on("change","input,select",(function(t){return r.calculateModifier(t)})),t.find(".modifiers option").mousedown((function(t){r.calculateModifier(t)})),t.find(".quantity-click").mousedown((function(t){return r.calculateModifier(t)}));var o=this.readTargets();this.calculateModifier();var i=this;this.checkTargets=setInterval((function(){o=i.compareTargets(t,o)}),500)}},{key:"checkCounterAttack",value:function checkCounterAttack(t){if("parry"!=!this.dialogData.mode){var r=d.Z.getSpeaker(this.dialogData.speaker);if(r)if(r.items.get(t.currentTarget.dataset.id).name==game.i18n.localize("LocalizedIDs.counterAttack")){this.dialogData.counterAttack=0==t.button,this.prepareWeapon();var a=0==t.button?"attack":"parry",o=r.items.get(this.dialogData.source._id),c=y.Z.getRollModifiers(r,o,{mode:a});i.Z.getSubClass(o.type).getSituationalModifiers(c,r,{mode:a},o),"attack"==a&&(c=c.filter((function(t){return"defenseMalus"!=t.type})));var u=$(this._element).find("[name=situationalModifiers]");if(c.length>0){if(0==u.length){var l='
\n \n '.concat(w,"")}},{key:"activateListeners",value:function activateListeners(t){_get(_getPrototypeOf(DSAActiveEffectConfig.prototype),"activateListeners",this).call(this,t);var r=this.dropDownMenu();t.find(".changes-list .effect-change .key").append(r),t.find(".selMenu").select2({width:"element"}).change((function(t){var r=$(t.currentTarget);r.siblings("input").val(r.val());var a=r.closest(".effect-change"),o=r.find("option:selected");a.find(".mode select").val(o.attr("data-mode")),a.find(".value input").attr("placeholder",o.attr("data-ph")),r.blur()})),t.find(".select2").each((function(t,r){$(r)[0].style.removeProperty("width")}))}}],[{key:"defaultOptions",get:function get(){return mergeObject(_get(_getPrototypeOf(DSAActiveEffectConfig),"defaultOptions",this),{resizable:!0})}},{key:"onEffectRemove",value:function(){var _onEffectRemove=_asyncToGenerator(_regeneratorRuntime().mark((function _callee3(actor,effect){var onRemoveMacro;return _regeneratorRuntime().wrap((function _callee3$(_context3){for(;;)switch(_context3.prev=_context3.next){case 0:if(onRemoveMacro=getProperty(effect,"flags.dsa5.onRemove"),!onRemoveMacro){_context3.next=8;break}if(game.user.can("MACRO_SCRIPT")){_context3.next=6;break}ui.notifications.warn("You are not allowed to use JavaScript macros."),_context3.next=8;break;case 6:return _context3.next=8,eval("(async () => {".concat(onRemoveMacro,"})()"));case 8:case"end":return _context3.stop()}}),_callee3)})));function onEffectRemove(t,r){return _onEffectRemove.apply(this,arguments)}return onEffectRemove}()},{key:"applyRollTransformation",value:function applyRollTransformation(actor,options,functionID){var msg="",source=options.origin,_iterator4=_createForOfIteratorHelper(source.effects),_step4;try{for(_iterator4.s();!(_step4=_iterator4.n()).done;){var ef=_step4.value;try{Number(getProperty(ef,"flags.dsa5.advancedFunction"))==functionID&&eval(getProperty(ef,"flags.dsa5.args3"))}catch(t){console.warn("Unable to apply advanced effect",t,ef)}}}catch(t){_iterator4.e(t)}finally{_iterator4.f()}return options.origin=source,{msg,options}}},{key:"applyAdvancedFunction",value:function(){var _applyAdvancedFunction=_asyncToGenerator(_regeneratorRuntime().mark((function _callee4(actor,effects,source,testData,sourceActor){var skipResistRolls,msg,resistRolls,effectApplied,effectsWithChanges,effectNames,_iterator5,_step5,_loop,_args5=arguments;return _regeneratorRuntime().wrap((function _callee4$(_context5){for(;;)switch(_context5.prev=_context5.next){case 0:skipResistRolls=!(_args5.length>5&&void 0!==_args5[5])||_args5[5],msg="",resistRolls=[],effectApplied=!1,effectsWithChanges=[],effectNames=new Set,_iterator5=_createForOfIteratorHelper(effects),_context5.prev=7,_loop=_regeneratorRuntime().mark((function _loop(){var ef,specStep,customEf,qs,resistRoll,skills,mod,effect,value,creatures;return _regeneratorRuntime().wrap((function _loop$(_context4){for(;;)switch(_context4.prev=_context4.next){case 0:if(ef=_step5.value,ef.origin&&delete ef.origin,specStep=Number(getProperty(ef,"flags.dsa5.specStep"))||0,_context4.prev=3,customEf=Number(getProperty(ef,"flags.dsa5.advancedFunction")),qs=Math.min(testData.qualityStep||0,6),resistRoll=getProperty(ef,"flags.dsa5.resistRoll"),!resistRoll||skipResistRolls){_context4.next=13;break}skills=resistRoll.split(" "),mod="".concat(skills.pop()),resistRolls.push({skill:skills.join(" "),mod:Math.round(Roll.safeEval("".concat(mod).replace(/q(l|s)/i,qs).replace("step",specStep)))||0,effect:ef,target:actor,token:actor.token?actor.token.id:void 0}),_context4.next=37;break;case 13:if(effectApplied=!0,effectNames.has(ef.name)||effectNames.add(ef.name),ef.changes&&ef.changes.length>0&&effectsWithChanges.push(ef),!customEf){_context4.next=37;break}_context4.t0=customEf,_context4.next=1===_context4.t0?20:2===_context4.t0?27:3===_context4.t0?34:37;break;case 20:return effect=duplicate(CONFIG.statusEffects.find((function(t){return t.id==getProperty(ef,"flags.dsa5.args0")}))),value="".concat(getProperty(ef,"flags.dsa5.args1"))||"1",effect.duration=ef.duration,value=/,/.test(value)?Number(value.split(",")[qs-1]):Number(value.replace(game.i18n.localize("CHARAbbrev.QS"),qs)),_context4.next=26,actor.addCondition(effect,value,!1,!1);case 26:return _context4.abrupt("break",37);case 27:if(game.user.can("MACRO_SCRIPT")){_context4.next=31;break}ui.notifications.warn("You are not allowed to use JavaScript macros."),_context4.next=33;break;case 31:return _context4.next=33,eval("(async () => {".concat(getProperty(ef,"flags.dsa5.args3"),"})()"));case 33:return _context4.abrupt("break",37);case 34:return creatures=(getProperty(ef,"flags.dsa5.args4")||"").split(",").map((function(t){return"@Compendium[".concat(t.trim().replace(/(@Compendium\[|\])/),"]")})).join(" "),msg+="

".concat(game.i18n.localize("ActiveEffects.advancedFunctions.creature"),":

").concat(creatures,"

"),_context4.abrupt("break",37);case 37:_context4.next=44;break;case 39:_context4.prev=39,_context4.t1=_context4.catch(3),console.warn("Unable to apply advanced effect"),console.warn(_context4.t1),console.warn(ef);case 44:case"end":return _context4.stop()}}),_loop,null,[[3,39]])})),_iterator5.s();case 10:if((_step5=_iterator5.n()).done){_context5.next=14;break}return _context5.delegateYield(_loop(),"t0",12);case 12:_context5.next=10;break;case 14:_context5.next=19;break;case 16:_context5.prev=16,_context5.t1=_context5.catch(7),_iterator5.e(_context5.t1);case 19:return _context5.prev=19,_iterator5.f(),_context5.finish(19);case 22:return _context5.next=24,actor.createEmbeddedDocuments("ActiveEffect",effectsWithChanges.map((function(t){return t.origin=actor.uuid,t})));case 24:return _context5.abrupt("return",{msg,resistRolls,effectApplied,effectNames:Array.from(effectNames)});case 25:case"end":return _context5.stop()}}),_callee4,null,[[7,16,19,22]])})));function applyAdvancedFunction(t,r,a,o,i){return _applyAdvancedFunction.apply(this,arguments)}return applyAdvancedFunction}()},{key:"resistEffect",value:(_resistEffect=_asyncToGenerator(_regeneratorRuntime().mark((function _callee6(t){var r,a,o,i,c=this;return _regeneratorRuntime().wrap((function _callee6$(u){for(;;)switch(u.prev=u.next){case 0:r=t.currentTarget.dataset,a={token:r.token,actor:r.actor,scene:canvas.id},(o=_system_utility_dsa5_js__WEBPACK_IMPORTED_MODULE_3__.Z.getSpeaker(a))?(i=o.items.find((function(t){return"skill"==t.type&&t.name==r.skill})),o.setupSkill(i,{modifier:r.mod},r.token).then(function(){var t=_asyncToGenerator(_regeneratorRuntime().mark((function _callee5(t){return _regeneratorRuntime().wrap((function _callee5$(i){for(;;)switch(i.prev=i.next){case 0:return t.testData.opposable=!1,i.next=3,o.basicTest(t);case 3:if(!((i.sent.result.qualityStep||0)<1)){i.next=8;break}return i.next=8,c.applyEffect(r.message,r.mode,[a],{effectIds:[r.effect],skipResistRolls:!0});case 8:case"end":return i.stop()}}),_callee5)})));return function(r){return t.apply(this,arguments)}}())):console.warn("Actor not found for resist roll.");case 4:case"end":return u.stop()}}),_callee6)}))),function resistEffect(t){return _resistEffect.apply(this,arguments)})},{key:"applyEffect",value:(_applyEffect=_asyncToGenerator(_regeneratorRuntime().mark((function _callee7(t,r,a){var o,i,c,u,l,p,d,h,m,y,g,v,_,b,k,w,x,S,T,A,O=arguments;return _regeneratorRuntime().wrap((function _callee7$(P){for(;;)switch(P.prev=P.next){case 0:return o=O.length>3&&void 0!==O[3]?O[3]:{},i=game.messages.get(t),c=i.flags.data.preData.source,u=i.flags.data.postData,l=i.speaker,["poison","disease"].includes(c.type)&&(u.qualityStep=u.successLevel>0?2:1),p=_system_utility_dsa5_js__WEBPACK_IMPORTED_MODULE_3__.Z.getSpeaker(l)||_system_utility_dsa5_js__WEBPACK_IMPORTED_MODULE_3__.Z.getSpeaker(getProperty(i.flags,"data.preData.extra.speaker"))||game.actors.get(getProperty(i.flags,"data.preData.extra.actor.id")),d=p,P.next=10,this._parseEffectDuration(c,u,i.flags.data.preData,p);case 10:if(h=P.sent.filter((function(t){return!getProperty(t,"flags.dsa5.applyToOwner")})),o.effectIds&&(h=h.filter((function(t){return o.effectIds.includes(t._id)}))),m=[],"self"==r?p&&m.push(p):a?m=a.map((function(t){return _system_utility_dsa5_js__WEBPACK_IMPORTED_MODULE_3__.Z.getSpeaker(t)})):game.user.targets.size&&game.user.targets.forEach((function(t){t.actor&&m.push(t.actor)})),!game.user.isGM){P.next=47;break}y=_createForOfIteratorHelper(m),P.prev=16,y.s();case 18:if((g=y.n()).done){P.next=37;break}return v=g.value,P.next=22,DSAActiveEffectConfig.applyAdvancedFunction(v,h,c,u,d,o.skipResistRolls||!1);case 22:if(_=P.sent,b=_.msg,k=_.resistRolls,w=_.effectApplied,x=_.effectNames,!w){P.next=32;break}return T=game.i18n.format("ActiveEffects.appliedEffect",{target:(null===(S=v.token)||void 0===S?void 0:S.name)||v.name,source:x.join(", ")}),A="".concat(T).concat(b||""),P.next=32,ChatMessage.create(_system_utility_dsa5_js__WEBPACK_IMPORTED_MODULE_3__.Z.chatDataSetup(A));case 32:if(!k.length){P.next=35;break}return P.next=35,this.createResistRollMessage(k,t,r);case 35:P.next=18;break;case 37:P.next=42;break;case 39:P.prev=39,P.t0=P.catch(16),y.e(P.t0);case 42:return P.prev=42,y.f(),P.finish(42);case 45:P.next=48;break;case 47:game.socket.emit("system.dsa5",{type:"addEffect",payload:{mode:r,id:t,actors:m.map((function(t){return{token:t.token?t.token.id:void 0,actor:t.id,scene:canvas.scene.id}}))}});case 48:case"end":return P.stop()}}),_callee7,this,[[16,39,42,45]])}))),function applyEffect(t,r,a){return _applyEffect.apply(this,arguments)})},{key:"createResistRollMessage",value:(_createResistRollMessage=_asyncToGenerator(_regeneratorRuntime().mark((function _callee8(t,r,a){var o,i,c,u;return _regeneratorRuntime().wrap((function _callee8$(l){for(;;)switch(l.prev=l.next){case 0:o=_createForOfIteratorHelper(t),l.prev=1,o.s();case 3:if((i=o.n()).done){l.next=12;break}return c=i.value,l.next=7,renderTemplate("systems/dsa5/templates/chat/roll/resist-roll.html",{resist:c,id:r,mode:a});case 7:return u=l.sent,l.next=10,ChatMessage.create(_system_utility_dsa5_js__WEBPACK_IMPORTED_MODULE_3__.Z.chatDataSetup(u));case 10:l.next=3;break;case 12:l.next=17;break;case 14:l.prev=14,l.t0=l.catch(1),o.e(l.t0);case 17:return l.prev=17,o.f(),l.finish(17);case 20:case"end":return l.stop()}}),_callee8,null,[[1,14,17,20]])}))),function createResistRollMessage(t,r,a){return _createResistRollMessage.apply(this,arguments)})},{key:"_parseEffectDuration",value:(_parseEffectDuration2=_asyncToGenerator(_regeneratorRuntime().mark((function _callee9(t,r,a,o){var i,c,u,l,p,d,h,m,y,g,v,_,b,k,w,x,S,T,A,O,P,E,C,D,I,R,L;return _regeneratorRuntime().wrap((function _callee9$(G){for(;;)switch(G.prev=G.next){case 0:i={},c=_createForOfIteratorHelper(a.situationalModifiers.filter((function(t){return t.specAbId})));try{for(c.s();!(u=c.n()).done;)l=u.value,i[l.specAbId]=l.step}catch(t){c.e(t)}finally{c.f()}p=Object.keys(i),d=o?o.items.filter((function(t){return p.includes(t.id)})):[],h=t.effects?duplicate(t.effects):[],m=_createForOfIteratorHelper(d);try{for(m.s();!(y=m.n()).done;){g=y.value,v=duplicate(g).effects,_=_createForOfIteratorHelper(v);try{for(_.s();!(b=_.n()).done;)k=b.value,setProperty(k,"flags.dsa5.specStep",i[g.id])}catch(t){_.e(t)}finally{_.f()}h.push.apply(h,_toConsumableArray(v))}}catch(t){m.e(t)}finally{m.f()}w=(w=getProperty(t,"system.duration.value")||"").replace(" x "," * ").replace(game.i18n.localize("CHARAbbrev.QS"),r.qualityStep),G.prev=10,x=[{regEx:new RegExp(game.i18n.localize("DSAREGEX.combatRounds"),"gi"),seconds:5},{regEx:new RegExp(game.i18n.localize("DSAREGEX.minutes"),"gi"),seconds:60},{regEx:new RegExp(game.i18n.localize("DSAREGEX.hours"),"gi"),seconds:3600},{regEx:new RegExp(game.i18n.localize("DSAREGEX.days"),"gi"),seconds:86400},{regEx:new RegExp(game.i18n.localize("DSAREGEXmaintain.weeks"),"gi"),seconds:604800},{regEx:new RegExp(game.i18n.localize("DSAREGEXmaintain.months"),"gi"),seconds:2592e3},{regEx:new RegExp(game.i18n.localize("DSAREGEXmaintain.years"),"gi"),seconds:3024e4}],S=0,T=x;case 13:if(!(S{a.d(r,{Z:()=>u});var o=a(947),i=a(577),c=a(472);function _typeof(t){return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},_typeof(t)}function _get(){return _get="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function _get(t,r,a){var o=_superPropBase(t,r);if(o){var i=Object.getOwnPropertyDescriptor(o,r);return i.get?i.get.call(arguments.length<3?t:a):i.value}},_get.apply(this,arguments)}function _superPropBase(t,r){for(;!Object.prototype.hasOwnProperty.call(t,r)&&null!==(t=_getPrototypeOf(t)););return t}function _inherits(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(r&&r.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),r&&_setPrototypeOf(t,r)}function _setPrototypeOf(t,r){return _setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function _setPrototypeOf(t,r){return t.__proto__=r,t},_setPrototypeOf(t,r)}function _createSuper(t){var r=function _isNativeReflectConstruct(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function _createSuperInternal(){var a,o=_getPrototypeOf(t);if(r){var i=_getPrototypeOf(this).constructor;a=Reflect.construct(o,arguments,i)}else a=o.apply(this,arguments);return _possibleConstructorReturn(this,a)}}function _possibleConstructorReturn(t,r){if(r&&("object"===_typeof(r)||"function"==typeof r))return r;if(void 0!==r)throw new TypeError("Derived constructors may only return object or undefined");return function _assertThisInitialized(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}function _getPrototypeOf(t){return _getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function _getPrototypeOf(t){return t.__proto__||Object.getPrototypeOf(t)},_getPrototypeOf(t)}function _slicedToArray(t,r){return function _arrayWithHoles(t){if(Array.isArray(t))return t}(t)||function _iterableToArrayLimit(t,r){var a=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null==a)return;var o,i,c=[],u=!0,l=!1;try{for(a=a.call(t);!(u=(o=a.next()).done)&&(c.push(o.value),!r||c.length!==r);u=!0);}catch(t){l=!0,i=t}finally{try{u||null==a.return||a.return()}finally{if(l)throw i}}return c}(t,r)||_unsupportedIterableToArray(t,r)||function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function _regeneratorRuntime(){_regeneratorRuntime=function _regeneratorRuntime(){return t};var t={},r=Object.prototype,a=r.hasOwnProperty,o="function"==typeof Symbol?Symbol:{},i=o.iterator||"@@iterator",c=o.asyncIterator||"@@asyncIterator",u=o.toStringTag||"@@toStringTag";function define(t,r,a){return Object.defineProperty(t,r,{value:a,enumerable:!0,configurable:!0,writable:!0}),t[r]}try{define({},"")}catch(t){define=function define(t,r,a){return t[r]=a}}function wrap(t,r,a,o){var i=r&&r.prototype instanceof Generator?r:Generator,c=Object.create(i.prototype),u=new Context(o||[]);return c._invoke=function(t,r,a){var o="suspendedStart";return function(i,c){if("executing"===o)throw new Error("Generator is already running");if("completed"===o){if("throw"===i)throw c;return doneResult()}for(a.method=i,a.arg=c;;){var u=a.delegate;if(u){var p=maybeInvokeDelegate(u,a);if(p){if(p===l)continue;return p}}if("next"===a.method)a.sent=a._sent=a.arg;else if("throw"===a.method){if("suspendedStart"===o)throw o="completed",a.arg;a.dispatchException(a.arg)}else"return"===a.method&&a.abrupt("return",a.arg);o="executing";var d=tryCatch(t,r,a);if("normal"===d.type){if(o=a.done?"completed":"suspendedYield",d.arg===l)continue;return{value:d.arg,done:a.done}}"throw"===d.type&&(o="completed",a.method="throw",a.arg=d.arg)}}}(t,a,u),c}function tryCatch(t,r,a){try{return{type:"normal",arg:t.call(r,a)}}catch(t){return{type:"throw",arg:t}}}t.wrap=wrap;var l={};function Generator(){}function GeneratorFunction(){}function GeneratorFunctionPrototype(){}var p={};define(p,i,(function(){return this}));var d=Object.getPrototypeOf,h=d&&d(d(values([])));h&&h!==r&&a.call(h,i)&&(p=h);var m=GeneratorFunctionPrototype.prototype=Generator.prototype=Object.create(p);function defineIteratorMethods(t){["next","throw","return"].forEach((function(r){define(t,r,(function(t){return this._invoke(r,t)}))}))}function AsyncIterator(t,r){function invoke(o,i,c,u){var l=tryCatch(t[o],t,i);if("throw"!==l.type){var p=l.arg,d=p.value;return d&&"object"==_typeof(d)&&a.call(d,"__await")?r.resolve(d.__await).then((function(t){invoke("next",t,c,u)}),(function(t){invoke("throw",t,c,u)})):r.resolve(d).then((function(t){p.value=t,c(p)}),(function(t){return invoke("throw",t,c,u)}))}u(l.arg)}var o;this._invoke=function(t,a){function callInvokeWithMethodAndArg(){return new r((function(r,o){invoke(t,a,r,o)}))}return o=o?o.then(callInvokeWithMethodAndArg,callInvokeWithMethodAndArg):callInvokeWithMethodAndArg()}}function maybeInvokeDelegate(t,r){var a=t.iterator[r.method];if(void 0===a){if(r.delegate=null,"throw"===r.method){if(t.iterator.return&&(r.method="return",r.arg=void 0,maybeInvokeDelegate(t,r),"throw"===r.method))return l;r.method="throw",r.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var o=tryCatch(a,t.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,l;var i=o.arg;return i?i.done?(r[t.resultName]=i.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=void 0),r.delegate=null,l):i:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,l)}function pushTryEntry(t){var r={tryLoc:t[0]};1 in t&&(r.catchLoc=t[1]),2 in t&&(r.finallyLoc=t[2],r.afterLoc=t[3]),this.tryEntries.push(r)}function resetTryEntry(t){var r=t.completion||{};r.type="normal",delete r.arg,t.completion=r}function Context(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(pushTryEntry,this),this.reset(!0)}function values(t){if(t){var r=t[i];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var o=-1,c=function next(){for(;++o=0;--o){var i=this.tryEntries[o],c=i.completion;if("root"===i.tryLoc)return handle("end");if(i.tryLoc<=this.prev){var u=a.call(i,"catchLoc"),l=a.call(i,"finallyLoc");if(u&&l){if(this.prev=0;--o){var i=this.tryEntries[o];if(i.tryLoc<=this.prev&&a.call(i,"finallyLoc")&&this.prev=0;--r){var a=this.tryEntries[r];if(a.finallyLoc===t)return this.complete(a.completion,a.afterLoc),resetTryEntry(a),l}},catch:function _catch(t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc===t){var o=a.completion;if("throw"===o.type){var i=o.arg;resetTryEntry(a)}return i}}throw new Error("illegal catch attempt")},delegateYield:function delegateYield(t,r,a){return this.delegate={iterator:values(t),resultName:r,nextLoc:a},"next"===this.method&&(this.arg=void 0),l}},t}function asyncGeneratorStep(t,r,a,o,i,c,u){try{var l=t[c](u),p=l.value}catch(t){return void a(t)}l.done?r(p):Promise.resolve(p).then(o,i)}function _asyncToGenerator(t){return function(){var r=this,a=arguments;return new Promise((function(o,i){var c=t.apply(r,a);function _next(t){asyncGeneratorStep(c,o,i,_next,_throw,"next",t)}function _throw(t){asyncGeneratorStep(c,o,i,_next,_throw,"throw",t)}_next(void 0)}))}}function _toConsumableArray(t){return function _arrayWithoutHoles(t){if(Array.isArray(t))return _arrayLikeToArray(t)}(t)||function _iterableToArray(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||_unsupportedIterableToArray(t)||function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function _createForOfIteratorHelper(t,r){var a="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!a){if(Array.isArray(t)||(a=_unsupportedIterableToArray(t))||r&&t&&"number"==typeof t.length){a&&(t=a);var o=0,i=function F(){};return{s:i,n:function n(){return o>=t.length?{done:!0}:{done:!1,value:t[o++]}},e:function e(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var c,u=!0,l=!1;return{s:function s(){a=a.call(t)},n:function n(){var t=a.next();return u=t.done,t},e:function e(t){l=!0,c=t},f:function f(){try{u||null==a.return||a.return()}finally{if(l)throw c}}}}function _unsupportedIterableToArray(t,r){if(t){if("string"==typeof t)return _arrayLikeToArray(t,r);var a=Object.prototype.toString.call(t).slice(8,-1);return"Object"===a&&t.constructor&&(a=t.constructor.name),"Map"===a||"Set"===a?Array.from(t):"Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a)?_arrayLikeToArray(t,r):void 0}}function _arrayLikeToArray(t,r){(null==r||r>t.length)&&(r=t.length);for(var a=0,o=new Array(r);a1&&void 0!==arguments[1]?arguments[1]:"",a=arguments.length>2?arguments[2]:void 0;a=a||game.i18n.localize("CONDITION.custom"),""==r&&(r=a),t.addCondition({name:a,icon:"icons/svg/aura.svg",origin:t.uuid,flags:{dsa5:{value:null,editable:!0,description:r,custom:!0}}})}},{key:"prepareActiveEffects",value:function prepareActiveEffects(t,r){var a=duplicate(CONFIG.statusEffects),o=[];r.conditions=[],r.transferedConditions=[];var c,u=_createForOfIteratorHelper(t.effects.filter((function(r){return game.user.isGM||"Item"==t.documentName||!r.getFlag("dsa5","hidePlayers")})));try{for(u.s();!(c=u.n()).done;){var l=c.value;l.disabled=l.disabled,l.boolean=null==l.getFlag("dsa5","value"),l.icon=l.icon;var p=_toConsumableArray(l.statuses)[0];p&&(l.value=l.getFlag("dsa5","value"),l.editable=l.getFlag("dsa5","editable"),l.descriptor=p,l.manual=l.getFlag("dsa5","manual"),o.push(p)),l.origin!=t.uuid&&l.origin||l.notApplicable?l.notApplicable||r.transferedConditions.push(l):r.conditions.push(l)}}catch(t){u.e(t)}finally{u.f()}r.manualConditions=a.filter((function(t){return!o.includes(t.id)}));for(var d=[],h=function _loop(){var r=y[m];if(t.system.condition[r]){var a=i.Z.statusEffects.find((function(t){return t.id==r}));a&&d.push({icon:a.icon,id:r,name:game.i18n.localize(a.name),value:t.system.condition[r]})}},m=0,y=Object.keys((null===(g=t.system)||void 0===g?void 0:g.condition)||{});m2&&void 0!==u[2]?u[2]:1,o=u.length>3&&void 0!==u[3]&&u[3],i=!(u.length>4&&void 0!==u[4])||u[4],t.isOwner){l.next=5;break}return l.abrupt("return","Not owned");case 5:if(!t.compendium){l.next=7;break}return l.abrupt("return","Can not add in compendium");case 7:if(!(o&&a<1)){l.next=9;break}return l.abrupt("return",this.removeCondition(t,r,a,i,o));case 9:if("string"==typeof r&&(r=duplicate(CONFIG.statusEffects.find((function(t){return t.id==r})))),r){l.next=12;break}return l.abrupt("return","No Effect Found");case 12:if(!(c=this.hasCondition(t,r.id))||null!=c.flags.dsa5.value){l.next=17;break}return l.abrupt("return",c);case 17:if(!c){l.next=21;break}return l.next=20,DSA5StatusEffects.updateEffect(t,c,a,o,i,r);case 20:case 23:return l.abrupt("return",l.sent);case 21:return l.next=23,DSA5StatusEffects.createEffect(t,r,a,i);case 24:case"end":return l.stop()}}),_callee,this)}))),function addCondition(t,r){return p.apply(this,arguments)})},{key:"hasCondition",value:function hasCondition(t,r){return!(null==t||!r)&&(!!t.effects&&t.effects.find((function(t){return t.statuses.has(r)})))}},{key:"removeCondition",value:(l=_asyncToGenerator(_regeneratorRuntime().mark((function _callee2(t,r){var a,o,i,c,u,l=arguments;return _regeneratorRuntime().wrap((function _callee2$(p){for(;;)switch(p.prev=p.next){case 0:if(a=l.length>2&&void 0!==l[2]?l[2]:1,o=!(l.length>3&&void 0!==l[3])||l[3],i=l.length>4&&void 0!==l[4]&&l[4],t.isOwner){p.next=5;break}return p.abrupt("return","Not owned");case 5:if("string"==typeof r&&(r=duplicate(CONFIG.statusEffects.find((function(t){return t.id==r})))),r){p.next=8;break}return p.abrupt("return","No Effect Found");case 8:if(!(c=this.hasCondition(t,r.id))||null!=c.flags.dsa5.value){p.next=17;break}return t.token&&(t=t.token.actor),p.next=13,t.deleteEmbeddedDocuments("ActiveEffect",[c.id]);case 13:return u=p.sent,p.abrupt("return",u);case 17:if(!c){p.next=21;break}return p.next=20,DSA5StatusEffects.removeEffect(t,c,a,i,o);case 20:return p.abrupt("return",p.sent);case 21:case"end":return p.stop()}}),_callee2,this)}))),function removeCondition(t,r){return l.apply(this,arguments)})},{key:"immuneToEffect",value:function immuneToEffect(t,r){var a=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];if(r.id&&hasProperty(r,"flags.dsa5.max")){var o,i=getProperty(t,"system.immunities")||[];if(i.includes(r.id)&&(o={name:t.name,condition:game.i18n.localize("CONDITION.".concat(r.id))}),!o&&"Actor"==t.documentName){var u,l=c.Z.detectCreatureType(t),p=_createForOfIteratorHelper(l);try{for(p.s();!(u=p.n()).done;){var d=u.value;if(d.ignoredCondition(r.id)){o={name:"".concat(t.name," (").concat(d.getName(),")"),condition:game.i18n.localize("CONDITION.".concat(r.id))};break}}}catch(t){p.e(t)}finally{p.f()}}if(o&&ui.notifications&&!a){var h=game.i18n.format("DSAError.conditionInvalidToCreature",{name:o.name,condition:o.condition});ui.notifications.warn(h)}}}},{key:"resistantToEffect",value:function resistantToEffect(t,r){var a=_toConsumableArray(r.statuses)[0];return a?(getProperty(t,"system.resistances.effects")||[]).reduce((function(t,r){return r.target==a&&(t+=Number(r.value)),t}),0):0}},{key:"createEffect",value:(u=_asyncToGenerator(_regeneratorRuntime().mark((function _callee3(t,r,a,o){var i,c;return _regeneratorRuntime().wrap((function _callee3$(u){for(;;)switch(u.prev=u.next){case 0:return r.name=game.i18n.localize(r.name),this.immuneToEffect(t,r,!1),o?(r.flags.dsa5.auto=Math.min(r.flags.dsa5.max,a),r.flags.dsa5.manual=0):(r.flags.dsa5.manual=Math.min(r.flags.dsa5.max,a),r.flags.dsa5.auto=0),r.flags.dsa5.value=Math.min(4,r.flags.dsa5.manual+r.flags.dsa5.auto),r.id&&(r.statuses=[r.id]),"dead"==r.id&&(r["flags.core.overlay"]=!0),i=duplicate(r),(game.dsa5.config.statusEffectClasses[r.id]||DSA5StatusEffects).levelDependentEffects(r,i),u.next=10,t.createEmbeddedDocuments("ActiveEffect",[i]);case 10:return c=u.sent,delete r.id,u.abrupt("return",c);case 13:case"end":return u.stop()}}),_callee3,this)}))),function createEffect(t,r,a,o){return u.apply(this,arguments)})},{key:"removeEffect",value:(a=_asyncToGenerator(_regeneratorRuntime().mark((function _callee4(t,r,a,o,i){var c,u,l;return _regeneratorRuntime().wrap((function _callee4$(p){for(;;)switch(p.prev=p.next){case 0:if(c=i?o?a:Math.max(0,r.flags.dsa5.auto-a):r.flags.dsa5.auto,u=i?r.flags.dsa5.manual:o?a:r.flags.dsa5.manual-a,!((l={flags:{dsa5:{auto:c,manual:u,value:Math.max(0,Math.min(r.flags.dsa5.max,u+c))}}}).flags.dsa5.auto<1&&0==l.flags.dsa5.manual)){p.next=9;break}return p.next=6,t.deleteEmbeddedDocuments("ActiveEffect",[r.id]);case 6:case 12:return p.abrupt("return",p.sent);case 9:return(game.dsa5.config.statusEffectClasses[_toConsumableArray(r.statuses)[0]]||DSA5StatusEffects).levelDependentEffects(r,l),p.next=12,r.update(l);case 13:case"end":return p.stop()}}),_callee4)}))),function removeEffect(t,r,o,i,c){return a.apply(this,arguments)})},{key:"levelDependentEffects",value:(r=_asyncToGenerator(_regeneratorRuntime().mark((function _callee5(t,r){return _regeneratorRuntime().wrap((function _callee5$(t){for(;;)switch(t.prev=t.next){case 0:case"end":return t.stop()}}),_callee5)}))),function levelDependentEffects(t,a){return r.apply(this,arguments)})},{key:"updateEffect",value:(t=_asyncToGenerator(_regeneratorRuntime().mark((function _callee6(t,r,a,o,i){var c,u,l,p,d=arguments;return _regeneratorRuntime().wrap((function _callee6$(h){for(;;)switch(h.prev=h.next){case 0:if(c=d.length>5&&void 0!==d[5]?d[5]:void 0,this.immuneToEffect(t,r,!0),i?(l=Math.min(r.flags.dsa5.max,o?a:r.flags.dsa5.auto+a),u=l-r.flags.dsa5.auto,p={flags:{dsa5:{auto:l,manual:r.flags.dsa5.manual}}}):(l=o?a:r.flags.dsa5.manual+a,u=l-r.flags.dsa5.manual,p={flags:{dsa5:{manual:l,auto:r.flags.dsa5.auto}}}),0!=u){h.next=5;break}return h.abrupt("return",r);case 5:return p.flags.dsa5.value=Math.max(0,Math.min(r.flags.dsa5.max,p.flags.dsa5.manual+p.flags.dsa5.auto)),c.duration&&(p.duration=c.duration,p.duration.startTime=game.time.worldTime),(game.dsa5.config.statusEffectClasses[_toConsumableArray(r.statuses)[0]]||DSA5StatusEffects).levelDependentEffects(r,p),h.next=10,r.update(p);case 10:return h.abrupt("return",r);case 11:case"end":return h.stop()}}),_callee6,this)}))),function updateEffect(r,a,o,i,c){return t.apply(this,arguments)})},{key:"calculateRollModifier",value:function calculateRollModifier(t,r,a){return null==t.flags.dsa5.value||"regenerate"==a.type?0:DSA5StatusEffects.clampedCondition(r,t)}},{key:"clampedCondition",value:function clampedCondition(t,r){var a=_toConsumableArray(r.statuses)[0];if(!a)return 0;var o=Number(r.flags.dsa5.max),i=-1*Math.clamped(t.system.condition[a]||0,0,o),c=this.resistantToEffect(t,r);return Math.clamped(i+c,-1*o,0)}},{key:"ModifierIsSelected",value:function ModifierIsSelected(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return"damage"!=r.mode}},{key:"getDamageBonus",value:function getDamageBonus(){return 0}},{key:"getRollModifiers",value:function getRollModifiers(t,r){var a,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},c=game.i18n.localize("status")+"/"+game.i18n.localize("condition"),u=[],l=[],p=_createForOfIteratorHelper(t.effects);try{for(p.s();!(a=p.n()).done;){var d=a.value;if(!d.disabled){var h=_toConsumableArray(d.statuses)[0],m=game.dsa5.config.statusEffectClasses[h]||DSA5StatusEffects,y=m.calculateRollModifier(d,t,r,o);h&&l.push(h),0!=y&&u.push({name:d.name,value:y,selected:m.ModifierIsSelected(r,o,t),source:c})}}}catch(t){p.e(t)}finally{p.f()}for(var g=function _loop2(){var a=_slicedToArray(_[v],2),p=a[0],d=a[1];if(d&&!l.includes(p)){var h=duplicate(i.Z.statusEffects.find((function(t){return t.id==p})));if(!h)return"continue";var m=game.dsa5.config.statusEffectClasses[p]||DSA5StatusEffects;h.flags.dsa5.value=d,h.statuses=[p];var y=m.calculateRollModifier(h,t,r,o);0!=y&&u.push({name:h.name,value:y,selected:m.ModifierIsSelected(r,o,t),source:c})}},v=0,_=Object.entries(t.system.condition);v<_.length;v++)g();return u}}]),DSA5StatusEffects}(),l=function(t){_inherits(EncumberedEffect,t);var r=_createSuper(EncumberedEffect);function EncumberedEffect(){return _classCallCheck(this,EncumberedEffect),r.apply(this,arguments)}return _createClass(EncumberedEffect,null,[{key:"ModifierIsSelected",value:function ModifierIsSelected(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},a="skill"==t.type&&"yes"==t.system.burden.value,o=["rangeweapon"].includes(t.type)&&"damage"!=r.mode&&game.settings.get("dsa5","encumbranceForRange"),i=!["skill","spell","ritual","ceremony","liturgy","rangeweapon"].includes(t.type)&&"damage"!=r.mode;return a||i||o}},{key:"calculateRollModifier",value:function calculateRollModifier(t,r,a){var o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return"regenerate"==a.type||"skill"==a.type&&"no"==a.system.burden.value?0:_get(_getPrototypeOf(EncumberedEffect),"calculateRollModifier",this).call(this,t,r,a,o)}}]),EncumberedEffect}(u),p=function(t){_inherits(ProneEffect,t);var r=_createSuper(ProneEffect);function ProneEffect(){return _classCallCheck(this,ProneEffect),r.apply(this,arguments)}return _createClass(ProneEffect,null,[{key:"calculateRollModifier",value:function calculateRollModifier(t,r,a){var o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return"regenerate"==a.type?0:"dodge"==a.type?-2:o.mode?"attack"==o.mode?-4:-2:0}}]),ProneEffect}(u),d=function(t){_inherits(RaptureEffect,t);var r=_createSuper(RaptureEffect);function RaptureEffect(){return _classCallCheck(this,RaptureEffect),r.apply(this,arguments)}return _createClass(RaptureEffect,null,[{key:"calculateRollModifier",value:function calculateRollModifier(t,r,a){var o=new RegExp("".concat(game.i18n.localize("combatskill")," "),"gi"),i=r.system.happyTalents.value.split(/;|,/).map((function(t){return t.replace(o,"").trim()}));return i.includes(a.name)&&["skill","combatskill"].includes(a.type)||["rangeweapon","meleeweapon"].includes(a.type)&&i.includes(a.system.combatskill.value)||["ceremony","liturgy"].includes(a.type)?-1*this.clampedCondition(r,t)-1:["ritual","spell","skill","combatskill"].includes(a.type)?this.clampedCondition(r,t):(a.type,0)}}]),RaptureEffect}(u),h=function(t){_inherits(DeafEffect,t);var r=_createSuper(DeafEffect);function DeafEffect(){return _classCallCheck(this,DeafEffect),r.apply(this,arguments)}return _createClass(DeafEffect,null,[{key:"calculateRollModifier",value:function calculateRollModifier(t,r,a){return"regenerate"==a.type?0:"skill"==a.type&&a.name==game.i18n.localize("LocalizedIDs.perception")?-3:0}}]),DeafEffect}(u),m=function(t){_inherits(BloodrushEffect,t);var r=_createSuper(BloodrushEffect);function BloodrushEffect(){return _classCallCheck(this,BloodrushEffect),r.apply(this,arguments)}return _createClass(BloodrushEffect,null,[{key:"calculateRollModifier",value:function calculateRollModifier(t,r,a){var o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return"regenerate"==a.type?0:"skill"==a.type?a.name==game.i18n.localize("LocalizedIDs.featOfStrength")?2:0:"attack"==o.mode?4:0}}]),BloodrushEffect}(u),y=function(t){_inherits(PainEffect,t);var r=_createSuper(PainEffect);function PainEffect(){return _classCallCheck(this,PainEffect),r.apply(this,arguments)}return _createClass(PainEffect,null,[{key:"ModifierIsSelected",value:function ModifierIsSelected(t){var r=arguments.length>2?arguments[2]:void 0;return null==r.effects.find((function(t){return Array.from(t.statuses).includes("bloodrush")}))}}]),PainEffect}(u),g=function(t){_inherits(TranceEffect,t);var r=_createSuper(TranceEffect);function TranceEffect(){return _classCallCheck(this,TranceEffect),r.apply(this,arguments)}return _createClass(TranceEffect,null,[{key:"calculateRollModifier",value:function calculateRollModifier(t,r,a){if("regenerate"==a.type)return 0;switch(Number(this.clampedCondition(r,t))){case-2:var o=new RegExp("".concat(game.i18n.localize("combatskill")," "),"gi"),i=r.system.happyTalents.value.split(/;|,/).map((function(t){return t.replace(o,"").trim()}));if(i.includes(a.name)&&["skill","combatskill"].includes(a.type)||["rangeweapon","meleeweapon"].includes(a.type)&&i.includes(a.system.combatskill.value)||["ceremony","liturgy"].includes(a.type))return-2;case-3:return-3}return 0}}]),TranceEffect}(u),v=function(t){_inherits(DrunkenEffect,t);var r=_createSuper(DrunkenEffect);function DrunkenEffect(){return _classCallCheck(this,DrunkenEffect),r.apply(this,arguments)}return _createClass(DrunkenEffect,null,[{key:"calculateRollModifier",value:function calculateRollModifier(t,r,a){return"regenerate"==a.type?0:"skill"==a.type&&a.name==game.i18n.localize("LocalizedIDs.gambling")?Math.clamped(this.clampedCondition(r,t),-3,0):0}}]),DrunkenEffect}(u),_=function(t){_inherits(BurningEffect,t);var r=_createSuper(BurningEffect);function BurningEffect(){return _classCallCheck(this,BurningEffect),r.apply(this,arguments)}return _createClass(BurningEffect,null,[{key:"calculateRollModifier",value:function calculateRollModifier(t,r,a){return"regenerate"==a.type?0:"skill"==a.type&&a.name==game.i18n.localize("LocalizedIDs.bodyControl")?Math.clamped(this.clampedCondition(r,t)+1,-2,0):0}}]),BurningEffect}(u),b=function(t){_inherits(ArousalEffect,t);var r=_createSuper(ArousalEffect);function ArousalEffect(){return _classCallCheck(this,ArousalEffect),r.apply(this,arguments)}return _createClass(ArousalEffect,null,[{key:"calculateRollModifier",value:function calculateRollModifier(t,r,a){return 0}}]),ArousalEffect}(u),k=function(t){_inherits(SikaryanlossEffect,t);var r=_createSuper(SikaryanlossEffect);function SikaryanlossEffect(){return _classCallCheck(this,SikaryanlossEffect),r.apply(this,arguments)}return _createClass(SikaryanlossEffect,null,[{key:"calculateRollModifier",value:function calculateRollModifier(t,r,a){return"skill"==a.type&&a.name==game.i18n.localize("LocalizedIDs.willpower")?2*(this.clampedCondition(r,t)+1):"regenerate"==a.type?this.clampedCondition(r,t):0}}]),SikaryanlossEffect}(u),w=function(t){_inherits(DesireEffect,t);var r=_createSuper(DesireEffect);function DesireEffect(){return _classCallCheck(this,DesireEffect),r.apply(this,arguments)}return _createClass(DesireEffect,null,[{key:"calculateRollModifier",value:function calculateRollModifier(t,r,a){return"skill"==a.type&&a.name==game.i18n.localize("LocalizedIDs.willpower")?Math.clamped(this.clampedCondition(r,t),-3,0):0}}]),DesireEffect}(u),x=function(t){_inherits(TheriakEffect,t);var r=_createSuper(TheriakEffect);function TheriakEffect(){return _classCallCheck(this,TheriakEffect),r.apply(this,arguments)}return _createClass(TheriakEffect,null,[{key:"calculateRollModifier",value:function calculateRollModifier(t,r,a){return"regenerate"==a.type?-1*this.clampedCondition(r,t):0}}]),TheriakEffect}(u),S=function(t){_inherits(SunkenEffect,t);var r=_createSuper(SunkenEffect);function SunkenEffect(){return _classCallCheck(this,SunkenEffect),r.apply(this,arguments)}return _createClass(SunkenEffect,null,[{key:"calculateRollModifier",value:function calculateRollModifier(t,r,a){return"skill"==a.type&&"body"==a.system.group.value?-1*Math.clamped(this.clampedCondition(r,t)-1,3,0):0}}]),SunkenEffect}(u),T=function(t){_inherits(HungerEffect,t);var r=_createSuper(HungerEffect);function HungerEffect(){return _classCallCheck(this,HungerEffect),r.apply(this,arguments)}return _createClass(HungerEffect,null,[{key:"calculateRollModifier",value:function calculateRollModifier(t,r,a){return"regenerate"==a.type?-1*Math.pow(2,-1*this.clampedCondition(r,t)-1):0}}]),HungerEffect}(u),A=function(t){_inherits(ThirstEffect,t);var r=_createSuper(ThirstEffect);function ThirstEffect(){return _classCallCheck(this,ThirstEffect),r.apply(this,arguments)}return _createClass(ThirstEffect,null,[{key:"calculateRollModifier",value:function calculateRollModifier(t,r,a){var o=this.clampedCondition(r,t);return"regenerate"==a.type?1==o?-1:-5*o:Math.clamped(o-1,0,3)}},{key:"levelDependentEffects",value:function levelDependentEffects(t,r){r.changes={1:[],2:[{key:"system.condition.stunned",mode:2,value:.5}],3:[{key:"system.condition.stunned",mode:2,value:2/3}],4:[{key:"system.condition.stunned",mode:2,value:3/4}]}[r.flags.dsa5.value]}}]),ThirstEffect}(u),O=function(t){_inherits(HeatEffect,t);var r=_createSuper(HeatEffect);function HeatEffect(){return _classCallCheck(this,HeatEffect),r.apply(this,arguments)}return _createClass(HeatEffect,null,[{key:"levelDependentEffects",value:function levelDependentEffects(t,r){r.changes={1:[{key:"system.condition.stunned",mode:2,value:1},{key:"system.condition.confused",mode:2,value:1}],2:[{key:"system.condition.stunned",mode:2,value:1},{key:"system.condition.confused",mode:2,value:.5}],3:[{key:"system.condition.stunned",mode:2,value:1},{key:"system.condition.confused",mode:2,value:2/3}],4:[{key:"system.condition.stunned",mode:2,value:1},{key:"system.condition.confused",mode:2,value:.5}]}[r.flags.dsa5.value]}}]),HeatEffect}(u),P=function(t){_inherits(ColdEffect,t);var r=_createSuper(ColdEffect);function ColdEffect(){return _classCallCheck(this,ColdEffect),r.apply(this,arguments)}return _createClass(ColdEffect,null,[{key:"levelDependentEffects",value:function levelDependentEffects(t,r){r.changes={1:[{key:"system.condition.confused",mode:2,value:1},{key:"system.condition.paralysed",mode:2,value:1}],2:[{key:"system.condition.confused",mode:2,value:1},{key:"system.condition.paralysed",mode:2,value:.5}],3:[{key:"system.condition.confused",mode:2,value:1},{key:"system.condition.paralysed",mode:2,value:2/3}],4:[{key:"system.condition.confused",mode:2,value:1},{key:"system.condition.paralysed",mode:2,value:.5}]}[r.flags.dsa5.value]}}]),ColdEffect}(u),E=function(t){_inherits(NoModifierEffect,t);var r=_createSuper(NoModifierEffect);function NoModifierEffect(){return _classCallCheck(this,NoModifierEffect),r.apply(this,arguments)}return _createClass(NoModifierEffect,null,[{key:"calculateRollModifier",value:function calculateRollModifier(t,r,a){return 0}}]),NoModifierEffect}(u);i.Z.statusEffectClasses={inpain:y,heat:O,cold:P,encumbered:l,stunned:u,raptured:d,feared:u,paralysed:u,confused:u,prone:p,deaf:h,bloodrush:m,trance:g,drunken:v,arousal:b,burning:_,sikaryanloss:k,desire:w,theriak:x,services:E,sunken:S,hunger:T,thirst:A}},272:(t,r,a)=>{a.d(r,{Z:()=>u});var o=a(577),i=a(794),c=a(492);function _typeof(t){return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},_typeof(t)}function _toConsumableArray(t){return function _arrayWithoutHoles(t){if(Array.isArray(t))return _arrayLikeToArray(t)}(t)||function _iterableToArray(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function _unsupportedIterableToArray(t,r){if(!t)return;if("string"==typeof t)return _arrayLikeToArray(t,r);var a=Object.prototype.toString.call(t).slice(8,-1);"Object"===a&&t.constructor&&(a=t.constructor.name);if("Map"===a||"Set"===a)return Array.from(t);if("Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a))return _arrayLikeToArray(t,r)}(t)||function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function _arrayLikeToArray(t,r){(null==r||r>t.length)&&(r=t.length);for(var a=0,o=new Array(r);a=0;--o){var i=this.tryEntries[o],c=i.completion;if("root"===i.tryLoc)return handle("end");if(i.tryLoc<=this.prev){var u=a.call(i,"catchLoc"),l=a.call(i,"finallyLoc");if(u&&l){if(this.prev=0;--o){var i=this.tryEntries[o];if(i.tryLoc<=this.prev&&a.call(i,"finallyLoc")&&this.prev=0;--r){var a=this.tryEntries[r];if(a.finallyLoc===t)return this.complete(a.completion,a.afterLoc),resetTryEntry(a),l}},catch:function _catch(t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc===t){var o=a.completion;if("throw"===o.type){var i=o.arg;resetTryEntry(a)}return i}}throw new Error("illegal catch attempt")},delegateYield:function delegateYield(t,r,a){return this.delegate={iterator:values(t),resultName:r,nextLoc:a},"next"===this.method&&(this.arg=void 0),l}},t}function asyncGeneratorStep(t,r,a,o,i,c,u){try{var l=t[c](u),p=l.value}catch(t){return void a(t)}l.done?r(p):Promise.resolve(p).then(o,i)}function _asyncToGenerator(t){return function(){var r=this,a=arguments;return new Promise((function(o,i){var c=t.apply(r,a);function _next(t){asyncGeneratorStep(c,o,i,_next,_throw,"next",t)}function _throw(t){asyncGeneratorStep(c,o,i,_next,_throw,"throw",t)}_next(void 0)}))}}function _classCallCheck(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}function _defineProperties(t,r){for(var a=0;a2&&void 0!==i[2])||i[2],game.dsa5.config.removevantageRules[r.name]&&game.dsa5.config.removevantageRules[r.name](t,r),o=AdvantageRulesDSA5.calcAPCostSum(r),c.next=5,AdvantageRulesDSA5.removeSingularVantages(t,r,o);case 5:return o=c.sent,c.next=8,t._updateAPs(-1*o,{},{render:a});case 8:case"end":return c.stop()}}),_callee2)}))),function vantageRemoved(t,r){return i.apply(this,arguments)})},{key:"_vantageReturnFunction",value:(a=_asyncToGenerator(_regeneratorRuntime().mark((function _callee3(t,r,a,i){var c,u,l,p;return _regeneratorRuntime().wrap((function _callee3$(d){for(;;)switch(d.prev=d.next){case 0:if(null!=r){d.next=2;break}return d.abrupt("return");case 2:if(r=duplicate(r),/,/.test(r.system.APValue.value)&&(c=r.name.replace(" ()",""),r.system.APValue.value=r.system.APValue.value.split(",")[t.items.filter((function(t){return t.type==r.type&&t.name.includes(c)})).length].trim()),null!=i&&(AdvantageRulesDSA5.simpleAdoption(r,i,r.name,o.Z.vantagesNeedingAdaption),r.name="".concat(r.name.replace(" ()","")," (").concat(i.name,")"),i.data&&(r.system.APValue.value=r.system.APValue.value.split("/")[i.system.StF.value.charCodeAt(0)-65].trim())),!(u=t.items.find((function(t){return t.type==a&&t.name==r.name})))){d.next=25;break}if(p=duplicate(u),l=Number(/;/.test(p.system.APValue.value)?p.system.APValue.value.split(";").map((function(t){return Number(t.trim())}))[p.system.step.value]:p.system.APValue.value),d.t0=p.system.step.value+1<=p.system.max.value,!d.t0){d.next=14;break}return d.next=13,t.checkEnoughXP(l);case 13:d.t0=d.sent;case 14:if(!d.t0){d.next=23;break}return p.system.step.value+=1,l=this.addSingularVantages(t,p,l),d.next=19,t._updateAPs(l,{},{render:!1});case 19:return d.next=21,t.updateEmbeddedDocuments("Item",[p]);case 21:return d.next=23,AdvantageRulesDSA5.vantageAdded(t,p);case 23:d.next=35;break;case 25:return d.next=27,t.checkEnoughXP(l=Number(r.system.APValue.value.split(";").map((function(t){return t.trim()}))[0]));case 27:if(!d.sent){d.next=35;break}return d.next=30,AdvantageRulesDSA5.vantageAdded(t,r);case 30:return l=this.addSingularVantages(t,r,l),d.next=33,t._updateAPs(l,{},{render:!1});case 33:return d.next=35,t.createEmbeddedDocuments("Item",[r]);case 35:case"end":return d.stop()}}),_callee3,this)}))),function _vantageReturnFunction(t,r,o,i){return a.apply(this,arguments)})},{key:"needsAdoption",value:(r=_asyncToGenerator(_regeneratorRuntime().mark((function _callee4(t,r,a){var i,u,l;return _regeneratorRuntime().wrap((function _callee4$(p){for(;;)switch(p.prev=p.next){case 0:if(!o.Z.vantagesNeedingAdaption[r.name]){p.next=17;break}if("text"!=o.Z.vantagesNeedingAdaption[r.name].items){p.next=8;break}return p.next=4,renderTemplate("systems/dsa5/templates/dialog/requires-adoption-string-dialog.html",{original:r});case 4:i=p.sent,u=function callback(o){var i={name:o.find('[name="entryselection"]').val()};AdvantageRulesDSA5._vantageReturnFunction(t,r,a,i)},p.next=13;break;case 8:return l=t.items.filter((function(t){return o.Z.vantagesNeedingAdaption[r.name].items.includes(t.type)})),p.next=11,renderTemplate("systems/dsa5/templates/dialog/requires-adoption-dialog.html",{items:l,original:r});case 11:i=p.sent,u=function callback(o){var i=l.find((function(t){return t.name==o.find('[name="entryselection"]').val()}));AdvantageRulesDSA5._vantageReturnFunction(t,r,a,i)};case 13:return p.next=15,new c.Z({title:game.i18n.localize("DIALOG.ItemRequiresAdoption"),content:i,buttons:{Yes:{icon:'',label:game.i18n.localize("yes"),callback:u},cancel:{icon:'',label:game.i18n.localize("cancel")}},default:"Yes"}).render(!0);case 15:p.next=18;break;case 17:AdvantageRulesDSA5._vantageReturnFunction(t,r,a,null);case 18:case"end":return p.stop()}}),_callee4)}))),function needsAdoption(t,a,o){return r.apply(this,arguments)})},{key:"addSingularVantages",value:function addSingularVantages(t,r,a){return AdvantageRulesDSA5._calculateSingularVantages(r,t,a,(function filter(t,r,a){return"disadvantage"==t.type&&r.test(t.name)}))}},{key:"removeSingularVantages",value:function removeSingularVantages(t,r,a){return AdvantageRulesDSA5._calculateSingularVantages(r,t,a,(function filter(t,r,a){return"disadvantage"==t.type&&r.test(t.name)&&t.name!=a.name}))}},{key:"_calculateSingularVantages",value:function _calculateSingularVantages(t,r,a,o){var i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:function(t,r){return Math.min(0,t-r)};if("disadvantage"!=t.type)return a;for(var c=function _loop(){var c=l[u],p=new RegExp("^".concat(game.i18n.localize("LocalizedIDs."+c)," \\("));if(p.test(t.name)){var d=r.items.filter((function(r){return o(r,p,t)})),h=Math.min.apply(Math,[0].concat(_toConsumableArray(d.map((function(t){return AdvantageRulesDSA5.calcAPCostSum(t)}))))),m=AdvantageRulesDSA5.calcAPCostSum(t);a=i(m,h)}},u=0,l=["principles","obligations"];u2&&void 0!==arguments[2]?arguments[2]:1,o=arguments.length>3&&void 0!==arguments[3]&&arguments[3],i=arguments.length>4&&void 0!==arguments[4]&&arguments[4];return _get(_getPrototypeOf(AdvantageRulesDSA5),"itemAsModifier",this).call(this,t,r,a,["advantage","disadvantage"],o,i)}}]),AdvantageRulesDSA5}(i.Z);i.Z.children.AdvantageRulesDSA5=u},231:(t,r,a)=>{a.d(r,{Z:()=>l});var o=a(947),i=a(903),c=a(491),u=a(416);function _typeof(t){return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},_typeof(t)}function _regeneratorRuntime(){_regeneratorRuntime=function _regeneratorRuntime(){return t};var t={},r=Object.prototype,a=r.hasOwnProperty,o="function"==typeof Symbol?Symbol:{},i=o.iterator||"@@iterator",c=o.asyncIterator||"@@asyncIterator",u=o.toStringTag||"@@toStringTag";function define(t,r,a){return Object.defineProperty(t,r,{value:a,enumerable:!0,configurable:!0,writable:!0}),t[r]}try{define({},"")}catch(t){define=function define(t,r,a){return t[r]=a}}function wrap(t,r,a,o){var i=r&&r.prototype instanceof Generator?r:Generator,c=Object.create(i.prototype),u=new Context(o||[]);return c._invoke=function(t,r,a){var o="suspendedStart";return function(i,c){if("executing"===o)throw new Error("Generator is already running");if("completed"===o){if("throw"===i)throw c;return doneResult()}for(a.method=i,a.arg=c;;){var u=a.delegate;if(u){var p=maybeInvokeDelegate(u,a);if(p){if(p===l)continue;return p}}if("next"===a.method)a.sent=a._sent=a.arg;else if("throw"===a.method){if("suspendedStart"===o)throw o="completed",a.arg;a.dispatchException(a.arg)}else"return"===a.method&&a.abrupt("return",a.arg);o="executing";var d=tryCatch(t,r,a);if("normal"===d.type){if(o=a.done?"completed":"suspendedYield",d.arg===l)continue;return{value:d.arg,done:a.done}}"throw"===d.type&&(o="completed",a.method="throw",a.arg=d.arg)}}}(t,a,u),c}function tryCatch(t,r,a){try{return{type:"normal",arg:t.call(r,a)}}catch(t){return{type:"throw",arg:t}}}t.wrap=wrap;var l={};function Generator(){}function GeneratorFunction(){}function GeneratorFunctionPrototype(){}var p={};define(p,i,(function(){return this}));var d=Object.getPrototypeOf,h=d&&d(d(values([])));h&&h!==r&&a.call(h,i)&&(p=h);var m=GeneratorFunctionPrototype.prototype=Generator.prototype=Object.create(p);function defineIteratorMethods(t){["next","throw","return"].forEach((function(r){define(t,r,(function(t){return this._invoke(r,t)}))}))}function AsyncIterator(t,r){function invoke(o,i,c,u){var l=tryCatch(t[o],t,i);if("throw"!==l.type){var p=l.arg,d=p.value;return d&&"object"==_typeof(d)&&a.call(d,"__await")?r.resolve(d.__await).then((function(t){invoke("next",t,c,u)}),(function(t){invoke("throw",t,c,u)})):r.resolve(d).then((function(t){p.value=t,c(p)}),(function(t){return invoke("throw",t,c,u)}))}u(l.arg)}var o;this._invoke=function(t,a){function callInvokeWithMethodAndArg(){return new r((function(r,o){invoke(t,a,r,o)}))}return o=o?o.then(callInvokeWithMethodAndArg,callInvokeWithMethodAndArg):callInvokeWithMethodAndArg()}}function maybeInvokeDelegate(t,r){var a=t.iterator[r.method];if(void 0===a){if(r.delegate=null,"throw"===r.method){if(t.iterator.return&&(r.method="return",r.arg=void 0,maybeInvokeDelegate(t,r),"throw"===r.method))return l;r.method="throw",r.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var o=tryCatch(a,t.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,l;var i=o.arg;return i?i.done?(r[t.resultName]=i.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=void 0),r.delegate=null,l):i:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,l)}function pushTryEntry(t){var r={tryLoc:t[0]};1 in t&&(r.catchLoc=t[1]),2 in t&&(r.finallyLoc=t[2],r.afterLoc=t[3]),this.tryEntries.push(r)}function resetTryEntry(t){var r=t.completion||{};r.type="normal",delete r.arg,t.completion=r}function Context(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(pushTryEntry,this),this.reset(!0)}function values(t){if(t){var r=t[i];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var o=-1,c=function next(){for(;++o=0;--o){var i=this.tryEntries[o],c=i.completion;if("root"===i.tryLoc)return handle("end");if(i.tryLoc<=this.prev){var u=a.call(i,"catchLoc"),l=a.call(i,"finallyLoc");if(u&&l){if(this.prev=0;--o){var i=this.tryEntries[o];if(i.tryLoc<=this.prev&&a.call(i,"finallyLoc")&&this.prev=0;--r){var a=this.tryEntries[r];if(a.finallyLoc===t)return this.complete(a.completion,a.afterLoc),resetTryEntry(a),l}},catch:function _catch(t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc===t){var o=a.completion;if("throw"===o.type){var i=o.arg;resetTryEntry(a)}return i}}throw new Error("illegal catch attempt")},delegateYield:function delegateYield(t,r,a){return this.delegate={iterator:values(t),resultName:r,nextLoc:a},"next"===this.method&&(this.arg=void 0),l}},t}function asyncGeneratorStep(t,r,a,o,i,c,u){try{var l=t[c](u),p=l.value}catch(t){return void a(t)}l.done?r(p):Promise.resolve(p).then(o,i)}function _asyncToGenerator(t){return function(){var r=this,a=arguments;return new Promise((function(o,i){var c=t.apply(r,a);function _next(t){asyncGeneratorStep(c,o,i,_next,_throw,"next",t)}function _throw(t){asyncGeneratorStep(c,o,i,_next,_throw,"throw",t)}_next(void 0)}))}}function _defineProperties(t,r){for(var a=0;a1&&void 0!==arguments[1]?arguments[1]:void 0;t=t.replace(/(-|\+)?\d+/g,"").trim();var a=DSA5ChatAutoCompletion.skills.filter((function(a){return-1!=a.name.toLowerCase().trim().indexOf(t)&&(null==r||r==a.type)})).slice(0,5);return this._checkEmpty(a),a}},{key:"_filterCH",value:function _filterCH(t,r){this._setList(this._getSkills(t),"CH",r)}},{key:"_filterSK",value:function _filterSK(t,r){this._setList(this._getSkills(t),"SK",r)}},{key:"_filterRQ",value:function _filterRQ(t,r){this._setList(this._getSkills(t),"RQ",r)}},{key:"_filterGC",value:function _filterGC(t,r){this._setList(this._getSkills(t,"skill"),"GC",r)}},{key:"_setList",value:function _setList(t,r,a){var o=$('
    '.concat(t.map((function(t){return'
  • ').concat(t.name,"
  • ")})).join(""),"
"));o.find(".quick-item:first").addClass("focus");var i=$(a.currentTarget).closest("#chat-form"),c=i.find(".quickfind");c.length?c.replaceWith(o):i.append(o)}},{key:"_navigateQuickFind",value:function _navigateQuickFind(t){if(this.filtering){var r=$(t.currentTarget).closest("#chat-form").find(".focus");switch(t.which){case 38:return r.prev(".quick-item").length&&r.removeClass("focus").prev(".quick-item").addClass("focus"),!1;case 40:return r.next(".quick-item").length&&r.removeClass("focus").next(".quick-item").addClass("focus"),!1;case 13:if("W"==r.attr("data-category"))break;return t.stopPropagation(),t.preventDefault(),this._quickSelect(r),!1;case 9:return t.stopPropagation(),t.preventDefault(),this._completeCurrentEntry(r),!1}}return!0}},{key:"_quickSelect",value:function _quickSelect(t){var r=t.attr("data-category");switch(r){case"NM":case"GC":case"RQ":case"CH":this["_quick".concat(r)](t);break;case"W":this._completeCurrentEntry(t);break;default:var a=DSA5ChatAutoCompletion._getActor(),o=a.actor,i=a.tokenId;o&&(this._resetChatAutoCompletion(t),this["_quick".concat(r)](t,o,i))}}},{key:"_quickW",value:function _quickW(t,r,a){}},{key:"_quickCH",value:function _quickCH(t){o.Z.check3D20(t),this._resetChatAutoCompletion(t)}},{key:"_quickSK",value:function _quickSK(t,r,a){switch(t.attr("data-type")){case"skill":var o=r.items.find((function(r){return r.name==t.text()&&"skill"==r.type}));o&&r.setupSkill(o,{},a).then((function(t){r.basicTest(t)}));break;case"attribute":var i=Object.keys(game.dsa5.config.characteristics).find((function(r){return game.i18n.localize(game.dsa5.config.characteristics[r])==t.text()}));r.setupCharacteristic(i,{},a).then((function(t){r.basicTest(t)}));break;case"regeneration":r.setupRegeneration("regenerate",{},a).then((function(t){r.basicTest(t)}))}}},{key:"_resetChatAutoCompletion",value:function _resetChatAutoCompletion(t){var r=t.closest("#chat-form");r.find("#chat-message").val(""),r.find(".quickfind").remove()}},{key:"_quickGC",value:function _quickGC(t){var r=Number($("#chat-message").val().match(/(-|\+)?\d+/g))||0;this._resetChatAutoCompletion(t),i.Z.showGCMessage(t.text(),r)}},{key:"_quickRQ",value:function _quickRQ(t){var r=Number($("#chat-message").val().match(/(-|\+)?\d+/g))||0;this._resetChatAutoCompletion(t),i.Z.showRQMessage(t.text(),r)}},{key:"_quickPA",value:function _quickPA(t,r,a){var o=t.text();if(this.combatConstants.dodge==o)r.setupDodge({},a).then((function(t){r.basicTest(t)}));else if(this.combatConstants.parryWeaponless==o)r.setupWeaponless("parry",{},a).then((function(t){r.basicTest(t)}));else{var i=["meleeweapon"],c=r.items.find((function(r){return i.includes(r.type)&&r.name==t.text()}));c&&r.setupWeapon(c,"parry",{},a).then((function(t){r.basicTest(t)}))}}},{key:"_quickAT",value:function _quickAT(t,r,a){var o=t.text();if(this.combatConstants.attackWeaponless==o)r.setupWeaponless("attack",{},a).then((function(t){r.basicTest(t)}));else{var i=["meleeweapon","rangeweapon"],c=["meleeAttack","rangeAttack"],u=r.items.find((function(r){return i.includes(r.type)&&r.name==t.text()}));u||(u=r.items.find((function(r){return"trait"==r.type&&r.name==t.text()&&c.includes(r.system.traitType.value)}))),u&&r.setupWeapon(u,"attack",{},a).then((function(t){r.basicTest(t)}))}}},{key:"_quickSP",value:function _quickSP(t,r,a){var o=["ritual","spell"],i=r.items.find((function(r){return o.includes(r.type)&&r.name==t.text()}));i&&r.setupSpell(i,{},a).then((function(t){r.basicTest(t)}))}},{key:"_quickLI",value:function _quickLI(t,r,a){var o=["liturgy","ceremony"],i=r.items.find((function(r){return o.includes(r.type)&&r.name==t.text()}));i&&r.setupSpell(i,{},a).then((function(t){r.basicTest(t)}))}}],[{key:"_getActor",value:function _getActor(){var t,r=ChatMessage.getSpeaker();return r.token&&(t=game.actors.tokens[r.token]),t||(t=game.actors.get(r.actor)),t?{actor:t,tokenId:r.token}:(ui.notifications.error(game.i18n.localize("DSAError.noProperActor")),{})}},{key:"infoItemAsync",value:(t=_asyncToGenerator(_regeneratorRuntime().mark((function _callee4(t){return _regeneratorRuntime().wrap((function _callee4$(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,fromUuid(t);case 2:r.sent.postItem();case 4:case"end":return r.stop()}}),_callee4)}))),function infoItemAsync(r){return t.apply(this,arguments)})},{key:"bindRollCommands",value:function bindRollCommands(t){var r=this;t.on("click",".request-roll",(function(t){return i.Z.showRQMessage(t.currentTarget.dataset.name,Number(t.currentTarget.dataset.modifier)||0),t.stopPropagation(),!1})),t.on("click",".postInfo",(function(t){var a=fromUuidSync(t.currentTarget.dataset.uuid);return a&&("function"==typeof a.postItem?a.postItem():r.infoItemAsync(t.currentTarget.dataset.uuid)),t.stopPropagation(),!1})),t.on("click",".postContentChat",function(){var t=_asyncToGenerator(_regeneratorRuntime().mark((function _callee5(t){var r;return _regeneratorRuntime().wrap((function _callee5$(a){for(;;)switch(a.prev=a.next){case 0:r=$(t.currentTarget).closest(".postChatSection").find(".postChatContent").html(),u.TB.getDialog(r);case 2:case"end":return a.stop()}}),_callee5)})));return function(r){return t.apply(this,arguments)}}()),t.on("click",".request-GC",(function(t){return i.Z.showGCMessage(t.currentTarget.dataset.name,Number(t.currentTarget.dataset.modifier)||0),t.stopPropagation(),!1})),t.on("click",".request-CH",(function(t){return o.Z.check3D20(void 0,t.currentTarget.dataset.name,{modifier:Number(t.currentTarget.dataset.modifier)||0}),t.stopPropagation(),!1}))}}]),DSA5ChatAutoCompletion}();_defineProperty(l,"skills",[]),_defineProperty(l,"cmds",["sk","at","pa","sp","li","rq","gc","w","ch"])},947:(t,r,a)=>{a.d(r,{Z:()=>p});var o=a(577),i=a(491),c=a(586),u=a(122),l=a(147);function _typeof(t){return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},_typeof(t)}function _regeneratorRuntime(){_regeneratorRuntime=function _regeneratorRuntime(){return t};var t={},r=Object.prototype,a=r.hasOwnProperty,o="function"==typeof Symbol?Symbol:{},i=o.iterator||"@@iterator",c=o.asyncIterator||"@@asyncIterator",u=o.toStringTag||"@@toStringTag";function define(t,r,a){return Object.defineProperty(t,r,{value:a,enumerable:!0,configurable:!0,writable:!0}),t[r]}try{define({},"")}catch(t){define=function define(t,r,a){return t[r]=a}}function wrap(t,r,a,o){var i=r&&r.prototype instanceof Generator?r:Generator,c=Object.create(i.prototype),u=new Context(o||[]);return c._invoke=function(t,r,a){var o="suspendedStart";return function(i,c){if("executing"===o)throw new Error("Generator is already running");if("completed"===o){if("throw"===i)throw c;return doneResult()}for(a.method=i,a.arg=c;;){var u=a.delegate;if(u){var p=maybeInvokeDelegate(u,a);if(p){if(p===l)continue;return p}}if("next"===a.method)a.sent=a._sent=a.arg;else if("throw"===a.method){if("suspendedStart"===o)throw o="completed",a.arg;a.dispatchException(a.arg)}else"return"===a.method&&a.abrupt("return",a.arg);o="executing";var d=tryCatch(t,r,a);if("normal"===d.type){if(o=a.done?"completed":"suspendedYield",d.arg===l)continue;return{value:d.arg,done:a.done}}"throw"===d.type&&(o="completed",a.method="throw",a.arg=d.arg)}}}(t,a,u),c}function tryCatch(t,r,a){try{return{type:"normal",arg:t.call(r,a)}}catch(t){return{type:"throw",arg:t}}}t.wrap=wrap;var l={};function Generator(){}function GeneratorFunction(){}function GeneratorFunctionPrototype(){}var p={};define(p,i,(function(){return this}));var d=Object.getPrototypeOf,h=d&&d(d(values([])));h&&h!==r&&a.call(h,i)&&(p=h);var m=GeneratorFunctionPrototype.prototype=Generator.prototype=Object.create(p);function defineIteratorMethods(t){["next","throw","return"].forEach((function(r){define(t,r,(function(t){return this._invoke(r,t)}))}))}function AsyncIterator(t,r){function invoke(o,i,c,u){var l=tryCatch(t[o],t,i);if("throw"!==l.type){var p=l.arg,d=p.value;return d&&"object"==_typeof(d)&&a.call(d,"__await")?r.resolve(d.__await).then((function(t){invoke("next",t,c,u)}),(function(t){invoke("throw",t,c,u)})):r.resolve(d).then((function(t){p.value=t,c(p)}),(function(t){return invoke("throw",t,c,u)}))}u(l.arg)}var o;this._invoke=function(t,a){function callInvokeWithMethodAndArg(){return new r((function(r,o){invoke(t,a,r,o)}))}return o=o?o.then(callInvokeWithMethodAndArg,callInvokeWithMethodAndArg):callInvokeWithMethodAndArg()}}function maybeInvokeDelegate(t,r){var a=t.iterator[r.method];if(void 0===a){if(r.delegate=null,"throw"===r.method){if(t.iterator.return&&(r.method="return",r.arg=void 0,maybeInvokeDelegate(t,r),"throw"===r.method))return l;r.method="throw",r.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var o=tryCatch(a,t.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,l;var i=o.arg;return i?i.done?(r[t.resultName]=i.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=void 0),r.delegate=null,l):i:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,l)}function pushTryEntry(t){var r={tryLoc:t[0]};1 in t&&(r.catchLoc=t[1]),2 in t&&(r.finallyLoc=t[2],r.afterLoc=t[3]),this.tryEntries.push(r)}function resetTryEntry(t){var r=t.completion||{};r.type="normal",delete r.arg,t.completion=r}function Context(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(pushTryEntry,this),this.reset(!0)}function values(t){if(t){var r=t[i];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var o=-1,c=function next(){for(;++o=0;--o){var i=this.tryEntries[o],c=i.completion;if("root"===i.tryLoc)return handle("end");if(i.tryLoc<=this.prev){var u=a.call(i,"catchLoc"),l=a.call(i,"finallyLoc");if(u&&l){if(this.prev=0;--o){var i=this.tryEntries[o];if(i.tryLoc<=this.prev&&a.call(i,"finallyLoc")&&this.prev=0;--r){var a=this.tryEntries[r];if(a.finallyLoc===t)return this.complete(a.completion,a.afterLoc),resetTryEntry(a),l}},catch:function _catch(t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc===t){var o=a.completion;if("throw"===o.type){var i=o.arg;resetTryEntry(a)}return i}}throw new Error("illegal catch attempt")},delegateYield:function delegateYield(t,r,a){return this.delegate={iterator:values(t),resultName:r,nextLoc:a},"next"===this.method&&(this.arg=void 0),l}},t}function asyncGeneratorStep(t,r,a,o,i,c,u){try{var l=t[c](u),p=l.value}catch(t){return void a(t)}l.done?r(p):Promise.resolve(p).then(o,i)}function _asyncToGenerator(t){return function(){var r=this,a=arguments;return new Promise((function(o,i){var c=t.apply(r,a);function _next(t){asyncGeneratorStep(c,o,i,_next,_throw,"next",t)}function _throw(t){asyncGeneratorStep(c,o,i,_next,_throw,"throw",t)}_next(void 0)}))}}function _defineProperties(t,r){for(var a=0;a');r.click((function(){DSA5ChatListeners.getHelp()})),$(t.find(".control-buttons")).prepend(r),t.on("click",".showPatchViewer",(function(){return(0,c.j)()})),t.on("click",".functionswitch",(function(t){return u.Z[t.currentTarget.dataset.function](t)})),t.on("click",".panToToken",(function(t){return DSA5ChatListeners.panToToken(t)})),t.on("click",".popoutImage",(function(t){return(0,l.d)(t)}))}},{key:"panToToken",value:(a=_asyncToGenerator(_regeneratorRuntime().mark((function _callee(t){var r;return _regeneratorRuntime().wrap((function _callee$(a){for(;;)switch(a.prev=a.next){case 0:return a.next=2,fromUuid(t.currentTarget.dataset.uuid);case 2:if(r=a.sent){a.next=5;break}return a.abrupt("return");case 5:if(canvas.animatePan({x:r.x,y:r.y}),r.isOwner){a.next=8;break}return a.abrupt("return");case 8:r.object.control({releaseOthers:!0});case 9:case"end":return a.stop()}}),_callee)}))),function panToToken(t){return a.apply(this,arguments)})},{key:"postStatus",value:function postStatus(t){var r=CONFIG.statusEffects.find((function(r){return r.id==t})),a='

').concat(game.i18n.localize(r.name),"

").concat(game.i18n.localize(r.description),"

");ChatMessage.create(i.Z.chatDataSetup(a,"roll"))}},{key:"getHelp",value:function getHelp(){var t=o.Z.helpContent.map((function(t){return"

".concat(game.i18n.localize("HELP.".concat(t.name)),"

\n

").concat(game.i18n.localize("HELP.command"),": ").concat(t.command,"

\n

").concat(game.i18n.localize("HELP.example"),": ").concat(t.example,"

\n

").concat(game.i18n.localize("Description"),": ").concat(game.i18n.localize("HELP.descr".concat(t.name)))})).join("")+"
\n

".concat(game.i18n.localize("HELP.default"),"

");ChatMessage.create(i.Z.chatDataSetup(t,"roll"))}},{key:"showConditions",value:function showConditions(){var t=duplicate(CONFIG.statusEffects).map((function(t){return t.name=game.i18n.localize(t.name),t})).sort((function(t,r){return t.name.localeCompare(r.name)})).map((function(t){return'').concat(t.name,"")})).join(" ");ChatMessage.create(i.Z.chatDataSetup(t,"roll"))}},{key:"check3D20",value:(r=_asyncToGenerator(_regeneratorRuntime().mark((function _callee2(t,r){var a,o,c,u=arguments;return _regeneratorRuntime().wrap((function _callee2$(l){for(;;)switch(l.prev=l.next){case 0:if(a=u.length>2&&void 0!==u[2]?u[2]:{},o=12,!t){l.next=10;break}return t=t.get(0),l.next=6,i.Z.skillByName(t.textContent);case 6:r=l.sent,t.dataset.attrs&&(o=t.dataset.attrs.split("|")),l.next=14;break;case 10:if(!r){l.next=14;break}return l.next=13,i.Z.skillByName(r);case 13:r=l.sent;case 14:return r&&(r=r.toObject()),r||(r={name:"3d20",type:"skill",system:{talentValue:{value:0},characteristic1:{value:"mu"},characteristic2:{value:"kl"},characteristic3:{value:"in"},RPr:{value:"no"},burden:{value:"no"}}}),l.next=18,i.Z.emptyActor(o);case 18:(c=l.sent).setupSkill(r,a,"emptyActor").then((function(t){c.basicTest(t)}));case 20:case"end":return l.stop()}}),_callee2)}))),function check3D20(t,a){return r.apply(this,arguments)})},{key:"showTables",value:(t=_asyncToGenerator(_regeneratorRuntime().mark((function _callee3(){var t;return _regeneratorRuntime().wrap((function _callee3$(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,renderTemplate("systems/dsa5/templates/tables/systemtables.html",{tables:o.Z.systemTables});case 2:t=r.sent,ChatMessage.create(i.Z.chatDataSetup(t,"roll"));case 4:case"end":return r.stop()}}),_callee3)}))),function showTables(){return t.apply(this,arguments)})}]),DSA5ChatListeners}()},577:(t,r,a)=>{a.d(r,{Z:()=>i});var o={statusEffects:[{icon:"icons/svg/skull.svg",id:"dead",name:"CONDITION.defeated",label:"CONDITION.defeated",description:"CONDITIONDESCRIPTION.defeated",flags:{dsa5:{value:null,editable:!0}}},{id:"inpain",name:"CONDITION.inpain",icon:"icons/svg/blood.svg",description:"CONDITIONDESCRIPTION.inpain",changes:[{key:"system.condition.inpain",mode:2,value:1}],flags:{dsa5:{value:1,editable:!0,max:4}}},{id:"prone",name:"CONDITION.prone",icon:"icons/svg/falling.svg",description:"CONDITIONDESCRIPTION.prone",flags:{dsa5:{value:null,editable:!0}}},{id:"unconscious",name:"CONDITION.unconscious",icon:"icons/svg/unconscious.svg",description:"CONDITIONDESCRIPTION.unconscious",flags:{dsa5:{value:null,editable:!0}}},{id:"rooted",name:"CONDITION.rooted",icon:"icons/svg/net.svg",description:"CONDITIONDESCRIPTION.rooted",flags:{dsa5:{value:null,editable:!0}}},{id:"fixated",name:"CONDITION.fixated",icon:"icons/svg/padlock.svg",description:"CONDITIONDESCRIPTION.fixated",flags:{dsa5:{value:null,editable:!0}}},{id:"surprised",name:"CONDITION.surprised",icon:"icons/svg/hazard.svg",description:"CONDITIONDESCRIPTION.surprised",flags:{dsa5:{value:null,editable:!0}}},{id:"blind",name:"CONDITION.blind",icon:"icons/svg/blind.svg",description:"CONDITIONDESCRIPTION.blind",flags:{dsa5:{value:null,editable:!0}}},{id:"poisoned",name:"CONDITION.poisoned",icon:"icons/svg/poison.svg",description:"CONDITIONDESCRIPTION.poisoned",flags:{dsa5:{value:null,editable:!0}}},{id:"sick",name:"CONDITION.sick",icon:"icons/svg/biohazard.svg",description:"CONDITIONDESCRIPTION.sick",flags:{dsa5:{value:null,editable:!0}}},{id:"deaf",name:"CONDITION.deaf",icon:"icons/svg/deaf.svg",description:"CONDITIONDESCRIPTION.deaf",flags:{dsa5:{value:null,editable:!0}}},{id:"burning",name:"CONDITION.burning",icon:"icons/svg/fire.svg",description:"CONDITIONDESCRIPTION.burning",flags:{dsa5:{value:1,editable:!0,max:3}}},{id:"invisible",name:"CONDITION.invisible",icon:"icons/svg/circle.svg",description:"CONDITIONDESCRIPTION.invisible",flags:{dsa5:{value:null,editable:!0}}},{id:"constricted",name:"CONDITION.constricted",icon:"icons/svg/cave.svg",description:"CONDITIONDESCRIPTION.constricted",flags:{dsa5:{value:null,editable:!0}}},{id:"bloodrush",name:"CONDITION.bloodrush",icon:"icons/svg/bones.svg",description:"CONDITIONDESCRIPTION.bloodrush",changes:[{key:"system.skillModifiers.step",mode:0,value:"Kraftakt 2;Feat of Strength 2"}],flags:{dsa5:{value:null,editable:!0}}},{id:"mute",name:"CONDITION.mute",icon:"icons/svg/silenced.svg",description:"CONDITIONDESCRIPTION.mute",flags:{dsa5:{value:null,editable:!0}}},{id:"incapacitated",name:"CONDITION.incapacitated",icon:"icons/svg/sleep.svg",description:"CONDITIONDESCRIPTION.incapacitated",flags:{dsa5:{value:null,editable:!0}}},{id:"encumbered",name:"CONDITION.encumbered",icon:"icons/svg/anchor.svg",changes:[{key:"system.condition.encumbered",mode:2,value:1}],description:"CONDITIONDESCRIPTION.encumbered",flags:{dsa5:{value:1,editable:!0,max:4}}},{id:"stunned",name:"CONDITION.stunned",icon:"icons/svg/daze.svg",changes:[{key:"system.condition.stunned",mode:2,value:1}],description:"CONDITIONDESCRIPTION.stunned",flags:{dsa5:{value:1,editable:!0,max:4}}},{id:"raptured",name:"CONDITION.raptured",icon:"icons/svg/ice-aura.svg",changes:[{key:"system.condition.raptured",mode:2,value:1}],description:"CONDITIONDESCRIPTION.raptured",flags:{dsa5:{value:1,editable:!0,max:4}}},{id:"feared",name:"CONDITION.feared",icon:"icons/svg/terror.svg",description:"CONDITIONDESCRIPTION.feared",changes:[{key:"system.condition.feared",mode:2,value:1}],flags:{dsa5:{value:1,editable:!0,max:4}}},{id:"paralysed",name:"CONDITION.paralysed",icon:"icons/svg/paralysis.svg",description:"CONDITIONDESCRIPTION.paralysed",changes:[{key:"system.condition.paralysed",mode:2,value:1}],flags:{dsa5:{value:1,editable:!0,max:4}}},{id:"confused",name:"CONDITION.confused",icon:"icons/svg/stoned.svg",description:"CONDITIONDESCRIPTION.confused",changes:[{key:"system.condition.confused",mode:2,value:1}],flags:{dsa5:{value:1,editable:!0,max:4}}},{id:"minorSpirits",name:"CONDITION.minorSpirits",icon:"icons/svg/terror.svg",description:"CONDITIONDESCRIPTION.minorSpirits",changes:[{key:"system.skillModifiers.global",mode:0,value:-1}],duration:{seconds:600},flags:{dsa5:{value:null,editable:!0}}},{id:"services",name:"PLAYER.services",icon:"icons/svg/aura.svg",description:"CONDITIONDESCRIPTION.services",flags:{dsa5:{value:1,editable:!0,max:500,hideOnToken:!0}}}],armorSubcategories:{0:4,1:5,2:6,3:8,4:9,5:13,6:12,7:11,8:10},weaponStabilities:{Blowpipes:10,Bows:4,Brawling:12,"Chain Weapons":10,Crossbows:6,Daggers:14,Discuses:12,Fans:13,"Fencing Weapons":8,"Impact Weapons":12,Lances:6,Pikes:12,Polearms:12,Shields:10,Slingshots:4,Swords:13,"Throwing Weapons":10,"Two-Handed Impact Weapons":11,"Two-Handed Swords":12,Whips:4},journalFontSizes:[8,10,12,14,16,18,20,24,28,32],styles:{"dsa5-immersive":"dsaStyle.immersive","dsa5-naked":"dsaStyle.naked"},fallingConditions:{normal:0,soft1:-1,soft2:-2,soft3:-3,soft4:-4,rough1:1,rough2:2,rough3:3,rough4:4},combatSkillSubCategories:{0:"COMBATSKILLCATEGORY.0",1:"COMBATSKILLCATEGORY.1",2:"COMBATSKILLCATEGORY.2",3:"COMBATSKILLCATEGORY.3",4:"COMBATSKILLCATEGORY.4"}};o.effectTextStyle=CONFIG.canvasTextStyle.clone(),o.effectTextStyle.fontSize="30",o.effectTextStyle.fontFamily="GentiumBasic",o.knownShortcuts={},o.gearModifyableCalculatedAttributes=["fatePoints","initiative","speed","astralenergy","karmaenergy","wounds","dodge","soulpower","toughness"],o.defaultWeapon={name:"default",type:"meleeweapon",effects:[],system:{type:"meleeweapon",crit:1,botch:20,reach:{value:"short"},damage:{value:"1d6"},atmod:{value:0,offHandMod:0},pamod:{value:0,offHandMod:0},guidevalue:{value:"ge/kk"},damageThreshold:{value:"5000"},worn:{offhand:!1}}},o.asyncHooks={postProcessDSARoll:[]},o.characteristics={mu:"CHAR.MU",kl:"CHAR.KL",in:"CHAR.IN",ch:"CHAR.CH",ff:"CHAR.FF",ge:"CHAR.GE",ko:"CHAR.KO",kk:"CHAR.KK"},o.equipmentTypes={misc:"Equipment.misc",clothes:"Equipment.clothes",tools:"Equipment.tools",light:"Equipment.light",healing:"Equipment.healing",bags:"Equipment.bags",wealth:"Equipment.wealth",writing:"Equipment.writing",alchemy:"Equipment.alchemy",service:"Equipment.service",luxus:"Equipment.luxus",blessed:"Equipment.blessed",food:"Equipment.food"},o.equipmentCategories=["meleeweapon","rangeweapon","equipment","ammunition","armor","poison","consumable","plant"],o.systemTables=[{name:"Defense",attrs:'data-weaponless="false"',roll:"botch-roll",pack:{de:"dsa5.patzer",en:"dsa5.botch"},setting:{module:"dsa5",key:"defenseBotchTableEnabled"}},{name:"Melee",attrs:'data-weaponless="false"',roll:"botch-roll",pack:{de:"dsa5.patzer",en:"dsa5.botch"},setting:{module:"dsa5",key:"meleeBotchTableEnabled"}},{name:"Range",attrs:'data-weaponless="false"',roll:"botch-roll",pack:{de:"dsa5.patzer",en:"dsa5.botch"},setting:{module:"dsa5",key:"rangeBotchTableEnabled"}},{name:"Liturgy",attrs:"",roll:"botch-roll",pack:{de:"dsa5.patzer",en:"dsa5.botch"},setting:{module:"",key:""}},{name:"Spell",attrs:"",roll:"botch-roll",pack:{de:"dsa5.patzer",en:"dsa5.botch"},setting:{module:"",key:""}}],o.morePackages={packages:{},names:{de:[],en:[]}},o.narrowSpaceModifiers={weaponshort:{attack:0,parry:0,label:"NarrowSpaceModifiers.weapon.short"},weaponmedium:{attack:-4,parry:-4,label:"NarrowSpaceModifiers.weapon.medium"},weaponlong:{attack:-8,parry:-8,label:"NarrowSpaceModifiers.weapon.long"},shieldshort:{attack:-2,parry:-2,label:"NarrowSpaceModifiers.shield.short"},shieldmedium:{attack:-4,parry:-3,label:"NarrowSpaceModifiers.shield.medium"},shieldlong:{attack:-6,parry:-4,label:"NarrowSpaceModifiers.shield.long"}},o.traditionArtifacts={Animistenwaffe:15,Bannschwert:15,Druidendolch:15,Druidensichel:12,Zauberkleidung:15,Magierkugel:12,Zauberinstrument:15,Narrenkappe:15,Hexenkessel:15,Krallenkette:12,Lebensring:12,Alchimistenschale:15,"Scharlatanische Zauberkugel":15,Sippenchronik:15,Schelmenspielzeug:12,Zauberstecken:0,Magierstab:18,Trinkhorn:12,Schuppenbeutel:18,"Kristallomantische Kristallkugel":15,Echsenhaube:12},o.moneyNames={D:"Money-D",S:"Money-S",H:"Money-H",K:"Money-K"},o.areaTargetTypes={cube:"rect",line:"ray",sphere:"circle",cone:"cone"},o.rangeMods={short:{damage:1,attack:2},medium:{damage:0,attack:0},long:{damage:-1,attack:-2},rangesense:{damage:-1,attack:-1},extreme:{damage:-2,attack:-4}},o.regnerationCampLocations={0:"regnerationCampLocations.normal","-1":"regnerationCampLocations.bad",1:"regnerationCampLocations.good"},o.regenerationInterruptOptions={0:"regenerationInterruptOptions.none","-1":"regenerationInterruptOptions.small","-2":"regenerationInterruptOptions.big"},o.targetMomevementOptions={0:"rangeMovementOptions.SLOW","-2":"rangeMovementOptions.FAST",2:"rangeMovementOptions.STATIONARY"},o.allowedforeignfields=["system.details.notes.value"],o.shooterMovementOptions={0:"rangeMovementOptions.SHOOTERSTATIONARY","-2":"rangeMovementOptions.SHOOTERMOVING","-4":"rangeMovementOptions.SHOOTERRUNNING"},o.mountedRangeOptionsSpecAb={STATIONARY:"0",SCHRITT:"0",TROT:"-5000",GALOPP:"-4"},o.mountedRangeOptions={STATIONARY:"0",SCHRITT:"-4",TROT:"-5000",GALOPP:"-8"},o.drivingArcherOptions={STATIONARY:"0",SCHRITT:"-2",GALOPP:"-4"},o.aimOptions={0:"aimOptions.0",2:"aimOptions.1",4:"aimOptions.2"},o.traitCategories={meleeAttack:"closeCombatAttacks",rangeAttack:"rangeCombatAttacks",armor:"armor",general:"general",familiar:"familiar",trick:"trick",training:"training",entity:"entityAbility",summoning:"summoningPackage"},o.ritualLocationModifiers={0:"-",1:"RITUALMODIFIER.holysite","-3":"RITUALMODIFIER.wrongsite"},o.ritualTimeModifiers={0:"-",1:"RITUALMODIFIER.matchingConstellation","-1":"RITUALMODIFIER.wrongConstellation"},o.ceremonyLocationModifiers={0:"-",2:"CEREMONYMODIFIER.holysite",1:"CEREMONYMODIFIER.temple","-1":"CEREMONYMODIFIER.otherTemple","-2":"CEREMONYMODIFIER.enemyGod","-3":"CEREMONYMODIFIER.archDemon","-4":"CEREMONYMODIFIER.nameless","-5":"CEREMONYMODIFIER.nemesis"},o.advancementCosts={A:[1,1,1,1,1,1,1,1,1,1,1,1,1,2,3,4,5,6,7,8,9,10,11,12,13,14],B:[2,2,2,2,2,2,2,2,2,2,2,2,2,4,6,8,10,12,14,16,18,20,22,24,26,28],C:[3,3,3,3,3,3,3,3,3,3,3,3,3,6,9,12,15,18,21,24,27,30,33,36,39,42],D:[4,4,4,4,4,4,4,4,4,4,4,4,4,8,12,16,20,24,28,32,36,40,44,48,52,56],E:[15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,30,45,60,75,90,105,120,135,150,165,180]},o.hooks={},o.startXP={900:"EXP.inexperienced",1e3:"EXP.average",1100:"EXP.experienced",1200:"EXP.competent",1400:"EXP.masterful",1700:"EXP.brillant",2100:"EXP.legendary"},o.helpContent=[{name:"pay",command:"/pay [0-9]+",example:"/pay 5.03"},{name:"getPaid",command:"/getPaid [0-9]+",example:"/getPaid 5.03"},{name:"quickAbility",command:"/sk [a-z]*, /sp [a-z]*, /li [a-z]*, /at [a-z]*, /pa [a-z]*",example:"/sk betören"},{name:"conditions",command:"/conditions",example:"/conditions"},{name:"tables",command:"/tables",example:"/tables"},{name:"request",command:"/rq",example:"/rq betören"},{name:"threeD20Check",command:"/ch",example:"/ch"},{name:"groupcheck",command:"/gc",example:"/gc"}],o.ceremonyTimeModifiers={0:"-",1:"CEREMONYMODIFIER.monthGod",2:"CEREMONYMODIFIER.celebration","-5":"CEREMONYMODIFIER.namelessDays"},o.mageLevels={mundane:"mundane",clerical:"clerical",magical:"magical"},o.specialAbilityCategories={general:"general",Combat:"Combat",fatePoints:"fatePoints",magical:"magical",clerical:"clerical",language:"language",animal:"animal",staff:"traditionArtifact",ceremonial:"ceremonialItem",pact:"pactgift"},o.addvantageRules={},o.removevantageRules={},o.vantagesNeedingAdaption={},o.addAbilityRules={},o.removeAbilityRules={},o.AbilitiesNeedingAdaption={},o.addTraitRules={},o.rangeWeaponModifiers={short:"RangeMod.short",medium:"RangeMod.medium",long:"RangeMod.long",rangesense:"RangeMod.rangesense",extreme:"RangeMod.extreme"},o.meleeRangesArray=["short","medium","long"],o.meleeRanges={short:"Range-short",medium:"Range-medium",long:"Range-long"},o.weapontypes={melee:"meleeweapon",range:"rangeweapon"},o.ammunitiongroups={"-":"-",arrow:"arrow",bolt:"bolt",bullet:"bullet",stone:"stone",dart:"dart",mag:"mag",infinite:"infinite"},o.combatskillsGuidevalues={ff:"CHAR.FF",ge:"CHAR.GE",kk:"CHAR.KK","ge/kk":"CHAR.GEKK"},o.skillDifficultyModifiers={eeasy:5,veasy:3,easy:1,challenging:0,difficult:-1,hard:-3,vhard:-5},o.magicResistanceModifiers={"-":"-",SK:"soulpower",ZK:"toughness"},o.sizeCategories={tiny:"SIZE.tiny",small:"SIZE.small",average:"SIZE.average",big:"SIZE.big",giant:"SIZE.giant"},o.tokenSizeCategories={tiny:.5,small:.8,average:1,big:2,giant:4},o.rangeSizeCategories={tiny:"RANGESIZE.tiny",small:"RANGESIZE.small",average:"RANGESIZE.average",big:"RANGESIZE.big",giant:"RANGESIZE.giant"},o.meleeSizeCategories={tiny:"MELEESIZE.tiny",small:"MELEESIZE.small",average:"MELEESIZE.average",big:"MELEESIZE.big",giant:"MELEESIZE.giant"},o.shieldSizes={short:"SIZE.small",medium:"SIZE.average",long:"SIZE.big"},o.rangeSizeModifier={tiny:-8,small:-4,average:0,big:4,giant:8},o.meleeSizeModifier={tiny:-4,small:0,average:0,big:0,giant:0},o.rangeVision={0:"VisionDisruption.step0","-2":"VisionDisruption.step1","-4":"VisionDisruption.step2","-6":"VisionDisruption.step3","-5000":"VisionDisruption.step4"},o.meleeRangeVision=function(t){return function _defineProperty(t,r,a){return r in t?Object.defineProperty(t,r,{value:a,enumerable:!0,configurable:!0,writable:!0}):t[r]=a,t}({"+0":"meleeVisionDisruption.0","-1":"meleeVisionDisruption.1","-2":"meleeVisionDisruption.2","-3":"meleeVisionDisruption.3"},"attack"==t?"*0,5":"-5000","meleeVisionDisruption.4")},o.attributeDifficultyModifiers={eeasy:6,veasy:4,easy:2,challenging:0,difficult:-2,hard:-4,vhard:-6},o.skillDifficultyLabels={eeasy:"Skill-eeasy",veasy:"Skill-veasy",easy:"Skill-easy",challenging:"Skill-challenging",difficult:"Skill-difficult",hard:"Skill-hard",vhard:"Skill-vhard"},o.attributeDifficultyLabels={eeasy:"Attribute-eeasy",veasy:"Attribute-veasy",easy:"Attribute-easy",challenging:"Attribute-challenging",difficult:"Attribute-difficult",hard:"Attribute-hard",vhard:"Attribute-vhard"},o.skillGroups={body:"SKILL.body",social:"SKILL.social",knowledge:"SKILL.knowledge",trade:"SKILL.trade",nature:"SKILL.nature"},o.features=["Object","Spheres","Influence","Clairvoyance","Healing","Transformation","Telekinesis","Elemental","Illusion","Anti-Magic","Demonic","Temporal"],o.skillBurdens={yes:"yes",no:"no",maybe:"maybe"},o.StFs={A:"A",B:"B",C:"C",D:"D"},o.noteIcons={"Griffin Shield":"systems/dsa5/icons/thirdparty/griffinshield.svg","At Sea":"systems/dsa5/icons/thirdparty/at-sea.svg","Medieval Gate":"systems/dsa5/icons/thirdparty/medieval-gate.svg","Position Marker":"systems/dsa5/icons/thirdparty/position-marker.svg",River:"systems/dsa5/icons/thirdparty/river.svg",Trail:"systems/dsa5/icons/thirdparty/trail.svg"},CONFIG.time.roundTime=5,CONFIG.time.turnTime=0;const i=o},472:(t,r,a)=>{a.d(r,{Z:()=>i});var o=a(491);function _typeof(t){return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},_typeof(t)}function _get(){return _get="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function _get(t,r,a){var o=_superPropBase(t,r);if(o){var i=Object.getOwnPropertyDescriptor(o,r);return i.get?i.get.call(arguments.length<3?t:a):i.value}},_get.apply(this,arguments)}function _superPropBase(t,r){for(;!Object.prototype.hasOwnProperty.call(t,r)&&null!==(t=_getPrototypeOf(t)););return t}function _inherits(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(r&&r.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),r&&_setPrototypeOf(t,r)}function _setPrototypeOf(t,r){return _setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function _setPrototypeOf(t,r){return t.__proto__=r,t},_setPrototypeOf(t,r)}function _createSuper(t){var r=function _isNativeReflectConstruct(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function _createSuperInternal(){var a,o=_getPrototypeOf(t);if(r){var i=_getPrototypeOf(this).constructor;a=Reflect.construct(o,arguments,i)}else a=o.apply(this,arguments);return _possibleConstructorReturn(this,a)}}function _possibleConstructorReturn(t,r){if(r&&("object"===_typeof(r)||"function"==typeof r))return r;if(void 0!==r)throw new TypeError("Derived constructors may only return object or undefined");return function _assertThisInitialized(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}function _getPrototypeOf(t){return _getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function _getPrototypeOf(t){return t.__proto__||Object.getPrototypeOf(t)},_getPrototypeOf(t)}function _toConsumableArray(t){return function _arrayWithoutHoles(t){if(Array.isArray(t))return _arrayLikeToArray(t)}(t)||function _iterableToArray(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||_unsupportedIterableToArray(t)||function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function _createForOfIteratorHelper(t,r){var a="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!a){if(Array.isArray(t)||(a=_unsupportedIterableToArray(t))||r&&t&&"number"==typeof t.length){a&&(t=a);var o=0,i=function F(){};return{s:i,n:function n(){return o>=t.length?{done:!0}:{done:!1,value:t[o++]}},e:function e(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var c,u=!0,l=!1;return{s:function s(){a=a.call(t)},n:function n(){var t=a.next();return u=t.done,t},e:function e(t){l=!0,c=t},f:function f(){try{u||null==a.return||a.return()}finally{if(l)throw c}}}}function _unsupportedIterableToArray(t,r){if(t){if("string"==typeof t)return _arrayLikeToArray(t,r);var a=Object.prototype.toString.call(t).slice(8,-1);return"Object"===a&&t.constructor&&(a=t.constructor.name),"Map"===a||"Set"===a?Array.from(t):"Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a)?_arrayLikeToArray(t,r):void 0}}function _arrayLikeToArray(t,r){(null==r||r>t.length)&&(r=t.length);for(var a=0,o=new Array(r);a=0;--o){var i=this.tryEntries[o],c=i.completion;if("root"===i.tryLoc)return handle("end");if(i.tryLoc<=this.prev){var u=a.call(i,"catchLoc"),l=a.call(i,"finallyLoc");if(u&&l){if(this.prev=0;--o){var i=this.tryEntries[o];if(i.tryLoc<=this.prev&&a.call(i,"finallyLoc")&&this.prev=0;--r){var a=this.tryEntries[r];if(a.finallyLoc===t)return this.complete(a.completion,a.afterLoc),resetTryEntry(a),l}},catch:function _catch(t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc===t){var o=a.completion;if("throw"===o.type){var i=o.arg;resetTryEntry(a)}return i}}throw new Error("illegal catch attempt")},delegateYield:function delegateYield(t,r,a){return this.delegate={iterator:values(t),resultName:r,nextLoc:a},"next"===this.method&&(this.arg=void 0),l}},t}function asyncGeneratorStep(t,r,a,o,i,c,u){try{var l=t[c](u),p=l.value}catch(t){return void a(t)}l.done?r(p):Promise.resolve(p).then(o,i)}function _asyncToGenerator(t){return function(){var r=this,a=arguments;return new Promise((function(o,i){var c=t.apply(r,a);function _next(t){asyncGeneratorStep(c,o,i,_next,_throw,"next",t)}function _throw(t){asyncGeneratorStep(c,o,i,_next,_throw,"throw",t)}_next(void 0)}))}}Hooks.once("i18nInit",_asyncToGenerator(_regeneratorRuntime().mark((function _callee(){var t;return _regeneratorRuntime().wrap((function _callee$(r){for(;;)switch(r.prev=r.next){case 0:if(i.creatureData){r.next=11;break}return r.next=3,fetch("systems/dsa5/lazy/creaturetype/".concat(game.i18n.lang,".json"));case 3:return t=r.sent,r.next=6,t.json();case 6:i.creatureData=r.sent,i.magical=game.i18n.localize("WEAPON.magical"),i.clerical=game.i18n.localize("WEAPON.clerical"),i.silverPlated=game.i18n.localize("WEAPON.silverPlated"),game.dsa5.apps.CreatureType=i;case 11:case"end":return r.stop()}}),_callee)}))));var i=function(){function CreatureType(t){_classCallCheck(this,CreatureType),this.creatureClass=t,this.spellImmunities=[],this.poisonImmunity=!1,this.diseaseImmunity=!1}return _createClass(CreatureType,[{key:"getName",value:function getName(){var t=this;return Object.keys(CreatureType.creatureData.types).find((function(r){return CreatureType.creatureData.types[r]==t.constructor.name}))}},{key:"ignoredCondition",value:function ignoredCondition(t){return!1}},{key:"damageModifier",value:function damageModifier(t){return[]}},{key:"spellImmunity",value:function spellImmunity(t){return this.spellImmunities.some((function(r){return t.includes(r)}))}},{key:"spellArmorModifier",value:function spellArmorModifier(t){return 0}},{key:"poisonImmunity",value:function poisonImmunity(){return this.poisonImmunity}},{key:"diseaseImmunity",value:function diseaseImmunity(){return this.diseaseImmunity}},{key:"spellResistanceModifier",value:function spellResistanceModifier(t){return 0}},{key:"weaponAttributes",value:function weaponAttributes(t){return getProperty(t,"system.effect.attributes")||""}},{key:"getTypeByClass",value:function getTypeByClass(t){return Object.keys(CreatureType.creatureData.types).find((function(r){return CreatureType.creatureData.types[r]===t}))}},{key:"isAttackItem",value:function isAttackItem(t){return["meleeweapon","trait","rangeweapon"].includes(t.type)&&function isNotEmpty(t){return!(!t||0===t.length)}(this.weaponAttributes(t))}},{key:"attributesRegex",value:function attributesRegex(t){var r=this.weaponAttributes(t);return new RegExp("(".concat(r.split(",").map((function(t){return o.Z.escapeRegex(t.split("(")[0].trim())})).join("|"),")"),"i")}}],[{key:"detectCreatureType",value:function detectCreatureType(t){var r=this,a="creature"==t.type?t.system.creatureClass.value:t.system.details.species.value;return Object.keys(CreatureType.creatureData.types).filter((function(t){return a.indexOf(t)>=0})).map((function(t){return r.getClass(CreatureType.creatureData.types[t],a)}))}},{key:"getClass",value:function getClass(t,r){return new(0,{DemonType:d,ChimeraType:u,DaimonidType:l,DragonType:p,ElementalType:h,FairyType:m,GhostType:y,GolemType:g,HomunculiType:v,IntelligentCreatureType:_,PlantType:b,AnimalType:k,UndeadType:w,SupernaturalType:x,MagicalConstructType:S,WerCreatureType:T,VampireType:A}[t])(r)}},{key:"checkImmunity",value:function checkImmunity(t){var r=[];switch(t.preData.source.type){case"poison":case"disease":var a=function(){var a,o=game.i18n.localize("LocalizedIDs.immuneTo")+" ("+t.preData.source.name+")",i=_createForOfIteratorHelper(game.user.targets);try{for(i.s();!(a=i.n()).done;){var c=a.value,u=c.actor,l=u.items.find((function(t){return t.name==o&&"advantage"==t.type}));if(l)r.push({name:l.name,uuid:l.uuid,target:u.name,condition:t.preData.source.name});else{var p,d=_createForOfIteratorHelper(CreatureType.detectCreatureType(c.actor));try{for(d.s();!(p=d.n()).done;){var h=p.value;if(h["".concat(t.preData.source.type,"Immunity")]){r.push({name:t.preData.source.name,target:"".concat(u.name," (").concat(h.getName(),")"),condition:t.preData.source.name});break}}}catch(t){d.e(t)}finally{d.f()}}}}catch(t){i.e(t)}finally{i.f()}return"break"}();if("break"===a)break;case"spell":case"ritual":var o,i=_createForOfIteratorHelper(game.user.targets);try{for(i.s();!(o=i.n()).done;){var c,u=o.value,l=CreatureType.detectCreatureType(u.actor),p=t.preData.source.system.feature.split(",").map((function(t){return t.trim()})),d=!1,h=_createForOfIteratorHelper(l);try{for(h.s();!(c=h.n()).done;){var m,y=c.value,g=_createForOfIteratorHelper(p);try{for(g.s();!(m=g.n()).done;){var v=m.value;if(y.spellImmunities.includes(v)){r.push({name:t.preData.source.name,target:"".concat(u.actor.name," (").concat(y.getName(),")"),condition:"".concat(game.i18n.localize("feature")," ").concat(v)}),d=!0;break}}}catch(t){g.e(t)}finally{g.f()}if(d)break}}catch(t){h.e(t)}finally{h.f()}}}catch(t){i.e(t)}finally{i.f()}}return r}},{key:"creatureTypeName",value:function creatureTypeName(t){if("creature"==t.type){var r=t.system.creatureClass.value;return Object.keys(CreatureType.creatureData.types).filter((function(t){return r.indexOf(t)>=0}))[0]}return t.system.details.species.value}},{key:"addCreatureTypeModifiers",value:function addCreatureTypeModifiers(t,r,a,o){var i,c=CreatureType.detectCreatureType(t),u=["spell","ceremony","liturgy","ritual"].includes(r.type),l=_createForOfIteratorHelper(c);try{for(l.s();!(i=l.n()).done;){var p=i.value,d=p.damageModifier(r);if(u){var h,m=_createForOfIteratorHelper(d);try{for(m.s();!(h=m.n()).done;){h.value.armorPen=p.spellResistanceModifier(t)}}catch(t){m.e(t)}finally{m.f()}}a.push.apply(a,_toConsumableArray(d))}}catch(t){l.e(t)}finally{l.f()}a.push.apply(a,_toConsumableArray(this.creatureBonusDamage(t,o))),CreatureType.addVulnerabilitiesToSource(t,r,a)}},{key:"addVulnerabilitiesToSource",value:function addVulnerabilitiesToSource(t,r,a){var o=getProperty(t,"system.vulnerabilities");o&&(["meleeweapon","rangeweapon"].includes(r.type)&&getProperty(o,"combatskill").reduce((function(t,o){if(o.target==r.system.combatskill.value){var i=(/\*/.test(o.value)?Number(o.value.replace("*",""))>1:Number(o.value)>0)?"WEAPON.vulnerableTo":"WEAPON.resistantTo";a.push.apply(a,_toConsumableArray(CreatureType.buildDamageMod("".concat(game.i18n.format(i,{name:r.system.combatskill.value})," (").concat(o.source,")"),o.value)))}}),a))}},{key:"creatureBonusDamage",value:function creatureBonusDamage(t,r){var a,o=[],i="creature"==t.type?t.system.creatureClass.value:t.system.details.species.value,c=_createForOfIteratorHelper(getProperty(r,"system.creatureBonus"));try{for(c.s();!(a=c.n()).done;){var u=a.value;i.indexOf(u.target)>=0&&o.push.apply(o,_toConsumableArray(this.buildDamageMod(u.source,u.value,!0)))}}catch(t){c.e(t)}finally{c.f()}return o}},{key:"buildDamageMod",value:function buildDamageMod(t,r){var a=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];return[{name:t,value:r,selected:a,type:"dmg",source:game.i18n.localize("target")}]}}]),CreatureType}();_defineProperty(i,"creatureData",void 0),_defineProperty(i,"magical",void 0),_defineProperty(i,"clerical",void 0);var c=function(t){_inherits(VulnerableToLifeGods,t);var r=_createSuper(VulnerableToLifeGods);function VulnerableToLifeGods(){return _classCallCheck(this,VulnerableToLifeGods),r.apply(this,arguments)}return _createClass(VulnerableToLifeGods,[{key:"damageModifier",value:function damageModifier(t){if(this.isAttackItem(t)){var r,a=this.attributesRegex(t),o=_createForOfIteratorHelper(i.creatureData.godOfLife);try{for(o.s();!(r=o.n()).done;){var c=r.value,u="".concat(i.clerical," (").concat(c,")");if(a.test(u))return i.buildDamageMod(u,"*2")}}catch(t){o.e(t)}finally{o.f()}}return _get(_getPrototypeOf(VulnerableToLifeGods.prototype),"damageModifier",this).call(this,t)}}]),VulnerableToLifeGods}(i),u=function(t){_inherits(ChimeraType,t);var r=_createSuper(ChimeraType);function ChimeraType(){return _classCallCheck(this,ChimeraType),r.apply(this,arguments)}return _createClass(ChimeraType)}(c),l=function(t){_inherits(DaimonidType,t);var r=_createSuper(DaimonidType);function DaimonidType(t){var a;return _classCallCheck(this,DaimonidType),(a=r.call(this,t)).spellImmunities=["Influence","Transformation"].map((function(t){return game.i18n.localize("Features.".concat(t))})),a}return _createClass(DaimonidType,[{key:"damageModifier",value:function damageModifier(t){if(this.isAttackItem(t)&&this.attributesRegex(t).test(i.clerical))return i.buildDamageMod(i.clerical,"*2");return _get(_getPrototypeOf(DaimonidType.prototype),"damageModifier",this).call(this,t)}}]),DaimonidType}(i),p=function(t){_inherits(DragonType,t);var r=_createSuper(DragonType);function DragonType(){return _classCallCheck(this,DragonType),r.apply(this,arguments)}return _createClass(DragonType)}(i),d=function(t){_inherits(DemonType,t);var r=_createSuper(DemonType);function DemonType(t){var a;return _classCallCheck(this,DemonType),(a=r.call(this,t)).spellImmunities=["Influence","Transformation","Healing","Illusion"].map((function(t){return game.i18n.localize("Features.".concat(t))})),a.poisonImmunity=!0,a.diseaseImmunity=!0,a}return _createClass(DemonType,[{key:"damageModifier",value:function damageModifier(t){if(this.isAttackItem(t)){var r=this.attributesRegex(t);if(r.test(i.clerical))return i.buildDamageMod("".concat(i.clerical," (").concat(i.creatureData.opposingGod,")"),"*2",!1);if(r.test(i.magical))return _get(_getPrototypeOf(DemonType.prototype),"damageModifier",this).call(this,t)}else if(["spell","ceremony","liturgy","ritual"].includes(t.type))return _get(_getPrototypeOf(DemonType.prototype),"damageModifier",this).call(this,t);return i.buildDamageMod(this.getTypeByClass("DemonType"),"*0.5")}},{key:"spellArmorModifier",value:function spellArmorModifier(t){return Number(t.system.status.soulpower.max)}},{key:"spellResistanceModifier",value:function spellResistanceModifier(t){return Number(t.system.status.soulpower.max)}},{key:"ignoredCondition",value:function ignoredCondition(t){return!0}}]),DemonType}(i),h=function(t){_inherits(ElementalType,t);var r=_createSuper(ElementalType);function ElementalType(t){var a;return _classCallCheck(this,ElementalType),(a=r.call(this,t)).poisonImmunity=!0,a.diseaseImmunity=!0,a}return _createClass(ElementalType,[{key:"damageModifier",value:function damageModifier(t){if(this.isAttackItem(t)){if(this.attributesRegex(t).test(i.magical))return _get(_getPrototypeOf(ElementalType.prototype),"damageModifier",this).call(this,t)}else if(["spell","ceremony","liturgy","ritual"].includes(t.type))return i.buildDamageMod(this.getTypeByClass("ElementalType"),"*1");return i.buildDamageMod(this.getTypeByClass("ElementalType"),"*0.5")}},{key:"spellArmorModifier",value:function spellArmorModifier(t){return Number(t.system.status.soulpower.max)}},{key:"spellResistanceModifier",value:function spellResistanceModifier(t){return Number(t.system.status.soulpower.max)}},{key:"ignoredCondition",value:function ignoredCondition(t){return!0}}]),ElementalType}(i),m=function(t){_inherits(FairyType,t);var r=_createSuper(FairyType);function FairyType(t){var a;return _classCallCheck(this,FairyType),(a=r.call(this,t)).spellImmunities=["Illusion"].map((function(t){return game.i18n.localize("Features.".concat(t))})),a.poisonImmunity=!0,a.diseaseImmunity=!0,a}return _createClass(FairyType)}(i),y=function(t){_inherits(GhostType,t);var r=_createSuper(GhostType);function GhostType(t){var a;return _classCallCheck(this,GhostType),(a=r.call(this,t)).spellImmunities=["Illusion","Healing","Telekinesis","Transformation"].map((function(t){return game.i18n.localize("Features.".concat(t))})),a.poisonImmunity=!0,a.diseaseImmunity=!0,a}return _createClass(GhostType,[{key:"damageModifier",value:function damageModifier(t){if(this.isAttackItem(t)){var r,a=this.attributesRegex(t),o=_createForOfIteratorHelper(i.creatureData.godOfDeath);try{for(o.s();!(r=o.n()).done;){var c=r.value,u="".concat(i.clerical," (").concat(c,")");if(a.test(u))return[]}}catch(t){o.e(t)}finally{o.f()}if((a=this.attributesRegex(t)).test(i.clerical))return i.buildDamageMod(i.clerical,"*0.5");if(a.test(i.magical))return i.buildDamageMod(i.magical,"*0.5")}else if(["spell","ceremony","liturgy","ritual"].includes(t.type))return i.buildDamageMod(i.magical,"*0.5");return i.buildDamageMod(this.getTypeByClass("GhostType"),"*0")}},{key:"ignoredCondition",value:function ignoredCondition(t){return!["feared","inpain","confused"].includes(t)}}]),GhostType}(i),g=function(t){_inherits(GolemType,t);var r=_createSuper(GolemType);function GolemType(t){var a;return _classCallCheck(this,GolemType),(a=r.call(this,t)).spellImmunities=["Transformation"].map((function(t){return game.i18n.localize("Features.".concat(t))})),a.poisonImmunity=!0,a.diseaseImmunity=!0,a}return _createClass(GolemType,[{key:"ignoredCondition",value:function ignoredCondition(t){return!["confused","paralysed"].includes(t)}}]),GolemType}(c),v=function(t){_inherits(HomunculiType,t);var r=_createSuper(HomunculiType);function HomunculiType(t){var a;return _classCallCheck(this,HomunculiType),(a=r.call(this,t)).spellImmunities=["Healing"].map((function(t){return game.i18n.localize("Features.".concat(t))})),a}return _createClass(HomunculiType,[{key:"ignoredCondition",value:function ignoredCondition(t){return!["inpain","encumbered","stunned","feared","paralysed","confused"].includes(t)}}]),HomunculiType}(c),_=function(t){_inherits(IntelligentCreatureType,t);var r=_createSuper(IntelligentCreatureType);function IntelligentCreatureType(){return _classCallCheck(this,IntelligentCreatureType),r.apply(this,arguments)}return _createClass(IntelligentCreatureType)}(i),b=function(t){_inherits(PlantType,t);var r=_createSuper(PlantType);function PlantType(){return _classCallCheck(this,PlantType),r.apply(this,arguments)}return _createClass(PlantType)}(i),k=function(t){_inherits(AnimalType,t);var r=_createSuper(AnimalType);function AnimalType(){return _classCallCheck(this,AnimalType),r.apply(this,arguments)}return _createClass(AnimalType)}(i),w=function(t){_inherits(UndeadType,t);var r=_createSuper(UndeadType);function UndeadType(t){var a;return _classCallCheck(this,UndeadType),(a=r.call(this,t)).spellImmunities=["Influence","Healing","Illusion"].map((function(t){return game.i18n.localize("Features.".concat(t))})),a.poisonImmunity=!0,a.diseaseImmunity=!0,a}return _createClass(UndeadType,[{key:"damageModifier",value:function damageModifier(t){if(this.isAttackItem(t)){var r,a=this.attributesRegex(t),o=_createForOfIteratorHelper(i.creatureData.godOfDeath);try{for(o.s();!(r=o.n()).done;){var c=r.value,u="".concat(i.clerical," (").concat(c,")");if(a.test(u))return i.buildDamageMod(u,"*2")}}catch(t){o.e(t)}finally{o.f()}}return _get(_getPrototypeOf(UndeadType.prototype),"damageModifier",this).call(this,t)}},{key:"ignoredCondition",value:function ignoredCondition(t){return!["paralysed"].includes(t)}}]),UndeadType}(i),x=function(t){_inherits(SupernaturalType,t);var r=_createSuper(SupernaturalType);function SupernaturalType(){return _classCallCheck(this,SupernaturalType),r.apply(this,arguments)}return _createClass(SupernaturalType)}(i),S=function(t){_inherits(MagicalConstructType,t);var r=_createSuper(MagicalConstructType);function MagicalConstructType(t){var a;return _classCallCheck(this,MagicalConstructType),(a=r.call(this,t)).spellImmunities=["Transformation"].map((function(t){return game.i18n.localize("Features.".concat(t))})),a.poisonImmunity=!0,a.diseaseImmunity=!0,a}return _createClass(MagicalConstructType,[{key:"ignoredCondition",value:function ignoredCondition(t){return!["stunned","feared","paralysed","confused"].includes(t)}}]),MagicalConstructType}(i),T=function(t){_inherits(WerCreatureType,t);var r=_createSuper(WerCreatureType);function WerCreatureType(){return _classCallCheck(this,WerCreatureType),r.apply(this,arguments)}return _createClass(WerCreatureType,[{key:"damageModifier",value:function damageModifier(t){if(this.isAttackItem(t)){if(this.attributesRegex(t).test(i.silverPlated))return i.buildDamageMod(this.getTypeByClass("WerCreatureType"),"*2")}else if(["spell","ceremony","liturgy","ritual"].includes(t.type))return _get(_getPrototypeOf(WerCreatureType.prototype),"damageModifier",this).call(this,t);return i.buildDamageMod(this.getTypeByClass("WerCreatureType"),"*0.5")}}]),WerCreatureType}(i),A=function(t){_inherits(VampireType,t);var r=_createSuper(VampireType);function VampireType(){return _classCallCheck(this,VampireType),r.apply(this,arguments)}return _createClass(VampireType,[{key:"damageModifier",value:function damageModifier(t){return["spell","ceremony","liturgy","ritual"].includes(t.type)?_get(_getPrototypeOf(VampireType.prototype),"damageModifier",this).call(this,t):i.buildDamageMod(this.getTypeByClass("VampireType"),"*0.5")}}]),VampireType}(i)},565:(t,r,a)=>{a.d(r,{Z:()=>i});var o=a(272);function _createForOfIteratorHelper(t,r){var a="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!a){if(Array.isArray(t)||(a=function _unsupportedIterableToArray(t,r){if(!t)return;if("string"==typeof t)return _arrayLikeToArray(t,r);var a=Object.prototype.toString.call(t).slice(8,-1);"Object"===a&&t.constructor&&(a=t.constructor.name);if("Map"===a||"Set"===a)return Array.from(t);if("Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a))return _arrayLikeToArray(t,r)}(t))||r&&t&&"number"==typeof t.length){a&&(t=a);var o=0,i=function F(){};return{s:i,n:function n(){return o>=t.length?{done:!0}:{done:!1,value:t[o++]}},e:function e(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var c,u=!0,l=!1;return{s:function s(){a=a.call(t)},n:function n(){var t=a.next();return u=t.done,t},e:function e(t){l=!0,c=t},f:function f(){try{u||null==a.return||a.return()}finally{if(l)throw c}}}}function _arrayLikeToArray(t,r){(null==r||r>t.length)&&(r=t.length);for(var a=0,o=new Array(r);a=u,p=c.object.document.config.dim>=u;if((l||p)&&((!1===c.data.walls||c.shape.contains(t.center.x,t.center.y))&&(r=l||r,a=p||a),r))break}else if(r=r||c.data.bright>0,a=a||c.data.dim>0,r)break}}catch(t){i.e(t)}finally{i.f()}}return{bright:r,dim:a}}},{key:"isEnabled",get:function get(){var t,r,a=null===(t=canvas)||void 0===t||null===(r=t.scene)||void 0===r?void 0:r.getFlag("dsa5","enableDPS");return a?"2"==a:game.settings.get("dsa5","enableDPS")}},{key:"lightLevel",value:function lightLevel(t,r){if(canvas.scene&&game.settings.get("dsa5","sightAutomationEnabled")){for(var a,i=0,c=(null===(a=canvas.scene)||void 0===a?void 0:a.darkness)||0,u=game.settings.get("dsa5","sightOptions").split("|").map((function(t){return Number(t)}));u[i]<=c;)i+=1;if(t){var l=o.Z.vantageStep(t,game.i18n.localize("LocalizedIDs.darksight")),p=Number(getProperty(t,"system.sightModifier.value"))||0,d=Number(getProperty(t,"system.sightModifier.maxLevel"))||3,h=Array.from(game.user.targets);if(h.length){h=h[0];var m=DPS.inLight(h),y=0;m.bright?y=-2:m.dim&&(y=-1),i=Math.max(i+y,0)}i<=d&&i>0&&(i=l>1?0:Math.clamped(i+p-l,0,4))}var g=r.find('[name="vision"] option:nth-child('.concat(i+1,")"));g.length&&(g[0].selected=!0)}}},{key:"distanceModifier",value:function distanceModifier(t,r,a){if(!DPS.isEnabled||!t)return 1;var o,i={},c=_createForOfIteratorHelper(game.user.targets);try{for(c.s();!(o=c.n()).done;){var u=o.value,l=DPS.rangeFinder(t,u);(i.distanceSum||0)\n \n \n
");r.find(".dpsSelector").remove(),r.find('.tab[data-tab="grid"]').append(i)}))},562:(__unused_webpack_module,__webpack_exports__,__webpack_require__)=>{__webpack_require__.d(__webpack_exports__,{Z:()=>DiceDSA5});var _actor_actor_dsa5_js__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__(369),_config_dsa5_js__WEBPACK_IMPORTED_MODULE_1__=__webpack_require__(577),_dialog_dialog_dsa5_js__WEBPACK_IMPORTED_MODULE_2__=__webpack_require__(538),_utility_dsa5_js__WEBPACK_IMPORTED_MODULE_3__=__webpack_require__(491),_advantage_rules_dsa5_js__WEBPACK_IMPORTED_MODULE_4__=__webpack_require__(272),_specialability_rules_dsa5_js__WEBPACK_IMPORTED_MODULE_5__=__webpack_require__(173),_trait_rules_dsa5_js__WEBPACK_IMPORTED_MODULE_6__=__webpack_require__(101),_item_item_dsa5_js__WEBPACK_IMPORTED_MODULE_7__=__webpack_require__(839),_status_status_effects_js__WEBPACK_IMPORTED_MODULE_8__=__webpack_require__(973),_opposed_dsa5_js__WEBPACK_IMPORTED_MODULE_9__=__webpack_require__(600),_status_active_effects_js__WEBPACK_IMPORTED_MODULE_10__=__webpack_require__(61),_dsa_soundeffect_js__WEBPACK_IMPORTED_MODULE_11__=__webpack_require__(803),_equipment_damage_js__WEBPACK_IMPORTED_MODULE_12__=__webpack_require__(702),_dialog_dialog_equipmentdamage_js__WEBPACK_IMPORTED_MODULE_13__=__webpack_require__(266),_tables_dsatables_js__WEBPACK_IMPORTED_MODULE_14__=__webpack_require__(430),_request_roll_js__WEBPACK_IMPORTED_MODULE_15__=__webpack_require__(903),_measuretemplate_js__WEBPACK_IMPORTED_MODULE_16__=__webpack_require__(174),_tables_tableEffects_js__WEBPACK_IMPORTED_MODULE_17__=__webpack_require__(585),_creature_type_js__WEBPACK_IMPORTED_MODULE_18__=__webpack_require__(472);function _typeof(t){return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},_typeof(t)}function _defineProperty(t,r,a){return r in t?Object.defineProperty(t,r,{value:a,enumerable:!0,configurable:!0,writable:!0}):t[r]=a,t}function _slicedToArray(t,r){return _arrayWithHoles(t)||_iterableToArrayLimit(t,r)||_unsupportedIterableToArray(t,r)||_nonIterableRest()}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _iterableToArrayLimit(t,r){var a=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=a){var o,i,c=[],u=!0,l=!1;try{for(a=a.call(t);!(u=(o=a.next()).done)&&(c.push(o.value),!r||c.length!==r);u=!0);}catch(t){l=!0,i=t}finally{try{u||null==a.return||a.return()}finally{if(l)throw i}}return c}}function _arrayWithHoles(t){if(Array.isArray(t))return t}function _createForOfIteratorHelper(t,r){var a="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!a){if(Array.isArray(t)||(a=_unsupportedIterableToArray(t))||r&&t&&"number"==typeof t.length){a&&(t=a);var o=0,i=function F(){};return{s:i,n:function n(){return o>=t.length?{done:!0}:{done:!1,value:t[o++]}},e:function e(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var c,u=!0,l=!1;return{s:function s(){a=a.call(t)},n:function n(){var t=a.next();return u=t.done,t},e:function e(t){l=!0,c=t},f:function f(){try{u||null==a.return||a.return()}finally{if(l)throw c}}}}function _toConsumableArray(t){return _arrayWithoutHoles(t)||_iterableToArray(t)||_unsupportedIterableToArray(t)||_nonIterableSpread()}function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray(t,r){if(t){if("string"==typeof t)return _arrayLikeToArray(t,r);var a=Object.prototype.toString.call(t).slice(8,-1);return"Object"===a&&t.constructor&&(a=t.constructor.name),"Map"===a||"Set"===a?Array.from(t):"Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a)?_arrayLikeToArray(t,r):void 0}}function _iterableToArray(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}function _arrayWithoutHoles(t){if(Array.isArray(t))return _arrayLikeToArray(t)}function _arrayLikeToArray(t,r){(null==r||r>t.length)&&(r=t.length);for(var a=0,o=new Array(r);a=0;--o){var i=this.tryEntries[o],c=i.completion;if("root"===i.tryLoc)return handle("end");if(i.tryLoc<=this.prev){var u=a.call(i,"catchLoc"),l=a.call(i,"finallyLoc");if(u&&l){if(this.prev=0;--o){var i=this.tryEntries[o];if(i.tryLoc<=this.prev&&a.call(i,"finallyLoc")&&this.prev=0;--r){var a=this.tryEntries[r];if(a.finallyLoc===t)return this.complete(a.completion,a.afterLoc),resetTryEntry(a),l}},catch:function _catch(t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc===t){var o=a.completion;if("throw"===o.type){var i=o.arg;resetTryEntry(a)}return i}}throw new Error("illegal catch attempt")},delegateYield:function delegateYield(t,r,a){return this.delegate={iterator:values(t),resultName:r,nextLoc:a},"next"===this.method&&(this.arg=void 0),l}},t}function asyncGeneratorStep(t,r,a,o,i,c,u){try{var l=t[c](u),p=l.value}catch(t){return void a(t)}l.done?r(p):Promise.resolve(p).then(o,i)}function _asyncToGenerator(t){return function(){var r=this,a=arguments;return new Promise((function(o,i){var c=t.apply(r,a);function _next(t){asyncGeneratorStep(c,o,i,_next,_throw,"next",t)}function _throw(t){asyncGeneratorStep(c,o,i,_next,_throw,"throw",t)}_next(void 0)}))}}function _classCallCheck(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}function _defineProperties(t,r){for(var a=0;a0,h.t3=u,h.t4=r.data.rollMode||i,h.t5=CONFIG.Dice.rollModes,h.next=20,this.getDefenseCount(a);case 20:if(h.t6=h.sent,h.t7=l,h.t8={hasSituationalModifiers:h.t2,situationalModifiers:h.t3,rollMode:h.t4,rollModes:h.t5,defenseCount:h.t6,targets:h.t7},(0,h.t0)(h.t1,h.t8),mergeObject(o,{user:game.user.id}),a.extra.options.bypass){h.next=33;break}return p=_dialog_dialog_dsa5_js__WEBPACK_IMPORTED_MODULE_2__.Z.getDialogForItem(a,r.data),h.next=29,renderTemplate(r.template,r.data);case 29:return d=h.sent,h.abrupt("return",new Promise((function(t,o){new p({title:r.title,content:d,buttons:p.getRollButtons(a,r,t,o),default:"rollButton"}).recallSettings(a.extra.speaker,a.source,a.mode,r.data).render(!0)})));case 33:return o.rollMode=a.extra.options.rollMode||i,a.situationalModifiers||(a.situationalModifiers=[]),h.abrupt("return",{testData:a,cardOptions:o});case 36:case"end":return h.stop()}}),_callee3,this)}))),function setupDialog(t){return _setupDialog.apply(this,arguments)})},{key:"getDefenseCount",value:(_getDefenseCount=_asyncToGenerator(_regeneratorRuntime().mark((function _callee4(t){return _regeneratorRuntime().wrap((function _callee4$(r){for(;;)switch(r.prev=r.next){case 0:if(!game.combat){r.next=4;break}return r.next=3,game.combat.getDefenseCount(t.extra.speaker);case 3:return r.abrupt("return",r.sent);case 4:return r.abrupt("return",0);case 5:case"end":return r.stop()}}),_callee4)}))),function getDefenseCount(t){return _getDefenseCount.apply(this,arguments)})},{key:"_rollSingleD20",value:(_rollSingleD=_asyncToGenerator(_regeneratorRuntime().mark((function _callee5(t,r,a,o,i){var c,u,l,p,d,h,m,y,g,v,_,b,k,w,x=arguments;return _regeneratorRuntime().wrap((function _callee5$(S){for(;;)switch(S.prev=S.next){case 0:return c=x.length>5&&void 0!==x[5]?x[5]:"",u=x.length>6&&void 0!==x[6]?x[6]:1,l="",p=[],r+=o,r=Math.round(r*u),d=r-t.terms[0].results[0].result,h=game.dsa5.apps.DiceSoNiceCustomization.getAttributeConfiguration(a),p.push({char:a,res:t.terms[0].results[0].result,suc:d>=0,tar:r}),S.next=11,new Roll("1d20").evaluate({async:!0});case 11:if(m=S.sent,y=d>=0?1:-1,g=20,v=1,"meleeweapon"==i.source.type&&(g=Math.min(i.extra.actor.system.meleeStats.botch,i.source.system.botch),v=Math.max(i.extra.actor.system.meleeStats.crit,i.source.system.crit)),"rangeweapon"==i.source.type&&(g=Math.min(i.extra.actor.system.rangeStats.botch,i.source.system.botch),v=Math.max(i.extra.actor.system.rangeStats.crit,i.source.system.crit)),/(\(|,)( )?i\)$/.test(i.source.name)&&(_specialability_rules_dsa5_js__WEBPACK_IMPORTED_MODULE_5__.Z.hasAbility(i.extra.actor,game.i18n.localize("LocalizedIDs.improvisedWeaponMaster"))||(g=Math.min(19,g)),this._appendSituationalModifiers(i,"".concat(game.i18n.localize("CHAR.ATTACK")," - ").concat(game.i18n.localize("WEAPON.improvised")),2,"defenseMalus")),i.situationalModifiers.find((function(t){return t.name==game.i18n.localize("opportunityAttack")&&0!=t.value}))&&(g=50,v=-50),1!=t.terms[0].results.filter((function(t){return t.result<=v})).length){S.next=41;break}if(l=game.i18n.localize("CriticalSuccess"),!game.settings.get("dsa5","noConfirmationRoll")){S.next=25;break}y=3,S.next=39;break;case 25:return S.next=27,DiceDSA5.manualRolls(m,"confirmationRoll",i.extra.options);case 27:if(m=S.sent,_=r-m.terms[0].results[0].result,!_advantage_rules_dsa5_js__WEBPACK_IMPORTED_MODULE_4__.Z.hasVantage(i.extra.actor,"".concat(game.i18n.localize("LocalizedIDs.weaponAptitude")," (").concat(c,")"))||_>=0){S.next=36;break}return b=m.terms[0].results[0].result,S.next=33,new Roll("1d20").evaluate({async:!0});case 33:m=S.sent,_=r-m.terms[0].results[0].result,l+=", "+game.i18n.format("usedWeaponExpertise",{a:b,b:m.terms[0].results[0].result});case 36:this._addRollDiceSoNice(i,m,h),p.push({char:a,res:m.terms[0].results[0].result,suc:_>=0,tar:r}),y=_>=0?3:2;case 39:S.next=61;break;case 41:if(1!=t.terms[0].results.filter((function(t){return t.result>=g})).length){S.next=61;break}if(l=game.i18n.localize("CriticalFailure"),!game.settings.get("dsa5","noConfirmationRoll")){S.next=47;break}y=-3,S.next=61;break;case 47:return S.next=49,DiceDSA5.manualRolls(m,"confirmationRoll",i.extra.options);case 49:if(m=S.sent,k=r-m.terms[0].results[0].result,!_advantage_rules_dsa5_js__WEBPACK_IMPORTED_MODULE_4__.Z.hasVantage(i.extra.actor,"".concat(game.i18n.localize("LocalizedIDs.weaponAptitude")," (").concat(c,")"))||k>=0){S.next=58;break}return w=m.terms[0].results[0].result,S.next=55,new Roll("1d20").evaluate({async:!0});case 55:m=S.sent,k=r-m.terms[0].results[0].result,l+=", "+game.i18n.format("usedWeaponExpertise",{a:w,b:m.terms[0].results[0].result});case 58:this._addRollDiceSoNice(i,m,h),p.push({char:a,res:m.terms[0].results[0].result,suc:k>=0,tar:r}),y=k>=0?-2:-3;case 61:return""==l?l=game.i18n.localize(d>=0?"Success":"Failure"):game.settings.get("dsa5","noConfirmationRoll")||(3==Math.abs(y)?l="".concat(game.i18n.localize("confirmed")," ").concat(l):2==Math.abs(y)&&(l="".concat(game.i18n.localize("unconfirmed")," ").concat(l))),S.abrupt("return",{successLevel:y,characteristics:p,description:l,preData:i,modifiers:o,extra:{}});case 63:case"end":return S.stop()}}),_callee5,this)}))),function _rollSingleD20(t,r,a,o,i){return _rollSingleD.apply(this,arguments)})},{key:"rollFallingDamage",value:(_rollFallingDamage=_asyncToGenerator(_regeneratorRuntime().mark((function _callee6(t){var r,a,o,i,c,u;return _regeneratorRuntime().wrap((function _callee6$(l){for(;;)switch(l.prev=l.next){case 0:r=t.roll,a=[],o=_createForOfIteratorHelper(r.terms[0].results);try{for(o.s();!(i=o.n()).done;)c=i.value,a.push({char:"damage",res:c.result,suc:!1})}catch(t){o.e(t)}finally{o.f()}return l.t0=t,l.next=7,this._situationalModifiers(t);case 7:return l.t1=l.sent,l.t2={},l.t3=Math.max(0,r.total),l.t4=r.formula,l.t5=a,u={rollType:"fallingDamage",preData:l.t0,modifiers:l.t1,extra:l.t2,damage:l.t3,formula:l.t4,characteristics:l.t5},l.abrupt("return",u);case 14:case"end":return l.stop()}}),_callee6,this)}))),function rollFallingDamage(t){return _rollFallingDamage.apply(this,arguments)})},{key:"rollRegeneration",value:(_rollRegeneration=_asyncToGenerator(_regeneratorRuntime().mark((function _callee7(t){var r,a,o,i,c,u,l,p,d,h,m,y;return _regeneratorRuntime().wrap((function _callee7$(g){for(;;)switch(g.prev=g.next){case 0:return g.next=2,this._situationalModifiers(t);case 2:if(r=g.sent,a=t.roll,o=[],i={rollType:"regenerate",preData:t,modifiers:r,extra:{}},c=[],t.regenerateLeP&&c.push("LeP"),t.extra.actor.system.isMage&&t.regenerateAsP&&c.push("AsP"),t.extra.actor.system.isPriest&&t.regenerateKaP&&c.push("KaP"),u=0,!t.extra.actor.effects.some((function(t){return t.statuses.includes("sick")}))){g.next=18;break}this._appendSituationalModifiers(t,game.i18n.localize("CONDITION.sick"),"*0"),l=_createForOfIteratorHelper(c);try{for(l.s();!(p=l.n()).done;)d=p.value,o.push({char:d,res:0,die:"d6"}),i[d]=0,u+=2}catch(t){l.e(t)}finally{l.f()}g.next=51;break;case 18:h=_createForOfIteratorHelper(c),g.prev=19,h.s();case 21:if((m=h.n()).done){g.next=43;break}return y=m.value,this._appendSituationalModifiers(t,game.i18n.localize("LocalizedIDs.regeneration".concat(y)),_advantage_rules_dsa5_js__WEBPACK_IMPORTED_MODULE_4__.Z.vantageStep(t.extra.actor,game.i18n.localize("LocalizedIDs.regeneration".concat(y))),y),this._appendSituationalModifiers(t,game.i18n.localize("LocalizedIDs.weakRegeneration".concat(y)),-1*_advantage_rules_dsa5_js__WEBPACK_IMPORTED_MODULE_4__.Z.vantageStep(t.extra.actor,game.i18n.localize("LocalizedIDs.weakRegeneration".concat(y))),y),this._appendSituationalModifiers(t,game.i18n.localize("LocalizedIDs.advancedRegeneration".concat(y)),_specialability_rules_dsa5_js__WEBPACK_IMPORTED_MODULE_5__.Z.abilityStep(t.extra.actor,game.i18n.localize("LocalizedIDs.advancedRegeneration".concat(y))),y),this._appendSituationalModifiers(t,"".concat(game.i18n.localize("CHARAbbrev.".concat(y))," ").concat(game.i18n.localize("Modifier")),t["".concat(y,"Modifier")],y),this._appendSituationalModifiers(t,"".concat(game.i18n.localize("CHARAbbrev.".concat(y))," ").concat(game.i18n.localize("regenerate")),t["regeneration".concat(y)],y),o.push({char:y,res:a.terms[u].results[0].result,die:"d6"}),g.t0=Math,g.t1=Math,g.t2=Number(a.terms[u].results[0].result)+Number(r),g.next=34,this._situationalModifiers(t,y);case 34:g.t3=g.sent,g.t4=g.t2+g.t3,g.t5=g.t1.max.call(g.t1,0,g.t4),g.t6=Number(t.regenerationFactor),g.t7=g.t5*g.t6,i[y]=g.t0.round.call(g.t0,g.t7),u+=2;case 41:g.next=21;break;case 43:g.next=48;break;case 45:g.prev=45,g.t8=g.catch(19),h.e(g.t8);case 48:return g.prev=48,h.f(),g.finish(48);case 51:return i.characteristics=o,g.abrupt("return",i);case 53:case"end":return g.stop()}}),_callee7,this,[[19,45,48,51]])}))),function rollRegeneration(t){return _rollRegeneration.apply(this,arguments)})},{key:"rollStatus",value:(_rollStatus=_asyncToGenerator(_regeneratorRuntime().mark((function _callee8(t){var r,a,o;return _regeneratorRuntime().wrap((function _callee8$(i){for(;;)switch(i.prev=i.next){case 0:if(i.t0=t.roll,i.t0){i.next=5;break}return i.next=4,new Roll("1d20").evaluate({async:!0});case 4:i.t0=i.sent;case 5:return r=i.t0,i.t1=this,i.t2=r,i.t3=t.source.system.max,i.t4=t.extra.statusId,i.next=12,this._situationalModifiers(t);case 12:return i.t5=i.sent,i.t6=t,i.t7=this._situationalMultipliers(t),i.next=17,i.t1._rollSingleD20.call(i.t1,i.t2,i.t3,i.t4,i.t5,i.t6,"",i.t7);case 17:if((a=i.sent).rollType="dodge",!(o="dodge"==t.extra.statusId)||3!=a.successLevel){i.next=30;break}return i.next=23,_tables_dsatables_js__WEBPACK_IMPORTED_MODULE_14__.Z.tableEnabledFor("criticalMeleeDefense");case 23:if(!i.sent){i.next=27;break}a.description+=_tables_dsatables_js__WEBPACK_IMPORTED_MODULE_14__.Z.rollCritBotchButton("criticalMeleeDefense",!1,t,t),i.next=28;break;case 27:a.description+=_tables_dsatables_js__WEBPACK_IMPORTED_MODULE_14__.Z.defaultParryCrit();case 28:i.next=41;break;case 30:if(!o||-3!=a.successLevel){i.next=41;break}return i.next=33,_tables_dsatables_js__WEBPACK_IMPORTED_MODULE_14__.Z.tableEnabledFor("Defense");case 33:if(!i.sent){i.next=37;break}a.description+=_tables_dsatables_js__WEBPACK_IMPORTED_MODULE_14__.Z.rollCritBotchButton("Defense",!0,t,t),i.next=41;break;case 37:return i.t8=a.description,i.next=40,_tables_dsatables_js__WEBPACK_IMPORTED_MODULE_14__.Z.defaultBotch();case 40:a.description=i.t8+=i.sent;case 41:return i.abrupt("return",a);case 42:case"end":return i.stop()}}),_callee8,this)}))),function rollStatus(t){return _rollStatus.apply(this,arguments)})},{key:"rollAttribute",value:(_rollAttribute=_asyncToGenerator(_regeneratorRuntime().mark((function _callee9(t){var r,a;return _regeneratorRuntime().wrap((function _callee9$(o){for(;;)switch(o.prev=o.next){case 0:if(!t.roll){o.next=4;break}o.t0=t.roll,o.next=7;break;case 4:return o.next=6,new Roll("1d20").evaluate({async:!0});case 6:o.t0=o.sent;case 7:return r=o.t0,this._appendSituationalModifiers(t,game.i18n.localize("Difficulty"),t.testDifficulty),o.t1=this,o.t2=r,o.t3=t.source.system.value,o.t4=t.extra.characteristicId,o.next=15,this._situationalModifiers(t);case 15:return o.t5=o.sent,o.t6=t,o.t7=this._situationalMultipliers(t),o.next=20,o.t1._rollSingleD20.call(o.t1,o.t2,o.t3,o.t4,o.t5,o.t6,"",o.t7);case 20:return(a=o.sent).rollType="attribute",o.abrupt("return",a);case 23:case"end":return o.stop()}}),_callee9,this)}))),function rollAttribute(t){return _rollAttribute.apply(this,arguments)})},{key:"damageFormula",value:(_damageFormula=_asyncToGenerator(_regeneratorRuntime().mark((function _callee10(t){var r,a,o;return _regeneratorRuntime().wrap((function _callee10$(i){for(;;)switch(i.prev=i.next){case 0:return"meleeweapon"==t.source.type?(a=_actor_actor_dsa5_js__WEBPACK_IMPORTED_MODULE_0__.Z._calculateCombatSkillValues(t.extra.actor.items.find((function(r){return"combatskill"==r.type&&r.name==t.source.system.combatskill.value})),t.extra.actor.system),r=_actor_actor_dsa5_js__WEBPACK_IMPORTED_MODULE_0__.Z._prepareMeleeWeapon(t.source,[a],t.extra.actor)):"rangeweapon"==t.source.type?(o=_actor_actor_dsa5_js__WEBPACK_IMPORTED_MODULE_0__.Z._calculateCombatSkillValues(t.extra.actor.items.find((function(r){return"combatskill"==r.type&&r.name==t.source.system.combatskill.value})),t.extra.actor.system),r=_actor_actor_dsa5_js__WEBPACK_IMPORTED_MODULE_0__.Z._prepareRangeWeapon(t.source,[],[o],t.extra.actor)):r=t.source.system,i.abrupt("return",t.source.system.damage.value.replace(/[Ww]/g,"d")+"+".concat(r.extraDamage||0));case 2:case"end":return i.stop()}}),_callee10)}))),function damageFormula(t){return _damageFormula.apply(this,arguments)})},{key:"rollDamage",value:(_rollDamage=_asyncToGenerator(_regeneratorRuntime().mark((function _callee11(t){var r,a,o,i,c,u,l,p,d,h;return _regeneratorRuntime().wrap((function _callee11$(m){for(;;)switch(m.prev=m.next){case 0:return m.next=2,this._situationalModifiers(t);case 2:r=m.sent,a=[],o=t.roll,i=o.total+r,c=_createForOfIteratorHelper(o.terms);try{for(c.s();!(u=c.n()).done;)if((l=u.value)instanceof Die||"Die"==l.class){p=_createForOfIteratorHelper(l.results);try{for(p.s();!(d=p.n()).done;)h=d.value,a.push({char:t.mode,res:h.result,die:"d"+l.faces})}catch(t){p.e(t)}finally{p.f()}}}catch(t){c.e(t)}finally{c.f()}return m.abrupt("return",{rollType:"damage",damage:i,characteristics:a,preData:t,modifiers:r,extra:{}});case 9:case"end":return m.stop()}}),_callee11,this)}))),function rollDamage(t){return _rollDamage.apply(this,arguments)})},{key:"_situationalModifiers",value:(_situationalModifiers2=_asyncToGenerator(_regeneratorRuntime().mark((function _callee12(t){var r,a,o,i,c,u,l=arguments;return _regeneratorRuntime().wrap((function _callee12$(p){for(;;)switch(p.prev=p.next){case 0:r=l.length>1&&void 0!==l[1]?l[1]:"",a=0,o=_createForOfIteratorHelper(t.situationalModifiers),p.prev=3,o.s();case 5:if((i=o.n()).done){p.next=18;break}if(null!=(c=i.value).value){p.next=9;break}return p.abrupt("continue",16);case 9:if(p.t0=Number(c.value),p.t0){p.next=14;break}return p.next=13,this._stringToRoll(c.value);case 13:p.t0=p.sent;case 14:u=p.t0,a+=c.type==r||""==r&&null==c.type?u:0;case 16:p.next=5;break;case 18:p.next=23;break;case 20:p.prev=20,p.t1=p.catch(3),o.e(p.t1);case 23:return p.prev=23,o.f(),p.finish(23);case 26:return p.abrupt("return",a);case 27:case"end":return p.stop()}}),_callee12,this,[[3,20,23,26]])}))),function _situationalModifiers(t){return _situationalModifiers2.apply(this,arguments)})},{key:"_situationalPartCheckModifiers",value:function _situationalPartCheckModifiers(t){return t.situationalModifiers.reduce((function(t,r){if("TPM"==r.type){var a=r.value.split("|");return 3!=a.length||(t[0]=t[0]+Number(a[0]),t[1]=t[1]+Number(a[1]),t[2]=t[2]+Number(a[2])),t}return t}),[0,0,0])}},{key:"_situationalMultipliers",value:function _situationalMultipliers(t){return t.situationalModifiers.reduce((function(t,r){return t*("*"==r.type&&Number("".concat(r.value).replace(/,/,"."))||1)}),1)}},{key:"_appendSituationalModifiers",value:function _appendSituationalModifiers(t,r,a){var o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"",i=t.situationalModifiers.find((function(t){return t.name==r}));i?i.value=a:t.situationalModifiers.push({name:r,value:a,type:o})}},{key:"rollCombatTrait",value:(_rollCombatTrait=_asyncToGenerator(_regeneratorRuntime().mark((function _callee13(t){var r,a,o,i,c,u,l,p;return _regeneratorRuntime().wrap((function _callee13$(d){for(;;)switch(d.prev=d.next){case 0:if(d.t0=t.roll,d.t0){d.next=5;break}return d.next=4,new Roll("1d20").evaluate({async:!0});case 4:d.t0=d.sent;case 5:return r=d.t0,a=t.source,o="meleeAttack"==a.system.traitType.value,i="attack"==t.mode,o&&(c={system:{combatskill:{value:"-"},reach:{value:a.system.reach.value}}},this._appendSituationalModifiers(t,game.i18n.localize("opposingWeaponSize"),this._compareWeaponReach(c,t))),d.t1=this,d.t2=r,d.t3=Number(i?a.system.at.value:a.system.pa),d.t4=t.mode,d.next=16,this._situationalModifiers(t);case 16:return d.t5=d.sent,d.t6=t,d.t7=this._situationalMultipliers(t),d.next=21,d.t1._rollSingleD20.call(d.t1,d.t2,d.t3,d.t4,d.t5,d.t6,"",d.t7);case 21:return u=d.sent,l=u.successLevel>0,d.next=25,this.detailedWeaponResult(u,t,a);case 25:if(!i||!l){d.next=28;break}return d.next=28,DiceDSA5.evaluateDamage(t,u,a,!o,u.doubleDamage);case 28:return u.rollType="weapon",(p=DiceDSA5.parseEffect(a))&&(u.parsedEffect=p),d.abrupt("return",u);case 32:case"end":return d.stop()}}),_callee13,this)}))),function rollCombatTrait(t){return _rollCombatTrait.apply(this,arguments)})},{key:"_stringToRoll",value:(_stringToRoll2=_asyncToGenerator(_regeneratorRuntime().mark((function _callee14(t,r){var a,o,i,c,u;return _regeneratorRuntime().wrap((function _callee14$(l){for(;;)switch(l.prev=l.next){case 0:return a=[],o=/\d{1}[dDwW]\d/g,(i="".concat(t)).replace(o,(function(t){a.push(new Roll(t.replace(/[Ww]/,"d")).evaluate({async:!0}))})),l.next=6,Promise.all(a);case 6:return c=l.sent,u=i.replace(o,(function(){var t=c.shift();return r&&DiceDSA5._addRollDiceSoNice(r,t,game.dsa5.apps.DiceSoNiceCustomization.getAttributeConfiguration("ch")),t.total})),l.next=10,Roll.safeEval(u);case 10:return l.abrupt("return",l.sent);case 11:case"end":return l.stop()}}),_callee14)}))),function _stringToRoll(t,r){return _stringToRoll2.apply(this,arguments)})},{key:"evaluateDamage",value:(_evaluateDamage=_asyncToGenerator(_regeneratorRuntime().mark((function _callee15(t,r,a,o,i){var c,u,l,p,d,h,m,y,g,v,_,b,k,w,x,S,T,A,O,P,E,C,D,I,R,L,G,M;return _regeneratorRuntime().wrap((function _callee15$(j){for(;;)switch(j.prev=j.next){case 0:c=a.system.damage.value.replace(/[Ww]/g,"d"),u=[],l=a.dmgMultipliers||[],p=l.map((function(t){return"".concat(t.name," *").concat(t.val)})),d=[],h=0,m=_createForOfIteratorHelper(t.situationalModifiers),j.prev=7,m.s();case 9:if((y=m.n()).done){j.next=33;break}if(g=y.value,v=0,g.armorPen&&d.push(g.armorPen),!g.damageBonus){j.next=31;break}if(!/^\*/.test(g.damageBonus)){j.next=17;break}return l.push({name:g.name,val:Number(g.damageBonus.replace("*",""))}),j.abrupt("continue",31);case 17:return _=/^=/.test(g.damageBonus),b="".concat(g.damageBonus).replace(/^=/,""),j.next=21,DiceDSA5._stringToRoll(b,t);case 21:if(k=j.sent,v=k*(g.step||1),!_){j.next=29;break}return c=b.replace(/[Ww]/,"d"),u.push({name:g.name,roll:k}),j.abrupt("continue",31);case 29:g.damageBonus=k,h+=v;case 31:j.next=9;break;case 33:j.next=38;break;case 35:j.prev=35,j.t0=j.catch(7),m.e(j.t0);case 38:return j.prev=38,m.f(),j.finish(38);case 41:if(!t.damageRoll){j.next=45;break}j.t1=t.damageRoll,j.next=53;break;case 45:return j.t2=DiceDSA5,j.next=48,new Roll(c).evaluate({async:!0});case 48:return j.t3=j.sent,j.t4=t.extra.options,j.next=52,j.t2.manualRolls.call(j.t2,j.t3,"CHAR.DAMAGE",j.t4);case 52:j.t1=j.sent;case 53:w=j.t1,x=w.total,S=0,T=_createForOfIteratorHelper(w.terms);try{for(T.s();!(A=T.n()).done;)if((O=A.value)instanceof Die||"Die"==O.class){P=_createForOfIteratorHelper(O.results);try{for(P.s();!(E=P.n()).done;)C=E.value,S+=Number(C.result),r.characteristics.push({char:"damage",res:C.result,die:"d"+O.faces})}catch(t){P.e(t)}finally{P.f()}}}catch(t){T.e(t)}finally{T.f()}if(D=x-S,!(u.length>0)){j.next=63;break}p.push(u[0].name+" "+x),j.next=74;break;case 63:return x+=h,p.push(game.i18n.localize("Roll")+" "+S),0!=D&&p.push(game.i18n.localize("weaponModifier")+" "+D),t.situationalModifiers.reduce((function(t,r){if(r.damageBonus){var a=/^\*/.test(r.damageBonus)?r.damageBonus:Number(r.damageBonus)*(r.step||1);p.push("".concat(r.name," ").concat(a))}}),p),t.situationalModifiers.find((function(t){return t.name.indexOf(game.i18n.localize("CONDITION.bloodrush"))>-1}))&&(x+=2,p.push(game.i18n.localize("CONDITION.bloodrush")+" 2")),a.extraDamage&&(x=Number(a.extraDamage)+Number(x),p.push(game.i18n.localize("damageThreshold")+" "+a.extraDamage)),I=t.extra.actor.system[o?"rangeStats":"meleeStats"].damage,j.next=72,DiceDSA5._stringToRoll(I,t);case 72:0!=(R=j.sent)&&(x+=R,p.push(game.i18n.localize("statuseffects")+" "+R));case 74:i&&(x*=i,p.push(game.i18n.format("doubleDamage",{x:i}))),L=_createForOfIteratorHelper(l);try{for(L.s();!(G=L.n()).done;)M=G.value,x*=M.val}catch(t){L.e(t)}finally{L.f()}r.armorPen=d,r.damagedescription=p.join(", "),r.damage=Math.round(x),r.damageRoll=duplicate(w);case 81:case"end":return j.stop()}}),_callee15,null,[[7,35,38,41]])}))),function evaluateDamage(t,r,a,o,i){return _evaluateDamage.apply(this,arguments)})},{key:"rollWeapon",value:(_rollWeapon=_asyncToGenerator(_regeneratorRuntime().mark((function _callee16(t){var r,a,o,i,c,u,l,p;return _regeneratorRuntime().wrap((function _callee16$(d){for(;;)switch(d.prev=d.next){case 0:if(d.t0=t.roll,d.t0){d.next=5;break}return d.next=4,new Roll("1d20").evaluate({async:!0});case 4:d.t0=d.sent;case 5:return r=d.t0,o=t.source,i=o.system.combatskill.value,c=_actor_actor_dsa5_js__WEBPACK_IMPORTED_MODULE_0__.Z._calculateCombatSkillValues(t.extra.actor.items.find((function(t){return"combatskill"==t.type&&t.name==i})),t.extra.actor.system),(u="meleeweapon"==o.type)?(a=_actor_actor_dsa5_js__WEBPACK_IMPORTED_MODULE_0__.Z._prepareMeleeWeapon(o,[c],t.extra.actor),"attack"==t.mode&&this._appendSituationalModifiers(t,game.i18n.localize("opposingWeaponSize"),this._compareWeaponReach(a,t))):a=_actor_actor_dsa5_js__WEBPACK_IMPORTED_MODULE_0__.Z._prepareRangeWeapon(o,[],[c],t.extra.actor),d.t1=this,d.t2=r,d.t3=a[t.mode],d.t4=t.mode,d.next=17,this._situationalModifiers(t);case 17:return d.t5=d.sent,d.t6=t,d.t7=i,d.t8=this._situationalMultipliers(t),d.next=23,d.t1._rollSingleD20.call(d.t1,d.t2,d.t3,d.t4,d.t5,d.t6,d.t7,d.t8);case 23:return l=d.sent,d.next=26,this.detailedWeaponResult(l,t,o);case 26:if(!("attack"==t.mode&&l.successLevel>0)||t.extra.counterAttack){d.next=29;break}return d.next=29,DiceDSA5.evaluateDamage(t,l,a,!u,l.doubleDamage);case 29:return t.extra.counterAttack&&(_utility_dsa5_js__WEBPACK_IMPORTED_MODULE_3__.Z.getSpeaker(t.extra.speaker).addCondition("stunned"),l.description+=", "+_utility_dsa5_js__WEBPACK_IMPORTED_MODULE_3__.Z.replaceConditions(game.i18n.localize("stunnedByCounterAttack"))),l.rollType="weapon",(p=DiceDSA5.parseEffect(a))&&(l.parsedEffect=p),d.abrupt("return",l);case 34:case"end":return d.stop()}}),_callee16,this)}))),function rollWeapon(t){return _rollWeapon.apply(this,arguments)})},{key:"detailedWeaponResult",value:(_detailedWeaponResult=_asyncToGenerator(_regeneratorRuntime().mark((function _callee17(t,r,a){var o,i,c;return _regeneratorRuntime().wrap((function _callee17$(u){for(;;)switch(u.prev=u.next){case 0:o="attack"==r.mode&&!r.extra.counterAttack,i="meleeweapon"==a.type||"meleeAttack"==getProperty(a,"system.traitType.value"),u.t0=t.successLevel,u.next=3===u.t0?5:-3===u.t0?34:2===u.t0?67:-2===u.t0?69:70;break;case 5:if(!o){u.next=17;break}return u.next=8,_tables_dsatables_js__WEBPACK_IMPORTED_MODULE_14__.Z.tableEnabledFor("criticalAttack");case 8:if(!u.sent){u.next=12;break}t.description+=_tables_dsatables_js__WEBPACK_IMPORTED_MODULE_14__.Z.rollCritBotchButton("criticalAttack",!1,r),u.next=14;break;case 12:t.description+=_tables_dsatables_js__WEBPACK_IMPORTED_MODULE_14__.Z.defaultAttackCrit(!0),t.doubleDamage=2;case 14:t.halfDefense=!0,u.next=33;break;case 17:if(u.t1=r.isRangeDefense,!u.t1){u.next=22;break}return u.next=21,_tables_dsatables_js__WEBPACK_IMPORTED_MODULE_14__.Z.tableEnabledFor("criticalRangeDefense");case 21:u.t1=u.sent;case 22:if(!u.t1){u.next=26;break}t.description+=_tables_dsatables_js__WEBPACK_IMPORTED_MODULE_14__.Z.rollCritBotchButton("criticalRangeDefense",!1,r),u.next=33;break;case 26:return u.next=28,_tables_dsatables_js__WEBPACK_IMPORTED_MODULE_14__.Z.tableEnabledFor("criticalMeleeDefense");case 28:if(!u.sent){u.next=32;break}t.description+=_tables_dsatables_js__WEBPACK_IMPORTED_MODULE_14__.Z.rollCritBotchButton("criticalMeleeDefense",!1,r),u.next=33;break;case 32:t.description+=_tables_dsatables_js__WEBPACK_IMPORTED_MODULE_14__.Z.defaultParryCrit();case 33:return u.abrupt("break",70);case 34:if(c=getProperty(a,"system.combatskill.value")==game.i18n.localize("LocalizedIDs.wrestle")||"trait"==a.type,u.t2=o&&i,!u.t2){u.next=40;break}return u.next=39,_tables_dsatables_js__WEBPACK_IMPORTED_MODULE_14__.Z.tableEnabledFor("Melee");case 39:u.t2=u.sent;case 40:if(!u.t2){u.next=44;break}t.description+=_tables_dsatables_js__WEBPACK_IMPORTED_MODULE_14__.Z.rollCritBotchButton("Melee",c,r),u.next=66;break;case 44:if(u.t3=o,!u.t3){u.next=49;break}return u.next=48,_tables_dsatables_js__WEBPACK_IMPORTED_MODULE_14__.Z.tableEnabledFor("Range");case 48:u.t3=u.sent;case 49:if(!u.t3){u.next=53;break}t.description+=_tables_dsatables_js__WEBPACK_IMPORTED_MODULE_14__.Z.rollCritBotchButton("Range",!1,r),u.next=66;break;case 53:if(u.t4=!o,!u.t4){u.next=58;break}return u.next=57,_tables_dsatables_js__WEBPACK_IMPORTED_MODULE_14__.Z.tableEnabledFor("Defense");case 57:u.t4=u.sent;case 58:if(!u.t4){u.next=62;break}t.description+=_tables_dsatables_js__WEBPACK_IMPORTED_MODULE_14__.Z.rollCritBotchButton("Defense",c,r),u.next=66;break;case 62:return u.t5=t.description,u.next=65,_tables_dsatables_js__WEBPACK_IMPORTED_MODULE_14__.Z.defaultBotch();case 65:t.description=u.t5+=u.sent;case 66:return u.abrupt("break",70);case 67:return o&&(t.description+=_tables_dsatables_js__WEBPACK_IMPORTED_MODULE_14__.Z.defaultAttackCrit(!1),t.halfDefense=!0),u.abrupt("break",70);case 69:return u.abrupt("break",70);case 70:case"end":return u.stop()}}),_callee17)}))),function detailedWeaponResult(t,r,a){return _detailedWeaponResult.apply(this,arguments)})},{key:"_addRollDiceSoNice",value:(_addRollDiceSoNice2=_asyncToGenerator(_regeneratorRuntime().mark((function _callee18(t,r,a){var o;return _regeneratorRuntime().wrap((function _callee18$(i){for(;;)switch(i.prev=i.next){case 0:if(!t.rollMode){i.next=4;break}for(o=0;o1&&void 0!==b[1]?b[1]:"",!(a=b.length>2&&void 0!==b[2]?b[2]:{}).cheat&&!game.settings.get("dsa5","allowPhysicalDice")){k.next=21;break}if(a.predefinedResult){k.next=20;break}o=!1,c=[],u=_createForOfIteratorHelper(t.terms);try{for(u.s();!(l=u.n()).done;)if((p=l.value)instanceof Die||"Die"==p.class){d=_createForOfIteratorHelper(p.results);try{for(d.s();!(h=d.n()).done;)m=h.value,c.push({faces:p.faces,val:m.result})}catch(t){d.e(t)}finally{d.f()}}}catch(t){u.e(t)}finally{u.f()}return k.next=10,renderTemplate("systems/dsa5/templates/dialog/manualroll-dialog.html",{dice:c,description:r});case 10:return y=k.sent,k.next=13,new Promise((function(t,r){new _dialog_dialog_dsa5_js__WEBPACK_IMPORTED_MODULE_2__.Z({title:game.i18n.localize(a.cheat?"DIALOG.cheat":"DSASETTINGS.allowPhysicalDice"),content:y,default:"ok",buttons:{ok:{icon:'',label:game.i18n.localize("yes"),callback:function callback(r){t([!0,r])}},cancel:{icon:'',label:game.i18n.localize("cancel"),callback:function callback(){t([!1,0])}}}}).render(!0)}));case 13:g=k.sent,v=_slicedToArray(g,2),o=v[0],i=v[1],o&&(_=[],i.find(".dieInput").each((function(t){var r=Number($(this).val());r>0&&_.push({val:r,index:t}),t++})),t.editRollAtIndex(_)),k.next=21;break;case 20:t.editRollAtIndex(a.predefinedResult);case 21:return k.abrupt("return",t);case 22:case"end":return k.stop()}}),_callee20)}))),function manualRolls(t){return _manualRolls.apply(this,arguments)})},{key:"parseEffect",value:function parseEffect(t){var r=t.system.effect?t.system.effect.value:void 0,a=[];if(r){var o,i=/^[a-z]+\|[öäüÖÄÜa-zA-z ]+$/,c=_createForOfIteratorHelper(r.split(";"));try{for(c.s();!(o=c.n()).done;){var u=o.value;i.test(u.trim())&&function(){var t=u.split("|").map((function(t){return t.trim()}));if("condition"==t[0]){var r=CONFIG.statusEffects.find((function(r){return r.id==t[1]}));a.push('\n ').concat(game.i18n.localize(r.name),"\n "))}else a.push('').concat(game.i18n.localize(t[0]),": ").concat(t[1],""))}()}}catch(t){c.e(t)}finally{c.f()}}var l=getProperty(t,"flags.dsa5.poison");return l&&a.push('').concat(game.i18n.localize("poison"),": ").concat(l.name,"")),a.join(", ")}},{key:"calculateEnergyCost",value:(_calculateEnergyCost=_asyncToGenerator(_regeneratorRuntime().mark((function _callee21(t,r,a){var o,i,c,u,l,p,d,h;return _regeneratorRuntime().wrap((function _callee21$(m){for(;;)switch(m.prev=m.next){case 0:return o=[],r.successLevel<0&&(p=["traditionWitch","traditionFjarning","braniborian"].map((function(t){return game.i18n.localize("LocalizedIDs.".concat(t))})),d=a.extra.actor.items.some((function(t){return"specialability"==t.type&&p.includes(t.name)}))?3:2,r.preData.calculatedSpellModifiers.finalcost=Math.round(r.preData.calculatedSpellModifiers.finalcost/d)),t?(l="KaPCost",i=game.i18n.localize("LocalizedIDs.weakKarmicBody"),c=game.i18n.localize("LocalizedIDs.".concat(r.successLevel>0?"mightyKarmaControl":"karmaControl")),u={val:"kapModifier",name:"KaP"}):(l="AsPCost",i=game.i18n.localize("LocalizedIDs.weakAstralBody"),c=game.i18n.localize("LocalizedIDs.".concat(r.successLevel>0?"energyControl":"smallEnergyControl")),u={val:"aspModifier",name:"AsP"}),m.t0=o,m.t1={name:i,value:_advantage_rules_dsa5_js__WEBPACK_IMPORTED_MODULE_4__.Z.vantageStep(a.extra.actor,i)},m.t2={name:c,value:-1*_specialability_rules_dsa5_js__WEBPACK_IMPORTED_MODULE_5__.Z.abilityStep(a.extra.actor,c)},m.t3="".concat(game.i18n.localize("statuseffects")," (").concat(game.i18n.localize("CHARAbbrev."+u.name),")"),m.t4=a.extra.actor.system[u.val],m.next=10,this._situationalModifiers(a,l);case 10:m.t5=m.sent,m.t6=m.t4+m.t5,m.t7={name:m.t3,value:m.t6},m.t0.push.call(m.t0,m.t1,m.t2,m.t7),o=o.filter((function(t){return 0!=t.value})),r.preData.calculatedSpellModifiers.description=o.map((function(t){return"".concat(t.name," ").concat(t.value)})).join("\n"),r.preData.calculatedSpellModifiers.finalcost=Math.max(1,Number(r.preData.calculatedSpellModifiers.finalcost)+o.reduce((function(t,r){return t+r.value}),0)),r.successLevel>0&&0!=r.preData.calculatedSpellModifiers.maintainCost&&((h=r.preData.calculatedSpellModifiers.maintainCost.split(" "))[0]=Math.round(Number(h[0])),r.preData.calculatedSpellModifiers.finalcost+=h[0],r.preData.calculatedSpellModifiers.maintainCost=h.join(" "));case 18:case"end":return m.stop()}}),_callee21,this)}))),function calculateEnergyCost(t,r,a){return _calculateEnergyCost.apply(this,arguments)})},{key:"rollSpell",value:(_rollSpell=_asyncToGenerator(_regeneratorRuntime().mark((function _callee22(t){var r,a,o,i,c,u,l,p,d,h,m,y,g,v,_,b,k;return _regeneratorRuntime().wrap((function _callee22$(w){for(;;)switch(w.prev=w.next){case 0:return w.next=2,this._rollThreeD20(t);case 2:if(r=w.sent,a=["ceremony","liturgy"].includes(t.source.type),r.rollType=t.source.type,r.preData.calculatedSpellModifiers.finalcost=r.preData.calculatedSpellModifiers.cost,!(r.successLevel>=2)){w.next=16;break}return w.next=9,new Roll("1d6").evaluate({async:!0});case 9:o=w.sent.total,r.description=r.description+", "+game.i18n.localize("additionalFPs")+" "+o,r.result+=o,r.qualityStep=Math.min(game.settings.get("dsa5","capQSat"),Math.ceil(r.result/3)),r.preData.calculatedSpellModifiers.finalcost=Math.round(r.preData.calculatedSpellModifiers.cost/2),w.next=17;break;case 16:r.successLevel<=-2&&(r.description+=_tables_dsatables_js__WEBPACK_IMPORTED_MODULE_14__.Z.rollCritBotchButton(a?"Liturgy":"Spell",!1,t));case 17:if(!(r.successLevel>0)){w.next=50;break}if(""==t.source.system.effectFormula.value){w.next=50;break}i=t.source.system.effectFormula.value.replace(game.i18n.localize("CHARAbbrev.QS"),r.qualityStep).replace(/[Ww]/g,"d"),c=[],u=_createForOfIteratorHelper(t.situationalModifiers);try{for(u.s();!(l=u.n()).done;)(p=l.value).armorPen&&c.push(p.armorPen)}catch(t){u.e(t)}finally{u.f()}if(/(,|;)/.test(i)&&(i=i.split(/[,;]/)[r.qualityStep-1]),!t.damageRoll){w.next=28;break}w.t0=t.damageRoll,w.next=36;break;case 28:return w.t1=DiceDSA5,w.next=31,new Roll(i).evaluate({async:!0});case 31:return w.t2=w.sent,w.t3=t.extra.options,w.next=35,w.t1.manualRolls.call(w.t1,w.t2,"CHAR.DAMAGE",w.t3);case 35:w.t0=w.sent;case 36:d=w.t0,this._addRollDiceSoNice(t,d,game.dsa5.apps.DiceSoNiceCustomization.getAttributeConfiguration("damage")),r.calculatedEffectFormula=i,h=_createForOfIteratorHelper(d.terms);try{for(h.s();!(m=h.n()).done;)if((y=m.value)instanceof Die||"Die"==y.class){g=_createForOfIteratorHelper(y.results);try{for(g.s();!(v=g.n()).done;)_=v.value,r.characteristics.push({char:"effect",res:_.result,die:"d"+y.faces})}catch(t){g.e(t)}finally{g.f()}}}catch(t){h.e(t)}finally{h.f()}return b=[],w.next=44,DiceDSA5._stringToRoll(t.extra.actor.system[a?"liturgyStats":"spellStats"].damage,t);case 44:0!=(k=w.sent)&&b.push(game.i18n.localize("statuseffects")+" "+k),r.armorPen=c,r.damageRoll=d,r.damage=d.total+k,r.damagedescription=b.join("\n");case 50:return w.next=52,this.calculateEnergyCost(a,r,t);case 52:if(!_advantage_rules_dsa5_js__WEBPACK_IMPORTED_MODULE_4__.Z.hasVantage(t.extra.actor,game.i18n.localize("CONDITION.minorSpirits"))||t.extra.actor.effects.find((function(t){return t.name==game.i18n.localize("CONDITION.minorSpirits")}))){w.next=57;break}return w.next=55,new Roll("1d20").evaluate({async:!0});case 55:w.sent.total<=r.preData.calculatedSpellModifiers.finalcost&&(r.description+=", "+game.i18n.localize("minorghostsappear"),_utility_dsa5_js__WEBPACK_IMPORTED_MODULE_3__.Z.getSpeaker(t.extra.speaker).addCondition("minorSpirits"));case 57:return w.abrupt("return",r);case 58:case"end":return w.stop()}}),_callee22,this)}))),function rollSpell(t){return _rollSpell.apply(this,arguments)})},{key:"_rollThreeD20",value:(_rollThreeD=_asyncToGenerator(_regeneratorRuntime().mark((function _callee23(t){var r,a,o,i,c,u,l,p,d,h,m,y,g,v,_,b,k,w;return _regeneratorRuntime().wrap((function _callee23$(x){for(;;)switch(x.prev=x.next){case 0:if(!t.roll){x.next=4;break}x.t0=Roll.fromData(t.roll),x.next=7;break;case 4:return x.next=6,new Roll("1d20+1d20+1d20").evaluate({async:!0});case 6:x.t0=x.sent;case 7:return r=x.t0,a=[],o=0,this._appendSituationalModifiers(t,game.i18n.localize("Difficulty"),t.testDifficulty),x.next=13,this._situationalModifiers(t);case 13:return i=x.sent,x.t1=t.source.system.talentValue.value+t.advancedModifiers.fws,x.next=17,this._situationalModifiers(t,"FW");case 17:if(x.t2=x.sent,c=x.t1+x.t2,u=this._situationalPartCheckModifiers(t,"TPM"),l=[1,2,3].map((function(r){return t.extra.actor.system.characteristics[t.source.system["characteristic".concat(r)].value].value+i+t.advancedModifiers.chars[r-1]+u[r-1]})),p=[0,1,2].map((function(t){return r.terms[2*t].results[0].result-l[t]})),t.routine)c=Math.round(c/2);else{d=_createForOfIteratorHelper(p);try{for(d.s();!(h=d.n()).done;)(m=h.value)>0&&(c-=m)}catch(t){d.e(t)}finally{d.f()}}if(y=t.extra.actor.system.skillModifiers.crit,g=t.extra.actor.system.skillModifiers.botch,["spell","ritual"].includes(t.source.type)&&_advantage_rules_dsa5_js__WEBPACK_IMPORTED_MODULE_4__.Z.hasVantage(t.extra.actor,game.i18n.localize("LocalizedIDs.wildMagic"))&&(g=19),"skill"!=t.source.type||!_advantage_rules_dsa5_js__WEBPACK_IMPORTED_MODULE_4__.Z.hasVantage(t.extra.actor,"".concat(game.i18n.localize("LocalizedIDs.incompetent")," (").concat(t.source.name,")"))){x.next=37;break}return x.next=29,new Roll("1d20").evaluate({async:!0});case 29:v=x.sent,_=p.reduce((function(t,r,a,o){return r0)){x.next=51;break}return x.t3=c,x.next=45,this._situationalModifiers(t,"FP");case 45:return c=x.t3+=x.sent,x.t4=Math.max(1,(0==c?1:c>0?Math.ceil(c/3):0)+(null!=t.qualityStep?Number(t.qualityStep):0))+(t.advancedModifiers.qls||0),x.next=49,this._situationalModifiers(t,"QL");case 49:x.t5=x.sent,w=x.t4+x.t5;case 51:return(w=Math.min(game.settings.get("dsa5","capQSat"),w))2&&void 0!==arguments[2]?arguments[2]:20,o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1,i=t.terms.filter((function(t){return t.results&&t.results[0].result<=o})).length,c=t.terms.filter((function(t){return t.results&&t.results[0].result>=a})).length;return i>=2?i:c>=2?-1*c:r>=0?1:-1}},{key:"getSuccessDescription",value:function getSuccessDescription(t){return game.i18n.localize(["AstoundingFailure","CriticalFailure","Failure","","Success","CriticalSuccess","AstoundingSuccess"][t+3])}},{key:"rollItem",value:(_rollItem=_asyncToGenerator(_regeneratorRuntime().mark((function _callee25(t){var r,a,o,i,c,u,l,p,d,h,m,y,g,v,_;return _regeneratorRuntime().wrap((function _callee25$(b){for(;;)switch(b.prev=b.next){case 0:if(b.t0=t.roll,b.t0){b.next=5;break}return b.next=4,new Roll("1d20+1d20+1d20").evaluate({async:!0});case 4:b.t0=b.sent;case 5:return r=b.t0,a=[],b.next=9,this._situationalModifiers(t);case 9:o=b.sent,i=Number(t.source.system.step.value),c=[1,2,3].map((function(r){return 10+Number(t.source.system.step.value)+o})),u=[0,1,2].map((function(t){return r.terms[2*t].results[0].result-c[t]})),l=_createForOfIteratorHelper(u);try{for(l.s();!(p=l.n()).done;)(d=p.value)>0&&(i-=d)}catch(t){l.e(t)}finally{l.f()}h=DiceDSA5.get3D20SuccessLevel(r,i,20),a.push(DiceDSA5.getSuccessDescription(h)),a=a.join(", "),m={result:i,characteristics:[0,1,2].map((function(a){return{char:t.source.type,res:r.terms[2*a].results[0].result,suc:u[a]<=0,tar:c[a]}})),qualityStep:Math.min(game.settings.get("dsa5","capQSat"),(0==i?1:i>0?Math.ceil(i/3):0)+(null!=t.qualityStep?Number(t.qualityStep):0)),description:a,preData:t,successLevel:h,modifiers:o,extra:{}},b.t1=t.source.type,b.next="poison"===b.t1?23:"disease"===b.t1?28:33;break;case 23:return y=t.source.system.duration.value.split(" / ").map((function(t){return t.trim()})),g=t.source.system.effect.value.split(" / ").map((function(t){return t.trim()})),m.duration=y.length>1?m.successLevel>0?y[0]:y[1]:y[0],m.effect=g.length>1?m.successLevel>0?g[0]:g[1]:g[0],b.abrupt("break",33);case 28:return v=t.source.system.damage.value.split(" / ").map((function(t){return t.trim()})),_=t.source.system.duration.value.split(" / ").map((function(t){return t.trim()})),m.damageeffect=v.length>1?m.successLevel>0?v[0]:v[1]:v[0],m.duration=_.length>1?m.successLevel>0?_[0]:_[1]:_[0],b.abrupt("break",33);case 33:return b.abrupt("return",m);case 34:case"end":return b.stop()}}),_callee25,this)}))),function rollItem(t){return _rollItem.apply(this,arguments)})},{key:"updateDefenseCount",value:(_updateDefenseCount=_asyncToGenerator(_regeneratorRuntime().mark((function _callee26(t){return _regeneratorRuntime().wrap((function _callee26$(r){for(;;)switch(r.prev=r.next){case 0:if(!game.combat){r.next=3;break}return r.next=3,game.combat.updateDefenseCount(t.extra.speaker);case 3:case"end":return r.stop()}}),_callee26)}))),function updateDefenseCount(t){return _updateDefenseCount.apply(this,arguments)})},{key:"_compareWeaponReach",value:function _compareWeaponReach(t,r){var a=r.situationalModifiers.find((function(t){return t.name==game.i18n.localize("LocalizedIDs.circumvent")})),o=_config_dsa5_js__WEBPACK_IMPORTED_MODULE_1__.Z.meleeRangesArray.indexOf(t.system.reach.value),i=_config_dsa5_js__WEBPACK_IMPORTED_MODULE_1__.Z.meleeRangesArray.indexOf(r.opposingWeaponSize);return a&&i>o&&(a.value=2*Math.min(a.step,i-o)),2*Math.min(0,o-i)}},{key:"showDiceSoNice",value:(_showDiceSoNice=_asyncToGenerator(_regeneratorRuntime().mark((function _callee27(t,r){var a,o,i;return _regeneratorRuntime().wrap((function _callee27$(c){for(;;)switch(c.prev=c.next){case 0:if(!_utility_dsa5_js__WEBPACK_IMPORTED_MODULE_3__.Z.moduleEnabled("dice-so-nice")||!game.dice3d){c.next=17;break}a=null,o=!1,c.t0=r,c.next="blindroll"===c.t0?6:"gmroll"===c.t0?9:"selfroll"===c.t0?11:13;break;case 6:return o=!0,a=game.users.filter((function(t){return t.isGM})).map((function(t){return t.id})),c.abrupt("break",13);case 9:return a=game.users.filter((function(t){return t.isGM})).map((function(t){return t.id})),c.abrupt("break",13);case 11:return a=[],c.abrupt("break",13);case 13:if(i=game.dice3d.showForRoll(t,game.user,!0,a,o),game.settings.get("dice-so-nice","immediatelyDisplayChatMessages")){c.next=17;break}return c.next=17,i;case 17:case"end":return c.stop()}}),_callee27)}))),function showDiceSoNice(t,r){return _showDiceSoNice.apply(this,arguments)})},{key:"addApplyEffectData",value:function addApplyEffectData(t){var r=t.preData.source;if(t.successLevel>0){if(["meleeweapon","rangeweapon"].includes(r.type)||"trait"==r.type&&["rangeAttack","meleeAttack"].includes(r.system.traitType.value)){if(r.effects.some((function(t){return!getProperty(t,"flags.dsa5.applyToOwner")})))return!0}else if(["spell","liturgy","ritual","ceremony","trait"].includes(r.type)&&r.effects.length>0)return!0}else if(["disease","poison"].includes(r.type))return r.effects.length>0;var a=t.preData.situationalModifiers.filter((function(t){return t.specAbId})).map((function(t){return t.specAbId}));if(a.length>0){var o,i=_createForOfIteratorHelper(t.preData.extra.actor.items.filter((function(t){return a.includes(t._id)})));try{for(i.s();!(o=i.n()).done;){if(o.value.effects.length>0)return!0}}catch(t){i.e(t)}finally{i.f()}}return!1}},{key:"renderRollCard",value:function(){var _renderRollCard=_asyncToGenerator(_regeneratorRuntime().mark((function _callee28(chatOptions,testData,rerenderMessage){var applyEffect,immuneTo,preData,hideDamage,hasAreaTemplate,chatData,postFunction,html,actor,rollData,enriched,newMsg;return _regeneratorRuntime().wrap((function _callee28$(_context28){for(;;)switch(_context28.prev=_context28.next){case 0:return applyEffect=this.addApplyEffectData(testData),immuneTo=_creature_type_js__WEBPACK_IMPORTED_MODULE_18__.Z.checkImmunity(testData),preData=deepClone(testData.preData),hideDamage=rerenderMessage?rerenderMessage.flags.data.hideDamage:"attack"==preData.mode,Hooks.call("postProcessDSARoll",chatOptions,testData,rerenderMessage,hideDamage),_context28.next=7,_utility_dsa5_js__WEBPACK_IMPORTED_MODULE_3__.Z.callAsyncHooks("postProcessDSARoll",[testData]);case 7:return delete preData.extra.actor,delete testData.actor,delete testData.preData,hasAreaTemplate=testData.successLevel>0&&preData.source.system.target&&preData.source.system.target.type in game.dsa5.config.areaTargetTypes,_context28.t0=chatOptions.title,_context28.t1=immuneTo,_context28.t2=testData,_context28.t3=game.user.isGM,_context28.t4=preData,_context28.t5=hideDamage,_context28.t6=preData.situationalModifiers.filter((function(t){return 0!=t.value})),_context28.t7=applyEffect,_context28.t8=hasAreaTemplate,_context28.next=22,_equipment_damage_js__WEBPACK_IMPORTED_MODULE_12__.Z.showDamageToGear(preData,testData);case 22:if(_context28.t9=_context28.sent,chatData={title:_context28.t0,immuneTo:_context28.t1,testData:_context28.t2,hideData:_context28.t3,preData:_context28.t4,hideDamage:_context28.t5,modifierList:_context28.t6,applyEffect:_context28.t7,hasAreaTemplate:_context28.t8,showDamageToGear:_context28.t9},preData.advancedModifiers&&(preData.advancedModifiers.chars.some((function(t){return 0!=t}))&&chatData.modifierList.push({name:game.i18n.localize("MODS.partChecks"),value:preData.advancedModifiers.chars}),0!=preData.advancedModifiers.fws&&chatData.modifierList.push({name:game.i18n.localize("MODS.FW"),value:preData.advancedModifiers.fws}),0!=preData.advancedModifiers.qls&&chatData.modifierList.push({name:game.i18n.localize("MODS.QS"),value:preData.advancedModifiers.qls})),["gmroll","blindroll"].includes(chatOptions.rollMode)&&(chatOptions.whisper=game.users.filter((function(t){return t.isGM})).map((function(t){return t.id}))),"blindroll"===chatOptions.rollMode?chatOptions.blind=!0:"selfroll"===chatOptions.rollMode&&(chatOptions.whisper=[game.user.id]),_dsa_soundeffect_js__WEBPACK_IMPORTED_MODULE_11__.Z.playEffect(preData.mode,preData.source,testData.successLevel,chatOptions.whisper,chatOptions.blind),chatOptions["flags.data"]={preData,postData:testData,template:chatOptions.template,rollMode:chatOptions.rollMode,isOpposedTest:chatOptions.isOpposedTest,title:chatOptions.title,hideData:chatData.hideData,hideDamage:chatData.hideDamage,isDSARoll:!0},rerenderMessage){_context28.next=38;break}return _context28.next=32,renderTemplate(chatOptions.template,chatData);case 32:return chatOptions.content=_context28.sent,_context28.next=35,ChatMessage.create(chatOptions,!1);case 35:return _context28.abrupt("return",_context28.sent);case 38:if(postFunction=getProperty(rerenderMessage,"flags.data.preData.extra.options.postFunction"),!postFunction){_context28.next=43;break}return testData.messageId=rerenderMessage.id,_context28.next=43,eval(postFunction.functionName)(postFunction,{result:testData,chatData},preData.source);case 43:return _context28.next=45,renderTemplate(chatOptions.template,chatData);case 45:return html=_context28.sent,actor=ChatMessage.getSpeakerActor(rerenderMessage.speaker)||game.users.get(rerenderMessage.user).character,rollData=actor?actor.getRollData():{},_context28.next=50,TextEditor.enrichHTML(html,{rollData,async:!0});case 50:return enriched=_context28.sent,chatOptions.content=enriched,_context28.next=54,rerenderMessage.update(_defineProperty({content:chatOptions.content},"flags.data",chatOptions["flags.data"]));case 54:return newMsg=_context28.sent,ui.chat.updateMessage(newMsg),_context28.abrupt("return",newMsg);case 57:case"end":return _context28.stop()}}),_callee28,this)})));function renderRollCard(t,r,a){return _renderRollCard.apply(this,arguments)}return renderRollCard}()},{key:"_itemRoll",value:(_itemRoll2=_asyncToGenerator(_regeneratorRuntime().mark((function _callee30(t){var r,a,o,i,c,u,l,p,d,h;return _regeneratorRuntime().wrap((function _callee30$(m){for(;;)switch(m.prev=m.next){case 0:if(r=$(t.currentTarget),a=r.parents(".message").attr("data-message-id"),o=game.messages.get(a),i=o.speaker,c=r.attr("data-type"),u=r.attr("data-name"),!(l=_utility_dsa5_js__WEBPACK_IMPORTED_MODULE_3__.Z.getSpeaker(i))){m.next=15;break}if(!(p=l.items.find((function(t){return t.name==u&&t.type==c})))){m.next=14;break}if(d=new _item_item_dsa5_js__WEBPACK_IMPORTED_MODULE_7__.Z(p.toObject(),{temporary:!0}),!(h=!!r.attr("data-removecharge")&&"true"==r.attr("data-removecharge"))){m.next=11;break}if(!(d.system.quantity.value<1)){m.next=11;break}return ui.notifications.error(game.i18n.localize("DSAError.NotEnoughCharges")),m.abrupt("return");case 11:d.setupEffect().then(function(){var t=_asyncToGenerator(_regeneratorRuntime().mark((function _callee29(t){return _regeneratorRuntime().wrap((function _callee29$(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,d.itemTest(t);case 2:if(!h){r.next=5;break}return r.next=5,p.update({"system.quantity.value":p.system.quantity.value-1});case 5:case"end":return r.stop()}}),_callee29)})));return function(r){return t.apply(this,arguments)}}()),m.next=15;break;case 14:ui.notifications.error(game.i18n.format("DSAError.notFound",{category:c,name:u}));case 15:case"end":return m.stop()}}),_callee30)}))),function _itemRoll(t){return _itemRoll2.apply(this,arguments)})},{key:"_rollEdit",value:(_rollEdit2=_asyncToGenerator(_regeneratorRuntime().mark((function _callee31(t){var r,a,o,i,c,u,l,p,d,h,m;return _regeneratorRuntime().wrap((function _callee31$(y){for(;;)switch(y.prev=y.next){case 0:r=$(t.currentTarget),a=r.parents(".message").attr("data-message-id"),o=game.messages.get(a),i=o.flags.data,(c=i.preData).extra.actor=_utility_dsa5_js__WEBPACK_IMPORTED_MODULE_3__.Z.getSpeaker(c.extra.speaker).toObject(!1),c.extra.options.cheat&&delete c.extra.options.cheat,y.t0=r.attr("data-edit-type"),y.next="roll"===y.t0?8:"mod"===y.t0?12:23;break;case 8:return u=r.attr("data-edit-id"),l=Number(r.val()),c.roll.terms.length>2*u?((p=Roll.fromData(c.roll)).editRollAtIndex([{index:u,val:l}]),c.roll=p):(d=Roll.fromData(i.postData.damageRoll),u-=c.roll.terms.filter((function(t){return t.results})).length,d.editRollAtIndex([{index:u,val:l}]),c.damageRoll=d),y.abrupt("break",23);case 12:return(u=c.situationalModifiers.findIndex((function(t){return t.name==game.i18n.localize("chatEdit")})))>0&&c.situationalModifiers.splice(u,1),y.t1=game.i18n.localize("chatEdit"),y.t2=Number(r.val()),y.next=18,this._situationalModifiers(c);case 18:return y.t3=y.sent,y.t4=y.t2-y.t3,h={name:y.t1,value:y.t4},c.situationalModifiers.push(h),y.abrupt("break",23);case 23:m={template:i.template,rollMode:i.rollMode,title:i.title,speaker:o.speaker,user:o.user.id},["gmroll","blindroll"].includes(m.rollMode)&&(m.whisper=game.users.filter((function(t){return t.isGM})).map((function(t){return t.id}))),"blindroll"===m.rollMode&&(m.blind=!0),["poison","disease"].includes(c.source.type)?new _item_item_dsa5_js__WEBPACK_IMPORTED_MODULE_7__.Z(c.source,{temporary:!0})["".concat(i.postData.postFunction)]({testData:c,cardOptions:m},{rerenderMessage:o}):_utility_dsa5_js__WEBPACK_IMPORTED_MODULE_3__.Z.getSpeaker(o.speaker)["".concat(i.postData.postFunction)]({testData:c,cardOptions:m},{rerenderMessage:o});case 27:case"end":return y.stop()}}),_callee31,this)}))),function _rollEdit(t){return _rollEdit2.apply(this,arguments)})},{key:"gearDamaged",value:(_gearDamaged=_asyncToGenerator(_regeneratorRuntime().mark((function _callee32(t){var r,a;return _regeneratorRuntime().wrap((function _callee32$(o){for(;;)switch(o.prev=o.next){case 0:if(!((r=t.currentTarget.dataset.uuid.split(";")).length>1)){o.next=8;break}return o.next=4,Promise.all(r.map((function(t){return fromUuid(t)})));case 4:a=o.sent,_dialog_dialog_equipmentdamage_js__WEBPACK_IMPORTED_MODULE_13__.Z.showDialog(a),o.next=13;break;case 8:return o.t0=_equipment_damage_js__WEBPACK_IMPORTED_MODULE_12__.Z,o.next=11,fromUuid(r[0]);case 11:o.t1=o.sent,o.t0.breakingTest.call(o.t0,o.t1);case 13:case"end":return o.stop()}}),_callee32)}))),function gearDamaged(t){return _gearDamaged.apply(this,arguments)})},{key:"rollResistPain",value:(_rollResistPain=_asyncToGenerator(_regeneratorRuntime().mark((function _callee33(t){var r,a,o;return _regeneratorRuntime().wrap((function _callee33$(i){for(;;)switch(i.prev=i.next){case 0:r=t.currentTarget.dataset,a={token:r.token,actor:r.actor,scene:canvas.id},(o=_utility_dsa5_js__WEBPACK_IMPORTED_MODULE_3__.Z.getSpeaker(a))&&o.finishResistPainRoll();case 4:case"end":return i.stop()}}),_callee33)}))),function rollResistPain(t){return _rollResistPain.apply(this,arguments)})},{key:"wrapLock",value:(_wrapLock=_asyncToGenerator(_regeneratorRuntime().mark((function _callee34(t,r){var a;return _regeneratorRuntime().wrap((function _callee34$(o){for(;;)switch(o.prev=o.next){case 0:if(!(a=$(t.currentTarget)).hasClass("locked")){o.next=3;break}return o.abrupt("return");case 3:return a.addClass("locked"),a.prepend(''),o.next=7,r(t,a);case 7:setTimeout((function(){a.removeClass("locked"),a.find("i").remove()}),2e3);case 8:case"end":return o.stop()}}),_callee34)}))),function wrapLock(t,r){return _wrapLock.apply(this,arguments)})},{key:"chatListeners",value:(_chatListeners=_asyncToGenerator(_regeneratorRuntime().mark((function _callee41(t){return _regeneratorRuntime().wrap((function _callee41$(r){for(;;)switch(r.prev=r.next){case 0:t.on("click",".expand-mods",(function(t){t.preventDefault();var r=$(t.currentTarget);r.find("i").toggleClass("fa-minus fa-plus"),r.siblings("ul,div").fadeToggle()})),t.on("click",".edit-toggle",(function(t){t.preventDefault(),$(t.currentTarget).parents(".chat-card").find(".display-toggle").toggle()})),t.on("click",".botch-roll",(function(t){return _tables_dsatables_js__WEBPACK_IMPORTED_MODULE_14__.Z.showBotchCard(t.currentTarget.dataset)})),t.on("click",".roll-item",(function(t){return DiceDSA5._itemRoll(t)})),t.on("click",".gearDamaged",function(){var t=_asyncToGenerator(_regeneratorRuntime().mark((function _callee35(t){return _regeneratorRuntime().wrap((function _callee35$(r){for(;;)switch(r.prev=r.next){case 0:return r.abrupt("return",DiceDSA5.gearDamaged(t));case 1:case"end":return r.stop()}}),_callee35)})));return function(r){return t.apply(this,arguments)}}()),t.on("change",".roll-edit",(function(t){return DiceDSA5._rollEdit(t)})),t.on("click",".applyEffect",function(){var t=_asyncToGenerator(_regeneratorRuntime().mark((function _callee37(t){return _regeneratorRuntime().wrap((function _callee37$(r){for(;;)switch(r.prev=r.next){case 0:DiceDSA5.wrapLock(t,function(){var t=_asyncToGenerator(_regeneratorRuntime().mark((function _callee36(t,r){var a,o;return _regeneratorRuntime().wrap((function _callee36$(i){for(;;)switch(i.prev=i.next){case 0:return a=r.parents(".message").attr("data-message-id"),o=t.currentTarget.dataset.target,i.next=4,_status_active_effects_js__WEBPACK_IMPORTED_MODULE_10__.Z.applyEffect(a,o);case 4:case"end":return i.stop()}}),_callee36)})));return function(r,a){return t.apply(this,arguments)}}());case 1:case"end":return r.stop()}}),_callee37)})));return function(r){return t.apply(this,arguments)}}()),t.on("click",".applyTableEffect",function(){var t=_asyncToGenerator(_regeneratorRuntime().mark((function _callee39(t){return _regeneratorRuntime().wrap((function _callee39$(r){for(;;)switch(r.prev=r.next){case 0:DiceDSA5.wrapLock(t,function(){var t=_asyncToGenerator(_regeneratorRuntime().mark((function _callee38(t,r){var a,o;return _regeneratorRuntime().wrap((function _callee38$(i){for(;;)switch(i.prev=i.next){case 0:return a=r.parents(".message").attr("data-message-id"),o=t.currentTarget.dataset.target,i.next=4,_tables_tableEffects_js__WEBPACK_IMPORTED_MODULE_17__.Z.applyEffect(a,o);case 4:case"end":return i.stop()}}),_callee38)})));return function(r,a){return t.apply(this,arguments)}}());case 1:case"end":return r.stop()}}),_callee39)})));return function(r){return t.apply(this,arguments)}}()),t.on("click",".placeTemplate",function(){var t=_asyncToGenerator(_regeneratorRuntime().mark((function _callee40(t){return _regeneratorRuntime().wrap((function _callee40$(r){for(;;)switch(r.prev=r.next){case 0:return r.abrupt("return",_measuretemplate_js__WEBPACK_IMPORTED_MODULE_16__.c.placeTemplateFromChat(t));case 1:case"end":return r.stop()}}),_callee40)})));return function(r){return t.apply(this,arguments)}}()),t.on("click",".message-delete",(function(t){var r=game.messages.get($(t.currentTarget).parents(".message").attr("data-message-id"));if(r.flags.unopposeData){var a=canvas.tokens.get(r.flags.unopposeData.targetSpeaker.token);_opposed_dsa5_js__WEBPACK_IMPORTED_MODULE_9__.Z.clearOpposed(a.actor)}})),t.on("click",".resistEffect",(function(t){return _status_active_effects_js__WEBPACK_IMPORTED_MODULE_10__.Z.resistEffect(t)})),t.on("click",".resistPain",(function(t){return DiceDSA5.rollResistPain(t)})),_request_roll_js__WEBPACK_IMPORTED_MODULE_15__.Z.chatListeners(t);case 13:case"end":return r.stop()}}),_callee41)}))),function chatListeners(t){return _chatListeners.apply(this,arguments)})}]),DiceDSA5}()},803:(t,r,a)=>{function _typeof(t){return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},_typeof(t)}function _createForOfIteratorHelper(t,r){var a="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!a){if(Array.isArray(t)||(a=_unsupportedIterableToArray(t))||r&&t&&"number"==typeof t.length){a&&(t=a);var o=0,i=function F(){};return{s:i,n:function n(){return o>=t.length?{done:!0}:{done:!1,value:t[o++]}},e:function e(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var c,u=!0,l=!1;return{s:function s(){a=a.call(t)},n:function n(){var t=a.next();return u=t.done,t},e:function e(t){l=!0,c=t},f:function f(){try{u||null==a.return||a.return()}finally{if(l)throw c}}}}function _toConsumableArray(t){return function _arrayWithoutHoles(t){if(Array.isArray(t))return _arrayLikeToArray(t)}(t)||function _iterableToArray(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||_unsupportedIterableToArray(t)||function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function _unsupportedIterableToArray(t,r){if(t){if("string"==typeof t)return _arrayLikeToArray(t,r);var a=Object.prototype.toString.call(t).slice(8,-1);return"Object"===a&&t.constructor&&(a=t.constructor.name),"Map"===a||"Set"===a?Array.from(t):"Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a)?_arrayLikeToArray(t,r):void 0}}function _arrayLikeToArray(t,r){(null==r||r>t.length)&&(r=t.length);for(var a=0,o=new Array(r);a=0;--o){var i=this.tryEntries[o],c=i.completion;if("root"===i.tryLoc)return handle("end");if(i.tryLoc<=this.prev){var u=a.call(i,"catchLoc"),l=a.call(i,"finallyLoc");if(u&&l){if(this.prev=0;--o){var i=this.tryEntries[o];if(i.tryLoc<=this.prev&&a.call(i,"finallyLoc")&&this.prev=0;--r){var a=this.tryEntries[r];if(a.finallyLoc===t)return this.complete(a.completion,a.afterLoc),resetTryEntry(a),l}},catch:function _catch(t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc===t){var o=a.completion;if("throw"===o.type){var i=o.arg;resetTryEntry(a)}return i}}throw new Error("illegal catch attempt")},delegateYield:function delegateYield(t,r,a){return this.delegate={iterator:values(t),resultName:r,nextLoc:a},"next"===this.method&&(this.arg=void 0),l}},t}function asyncGeneratorStep(t,r,a,o,i,c,u){try{var l=t[c](u),p=l.value}catch(t){return void a(t)}l.done?r(p):Promise.resolve(p).then(o,i)}function _asyncToGenerator(t){return function(){var r=this,a=arguments;return new Promise((function(o,i){var c=t.apply(r,a);function _next(t){asyncGeneratorStep(c,o,i,_next,_throw,"next",t)}function _throw(t){asyncGeneratorStep(c,o,i,_next,_throw,"throw",t)}_next(void 0)}))}}function _defineProperties(t,r){for(var a=0;ao});var o=function(){function DSA5SoundEffect(){!function _classCallCheck(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}(this,DSA5SoundEffect)}var t,r,a,o,i,c;return function _createClass(t,r,a){return r&&_defineProperties(t.prototype,r),a&&_defineProperties(t,a),Object.defineProperty(t,"prototype",{writable:!1}),t}(DSA5SoundEffect,null,[{key:"prepareSoundEffects",value:function prepareSoundEffects(){DSA5SoundEffect.soundPaths={money:[],armor:[],meleeweapon:[],rangeweapon:[],default:[]},game.modules.get("gAudioBundle-3")&&(DSA5SoundEffect.soundPaths.money.push("modules/gAudioBundle-3/src/Mint Coins And Money/Coin_Slide_Carpet.ogg","modules/gAudioBundle-3/src/Mint Coins And Money/Coins_Drop_Carpet_06.ogg","modules/gAudioBundle-3/src/Mint Coins And Money/Coins_Bottlecaps_Drop.ogg","modules/gAudioBundle-3/src/Mint Coins And Money/Coins_In_Sack_Held_By_Drawstring_06.ogg","modules/gAudioBundle-3/src/Money/Money_Coins_Handle.ogg"),DSA5SoundEffect.soundPaths.meleeweapon.push("modules/gAudioBundle-3/src/Medieval Armor And Impacts/Weapon_Impact_Parry_01.ogg")),game.modules.get("gAudioBundle-2")&&(DSA5SoundEffect.soundPaths.meleeweapon.push("modules/gAudioBundle-2/src/Gore/Melee_Sword_Attack_04.ogg"),DSA5SoundEffect.soundPaths.armor.push("modules/gAudioBundle-2/src/Footsteps/Footstep And Foley Sounds/Foley_Soldier_Gear_Equipment_Metal_Cloth_Heavy_Movement_Light_08.ogg"),DSA5SoundEffect.soundPaths.default.push("modules/gAudioBundle-2/src/Footsteps/Footstep And Foley Sounds/Foley_Sports_Bag_Grab_Pickup_Catch_04.ogg","modules/gAudioBundle-2/src/Footsteps/Footstep And Foley Sounds/Footstep_Ice_Crunchy_Run_01.ogg","modules/gAudioBundle-2/src/Footsteps/Footstep And Foley Sounds/Footstep_Ice_Crunchy_Run_02.ogg")),game.modules.get("gAudioBundle-4")&&DSA5SoundEffect.soundPaths.rangeweapon.push("modules/gAudioBundle-4/src/Super Heroes Sound Design/Hawk's_Arrow_Flies_Bow_And_Arrow_Shoot_2.ogg"),Hooks.call("setDefaultDSASounds",DSA5SoundEffect.soundPaths)}},{key:"playEffect",value:(c=_asyncToGenerator(_regeneratorRuntime().mark((function _callee(t,r,a){var o,i,c,u=arguments;return _regeneratorRuntime().wrap((function _callee$(l){for(;;)switch(l.prev=l.next){case 0:return o=u.length>3&&void 0!==u[3]?u[3]:void 0,i=u.length>4&&void 0!==u[4]&&u[4],l.next=4,this.getSound(t,r,a);case 4:if(c=l.sent)try{o?(game.socket.emit("system.dsa5",{type:"playWhisperSound",payload:{whisper:o,soundPath:c}}),i||AudioHelper.play({src:c,volume:.8,loop:!1},!1)):AudioHelper.play({src:c,volume:.8,loop:!1},!0)}catch(t){console.warn("Could not play item sound effect ".concat(c))}case 6:case"end":return l.stop()}}),_callee,this)}))),function playEffect(t,r,a){return c.apply(this,arguments)})},{key:"loadSoundConfig",value:(i=_asyncToGenerator(_regeneratorRuntime().mark((function _callee2(){var t,r,a;return _regeneratorRuntime().wrap((function _callee2$(o){for(;;)switch(o.prev=o.next){case 0:return o.next=2,game.settings.get("dsa5","soundConfig");case 2:if(!(t=o.sent)){o.next=18;break}return o.prev=4,o.next=7,fetch(t);case 7:return r=o.sent,o.next=10,r.json();case 10:a=o.sent,this.sounds=a,console.log("DSA5 | Sound Config Loaded"),o.next=18;break;case 15:o.prev=15,o.t0=o.catch(4),console.warn(o.t0);case 18:case"end":return o.stop()}}),_callee2,this,[[4,15]])}))),function loadSoundConfig(){return i.apply(this,arguments)})},{key:"successLevelToString",value:function successLevelToString(t){switch(t){case-1:return["fail"];case-2:return["botch","fail"];case 1:return["success"];case 2:return["crit","success"];default:return[]}}},{key:"getSound",value:(o=_asyncToGenerator(_regeneratorRuntime().mark((function _callee3(t,r,a){var o,i,c,u,l,p,d;return _regeneratorRuntime().wrap((function _callee3$(h){for(;;)switch(h.prev=h.next){case 0:if(this.sounds||this.triedInit){h.next=4;break}return h.next=3,this.loadSoundConfig();case 3:this.triedInit=!0;case 4:if(this.sounds){h.next=6;break}return h.abrupt("return",void 0);case 6:i=this.successLevelToString(a),c=[],h.t0=r.type,h.next="meleeweapon"===h.t0||"rangeweapon"===h.t0?11:"skill"===h.t0?13:"liturgy"===h.t0||"spell"===h.t0||"ceremony"===h.t0||"ritual"===h.t0?15:17;break;case 11:return c=[].concat(_toConsumableArray(i.map((function(a){return"".concat(r.type,".manual.").concat(r.name,".").concat(t,"_").concat(a)}))),["".concat(r.type,".manual.").concat(r.name,".").concat(t),"".concat(r.type,".manual.").concat(r.name,".default.").concat(t),"".concat(r.type,".manual.").concat(r.name,".default")],_toConsumableArray(i.map((function(a){return"".concat(r.type,".").concat(r.system.combatskill.value,".").concat(t,"_").concat(a)}))),["".concat(r.type,".").concat(r.system.combatskill.value,".").concat(t)],_toConsumableArray(i.map((function(t){return"".concat(r.type,".").concat(r.system.combatskill.value,".default_").concat(t)}))),["".concat(r.type,".").concat(r.system.combatskill.value,".default")]),h.abrupt("break",17);case 13:case 15:return c=[].concat(_toConsumableArray(i.map((function(a){return"".concat(r.type,".").concat(r.name,".").concat(t,"_").concat(a)}))),["".concat(r.type,".").concat(r.name,".").concat(t)],_toConsumableArray(i.map((function(t){return"".concat(r.type,".").concat(r.name,".default_").concat(t)}))),["".concat(r.type,".").concat(r.name,".default")]),h.abrupt("break",17);case 17:(o=c).push.apply(o,_toConsumableArray(i.map((function(t){return"".concat(r.type,".default_").concat(t)}))).concat(["".concat(r.type,".default")])),l=_createForOfIteratorHelper(c),h.prev=19,l.s();case 21:if((p=l.n()).done){h.next=30;break}if(d=p.value,hasProperty(this.sounds,d)){h.next=25;break}return h.abrupt("continue",28);case 25:if(!(u=getProperty(this.sounds,d))||!("string"==typeof u||u instanceof String)){h.next=28;break}return h.abrupt("break",30);case 28:h.next=21;break;case 30:h.next=35;break;case 32:h.prev=32,h.t1=h.catch(19),l.e(h.t1);case 35:return h.prev=35,l.f(),h.finish(35);case 38:return h.abrupt("return",u);case 39:case"end":return h.stop()}}),_callee3,this,[[19,32,35,38]])}))),function getSound(t,r,a){return o.apply(this,arguments)})},{key:"playMoneySound",value:(a=_asyncToGenerator(_regeneratorRuntime().mark((function _callee4(){var t,r,a,o=arguments;return _regeneratorRuntime().wrap((function _callee4$(i){for(;;)switch(i.prev=i.next){case 0:return t=o.length>0&&void 0!==o[0]&&o[0],r=DSA5SoundEffect.soundPaths.money,a=r[Math.floor(Math.random()*r.length)],i.next=5,this.playSoundPath(a,t);case 5:case"end":return i.stop()}}),_callee4,this)}))),function playMoneySound(){return a.apply(this,arguments)})},{key:"playEquipmentWearStatusChange",value:(r=_asyncToGenerator(_regeneratorRuntime().mark((function _callee5(t){var r,a,o,i=arguments;return _regeneratorRuntime().wrap((function _callee5$(c){for(;;)switch(c.prev=c.next){case 0:if(r=i.length>1&&void 0!==i[1]&&i[1],!((a=DSA5SoundEffect.soundPaths[t.type]||DSA5SoundEffect.soundPaths.default).length>0)){c.next=6;break}return o=a[Math.floor(Math.random()*a.length)],c.next=6,this.playSoundPath(o,r,.5);case 6:case"end":return c.stop()}}),_callee5,this)}))),function playEquipmentWearStatusChange(t){return r.apply(this,arguments)})},{key:"playSoundPath",value:(t=_asyncToGenerator(_regeneratorRuntime().mark((function _callee6(t){var r,a,o=arguments;return _regeneratorRuntime().wrap((function _callee6$(i){for(;;)switch(i.prev=i.next){case 0:if(r=o.length>1&&void 0!==o[1]&&o[1],a=o.length>2&&void 0!==o[2]?o[2]:.8,game.settings.get("dsa5","inventorySound")){i.next=4;break}return i.abrupt("return");case 4:try{AudioHelper.play({src:t,volume:a,loop:!1},r)}catch(r){console.warn("Could not play item sound effect ".concat(t))}case 5:case"end":return i.stop()}}),_callee6)}))),function playSoundPath(r){return t.apply(this,arguments)})}]),DSA5SoundEffect}();_defineProperty(o,"sounds",void 0),_defineProperty(o,"triedInit",!1)},702:(t,r,a)=>{a.d(r,{Z:()=>p});var o=a(5),i=a(577),c=a(472),u=a(562),l=a(491);function _typeof(t){return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},_typeof(t)}function _regeneratorRuntime(){_regeneratorRuntime=function _regeneratorRuntime(){return t};var t={},r=Object.prototype,a=r.hasOwnProperty,o="function"==typeof Symbol?Symbol:{},i=o.iterator||"@@iterator",c=o.asyncIterator||"@@asyncIterator",u=o.toStringTag||"@@toStringTag";function define(t,r,a){return Object.defineProperty(t,r,{value:a,enumerable:!0,configurable:!0,writable:!0}),t[r]}try{define({},"")}catch(t){define=function define(t,r,a){return t[r]=a}}function wrap(t,r,a,o){var i=r&&r.prototype instanceof Generator?r:Generator,c=Object.create(i.prototype),u=new Context(o||[]);return c._invoke=function(t,r,a){var o="suspendedStart";return function(i,c){if("executing"===o)throw new Error("Generator is already running");if("completed"===o){if("throw"===i)throw c;return doneResult()}for(a.method=i,a.arg=c;;){var u=a.delegate;if(u){var p=maybeInvokeDelegate(u,a);if(p){if(p===l)continue;return p}}if("next"===a.method)a.sent=a._sent=a.arg;else if("throw"===a.method){if("suspendedStart"===o)throw o="completed",a.arg;a.dispatchException(a.arg)}else"return"===a.method&&a.abrupt("return",a.arg);o="executing";var d=tryCatch(t,r,a);if("normal"===d.type){if(o=a.done?"completed":"suspendedYield",d.arg===l)continue;return{value:d.arg,done:a.done}}"throw"===d.type&&(o="completed",a.method="throw",a.arg=d.arg)}}}(t,a,u),c}function tryCatch(t,r,a){try{return{type:"normal",arg:t.call(r,a)}}catch(t){return{type:"throw",arg:t}}}t.wrap=wrap;var l={};function Generator(){}function GeneratorFunction(){}function GeneratorFunctionPrototype(){}var p={};define(p,i,(function(){return this}));var d=Object.getPrototypeOf,h=d&&d(d(values([])));h&&h!==r&&a.call(h,i)&&(p=h);var m=GeneratorFunctionPrototype.prototype=Generator.prototype=Object.create(p);function defineIteratorMethods(t){["next","throw","return"].forEach((function(r){define(t,r,(function(t){return this._invoke(r,t)}))}))}function AsyncIterator(t,r){function invoke(o,i,c,u){var l=tryCatch(t[o],t,i);if("throw"!==l.type){var p=l.arg,d=p.value;return d&&"object"==_typeof(d)&&a.call(d,"__await")?r.resolve(d.__await).then((function(t){invoke("next",t,c,u)}),(function(t){invoke("throw",t,c,u)})):r.resolve(d).then((function(t){p.value=t,c(p)}),(function(t){return invoke("throw",t,c,u)}))}u(l.arg)}var o;this._invoke=function(t,a){function callInvokeWithMethodAndArg(){return new r((function(r,o){invoke(t,a,r,o)}))}return o=o?o.then(callInvokeWithMethodAndArg,callInvokeWithMethodAndArg):callInvokeWithMethodAndArg()}}function maybeInvokeDelegate(t,r){var a=t.iterator[r.method];if(void 0===a){if(r.delegate=null,"throw"===r.method){if(t.iterator.return&&(r.method="return",r.arg=void 0,maybeInvokeDelegate(t,r),"throw"===r.method))return l;r.method="throw",r.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var o=tryCatch(a,t.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,l;var i=o.arg;return i?i.done?(r[t.resultName]=i.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=void 0),r.delegate=null,l):i:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,l)}function pushTryEntry(t){var r={tryLoc:t[0]};1 in t&&(r.catchLoc=t[1]),2 in t&&(r.finallyLoc=t[2],r.afterLoc=t[3]),this.tryEntries.push(r)}function resetTryEntry(t){var r=t.completion||{};r.type="normal",delete r.arg,t.completion=r}function Context(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(pushTryEntry,this),this.reset(!0)}function values(t){if(t){var r=t[i];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var o=-1,c=function next(){for(;++o=0;--o){var i=this.tryEntries[o],c=i.completion;if("root"===i.tryLoc)return handle("end");if(i.tryLoc<=this.prev){var u=a.call(i,"catchLoc"),l=a.call(i,"finallyLoc");if(u&&l){if(this.prev=0;--o){var i=this.tryEntries[o];if(i.tryLoc<=this.prev&&a.call(i,"finallyLoc")&&this.prev=0;--r){var a=this.tryEntries[r];if(a.finallyLoc===t)return this.complete(a.completion,a.afterLoc),resetTryEntry(a),l}},catch:function _catch(t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc===t){var o=a.completion;if("throw"===o.type){var i=o.arg;resetTryEntry(a)}return i}}throw new Error("illegal catch attempt")},delegateYield:function delegateYield(t,r,a){return this.delegate={iterator:values(t),resultName:r,nextLoc:a},"next"===this.method&&(this.arg=void 0),l}},t}function asyncGeneratorStep(t,r,a,o,i,c,u){try{var l=t[c](u),p=l.value}catch(t){return void a(t)}l.done?r(p):Promise.resolve(p).then(o,i)}function _asyncToGenerator(t){return function(){var r=this,a=arguments;return new Promise((function(o,i){var c=t.apply(r,a);function _next(t){asyncGeneratorStep(c,o,i,_next,_throw,"next",t)}function _throw(t){asyncGeneratorStep(c,o,i,_next,_throw,"throw",t)}_next(void 0)}))}}function _defineProperties(t,r){for(var a=0;a14||r.successLevel>2)&&game.settings.get("dsa5","armorAndWeaponDamage")}},{key:"armorEncumbranceModifier",value:function armorEncumbranceModifier(t){return game.settings.get("dsa5","armorAndWeaponDamage")&&EquipmentDamage.calculateWear(t)>1?1:0}},{key:"showDamageToGear",value:(p=_asyncToGenerator(_regeneratorRuntime().mark((function _callee(t,r){var a,o,i,c,u;return _regeneratorRuntime().wrap((function _callee$(p){for(;;)switch(p.prev=p.next){case 0:if(!game.settings.get("dsa5","armorAndWeaponDamage")){p.next=11;break}if(a=l.Z.getSpeaker(t.extra.speaker),o=0,(i=getProperty(a,"flags.oppose.messageId"))&&(c=game.messages.get(i))&&(o=getProperty(c,"flags.data.postData.successLevel")||0),!((u=t.source)._id&&u.system.structure&&(r.successLevel<-2||o>2)&&["meleeweapon","rangeweapon","armor"].includes(u.type))){p.next=11;break}return p.next=9,l.Z.getSpeaker(r.speaker);case 9:return a=p.sent,p.abrupt("return",a.items.get(u._id).uuid);case 11:return p.abrupt("return",void 0);case 12:case"end":return p.stop()}}),_callee)}))),function showDamageToGear(t,r){return p.apply(this,arguments)})},{key:"breakingTest",value:function breakingTest(t){if(!t)return ui.notifications.warn(game.i18n.format("DSAError.notfound",{category:"",name:game.i18n.localize("equipment")}));if(t.system.structure.max<=0)return ui.notifications.warn(game.i18n.format("DSAError.noBreakingStructure",{name:t.name}));var r,a=0;if("armor"==t.type?(r=game.i18n.localize("ARMORSUBCATEGORIES.".concat(t.system.subcategory)),a=getProperty(t,"system.structure.breakPointRating")||i.Z.armorSubcategories[t.system.subcategory]):(r=t.system.combatskill.value,a=getProperty(t,"system.structure.breakPointRating")||i.Z.weaponStabilities[game.i18n.localize("LocalizedCTs.".concat(r))]),a){var u="",l=getProperty(t,"effect.attributes")||"";new RegExp("".concat(c.Z.magical),"i").test(l)?u="".concat(game.i18n.format("WEAPON.attributeWarning",{domain:c.Z.clerical}),"
"):new RegExp("".concat(c.Z.clerical),"i").test(l)&&(u="".concat(game.i18n.format("WEAPON.attributeWarning",{domain:c.Z.magical}),"
")),new o.Z({title:game.i18n.localize("DSASETTINGS.armorAndWeaponDamage"),content:"".concat(u,': '),buttons:{Yes:{icon:'',label:game.i18n.localize("Roll"),callback:function callback(a){EquipmentDamage.resolveBreakingTest(t,Number(a.find('[name="threshold"]').val()),r)}},cancel:{icon:'',label:game.i18n.localize("cancel")}},default:"Yes"}).render(!0)}else ui.notifications.error(game.i18n.format("DSAError.noBreakingResistance",{item:t.name}))}},{key:"applyDamageLevelToItem",value:(a=_asyncToGenerator(_regeneratorRuntime().mark((function _callee2(t,r){var a;return _regeneratorRuntime().wrap((function _callee2$(o){for(;;)switch(o.prev=o.next){case 0:return a=Math.ceil(.25*t.system.structure.max)*r,o.next=3,t.update({"system.structure.value":Math.max(0,t.system.structure.value-a)});case 3:case"end":return o.stop()}}),_callee2)}))),function applyDamageLevelToItem(t,r){return a.apply(this,arguments)})},{key:"absoluteDamageLevelToItem",value:(r=_asyncToGenerator(_regeneratorRuntime().mark((function _callee3(t,r){var a;return _regeneratorRuntime().wrap((function _callee3$(o){for(;;)switch(o.prev=o.next){case 0:return a=Math.ceil(.25*t.system.structure.max)*r,o.next=3,t.update({"system.structure.value":Math.min(t.system.structure.value,Math.max(0,t.system.structure.max-a))});case 3:case"end":return o.stop()}}),_callee3)}))),function absoluteDamageLevelToItem(t,a){return r.apply(this,arguments)})},{key:"resolveBreakingTest",value:(t=_asyncToGenerator(_regeneratorRuntime().mark((function _callee4(t,r,a){var o,i,c,p;return _regeneratorRuntime().wrap((function _callee4$(d){for(;;)switch(d.prev=d.next){case 0:return d.t0=u.Z,d.next=3,new Roll("1d20").evaluate({async:!0});case 3:return d.t1=d.sent,d.t2=game.i18n.format("WEAR.check",{category:a}),d.next=7,d.t0.manualRolls.call(d.t0,d.t1,d.t2);case 7:return o=d.sent,d.t3=u.Z,d.t4=o,d.next=12,game.settings.get("core","rollMode");case 12:return d.t5=d.sent,d.next=15,d.t3.showDiceSoNice.call(d.t3,d.t4,d.t5);case 15:return i=o.total>r?1:0,d.next=18,this.applyDamageLevelToItem(t,i);case 18:return c=EquipmentDamage.calculateWear(t.data),d.next=21,renderTemplate("systems/dsa5/templates/system/breakingtest.html",{wear:c,item:t,threshold:r,category:a,roll:o,result:game.i18n.localize("WEAR.".concat(t.type,".").concat(c))});case 21:p=d.sent,ChatMessage.create(l.Z.chatDataSetup(p));case 23:case"end":return d.stop()}}),_callee4,this)}))),function resolveBreakingTest(r,a,o){return t.apply(this,arguments)})},{key:"damageTooltip",value:function damageTooltip(t){if(game.settings.get("dsa5","armorAndWeaponDamage")){var r=this.calculateWear(t);return{msg:game.i18n.localize("WEAR.".concat(t.type,".").concat(r)),css:"gearD damaged".concat(r)}}return{msg:"",css:""}}},{key:"weaponWearModifier",value:function weaponWearModifier(t){if(game.settings.get("dsa5","armorAndWeaponDamage"))switch(EquipmentDamage.calculateWear(t)){case 1:t.attack-=1,t.parry&&(t.parry-=1);break;case 2:t.attack-=2,t.parry&&(t.parry-=2);break;case 3:case 4:t.attack=0,t.parry&&(t.parry=0)}}},{key:"calculateWear",value:function calculateWear(t){return!t.system.structure||Number(t.system.structure.max<=0)?0:Math.floor(4*(1-t.system.structure.value/t.system.structure.max))}}]),EquipmentDamage}()},794:(t,r,a)=>{a.d(r,{Z:()=>c});var o=a(577),i=a(491);function _typeof(t){return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},_typeof(t)}function _regeneratorRuntime(){_regeneratorRuntime=function _regeneratorRuntime(){return t};var t={},r=Object.prototype,a=r.hasOwnProperty,o="function"==typeof Symbol?Symbol:{},i=o.iterator||"@@iterator",c=o.asyncIterator||"@@asyncIterator",u=o.toStringTag||"@@toStringTag";function define(t,r,a){return Object.defineProperty(t,r,{value:a,enumerable:!0,configurable:!0,writable:!0}),t[r]}try{define({},"")}catch(t){define=function define(t,r,a){return t[r]=a}}function wrap(t,r,a,o){var i=r&&r.prototype instanceof Generator?r:Generator,c=Object.create(i.prototype),u=new Context(o||[]);return c._invoke=function(t,r,a){var o="suspendedStart";return function(i,c){if("executing"===o)throw new Error("Generator is already running");if("completed"===o){if("throw"===i)throw c;return doneResult()}for(a.method=i,a.arg=c;;){var u=a.delegate;if(u){var p=maybeInvokeDelegate(u,a);if(p){if(p===l)continue;return p}}if("next"===a.method)a.sent=a._sent=a.arg;else if("throw"===a.method){if("suspendedStart"===o)throw o="completed",a.arg;a.dispatchException(a.arg)}else"return"===a.method&&a.abrupt("return",a.arg);o="executing";var d=tryCatch(t,r,a);if("normal"===d.type){if(o=a.done?"completed":"suspendedYield",d.arg===l)continue;return{value:d.arg,done:a.done}}"throw"===d.type&&(o="completed",a.method="throw",a.arg=d.arg)}}}(t,a,u),c}function tryCatch(t,r,a){try{return{type:"normal",arg:t.call(r,a)}}catch(t){return{type:"throw",arg:t}}}t.wrap=wrap;var l={};function Generator(){}function GeneratorFunction(){}function GeneratorFunctionPrototype(){}var p={};define(p,i,(function(){return this}));var d=Object.getPrototypeOf,h=d&&d(d(values([])));h&&h!==r&&a.call(h,i)&&(p=h);var m=GeneratorFunctionPrototype.prototype=Generator.prototype=Object.create(p);function defineIteratorMethods(t){["next","throw","return"].forEach((function(r){define(t,r,(function(t){return this._invoke(r,t)}))}))}function AsyncIterator(t,r){function invoke(o,i,c,u){var l=tryCatch(t[o],t,i);if("throw"!==l.type){var p=l.arg,d=p.value;return d&&"object"==_typeof(d)&&a.call(d,"__await")?r.resolve(d.__await).then((function(t){invoke("next",t,c,u)}),(function(t){invoke("throw",t,c,u)})):r.resolve(d).then((function(t){p.value=t,c(p)}),(function(t){return invoke("throw",t,c,u)}))}u(l.arg)}var o;this._invoke=function(t,a){function callInvokeWithMethodAndArg(){return new r((function(r,o){invoke(t,a,r,o)}))}return o=o?o.then(callInvokeWithMethodAndArg,callInvokeWithMethodAndArg):callInvokeWithMethodAndArg()}}function maybeInvokeDelegate(t,r){var a=t.iterator[r.method];if(void 0===a){if(r.delegate=null,"throw"===r.method){if(t.iterator.return&&(r.method="return",r.arg=void 0,maybeInvokeDelegate(t,r),"throw"===r.method))return l;r.method="throw",r.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var o=tryCatch(a,t.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,l;var i=o.arg;return i?i.done?(r[t.resultName]=i.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=void 0),r.delegate=null,l):i:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,l)}function pushTryEntry(t){var r={tryLoc:t[0]};1 in t&&(r.catchLoc=t[1]),2 in t&&(r.finallyLoc=t[2],r.afterLoc=t[3]),this.tryEntries.push(r)}function resetTryEntry(t){var r=t.completion||{};r.type="normal",delete r.arg,t.completion=r}function Context(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(pushTryEntry,this),this.reset(!0)}function values(t){if(t){var r=t[i];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var o=-1,c=function next(){for(;++o=0;--o){var i=this.tryEntries[o],c=i.completion;if("root"===i.tryLoc)return handle("end");if(i.tryLoc<=this.prev){var u=a.call(i,"catchLoc"),l=a.call(i,"finallyLoc");if(u&&l){if(this.prev=0;--o){var i=this.tryEntries[o];if(i.tryLoc<=this.prev&&a.call(i,"finallyLoc")&&this.prev=0;--r){var a=this.tryEntries[r];if(a.finallyLoc===t)return this.complete(a.completion,a.afterLoc),resetTryEntry(a),l}},catch:function _catch(t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc===t){var o=a.completion;if("throw"===o.type){var i=o.arg;resetTryEntry(a)}return i}}throw new Error("illegal catch attempt")},delegateYield:function delegateYield(t,r,a){return this.delegate={iterator:values(t),resultName:r,nextLoc:a},"next"===this.method&&(this.arg=void 0),l}},t}function asyncGeneratorStep(t,r,a,o,i,c,u){try{var l=t[c](u),p=l.value}catch(t){return void a(t)}l.done?r(p):Promise.resolve(p).then(o,i)}function _createForOfIteratorHelper(t,r){var a="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!a){if(Array.isArray(t)||(a=function _unsupportedIterableToArray(t,r){if(!t)return;if("string"==typeof t)return _arrayLikeToArray(t,r);var a=Object.prototype.toString.call(t).slice(8,-1);"Object"===a&&t.constructor&&(a=t.constructor.name);if("Map"===a||"Set"===a)return Array.from(t);if("Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a))return _arrayLikeToArray(t,r)}(t))||r&&t&&"number"==typeof t.length){a&&(t=a);var o=0,i=function F(){};return{s:i,n:function n(){return o>=t.length?{done:!0}:{done:!1,value:t[o++]}},e:function e(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var c,u=!0,l=!1;return{s:function s(){a=a.call(t)},n:function n(){var t=a.next();return u=t.done,t},e:function e(t){l=!0,c=t},f:function f(){try{u||null==a.return||a.return()}finally{if(l)throw c}}}}function _arrayLikeToArray(t,r){(null==r||r>t.length)&&(r=t.length);for(var a=0,o=new Array(r);a4&&void 0!==arguments[4]&&arguments[4],u=arguments.length>5&&void 0!==arguments[5]&&arguments[5],l=[],p=c?new RegExp("^".concat(i.Z.escapeRegex("".concat(r," (")))):new RegExp("^".concat(i.Z.escapeRegex(r),"$")),d=t.items.find((function(t){return o.includes(t.type)&&p.test(t.name)}));return d&&l.push({name:d.name,value:Number(d.system.step.value)*a,selected:u,source:d.name}),l}}]),ItemRulesDSA5}();!function _defineProperty(t,r,a){return r in t?Object.defineProperty(t,r,{value:a,enumerable:!0,configurable:!0,writable:!0}):t[r]=a,t}(c,"children",{})},174:(t,r,a)=>{function _typeof(t){return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},_typeof(t)}function _regeneratorRuntime(){_regeneratorRuntime=function _regeneratorRuntime(){return t};var t={},r=Object.prototype,a=r.hasOwnProperty,o="function"==typeof Symbol?Symbol:{},i=o.iterator||"@@iterator",c=o.asyncIterator||"@@asyncIterator",u=o.toStringTag||"@@toStringTag";function define(t,r,a){return Object.defineProperty(t,r,{value:a,enumerable:!0,configurable:!0,writable:!0}),t[r]}try{define({},"")}catch(t){define=function define(t,r,a){return t[r]=a}}function wrap(t,r,a,o){var i=r&&r.prototype instanceof Generator?r:Generator,c=Object.create(i.prototype),u=new Context(o||[]);return c._invoke=function(t,r,a){var o="suspendedStart";return function(i,c){if("executing"===o)throw new Error("Generator is already running");if("completed"===o){if("throw"===i)throw c;return doneResult()}for(a.method=i,a.arg=c;;){var u=a.delegate;if(u){var p=maybeInvokeDelegate(u,a);if(p){if(p===l)continue;return p}}if("next"===a.method)a.sent=a._sent=a.arg;else if("throw"===a.method){if("suspendedStart"===o)throw o="completed",a.arg;a.dispatchException(a.arg)}else"return"===a.method&&a.abrupt("return",a.arg);o="executing";var d=tryCatch(t,r,a);if("normal"===d.type){if(o=a.done?"completed":"suspendedYield",d.arg===l)continue;return{value:d.arg,done:a.done}}"throw"===d.type&&(o="completed",a.method="throw",a.arg=d.arg)}}}(t,a,u),c}function tryCatch(t,r,a){try{return{type:"normal",arg:t.call(r,a)}}catch(t){return{type:"throw",arg:t}}}t.wrap=wrap;var l={};function Generator(){}function GeneratorFunction(){}function GeneratorFunctionPrototype(){}var p={};define(p,i,(function(){return this}));var d=Object.getPrototypeOf,h=d&&d(d(values([])));h&&h!==r&&a.call(h,i)&&(p=h);var m=GeneratorFunctionPrototype.prototype=Generator.prototype=Object.create(p);function defineIteratorMethods(t){["next","throw","return"].forEach((function(r){define(t,r,(function(t){return this._invoke(r,t)}))}))}function AsyncIterator(t,r){function invoke(o,i,c,u){var l=tryCatch(t[o],t,i);if("throw"!==l.type){var p=l.arg,d=p.value;return d&&"object"==_typeof(d)&&a.call(d,"__await")?r.resolve(d.__await).then((function(t){invoke("next",t,c,u)}),(function(t){invoke("throw",t,c,u)})):r.resolve(d).then((function(t){p.value=t,c(p)}),(function(t){return invoke("throw",t,c,u)}))}u(l.arg)}var o;this._invoke=function(t,a){function callInvokeWithMethodAndArg(){return new r((function(r,o){invoke(t,a,r,o)}))}return o=o?o.then(callInvokeWithMethodAndArg,callInvokeWithMethodAndArg):callInvokeWithMethodAndArg()}}function maybeInvokeDelegate(t,r){var a=t.iterator[r.method];if(void 0===a){if(r.delegate=null,"throw"===r.method){if(t.iterator.return&&(r.method="return",r.arg=void 0,maybeInvokeDelegate(t,r),"throw"===r.method))return l;r.method="throw",r.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var o=tryCatch(a,t.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,l;var i=o.arg;return i?i.done?(r[t.resultName]=i.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=void 0),r.delegate=null,l):i:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,l)}function pushTryEntry(t){var r={tryLoc:t[0]};1 in t&&(r.catchLoc=t[1]),2 in t&&(r.finallyLoc=t[2],r.afterLoc=t[3]),this.tryEntries.push(r)}function resetTryEntry(t){var r=t.completion||{};r.type="normal",delete r.arg,t.completion=r}function Context(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(pushTryEntry,this),this.reset(!0)}function values(t){if(t){var r=t[i];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var o=-1,c=function next(){for(;++o=0;--o){var i=this.tryEntries[o],c=i.completion;if("root"===i.tryLoc)return handle("end");if(i.tryLoc<=this.prev){var u=a.call(i,"catchLoc"),l=a.call(i,"finallyLoc");if(u&&l){if(this.prev=0;--o){var i=this.tryEntries[o];if(i.tryLoc<=this.prev&&a.call(i,"finallyLoc")&&this.prev=0;--r){var a=this.tryEntries[r];if(a.finallyLoc===t)return this.complete(a.completion,a.afterLoc),resetTryEntry(a),l}},catch:function _catch(t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc===t){var o=a.completion;if("throw"===o.type){var i=o.arg;resetTryEntry(a)}return i}}throw new Error("illegal catch attempt")},delegateYield:function delegateYield(t,r,a){return this.delegate={iterator:values(t),resultName:r,nextLoc:a},"next"===this.method&&(this.arg=void 0),l}},t}function asyncGeneratorStep(t,r,a,o,i,c,u){try{var l=t[c](u),p=l.value}catch(t){return void a(t)}l.done?r(p):Promise.resolve(p).then(o,i)}function _asyncToGenerator(t){return function(){var r=this,a=arguments;return new Promise((function(o,i){var c=t.apply(r,a);function _next(t){asyncGeneratorStep(c,o,i,_next,_throw,"next",t)}function _throw(t){asyncGeneratorStep(c,o,i,_next,_throw,"throw",t)}_next(void 0)}))}}function _classCallCheck(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}function _defineProperties(t,r){for(var a=0;au});var o=new WeakMap,i=new WeakMap,c=new WeakMap,u=function(t){!function _inherits(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(r&&r.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),r&&_setPrototypeOf(t,r)}(MeasuredTemplateDSA,MeasuredTemplate);var r,a,u,l,p=_createSuper(MeasuredTemplateDSA);function MeasuredTemplateDSA(){var t;_classCallCheck(this,MeasuredTemplateDSA);for(var r=arguments.length,a=new Array(r),u=0;uCONST.GRID_TYPES.SQUARE?30:15,a=t.shiftKey?r:5,o={direction:this.document.direction+a*Math.sign(t.deltaY)};this.document.updateSource(o),this.refresh()}},{key:"_onConfirmPlacement",value:(u=_asyncToGenerator(_regeneratorRuntime().mark((function _callee2(t){var r;return _regeneratorRuntime().wrap((function _callee2$(a){for(;;)switch(a.prev=a.next){case 0:return a.next=2,this._finishPlacement(t);case 2:r=canvas.grid.getSnappedPosition(this.document.x,this.document.y,2),this.document.updateSource(r),_classPrivateFieldGet(this,c).resolve(canvas.scene.createEmbeddedDocuments("MeasuredTemplate",[this.document.toObject()]));case 5:case"end":return a.stop()}}),_callee2,this)}))),function _onConfirmPlacement(t){return u.apply(this,arguments)})},{key:"_onCancelPlacement",value:(a=_asyncToGenerator(_regeneratorRuntime().mark((function _callee3(t){return _regeneratorRuntime().wrap((function _callee3$(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,this._finishPlacement(t);case 2:_classPrivateFieldGet(this,c).reject();case 3:case"end":return r.stop()}}),_callee3,this)}))),function _onCancelPlacement(t){return a.apply(this,arguments)})}],[{key:"placeTemplateFromChat",value:(r=_asyncToGenerator(_regeneratorRuntime().mark((function _callee4(t){var r,a,o,i,c;return _regeneratorRuntime().wrap((function _callee4$(u){for(;;)switch(u.prev=u.next){case 0:r=$(t.currentTarget).parents(".message").attr("data-message-id"),a=game.messages.get(r),o=a.flags.data.preData.source,i=a.flags.data.postData,(c=this.fromItem(o,i.successLevel))&&c.drawPreview();case 6:case"end":return u.stop()}}),_callee4,this)}))),function placeTemplateFromChat(t){return r.apply(this,arguments)})},{key:"fromItem",value:function fromItem(t,r){var a,o=t.system.target||{},i=game.dsa5.config.areaTargetTypes[o.type];if(!i||!o.value)return null;var c=Number(Roll.safeEval("".concat(o.value).replace(/(qs|ql)/gi,r)))||1,u={t:i,user:game.user.id,distance:c,direction:0,x:0,y:0,fillColor:game.user.color,flags:{dsa5:{origin:t.uuid}}};switch(i){case"cone":u.angle=Number(o.angle)||CONFIG.MeasuredTemplate.defaults.angle;break;case"rect":u.distance=Math.hypot(c,c),u.width=c,u.direction=45;break;case"ray":u.width=o.width&&Number(Roll.safeEval("".concat(o.width).replace(/(qs|ql)/gi,r)))||canvas.dimensions.distance}var l=new this(new(0,CONFIG.MeasuredTemplate.documentClass)(u,{parent:canvas.scene}));return l.item=t,l.actorSheet=(null===(a=t.actor)||void 0===a?void 0:a.sheet)||null,l}}]),MeasuredTemplateDSA}()},586:(t,r,a)=>{a.d(r,{Z:()=>migrateWorld,j:()=>showPatchViewer});var o=a(491),i=a(707);function _typeof(t){return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},_typeof(t)}function _createForOfIteratorHelper(t,r){var a="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!a){if(Array.isArray(t)||(a=function _unsupportedIterableToArray(t,r){if(!t)return;if("string"==typeof t)return _arrayLikeToArray(t,r);var a=Object.prototype.toString.call(t).slice(8,-1);"Object"===a&&t.constructor&&(a=t.constructor.name);if("Map"===a||"Set"===a)return Array.from(t);if("Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a))return _arrayLikeToArray(t,r)}(t))||r&&t&&"number"==typeof t.length){a&&(t=a);var o=0,i=function F(){};return{s:i,n:function n(){return o>=t.length?{done:!0}:{done:!1,value:t[o++]}},e:function e(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var c,u=!0,l=!1;return{s:function s(){a=a.call(t)},n:function n(){var t=a.next();return u=t.done,t},e:function e(t){l=!0,c=t},f:function f(){try{u||null==a.return||a.return()}finally{if(l)throw c}}}}function _arrayLikeToArray(t,r){(null==r||r>t.length)&&(r=t.length);for(var a=0,o=new Array(r);a=0;--o){var i=this.tryEntries[o],c=i.completion;if("root"===i.tryLoc)return handle("end");if(i.tryLoc<=this.prev){var u=a.call(i,"catchLoc"),l=a.call(i,"finallyLoc");if(u&&l){if(this.prev=0;--o){var i=this.tryEntries[o];if(i.tryLoc<=this.prev&&a.call(i,"finallyLoc")&&this.prev=0;--r){var a=this.tryEntries[r];if(a.finallyLoc===t)return this.complete(a.completion,a.afterLoc),resetTryEntry(a),l}},catch:function _catch(t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc===t){var o=a.completion;if("throw"===o.type){var i=o.arg;resetTryEntry(a)}return i}}throw new Error("illegal catch attempt")},delegateYield:function delegateYield(t,r,a){return this.delegate={iterator:values(t),resultName:r,nextLoc:a},"next"===this.method&&(this.arg=void 0),l}},t}function asyncGeneratorStep(t,r,a,o,i,c,u){try{var l=t[c](u),p=l.value}catch(t){return void a(t)}l.done?r(p):Promise.resolve(p).then(o,i)}function _asyncToGenerator(t){return function(){var r=this,a=arguments;return new Promise((function(o,i){var c=t.apply(r,a);function _next(t){asyncGeneratorStep(c,o,i,_next,_throw,"next",t)}function _throw(t){asyncGeneratorStep(c,o,i,_next,_throw,"throw",t)}_next(void 0)}))}}function setupDefaulTokenConfig(){return _setupDefaulTokenConfig.apply(this,arguments)}function _setupDefaulTokenConfig(){return(_setupDefaulTokenConfig=_asyncToGenerator(_regeneratorRuntime().mark((function _callee7(){var t;return _regeneratorRuntime().wrap((function _callee7$(r){for(;;)switch(r.prev=r.next){case 0:if(game.settings.get("dsa5","defaultConfigFinished")){r.next=13;break}return console.log("Configuring default token settings"),(t=game.settings.get("core","defaultToken")).displayName=CONST.TOKEN_DISPLAY_MODES.OWNER_HOVER,t.displayBars=CONST.TOKEN_DISPLAY_MODES.OWNER_HOVER,t.disposition=CONST.TOKEN_DISPOSITIONS.NEUTRAL,t.bar1={attribute:"status.wounds"},r.next=9,game.settings.set("core","defaultToken",t);case 9:return r.next=11,game.settings.set("core","leftClickRelease",!0);case 11:return r.next=13,game.settings.set("dsa5","defaultConfigFinished",!0);case 13:case"end":return r.stop()}}),_callee7)})))).apply(this,arguments)}function migrateDSA(t,r){return _migrateDSA.apply(this,arguments)}function _migrateDSA(){return(_migrateDSA=_asyncToGenerator(_regeneratorRuntime().mark((function _callee8(t,r){return _regeneratorRuntime().wrap((function _callee8$(a){for(;;)switch(a.prev=a.next){case 0:return a.next=2,showPatchViewer();case 2:if(!(t<24)){a.next=5;break}return a.next=5,migratTo24();case 5:return a.next=7,game.settings.set("dsa5","migrationVersion",r);case 7:case"end":return a.stop()}}),_callee8)})))).apply(this,arguments)}function migratTo24(){return _migratTo.apply(this,arguments)}function _migratTo(){return(_migratTo=_asyncToGenerator(_regeneratorRuntime().mark((function _callee9(){var t,r,a,o;return _regeneratorRuntime().wrap((function _callee9$(i){for(;;)switch(i.prev=i.next){case 0:t=_createForOfIteratorHelper(game.actors),i.prev=1,t.s();case 3:if((r=t.n()).done){i.next=11;break}if(a=r.value,!(o=a.effects.filter((function(t){return["inpain","encumbered"].includes(t.getFlag("core","statusId"))}))).length){i.next=9;break}return i.next=9,a.deleteEmbeddedDocuments("ActiveEffect",o.map((function(t){return t.id})));case 9:i.next=3;break;case 11:i.next=16;break;case 13:i.prev=13,i.t0=i.catch(1),t.e(i.t0);case 16:return i.prev=16,t.f(),i.finish(16);case 19:case"end":return i.stop()}}),_callee9,null,[[1,13,16,19]])})))).apply(this,arguments)}function showPatchViewer(){return _showPatchViewer.apply(this,arguments)}function _showPatchViewer(){return(_showPatchViewer=_asyncToGenerator(_regeneratorRuntime().mark((function _callee10(){var t,r;return _regeneratorRuntime().wrap((function _callee10$(a){for(;;)switch(a.prev=a.next){case 0:return a.next=2,fetch("systems/dsa5/lazy/updatenotes.json");case 2:return t=a.sent,a.next=5,t.json();case 5:r=a.sent,new c(r).render(!0);case 8:case"end":return a.stop()}}),_callee10)})))).apply(this,arguments)}function migrateWorld(){Hooks.once("ready",_asyncToGenerator(_regeneratorRuntime().mark((function _callee(){var t,r;return _regeneratorRuntime().wrap((function _callee$(a){for(;;)switch(a.prev=a.next){case 0:if(game.user.isGM){a.next=2;break}return a.abrupt("return");case 2:return a.next=4,setupDefaulTokenConfig();case 4:return a.next=6,game.settings.get("dsa5","migrationVersion");case 6:if(t=a.sent,t<(r=25)){a.next=11;break}return a.abrupt("return");case 11:migrateDSA(t,r);case 12:case"end":return a.stop()}}),_callee)}))))}var c=function(t){!function _inherits(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(r&&r.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),r&&_setPrototypeOf(t,r)}(PatchViewer,Application);var r,a,c,u=_createSuper(PatchViewer);function PatchViewer(t,r){var a;return function _classCallCheck(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}(this,PatchViewer),(a=u.call(this,r)).json=t,a.versionIndex=3,a}return function _createClass(t,r,a){return r&&_defineProperties(t.prototype,r),a&&_defineProperties(t,a),Object.defineProperty(t,"prototype",{writable:!1}),t}(PatchViewer,[{key:"activateListeners",value:function activateListeners(t){var r=this;_get(_getPrototypeOf(PatchViewer.prototype),"activateListeners",this).call(this,t),(0,i.Ee)(t),t.find(".showMore").click((function(a){return r.showMore(t)}))}},{key:"showMore",value:(c=_asyncToGenerator(_regeneratorRuntime().mark((function _callee2(t){var r,a;return _regeneratorRuntime().wrap((function _callee2$(o){for(;;)switch(o.prev=o.next){case 0:if("2.3.0"!=(r=[this.json.notes[this.json.notes.length-this.versionIndex]])[0].version){o.next=4;break}return t.find(".showMore").hide(),o.abrupt("return");case 4:return o.next=6,this.fetchVersions(r);case 6:a=o.sent,t.find(".changelogsection").append(a.changelog[0]),t.find(".newssection").append(a.news[0]),this.versionIndex+=1;case 10:case"end":return o.stop()}}),_callee2,this)}))),function showMore(t){return c.apply(this,arguments)})},{key:"fetchVersions",value:(a=_asyncToGenerator(_regeneratorRuntime().mark((function _callee5(t){var r,a,o;return _regeneratorRuntime().wrap((function _callee5$(i){for(;;)switch(i.prev=i.next){case 0:return r=game.i18n.lang,i.next=3,Promise.all(t.map(function(){var t=_asyncToGenerator(_regeneratorRuntime().mark((function _callee3(t){return _regeneratorRuntime().wrap((function _callee3$(a){for(;;)switch(a.prev=a.next){case 0:return a.next=2,renderTemplate("systems/dsa5/lazy/patchhtml/changelog_".concat(r,"_").concat(t.version,".html"));case 2:return a.abrupt("return",a.sent);case 3:case"end":return a.stop()}}),_callee3)})));return function(r){return t.apply(this,arguments)}}()));case 3:return a=i.sent,i.next=6,Promise.all(t.map(function(){var t=_asyncToGenerator(_regeneratorRuntime().mark((function _callee4(t){return _regeneratorRuntime().wrap((function _callee4$(a){for(;;)switch(a.prev=a.next){case 0:return a.next=2,renderTemplate("systems/dsa5/lazy/patchhtml/news_".concat(r,"_").concat(t.version,".html"));case 2:return a.abrupt("return",a.sent);case 3:case"end":return a.stop()}}),_callee4)})));return function(r){return t.apply(this,arguments)}}()));case 6:return o=i.sent,i.abrupt("return",{changelog:a,news:o});case 8:case"end":return i.stop()}}),_callee5)}))),function fetchVersions(t){return a.apply(this,arguments)})},{key:"getData",value:(r=_asyncToGenerator(_regeneratorRuntime().mark((function _callee6(){var t,r,a,i,c,u,l,p;return _regeneratorRuntime().wrap((function _callee6$(d){for(;;)switch(d.prev=d.next){case 0:return t=this.json.notes[this.json.notes.length-1],r=this.json.default.replace(/VERSION/g,t.version),a="

CHANGELOG

".concat(r,".
Important updates: ").concat(t.text,'

For details or proposals visit our wiki page at Github or show the Full Changelog in Foundry. Have fun.

'),d.next=5,ChatMessage.create(o.Z.chatDataSetup(a,"roll"));case 5:return i=game.i18n.lang,d.next=8,this.fetchVersions([t]);case 8:return c=d.sent,u=[this.json.notes[this.json.notes.length-2]],d.next=12,this.fetchVersions(u);case 12:return l=d.sent,d.next=15,renderTemplate("systems/dsa5/lazy/patchhtml/modules_".concat(i,".html"));case 15:return p=d.sent,d.abrupt("return",{patchName:r,changelog:c.changelog[0],news:c.news[0],prevVersions:u,prevChangeLogs:l.changelog,prevNews:l.news,modules:p});case 17:case"end":return d.stop()}}),_callee6,this)}))),function getData(){return r.apply(this,arguments)})}],[{key:"defaultOptions",get:function get(){var t=_get(_getPrototypeOf(PatchViewer),"defaultOptions",this);return t.tabs=[{navSelector:".tabs",contentSelector:".content",initial:"newcontent"}],mergeObject(t,{classes:t.classes.concat(["dsa5","largeDialog","patches"]),width:740,height:740,title:"Changelog"}),t.template="systems/dsa5/templates/system/patchviewer.html",t.resizable=!0,t}}]),PatchViewer}()},604:(t,r,a)=>{a.d(r,{Z:()=>i});var o=a(491);a(122),a(803);function _typeof(t){return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},_typeof(t)}function _regeneratorRuntime(){_regeneratorRuntime=function _regeneratorRuntime(){return t};var t={},r=Object.prototype,a=r.hasOwnProperty,o="function"==typeof Symbol?Symbol:{},i=o.iterator||"@@iterator",c=o.asyncIterator||"@@asyncIterator",u=o.toStringTag||"@@toStringTag";function define(t,r,a){return Object.defineProperty(t,r,{value:a,enumerable:!0,configurable:!0,writable:!0}),t[r]}try{define({},"")}catch(t){define=function define(t,r,a){return t[r]=a}}function wrap(t,r,a,o){var i=r&&r.prototype instanceof Generator?r:Generator,c=Object.create(i.prototype),u=new Context(o||[]);return c._invoke=function(t,r,a){var o="suspendedStart";return function(i,c){if("executing"===o)throw new Error("Generator is already running");if("completed"===o){if("throw"===i)throw c;return doneResult()}for(a.method=i,a.arg=c;;){var u=a.delegate;if(u){var p=maybeInvokeDelegate(u,a);if(p){if(p===l)continue;return p}}if("next"===a.method)a.sent=a._sent=a.arg;else if("throw"===a.method){if("suspendedStart"===o)throw o="completed",a.arg;a.dispatchException(a.arg)}else"return"===a.method&&a.abrupt("return",a.arg);o="executing";var d=tryCatch(t,r,a);if("normal"===d.type){if(o=a.done?"completed":"suspendedYield",d.arg===l)continue;return{value:d.arg,done:a.done}}"throw"===d.type&&(o="completed",a.method="throw",a.arg=d.arg)}}}(t,a,u),c}function tryCatch(t,r,a){try{return{type:"normal",arg:t.call(r,a)}}catch(t){return{type:"throw",arg:t}}}t.wrap=wrap;var l={};function Generator(){}function GeneratorFunction(){}function GeneratorFunctionPrototype(){}var p={};define(p,i,(function(){return this}));var d=Object.getPrototypeOf,h=d&&d(d(values([])));h&&h!==r&&a.call(h,i)&&(p=h);var m=GeneratorFunctionPrototype.prototype=Generator.prototype=Object.create(p);function defineIteratorMethods(t){["next","throw","return"].forEach((function(r){define(t,r,(function(t){return this._invoke(r,t)}))}))}function AsyncIterator(t,r){function invoke(o,i,c,u){var l=tryCatch(t[o],t,i);if("throw"!==l.type){var p=l.arg,d=p.value;return d&&"object"==_typeof(d)&&a.call(d,"__await")?r.resolve(d.__await).then((function(t){invoke("next",t,c,u)}),(function(t){invoke("throw",t,c,u)})):r.resolve(d).then((function(t){p.value=t,c(p)}),(function(t){return invoke("throw",t,c,u)}))}u(l.arg)}var o;this._invoke=function(t,a){function callInvokeWithMethodAndArg(){return new r((function(r,o){invoke(t,a,r,o)}))}return o=o?o.then(callInvokeWithMethodAndArg,callInvokeWithMethodAndArg):callInvokeWithMethodAndArg()}}function maybeInvokeDelegate(t,r){var a=t.iterator[r.method];if(void 0===a){if(r.delegate=null,"throw"===r.method){if(t.iterator.return&&(r.method="return",r.arg=void 0,maybeInvokeDelegate(t,r),"throw"===r.method))return l;r.method="throw",r.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var o=tryCatch(a,t.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,l;var i=o.arg;return i?i.done?(r[t.resultName]=i.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=void 0),r.delegate=null,l):i:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,l)}function pushTryEntry(t){var r={tryLoc:t[0]};1 in t&&(r.catchLoc=t[1]),2 in t&&(r.finallyLoc=t[2],r.afterLoc=t[3]),this.tryEntries.push(r)}function resetTryEntry(t){var r=t.completion||{};r.type="normal",delete r.arg,t.completion=r}function Context(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(pushTryEntry,this),this.reset(!0)}function values(t){if(t){var r=t[i];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var o=-1,c=function next(){for(;++o=0;--o){var i=this.tryEntries[o],c=i.completion;if("root"===i.tryLoc)return handle("end");if(i.tryLoc<=this.prev){var u=a.call(i,"catchLoc"),l=a.call(i,"finallyLoc");if(u&&l){if(this.prev=0;--o){var i=this.tryEntries[o];if(i.tryLoc<=this.prev&&a.call(i,"finallyLoc")&&this.prev=0;--r){var a=this.tryEntries[r];if(a.finallyLoc===t)return this.complete(a.completion,a.afterLoc),resetTryEntry(a),l}},catch:function _catch(t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc===t){var o=a.completion;if("throw"===o.type){var i=o.arg;resetTryEntry(a)}return i}}throw new Error("illegal catch attempt")},delegateYield:function delegateYield(t,r,a){return this.delegate={iterator:values(t),resultName:r,nextLoc:a},"next"===this.method&&(this.arg=void 0),l}},t}function _createForOfIteratorHelper(t,r){var a="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!a){if(Array.isArray(t)||(a=function _unsupportedIterableToArray(t,r){if(!t)return;if("string"==typeof t)return _arrayLikeToArray(t,r);var a=Object.prototype.toString.call(t).slice(8,-1);"Object"===a&&t.constructor&&(a=t.constructor.name);if("Map"===a||"Set"===a)return Array.from(t);if("Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a))return _arrayLikeToArray(t,r)}(t))||r&&t&&"number"==typeof t.length){a&&(t=a);var o=0,i=function F(){};return{s:i,n:function n(){return o>=t.length?{done:!0}:{done:!1,value:t[o++]}},e:function e(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var c,u=!0,l=!1;return{s:function s(){a=a.call(t)},n:function n(){var t=a.next();return u=t.done,t},e:function e(t){l=!0,c=t},f:function f(){try{u||null==a.return||a.return()}finally{if(l)throw c}}}}function _arrayLikeToArray(t,r){(null==r||r>t.length)&&(r=t.length);for(var a=0,o=new Array(r);a2&&void 0!==m[2]?m[2]:{},o=game.packs.get(t),y.next=4,o.getDocuments({name:r});case 4:if((i=y.sent).length){y.next=26;break}c=_createForOfIteratorHelper(game.packs.filter((function(t){return"Macro"==t.documentName&&/\(internal\)/.test(t.metadata.label)}))),y.prev=7,c.s();case 9:if((u=c.n()).done){y.next=18;break}return l=u.value,y.next=13,l.getDocuments({name:r});case 13:if(!(i=y.sent).length){y.next=16;break}return y.abrupt("break",18);case 16:y.next=9;break;case 18:y.next=23;break;case 20:y.prev=20,y.t0=y.catch(7),c.e(y.t0);case 23:return y.prev=23,c.f(),y.finish(23);case 26:if(p={},!i.length){y.next=43;break}return d="(async () => {".concat(i[0].command,"})()"),h=Function("args","actor","item",d),y.prev=30,a.result=p,y.next=34,h.call(this,a,this.item.actor,this.item);case 34:y.next=41;break;case 36:y.prev=36,y.t1=y.catch(30),ui.notifications.error("There was an error in your macro syntax. See the console (F12) for details"),console.error(y.t1),p.error=!0;case 41:y.next=44;break;case 43:ui.notifications.error(game.i18n.format("DSAError.macroNotFound",{name:r}));case 44:return y.abrupt("return",p);case 45:case"end":return y.stop()}}),_callee,this,[[7,20,23,26],[30,36]])}))),function callMacro(t,r){return p.apply(this,arguments)})},{key:"executeOnUseEffect",value:(l=_asyncToGenerator(_regeneratorRuntime().mark((function _callee2(){var t,r,a;return _regeneratorRuntime().wrap((function _callee2$(o){for(;;)switch(o.prev=o.next){case 0:if(game.user.can("MACRO_SCRIPT")){o.next=2;break}return o.abrupt("return",ui.notifications.warn("You are not allowed to use JavaScript macros."));case 2:if(this.item.actor){o.next=4;break}return o.abrupt("return");case 4:return t=OnUseEffect.getOnUseEffect(this.item),r="(async () => {".concat(t,"})()"),a=Function("item","actor",r),o.prev=7,o.next=10,a.call(this,this.item,this.item.actor);case 10:o.next=17;break;case 12:o.prev=12,o.t0=o.catch(7),ui.notifications.error("There was an error in your macro syntax. See the console (F12) for details"),console.error(o.t0),console.warn(o.t0.stack);case 17:case"end":return o.stop()}}),_callee2,this,[[7,12]])}))),function executeOnUseEffect(){return l.apply(this,arguments)})},{key:"automatedAnimation",value:(u=_asyncToGenerator(_regeneratorRuntime().mark((function _callee3(t){var r=arguments;return _regeneratorRuntime().wrap((function _callee3$(t){for(;;)switch(t.prev=t.next){case 0:r.length>1&&void 0!==r[1]&&r[1],o.Z.moduleEnabled("autoanimations")&&console.warn("Animations for on use effects not enabled yet");case 2:case"end":return t.stop()}}),_callee3)}))),function automatedAnimation(t){return u.apply(this,arguments)})},{key:"effectDummy",value:function effectDummy(t,r,a){return{name:t,icon:"icons/svg/aura.svg",changes:r,duration:a,flags:{dsa5:{value:null,editable:!0,customizable:!0,description:t,custom:!0}}}}},{key:"socketedConditionAddActor",value:(c=_asyncToGenerator(_regeneratorRuntime().mark((function _callee4(t,r){var a,o,i,c,u,l;return _regeneratorRuntime().wrap((function _callee4$(p){for(;;)switch(p.prev=p.next){case 0:if(!game.user.isGM){p.next=31;break}(a="string"==typeof r)&&((r=duplicate(CONFIG.statusEffects.find((function(t){return t.id==r})))).name=game.i18n.localize(r.name)),o=[],i=_createForOfIteratorHelper(t),p.prev=5,i.s();case 7:if((c=i.n()).done){p.next=19;break}if(u=c.value,!a){p.next=14;break}return p.next=12,u.addCondition(r,1,!1,!1);case 12:p.next=16;break;case 14:return p.next=16,u.addCondition(r);case 16:o.push(u.name);case 17:p.next=7;break;case 19:p.next=24;break;case 21:p.prev=21,p.t0=p.catch(5),i.e(p.t0);case 24:return p.prev=24,i.f(),p.finish(24);case 27:return p.next=29,this.createInfoMessage(r,o);case 29:p.next=33;break;case 31:l={id:this.item.uuid,data:r,actors:t.map((function(t){return t.id}))},game.socket.emit("system.dsa5",{type:"socketedConditionAddActor",payload:l});case 33:case"end":return p.stop()}}),_callee4,this,[[5,21,24,27]])}))),function socketedConditionAddActor(t,r){return c.apply(this,arguments)})},{key:"createInfoMessage",value:(i=_asyncToGenerator(_regeneratorRuntime().mark((function _callee5(t,r){var a,i,c,u=arguments;return _regeneratorRuntime().wrap((function _callee5$(l){for(;;)switch(l.prev=l.next){case 0:if(a=!(u.length>2&&void 0!==u[2])||u[2],!r.length){l.next=6;break}return i=a?"ActiveEffects.appliedEffect":"ActiveEffects.removedEffect",c=game.i18n.format(i,{source:t.name,target:r.join(", ")}),l.next=6,ChatMessage.create(o.Z.chatDataSetup(c));case 6:case"end":return l.stop()}}),_callee5)}))),function createInfoMessage(t,r){return i.apply(this,arguments)})},{key:"socketedRemoveCondition",value:(a=_asyncToGenerator(_regeneratorRuntime().mark((function _callee6(t,r){var a,o,i,c,u,l,p,d,h=arguments;return _regeneratorRuntime().wrap((function _callee6$(m){for(;;)switch(m.prev=m.next){case 0:if(a=h.length>2&&void 0!==h[2]?h[2]:1,!game.user.isGM){m.next=29;break}o=[],i=_createForOfIteratorHelper(t),m.prev=4,i.s();case 6:if((c=i.n()).done){m.next=15;break}if(u=c.value,!(l=canvas.tokens.get(u)).actor){m.next=13;break}return m.next=12,l.actor.removeCondition(r,a,!1);case 12:o.push(l.name);case 13:m.next=6;break;case 15:m.next=20;break;case 17:m.prev=17,m.t0=m.catch(4),i.e(m.t0);case 20:return m.prev=20,i.f(),m.finish(20);case 23:return(p=CONFIG.statusEffects.find((function(t){return t.id==r}))).name=game.i18n.localize(p.name),m.next=27,this.createInfoMessage(p,o,!1);case 27:m.next=31;break;case 29:d={id:this.item.uuid,coreId:r,targets:t},game.socket.emit("system.dsa5",{type:"socketedRemoveCondition",payload:d});case 31:case"end":return m.stop()}}),_callee6,this,[[4,17,20,23]])}))),function socketedRemoveCondition(t,r){return a.apply(this,arguments)})},{key:"socketedActorTransformation",value:(r=_asyncToGenerator(_regeneratorRuntime().mark((function _callee7(t,r){var a,o,i,c,u;return _regeneratorRuntime().wrap((function _callee7$(l){for(;;)switch(l.prev=l.next){case 0:if(!game.user.isGM){l.next=22;break}a=_createForOfIteratorHelper(t),l.prev=2,a.s();case 4:if((o=a.n()).done){l.next=12;break}if(i=o.value,!(c=canvas.tokens.get(i)).actor){l.next=10;break}return l.next=10,c.actor.update(r);case 10:l.next=4;break;case 12:l.next=17;break;case 14:l.prev=14,l.t0=l.catch(2),a.e(l.t0);case 17:return l.prev=17,a.f(),l.finish(17);case 20:l.next=24;break;case 22:u={id:this.item.uuid,targets:t,update:r},game.socket.emit("system.dsa5",{type:"socketedActorTransformation",payload:u});case 24:case"end":return l.stop()}}),_callee7,this,[[2,14,17,20]])}))),function socketedActorTransformation(t,a){return r.apply(this,arguments)})},{key:"socketedConditionAdd",value:(t=_asyncToGenerator(_regeneratorRuntime().mark((function _callee8(t,r){var a,o,i,c,u,l,p;return _regeneratorRuntime().wrap((function _callee8$(d){for(;;)switch(d.prev=d.next){case 0:if(!game.user.isGM){d.next=33;break}(a="string"==typeof r)&&((r=duplicate(CONFIG.statusEffects.find((function(t){return t.id==r})))).name=game.i18n.localize(r.name)),o=[],i=_createForOfIteratorHelper(t),d.prev=5,i.s();case 7:if((c=i.n()).done){d.next=21;break}if(u=c.value,!(l=canvas.tokens.get(u)).actor){d.next=19;break}if(!a){d.next=16;break}return d.next=14,l.actor.addCondition(r,1,!1,!1);case 14:d.next=18;break;case 16:return d.next=18,l.actor.addCondition(r);case 18:o.push(l.name);case 19:d.next=7;break;case 21:d.next=26;break;case 23:d.prev=23,d.t0=d.catch(5),i.e(d.t0);case 26:return d.prev=26,i.f(),d.finish(26);case 29:return d.next=31,this.createInfoMessage(r,o);case 31:d.next=35;break;case 33:p={id:this.item.uuid,data:r,targets:t},game.socket.emit("system.dsa5",{type:"socketedConditionAdd",payload:p});case 35:case"end":return d.stop()}}),_callee8,this,[[5,23,26,29]])}))),function socketedConditionAdd(r,a){return t.apply(this,arguments)})}],[{key:"getOnUseEffect",value:function getOnUseEffect(t){return t.getFlag("dsa5","onUseEffect")}}]),OnUseEffect}()},600:(t,r,a)=>{a.d(r,{Z:()=>h});var o=a(491),i=a(562),c=a(118),u=a(369),l=a(702),p=a(61),d=a(839);function _typeof(t){return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},_typeof(t)}function _createForOfIteratorHelper(t,r){var a="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!a){if(Array.isArray(t)||(a=_unsupportedIterableToArray(t))||r&&t&&"number"==typeof t.length){a&&(t=a);var o=0,i=function F(){};return{s:i,n:function n(){return o>=t.length?{done:!0}:{done:!1,value:t[o++]}},e:function e(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var c,u=!0,l=!1;return{s:function s(){a=a.call(t)},n:function n(){var t=a.next();return u=t.done,t},e:function e(t){l=!0,c=t},f:function f(){try{u||null==a.return||a.return()}finally{if(l)throw c}}}}function _defineProperty(t,r,a){return r in t?Object.defineProperty(t,r,{value:a,enumerable:!0,configurable:!0,writable:!0}):t[r]=a,t}function _toConsumableArray(t){return function _arrayWithoutHoles(t){if(Array.isArray(t))return _arrayLikeToArray(t)}(t)||function _iterableToArray(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||_unsupportedIterableToArray(t)||function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function _unsupportedIterableToArray(t,r){if(t){if("string"==typeof t)return _arrayLikeToArray(t,r);var a=Object.prototype.toString.call(t).slice(8,-1);return"Object"===a&&t.constructor&&(a=t.constructor.name),"Map"===a||"Set"===a?Array.from(t):"Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a)?_arrayLikeToArray(t,r):void 0}}function _arrayLikeToArray(t,r){(null==r||r>t.length)&&(r=t.length);for(var a=0,o=new Array(r);a=0;--o){var i=this.tryEntries[o],c=i.completion;if("root"===i.tryLoc)return handle("end");if(i.tryLoc<=this.prev){var u=a.call(i,"catchLoc"),l=a.call(i,"finallyLoc");if(u&&l){if(this.prev=0;--o){var i=this.tryEntries[o];if(i.tryLoc<=this.prev&&a.call(i,"finallyLoc")&&this.prev=0;--r){var a=this.tryEntries[r];if(a.finallyLoc===t)return this.complete(a.completion,a.afterLoc),resetTryEntry(a),l}},catch:function _catch(t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc===t){var o=a.completion;if("throw"===o.type){var i=o.arg;resetTryEntry(a)}return i}}throw new Error("illegal catch attempt")},delegateYield:function delegateYield(t,r,a){return this.delegate={iterator:values(t),resultName:r,nextLoc:a},"next"===this.method&&(this.arg=void 0),l}},t}function asyncGeneratorStep(t,r,a,o,i,c,u){try{var l=t[c](u),p=l.value}catch(t){return void a(t)}l.done?r(p):Promise.resolve(p).then(o,i)}function _asyncToGenerator(t){return function(){var r=this,a=arguments;return new Promise((function(o,i){var c=t.apply(r,a);function _next(t){asyncGeneratorStep(c,o,i,_next,_throw,"next",t)}function _throw(t){asyncGeneratorStep(c,o,i,_next,_throw,"throw",t)}_next(void 0)}))}}function _defineProperties(t,r){for(var a=0;a'):'')}},{key:"createOpposedTest",value:(S=_asyncToGenerator(_regeneratorRuntime().mark((function _callee6(t,r,a,o){var i,c,u,l;return _regeneratorRuntime().wrap((function _callee6$(o){for(;;)switch(o.prev=o.next){case 0:i=r.speaker.token?canvas.tokens.get(r.speaker.token).document:t.prototypeToken,a.successLevel>0?(c=r.flags.data.preData.attackOfOpportunity,u=c?"":'
"),l=[],game.user.targets.forEach(function(){var t=_asyncToGenerator(_regeneratorRuntime().mark((function _callee4(t){var a,o,p,d,h;return _regeneratorRuntime().wrap((function _callee4$(m){for(;;)switch(m.prev=m.next){case 0:if(!t.actor){m.next=17;break}return a="".concat(OpposedDsa5.opposeMessage(i,t,!1)," ").concat(u),m.next=4,ChatMessage.create(_defineProperty({user:game.user.id,content:a,speaker:r.speaker},"flags.unopposeData",{attackMessageId:r.id,targetSpeaker:{scene:t.scene.id,token:t.id,alias:t.document.name}}));case 4:if(o=m.sent,p={speaker:r.speaker,messageId:r.id,startMessageId:o.id},game.user.isGM){m.next=10;break}game.socket.emit("system.dsa5",{type:"target",payload:{target:t.id,scene:(null===(d=t.scene)||void 0===d?void 0:d.id)||(null===(h=canvas.scene)||void 0===h?void 0:h.id),opposeFlag:p}}),m.next=12;break;case 10:return m.next=12,t.actor.update({"flags.oppose":p});case 12:if(l.push(o.id),!c){m.next=16;break}return m.next=16,OpposedDsa5.resolveUndefended(o,game.i18n.localize("OPPOSED.attackOfOpportunity"));case 16:Hooks.call("DSAOpposedRollStart",t);case 17:case"end":return m.stop()}}),_callee4)})));return function(r){return t.apply(this,arguments)}}()),r.flags.data.startMessagesList=l):game.user.targets.forEach(function(){var t=_asyncToGenerator(_regeneratorRuntime().mark((function _callee5(t){return _regeneratorRuntime().wrap((function _callee5$(a){for(;;)switch(a.prev=a.next){case 0:if(!t.actor){a.next=3;break}return a.next=3,ChatMessage.create({user:game.user.id,content:OpposedDsa5.opposeMessage(i,t,!0),speaker:r.speaker});case 3:case"end":return a.stop()}}),_callee5)})));return function(r){return t.apply(this,arguments)}}());case 2:case"end":return o.stop()}}),_callee6)}))),function createOpposedTest(t,r,a,o){return S.apply(this,arguments)})},{key:"opposeMessage",value:function opposeMessage(t,r,a){return'
\n '.concat(t.name," ").concat(game.i18n.localize("ROLL.Targeting")," ").concat(r.document.name," ").concat(a?game.i18n.localize("ROLL.failed"):"",'\n
\n
\n
').concat(OpposedDsa5.videoOrImgTag(t.texture.src),'
\n
').concat(OpposedDsa5.videoOrImgTag(r.document.texture.src),"
\n
\n ")}},{key:"changeStartMessage",value:(x=_asyncToGenerator(_regeneratorRuntime().mark((function _callee7(t){var r,a,o,i,c;return _regeneratorRuntime().wrap((function _callee7$(u){for(;;)switch(u.prev=u.next){case 0:r=_createForOfIteratorHelper(t.flags.data.startMessagesList),u.prev=1,r.s();case 3:if((a=r.n()).done){u.next=12;break}return o=a.value,i=game.messages.get(o),c=i.flags.unopposeData,game.socket.emit("system.dsa5",{type:"target",payload:{target:c.targetSpeaker.token,scene:canvas.scene.id,opposeFlag:{speaker:t.speaker,messageId:t.id,startMessageId:i.id}}}),u.next=10,i.update({"flags.unopposeData.attackMessageId":t.id});case 10:u.next=3;break;case 12:u.next=17;break;case 14:u.prev=14,u.t0=u.catch(1),r.e(u.t0);case 17:return u.prev=17,r.f(),u.finish(17);case 20:case"end":return u.stop()}}),_callee7,null,[[1,14,17,20]])}))),function changeStartMessage(t){return x.apply(this,arguments)})},{key:"resolveFinalMessage",value:function resolveFinalMessage(t){var r,a;if(t.flags.data.defenderMessage){var o,i=_createForOfIteratorHelper(t.flags.data.defenderMessage);try{for(i.s();!(o=i.n()).done;){var c=o.value;r=OpposedDsa5.getMessageDude(t);var u=game.messages.get(c);a=OpposedDsa5.getMessageDude(u),this.completeOpposedProcess(r,a,{blind:t.blind,whisper:t.whisper})}}catch(t){i.e(t)}finally{i.f()}}else{a=OpposedDsa5.getMessageDude(t);var l=game.messages.get(t.flags.data.attackerMessage);r=OpposedDsa5.getMessageDude(l),this.completeOpposedProcess(r,a,{blind:t.blind,whisper:t.whisper})}}},{key:"getMessageDude",value:function getMessageDude(t){var r,a={speaker:t.speaker,testResult:mergeObject(t.flags.data.postData,{source:t.flags.data.preData.source}),img:o.Z.getSpeaker(t.speaker).img,messageId:t.id};return a.testResult.ammo&&(r=a.testResult.source.effects).push.apply(r,_toConsumableArray(a.testResult.ammo.effects)),a}},{key:"showDamage",value:(w=_asyncToGenerator(_regeneratorRuntime().mark((function _callee8(t){var r,a=arguments;return _regeneratorRuntime().wrap((function _callee8$(o){for(;;)switch(o.prev=o.next){case 0:if(r=a.length>1&&void 0!==a[1]&&a[1],!game.user.isGM){o.next=8;break}if(r&&t.flags.data.hideDamage||!t.flags.data.postData.damageRoll){o.next=6;break}return o.next=5,t.update({content:t.content.replace('data-hide-damage="'.concat(!r,'"'),'data-hide-damage="'.concat(r,'"')),"flags.data.hideDamage":r});case 5:r||i.Z._addRollDiceSoNice(t.flags.data.preData,Roll.fromData(t.flags.data.postData.damageRoll),game.dsa5.apps.DiceSoNiceCustomization.getAttributeConfiguration("damage"));case 6:o.next=9;break;case 8:game.socket.emit("system.dsa5",{type:"showDamage",payload:{id:t.id,hide:r}});case 9:case"end":return o.stop()}}),_callee8)}))),function showDamage(t){return w.apply(this,arguments)})},{key:"playAutomatedJBA2",value:(k=_asyncToGenerator(_regeneratorRuntime().mark((function _callee9(t,r,a){var i,c,u,l,p,h,m,y,g,v,_,b,k,w,x,S,T,A;return _regeneratorRuntime().wrap((function _callee9$(O){for(;;)switch(O.prev=O.next){case 0:if(!o.Z.moduleEnabled("autoanimations")){O.next=34;break}if(i=o.Z.getSpeaker(t.speaker).getActiveTokens()[0],c=o.Z.getSpeaker(r.speaker).getActiveTokens()[0],i&&i.actor&&c&&c.actor){O.next=5;break}return O.abrupt("return");case 5:if((u=i.actor.items.get(t.testResult.source._id))||(u=new d.Z(t.testResult.source,{temporary:!0})),u){O.next=9;break}return O.abrupt("return");case 9:for(u=u.toObject(),l=[c],p="attacker"==a.winner,h=p?l:[],m=t.testResult.successLevel>1&&p,y=t.testResult.successLevel<1&&!p,g=r.testResult.successLevel>1&&!p,v=r.testResult.successLevel<1&&p,_=[],b=[],m?b.push(game.i18n.localize("CriticalSuccess")):y?b.push(game.i18n.localize("CriticalFailure")):g?b.push("".concat(game.i18n.localize("CHAR.PARRY")," ").concat(game.i18n.localize("CriticalSuccess"))):v&&b.push("".concat(game.i18n.localize("CHAR.PARRY")," ").concat(game.i18n.localize("CriticalFailure"))),p||b.push(game.i18n.localize("CHAR.PARRY")),k=0,w=b;k0)){u.next=13;break}if((a=o.Z.getSpeaker(r.postData.speaker).getActiveTokens()[0])&&a.actor){u.next=9;break}return u.abrupt("return");case 9:i=Array.from(game.user.targets),c=a.actor.items.get(r.preData.source._id),i.length||(i=[a]),AutomatedAnimations.playAnimation(a,c,{targets:i});case 13:case"end":return u.stop()}}),_callee10)}))),function showSpellWithoutTarget(t){return b.apply(this,arguments)})},{key:"clearOpposed",value:(_=_asyncToGenerator(_regeneratorRuntime().mark((function _callee11(t){return _regeneratorRuntime().wrap((function _callee11$(r){for(;;)switch(r.prev=r.next){case 0:if(!game.user.isGM){r.next=5;break}return r.next=3,t.update(_defineProperty({},"flags.-=oppose",null));case 3:r.next=6;break;case 5:game.socket.emit("system.dsa5",{type:"clearOpposed",payload:{actorId:t.id}});case 6:case"end":return r.stop()}}),_callee11)}))),function clearOpposed(t){return _.apply(this,arguments)})},{key:"_handleReaction",value:(v=_asyncToGenerator(_regeneratorRuntime().mark((function _callee12(t){var r,a,o,i;return _regeneratorRuntime().wrap((function _callee12$(u){for(;;)switch(u.prev=u.next){case 0:r=$(t.currentTarget).parents(".message").attr("data-message-id"),a=game.messages.get(r),o=game.messages.get(a.flags.unopposeData.attackMessageId),i=o.flags.data.preData.source,u.t0=i.type,u.next="skill"===u.t0?7:9;break;case 7:return c.$G.showDialog(a),u.abrupt("break",10);case 9:c.MN.showDialog(a);case 10:case"end":return u.stop()}}),_callee12)}))),function _handleReaction(t){return v.apply(this,arguments)})},{key:"chatListeners",value:(g=_asyncToGenerator(_regeneratorRuntime().mark((function _callee13(t){var r=this;return _regeneratorRuntime().wrap((function _callee13$(a){for(;;)switch(a.prev=a.next){case 0:t.on("click",".unopposed-button",(function(t){t.preventDefault(),r._handleReaction(t)}));case 1:case"end":return a.stop()}}),_callee13)}))),function chatListeners(t){return g.apply(this,arguments)})},{key:"hideReactionButton",value:(y=_asyncToGenerator(_regeneratorRuntime().mark((function _callee14(t){var r,a;return _regeneratorRuntime().wrap((function _callee14$(o){for(;;)switch(o.prev=o.next){case 0:if(!t){o.next=11;break}if(!game.user.isGM){o.next=10;break}return r=game.messages.get(t),(a=$(r.content)).find("button.unopposed-button").remove(),a=$("
").append(a),o.next=8,r.update({content:a.html()});case 8:o.next=11;break;case 10:game.socket.emit("system.dsa5",{type:"hideQueryButton",payload:{id:t}});case 11:case"end":return o.stop()}}),_callee14)}))),function hideReactionButton(t){return y.apply(this,arguments)})},{key:"completeOpposedProcess",value:(m=_asyncToGenerator(_regeneratorRuntime().mark((function _callee15(t,r,a){var o;return _regeneratorRuntime().wrap((function _callee15$(i){for(;;)switch(i.prev=i.next){case 0:return i.next=2,this.evaluateOpposedTest(t.testResult,r.testResult,a);case 2:return o=i.sent,this.formatOpposedResult(o,t.speaker,r.speaker),this.rerenderMessagesWithModifiers(o,t,r),Hooks.call("finishOpposedTest",t,r,o,a),i.next=8,this.finishOpposedTestHookAsync(t,r,o,a);case 8:return this.playAutomatedJBA2(t,r,o),i.next=11,this.renderOpposedResult(o,a);case 11:return i.next=13,this.hideReactionButton(a.startMessageId);case 13:return i.abrupt("return",o);case 14:case"end":return i.stop()}}),_callee15,this)}))),function completeOpposedProcess(t,r,a){return m.apply(this,arguments)})},{key:"finishOpposedTestHookAsync",value:(h=_asyncToGenerator(_regeneratorRuntime().mark((function _callee16(t,r,a,o){return _regeneratorRuntime().wrap((function _callee16$(t){for(;;)switch(t.prev=t.next){case 0:case"end":return t.stop()}}),_callee16)}))),function finishOpposedTestHookAsync(t,r,a,o){return h.apply(this,arguments)})},{key:"evaluateOpposedTest",value:(a=_asyncToGenerator(_regeneratorRuntime().mark((function _callee17(t,r){var a,o,i=arguments;return _regeneratorRuntime().wrap((function _callee17$(c){for(;;)switch(c.prev=c.next){case 0:if(a=i.length>2&&void 0!==i[2]?i[2]:{},(o={}).other=[],a.additionalInfo&&o.other.push(a.additionalInfo),o.winner="attacker",["weapon","spell","liturgy","ceremony","ritual","combatskill"].includes(t.rollType)&&null==r.successLevel&&(r.successLevel=-5),null==r.successLevel){c.next=16;break}c.t0=t.rollType,c.next="combatskill"===c.t0||"talent"===c.t0?10:"ceremony"===c.t0||"ritual"===c.t0||"spell"===c.t0||"liturgy"===c.t0||"weapon"===c.t0?12:14;break;case 10:return this._evaluateTalentOpposedRoll(t,r,o,a),c.abrupt("break",16);case 12:return this._evaluateWeaponOpposedRoll(t,r,o,a),c.abrupt("break",16);case 14:ui.notifications.error("Can not oppose "+t.rollType),console.warn("Can not oppose "+t.rollType);case 16:return c.abrupt("return",o);case 17:case"end":return c.stop()}}),_callee17,this)}))),function evaluateOpposedTest(t,r){return a.apply(this,arguments)})},{key:"_evaluateWeaponOpposedRoll",value:function _evaluateWeaponOpposedRoll(t,r,a){var o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};if(t.successLevel>0&&r.successLevel<0){var i=this._calculateOpposedDamage(t,r,o);if(i.armorDamaged.damaged&&i.armorDamaged.ids.length){var c=i.armorDamaged.ids.join(";");a.other.push('
"))}r.counterAttack&&(i.damage+=2,i.sum=i.damage-i.armor,i.tooltip=game.i18n.localize("LocalizedIDs.counterAttack")+" 2"),i.messages.length&&(i.tooltip||(i.tooltip=""),i.tooltip+=" ".concat(i.messages.join("
"))),a.winner="attacker";var u=[0!=i.armorMod?"".concat(i.armorMod+" "+game.i18n.localize("Modifier")):"",1!=i.armorMultiplier?"*"+i.armorMultiplier+" "+game.i18n.localize("Modifier"):"",0!=i.spellArmor?"".concat(i.spellArmor," ").concat(game.i18n.localize("spellArmor")):"",0!=i.liturgyArmor?"".concat(i.liturgyArmor," ").concat(game.i18n.localize("liturgyArmor")):""].join(""),l="".concat(game.i18n.localize("damage"),": ").concat(i.damage,' - ').concat(i.armor,' = ').concat(i.sum);a.damage={description:l,value:i.sum,sp:i.damage}}else a.winner="defender"}},{key:"_calculateOpposedDamage",value:function _calculateOpposedDamage(t,r){var a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i=o.Z.getSpeaker(r.speaker),c=[],d=t.damage,h=game.i18n.localize("LocalizedIDs.immuneToCrit");t.doubleDamage&&i.items.find((function(t){return t.name==h&&"trait"==t.type}))&&(d=Math.floor(d/t.doubleDamage),c.push(h)),a.origin=t.source,a.damage=d;var m,y=p.Z.applyRollTransformation(i,a,5).options.damage,g=u.Z.armorValue(i,a),v=g.wornArmor,_=g.armor,b=[],k=0,w=t.armorPen||[],x=_createForOfIteratorHelper(w);try{for(x.s();!(m=x.n()).done;){var S=m.value;/^\*/.test(S)?b.push(Number(S.replace("*",""))):k+=Number(S)}}catch(t){x.e(t)}finally{x.f()}var T=0,A=0;["spell","ritual"].includes(t.source.type)?T+=i.system.spellArmor||0:["liturgy","ceremony"].includes(t.source.type)&&(T+=i.system.liturgyArmor||0),_+=k;var O=b.reduce((function(t,r){return t*r}),1);_=Math.max(Math.round(_*O),0),_+=T+A;var P=l.Z.armorGetsDamage(y,t),E=v.map((function(t){return t.uuid}));return{damage:y,armor:_,armorDamaged:{damaged:P,ids:E},armorMod:k,spellArmor:T,liturgyArmor:A,armorMultiplier:O,messages:c,sum:y-_}}},{key:"_evaluateTalentOpposedRoll",value:function _evaluateTalentOpposedRoll(t,r,a){t.successLevel>0&&t.successLevel>r.successLevel?a.winner="attacker":t.qualityStep>r.qualityStep||t.result>=0&&r.result<0?(a.winner="attacker",a.differenceSL=t.qualityStep-r.qualityStep):(a.winner="defender",a.differenceSL=r.qualityStep-t.qualityStep)}},{key:"formatOpposedResult",value:function formatOpposedResult(t,r,a){var o=t.differenceSL?"winsFP":"wins";return"attacker"==t.winner?(t.result=game.i18n.format("OPPOSED."+o,{winner:r.alias,loser:a.alias,SL:t.differenceSL}),t.img=r.img):"defender"==t.winner&&(t.result=game.i18n.format("OPPOSED."+o,{winner:a.alias,loser:r.alias,SL:t.differenceSL}),t.img=a.img),t.speakerAttack=r,t.speakerDefend=a,t}},{key:"rerenderMessagesWithModifiers",value:function rerenderMessagesWithModifiers(t,r,a){var o=game.messages.get(r.messageId);this.showDamage(o,"attacker"!=t.winner)}},{key:"renderOpposedResult",value:(r=_asyncToGenerator(_regeneratorRuntime().mark((function _callee18(t){var r,a,o,i=arguments;return _regeneratorRuntime().wrap((function _callee18$(c){for(;;)switch(c.prev=c.next){case 0:return r=i.length>1&&void 0!==i[1]?i[1]:{},c.next=3,game.settings.get("dsa5","hideOpposedDamage");case 3:return t.hideData=c.sent,c.next=6,renderTemplate("systems/dsa5/templates/chat/roll/opposed-result.html",t);case 6:return a=c.sent,o={user:game.user.id,content:a,"flags.opposeData":t,"flags.hideData":t.hideData,whisper:r.whisper,blind:r.blind},r.target&&(o["flags.startMessageId"]=r.startMessageId),c.next=11,ChatMessage.create(o);case 11:case"end":return c.stop()}}),_callee18)}))),function renderOpposedResult(t){return r.apply(this,arguments)})},{key:"resolveUndefended",value:(t=_asyncToGenerator(_regeneratorRuntime().mark((function _callee19(t){var r,a,o,i,c,u,l,p=arguments;return _regeneratorRuntime().wrap((function _callee19$(d){for(;;)switch(d.prev=d.next){case 0:return a=p.length>1&&void 0!==p[1]?p[1]:"",o=t.flags.unopposeData,i=game.messages.get(o.attackMessageId),(c={speaker:i.speaker,testResult:i.flags.data.postData,messageId:o.attackMessageId}).testResult.source=i.flags.data.preData.source,c.testResult.ammo&&(r=c.testResult.source.effects).push.apply(r,_toConsumableArray(c.testResult.ammo.effects)),u=canvas.tokens.get(o.targetSpeaker.token),l={speaker:o.targetSpeaker,testResult:{actor:u.actor,speaker:{token:o.targetSpeaker.token}}},d.next=10,this.clearOpposed(u.actor);case 10:return d.next=12,this.completeOpposedProcess(c,l,{target:!0,startMessageId:t.id,additionalInfo:a});case 12:if(!game.user.isGM){d.next=17;break}return d.next=15,i.update({"flags.data.unopposedStartMessage":t.id});case 15:d.next=19;break;case 17:return d.next=19,game.socket.emit("system.dsa5",{type:"updateAttackMessage",payload:{messageId:i.id,startMessageId:t.id}});case 19:case"end":return d.stop()}}),_callee19,this)}))),function resolveUndefended(r){return t.apply(this,arguments)})}]),OpposedDsa5}()},903:(t,r,a)=>{a.d(r,{Z:()=>u});var o=a(538),i=a(231),c=a(491);function _typeof(t){return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},_typeof(t)}function _createForOfIteratorHelper(t,r){var a="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!a){if(Array.isArray(t)||(a=function _unsupportedIterableToArray(t,r){if(!t)return;if("string"==typeof t)return _arrayLikeToArray(t,r);var a=Object.prototype.toString.call(t).slice(8,-1);"Object"===a&&t.constructor&&(a=t.constructor.name);if("Map"===a||"Set"===a)return Array.from(t);if("Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a))return _arrayLikeToArray(t,r)}(t))||r&&t&&"number"==typeof t.length){a&&(t=a);var o=0,i=function F(){};return{s:i,n:function n(){return o>=t.length?{done:!0}:{done:!1,value:t[o++]}},e:function e(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var c,u=!0,l=!1;return{s:function s(){a=a.call(t)},n:function n(){var t=a.next();return u=t.done,t},e:function e(t){l=!0,c=t},f:function f(){try{u||null==a.return||a.return()}finally{if(l)throw c}}}}function _arrayLikeToArray(t,r){(null==r||r>t.length)&&(r=t.length);for(var a=0,o=new Array(r);a=0;--o){var i=this.tryEntries[o],c=i.completion;if("root"===i.tryLoc)return handle("end");if(i.tryLoc<=this.prev){var u=a.call(i,"catchLoc"),l=a.call(i,"finallyLoc");if(u&&l){if(this.prev=0;--o){var i=this.tryEntries[o];if(i.tryLoc<=this.prev&&a.call(i,"finallyLoc")&&this.prev=0;--r){var a=this.tryEntries[r];if(a.finallyLoc===t)return this.complete(a.completion,a.afterLoc),resetTryEntry(a),l}},catch:function _catch(t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc===t){var o=a.completion;if("throw"===o.type){var i=o.arg;resetTryEntry(a)}return i}}throw new Error("illegal catch attempt")},delegateYield:function delegateYield(t,r,a){return this.delegate={iterator:values(t),resultName:r,nextLoc:a},"next"===this.method&&(this.arg=void 0),l}},t}function asyncGeneratorStep(t,r,a,o,i,c,u){try{var l=t[c](u),p=l.value}catch(t){return void a(t)}l.done?r(p):Promise.resolve(p).then(o,i)}function _asyncToGenerator(t){return function(){var r=this,a=arguments;return new Promise((function(o,i){var c=t.apply(r,a);function _next(t){asyncGeneratorStep(c,o,i,_next,_throw,"next",t)}function _throw(t){asyncGeneratorStep(c,o,i,_next,_throw,"throw",t)}_next(void 0)}))}}function _defineProperties(t,r){for(var a=0;a3&&void 0!==h[3]?h[3]:0,c=i.Z._getActor(),u=c.actor,l=c.tokenId,u){m.next=4;break}return m.abrupt("return");case 4:game.user.updateTokenTargets([]),p={modifier:o,postFunction:{cummulative:a,functionName:"game.dsa5.apps.RequestRoll.autoEditGroupCheckRoll"}},m.t0=t,m.next="attribute"===m.t0?9:10;break;case 9:return m.abrupt("break",12);case 10:d=u.items.find((function(a){return a.name==r&&a.type==t})),u.setupSkill(d,p,l).then(function(){var o=_asyncToGenerator(_regeneratorRuntime().mark((function _callee(o){var i;return _regeneratorRuntime().wrap((function _callee$(c){for(;;)switch(c.prev=c.next){case 0:return c.next=2,u.basicTest(o);case 2:return i=c.sent,c.next=5,RequestRoll.editGroupCheckRoll(a,i,r,t);case 5:case"end":return c.stop()}}),_callee)})));return function(t){return o.apply(this,arguments)}}());case 12:case"end":return m.stop()}}),_callee2)}))),function requestGC(t,r,a){return g.apply(this,arguments)})},{key:"autoEditGroupCheckRoll",value:(y=_asyncToGenerator(_regeneratorRuntime().mark((function _callee3(t,r,a){return _regeneratorRuntime().wrap((function _callee3$(o){for(;;)switch(o.prev=o.next){case 0:return o.next=2,RequestRoll.editGroupCheckRoll(t.cummulative,r,a.name,a.type);case 2:case"end":return o.stop()}}),_callee3)}))),function autoEditGroupCheckRoll(t,r,a){return y.apply(this,arguments)})},{key:"editGroupCheckRoll",value:(m=_asyncToGenerator(_regeneratorRuntime().mark((function _callee4(t,r,a,o){var i,u,l,p,d,h,m;return _regeneratorRuntime().wrap((function _callee4$(y){for(;;)switch(y.prev=y.next){case 0:return y.next=2,game.messages.get(t);case 2:i=y.sent,u=i.flags,l=r.result.successLevel>1,p=l?2:1,u.botched=u.botched||r.result.successLevel<-1,d=c.Z.getSpeaker(r.result.speaker),h={messageId:r.result.messageId,actor:d.name,qs:(r.result.qualityStep||0)*p,success:r.result.successLevel,target:a,type:o},(m=u.results.findIndex((function(t){return t.messageId==h.messageId})))>=0?u.results[m]=h:u.results.push(h),RequestRoll.rerenderGC(i,u);case 12:case"end":return y.stop()}}),_callee4)}))),function editGroupCheckRoll(t,r,a,o){return m.apply(this,arguments)})},{key:"requestRoll",value:(h=_asyncToGenerator(_regeneratorRuntime().mark((function _callee5(t,r){var a,o,c,u,l,p,d,h=arguments;return _regeneratorRuntime().wrap((function _callee5$(m){for(;;)switch(m.prev=m.next){case 0:if(a=h.length>2&&void 0!==h[2]?h[2]:0,o=i.Z._getActor(),c=o.actor,u=o.tokenId,!c){m.next=17;break}game.user.updateTokenTargets([]),l={modifier:a},m.t0=t,m.next="attribute"===m.t0?8:"regeneration"===m.t0?11:"fallingDamage"===m.t0?13:15;break;case 8:return p=Object.keys(game.dsa5.config.characteristics).find((function(t){return game.i18n.localize(game.dsa5.config.characteristics[t])==r})),c.setupCharacteristic(p,l,u).then((function(t){c.basicTest(t)})),m.abrupt("break",17);case 11:return c.setupRegeneration("regenerate",l,u).then((function(t){c.basicTest(t)})),m.abrupt("break",17);case 13:return c.setupFallingDamage(l,u),m.abrupt("break",17);case 15:d=c.items.find((function(a){return a.name==r&&a.type==t})),c.setupSkill(d,l,u).then((function(t){c.basicTest(t)}));case 17:case"end":return m.stop()}}),_callee5)}))),function requestRoll(t,r){return h.apply(this,arguments)})},{key:"rerenderGC",value:(d=_asyncToGenerator(_regeneratorRuntime().mark((function _callee6(t,r){var a,o,i,c,u;return _regeneratorRuntime().wrap((function _callee6$(l){for(;;)switch(l.prev=l.next){case 0:if(!game.user.isGM){l.next=14;break}a=0,r.qs=r.results.reduce((function(t,r){return a+=r.success<0?1:0,r.success>1&&(a=0),t+r.qs}),0),r.failed=a,o=_createForOfIteratorHelper(r.rollOptions);try{for(o.s();!(i=o.n()).done;)(c=i.value).calculatedModifier=c.modifier-a}catch(t){o.e(t)}finally{o.f()}return r.openRolls=r.maxRolls-r.results.length,r.doneRolls=r.results.length,l.next=10,renderTemplate("systems/dsa5/templates/chat/roll/groupcheck.html",r);case 10:u=l.sent,t.update({content:u,flags:r}),l.next=15;break;case 14:game.socket.emit("system.dsa5",{type:"updateGroupCheck",payload:{messageId:t.id,data:r}});case 15:$("#chat-log").find('[data-message-id="'.concat(t.id,'"')).appendTo("#chat-log");case 16:case"end":return l.stop()}}),_callee6)}))),function rerenderGC(t,r){return d.apply(this,arguments)})},{key:"showRQMessage",value:function showRQMessage(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,a=r<0?" ".concat(r):r>0?" +".concat(r):"",o=i.Z.skills.find((function(r){return r.name==t})).type,u=game.i18n.format("CHATNOTIFICATION.requestRoll",{user:game.user.name,item:' ').concat(t).concat(a,"")});ChatMessage.create(c.Z.chatDataSetup(u))}},{key:"showGCMessage",value:(p=_asyncToGenerator(_regeneratorRuntime().mark((function _callee7(t){var r,a,o,u,l,p,d=arguments;return _regeneratorRuntime().wrap((function _callee7$(h){for(;;)switch(h.prev=h.next){case 0:return r=d.length>1&&void 0!==d[1]?d[1]:0,a=d.length>2&&void 0!==d[2]?d[2]:{},o=i.Z.skills.find((function(r){return r.name==t})).type,u={results:[],qs:0,failed:0,modifier:r,name:game.user.name,maxRolls:7,openRolls:7,doneRolls:0,targetQs:10,rollOptions:[{type:o,modifier:r,calculatedModifier:r,target:t}]},mergeObject(u,a),h.next=7,renderTemplate("systems/dsa5/templates/chat/roll/groupcheck.html",u);case 7:l=h.sent,(p=c.Z.chatDataSetup(l)).flags=u,ChatMessage.create(p);case 11:case"end":return h.stop()}}),_callee7)}))),function showGCMessage(t){return p.apply(this,arguments)})},{key:"addSkillToGC",value:(l=_asyncToGenerator(_regeneratorRuntime().mark((function _callee9(t){var r,a,c;return _regeneratorRuntime().wrap((function _callee9$(u){for(;;)switch(u.prev=u.next){case 0:return r=$(t.currentTarget).parents(".message").attr("data-message-id"),u.next=3,renderTemplate("systems/dsa5/templates/dialog/addgroupcheckskill.html",{skills:i.Z.skills.filter((function(t){return"skill"==t.type})).sort((function(t,r){return t.name.localeCompare(r.name)}))});case 3:a=u.sent,c={title:game.i18n.localize("HELP.groupcheck"),content:a,buttons:{ok:{icon:'',label:game.i18n.localize("ok"),callback:function(){var t=_asyncToGenerator(_regeneratorRuntime().mark((function _callee8(t){var a,o;return _regeneratorRuntime().wrap((function _callee8$(i){for(;;)switch(i.prev=i.next){case 0:a=game.messages.get(r),(o=a.flags).rollOptions.push({type:"skill",modifier:t.find('[name="modifier"]').val(),target:t.find('[name="skill"]').val()}),RequestRoll.rerenderGC(a,o);case 4:case"end":return i.stop()}}),_callee8)})));return function callback(r){return t.apply(this,arguments)}}()},cancel:{icon:'',label:game.i18n.localize("cancel")}}},new o.Z(c).render(!0);case 6:case"end":return u.stop()}}),_callee9)}))),function addSkillToGC(t){return l.apply(this,arguments)})},{key:"removeGCEntry",value:(u=_asyncToGenerator(_regeneratorRuntime().mark((function _callee10(t){var r,a,o,i;return _regeneratorRuntime().wrap((function _callee10$(c){for(;;)switch(c.prev=c.next){case 0:r=$(t.currentTarget),a=Number(t.currentTarget.dataset.index),o=game.messages.get(r.parents(".message").attr("data-message-id")),(i=o.flags).results.splice(a,1),RequestRoll.rerenderGC(o,i);case 6:case"end":return c.stop()}}),_callee10)}))),function removeGCEntry(t){return u.apply(this,arguments)})},{key:"removeSkillFromGC",value:function removeSkillFromGC(t){var r=$(t.currentTarget),a=game.messages.get(r.parents(".message").attr("data-message-id")),o=a.flags;o.rollOptions=o.rollOptions.filter((function(r){return!(r.type==t.currentTarget.dataset.type&&r.target==t.currentTarget.dataset.name)})),o.results=o.results.filter((function(r){return!(r.type==t.currentTarget.dataset.type&&r.target==t.currentTarget.dataset.name)})),RequestRoll.rerenderGC(a,o)}},{key:"editGC",value:(a=_asyncToGenerator(_regeneratorRuntime().mark((function _callee11(t){var r,a,o,i;return _regeneratorRuntime().wrap((function _callee11$(c){for(;;)switch(c.prev=c.next){case 0:r=$(t.currentTarget),a=Number(t.currentTarget.dataset.index),o=game.messages.get(r.parents(".message").attr("data-message-id")),i=o.flags,a?i.results[a].qs=Number(r.val()):t.currentTarget.dataset.name?i.rollOptions.find((function(r){return r.target==t.currentTarget.dataset.name&&t.currentTarget.dataset.type==r.type}))[t.currentTarget.dataset.field]=Number(r.val()):i[t.currentTarget.dataset.field]=Number(r.val()),RequestRoll.rerenderGC(o,i);case 6:case"end":return c.stop()}}),_callee11)}))),function editGC(t){return a.apply(this,arguments)})},{key:"updateInformationRoll",value:(r=_asyncToGenerator(_regeneratorRuntime().mark((function _callee12(t,r,a){var o,i,u,l,p,d,h;return _regeneratorRuntime().wrap((function _callee12$(a){for(;;)switch(a.prev=a.next){case 0:if(!((o=r.result.qualityStep||0)>0)){a.next=20;break}return a.next=4,fromUuid(t.uuid);case 4:i=a.sent,u=["

".concat(i.name,"

")],l=1;case 7:if(!(l<=o)){a.next=17;break}if(p="qs".concat(l),!i.system[p]){a.next=14;break}return a.next=12,TextEditor.enrichHTML(i.system[p],{async:!0});case 12:d=a.sent,u.push("

".concat(d,"

"));case 14:l++,a.next=7;break;case 17:h=c.Z.chatDataSetup(u.join("")),t.recipients.length&&(h.whisper=t.recipients),ChatMessage.create(h);case 20:case"end":return a.stop()}}),_callee12)}))),function updateInformationRoll(t,a,o){return r.apply(this,arguments)})},{key:"informationRequestRoll",value:(t=_asyncToGenerator(_regeneratorRuntime().mark((function _callee14(t){var r,a,o,c,u,l,p,d,h,m=this;return _regeneratorRuntime().wrap((function _callee14$(y){for(;;)switch(y.prev=y.next){case 0:if(r=t.currentTarget.dataset.mod,a=t.currentTarget.dataset.uuid,o=i.Z._getActor(),c=o.actor,u=o.tokenId,c){y.next=5;break}return y.abrupt("return");case 5:l=game.settings.get("dsa5","informationDistribution"),p=[],1==l?(p=game.users.filter((function(t){return t.isGM})).map((function(t){return t.id}))).push(game.user.id):2==l&&(p=game.users.filter((function(t){return t.isGM})).map((function(t){return t.id}))),d={modifier:r,postFunction:{functionName:"game.dsa5.apps.RequestRoll.updateInformationRoll",uuid:a,recipients:p}},h=c.items.find((function(r){return r.name==t.currentTarget.dataset.skill&&"skill"==r.type})),c.setupSkill(h,d,u).then(function(){var t=_asyncToGenerator(_regeneratorRuntime().mark((function _callee13(t){var r;return _regeneratorRuntime().wrap((function _callee13$(a){for(;;)switch(a.prev=a.next){case 0:return t.testData.opposable=!1,a.next=3,c.basicTest(t);case 3:r=a.sent,m.updateInformationRoll(d.postFunction,r);case 5:case"end":return a.stop()}}),_callee13)})));return function(r){return t.apply(this,arguments)}}());case 11:case"end":return y.stop()}}),_callee14)}))),function informationRequestRoll(r){return t.apply(this,arguments)})},{key:"chatListeners",value:function chatListeners(t){t.on("change",".editGC",(function(t){return RequestRoll.editGC(t)})),t.on("click",".request-roll",(function(t){var r=t.currentTarget.dataset;RequestRoll.requestRoll(r.type,r.name,Number(r.modifier)||0)})),t.on("click",".request-gc",(function(t){var r=t.currentTarget.dataset;RequestRoll.requestGC(r.type,r.name,$(t.currentTarget).parents(".message").attr("data-message-id"),Number(r.modifier)||0)})),t.on("click",".removeGC",(function(t){return RequestRoll.removeGCEntry(t)})),t.on("click",".removeSkillFromGC",(function(t){return RequestRoll.removeSkillFromGC(t)})),t.on("click",".addSkillToGC",(function(t){return RequestRoll.addSkillToGC(t)})),t.on("click",".informationRequestRoll",(function(t){return RequestRoll.informationRequestRoll(t)}))}}]),RequestRoll}()},169:(t,r,a)=>{a.d(r,{Z:()=>i});var o=a(491);function _typeof(t){return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},_typeof(t)}function _createForOfIteratorHelper(t,r){var a="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!a){if(Array.isArray(t)||(a=function _unsupportedIterableToArray(t,r){if(!t)return;if("string"==typeof t)return _arrayLikeToArray(t,r);var a=Object.prototype.toString.call(t).slice(8,-1);"Object"===a&&t.constructor&&(a=t.constructor.name);if("Map"===a||"Set"===a)return Array.from(t);if("Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a))return _arrayLikeToArray(t,r)}(t))||r&&t&&"number"==typeof t.length){a&&(t=a);var o=0,i=function F(){};return{s:i,n:function n(){return o>=t.length?{done:!0}:{done:!1,value:t[o++]}},e:function e(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var c,u=!0,l=!1;return{s:function s(){a=a.call(t)},n:function n(){var t=a.next();return u=t.done,t},e:function e(t){l=!0,c=t},f:function f(){try{u||null==a.return||a.return()}finally{if(l)throw c}}}}function _arrayLikeToArray(t,r){(null==r||r>t.length)&&(r=t.length);for(var a=0,o=new Array(r);a=0;--o){var i=this.tryEntries[o],c=i.completion;if("root"===i.tryLoc)return handle("end");if(i.tryLoc<=this.prev){var u=a.call(i,"catchLoc"),l=a.call(i,"finallyLoc");if(u&&l){if(this.prev=0;--o){var i=this.tryEntries[o];if(i.tryLoc<=this.prev&&a.call(i,"finallyLoc")&&this.prev=0;--r){var a=this.tryEntries[r];if(a.finallyLoc===t)return this.complete(a.completion,a.afterLoc),resetTryEntry(a),l}},catch:function _catch(t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc===t){var o=a.completion;if("throw"===o.type){var i=o.arg;resetTryEntry(a)}return i}}throw new Error("illegal catch attempt")},delegateYield:function delegateYield(t,r,a){return this.delegate={iterator:values(t),resultName:r,nextLoc:a},"next"===this.method&&(this.arg=void 0),l}},t}function asyncGeneratorStep(t,r,a,o,i,c,u){try{var l=t[c](u),p=l.value}catch(t){return void a(t)}l.done?r(p):Promise.resolve(p).then(o,i)}function _asyncToGenerator(t){return function(){var r=this,a=arguments;return new Promise((function(o,i){var c=t.apply(r,a);function _next(t){asyncGeneratorStep(c,o,i,_next,_throw,"next",t)}function _throw(t){asyncGeneratorStep(c,o,i,_next,_throw,"throw",t)}_next(void 0)}))}}function _defineProperties(t,r){for(var a=0;a1&&void 0!==arguments[1]?arguments[1]:{},i=this.getHorse(t);if(i){var c=this.getLoyaltyFromHorse(i);if(!c)return ui.notifications.warn(game.i18n.format("DSAError.notFound",{category:o.Z.categoryLocalization("skill"),name:game.i18n.localize("LocalizedIDs.loyalty")}));i.setupSkill(c,a,null===(r=i.token)||void 0===r?void 0:r.id).then((function(t){i.basicTest(t)}))}}},{key:"updateRiderSpeed",value:(d=_asyncToGenerator(_regeneratorRuntime().mark((function _callee2(t,r){var a,o,i,c,u,l;return _regeneratorRuntime().wrap((function _callee2$(p){for(;;)switch(p.prev=p.next){case 0:if(null!==(a=canvas)&&void 0!==a&&null!==(o=a.tokens)&&void 0!==o&&o.documentCollection){p.next=2;break}return p.abrupt("return");case 2:for(i=t.getActiveTokens().map((function(t){return t.id})),c=0,u=Array.from(canvas.tokens.documentCollection);c1&&void 0!==arguments[1]&&arguments[1];return t.system.horse&&!(r=t.system.horse.token&&!t.system.horse.actorLink?o.Z.getSpeaker(t.system.horse.token):game.actors.get(t.system.horse.actorId))&&a&&t.system.horse.isRiding&&(r={name:game.i18n.localize("unknown")}),r}},{key:"unmountHorse",value:(c=_asyncToGenerator(_regeneratorRuntime().mark((function _callee7(t,r){var a,o,i,c,u;return _regeneratorRuntime().wrap((function _callee7$(l){for(;;)switch(l.prev=l.next){case 0:return _defineProperty(o={},"flags.dsa5.-=horseTokenId",null),_defineProperty(o,"elevation",Math.max(0,(null!==(a=r.elevation)&&void 0!==a?a:0)-1)),i=o,(c=r.getFlag("dsa5","horseResized"))&&mergeObject(i,(_defineProperty(u={},"flags.dsa5.-=horseResized",null),_defineProperty(u,"width",c.width),_defineProperty(u,"height",c.height),u)),l.next=5,this.clearMount(t);case 5:return l.next=7,r.update(i);case 7:case"end":return l.stop()}}),_callee7,this)}))),function unmountHorse(t,r){return c.apply(this,arguments)})},{key:"clearMount",value:(i=_asyncToGenerator(_regeneratorRuntime().mark((function _callee8(t){return _regeneratorRuntime().wrap((function _callee8$(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,t.update({system:{horse:{isRiding:!1,actorLink:!1,actorId:"","-=token":null}}});case 2:return r.next=4,this.removeRidingCondition(t);case 4:case"end":return r.stop()}}),_callee8,this)}))),function clearMount(t){return i.apply(this,arguments)})},{key:"ridingCondition",value:function ridingCondition(){return{name:game.i18n.localize("RIDING.riding"),icon:"systems/dsa5/icons/thirdparty/horse-head.svg",changes:[{key:"system.status.dodge.gearmodifier",mode:2,value:-2}],flags:{dsa5:{description:game.i18n.localize("RIDING.ridingDescription")}}}}},{key:"setHorse",value:(a=_asyncToGenerator(_regeneratorRuntime().mark((function _callee9(t,r){var a;return _regeneratorRuntime().wrap((function _callee9$(o){for(;;)switch(o.prev=o.next){case 0:return a={system:{horse:{isRiding:!0,actorLink:r.prototypeToken.actorLink,actorId:r.id}}},!r.prototypeToken.actorLink&&r.token&&mergeObject(a,{system:{horse:{token:{scene:canvas.scene.id,token:r.token.id}}}}),o.next=4,t.update(a);case 4:if(!r.isToken){o.next=7;break}return o.next=7,canvas.scene.updateEmbeddedDocuments("Token",t.getActiveTokens().map((function(t){return{_id:t.id,"flags.dsa5.horseTokenId":r.token.id,x:r.token.x,y:r.token.y}})).concat(_defineProperty({_id:r.token.id},"flags.dsa5.-=horseTokenId",null)),{noHooks:!0});case 7:return o.next=9,this.addRidingCondition(t);case 9:case"end":return o.stop()}}),_callee9,this)}))),function setHorse(t,r){return a.apply(this,arguments)})},{key:"adaptTokenSize",value:function adaptTokenSize(t,r){return t.width>=r.width?{width:.7*r.width,height:.7*r.height,"flags.dsa5.horseResized":{width:t.width,height:t.height}}:{}}},{key:"mountHorse",value:(r=_asyncToGenerator(_regeneratorRuntime().mark((function _callee10(t){var r,a,o,i,c;return _regeneratorRuntime().wrap((function _callee10$(u){for(;;)switch(u.prev=u.next){case 0:return a=canvas.tokens.controlled.find((function(r){return r.document.id!=t.id})),o=t.parent,i={system:{horse:{isRiding:!0,actorLink:a.actorLink,actorId:a.actor.id}}},a.actorLink||mergeObject(i,{system:{horse:{token:{scene:o.id,token:a.id}}}}),c={_id:t.id,"flags.dsa5.horseTokenId":a.id,x:a.x,y:a.y,elevation:(null!==(r=a.document.elevation)&&void 0!==r?r:0)+1},mergeObject(c,this.adaptTokenSize(t.document,a.document)),u.next=8,t.actor.update(i);case 8:return u.next=10,canvas.scene.updateEmbeddedDocuments("Token",[c,_defineProperty({_id:a.id},"flags.dsa5.-=horseTokenId",null)],{noHooks:!0});case 10:return u.next=12,this.addRidingCondition(t.actor);case 12:case"end":return u.stop()}}),_callee10,this)}))),function mountHorse(t){return r.apply(this,arguments)})},{key:"getHorseSpeed",value:function getHorseSpeed(t){var r;return(null===(r=t.effects.find((function(t){return getProperty(t,"flags.dsa5.horseSpeed")})))||void 0===r?void 0:r.flags.dsa5.horseSpeed)||0}},{key:"horseSpeedModifier",value:function horseSpeedModifier(t){var r=this.getHorseSpeed(t);return Object.keys(this.speedKeys).map((function(t){return Number(t)})).indexOf(Number(r))}},{key:"increaseSpeed",value:function increaseSpeed(t){var r=this.getHorseSpeed(t),a=Math.min(3,Object.keys(this.speedKeys).map((function(t){return Number(t)})).indexOf(r)+1);this.setSpeed(t,Object.keys(this.speedKeys).map((function(t){return Number(t)}))[a])}},{key:"decreaseSpeed",value:function decreaseSpeed(t){var r=this.getHorseSpeed(t),a=Math.max(0,Object.keys(this.speedKeys).map((function(t){return Number(t)})).indexOf(r)-1);this.setSpeed(t,Object.keys(this.speedKeys).map((function(t){return Number(t)}))[a])}},{key:"setSpeed",value:(t=_asyncToGenerator(_regeneratorRuntime().mark((function _callee11(t,r){return _regeneratorRuntime().wrap((function _callee11$(a){for(;;)switch(a.prev=a.next){case 0:return a.next=2,t.deleteEmbeddedDocuments("ActiveEffect",t.effects.filter((function(t){return hasProperty(t,"flags.dsa5.horseSpeed")})).map((function(t){return t.id})));case 2:return a.next=4,t.addCondition({name:game.i18n.localize("speed")+": "+game.i18n.localize("RIDING.speeds.".concat(r)),icon:"systems/dsa5/icons/thirdparty/horse-head.svg",changes:[this.speedKeys[r]],flags:{dsa5:{description:game.i18n.localize("RIDING.speed.".concat(r)),horseSpeed:r}}});case 4:case"end":return a.stop()}}),_callee11,this)}))),function setSpeed(r,a){return t.apply(this,arguments)})},{key:"renderTokenHUD",value:function renderTokenHUD(t,r,a){var o=this,i=t.object.actor;if(2==canvas.tokens.controlled.length)r.find(".col.left").prepend(this.preRenderedMountHud),r.find('.control-icon[data-action="ride"]').click((function(){return o.mountHorse(t.object)}));else if(this.isRiding(i)){r.find(".col.left").prepend(this.preRenderedUnmountHud);var c=r.find('.control-icon[data-action="ride"]');c.click((function(){o.unmountHorse(i,t.object.document),c.remove()}));var u=this.getHorse(i);r.find(".col.right").prepend(this.preRenderedSpeedHud),r.find('.control-icon[data-action="rideIncrease"]').click((function(){return o.increaseSpeed(u)})),r.find('.control-icon[data-action="rideDecrease"]').click((function(){return o.decreaseSpeed(u)}))}}}]),Riding}();_defineProperty(i,"preRenderedUnmountHud",'\n
\n \n
\n '),_defineProperty(i,"preRenderedMountHud",'
'),_defineProperty(i,"preRenderedSpeedHud",'\n
\n
\n '),_defineProperty(i,"speedKeys",{0:{key:"system.status.speed.multiplier",mode:5,value:0},"-4":{key:"system.status.speed.initial",mode:5,value:4},"-5000":{key:"system.status.speed.multiplier",mode:5,value:.66},"-8":{key:"system.status.speed.multiplier",mode:5,value:1}})},122:(t,r,a)=>{a.d(r,{Z:()=>u});var o=a(973),i=a(173),c=a(491);function _typeof(t){return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},_typeof(t)}function _createForOfIteratorHelper(t,r){var a="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!a){if(Array.isArray(t)||(a=function _unsupportedIterableToArray(t,r){if(!t)return;if("string"==typeof t)return _arrayLikeToArray(t,r);var a=Object.prototype.toString.call(t).slice(8,-1);"Object"===a&&t.constructor&&(a=t.constructor.name);if("Map"===a||"Set"===a)return Array.from(t);if("Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a))return _arrayLikeToArray(t,r)}(t))||r&&t&&"number"==typeof t.length){a&&(t=a);var o=0,i=function F(){};return{s:i,n:function n(){return o>=t.length?{done:!0}:{done:!1,value:t[o++]}},e:function e(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var c,u=!0,l=!1;return{s:function s(){a=a.call(t)},n:function n(){var t=a.next();return u=t.done,t},e:function e(t){l=!0,c=t},f:function f(){try{u||null==a.return||a.return()}finally{if(l)throw c}}}}function _arrayLikeToArray(t,r){(null==r||r>t.length)&&(r=t.length);for(var a=0,o=new Array(r);a=0;--o){var i=this.tryEntries[o],c=i.completion;if("root"===i.tryLoc)return handle("end");if(i.tryLoc<=this.prev){var u=a.call(i,"catchLoc"),l=a.call(i,"finallyLoc");if(u&&l){if(this.prev=0;--o){var i=this.tryEntries[o];if(i.tryLoc<=this.prev&&a.call(i,"finallyLoc")&&this.prev=0;--r){var a=this.tryEntries[r];if(a.finallyLoc===t)return this.complete(a.completion,a.afterLoc),resetTryEntry(a),l}},catch:function _catch(t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc===t){var o=a.completion;if("throw"===o.type){var i=o.arg;resetTryEntry(a)}return i}}throw new Error("illegal catch attempt")},delegateYield:function delegateYield(t,r,a){return this.delegate={iterator:values(t),resultName:r,nextLoc:a},"next"===this.method&&(this.arg=void 0),l}},t}function asyncGeneratorStep(t,r,a,o,i,c,u){try{var l=t[c](u),p=l.value}catch(t){return void a(t)}l.done?r(p):Promise.resolve(p).then(o,i)}function _asyncToGenerator(t){return function(){var r=this,a=arguments;return new Promise((function(o,i){var c=t.apply(r,a);function _next(t){asyncGeneratorStep(c,o,i,_next,_throw,"next",t)}function _throw(t){asyncGeneratorStep(c,o,i,_next,_throw,"throw",t)}_next(void 0)}))}}function _defineProperties(t,r){for(var a=0;ad)){m.next=14;break}return m.next=14,l.update(p);case 14:m.next=22;break;case 16:return h=duplicate(CONFIG.statusEffects.find((function(t){return"bleeding"==t.id}))),mergeObject(h,p),m.next=20,o.Z.addCondition(i,h,1,!1,!0);case 20:return m.next=22,ChatMessage.create(c.Z.chatDataSetup(game.i18n.format("CHATNOTIFICATION.gotBleeding",{actor:i.name})));case 22:case"end":return m.stop()}}),_callee2)})));return function(r){return t.apply(this,arguments)}}());case 5:case"end":return l.stop()}}),_callee3)}))),function calcBleeding(r){return t.apply(this,arguments)})},{key:"increment",value:function increment(t,r,a){var o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:void 0,i=t.ctrlKey?10:1,c=2==t.button?-1:1,u=getProperty(r,a)+i*c;return null!=o&&(u=Math.max(o,u)),setProperty(r,a,u),u}},{key:"magicalImprovement",value:function magicalImprovement(t,r){var a,o=_createForOfIteratorHelper(t.items);try{for(o.s();!(a=o.n()).done;){var i=a.value;["ritual","spell"].includes(i.type)&&(i.system.talentValue.value+=4)}}catch(t){o.e(t)}finally{o.f()}}}]),RuleChaos}();_defineProperty(u,"regex2h",/\(2H/)},173:(t,r,a)=>{a.d(r,{Z:()=>u});var o=a(577),i=a(794),c=a(492);function _typeof(t){return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},_typeof(t)}function _regeneratorRuntime(){_regeneratorRuntime=function _regeneratorRuntime(){return t};var t={},r=Object.prototype,a=r.hasOwnProperty,o="function"==typeof Symbol?Symbol:{},i=o.iterator||"@@iterator",c=o.asyncIterator||"@@asyncIterator",u=o.toStringTag||"@@toStringTag";function define(t,r,a){return Object.defineProperty(t,r,{value:a,enumerable:!0,configurable:!0,writable:!0}),t[r]}try{define({},"")}catch(t){define=function define(t,r,a){return t[r]=a}}function wrap(t,r,a,o){var i=r&&r.prototype instanceof Generator?r:Generator,c=Object.create(i.prototype),u=new Context(o||[]);return c._invoke=function(t,r,a){var o="suspendedStart";return function(i,c){if("executing"===o)throw new Error("Generator is already running");if("completed"===o){if("throw"===i)throw c;return doneResult()}for(a.method=i,a.arg=c;;){var u=a.delegate;if(u){var p=maybeInvokeDelegate(u,a);if(p){if(p===l)continue;return p}}if("next"===a.method)a.sent=a._sent=a.arg;else if("throw"===a.method){if("suspendedStart"===o)throw o="completed",a.arg;a.dispatchException(a.arg)}else"return"===a.method&&a.abrupt("return",a.arg);o="executing";var d=tryCatch(t,r,a);if("normal"===d.type){if(o=a.done?"completed":"suspendedYield",d.arg===l)continue;return{value:d.arg,done:a.done}}"throw"===d.type&&(o="completed",a.method="throw",a.arg=d.arg)}}}(t,a,u),c}function tryCatch(t,r,a){try{return{type:"normal",arg:t.call(r,a)}}catch(t){return{type:"throw",arg:t}}}t.wrap=wrap;var l={};function Generator(){}function GeneratorFunction(){}function GeneratorFunctionPrototype(){}var p={};define(p,i,(function(){return this}));var d=Object.getPrototypeOf,h=d&&d(d(values([])));h&&h!==r&&a.call(h,i)&&(p=h);var m=GeneratorFunctionPrototype.prototype=Generator.prototype=Object.create(p);function defineIteratorMethods(t){["next","throw","return"].forEach((function(r){define(t,r,(function(t){return this._invoke(r,t)}))}))}function AsyncIterator(t,r){function invoke(o,i,c,u){var l=tryCatch(t[o],t,i);if("throw"!==l.type){var p=l.arg,d=p.value;return d&&"object"==_typeof(d)&&a.call(d,"__await")?r.resolve(d.__await).then((function(t){invoke("next",t,c,u)}),(function(t){invoke("throw",t,c,u)})):r.resolve(d).then((function(t){p.value=t,c(p)}),(function(t){return invoke("throw",t,c,u)}))}u(l.arg)}var o;this._invoke=function(t,a){function callInvokeWithMethodAndArg(){return new r((function(r,o){invoke(t,a,r,o)}))}return o=o?o.then(callInvokeWithMethodAndArg,callInvokeWithMethodAndArg):callInvokeWithMethodAndArg()}}function maybeInvokeDelegate(t,r){var a=t.iterator[r.method];if(void 0===a){if(r.delegate=null,"throw"===r.method){if(t.iterator.return&&(r.method="return",r.arg=void 0,maybeInvokeDelegate(t,r),"throw"===r.method))return l;r.method="throw",r.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var o=tryCatch(a,t.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,l;var i=o.arg;return i?i.done?(r[t.resultName]=i.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=void 0),r.delegate=null,l):i:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,l)}function pushTryEntry(t){var r={tryLoc:t[0]};1 in t&&(r.catchLoc=t[1]),2 in t&&(r.finallyLoc=t[2],r.afterLoc=t[3]),this.tryEntries.push(r)}function resetTryEntry(t){var r=t.completion||{};r.type="normal",delete r.arg,t.completion=r}function Context(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(pushTryEntry,this),this.reset(!0)}function values(t){if(t){var r=t[i];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var o=-1,c=function next(){for(;++o=0;--o){var i=this.tryEntries[o],c=i.completion;if("root"===i.tryLoc)return handle("end");if(i.tryLoc<=this.prev){var u=a.call(i,"catchLoc"),l=a.call(i,"finallyLoc");if(u&&l){if(this.prev=0;--o){var i=this.tryEntries[o];if(i.tryLoc<=this.prev&&a.call(i,"finallyLoc")&&this.prev=0;--r){var a=this.tryEntries[r];if(a.finallyLoc===t)return this.complete(a.completion,a.afterLoc),resetTryEntry(a),l}},catch:function _catch(t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc===t){var o=a.completion;if("throw"===o.type){var i=o.arg;resetTryEntry(a)}return i}}throw new Error("illegal catch attempt")},delegateYield:function delegateYield(t,r,a){return this.delegate={iterator:values(t),resultName:r,nextLoc:a},"next"===this.method&&(this.arg=void 0),l}},t}function asyncGeneratorStep(t,r,a,o,i,c,u){try{var l=t[c](u),p=l.value}catch(t){return void a(t)}l.done?r(p):Promise.resolve(p).then(o,i)}function _asyncToGenerator(t){return function(){var r=this,a=arguments;return new Promise((function(o,i){var c=t.apply(r,a);function _next(t){asyncGeneratorStep(c,o,i,_next,_throw,"next",t)}function _throw(t){asyncGeneratorStep(c,o,i,_next,_throw,"throw",t)}_next(void 0)}))}}function _classCallCheck(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}function _defineProperties(t,r){for(var a=0;a2&&void 0!==c[2])||c[2],o.Z.removeAbilityRules[r.name]&&o.Z.removeAbilityRules[r.name](t,r),i=SpecialabilityRulesDSA5.calcAPCostSum(r),u.next=5,SpecialabilityRulesDSA5.refundFreelanguage(r,t,i,a);case 5:return i=u.sent,u.next=8,t._updateAPs(-1*i,{},{render:a});case 8:case"end":return u.stop()}}),_callee2)}))),function abilityRemoved(t,r){return l.apply(this,arguments)})},{key:"_specialabilityReturnFunction",value:(u=_asyncToGenerator(_regeneratorRuntime().mark((function _callee3(t,r,a,i){var c,u,l,p,d,h;return _regeneratorRuntime().wrap((function _callee3$(m){for(;;)switch(m.prev=m.next){case 0:if(null!=r){m.next=2;break}return m.abrupt("return");case 2:if(r=duplicate(r),null!=i&&(/,/.test(r.system.APValue.value)&&(u="".concat(r.name.replace(" ()","")," (").concat(i.name),r.system.APValue.value=r.system.APValue.value.split(",")[t.items.filter((function(t){return t.type==r.type&&t.name.includes(u)})).length].trim()),SpecialabilityRulesDSA5.simpleAdoption(r,i,r.name,o.Z.AbilitiesNeedingAdaption),r.name="".concat(r.name.replace(" ()","")," (").concat(i.name).concat(i.customEntry?", "+i.customEntry:"",")"),i.data&&null!==(c=i.system.StF)&&void 0!==c&&c.value&&/\//.test(r.system.APValue.value)&&(r.system.APValue.value=r.system.APValue.value.split("/")[i.system.StF.value.charCodeAt(0)-65].trim())),!(l=t.items.find((function(t){return t.type==a&&t.name==r.name})))){m.next=25;break}return p=duplicate(l),m.next=9,SpecialabilityRulesDSA5.isFreeLanguage(r,t,/;/.test(p.system.APValue.value)?p.system.APValue.value.split(";").map((function(t){return Number(t.trim())}))[p.system.step.value]:p.system.APValue.value,!1);case 9:if(d=m.sent,m.t0=p.system.step.value+1<=p.system.maxRank.value,!m.t0){m.next=15;break}return m.next=14,t.checkEnoughXP(d);case 14:m.t0=m.sent;case 15:if(!m.t0){m.next=23;break}return p.system.step.value+=1,m.next=19,t._updateAPs(d,{},{render:!1});case 19:return m.next=21,t.updateEmbeddedDocuments("Item",[p]);case 21:return m.next=23,SpecialabilityRulesDSA5.abilityAdded(t,p);case 23:m.next=37;break;case 25:return m.next=27,SpecialabilityRulesDSA5.isFreeLanguage(r,t,r.system.APValue.value.split(";").map((function(t){return t.trim()}))[0],!1);case 27:return h=m.sent,m.next=30,t.checkEnoughXP(h);case 30:if(!m.sent){m.next=37;break}return m.next=33,SpecialabilityRulesDSA5.abilityAdded(t,r);case 33:return m.next=35,t._updateAPs(h,{},{render:!1});case 35:return m.next=37,t.createEmbeddedDocuments("Item",[r]);case 37:case"end":return m.stop()}}),_callee3)}))),function _specialabilityReturnFunction(t,r,a,o){return u.apply(this,arguments)})},{key:"refundFreelanguage",value:(i=_asyncToGenerator(_regeneratorRuntime().mark((function _callee4(t,r,a){var o,i,c,u,l,p=arguments;return _regeneratorRuntime().wrap((function _callee4$(d){for(;;)switch(d.prev=d.next){case 0:if(o=!(p.length>3&&void 0!==p[3])||p[3],"language"!=t.system.category.value||!r.system.freeLanguagePoints){d.next=9;break}return i=Number(r.system.freeLanguagePoints.value),c=r.items.filter((function(t){return"specialability"==t.type&&"language"==t.system.category.value})).reduce((function(t,r){return t+Number(r.system.step.value)*Number(r.system.APValue.value)}),0),u=Math.min(i,c-Number(a)),l=Math.max(0,i-u),d.next=8,r.update({"system.freeLanguagePoints.used":Math.min(i,Number(u))},{render:o});case 8:a=Math.max(0,a-l);case 9:return d.abrupt("return",a);case 10:case"end":return d.stop()}}),_callee4)}))),function refundFreelanguage(t,r,a){return i.apply(this,arguments)})},{key:"isFreeLanguage",value:(a=_asyncToGenerator(_regeneratorRuntime().mark((function _callee5(t,r,a){var o,i,c,u,l,p=arguments;return _regeneratorRuntime().wrap((function _callee5$(d){for(;;)switch(d.prev=d.next){case 0:if(o=!(p.length>3&&void 0!==p[3])||p[3],"language"!=t.system.category.value||!r.system.freeLanguagePoints){d.next=9;break}return i=Number(r.system.freeLanguagePoints.value),c=r.items.filter((function(t){return"specialability"==t.type&&"language"==t.system.category.value})).reduce((function(t,r){return t+Number(r.system.step.value)*Number(r.system.APValue.value)}),0),u=Math.min(i,c),l=Math.max(0,i-u),d.next=8,r.update({"system.freeLanguagePoints.used":Math.min(i,Number(u)+Number(a))},{render:o});case 8:a=Math.max(0,a-l);case 9:return d.abrupt("return",a);case 10:case"end":return d.stop()}}),_callee5)}))),function isFreeLanguage(t,r,o){return a.apply(this,arguments)})},{key:"needsAdoption",value:(r=_asyncToGenerator(_regeneratorRuntime().mark((function _callee6(t,r,a){var i,u,l,p,d;return _regeneratorRuntime().wrap((function _callee6$(h){for(;;)switch(h.prev=h.next){case 0:if(!(i=o.Z.AbilitiesNeedingAdaption[r.name])){h.next=26;break}if("text"!=i.items){h.next=9;break}return h.next=5,renderTemplate("systems/dsa5/templates/dialog/requires-adoption-string-dialog.html",{original:r});case 5:u=h.sent,l=function callback(o){var i={name:o.find('[name="entryselection"]').val()};SpecialabilityRulesDSA5._specialabilityReturnFunction(t,r,a,i)},h.next=22;break;case 9:if("array"!=i.items){h.next=17;break}return p=i.elems.map((function(t){return{name:t}})),h.next=13,renderTemplate("systems/dsa5/templates/dialog/requires-adoption-dialog.html",{items:p,original:r,area:i.area});case 13:u=h.sent,l=function callback(o){var i=p.find((function(t){return t.name==o.find('[name="entryselection"]').val()}));SpecialabilityRulesDSA5._specialabilityReturnFunction(t,r,a,i)},h.next=22;break;case 17:return d=t.items.filter((function(t){return i.items.includes(t.type)})).sort((function(t,r){return t.name.localeCompare(r.name)})),h.next=20,renderTemplate("systems/dsa5/templates/dialog/requires-adoption-dialog.html",{items:d,original:r,area:i.area});case 20:u=h.sent,l=function callback(o){var i=d.find((function(t){return t.name==o.find('[name="entryselection"]').val()}));i.customEntry=o.find('[name="custom"]').val(),SpecialabilityRulesDSA5._specialabilityReturnFunction(t,r,a,i)};case 22:return h.next=24,new c.Z({title:game.i18n.localize("DIALOG.ItemRequiresAdoption"),content:u,buttons:{Yes:{icon:'',label:game.i18n.localize("yes"),callback:l},cancel:{icon:'',label:game.i18n.localize("cancel")}},default:"Yes"}).render(!0);case 24:h.next=27;break;case 26:SpecialabilityRulesDSA5._specialabilityReturnFunction(t,r,a,null);case 27:case"end":return h.stop()}}),_callee6)}))),function needsAdoption(t,a,o){return r.apply(this,arguments)})},{key:"hasAbility",value:function hasAbility(t,r){return _get(_getPrototypeOf(SpecialabilityRulesDSA5),"hasItem",this).call(this,t,r,["specialability"])}},{key:"abilityStep",value:function abilityStep(t,r){return _get(_getPrototypeOf(SpecialabilityRulesDSA5),"itemStep",this).call(this,t,r,["specialability"])}},{key:"abilityAsModifier",value:function abilityAsModifier(t,r){var a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,o=arguments.length>3&&void 0!==arguments[3]&&arguments[3];return _get(_getPrototypeOf(SpecialabilityRulesDSA5),"itemAsModifier",this).call(this,t,r,a,["specialability"],o)}}]),SpecialabilityRulesDSA5}(i.Z);i.Z.children.SpecialabilityRulesDSA5=u},101:(t,r,a)=>{a.d(r,{Z:()=>u});var o=a(577),i=a(794),c=a(491);function _typeof(t){return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},_typeof(t)}function _regeneratorRuntime(){_regeneratorRuntime=function _regeneratorRuntime(){return t};var t={},r=Object.prototype,a=r.hasOwnProperty,o="function"==typeof Symbol?Symbol:{},i=o.iterator||"@@iterator",c=o.asyncIterator||"@@asyncIterator",u=o.toStringTag||"@@toStringTag";function define(t,r,a){return Object.defineProperty(t,r,{value:a,enumerable:!0,configurable:!0,writable:!0}),t[r]}try{define({},"")}catch(t){define=function define(t,r,a){return t[r]=a}}function wrap(t,r,a,o){var i=r&&r.prototype instanceof Generator?r:Generator,c=Object.create(i.prototype),u=new Context(o||[]);return c._invoke=function(t,r,a){var o="suspendedStart";return function(i,c){if("executing"===o)throw new Error("Generator is already running");if("completed"===o){if("throw"===i)throw c;return doneResult()}for(a.method=i,a.arg=c;;){var u=a.delegate;if(u){var p=maybeInvokeDelegate(u,a);if(p){if(p===l)continue;return p}}if("next"===a.method)a.sent=a._sent=a.arg;else if("throw"===a.method){if("suspendedStart"===o)throw o="completed",a.arg;a.dispatchException(a.arg)}else"return"===a.method&&a.abrupt("return",a.arg);o="executing";var d=tryCatch(t,r,a);if("normal"===d.type){if(o=a.done?"completed":"suspendedYield",d.arg===l)continue;return{value:d.arg,done:a.done}}"throw"===d.type&&(o="completed",a.method="throw",a.arg=d.arg)}}}(t,a,u),c}function tryCatch(t,r,a){try{return{type:"normal",arg:t.call(r,a)}}catch(t){return{type:"throw",arg:t}}}t.wrap=wrap;var l={};function Generator(){}function GeneratorFunction(){}function GeneratorFunctionPrototype(){}var p={};define(p,i,(function(){return this}));var d=Object.getPrototypeOf,h=d&&d(d(values([])));h&&h!==r&&a.call(h,i)&&(p=h);var m=GeneratorFunctionPrototype.prototype=Generator.prototype=Object.create(p);function defineIteratorMethods(t){["next","throw","return"].forEach((function(r){define(t,r,(function(t){return this._invoke(r,t)}))}))}function AsyncIterator(t,r){function invoke(o,i,c,u){var l=tryCatch(t[o],t,i);if("throw"!==l.type){var p=l.arg,d=p.value;return d&&"object"==_typeof(d)&&a.call(d,"__await")?r.resolve(d.__await).then((function(t){invoke("next",t,c,u)}),(function(t){invoke("throw",t,c,u)})):r.resolve(d).then((function(t){p.value=t,c(p)}),(function(t){return invoke("throw",t,c,u)}))}u(l.arg)}var o;this._invoke=function(t,a){function callInvokeWithMethodAndArg(){return new r((function(r,o){invoke(t,a,r,o)}))}return o=o?o.then(callInvokeWithMethodAndArg,callInvokeWithMethodAndArg):callInvokeWithMethodAndArg()}}function maybeInvokeDelegate(t,r){var a=t.iterator[r.method];if(void 0===a){if(r.delegate=null,"throw"===r.method){if(t.iterator.return&&(r.method="return",r.arg=void 0,maybeInvokeDelegate(t,r),"throw"===r.method))return l;r.method="throw",r.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var o=tryCatch(a,t.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,l;var i=o.arg;return i?i.done?(r[t.resultName]=i.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=void 0),r.delegate=null,l):i:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,l)}function pushTryEntry(t){var r={tryLoc:t[0]};1 in t&&(r.catchLoc=t[1]),2 in t&&(r.finallyLoc=t[2],r.afterLoc=t[3]),this.tryEntries.push(r)}function resetTryEntry(t){var r=t.completion||{};r.type="normal",delete r.arg,t.completion=r}function Context(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(pushTryEntry,this),this.reset(!0)}function values(t){if(t){var r=t[i];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var o=-1,c=function next(){for(;++o=0;--o){var i=this.tryEntries[o],c=i.completion;if("root"===i.tryLoc)return handle("end");if(i.tryLoc<=this.prev){var u=a.call(i,"catchLoc"),l=a.call(i,"finallyLoc");if(u&&l){if(this.prev=0;--o){var i=this.tryEntries[o];if(i.tryLoc<=this.prev&&a.call(i,"finallyLoc")&&this.prev=0;--r){var a=this.tryEntries[r];if(a.finallyLoc===t)return this.complete(a.completion,a.afterLoc),resetTryEntry(a),l}},catch:function _catch(t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc===t){var o=a.completion;if("throw"===o.type){var i=o.arg;resetTryEntry(a)}return i}}throw new Error("illegal catch attempt")},delegateYield:function delegateYield(t,r,a){return this.delegate={iterator:values(t),resultName:r,nextLoc:a},"next"===this.method&&(this.arg=void 0),l}},t}function asyncGeneratorStep(t,r,a,o,i,c,u){try{var l=t[c](u),p=l.value}catch(t){return void a(t)}l.done?r(p):Promise.resolve(p).then(o,i)}function _asyncToGenerator(t){return function(){var r=this,a=arguments;return new Promise((function(o,i){var c=t.apply(r,a);function _next(t){asyncGeneratorStep(c,o,i,_next,_throw,"next",t)}function _throw(t){asyncGeneratorStep(c,o,i,_next,_throw,"throw",t)}_next(void 0)}))}}function _classCallCheck(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}function _defineProperties(t,r){for(var a=0;a{a.d(r,{Z:()=>u});var o=a(369),i=a(846),c=a(577);function _typeof(t){return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},_typeof(t)}function _toConsumableArray(t){return function _arrayWithoutHoles(t){if(Array.isArray(t))return _arrayLikeToArray(t)}(t)||function _iterableToArray(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||_unsupportedIterableToArray(t)||function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function _createForOfIteratorHelper(t,r){var a="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!a){if(Array.isArray(t)||(a=_unsupportedIterableToArray(t))||r&&t&&"number"==typeof t.length){a&&(t=a);var o=0,i=function F(){};return{s:i,n:function n(){return o>=t.length?{done:!0}:{done:!1,value:t[o++]}},e:function e(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var c,u=!0,l=!1;return{s:function s(){a=a.call(t)},n:function n(){var t=a.next();return u=t.done,t},e:function e(t){l=!0,c=t},f:function f(){try{u||null==a.return||a.return()}finally{if(l)throw c}}}}function _unsupportedIterableToArray(t,r){if(t){if("string"==typeof t)return _arrayLikeToArray(t,r);var a=Object.prototype.toString.call(t).slice(8,-1);return"Object"===a&&t.constructor&&(a=t.constructor.name),"Map"===a||"Set"===a?Array.from(t):"Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a)?_arrayLikeToArray(t,r):void 0}}function _arrayLikeToArray(t,r){(null==r||r>t.length)&&(r=t.length);for(var a=0,o=new Array(r);a=0;--o){var i=this.tryEntries[o],c=i.completion;if("root"===i.tryLoc)return handle("end");if(i.tryLoc<=this.prev){var u=a.call(i,"catchLoc"),l=a.call(i,"finallyLoc");if(u&&l){if(this.prev=0;--o){var i=this.tryEntries[o];if(i.tryLoc<=this.prev&&a.call(i,"finallyLoc")&&this.prev=0;--r){var a=this.tryEntries[r];if(a.finallyLoc===t)return this.complete(a.completion,a.afterLoc),resetTryEntry(a),l}},catch:function _catch(t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc===t){var o=a.completion;if("throw"===o.type){var i=o.arg;resetTryEntry(a)}return i}}throw new Error("illegal catch attempt")},delegateYield:function delegateYield(t,r,a){return this.delegate={iterator:values(t),resultName:r,nextLoc:a},"next"===this.method&&(this.arg=void 0),l}},t}function asyncGeneratorStep(t,r,a,o,i,c,u){try{var l=t[c](u),p=l.value}catch(t){return void a(t)}l.done?r(p):Promise.resolve(p).then(o,i)}function _asyncToGenerator(t){return function(){var r=this,a=arguments;return new Promise((function(o,i){var c=t.apply(r,a);function _next(t){asyncGeneratorStep(c,o,i,_next,_throw,"next",t)}function _throw(t){asyncGeneratorStep(c,o,i,_next,_throw,"throw",t)}_next(void 0)}))}}function _defineProperties(t,r){for(var a=0;ar.system.price.value?-1:1})));case 4:case"end":return r.stop()}}),_callee5,this)}))),function allMoneyItems(){return m.apply(this,arguments)})},{key:"allSkillsList",value:(h=_asyncToGenerator(_regeneratorRuntime().mark((function _callee6(){return _regeneratorRuntime().wrap((function _callee6$(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.allSkills();case 2:if(t.t0=t.sent,t.t0){t.next=5;break}t.t0=[];case 5:return t.abrupt("return",t.t0.map((function(t){return t.name})).sort((function(t,r){return t.localeCompare(r)})));case 6:case"end":return t.stop()}}),_callee6,this)}))),function allSkillsList(){return h.apply(this,arguments)})},{key:"allCombatSkillsList",value:(d=_asyncToGenerator(_regeneratorRuntime().mark((function _callee7(t){return _regeneratorRuntime().wrap((function _callee7$(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,this.allCombatSkills();case 2:if(r.t0=r.sent.filter((function(r){return r.system.weapontype.value==t})),r.t0){r.next=5;break}r.t0=[];case 5:return r.abrupt("return",r.t0.map((function(t){return t.name})).sort((function(t,r){return t.localeCompare(r)})));case 6:case"end":return r.stop()}}),_callee7,this)}))),function allCombatSkillsList(t){return d.apply(this,arguments)})},{key:"callItemTransformationMacro",value:(p=_asyncToGenerator(_regeneratorRuntime().mark((function _callee8(t,r,a){var o,i,c,u,l,p,d,h,m=arguments;return _regeneratorRuntime().wrap((function _callee8$(y){for(;;)switch(y.prev=y.next){case 0:if(o=m.length>3&&void 0!==m[3]?m[3]:{},i=t.split("."),c=game.packs.get("".concat(i[0],".").concat(i[1]))){y.next=6;break}return console.warn("Pack ".concat(c," not found")),y.abrupt("return",{});case 6:return y.next=8,c.getDocuments({name:i[2]});case 8:if(u=y.sent,l={},!u.length){y.next=27;break}return p=u[0],d="(async () => {".concat(p.command,"})()"),h=Function("args","source","effect",d),y.prev=14,o.result=l,y.next=18,h.call(this,o,r,a);case 18:y.next=25;break;case 20:y.prev=20,y.t0=y.catch(14),ui.notifications.error("There was an error in your macro syntax. See the console (F12) for details"),console.error(y.t0),l.error=!0;case 25:y.next=28;break;case 27:ui.notifications.error(game.i18n.format("DSAError.macroNotFound",{name:t}));case 28:return y.abrupt("return",l);case 29:case"end":return y.stop()}}),_callee8,this,[[14,20]])}))),function callItemTransformationMacro(t,r,a){return p.apply(this,arguments)})},{key:"isActiveGM",value:function isActiveGM(){var t;return null===(t=game.users.activeGM)||void 0===t?void 0:t.isSelf}},{key:"parseAbilityString",value:function parseAbilityString(t){return{original:t.replace(/ (FP|SR|FW|SP)?[+-]?\d{1,2}$/,"").trim(),name:t.replace(/\((.+?)\)/g,"()").replace(/ (FP|SR|FW|SP)?[+-]?\d{1,2}$/,"").trim(),step:Number((t.match(/[+-]?\d{1,2}$/)||[1])[0]),special:(t.match(/\(([^()]+)\)/)||["",""])[1],type:t.match(/ (FP|SP)[+-]?\d{1,2}/)?"FP":t.match(/ (FW|SR)[+-]?\d{1,2}/)?"FW":"",bonus:null!=t.match(/[-+]\d{1,2}$/)}}},{key:"categoryLocalization",value:function categoryLocalization(t){return game.i18n.localize("TYPES.Item.".concat(t))}},{key:"attributeLocalization",value:function attributeLocalization(t){return game.i18n.localize("CHAR.".concat(t.toUpperCase()))}},{key:"attributeAbbrLocalization",value:function attributeAbbrLocalization(t){return game.i18n.localize("CHARAbbrev.".concat(t.toUpperCase()))}},{key:"callAsyncHooks",value:(l=_asyncToGenerator(_regeneratorRuntime().mark((function _callee9(t,r){var a,o,i;return _regeneratorRuntime().wrap((function _callee9$(u){for(;;)switch(u.prev=u.next){case 0:a=_createForOfIteratorHelper(c.Z.asyncHooks[t]),u.prev=1,a.s();case 3:if((o=a.n()).done){u.next=9;break}return i=o.value,u.next=7,i.apply(void 0,_toConsumableArray(r));case 7:u.next=3;break;case 9:u.next=14;break;case 11:u.prev=11,u.t0=u.catch(1),a.e(u.t0);case 14:return u.prev=14,a.f(),u.finish(14);case 17:case"end":return u.stop()}}),_callee9,null,[[1,11,14,17]])}))),function callAsyncHooks(t,r){return l.apply(this,arguments)})},{key:"chatDataSetup",value:function chatDataSetup(t,r,a,o){var i={user:game.user.id,rollMode:r||game.settings.get("core","rollMode"),content:t};return["gmroll","blindroll"].includes(i.rollMode)&&(i.whisper=ChatMessage.getWhisperRecipients("GM").map((function(t){return t.id}))),"blindroll"===i.rollMode?i.blind=!0:"selfroll"===i.rollMode&&(i.whisper=[game.user]),a&&(i.speaker=ChatMessage.getSpeaker(),i.whisper=ChatMessage.getWhisperRecipients(a)),o&&(i.speaker=ChatMessage.getSpeaker(),i.whisper=o),i}},{key:"getSpeaker",value:function getSpeaker(t){var r=ChatMessage.getSpeakerActor(t);if(!r&&canvas.tokens){var a=canvas.tokens.get(t.token);a&&(r=a.actor)}if(!r){var o=game.scenes.get(t.scene);try{var i;o&&(r=null===(i=new Token(o.getEmbeddedDocument("Token",t.token)))||void 0===i?void 0:i.actor)}catch(t){}}return r}},{key:"fateAvailable",value:function fateAvailable(t,r){return r?game.settings.get("dsa5","groupschips").split("/").map((function(t){return Number(t)}))[0]>0:t.system.status.fatePoints.value>0}},{key:"_calculateAdvCost",value:function _calculateAdvCost(t,r){var a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1;return c.Z.advancementCosts[r][Number(t)+a]}},{key:"getFolderForType",value:(u=_asyncToGenerator(_regeneratorRuntime().mark((function _callee10(t){var r,a,o,i,c,u,l=arguments;return _regeneratorRuntime().wrap((function _callee10$(p){for(;;)switch(p.prev=p.next){case 0:return r=l.length>1&&void 0!==l[1]?l[1]:null,a=l.length>2&&void 0!==l[2]?l[2]:null,o=l.length>3&&void 0!==l[3]?l[3]:0,i=l.length>4&&void 0!==l[4]?l[4]:"",c=l.length>5&&void 0!==l[5]?l[5]:void 0,p.next=7,game.folders.contents.find((function(o){var i;return o.name==a&&o.type==t&&(null===(i=o.folder)||void 0===i?void 0:i.id)==r}));case 7:if(u=p.sent){p.next=12;break}return p.next=11,Folder.create({name:a,type:t,sorting:c||("JournalEntry"==t?"a":"m"),color:i,sort:o,parent:r});case 11:u=p.sent;case 12:return p.abrupt("return",u);case 13:case"end":return p.stop()}}),_callee10)}))),function getFolderForType(t){return u.apply(this,arguments)})},{key:"toObjectIfPossible",value:function toObjectIfPossible(t){return"function"==typeof t.toObject?t.toObject(!1):duplicate(t)}},{key:"showArtwork",value:(a=_asyncToGenerator(_regeneratorRuntime().mark((function _callee11(t){var r,a,o,i,c,u=arguments;return _regeneratorRuntime().wrap((function _callee11$(l){for(;;)switch(l.prev=l.next){case 0:return r=t.img,a=t.name,o=t.uuid,i=t.isOwner,c=u.length>1&&void 0!==u[1]&&u[1],l.abrupt("return",new ImagePopout(r,{title:c?i?a:"-":a,shareable:!0,uuid:o}).render(!0));case 3:case"end":return l.stop()}}),_callee11)}))),function showArtwork(t){return a.apply(this,arguments)})},{key:"findAnyItem",value:(r=_asyncToGenerator(_regeneratorRuntime().mark((function _callee12(t){var r,a,o,i,c,u,l,p,d,h,m,y,g;return _regeneratorRuntime().wrap((function _callee12$(v){for(;;)switch(v.prev=v.next){case 0:r=[],a=t.map((function(t){return t.name})),o=t.map((function(t){return t.type})),i=_createForOfIteratorHelper(game.items.contents),v.prev=4,i.s();case 6:if((c=i.n()).done){v.next=14;break}if(u=c.value,(l=a.indexOf(u.name))>=0&&o[l]==u.type&&(a.splice(l,1),o.splice(l,1),r.push(u.toObject())),!(a.length<=0)){v.next=12;break}return v.abrupt("break",14);case 12:v.next=6;break;case 14:v.next=19;break;case 16:v.prev=16,v.t0=v.catch(4),i.e(v.t0);case 19:return v.prev=19,i.f(),v.finish(19);case 22:if(!(a.length>0)){v.next=46;break}p=/^dsa5-core/,d=Array.from(game.packs.keys()).sort((function(t,r){return p.test(t)&&p.test(r)&&t.localeCompare(r),p.test(r)?-1:p.test(t)?1:t.localeCompare(r)})),h=_createForOfIteratorHelper(d),v.prev=26,h.s();case 28:if((m=h.n()).done){v.next=38;break}if(y=m.value,"Item"!=(g=game.packs.get(y)).documentName||!game.user.isGM&&g.private){v.next=36;break}return v.next=34,g.getDocuments({name__in:a,type__in:o}).then((function(t){var i,c=_createForOfIteratorHelper(t);try{for(c.s();!(i=c.n()).done;){var u=i.value,l=a.indexOf(u.name);l>=0&&o[l]==u.type&&(a.splice(l,1),o.splice(l,1),r.push(u.toObject()))}}catch(t){c.e(t)}finally{c.f()}}));case 34:if(!(a.length<=0)){v.next=36;break}return v.abrupt("break",38);case 36:v.next=28;break;case 38:v.next=43;break;case 40:v.prev=40,v.t1=v.catch(26),h.e(v.t1);case 43:return v.prev=43,h.f(),v.finish(43);case 46:return v.abrupt("return",r);case 47:case"end":return v.stop()}}),_callee12,null,[[4,16,19,22],[26,40,43,46]])}))),function findAnyItem(t){return r.apply(this,arguments)})},{key:"replaceDies",value:function replaceDies(t){var r=arguments.length>1&&void 0!==arguments[1]&&arguments[1],a=/( |^)(\d{1,2})?[wWdD][0-9]+((\+|-)[0-9]+)?/g,o=r?"":"/r ";return t.replace(a,(function(t){return" [[".concat(o).concat(t.replace(/[DwW]/,"d"),"]]")}))}},{key:"escapeRegex",value:function escapeRegex(t){return("string"==typeof t||t instanceof String?t:"").replace(/[-[/\]{}()*+?.,\\^$|#\s]/g,"\\$&")}},{key:"replaceConditions",value:function replaceConditions(t){return t?t.replace(c.Z.statusRegex.regex,(function(t){return(0,i.q)([t])})):t}},{key:"experienceDescription",value:function experienceDescription(t){for(var r=["EXP.legendary","EXP.brillant","EXP.masterful","EXP.competent","EXP.experienced","EXP.average"],a=0,o=0,i=[2100,1700,1400,1200,1100,1e3];o=Number(c))return r[a];a++}return"EXP.inexperienced"}},{key:"emptyActor",value:(t=_asyncToGenerator(_regeneratorRuntime().mark((function _callee13(){var t,r,a,i=arguments;return _regeneratorRuntime().wrap((function _callee13$(c){for(;;)switch(c.prev=c.next){case 0:return t=i.length>0&&void 0!==i[0]?i[0]:12,r=i.length>1&&void 0!==i[1]?i[1]:"Alrik",Array.isArray(t)||(t=[t,t,t,t,t,t,t,t]),c.next=5,o.Z.create({name:r,type:"npc",items:[],system:{status:{wounds:{value:50},fatePoints:{}},characteristics:{mu:{initial:t[0]},kl:{initial:t[1]},in:{initial:t[2]},ch:{initial:t[3]},ff:{initial:t[4]},ge:{initial:t[5]},ko:{initial:t[6]},kk:{initial:t[7]}}}},{temporary:!0,noHook:!0});case 5:return(a=c.sent).prepareData(),c.abrupt("return",a);case 8:case"end":return c.stop()}}),_callee13)}))),function emptyActor(){return t.apply(this,arguments)})}]),DSA5_Utility}()},707:(t,r,a)=>{function _typeof(t){return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},_typeof(t)}function _regeneratorRuntime(){_regeneratorRuntime=function _regeneratorRuntime(){return t};var t={},r=Object.prototype,a=r.hasOwnProperty,o="function"==typeof Symbol?Symbol:{},i=o.iterator||"@@iterator",c=o.asyncIterator||"@@asyncIterator",u=o.toStringTag||"@@toStringTag";function define(t,r,a){return Object.defineProperty(t,r,{value:a,enumerable:!0,configurable:!0,writable:!0}),t[r]}try{define({},"")}catch(t){define=function define(t,r,a){return t[r]=a}}function wrap(t,r,a,o){var i=r&&r.prototype instanceof Generator?r:Generator,c=Object.create(i.prototype),u=new Context(o||[]);return c._invoke=function(t,r,a){var o="suspendedStart";return function(i,c){if("executing"===o)throw new Error("Generator is already running");if("completed"===o){if("throw"===i)throw c;return doneResult()}for(a.method=i,a.arg=c;;){var u=a.delegate;if(u){var p=maybeInvokeDelegate(u,a);if(p){if(p===l)continue;return p}}if("next"===a.method)a.sent=a._sent=a.arg;else if("throw"===a.method){if("suspendedStart"===o)throw o="completed",a.arg;a.dispatchException(a.arg)}else"return"===a.method&&a.abrupt("return",a.arg);o="executing";var d=tryCatch(t,r,a);if("normal"===d.type){if(o=a.done?"completed":"suspendedYield",d.arg===l)continue;return{value:d.arg,done:a.done}}"throw"===d.type&&(o="completed",a.method="throw",a.arg=d.arg)}}}(t,a,u),c}function tryCatch(t,r,a){try{return{type:"normal",arg:t.call(r,a)}}catch(t){return{type:"throw",arg:t}}}t.wrap=wrap;var l={};function Generator(){}function GeneratorFunction(){}function GeneratorFunctionPrototype(){}var p={};define(p,i,(function(){return this}));var d=Object.getPrototypeOf,h=d&&d(d(values([])));h&&h!==r&&a.call(h,i)&&(p=h);var m=GeneratorFunctionPrototype.prototype=Generator.prototype=Object.create(p);function defineIteratorMethods(t){["next","throw","return"].forEach((function(r){define(t,r,(function(t){return this._invoke(r,t)}))}))}function AsyncIterator(t,r){function invoke(o,i,c,u){var l=tryCatch(t[o],t,i);if("throw"!==l.type){var p=l.arg,d=p.value;return d&&"object"==_typeof(d)&&a.call(d,"__await")?r.resolve(d.__await).then((function(t){invoke("next",t,c,u)}),(function(t){invoke("throw",t,c,u)})):r.resolve(d).then((function(t){p.value=t,c(p)}),(function(t){return invoke("throw",t,c,u)}))}u(l.arg)}var o;this._invoke=function(t,a){function callInvokeWithMethodAndArg(){return new r((function(r,o){invoke(t,a,r,o)}))}return o=o?o.then(callInvokeWithMethodAndArg,callInvokeWithMethodAndArg):callInvokeWithMethodAndArg()}}function maybeInvokeDelegate(t,r){var a=t.iterator[r.method];if(void 0===a){if(r.delegate=null,"throw"===r.method){if(t.iterator.return&&(r.method="return",r.arg=void 0,maybeInvokeDelegate(t,r),"throw"===r.method))return l;r.method="throw",r.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var o=tryCatch(a,t.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,l;var i=o.arg;return i?i.done?(r[t.resultName]=i.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=void 0),r.delegate=null,l):i:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,l)}function pushTryEntry(t){var r={tryLoc:t[0]};1 in t&&(r.catchLoc=t[1]),2 in t&&(r.finallyLoc=t[2],r.afterLoc=t[3]),this.tryEntries.push(r)}function resetTryEntry(t){var r=t.completion||{};r.type="normal",delete r.arg,t.completion=r}function Context(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(pushTryEntry,this),this.reset(!0)}function values(t){if(t){var r=t[i];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var o=-1,c=function next(){for(;++o=0;--o){var i=this.tryEntries[o],c=i.completion;if("root"===i.tryLoc)return handle("end");if(i.tryLoc<=this.prev){var u=a.call(i,"catchLoc"),l=a.call(i,"finallyLoc");if(u&&l){if(this.prev=0;--o){var i=this.tryEntries[o];if(i.tryLoc<=this.prev&&a.call(i,"finallyLoc")&&this.prev=0;--r){var a=this.tryEntries[r];if(a.finallyLoc===t)return this.complete(a.completion,a.afterLoc),resetTryEntry(a),l}},catch:function _catch(t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc===t){var o=a.completion;if("throw"===o.type){var i=o.arg;resetTryEntry(a)}return i}}throw new Error("illegal catch attempt")},delegateYield:function delegateYield(t,r,a){return this.delegate={iterator:values(t),resultName:r,nextLoc:a},"next"===this.method&&(this.arg=void 0),l}},t}function _createForOfIteratorHelper(t,r){var a="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!a){if(Array.isArray(t)||(a=function _unsupportedIterableToArray(t,r){if(!t)return;if("string"==typeof t)return _arrayLikeToArray(t,r);var a=Object.prototype.toString.call(t).slice(8,-1);"Object"===a&&t.constructor&&(a=t.constructor.name);if("Map"===a||"Set"===a)return Array.from(t);if("Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a))return _arrayLikeToArray(t,r)}(t))||r&&t&&"number"==typeof t.length){a&&(t=a);var o=0,i=function F(){};return{s:i,n:function n(){return o>=t.length?{done:!0}:{done:!1,value:t[o++]}},e:function e(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var c,u=!0,l=!1;return{s:function s(){a=a.call(t)},n:function n(){var t=a.next();return u=t.done,t},e:function e(t){l=!0,c=t},f:function f(){try{u||null==a.return||a.return()}finally{if(l)throw c}}}}function _arrayLikeToArray(t,r){(null==r||r>t.length)&&(r=t.length);for(var a=0,o=new Array(r);a1&&void 0!==arguments[1]?arguments[1]:320,a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:40;t.attr({width:.8*r,viewBox:"0 0 ".concat(r," ").concat(a)});var o=t.find("text"),i=o.get(0).getBBox(),c=r/i.width,u=a/i.height,l=c2&&void 0!==p[2])||p[2],"Actor"!=t.type){d.next=8;break}return d.next=4,Actor.implementation.fromDropData(t);case 4:i=d.sent,c=r===i.id,d.next=12;break;case 8:return d.next=10,Item.implementation.fromDropData(t);case 10:i=d.sent,c=r===(null===(u=i.parent)||void 0===u?void 0:u.uuid);case 12:return l=null===(a=i)||void 0===a?void 0:a.type,o&&(i=i.toObject()),t.amount&&(i.system.quantity.value=Number(t.amount)),d.abrupt("return",{item:i,typeClass:l,selfTarget:c});case 16:case"end":return d.stop()}}),_callee2)}))),_itemFromDrop.apply(this,arguments)}function slist(t,r,a){var o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"div";if(r=t.find(r)[0]){r.classList.add("slist");var i,c=r.querySelectorAll(o),u=null,l=_createForOfIteratorHelper(c);try{for(l.s();!(i=l.n()).done;){var p=i.value;p.draggable=!0,p.addEventListener("dragstart",(function(t){u=this})),p.addEventListener("dragover",(function(t){t.preventDefault()})),p.addEventListener("drop",function(){var t=_asyncToGenerator(_regeneratorRuntime().mark((function _callee(t){var o,i,l;return _regeneratorRuntime().wrap((function _callee$(p){for(;;)switch(p.prev=p.next){case 0:if(t.preventDefault(),this==u){p.next=7;break}for(o=0,i=0,l=0;l'),r=$(".tinyNotifications"));var a=$("
  • ".concat(t,"
  • "));r.prepend(a),setTimeout((function(){a.remove()}),1500)}function IconVisibility(t,r,a,o){var i=Math.ceil(r.scrollLeft),c=r.scrollWidth-r.clientWidth;a.style.display=i>0?"block":"none",o.style.display=c>i?"block":"none",function columnLayout(t){var r=t.width(),a=Number(getComputedStyle(document.body).getPropertyValue("--minColumnWidth").replace("px","")),o=Number(getComputedStyle(document.body).getPropertyValue("--minColumnWidth60").replace("px",""));r>=2*a+6?t.removeClass("singleColumnLayout"):t.addClass("singleColumnLayout");r<=o?t.addClass("minimumColumnLayout"):t.removeClass("minimumColumnLayout")}(t)}function clickableAbility(t){return _clickableAbility.apply(this,arguments)}function _clickableAbility(){return(_clickableAbility=_asyncToGenerator(_regeneratorRuntime().mark((function _callee3(t){var r,a,o,i,c,u,l,p,d,h,m,y;return _regeneratorRuntime().wrap((function _callee3$(g){for(;;)switch(g.prev=g.next){case 0:r=$(t.currentTarget).closest(".searchableAbility")[0].dataset.category.split(" "),a=t.currentTarget.text.replace(/\d+$/,"").trim(),o=_createForOfIteratorHelper(r),g.prev=3,o.s();case 5:if((i=o.n()).done){g.next=16;break}return c=i.value,g.next=9,game.dsa5.itemLibrary.findCompendiumItem(a,c);case 9:if(u=g.sent,!(l=u.find((function(t){return t.name==a})))){g.next=14;break}return l.sheet.render(!0),g.abrupt("return");case 14:g.next=5;break;case 16:g.next=21;break;case 18:g.prev=18,g.t0=g.catch(3),o.e(g.t0);case 21:return g.prev=21,o.f(),g.finish(21);case 24:if(!/\(/.test(a)){g.next=48;break}a=a.split("(")[0].trim()+" ()",p=_createForOfIteratorHelper(r),g.prev=27,p.s();case 29:if((d=p.n()).done){g.next=40;break}return h=d.value,g.next=33,game.dsa5.itemLibrary.findCompendiumItem(a,h);case 33:if(m=g.sent,!(y=m.find((function(t){return t.name==a})))){g.next=38;break}return y.sheet.render(!0),g.abrupt("return");case 38:g.next=29;break;case 40:g.next=45;break;case 42:g.prev=42,g.t1=g.catch(27),p.e(g.t1);case 45:return g.prev=45,p.f(),g.finish(45);case 48:case"end":return g.stop()}}),_callee3,null,[[3,18,21,24],[27,42,45,48]])})))).apply(this,arguments)}function tabSlider(t){var r,a=_createForOfIteratorHelper(t.find(".navWrapper"));try{var o=function _loop(){var a=r.value,o=a.querySelector(".left-btn"),i=a.querySelector(".right-btn"),c=a.querySelector(".sheet-tabs"),u=!1;i.addEventListener("click",(function(){c.scrollLeft+=150,setTimeout((function(){return IconVisibility(t,c,o,i)}),500)})),o.addEventListener("click",(function(){c.scrollLeft-=150,setTimeout((function(){return IconVisibility(t,c,o,i)}),500)})),new ResizeObserver((function(){return IconVisibility(t,c,o,i)})).observe(a),c.addEventListener("mousemove",(function(r){u&&(c.scrollLeft-=r.movementX,setTimeout((function(){return IconVisibility(t,c,o,i)}),500))})),c.addEventListener("mousedown",(function(){u=!0,c.classList.add("dragging"),document.addEventListener("mouseup",(function(){u=!1,c.classList.remove("dragging")}),{once:!0})}))};for(a.s();!(r=a.n()).done;)o()}catch(t){a.e(t)}finally{a.f()}}a.d(r,{$8:()=>clickableAbility,Ee:()=>tabSlider,Jp:()=>slist,gw:()=>delay,p0:()=>tinyNotification,x8:()=>itemFromDrop,zJ:()=>svgAutoFit});var o=function appHeight(){document.documentElement.style.setProperty("--app-height","".concat(window.innerHeight,"px"))};window.addEventListener("resize",o),o()},430:(t,r,a)=>{a.d(r,{Z:()=>u});var o=a(577),i=a(604),c=a(491);function _typeof(t){return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},_typeof(t)}function _regeneratorRuntime(){_regeneratorRuntime=function _regeneratorRuntime(){return t};var t={},r=Object.prototype,a=r.hasOwnProperty,o="function"==typeof Symbol?Symbol:{},i=o.iterator||"@@iterator",c=o.asyncIterator||"@@asyncIterator",u=o.toStringTag||"@@toStringTag";function define(t,r,a){return Object.defineProperty(t,r,{value:a,enumerable:!0,configurable:!0,writable:!0}),t[r]}try{define({},"")}catch(t){define=function define(t,r,a){return t[r]=a}}function wrap(t,r,a,o){var i=r&&r.prototype instanceof Generator?r:Generator,c=Object.create(i.prototype),u=new Context(o||[]);return c._invoke=function(t,r,a){var o="suspendedStart";return function(i,c){if("executing"===o)throw new Error("Generator is already running");if("completed"===o){if("throw"===i)throw c;return doneResult()}for(a.method=i,a.arg=c;;){var u=a.delegate;if(u){var p=maybeInvokeDelegate(u,a);if(p){if(p===l)continue;return p}}if("next"===a.method)a.sent=a._sent=a.arg;else if("throw"===a.method){if("suspendedStart"===o)throw o="completed",a.arg;a.dispatchException(a.arg)}else"return"===a.method&&a.abrupt("return",a.arg);o="executing";var d=tryCatch(t,r,a);if("normal"===d.type){if(o=a.done?"completed":"suspendedYield",d.arg===l)continue;return{value:d.arg,done:a.done}}"throw"===d.type&&(o="completed",a.method="throw",a.arg=d.arg)}}}(t,a,u),c}function tryCatch(t,r,a){try{return{type:"normal",arg:t.call(r,a)}}catch(t){return{type:"throw",arg:t}}}t.wrap=wrap;var l={};function Generator(){}function GeneratorFunction(){}function GeneratorFunctionPrototype(){}var p={};define(p,i,(function(){return this}));var d=Object.getPrototypeOf,h=d&&d(d(values([])));h&&h!==r&&a.call(h,i)&&(p=h);var m=GeneratorFunctionPrototype.prototype=Generator.prototype=Object.create(p);function defineIteratorMethods(t){["next","throw","return"].forEach((function(r){define(t,r,(function(t){return this._invoke(r,t)}))}))}function AsyncIterator(t,r){function invoke(o,i,c,u){var l=tryCatch(t[o],t,i);if("throw"!==l.type){var p=l.arg,d=p.value;return d&&"object"==_typeof(d)&&a.call(d,"__await")?r.resolve(d.__await).then((function(t){invoke("next",t,c,u)}),(function(t){invoke("throw",t,c,u)})):r.resolve(d).then((function(t){p.value=t,c(p)}),(function(t){return invoke("throw",t,c,u)}))}u(l.arg)}var o;this._invoke=function(t,a){function callInvokeWithMethodAndArg(){return new r((function(r,o){invoke(t,a,r,o)}))}return o=o?o.then(callInvokeWithMethodAndArg,callInvokeWithMethodAndArg):callInvokeWithMethodAndArg()}}function maybeInvokeDelegate(t,r){var a=t.iterator[r.method];if(void 0===a){if(r.delegate=null,"throw"===r.method){if(t.iterator.return&&(r.method="return",r.arg=void 0,maybeInvokeDelegate(t,r),"throw"===r.method))return l;r.method="throw",r.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var o=tryCatch(a,t.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,l;var i=o.arg;return i?i.done?(r[t.resultName]=i.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=void 0),r.delegate=null,l):i:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,l)}function pushTryEntry(t){var r={tryLoc:t[0]};1 in t&&(r.catchLoc=t[1]),2 in t&&(r.finallyLoc=t[2],r.afterLoc=t[3]),this.tryEntries.push(r)}function resetTryEntry(t){var r=t.completion||{};r.type="normal",delete r.arg,t.completion=r}function Context(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(pushTryEntry,this),this.reset(!0)}function values(t){if(t){var r=t[i];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var o=-1,c=function next(){for(;++o=0;--o){var i=this.tryEntries[o],c=i.completion;if("root"===i.tryLoc)return handle("end");if(i.tryLoc<=this.prev){var u=a.call(i,"catchLoc"),l=a.call(i,"finallyLoc");if(u&&l){if(this.prev=0;--o){var i=this.tryEntries[o];if(i.tryLoc<=this.prev&&a.call(i,"finallyLoc")&&this.prev=0;--r){var a=this.tryEntries[r];if(a.finallyLoc===t)return this.complete(a.completion,a.afterLoc),resetTryEntry(a),l}},catch:function _catch(t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc===t){var o=a.completion;if("throw"===o.type){var i=o.arg;resetTryEntry(a)}return i}}throw new Error("illegal catch attempt")},delegateYield:function delegateYield(t,r,a){return this.delegate={iterator:values(t),resultName:r,nextLoc:a},"next"===this.method&&(this.arg=void 0),l}},t}function _createForOfIteratorHelper(t,r){var a="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!a){if(Array.isArray(t)||(a=function _unsupportedIterableToArray(t,r){if(!t)return;if("string"==typeof t)return _arrayLikeToArray(t,r);var a=Object.prototype.toString.call(t).slice(8,-1);"Object"===a&&t.constructor&&(a=t.constructor.name);if("Map"===a||"Set"===a)return Array.from(t);if("Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a))return _arrayLikeToArray(t,r)}(t))||r&&t&&"number"==typeof t.length){a&&(t=a);var o=0,i=function F(){};return{s:i,n:function n(){return o>=t.length?{done:!0}:{done:!1,value:t[o++]}},e:function e(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var c,u=!0,l=!1;return{s:function s(){a=a.call(t)},n:function n(){var t=a.next();return u=t.done,t},e:function e(t){l=!0,c=t},f:function f(){try{u||null==a.return||a.return()}finally{if(l)throw c}}}}function _arrayLikeToArray(t,r){(null==r||r>t.length)&&(r=t.length);for(var a=0,o=new Array(r);a1&&void 0!==v[1]?v[1]:{}).speaker={token:t.token,actor:t.actor,scene:t.scene},r.source=t.source,a=o.Z.systemTables.find((function(r){return r.name==t.table})),_.next=6,DSATables.getRollTable(a.pack[game.i18n.lang],game.i18n.localize("TABLENAMES.".concat(t.table)),t);case 6:i=_.sent,u=_createForOfIteratorHelper(i),_.prev=8,u.s();case 10:if((l=u.n()).done){_.next=31;break}if(p=l.value,!r.speaker){_.next=18;break}return _.next=15,DSATables.hasEffect(p);case 15:_.t0=_.sent,_.next=19;break;case 18:_.t0=!1;case 19:return d=_.t0,h=c.Z.replaceDies(c.Z.replaceConditions(p.results[0].text)),m="".concat(game.i18n.localize("TABLENAMES."+t.table)),_.next=24,renderTemplate("systems/dsa5/templates/tables/tableCard.html",{result:h,title:m,hasEffect:d});case 24:return y=_.sent,_.next=27,this.buildEffects(p,d);case 27:g=_.sent,ChatMessage.create({user:game.user.id,content:y,whisper:r.whisper,blind:r.blind,flags:{data:{preData:{source:{effects:g},extra:{actor:{id:r.speaker.actor},speaker:r.speaker},situationalModifiers:[]},postData:{}},dsa5:{hasEffect:d,options:r}}});case 29:_.next=10;break;case 31:_.next=36;break;case 33:_.prev=33,_.t1=_.catch(8),u.e(_.t1);case 36:return _.prev=36,u.f(),_.finish(36);case 39:case"end":return _.stop()}}),_callee,this,[[8,33,36,39]])}))),function showBotchCard(t){return p.apply(this,arguments)})},{key:"hasEffect",value:(l=_asyncToGenerator(_regeneratorRuntime().mark((function _callee2(t){return _regeneratorRuntime().wrap((function _callee2$(r){for(;;)switch(r.prev=r.next){case 0:return r.abrupt("return",getProperty(t.results[0],"flags.dsa5")||!1);case 1:case"end":return r.stop()}}),_callee2)}))),function hasEffect(t){return l.apply(this,arguments)})},{key:"buildEffects",value:(u=_asyncToGenerator(_regeneratorRuntime().mark((function _callee3(t,r){var a,o,c,u,l,p;return _regeneratorRuntime().wrap((function _callee3$(t){for(;;)switch(t.prev=t.next){case 0:if(a=[],r&&r.resistEffect){o=Array.isArray(r.resistEffect.fail)?r.resistEffect.fail:[r.resistEffect.fail],c=_createForOfIteratorHelper(o);try{for(c.s();!(u=c.n()).done;)l=u.value,p=(new i.Z).effectDummy(l.description,r.resistEffect.changes||[],r.resistEffect.duration||{}),l.systemEffect?mergeObject(p,{_id:"botchEffect",flags:{dsa5:{hideOnToken:!1,hidePlayers:!1,advancedFunction:2,args3:'await actor.addCondition("'.concat(l.systemEffect,'", ').concat(l.level||1,");")}}}):l.command&&mergeObject(p,{_id:"botchEffect",flags:{dsa5:{hideOnToken:!1,hidePlayers:!1,advancedFunction:2,args3:l.command}}}),a.push(p)}catch(t){c.e(t)}finally{c.f()}}return t.abrupt("return",a);case 3:case"end":return t.stop()}}),_callee3)}))),function buildEffects(t,r){return u.apply(this,arguments)})},{key:"getRollTable",value:(a=_asyncToGenerator(_regeneratorRuntime().mark((function _callee4(t,r){var a,o,i,c,u=arguments;return _regeneratorRuntime().wrap((function _callee4$(l){for(;;)switch(l.prev=l.next){case 0:return a=u.length>2&&void 0!==u[2]?u[2]:{},o=game.packs.get(t),l.next=4,o.getDocuments({name__in:[r]});case 4:return i=l.sent[0],l.next=7,i.draw({displayChat:!1});case 7:if(c=l.sent,!("true"==a.weaponless&&c.roll.total<7)){l.next=13;break}return c.roll.editRollAtIndex([{index:0,val:c.roll.total+5}]),l.next=12,i.draw({displayChat:!1,roll:c.roll});case 12:c=l.sent;case 13:return l.abrupt("return",[c]);case 14:case"end":return l.stop()}}),_callee4)}))),function getRollTable(t,r){return a.apply(this,arguments)})},{key:"tableEnabledFor",value:(r=_asyncToGenerator(_regeneratorRuntime().mark((function _callee5(t){var r;return _regeneratorRuntime().wrap((function _callee5$(a){for(;;)switch(a.prev=a.next){case 0:return r=o.Z.systemTables.find((function(r){return r.name==t})),a.abrupt("return",!!r&&game.settings.get(r.setting.module,r.setting.key));case 2:case"end":return a.stop()}}),_callee5)}))),function tableEnabledFor(t){return r.apply(this,arguments)})},{key:"rollCritBotchButton",value:function rollCritBotchButton(t,r,a){var o=game.i18n.localize("TABLENAMES.".concat(t)),i=a.extra.speaker,c=a.source._id;return', ').concat(o,"")}},{key:"defaultBotch",value:(t=_asyncToGenerator(_regeneratorRuntime().mark((function _callee6(){return _regeneratorRuntime().wrap((function _callee6$(t){for(;;)switch(t.prev=t.next){case 0:return t.t0=", "+game.i18n.localize("selfDamage"),t.next=3,new Roll("1d6+2").evaluate({async:!0});case 3:return t.t1=t.sent.total,t.abrupt("return",t.t0+t.t1);case 5:case"end":return t.stop()}}),_callee6)}))),function defaultBotch(){return t.apply(this,arguments)})},{key:"defaultAttackCrit",value:function defaultAttackCrit(t){var r=", "+game.i18n.localize("halfDefense");return t&&(r+=", "+game.i18n.format("doubleDamage",{x:2})),r}},{key:"defaultParryCrit",value:function defaultParryCrit(){return", "+game.i18n.localize("attackOfOpportunity")}}]),DSATables}()},585:(t,r,a)=>{a.d(r,{Z:()=>d});var o=a(369),i=a(61),c=a(472),u=a(702),l=a(491),p=a(604);function _typeof(t){return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},_typeof(t)}function _createForOfIteratorHelper(t,r){var a="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!a){if(Array.isArray(t)||(a=function _unsupportedIterableToArray(t,r){if(!t)return;if("string"==typeof t)return _arrayLikeToArray(t,r);var a=Object.prototype.toString.call(t).slice(8,-1);"Object"===a&&t.constructor&&(a=t.constructor.name);if("Map"===a||"Set"===a)return Array.from(t);if("Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a))return _arrayLikeToArray(t,r)}(t))||r&&t&&"number"==typeof t.length){a&&(t=a);var o=0,i=function F(){};return{s:i,n:function n(){return o>=t.length?{done:!0}:{done:!1,value:t[o++]}},e:function e(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var c,u=!0,l=!1;return{s:function s(){a=a.call(t)},n:function n(){var t=a.next();return u=t.done,t},e:function e(t){l=!0,c=t},f:function f(){try{u||null==a.return||a.return()}finally{if(l)throw c}}}}function _arrayLikeToArray(t,r){(null==r||r>t.length)&&(r=t.length);for(var a=0,o=new Array(r);a=0;--o){var i=this.tryEntries[o],c=i.completion;if("root"===i.tryLoc)return handle("end");if(i.tryLoc<=this.prev){var u=a.call(i,"catchLoc"),l=a.call(i,"finallyLoc");if(u&&l){if(this.prev=0;--o){var i=this.tryEntries[o];if(i.tryLoc<=this.prev&&a.call(i,"finallyLoc")&&this.prev=0;--r){var a=this.tryEntries[r];if(a.finallyLoc===t)return this.complete(a.completion,a.afterLoc),resetTryEntry(a),l}},catch:function _catch(t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc===t){var o=a.completion;if("throw"===o.type){var i=o.arg;resetTryEntry(a)}return i}}throw new Error("illegal catch attempt")},delegateYield:function delegateYield(t,r,a){return this.delegate={iterator:values(t),resultName:r,nextLoc:a},"next"===this.method&&(this.arg=void 0),l}},t}function asyncGeneratorStep(t,r,a,o,i,c,u){try{var l=t[c](u),p=l.value}catch(t){return void a(t)}l.done?r(p):Promise.resolve(p).then(o,i)}function _asyncToGenerator(t){return function(){var r=this,a=arguments;return new Promise((function(o,i){var c=t.apply(r,a);function _next(t){asyncGeneratorStep(c,o,i,_next,_throw,"next",t)}function _throw(t){asyncGeneratorStep(c,o,i,_next,_throw,"throw",t)}_next(void 0)}))}}function _defineProperties(t,r){for(var a=0;a/,'hideAnchor">'))});case 23:case"end":return _.stop()}}),_callee)}))),function applyEffect(t,r){return _.apply(this,arguments)})},{key:"damageModifier",value:(v=_asyncToGenerator(_regeneratorRuntime().mark((function _callee2(t,r,a,o){return _regeneratorRuntime().wrap((function _callee2$(t){for(;;)switch(t.prev=t.next){case 0:case"end":return t.stop()}}),_callee2)}))),function damageModifier(t,r,a,o){return v.apply(this,arguments)})},{key:"nextAction",value:(g=_asyncToGenerator(_regeneratorRuntime().mark((function _callee3(t,r,a,o){return _regeneratorRuntime().wrap((function _callee3$(t){for(;;)switch(t.prev=t.next){case 0:case"end":return t.stop()}}),_callee3)}))),function nextAction(t,r,a,o){return g.apply(this,arguments)})},{key:"opportunityAttack",value:(y=_asyncToGenerator(_regeneratorRuntime().mark((function _callee4(t,r,a,o){return _regeneratorRuntime().wrap((function _callee4$(t){for(;;)switch(t.prev=t.next){case 0:case"end":return t.stop()}}),_callee4)}))),function opportunityAttack(t,r,a,o){return y.apply(this,arguments)})},{key:"gearDamaged",value:(m=_asyncToGenerator(_regeneratorRuntime().mark((function _callee5(t,r,a,o){var i;return _regeneratorRuntime().wrap((function _callee5$(r){for(;;)switch(r.prev=r.next){case 0:if(!o||!["meleeweapon","rangeweapon"].includes(o.type)){r.next=12;break}if(i=getProperty(o,"system.effect.attributes")||"",!new RegExp("(".concat(c.Z.magical,"|").concat(c.Z.clerical,")"),"i").test(i)){r.next=9;break}return r.next=7,o.update({"system.worn.value":!1});case 7:r.next=11;break;case 9:return r.next=11,u.Z.absoluteDamageLevelToItem(o,t);case 11:return r.abrupt("return",!0);case 12:case"end":return r.stop()}}),_callee5)}))),function gearDamaged(t,r,a,o){return m.apply(this,arguments)})},{key:"gearLost",value:(h=_asyncToGenerator(_regeneratorRuntime().mark((function _callee6(t,r,a,o){var i,c,u;return _regeneratorRuntime().wrap((function _callee6$(r){for(;;)switch(r.prev=r.next){case 0:if(!o||!["meleeweapon","rangeweapon"].includes(o.type)){r.next=13;break}return r.next=3,o.update({"system.worn.value":!1});case 3:if(!t.distance){r.next=12;break}return r.next=6,new Roll(t.distance).evaluate({async:!0});case 6:return i=r.sent,r.next=9,i.render();case 9:c=r.sent,u=game.i18n.format("WEAPON.dropped",{distance:i.total}),ChatMessage.create(l.Z.chatDataSetup("

    ".concat(u,"

    ").concat(c)));case 12:return r.abrupt("return",!0);case 13:case"end":return r.stop()}}),_callee6)}))),function gearLost(t,r,a,o){return h.apply(this,arguments)})},{key:"resistEffect",value:(d=_asyncToGenerator(_regeneratorRuntime().mark((function _callee7(t,r,a,o,c){var u,l,p,d;return _regeneratorRuntime().wrap((function _callee7$(o){for(;;)switch(o.prev=o.next){case 0:u=_createForOfIteratorHelper(a);try{for(u.s();!(l=u.n()).done;)p=l.value,d=[{skill:t.roll,mod:t.modifier||0,effect:{_id:"botchEffect",name:t.fail.description},target:p,token:p.token?p.token.id:void 0}],i.Z.createResistRollMessage(d,c,r)}catch(t){u.e(t)}finally{u.f()}return o.abrupt("return",!0);case 3:case"end":return o.stop()}}),_callee7)}))),function resistEffect(t,r,a,o,i){return d.apply(this,arguments)})},{key:"evaluateTargetArg",value:function evaluateTargetArg(t,r){var a=r,o=!0;if("victim"==t.target){var i=Array.from(game.user.targets).map((function(t){return t.actor}));i.length?a=i:(o=!1,ui.notifications.warn("DSAError.noVictim"))}return{hasTargets:o,finalTargets:a}}},{key:"malus",value:(a=_asyncToGenerator(_regeneratorRuntime().mark((function _callee8(t,r,a,o){var i,c,u,l,d,h,m;return _regeneratorRuntime().wrap((function _callee8$(r){for(;;)switch(r.prev=r.next){case 0:i=this.evaluateTargetArg(t,a),c=i.hasTargets,u=i.finalTargets,l=_createForOfIteratorHelper(t),r.prev=2,h=_regeneratorRuntime().mark((function _loop(){var t,r,a,o,i,l,h,m,y,g,v,_,b,k,w,x,S;return _regeneratorRuntime().wrap((function _loop$(T){for(;;)switch(T.prev=T.next){case 0:if(t=d.value,r=!c&&t.noTarget,a=r?t.noTarget.systemEffect:t.systemEffect,o=r?t.noTarget.level:t.level||1,i=r?t.noTarget.changes:t.changes,l=r?t.noTarget.duration:t.duration,!a){T.next=30;break}h=CONFIG.statusEffects.find((function(t){return t.id==a})),i||(i=duplicate(h.changes),(m=i.find((function(t){return t.key=="system.condition.".concat(a)})))&&(m.value=o)),i?(g=game.i18n.localize("CONDITION.".concat(a))+" - "+game.i18n.localize("botchCritEffect"),(y=(new p.Z).effectDummy(g,i,l||{})).icon=h.icon):y=a,v=_createForOfIteratorHelper(u),T.prev=11,v.s();case 13:if((_=v.n()).done){T.next=19;break}return b=_.value,T.next=17,b.addCondition(y);case 17:T.next=13;break;case 19:T.next=24;break;case 21:T.prev=21,T.t0=T.catch(11),v.e(T.t0);case 24:return T.prev=24,v.f(),T.finish(24);case 27:return T.abrupt("return",{v:!0});case 30:if(!i){T.next=51;break}k=(new p.Z).effectDummy(game.i18n.localize("botchCritEffect"),i||[],l||{}),mergeObject(k,{flags:{dsa5:{hideOnToken:!1,hidePlayers:!1}}}),w=_createForOfIteratorHelper(u),T.prev=34,w.s();case 36:if((x=w.n()).done){T.next=42;break}return S=x.value,T.next=40,S.addCondition(k);case 40:T.next=36;break;case 42:T.next=47;break;case 44:T.prev=44,T.t1=T.catch(34),w.e(T.t1);case 47:return T.prev=47,w.f(),T.finish(47);case 50:return T.abrupt("return",{v:!0});case 51:case"end":return T.stop()}}),_loop,null,[[11,21,24,27],[34,44,47,50]])})),l.s();case 5:if((d=l.n()).done){r.next=12;break}return r.delegateYield(h(),"t0",7);case 7:if("object"!==_typeof(m=r.t0)){r.next=10;break}return r.abrupt("return",m.v);case 10:r.next=5;break;case 12:r.next=17;break;case 14:r.prev=14,r.t1=r.catch(2),l.e(r.t1);case 17:return r.prev=17,l.f(),r.finish(17);case 20:case"end":return r.stop()}}),_callee8,this,[[2,14,17,20]])}))),function malus(t,r,o,i){return a.apply(this,arguments)})},{key:"selfAttack",value:(r=_asyncToGenerator(_regeneratorRuntime().mark((function _callee9(t,r,a,o){var i;return _regeneratorRuntime().wrap((function _callee9$(r){for(;;)switch(r.prev=r.next){case 0:(i=this.evaluateTargetArg(t,a)).hasTargets,i.finalTargets;case 2:case"end":return r.stop()}}),_callee9,this)}))),function selfAttack(t,a,o,i){return r.apply(this,arguments)})},{key:"selfDamage",value:(t=_asyncToGenerator(_regeneratorRuntime().mark((function _callee10(t,r,a,i){var c,u,p,d,h,m,y,g,v,_;return _regeneratorRuntime().wrap((function _callee10$(r){for(;;)switch(r.prev=r.next){case 0:if((c=this.evaluateTargetArg(t,a)).hasTargets,u=c.finalTargets,!i){r.next=22;break}p=l.Z.toObjectIfPossible(i),d=_createForOfIteratorHelper(u),r.prev=4,m=_regeneratorRuntime().mark((function _loop2(){var r,a,c,u,d;return _regeneratorRuntime().wrap((function _loop2$(m){for(;;)switch(m.prev=m.next){case 0:return r=h.value,a=r.items.filter((function(t){return"combatskill"==t.type})).map((function(t){return o.Z._calculateCombatSkillValues(t.toObject(),r.system)})),c=void 0,c=t.damage?{damagedie:t.damage,damageAdd:""}:"rangeweapon"==i.type?o.Z._prepareRangeWeapon(p,[],a,r):"meleeweapon"==i.type?o.Z._prepareMeleeWeapon(p,a,r):"meleeAttack"==i.system.traitType.value?o.Z._prepareRangeTrait(p):o.Z._prepareMeleetrait(p),u=(c.damagedie+c.damageAdd).replace(/wWD/g,"d"),m.next=7,new Roll("(".concat(u,")*").concat(t.multiplier||1).concat(t.modifier||"")).evaluate({async:!0});case 7:return d=m.sent,m.next=10,r.applyDamage(Math.round(d.total));case 10:return m.t0=ChatMessage,m.t1=l.Z,m.next=14,d.render();case 14:m.t2=m.sent,m.t3=m.t1.chatDataSetup.call(m.t1,m.t2),m.t0.create.call(m.t0,m.t3);case 17:case"end":return m.stop()}}),_loop2)})),d.s();case 7:if((h=d.n()).done){r.next=11;break}return r.delegateYield(m(),"t0",9);case 9:r.next=7;break;case 11:r.next=16;break;case 13:r.prev=13,r.t1=r.catch(4),d.e(r.t1);case 16:return r.prev=16,d.f(),r.finish(16);case 19:return r.abrupt("return",!0);case 22:y=_createForOfIteratorHelper(u),r.prev=23,y.s();case 25:if((g=y.n()).done){r.next=41;break}return v=g.value,r.next=29,new Roll("1d6").evaluate({async:!0});case 29:return _=r.sent,r.next=32,v.applyDamage(Math.round(_.total));case 32:return r.t2=ChatMessage,r.t3=l.Z,r.next=36,_.render();case 36:r.t4=r.sent,r.t5=r.t3.chatDataSetup.call(r.t3,r.t4),r.t2.create.call(r.t2,r.t5);case 39:r.next=25;break;case 41:r.next=46;break;case 43:r.prev=43,r.t6=r.catch(23),y.e(r.t6);case 46:return r.prev=46,y.f(),r.finish(46);case 49:return r.abrupt("return",!0);case 50:case"end":return r.stop()}}),_callee10,this,[[4,13,16,19],[23,43,46,49]])}))),function selfDamage(r,a,o,i){return t.apply(this,arguments)})}]),TableEffects}()},93:(__unused_webpack_module,__webpack_exports__,__webpack_require__)=>{__webpack_require__.d(__webpack_exports__,{Z:()=>DSATour});var _system_view_helper_js__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__(707);function _typeof(t){return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},_typeof(t)}function _createForOfIteratorHelper(t,r){var a="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!a){if(Array.isArray(t)||(a=_unsupportedIterableToArray(t))||r&&t&&"number"==typeof t.length){a&&(t=a);var o=0,i=function F(){};return{s:i,n:function n(){return o>=t.length?{done:!0}:{done:!1,value:t[o++]}},e:function e(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var c,u=!0,l=!1;return{s:function s(){a=a.call(t)},n:function n(){var t=a.next();return u=t.done,t},e:function e(t){l=!0,c=t},f:function f(){try{u||null==a.return||a.return()}finally{if(l)throw c}}}}function _unsupportedIterableToArray(t,r){if(t){if("string"==typeof t)return _arrayLikeToArray(t,r);var a=Object.prototype.toString.call(t).slice(8,-1);return"Object"===a&&t.constructor&&(a=t.constructor.name),"Map"===a||"Set"===a?Array.from(t):"Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a)?_arrayLikeToArray(t,r):void 0}}function _arrayLikeToArray(t,r){(null==r||r>t.length)&&(r=t.length);for(var a=0,o=new Array(r);a=0;--o){var i=this.tryEntries[o],c=i.completion;if("root"===i.tryLoc)return handle("end");if(i.tryLoc<=this.prev){var u=a.call(i,"catchLoc"),l=a.call(i,"finallyLoc");if(u&&l){if(this.prev=0;--o){var i=this.tryEntries[o];if(i.tryLoc<=this.prev&&a.call(i,"finallyLoc")&&this.prev=0;--r){var a=this.tryEntries[r];if(a.finallyLoc===t)return this.complete(a.completion,a.afterLoc),resetTryEntry(a),l}},catch:function _catch(t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc===t){var o=a.completion;if("throw"===o.type){var i=o.arg;resetTryEntry(a)}return i}}throw new Error("illegal catch attempt")},delegateYield:function delegateYield(t,r,a){return this.delegate={iterator:values(t),resultName:r,nextLoc:a},"next"===this.method&&(this.arg=void 0),l}},t}function asyncGeneratorStep(t,r,a,o,i,c,u){try{var l=t[c](u),p=l.value}catch(t){return void a(t)}l.done?r(p):Promise.resolve(p).then(o,i)}function _asyncToGenerator(t){return function(){var r=this,a=arguments;return new Promise((function(o,i){var c=t.apply(r,a);function _next(t){asyncGeneratorStep(c,o,i,_next,_throw,"next",t)}function _throw(t){asyncGeneratorStep(c,o,i,_next,_throw,"throw",t)}_next(void 0)}))}}function _classCallCheck(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}function _defineProperties(t,r){for(var a=0;a { ".concat(this.config.preCommand," })"));case 3:return fn=_context2.sent,_context2.next=6,fn();case 6:if(!this.app){_context2.next=14;break}return _context2.next=9,this.app.render(!0,{focus:!0});case 9:if(this.app.rendered){_context2.next=14;break}return _context2.next=12,(0,_system_view_helper_js__WEBPACK_IMPORTED_MODULE_0__.gw)(50);case 12:_context2.next=9;break;case 14:if(!this.app&&!this.config.preCommand){_context2.next=20;break}case 15:if($(this.steps[this.stepIndex+1].selector+":visible").length){_context2.next=20;break}return _context2.next=18,(0,_system_view_helper_js__WEBPACK_IMPORTED_MODULE_0__.gw)(50);case 18:_context2.next=15;break;case 20:return _context2.next=22,_get(_getPrototypeOf(DSATour.prototype),"start",this).call(this);case 22:return res=_context2.sent,$("#tooltip").show(),_context2.abrupt("return",res);case 25:case"end":return _context2.stop()}}),_callee2,this)})));function start(){return _start.apply(this,arguments)}return start}()}],[{key:"travelAgency",value:(_travelAgency=_asyncToGenerator(_regeneratorRuntime().mark((function _callee3(){var t,r,a,o,i,c,u,l,p;return _regeneratorRuntime().wrap((function _callee3$(d){for(;;)switch(d.prev=d.next){case 0:t="de"==game.i18n.lang?"de":"en",console.log("Adding DSA/TDE Tours"),r=_createForOfIteratorHelper(this.tours),d.prev=3,r.s();case 5:if((a=r.n()).done){d.next=13;break}return o=a.value,d.next=9,game.dsa5.apps.DSATour.fromJSON("".concat(o.replace("/lang/","/".concat(t,"/")),".json"));case 9:i=d.sent,game.tours.register(i.config.module,i.id,i);case 11:d.next=5;break;case 13:d.next=18;break;case 15:d.prev=15,d.t0=d.catch(3),r.e(d.t0);case 18:return d.prev=18,r.f(),d.finish(18);case 21:if(game.user.isGM){d.next=23;break}return d.abrupt("return");case 23:c=_createForOfIteratorHelper(this.gmTours),d.prev=24,c.s();case 26:if((u=c.n()).done){d.next=34;break}return l=u.value,d.next=30,game.dsa5.apps.DSATour.fromJSON("".concat(l.replace("/lang/","/".concat(t,"/")),".json"));case 30:p=d.sent,game.tours.register(p.config.module,p.id,p);case 32:d.next=26;break;case 34:d.next=39;break;case 36:d.prev=36,d.t1=d.catch(24),c.e(d.t1);case 39:return d.prev=39,c.f(),d.finish(39);case 42:case"end":return d.stop()}}),_callee3,this,[[3,15,18,21],[24,36,39,42]])}))),function travelAgency(){return _travelAgency.apply(this,arguments)})}]),DSATour}(Tour);_defineProperty(DSATour,"tours",["systems/dsa5/modules/tours/lang/initial","systems/dsa5/modules/tours/lang/library","systems/dsa5/modules/tours/lang/actor"]),_defineProperty(DSATour,"gmTours",["systems/dsa5/modules/tours/lang/mastermenu"])}},__webpack_module_cache__={};function __webpack_require__(t){var r=__webpack_module_cache__[t];if(void 0!==r)return r.exports;var a=__webpack_module_cache__[t]={exports:{}};return __webpack_modules__[t](a,a.exports,__webpack_require__),a.exports}__webpack_require__.d=(t,r)=>{for(var a in r)__webpack_require__.o(r,a)&&!__webpack_require__.o(t,a)&&Object.defineProperty(t,a,{enumerable:!0,get:r[a]})},__webpack_require__.o=(t,r)=>Object.prototype.hasOwnProperty.call(t,r);var __webpack_exports__={};(()=>{var t=__webpack_require__(491),r=__webpack_require__(577),a=__webpack_require__(272),o=__webpack_require__(839),i=__webpack_require__(173),c=__webpack_require__(947),u=__webpack_require__(973);function _typeof(t){return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},_typeof(t)}function _createForOfIteratorHelper(t,r){var a="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!a){if(Array.isArray(t)||(a=_unsupportedIterableToArray(t))||r&&t&&"number"==typeof t.length){a&&(t=a);var o=0,i=function F(){};return{s:i,n:function n(){return o>=t.length?{done:!0}:{done:!1,value:t[o++]}},e:function e(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var c,u=!0,l=!1;return{s:function s(){a=a.call(t)},n:function n(){var t=a.next();return u=t.done,t},e:function e(t){l=!0,c=t},f:function f(){try{u||null==a.return||a.return()}finally{if(l)throw c}}}}function _regeneratorRuntime(){_regeneratorRuntime=function _regeneratorRuntime(){return t};var t={},r=Object.prototype,a=r.hasOwnProperty,o="function"==typeof Symbol?Symbol:{},i=o.iterator||"@@iterator",c=o.asyncIterator||"@@asyncIterator",u=o.toStringTag||"@@toStringTag";function define(t,r,a){return Object.defineProperty(t,r,{value:a,enumerable:!0,configurable:!0,writable:!0}),t[r]}try{define({},"")}catch(t){define=function define(t,r,a){return t[r]=a}}function wrap(t,r,a,o){var i=r&&r.prototype instanceof Generator?r:Generator,c=Object.create(i.prototype),u=new Context(o||[]);return c._invoke=function(t,r,a){var o="suspendedStart";return function(i,c){if("executing"===o)throw new Error("Generator is already running");if("completed"===o){if("throw"===i)throw c;return doneResult()}for(a.method=i,a.arg=c;;){var u=a.delegate;if(u){var p=maybeInvokeDelegate(u,a);if(p){if(p===l)continue;return p}}if("next"===a.method)a.sent=a._sent=a.arg;else if("throw"===a.method){if("suspendedStart"===o)throw o="completed",a.arg;a.dispatchException(a.arg)}else"return"===a.method&&a.abrupt("return",a.arg);o="executing";var d=tryCatch(t,r,a);if("normal"===d.type){if(o=a.done?"completed":"suspendedYield",d.arg===l)continue;return{value:d.arg,done:a.done}}"throw"===d.type&&(o="completed",a.method="throw",a.arg=d.arg)}}}(t,a,u),c}function tryCatch(t,r,a){try{return{type:"normal",arg:t.call(r,a)}}catch(t){return{type:"throw",arg:t}}}t.wrap=wrap;var l={};function Generator(){}function GeneratorFunction(){}function GeneratorFunctionPrototype(){}var p={};define(p,i,(function(){return this}));var d=Object.getPrototypeOf,h=d&&d(d(values([])));h&&h!==r&&a.call(h,i)&&(p=h);var m=GeneratorFunctionPrototype.prototype=Generator.prototype=Object.create(p);function defineIteratorMethods(t){["next","throw","return"].forEach((function(r){define(t,r,(function(t){return this._invoke(r,t)}))}))}function AsyncIterator(t,r){function invoke(o,i,c,u){var l=tryCatch(t[o],t,i);if("throw"!==l.type){var p=l.arg,d=p.value;return d&&"object"==_typeof(d)&&a.call(d,"__await")?r.resolve(d.__await).then((function(t){invoke("next",t,c,u)}),(function(t){invoke("throw",t,c,u)})):r.resolve(d).then((function(t){p.value=t,c(p)}),(function(t){return invoke("throw",t,c,u)}))}u(l.arg)}var o;this._invoke=function(t,a){function callInvokeWithMethodAndArg(){return new r((function(r,o){invoke(t,a,r,o)}))}return o=o?o.then(callInvokeWithMethodAndArg,callInvokeWithMethodAndArg):callInvokeWithMethodAndArg()}}function maybeInvokeDelegate(t,r){var a=t.iterator[r.method];if(void 0===a){if(r.delegate=null,"throw"===r.method){if(t.iterator.return&&(r.method="return",r.arg=void 0,maybeInvokeDelegate(t,r),"throw"===r.method))return l;r.method="throw",r.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var o=tryCatch(a,t.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,l;var i=o.arg;return i?i.done?(r[t.resultName]=i.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=void 0),r.delegate=null,l):i:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,l)}function pushTryEntry(t){var r={tryLoc:t[0]};1 in t&&(r.catchLoc=t[1]),2 in t&&(r.finallyLoc=t[2],r.afterLoc=t[3]),this.tryEntries.push(r)}function resetTryEntry(t){var r=t.completion||{};r.type="normal",delete r.arg,t.completion=r}function Context(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(pushTryEntry,this),this.reset(!0)}function values(t){if(t){var r=t[i];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var o=-1,c=function next(){for(;++o=0;--o){var i=this.tryEntries[o],c=i.completion;if("root"===i.tryLoc)return handle("end");if(i.tryLoc<=this.prev){var u=a.call(i,"catchLoc"),l=a.call(i,"finallyLoc");if(u&&l){if(this.prev=0;--o){var i=this.tryEntries[o];if(i.tryLoc<=this.prev&&a.call(i,"finallyLoc")&&this.prev=0;--r){var a=this.tryEntries[r];if(a.finallyLoc===t)return this.complete(a.completion,a.afterLoc),resetTryEntry(a),l}},catch:function _catch(t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc===t){var o=a.completion;if("throw"===o.type){var i=o.arg;resetTryEntry(a)}return i}}throw new Error("illegal catch attempt")},delegateYield:function delegateYield(t,r,a){return this.delegate={iterator:values(t),resultName:r,nextLoc:a},"next"===this.method&&(this.arg=void 0),l}},t}function _slicedToArray(t,r){return function _arrayWithHoles(t){if(Array.isArray(t))return t}(t)||function _iterableToArrayLimit(t,r){var a=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null==a)return;var o,i,c=[],u=!0,l=!1;try{for(a=a.call(t);!(u=(o=a.next()).done)&&(c.push(o.value),!r||c.length!==r);u=!0);}catch(t){l=!0,i=t}finally{try{u||null==a.return||a.return()}finally{if(l)throw i}}return c}(t,r)||_unsupportedIterableToArray(t,r)||function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function _unsupportedIterableToArray(t,r){if(t){if("string"==typeof t)return _arrayLikeToArray(t,r);var a=Object.prototype.toString.call(t).slice(8,-1);return"Object"===a&&t.constructor&&(a=t.constructor.name),"Map"===a||"Set"===a?Array.from(t):"Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a)?_arrayLikeToArray(t,r):void 0}}function _arrayLikeToArray(t,r){(null==r||r>t.length)&&(r=t.length);for(var a=0,o=new Array(r);a1&&void 0!==c[1]&&c[1],u.next=3,new Promise((function(a,o){var i={Yes:{icon:'',label:game.i18n.localize("update"),callback:function callback(){a([!0])}},cancel:{icon:'',label:game.i18n.localize("cancel"),callback:function callback(){a([!1])}}};r&&(i.migrateAll={icon:'',label:game.i18n.localize("replace"),callback:function callback(){a([2])}}),new Dialog({title:game.i18n.localize("Migrakel.Migration"),content:t,default:"yes",buttons:i,close:function close(){a([!1])}}).render(!0)}));case 3:return a=u.sent,o=_slicedToArray(a,1),i=o[0],u.abrupt("return",i);case 7:case"end":return u.stop()}}),_callee)}))),function showDialog(t){return l.apply(this,arguments)})},{key:"refreshStatusEffects",value:(u=_asyncToGenerator(_regeneratorRuntime().mark((function _callee2(t){var r,a,o,i,c;return _regeneratorRuntime().wrap((function _callee2$(u){for(;;)switch(u.prev=u.next){case 0:r=[],a=_createForOfIteratorHelper(t.effects),u.prev=2,a.s();case 4:if((o=a.n()).done){u.next=19;break}if(!(i=o.value).origin){u.next=17;break}return c=void 0,u.prev=8,u.next=11,fromUuid(i.origin);case 11:c=u.sent,u.next=16;break;case 14:u.prev=14,u.t0=u.catch(8);case 16:c||r.push(i.id);case 17:u.next=4;break;case 19:u.next=24;break;case 21:u.prev=21,u.t1=u.catch(2),a.e(u.t1);case 24:return u.prev=24,a.f(),u.finish(24);case 27:return u.next=29,t.deleteEmbeddedDocuments("ActiveEffect",r);case 29:case"end":return u.stop()}}),_callee2,null,[[2,21,24,27],[8,14]])}))),function refreshStatusEffects(t){return u.apply(this,arguments)})},{key:"updateVals",value:(c=_asyncToGenerator(_regeneratorRuntime().mark((function _callee3(t,r,a){var o,i,c,u,l,p,d,h,m,y,g,v,_,b;return _regeneratorRuntime().wrap((function _callee3$(k){for(;;)switch(k.prev=k.next){case 0:return o=game.dsa5.itemLibrary,i=[],c=[],u=new Map,k.next=6,this.refreshStatusEffects(t);case 6:if(!r({type:"equipment"})){k.next=34;break}l=[],p=[],d=_createForOfIteratorHelper(t.items.filter((function(t){return"equipment"==t.type&&"bags"==t.system.equipmentType.value}))),k.prev=10,m=_regeneratorRuntime().mark((function _loop(){var t,r,i;return _regeneratorRuntime().wrap((function _loop$(c){for(;;)switch(c.prev=c.next){case 0:return t=h.value,c.next=3,o.findCompendiumItem(t.name,t.type);case 3:if(!((r=c.sent).length>0)){c.next=12;break}if(r=r.find((function(r){return r.name==t.name&&r.type==t.type}))){c.next=8;break}return c.abrupt("return","continue");case 8:console.log("MIGRATION - Updated ".concat(t.name)),i=mergeObject(t.toObject(),a(r)),p.push(i),l.push(t.id);case 12:case"end":return c.stop()}}),_loop)})),d.s();case 13:if((h=d.n()).done){k.next=20;break}return k.delegateYield(m(),"t0",15);case 15:if("continue"!==k.t0){k.next=18;break}return k.abrupt("continue",18);case 18:k.next=13;break;case 20:k.next=25;break;case 22:k.prev=22,k.t1=k.catch(10),d.e(k.t1);case 25:return k.prev=25,d.f(),k.finish(25);case 28:return k.next=30,t.createEmbeddedDocuments("Item",p);case 30:for(y=k.sent,g=0;g0)){p.next=13;break}if(r=r.find((function(r){return r.name==t.name&&r.type==t.type}))){p.next=8;break}return p.abrupt("return","continue");case 8:console.log("MIGRATION - Updated ".concat(t.name)),(l=mergeObject(t.toObject(),a(r))).system.parent_id&&u.has(l.system.parent_id)&&(l.system.parent_id=u.get(l.system.parent_id)),c.push(l),i.push(t.id);case 13:case"end":return p.stop()}}),_loop2)})),v.s();case 38:if((_=v.n()).done){k.next=45;break}return k.delegateYield(b(),"t2",40);case 40:if("continue"!==k.t2){k.next=43;break}return k.abrupt("continue",43);case 43:k.next=38;break;case 45:k.next=50;break;case 47:k.prev=47,k.t3=k.catch(35),v.e(k.t3);case 50:return k.prev=50,v.f(),k.finish(50);case 53:return k.next=55,t.createEmbeddedDocuments("Item",c);case 55:return k.next=57,t.deleteEmbeddedDocuments("Item",i);case 57:ui.notifications.notify(game.i18n.localize("Migrakel.migrationDone"));case 58:case"end":return k.stop()}}),_callee3,this,[[10,22,25,28],[35,47,50,53]])}))),function updateVals(t,r,a){return c.apply(this,arguments)})},{key:"updateSpellsAndLiturgies",value:(i=_asyncToGenerator(_regeneratorRuntime().mark((function _callee4(t){var r,a,o,i;return _regeneratorRuntime().wrap((function _callee4$(c){for(;;)switch(c.prev=c.next){case 0:return c.next=2,this.showDialog(game.i18n.localize("Migrakel.spells"),!0);case 2:if(r=c.sent,a=function condition(t){return["spell","liturgy","ritual","ceremony","spellextension"].includes(t.type)},2!=r){c.next=10;break}return o=function updator(t){var r=t.toObject();return delete r.system.talentValue,r},c.next=8,this.updateVals(t,a,o);case 8:c.next=14;break;case 10:if(!r){c.next=14;break}return i=function _updator(t){var r={effects:t.effects.toObject()};return"spellextension"!=t.type&&(r.system={effectFormula:{value:t.system.effectFormula.value}}),r},c.next=14,this.updateVals(t,a,i);case 14:case"end":return c.stop()}}),_callee4,this)}))),function updateSpellsAndLiturgies(t){return i.apply(this,arguments)})},{key:"updateSpecialAbilities",value:(o=_asyncToGenerator(_regeneratorRuntime().mark((function _callee5(t){var r,a,o=this;return _regeneratorRuntime().wrap((function _callee5$(i){for(;;)switch(i.prev=i.next){case 0:return i.next=2,this.showDialog(game.i18n.localize("Migrakel.abilities"));case 2:if(!i.sent){i.next=7;break}return r=function updator(t){var r={system:{effect:{value:t.system.effect.value}},effects:t.effects.toObject()};return"specialability"==t.type&&(mergeObject(r,{system:{category:{sub:t.system.category.sub||0},list:{value:t.system.list.value},effect:{value2:getProperty(t,"system.effect.value2")||"",value3:getProperty(t,"system.effect.value3")||""}}}),"staff"==t.system.category.value&&mergeObject(r,{system:{feature:getProperty(t,"system.feature")||"",AsPCost:getProperty(t,"system.AsPCost")||"",volume:Number(getProperty(t,"system.volume"))||0,artifact:getProperty(t,"system.artifact")||""}})),o.updateMacro(r,t),r},a=function condition(t){return["specialability","advantage","disadvantage","trait"].includes(t.type)},i.next=7,this.updateVals(t,a,r);case 7:case"end":return i.stop()}}),_callee5,this)}))),function updateSpecialAbilities(t){return o.apply(this,arguments)})},{key:"updateCombatskills",value:(a=_asyncToGenerator(_regeneratorRuntime().mark((function _callee6(t){var r,a;return _regeneratorRuntime().wrap((function _callee6$(o){for(;;)switch(o.prev=o.next){case 0:return o.next=2,this.showDialog(game.i18n.localize("Migrakel.cskills"));case 2:if(!o.sent){o.next=7;break}return r=function updator(t){return{effects:t.effects.toObject()}},a=function condition(t){return["combatskill"].includes(t.type)},o.next=7,this.updateVals(t,a,r);case 7:case"end":return o.stop()}}),_callee6,this)}))),function updateCombatskills(t){return a.apply(this,arguments)})},{key:"updateSkills",value:(r=_asyncToGenerator(_regeneratorRuntime().mark((function _callee7(t){var r,a;return _regeneratorRuntime().wrap((function _callee7$(o){for(;;)switch(o.prev=o.next){case 0:return o.next=2,this.showDialog(game.i18n.localize("Migrakel.skills"));case 2:if(!o.sent){o.next=7;break}return r=function condition(t){return["skill"].includes(t.type)},a=function updator(t){return{img:t.img}},o.next=7,this.updateVals(t,r,a);case 7:case"end":return o.stop()}}),_callee7,this)}))),function updateSkills(t){return r.apply(this,arguments)})},{key:"updateMacro",value:function updateMacro(t,r){var a=r.getFlag("dsa5","onUseEffect");a&&mergeObject(t,{flags:{dsa5:{onUseEffect:a}}})}},{key:"updateGear",value:(t=_asyncToGenerator(_regeneratorRuntime().mark((function _callee8(t){var r,a,o=this;return _regeneratorRuntime().wrap((function _callee8$(i){for(;;)switch(i.prev=i.next){case 0:return i.next=2,this.showDialog(game.i18n.localize("Migrakel.gear"));case 2:if(!i.sent){i.next=7;break}return r=function condition(t){return["meleeweapon","armor","rangeweapon","equipment","poison","consumable","ammunition"].includes(t.type)},a=function updator(t){var r={img:t.img,effects:t.effects.toObject()};return["poison","consumable"].includes(t.type)||mergeObject(r,{system:{effect:{value:t.system.effect.value}}}),["armor"].includes(t.type)&&mergeObject(r,{system:{subcategory:t.system.subcategory}}),["meleeweapon","rangeweapon","armor"].includes(t.type)&&mergeObject(r,{system:{structure:{max:t.system.structure.max,value:t.system.structure.value}}}),o.updateMacro(r,t),r},i.next=7,this.updateVals(t,r,a);case 7:case"end":return i.stop()}}),_callee8,this)}))),function updateGear(r){return t.apply(this,arguments)})}]),Migrakel}();function dialog_actorConfig_typeof(t){return dialog_actorConfig_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},dialog_actorConfig_typeof(t)}function dialog_actorConfig_regeneratorRuntime(){dialog_actorConfig_regeneratorRuntime=function _regeneratorRuntime(){return t};var t={},r=Object.prototype,a=r.hasOwnProperty,o="function"==typeof Symbol?Symbol:{},i=o.iterator||"@@iterator",c=o.asyncIterator||"@@asyncIterator",u=o.toStringTag||"@@toStringTag";function define(t,r,a){return Object.defineProperty(t,r,{value:a,enumerable:!0,configurable:!0,writable:!0}),t[r]}try{define({},"")}catch(t){define=function define(t,r,a){return t[r]=a}}function wrap(t,r,a,o){var i=r&&r.prototype instanceof Generator?r:Generator,c=Object.create(i.prototype),u=new Context(o||[]);return c._invoke=function(t,r,a){var o="suspendedStart";return function(i,c){if("executing"===o)throw new Error("Generator is already running");if("completed"===o){if("throw"===i)throw c;return doneResult()}for(a.method=i,a.arg=c;;){var u=a.delegate;if(u){var p=maybeInvokeDelegate(u,a);if(p){if(p===l)continue;return p}}if("next"===a.method)a.sent=a._sent=a.arg;else if("throw"===a.method){if("suspendedStart"===o)throw o="completed",a.arg;a.dispatchException(a.arg)}else"return"===a.method&&a.abrupt("return",a.arg);o="executing";var d=tryCatch(t,r,a);if("normal"===d.type){if(o=a.done?"completed":"suspendedYield",d.arg===l)continue;return{value:d.arg,done:a.done}}"throw"===d.type&&(o="completed",a.method="throw",a.arg=d.arg)}}}(t,a,u),c}function tryCatch(t,r,a){try{return{type:"normal",arg:t.call(r,a)}}catch(t){return{type:"throw",arg:t}}}t.wrap=wrap;var l={};function Generator(){}function GeneratorFunction(){}function GeneratorFunctionPrototype(){}var p={};define(p,i,(function(){return this}));var d=Object.getPrototypeOf,h=d&&d(d(values([])));h&&h!==r&&a.call(h,i)&&(p=h);var m=GeneratorFunctionPrototype.prototype=Generator.prototype=Object.create(p);function defineIteratorMethods(t){["next","throw","return"].forEach((function(r){define(t,r,(function(t){return this._invoke(r,t)}))}))}function AsyncIterator(t,r){function invoke(o,i,c,u){var l=tryCatch(t[o],t,i);if("throw"!==l.type){var p=l.arg,d=p.value;return d&&"object"==dialog_actorConfig_typeof(d)&&a.call(d,"__await")?r.resolve(d.__await).then((function(t){invoke("next",t,c,u)}),(function(t){invoke("throw",t,c,u)})):r.resolve(d).then((function(t){p.value=t,c(p)}),(function(t){return invoke("throw",t,c,u)}))}u(l.arg)}var o;this._invoke=function(t,a){function callInvokeWithMethodAndArg(){return new r((function(r,o){invoke(t,a,r,o)}))}return o=o?o.then(callInvokeWithMethodAndArg,callInvokeWithMethodAndArg):callInvokeWithMethodAndArg()}}function maybeInvokeDelegate(t,r){var a=t.iterator[r.method];if(void 0===a){if(r.delegate=null,"throw"===r.method){if(t.iterator.return&&(r.method="return",r.arg=void 0,maybeInvokeDelegate(t,r),"throw"===r.method))return l;r.method="throw",r.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var o=tryCatch(a,t.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,l;var i=o.arg;return i?i.done?(r[t.resultName]=i.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=void 0),r.delegate=null,l):i:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,l)}function pushTryEntry(t){var r={tryLoc:t[0]};1 in t&&(r.catchLoc=t[1]),2 in t&&(r.finallyLoc=t[2],r.afterLoc=t[3]),this.tryEntries.push(r)}function resetTryEntry(t){var r=t.completion||{};r.type="normal",delete r.arg,t.completion=r}function Context(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(pushTryEntry,this),this.reset(!0)}function values(t){if(t){var r=t[i];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var o=-1,c=function next(){for(;++o=0;--o){var i=this.tryEntries[o],c=i.completion;if("root"===i.tryLoc)return handle("end");if(i.tryLoc<=this.prev){var u=a.call(i,"catchLoc"),l=a.call(i,"finallyLoc");if(u&&l){if(this.prev=0;--o){var i=this.tryEntries[o];if(i.tryLoc<=this.prev&&a.call(i,"finallyLoc")&&this.prev=0;--r){var a=this.tryEntries[r];if(a.finallyLoc===t)return this.complete(a.completion,a.afterLoc),resetTryEntry(a),l}},catch:function _catch(t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc===t){var o=a.completion;if("throw"===o.type){var i=o.arg;resetTryEntry(a)}return i}}throw new Error("illegal catch attempt")},delegateYield:function delegateYield(t,r,a){return this.delegate={iterator:values(t),resultName:r,nextLoc:a},"next"===this.method&&(this.arg=void 0),l}},t}function dialog_actorConfig_asyncGeneratorStep(t,r,a,o,i,c,u){try{var l=t[c](u),p=l.value}catch(t){return void a(t)}l.done?r(p):Promise.resolve(p).then(o,i)}function dialog_actorConfig_asyncToGenerator(t){return function(){var r=this,a=arguments;return new Promise((function(o,i){var c=t.apply(r,a);function _next(t){dialog_actorConfig_asyncGeneratorStep(c,o,i,_next,_throw,"next",t)}function _throw(t){dialog_actorConfig_asyncGeneratorStep(c,o,i,_next,_throw,"throw",t)}_next(void 0)}))}}function dialog_actorConfig_defineProperties(t,r){for(var a=0;a
    '),a.next=4,l[t](o.actor);case 4:$(r.currentTarget).find("i").remove(),o.lock=!1;case 6:case"end":return a.stop()}}),_callee)})));return function upd(){return a.apply(this,arguments)}}(),a();case 4:case"end":return i.stop()}}),_callee2,this)}))),function updateWrapper(t,r){return a.apply(this,arguments)})},{key:"activateListeners",value:function activateListeners(t){var r=this;_get(_getPrototypeOf(DialogActorConfig.prototype),"activateListeners",this).call(this,t),t.find(".updateSpells").click(function(){var t=dialog_actorConfig_asyncToGenerator(dialog_actorConfig_regeneratorRuntime().mark((function _callee3(t){return dialog_actorConfig_regeneratorRuntime().wrap((function _callee3$(a){for(;;)switch(a.prev=a.next){case 0:return a.abrupt("return",r.updateWrapper("updateSpellsAndLiturgies",t));case 1:case"end":return a.stop()}}),_callee3)})));return function(r){return t.apply(this,arguments)}}()),t.find(".updateAbilities").click(function(){var t=dialog_actorConfig_asyncToGenerator(dialog_actorConfig_regeneratorRuntime().mark((function _callee4(t){return dialog_actorConfig_regeneratorRuntime().wrap((function _callee4$(a){for(;;)switch(a.prev=a.next){case 0:return a.abrupt("return",r.updateWrapper("updateSpecialAbilities",t));case 1:case"end":return a.stop()}}),_callee4)})));return function(r){return t.apply(this,arguments)}}()),t.find(".updatecSkills").click(function(){var t=dialog_actorConfig_asyncToGenerator(dialog_actorConfig_regeneratorRuntime().mark((function _callee5(t){return dialog_actorConfig_regeneratorRuntime().wrap((function _callee5$(a){for(;;)switch(a.prev=a.next){case 0:return a.abrupt("return",r.updateWrapper("updateCombatskills",t));case 1:case"end":return a.stop()}}),_callee5)})));return function(r){return t.apply(this,arguments)}}()),t.find(".updateSkills").click(function(){var t=dialog_actorConfig_asyncToGenerator(dialog_actorConfig_regeneratorRuntime().mark((function _callee6(t){return dialog_actorConfig_regeneratorRuntime().wrap((function _callee6$(a){for(;;)switch(a.prev=a.next){case 0:return a.abrupt("return",r.updateWrapper("updateSkills",t));case 1:case"end":return a.stop()}}),_callee6)})));return function(r){return t.apply(this,arguments)}}()),t.find(".updateGear").click(function(){var t=dialog_actorConfig_asyncToGenerator(dialog_actorConfig_regeneratorRuntime().mark((function _callee7(t){return dialog_actorConfig_regeneratorRuntime().wrap((function _callee7$(a){for(;;)switch(a.prev=a.next){case 0:return a.abrupt("return",r.updateWrapper("updateGear",t));case 1:case"end":return a.stop()}}),_callee7)})));return function(r){return t.apply(this,arguments)}}())}}],[{key:"buildDialog",value:(r=dialog_actorConfig_asyncToGenerator(dialog_actorConfig_regeneratorRuntime().mark((function _callee8(t){var r;return dialog_actorConfig_regeneratorRuntime().wrap((function _callee8$(a){for(;;)switch(a.prev=a.next){case 0:return a.next=2,renderTemplate("systems/dsa5/templates/actors/parts/actorConfig.html",{actor:t});case 2:r=a.sent,new DialogActorConfig(t,{title:game.i18n.localize("SHEET.actorConfig"),content:r,default:"Save",buttons:{Save:{icon:'',label:game.i18n.localize("Save"),callback:function callback(r){t.update({"system.config.autoBar":r.find('[name="autoBar"]').is(":checked"),"system.config.autoSize":r.find('[name="autoSize"]').is(":checked")})}},cancel:{icon:'',label:game.i18n.localize("cancel")}}}).render(!0);case 4:case"end":return a.stop()}}),_callee8)}))),function buildDialog(t){return r.apply(this,arguments)})}]),DialogActorConfig}(),d=__webpack_require__(369),h=__webpack_require__(707),m=__webpack_require__(803),y=__webpack_require__(122),g=__webpack_require__(604);function bindImgToCanvasDragStart(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"img";game.user.isGM&&t.find(r).each((function(t,r){r.setAttribute("draggable",!0),r.addEventListener("dragstart",(function(t){return v(t)}))}))}var v=function dragTileImg(t){canvas.tiles.activate();var r=t.currentTarget.src,a=t.currentTarget,o=canvas.dimensions.sceneHeight/a.naturalHeight,i=canvas.dimensions.sceneWidth/a.naturalWidth,c=Math.min(1,i,o),u={type:"Tile",texture:{src:r},tileSize:Math.round(canvas.dimensions.size/c)};t.dataTransfer.setData("text/plain",JSON.stringify(u));var l=a.naturalWidth*c*canvas.stage.scale.x,p=a.naturalHeight*c*canvas.stage.scale.y,d=DragDrop.createDragImage(a,l,p);t.dataTransfer.setDragImage(d,l/2,p/2)},_=__webpack_require__(231),b=__webpack_require__(169);function foreignFieldEditor_typeof(t){return foreignFieldEditor_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},foreignFieldEditor_typeof(t)}function foreignFieldEditor_regeneratorRuntime(){foreignFieldEditor_regeneratorRuntime=function _regeneratorRuntime(){return t};var t={},r=Object.prototype,a=r.hasOwnProperty,o="function"==typeof Symbol?Symbol:{},i=o.iterator||"@@iterator",c=o.asyncIterator||"@@asyncIterator",u=o.toStringTag||"@@toStringTag";function define(t,r,a){return Object.defineProperty(t,r,{value:a,enumerable:!0,configurable:!0,writable:!0}),t[r]}try{define({},"")}catch(t){define=function define(t,r,a){return t[r]=a}}function wrap(t,r,a,o){var i=r&&r.prototype instanceof Generator?r:Generator,c=Object.create(i.prototype),u=new Context(o||[]);return c._invoke=function(t,r,a){var o="suspendedStart";return function(i,c){if("executing"===o)throw new Error("Generator is already running");if("completed"===o){if("throw"===i)throw c;return doneResult()}for(a.method=i,a.arg=c;;){var u=a.delegate;if(u){var p=maybeInvokeDelegate(u,a);if(p){if(p===l)continue;return p}}if("next"===a.method)a.sent=a._sent=a.arg;else if("throw"===a.method){if("suspendedStart"===o)throw o="completed",a.arg;a.dispatchException(a.arg)}else"return"===a.method&&a.abrupt("return",a.arg);o="executing";var d=tryCatch(t,r,a);if("normal"===d.type){if(o=a.done?"completed":"suspendedYield",d.arg===l)continue;return{value:d.arg,done:a.done}}"throw"===d.type&&(o="completed",a.method="throw",a.arg=d.arg)}}}(t,a,u),c}function tryCatch(t,r,a){try{return{type:"normal",arg:t.call(r,a)}}catch(t){return{type:"throw",arg:t}}}t.wrap=wrap;var l={};function Generator(){}function GeneratorFunction(){}function GeneratorFunctionPrototype(){}var p={};define(p,i,(function(){return this}));var d=Object.getPrototypeOf,h=d&&d(d(values([])));h&&h!==r&&a.call(h,i)&&(p=h);var m=GeneratorFunctionPrototype.prototype=Generator.prototype=Object.create(p);function defineIteratorMethods(t){["next","throw","return"].forEach((function(r){define(t,r,(function(t){return this._invoke(r,t)}))}))}function AsyncIterator(t,r){function invoke(o,i,c,u){var l=tryCatch(t[o],t,i);if("throw"!==l.type){var p=l.arg,d=p.value;return d&&"object"==foreignFieldEditor_typeof(d)&&a.call(d,"__await")?r.resolve(d.__await).then((function(t){invoke("next",t,c,u)}),(function(t){invoke("throw",t,c,u)})):r.resolve(d).then((function(t){p.value=t,c(p)}),(function(t){return invoke("throw",t,c,u)}))}u(l.arg)}var o;this._invoke=function(t,a){function callInvokeWithMethodAndArg(){return new r((function(r,o){invoke(t,a,r,o)}))}return o=o?o.then(callInvokeWithMethodAndArg,callInvokeWithMethodAndArg):callInvokeWithMethodAndArg()}}function maybeInvokeDelegate(t,r){var a=t.iterator[r.method];if(void 0===a){if(r.delegate=null,"throw"===r.method){if(t.iterator.return&&(r.method="return",r.arg=void 0,maybeInvokeDelegate(t,r),"throw"===r.method))return l;r.method="throw",r.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var o=tryCatch(a,t.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,l;var i=o.arg;return i?i.done?(r[t.resultName]=i.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=void 0),r.delegate=null,l):i:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,l)}function pushTryEntry(t){var r={tryLoc:t[0]};1 in t&&(r.catchLoc=t[1]),2 in t&&(r.finallyLoc=t[2],r.afterLoc=t[3]),this.tryEntries.push(r)}function resetTryEntry(t){var r=t.completion||{};r.type="normal",delete r.arg,t.completion=r}function Context(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(pushTryEntry,this),this.reset(!0)}function values(t){if(t){var r=t[i];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var o=-1,c=function next(){for(;++o=0;--o){var i=this.tryEntries[o],c=i.completion;if("root"===i.tryLoc)return handle("end");if(i.tryLoc<=this.prev){var u=a.call(i,"catchLoc"),l=a.call(i,"finallyLoc");if(u&&l){if(this.prev=0;--o){var i=this.tryEntries[o];if(i.tryLoc<=this.prev&&a.call(i,"finallyLoc")&&this.prev=0;--r){var a=this.tryEntries[r];if(a.finallyLoc===t)return this.complete(a.completion,a.afterLoc),resetTryEntry(a),l}},catch:function _catch(t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc===t){var o=a.completion;if("throw"===o.type){var i=o.arg;resetTryEntry(a)}return i}}throw new Error("illegal catch attempt")},delegateYield:function delegateYield(t,r,a){return this.delegate={iterator:values(t),resultName:r,nextLoc:a},"next"===this.method&&(this.arg=void 0),l}},t}function foreignFieldEditor_asyncGeneratorStep(t,r,a,o,i,c,u){try{var l=t[c](u),p=l.value}catch(t){return void a(t)}l.done?r(p):Promise.resolve(p).then(o,i)}function foreignFieldEditor_asyncToGenerator(t){return function(){var r=this,a=arguments;return new Promise((function(o,i){var c=t.apply(r,a);function _next(t){foreignFieldEditor_asyncGeneratorStep(c,o,i,_next,_throw,"next",t)}function _throw(t){foreignFieldEditor_asyncGeneratorStep(c,o,i,_next,_throw,"throw",t)}_next(void 0)}))}}function foreignFieldEditor_defineProperties(t,r){for(var a=0;a=t.length?{done:!0}:{done:!1,value:t[o++]}},e:function e(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var c,u=!0,l=!1;return{s:function s(){a=a.call(t)},n:function n(){var t=a.next();return u=t.done,t},e:function e(t){l=!0,c=t},f:function f(){try{u||null==a.return||a.return()}finally{if(l)throw c}}}}function payment_unsupportedIterableToArray(t,r){if(t){if("string"==typeof t)return payment_arrayLikeToArray(t,r);var a=Object.prototype.toString.call(t).slice(8,-1);return"Object"===a&&t.constructor&&(a=t.constructor.name),"Map"===a||"Set"===a?Array.from(t):"Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a)?payment_arrayLikeToArray(t,r):void 0}}function payment_arrayLikeToArray(t,r){(null==r||r>t.length)&&(r=t.length);for(var a=0,o=new Array(r);a=0;--o){var i=this.tryEntries[o],c=i.completion;if("root"===i.tryLoc)return handle("end");if(i.tryLoc<=this.prev){var u=a.call(i,"catchLoc"),l=a.call(i,"finallyLoc");if(u&&l){if(this.prev=0;--o){var i=this.tryEntries[o];if(i.tryLoc<=this.prev&&a.call(i,"finallyLoc")&&this.prev=0;--r){var a=this.tryEntries[r];if(a.finallyLoc===t)return this.complete(a.completion,a.afterLoc),resetTryEntry(a),l}},catch:function _catch(t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc===t){var o=a.completion;if("throw"===o.type){var i=o.arg;resetTryEntry(a)}return i}}throw new Error("illegal catch attempt")},delegateYield:function delegateYield(t,r,a){return this.delegate={iterator:values(t),resultName:r,nextLoc:a},"next"===this.method&&(this.arg=void 0),l}},t}function payment_asyncGeneratorStep(t,r,a,o,i,c,u){try{var l=t[c](u),p=l.value}catch(t){return void a(t)}l.done?r(p):Promise.resolve(p).then(o,i)}function payment_asyncToGenerator(t){return function(){var r=this,a=arguments;return new Promise((function(o,i){var c=t.apply(r,a);function _next(t){payment_asyncGeneratorStep(c,o,i,_next,_throw,"next",t)}function _throw(t){payment_asyncGeneratorStep(c,o,i,_next,_throw,"throw",t)}_next(void 0)}))}}function payment_defineProperties(t,r){for(var a=0;a2&&void 0!==u[2]&&u[2],i=!(u.length>3&&void 0!==u[3])||u[3],!(c=DSA5Payment.canPay(r,a,o)).success){l.next=6;break}return l.next=6,DSA5Payment._updateMoney(r,c.actorsMoney.money,c.actorsMoney.sum-c.money,i);case 6:return o||""==c.msg||ChatMessage.create(t.Z.chatDataSetup("

    ".concat(c.msg,"

    "),"roll")),l.abrupt("return",c.success);case 8:case"end":return l.stop()}}),_callee)}))),function payMoney(t,r){return c.apply(this,arguments)})},{key:"canPay",value:function canPay(t,r,a){var o=this._getPaymoney(r),i={success:!1,msg:"",money:o};return o&&(i.actorsMoney=this._actorsMoney(t),i.actorsMoney.sum>=o?(i.msg=game.i18n.format("PAYMENT.pay",{actor:t.name,amount:DSA5Payment._moneyToString(o)}),i.success=!0):(i.msg=game.i18n.format("PAYMENT.cannotpay",{actor:t.name,amount:DSA5Payment._moneyToString(o)}),a&&ui.notifications.notify(i.msg))),i}},{key:"getMoney",value:(i=payment_asyncToGenerator(payment_regeneratorRuntime().mark((function _callee2(r,a){var o,i,c,u,l,p=arguments;return payment_regeneratorRuntime().wrap((function _callee2$(d){for(;;)switch(d.prev=d.next){case 0:if(o=p.length>2&&void 0!==p[2]&&p[2],i=!(p.length>3&&void 0!==p[3])||p[3],!(c=this._getPaidmoney(a))){d.next=10;break}return u=this._actorsMoney(r),d.next=7,DSA5Payment._updateMoney(r,u.money,u.sum+c,i);case 7:return l="

    ".concat(game.i18n.format("PAYMENT.getPaid",{actor:r.name,amount:DSA5Payment._moneyToString(c)}),"

    "),o||ChatMessage.create(t.Z.chatDataSetup(l,"roll")),d.abrupt("return",!0);case 10:case"end":return d.stop()}}),_callee2,this)}))),function getMoney(t,r){return i.apply(this,arguments)})},{key:"_updateMoney",value:(o=payment_asyncToGenerator(payment_regeneratorRuntime().mark((function _callee3(t,r,a){var o,i,c,u,l,p=arguments;return payment_regeneratorRuntime().wrap((function _callee3$(d){for(;;)switch(d.prev=d.next){case 0:o=!(p.length>3&&void 0!==p[3])||p[3],i=DSA5Payment._moneyToCoins(a),c=payment_createForOfIteratorHelper(r),d.prev=3,c.s();case 5:if((u=c.n()).done){d.next=20;break}l=u.value,d.t0=l.name,d.next="Money-D"===d.t0?10:"Money-S"===d.t0?12:"Money-H"===d.t0?14:"Money-K"===d.t0?16:18;break;case 10:return l.system.quantity.value=i.D,d.abrupt("break",18);case 12:return l.system.quantity.value=i.S,d.abrupt("break",18);case 14:return l.system.quantity.value=i.H,d.abrupt("break",18);case 16:return l.system.quantity.value=i.K,d.abrupt("break",18);case 18:d.next=5;break;case 20:d.next=25;break;case 22:d.prev=22,d.t1=d.catch(3),c.e(d.t1);case 25:return d.prev=25,c.f(),d.finish(25);case 28:return d.next=30,t.updateEmbeddedDocuments("Item",r,{render:o});case 30:case"end":return d.stop()}}),_callee3,null,[[3,22,25,28]])}))),function _updateMoney(t,r,a){return o.apply(this,arguments)})},{key:"createGetPaidChatMessage",value:function createGetPaidChatMessage(r){var a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:void 0,o=this._getPaidmoney(r);if(o){var i=a?" (".concat(a,")"):"",c="

    ".concat(game.i18n.localize("PAYMENT.wage"),"

    ").concat(game.i18n.format("PAYMENT.getPaidSum",{amount:DSA5Payment._moneyToString(o)})).concat(i,'

    ");ChatMessage.create(t.Z.chatDataSetup(c,"roll"))}}},{key:"createPayChatMessage",value:function createPayChatMessage(r){var a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:void 0,o=this._getPaymoney(r);if(o){var i=a?" (".concat(a,")"):"",c="

    ".concat(game.i18n.localize("PAYMENT.bill"),"

    ").concat(game.i18n.format("PAYMENT.paySum",{amount:DSA5Payment._moneyToString(o)})).concat(i,'

    ");ChatMessage.create(t.Z.chatDataSetup(c,"roll"))}}},{key:"_getPaidmoney",value:function _getPaidmoney(r){var a=this._parseMoneyString(r);if(!a){var o="

    ".concat(game.i18n.localize("PAYMENT.error"),"

    ").concat(game.i18n.localize("PAYMENT.getPaidexample"),"

    ");return ChatMessage.create(t.Z.chatDataSetup(o,"roll")),!1}return a}},{key:"_getPaymoney",value:function _getPaymoney(r){var a=this._parseMoneyString(r);if(!a){var o="

    ".concat(game.i18n.localize("PAYMENT.error"),"

    ").concat(game.i18n.localize("PAYMENT.payexample"),"

    ");return ChatMessage.create(t.Z.chatDataSetup(o,"roll")),!1}return a}},{key:"_parseMoneyString",value:function _parseMoneyString(t){var r=t.replace(",",".").match(/\d{1,}(\.\d{1,3}|,\d{1,3})?/);return!!r&&Number(r[0])}},{key:"_actorsMoney",value:function _actorsMoney(t){var r=duplicate(t.items.filter((function(t){return"money"==t.type})));return{money:r,sum:r.reduce((function(t,r){return t+Number(r.system.quantity.value)*Number(r.system.price.value)}),0)}}},{key:"handlePayAction",value:(a=payment_asyncToGenerator(payment_regeneratorRuntime().mark((function _callee4(t,r,a){var o,i,c=arguments;return payment_regeneratorRuntime().wrap((function _callee4$(u){for(;;)switch(u.prev=u.next){case 0:if(o=c.length>3&&void 0!==c[3]?c[3]:void 0,!game.user.isGM||o){u.next=4;break}return ui.notifications.notify(game.i18n.localize("PAYMENT.onlyActors")),u.abrupt("return");case 4:if(o?m.Z.playMoneySound(!0):o=game.user.character,i=!1,!o||!r){u.next=12;break}return u.next=9,DSA5Payment.payMoney(o,a);case 9:i=u.sent,u.next=19;break;case 12:if(!o||r){u.next=18;break}return u.next=15,DSA5Payment.getMoney(o,a);case 15:i=u.sent,u.next=19;break;case 18:ui.notifications.notify(game.i18n.localize("PAYMENT.onlyActors"));case 19:i&&t&&(t.fadeOut(),game.socket.emit("system.dsa5",{type:"updateMsg",payload:{id:t.closest(".message").attr("data-message-id"),updateData:_defineProperty({},"flags.dsa5.userHidden.".concat(game.user.id),!0)}}));case 20:case"end":return u.stop()}}),_callee4)}))),function handlePayAction(t,r,o){return a.apply(this,arguments)})},{key:"_moneyToCoins",value:function _moneyToCoins(t){var r=Math.round(100*t),a=Math.floor(r/1e3),o=Math.floor((r-1e3*a)/100),i=Math.floor((r-1e3*a-100*o)/10);return{D:a,S:o,H:i,K:Math.round(r-1e3*a-100*o-10*i)}}},{key:"_moneyToString",value:function _moneyToString(t){for(var r=DSA5Payment._moneyToCoins(t),a=[],o=0,i=Object.entries(r);o0&&a.push(''.concat(l,' '))}return a.join(", ")}},{key:"chatListeners",value:(r=payment_asyncToGenerator(payment_regeneratorRuntime().mark((function _callee5(t){return payment_regeneratorRuntime().wrap((function _callee5$(r){for(;;)switch(r.prev=r.next){case 0:t.on("click",".payButton",(function(t){var r=$(t.currentTarget);DSA5Payment.handlePayAction(r,1!=Number(r.attr("data-pay")),r.attr("data-amount")),m.Z.playMoneySound()}));case 1:case"end":return r.stop()}}),_callee5)}))),function chatListeners(t){return r.apply(this,arguments)})}]),DSA5Payment}();function tokenHotbar2_typeof(t){return tokenHotbar2_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},tokenHotbar2_typeof(t)}function tokenHotbar2_createForOfIteratorHelper(t,r){var a="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!a){if(Array.isArray(t)||(a=tokenHotbar2_unsupportedIterableToArray(t))||r&&t&&"number"==typeof t.length){a&&(t=a);var o=0,i=function F(){};return{s:i,n:function n(){return o>=t.length?{done:!0}:{done:!1,value:t[o++]}},e:function e(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var c,u=!0,l=!1;return{s:function s(){a=a.call(t)},n:function n(){var t=a.next();return u=t.done,t},e:function e(t){l=!0,c=t},f:function f(){try{u||null==a.return||a.return()}finally{if(l)throw c}}}}function _toConsumableArray(t){return function _arrayWithoutHoles(t){if(Array.isArray(t))return tokenHotbar2_arrayLikeToArray(t)}(t)||function _iterableToArray(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||tokenHotbar2_unsupportedIterableToArray(t)||function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function tokenHotbar2_unsupportedIterableToArray(t,r){if(t){if("string"==typeof t)return tokenHotbar2_arrayLikeToArray(t,r);var a=Object.prototype.toString.call(t).slice(8,-1);return"Object"===a&&t.constructor&&(a=t.constructor.name),"Map"===a||"Set"===a?Array.from(t):"Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a)?tokenHotbar2_arrayLikeToArray(t,r):void 0}}function tokenHotbar2_arrayLikeToArray(t,r){(null==r||r>t.length)&&(r=t.length);for(var a=0,o=new Array(r);a=0;--o){var i=this.tryEntries[o],c=i.completion;if("root"===i.tryLoc)return handle("end");if(i.tryLoc<=this.prev){var u=a.call(i,"catchLoc"),l=a.call(i,"finallyLoc");if(u&&l){if(this.prev=0;--o){var i=this.tryEntries[o];if(i.tryLoc<=this.prev&&a.call(i,"finallyLoc")&&this.prev=0;--r){var a=this.tryEntries[r];if(a.finallyLoc===t)return this.complete(a.completion,a.afterLoc),resetTryEntry(a),l}},catch:function _catch(t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc===t){var o=a.completion;if("throw"===o.type){var i=o.arg;resetTryEntry(a)}return i}}throw new Error("illegal catch attempt")},delegateYield:function delegateYield(t,r,a){return this.delegate={iterator:values(t),resultName:r,nextLoc:a},"next"===this.method&&(this.arg=void 0),l}},t}function tokenHotbar2_asyncGeneratorStep(t,r,a,o,i,c,u){try{var l=t[c](u),p=l.value}catch(t){return void a(t)}l.done?r(p):Promise.resolve(p).then(o,i)}function tokenHotbar2_asyncToGenerator(t){return function(){var r=this,a=arguments;return new Promise((function(o,i){var c=t.apply(r,a);function _next(t){tokenHotbar2_asyncGeneratorStep(c,o,i,_next,_throw,"next",t)}function _throw(t){tokenHotbar2_asyncGeneratorStep(c,o,i,_next,_throw,"throw",t)}_next(void 0)}))}}function tokenHotbar2_classCallCheck(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}function tokenHotbar2_defineProperties(t,r){for(var a=0;a0?Math.min(100,r+5):Math.max(15,r-5),a.next=4,game.settings.set("dsa5","tokenhotbarSize",r);case 4:return a.next=6,this.render(!0);case 6:case"end":return a.stop()}}),_callee2,this)}))),function _onWheelResize(t){return x.apply(this,arguments)})},{key:"_cycleLayout",value:(k=tokenHotbar2_asyncToGenerator(tokenHotbar2_regeneratorRuntime().mark((function _callee3(t){var r;return tokenHotbar2_regeneratorRuntime().wrap((function _callee3$(a){for(;;)switch(a.prev=a.next){case 0:if(2!=t.button){a.next=7;break}return 4==(r=game.settings.get("dsa5","tokenhotbarLayout")+1)&&(r=0),a.next=5,game.settings.set("dsa5","tokenhotbarLayout",r);case 5:return a.next=7,this.render(!0);case 7:case"end":return a.stop()}}),_callee3,this)}))),function _cycleLayout(t){return k.apply(this,arguments)})},{key:"changeDarkness",value:function changeDarkness(t){var r=Number(t.currentTarget.value);canvas.scene&&canvas.scene.update({darkness:r},{animateDarkness:3e3}),(0,h.p0)(r)}},{key:"activateListeners",value:function activateListeners(t){var r=this;tokenHotbar2_get(tokenHotbar2_getPrototypeOf(TokenHotbar2.prototype),"activateListeners",this).call(this,t);var a=t.find(".dragHandler");new Draggable(this,t,a[0],this.options.resizable),a.on("wheel",function(){var t=tokenHotbar2_asyncToGenerator(tokenHotbar2_regeneratorRuntime().mark((function _callee4(t){return tokenHotbar2_regeneratorRuntime().wrap((function _callee4$(a){for(;;)switch(a.prev=a.next){case 0:return t.stopPropagation(),t.preventDefault(),a.next=4,r._onWheelResize(t);case 4:return a.abrupt("return",!1);case 5:case"end":return a.stop()}}),_callee4)})));return function(r){return t.apply(this,arguments)}}()),a.on("mousedown",function(){var t=tokenHotbar2_asyncToGenerator(tokenHotbar2_regeneratorRuntime().mark((function _callee5(t){return tokenHotbar2_regeneratorRuntime().wrap((function _callee5$(a){for(;;)switch(a.prev=a.next){case 0:return a.next=2,r._cycleLayout(t);case 2:case"end":return a.stop()}}),_callee5)})));return function(r){return t.apply(this,arguments)}}()),t.find(".itdarkness input").change((function(t){return r.changeDarkness(t)}));var o=this,i=function fn(t){return o.filterButtons(t),!1};t.find(".filterable").hover((function(){$(document).keydown(i)}),(function(){$(document).unbind("keydown",i)})),t.find(".quantity-click").mousedown((function(t){return y.Z.quantityClick(t)})),t.on("mousedown","li",function(){var t=tokenHotbar2_asyncToGenerator(tokenHotbar2_regeneratorRuntime().mark((function _callee6(t){return tokenHotbar2_regeneratorRuntime().wrap((function _callee6$(a){for(;;)switch(a.prev=a.next){case 0:return t.stopPropagation(),a.next=3,r.executeQuickButton(t);case 3:return a.abrupt("return",!1);case 4:case"end":return a.stop()}}),_callee6)})));return function(r){return t.apply(this,arguments)}}()),t.on("mouseenter","li.primary",(function(a){var o=a.currentTarget.dataset.category;r.category=o,setTimeout((function(){t.find(".secondary").removeClass("shown"),o==r.category&&t.find('.secondary[data-category="'.concat(o,'"]')).addClass("shown")}),700)})),t.on("mouseleave","li.primary",(function(a){var i=a.currentTarget.dataset.category;r.category=void 0,setTimeout((function(){i!=r.category&&(o.searching="",$(a.currentTarget).find(".secondary").removeClass("dsahidden"),t.find('.secondary[data-category="'.concat(i,'"]')).removeClass("shown"))}),50)}))}},{key:"handleEffect",value:(_=tokenHotbar2_asyncToGenerator(tokenHotbar2_regeneratorRuntime().mark((function _callee7(t,r,a,o){var i,c;return tokenHotbar2_regeneratorRuntime().wrap((function _callee7$(o){for(;;)switch(o.prev=o.next){case 0:if(i=r.effects.get(a),c=_toConsumableArray(i.statuses)[0],0!=t.button){o.next=11;break}if(!c){o.next=8;break}return o.next=6,r.addCondition(c,1,!1,!1);case 6:o.next=9;break;case 8:i.sheet.render(!0);case 9:o.next=19;break;case 11:if(2!=t.button){o.next=19;break}if(!c){o.next=17;break}return o.next=15,r.removeCondition(c,1,!1);case 15:o.next=19;break;case 17:return o.next=19,r.sheet._deleteActiveEffect(a);case 19:return o.next=21,this.render(!0);case 21:case"end":return o.stop()}}),_callee7,this)}))),function handleEffect(t,r,a,o){return _.apply(this,arguments)})},{key:"handleGMRoll",value:(v=tokenHotbar2_asyncToGenerator(tokenHotbar2_regeneratorRuntime().mark((function _callee8(t){var r,a;return tokenHotbar2_regeneratorRuntime().wrap((function _callee8$(o){for(;;)switch(o.prev=o.next){case 0:r=t.currentTarget.dataset.id,a=Math.round($(t.currentTarget).closest(".tokenHotbarInner").find(".modifierVal").val()),t.ctrlKey?game.dsa5.apps.DSA5ChatListeners.check3D20(void 0,r,{modifier:a}):2==t.button?game.dsa5.macro.requestGC(r,a,{maxRolls:7}):game.dsa5.macro.requestRoll(r,a);case 3:case"end":return o.stop()}}),_callee8)}))),function handleGMRoll(t){return v.apply(this,arguments)})},{key:"handleSkillRoll",value:(m=tokenHotbar2_asyncToGenerator(tokenHotbar2_regeneratorRuntime().mark((function _callee10(t,r,a,o){var i,c,u=this;return tokenHotbar2_regeneratorRuntime().wrap((function _callee10$(l){for(;;)switch(l.prev=l.next){case 0:if(i={},2==t.button&&(i.rollMode="blindroll"),"rideLoyaltyID"!=a){l.next=6;break}b.Z.rollLoyalty(r,i),l.next=25;break;case 6:if("attackWeaponless"!=a){l.next=10;break}r.setupWeaponless("attack",i,o).then((function(t){r.basicTest(t)})),l.next=25;break;case 10:if(!(c=r.items.get(a))){l.next=25;break}if(!t.originalEvent.ctrlKey){l.next=14;break}return l.abrupt("return",c.sheet.render(!0));case 14:l.t0=c.type,l.next="meleeweapon"===l.t0||"rangeweapon"===l.t0||"trait"===l.t0?17:"liturgy"===l.t0||"spell"===l.t0?19:"skill"===l.t0?21:"consumable"===l.t0?23:25;break;case 17:return r.setupWeapon(c,"attack",i,o).then((function(t){r.basicTest(t)})),l.abrupt("break",25);case 19:return r.setupSpell(c,i,o).then((function(t){r.basicTest(t)})),l.abrupt("break",25);case 21:return r.setupSkill(c,i,o).then((function(t){r.basicTest(t)})),l.abrupt("break",25);case 23:return new Dialog({title:game.i18n.localize("SHEET.ConsumeItem")+": "+c.name,content:game.i18n.localize("SHEET.ConsumeItem")+": "+c.name,default:"yes",buttons:{Yes:{icon:'',label:game.i18n.localize("yes"),callback:function(){var t=tokenHotbar2_asyncToGenerator(tokenHotbar2_regeneratorRuntime().mark((function _callee9(){return tokenHotbar2_regeneratorRuntime().wrap((function _callee9$(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,c.setupEffect(null,{},o);case 2:return t.next=4,u.updateDSA5Hotbar();case 4:case"end":return t.stop()}}),_callee9)})));return function callback(){return t.apply(this,arguments)}}()},cancel:{icon:'',label:game.i18n.localize("cancel")}}}).render(!0),l.abrupt("break",25);case 25:case"end":return l.stop()}}),_callee10)}))),function handleSkillRoll(t,r,a,o){return m.apply(this,arguments)})},{key:"handleOnUse",value:(p=tokenHotbar2_asyncToGenerator(tokenHotbar2_regeneratorRuntime().mark((function _callee11(t,r,a,o){var i;return tokenHotbar2_regeneratorRuntime().wrap((function _callee11$(t){for(;;)switch(t.prev=t.next){case 0:i=r.items.get(a),new g.Z(i).executeOnUseEffect();case 3:case"end":return t.stop()}}),_callee11)}))),function handleOnUse(t,r,a,o){return p.apply(this,arguments)})},{key:"handleGM",value:(l=tokenHotbar2_asyncToGenerator(tokenHotbar2_regeneratorRuntime().mark((function _callee12(r,a,o,i){return tokenHotbar2_regeneratorRuntime().wrap((function _callee12$(c){for(;;)switch(c.prev=c.next){case 0:c.t0=o,c.next="masterMenu"===c.t0?3:"payMoney"===c.t0?5:"randomVictim"===c.t0?7:9;break;case 3:return t.Z.renderToggle(game.dsa5.apps.gameMasterMenu),c.abrupt("break",10);case 5:return this.payMoney(r),c.abrupt("break",10);case 7:return this.handleGMRandomVictim(r),c.abrupt("break",10);case 9:o in this.callbackFunctions&&this.callbackFunctions[o](r,a,o,i);case 10:case"end":return c.stop()}}),_callee12,this)}))),function handleGM(t,r,a,o){return l.apply(this,arguments)})},{key:"payMoney",value:function payMoney(t){var r="".concat($(t.currentTarget).closest(".tokenHotbarInner").find(".modifierVal").val());2==t.button?w.createGetPaidChatMessage(r):w.createPayChatMessage(r)}},{key:"handleGMRandomVictim",value:(u=tokenHotbar2_asyncToGenerator(tokenHotbar2_regeneratorRuntime().mark((function _callee13(r){var a,o,i;return tokenHotbar2_regeneratorRuntime().wrap((function _callee13$(c){for(;;)switch(c.prev=c.next){case 0:return c.next=2,game.dsa5.apps.gameMasterMenu.rollRandomPlayer(2==r.button);case 2:if(a=c.sent,!(o=game.actors.get(a))){c.next=9;break}return c.next=7,t.Z.showArtwork(o);case 7:i=c.sent,r.originalEvent.ctrlKey||setTimeout((function(){i.close()}),2e3);case 9:case"end":return c.stop()}}),_callee13)}))),function handleGMRandomVictim(t){return u.apply(this,arguments)})},{key:"executeQuickButton",value:(c=tokenHotbar2_asyncToGenerator(tokenHotbar2_regeneratorRuntime().mark((function _callee14(t){var r,a,o,i,c,u;return tokenHotbar2_regeneratorRuntime().wrap((function _callee14$(l){for(;;)switch(l.prev=l.next){case 0:o=null===(r=canvas.tokens.controlled[0])||void 0===r?void 0:r.actor,i=null===(a=canvas.tokens.controlled[0])||void 0===a?void 0:a.id,c=t.currentTarget.dataset.id,u=t.currentTarget.dataset.subfunction,l.t0=u,l.next="addEffect"===l.t0?7:"effect"===l.t0?9:"onUse"===l.t0?11:"gm"===l.t0?13:"none"===l.t0||"darkness"===l.t0?15:"skillgm"===l.t0?16:18;break;case 7:return S.showDialog(),l.abrupt("break",19);case 9:return this.handleEffect(t,o,c,i),l.abrupt("break",19);case 11:return this.handleOnUse(t,o,c,i),l.abrupt("break",19);case 13:return this.handleGM(t,o,c,i),l.abrupt("break",19);case 15:return l.abrupt("break",19);case 16:return this.handleGMRoll(t),l.abrupt("break",19);case 18:this.handleSkillRoll(t,o,c,i);case 19:case"end":return l.stop()}}),_callee14,this)}))),function executeQuickButton(t){return c.apply(this,arguments)})},{key:"subWidth",value:function subWidth(t,r){var a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:7;return'style="width:'.concat(200*Math.ceil(t.length/a),'px"')}},{key:"getData",value:(i=tokenHotbar2_asyncToGenerator(tokenHotbar2_regeneratorRuntime().mark((function _callee15(){var t,r,a,o,i,c,u,l,p,h,m,y,g,v,_,k,w,x,S,T,A,O,P,E,C,D,I,R,L,G,M,j,z,N,H,$,Z,W=this;return tokenHotbar2_regeneratorRuntime().wrap((function _callee15$(B){for(;;)switch(B.prev=B.next){case 0:return B.next=2,tokenHotbar2_get(tokenHotbar2_getPrototypeOf(TokenHotbar2.prototype),"getData",this).call(this);case 2:if(r=B.sent,a=this.actor,o={attacks:[],spells:[],default:[],skills:[],gm:[]},u=[],l=[],p=[],h=game.settings.get("dsa5","tokenhotbarLayout"),m=h%2,y=TokenHotbar2.defaultOptions.itemWidth,g=["liturgy","spell"],v=!1,!a){B.next=30;break}return _=[],k=[],w=b.Z.isRiding(a),x=game.i18n.localize("LocalizedIDs.riding"),B.next=20,a.actorEffects();case 20:if(p=B.sent.map((function(t){return{name:t.name,id:t.id,icon:t.icon,cssClass:"effect",abbrev:"".concat(t.name[0]," ").concat(t.getFlag("dsa5","value")||""),subfunction:"effect"}})),game.combat){S=a.items.filter((function(t){return"combatskill"==t.type})).map((function(t){return d.Z._calculateCombatSkillValues(t.toObject(),a.system)})),T=S.find((function(t){return t.name==game.i18n.localize("LocalizedIDs.wrestle")})),T&&o.attacks.push({name:game.i18n.localize("attackWeaponless"),id:"attackWeaponless",icon:"systems/dsa5/icons/categories/attack_weaponless.webp",attack:T.system.attack.value,damage:"1d6"}),A=["meleeweapon","rangeweapon"],O=["meleeAttack","rangeAttack"],P=tokenHotbar2_createForOfIteratorHelper(a.items);try{for(C=function _loop(){var t=E.value;if(["skill"].includes(t.type)&&(W.combatSkills.some((function(r){return t.name.startsWith(r)}))||w&&x==t.name)&&o.default.push({name:"".concat(t.name," (").concat(t.system.talentValue.value,")"),id:t.id,icon:t.img,cssClass:"skill filterable",abbrev:t.name[0]}),"trait"==t.type&&O.includes(t.system.traitType.value)){var r=d.Z._parseDmg(t.toObject());o.attacks.push({name:t.name,id:t.id,icon:t.img,cssClass:"weapon ".concat(t.id),abbrev:t.name[0],attack:t.system.at.value,damage:r.damagedie,dadd:r.damageAdd})}else if(A.includes(t.type)&&1==t.system.worn.value){var i="meleeweapon"==t.type?d.Z._prepareMeleeWeapon(t.toObject(),S,a):d.Z._prepareRangeWeapon(t.toObject(),[],S,a);o.attacks.push({name:t.name,id:t.id,icon:t.img,cssClass:"weapon ".concat(t.id),abbrev:t.name[0],attack:i.attack,damage:i.damagedie,dadd:i.damageAdd})}else if(g.includes(t.type))t.system.effectFormula.value?o.spells.push({name:t.name,id:t.id,icon:t.img,cssClass:"spell",abbrev:t.name[0]}):k.push({name:t.name,id:t.id,icon:t.img,cssClass:"spell",abbrev:t.name[0]});else if(["skill"].includes(t.type)){var c={name:"".concat(t.name," (").concat(t.system.talentValue.value,")"),id:t.id,icon:t.img,cssClass:"skill",addClass:t.system.group.value,abbrev:t.name[0],tw:t.system.talentValue.value};_.push(c)}else"consumable"==t.type&&u.push({name:t.name,id:t.id,icon:t.img,cssClass:"consumable",abbrev:t.system.quantity.value});t.getFlag("dsa5","onUseEffect")&&l.push({name:t.name,id:t.id,icon:t.img,cssClass:"onUse",abbrev:t.name[0],subfunction:"onUse"})},P.s();!(E=P.n()).done;)C()}catch(t){P.e(t)}finally{P.f()}i=u.pop(),w&&(D=b.Z.getHorse(a))&&(I=b.Z.getLoyaltyFromHorse(D))&&o.default.push({name:"".concat(I.name," (").concat(I.system.talentValue.value,")"),id:"rideLoyaltyID",icon:I.img,cssClass:"skill",abbrev:I.name[0]})}else{L=[],G=tokenHotbar2_createForOfIteratorHelper(a.items);try{for(G.s();!(M=G.n()).done;)j=M.value,["skill"].includes(j.type)&&(this.defaultSkills.includes(j.name)||w&&x==j.name)&&o.default.push({name:"".concat(j.name," (").concat(j.system.talentValue.value,")"),id:j.id,icon:j.img,cssClass:"skill filterable",abbrev:j.name[0]}),["skill"].includes(j.type)?(z={name:"".concat(j.name," (").concat(j.system.talentValue.value,")"),id:j.id,icon:j.img,cssClass:"skill",addClass:j.system.group.value,abbrev:j.name[0],tw:j.system.talentValue.value},j.system.talentValue.value>0&&(z.cssClass+=" filterable",L.push(z)),_.push(z)):g.includes(j.type)&&(j.system.effectFormula.value?o.spells.push({name:j.name,id:j.id,icon:j.img,cssClass:"spell",abbrev:j.name[0]}):k.push({name:j.name,id:j.id,icon:j.img,cssClass:"spell",abbrev:j.name[0]})),j.getFlag("dsa5","onUseEffect")&&l.push({name:j.name,id:j.id,icon:j.img,cssClass:"onUse",abbrev:j.name[0],subfunction:"onUse"})}catch(t){G.e(t)}finally{G.f()}(R=o.skills).push.apply(R,_toConsumableArray(L.sort((function(t,r){return r.tw-t.tw})).slice(0,5)))}c=l.pop(),0==o.spells.length&&k.length>0&&o.spells.push(k.pop()),o.spells.length>0&&k.length>0&&(o.spells[0].more=k.sort((function(t,r){return t.name.localeCompare(r.name)})),o.spells[0].subwidth=this.subWidth(k,y)),o.default.length>0&&_.length>0&&(o.default[0].more=_.sort((function(t,r){return t.addClass.localeCompare(r.addClass)||t.name.localeCompare(r.name)})),o.default[0].subwidth=this.subWidth(_,y,20)),i&&(u.length>0&&(i.more=u,i.subwidth=this.subWidth(u,y)),o.consumables=[i]),c&&(l.length>0&&(c.more=l,c.subwidth=this.subWidth(l,y)),o.onUsages=[c]),B.next=39;break;case 30:if(!game.user.isGM||game.settings.get("dsa5","disableTokenhotbarMaster")){B.next=39;break}if(v=!0,B.t0=this.skills,B.t0){B.next=37;break}return B.next=36,this.prepareSkills();case 36:B.t0=B.sent;case 37:N=B.t0,o.gm=this.gmItems.filter((function(t){return!t.disabled})).concat([{name:"TT.tokenhotbarSkill",id:"skillgm",icon:"systems/dsa5/icons/categories/Skill.webp",cssClass:"skillgm filterable",abbrev:"",subfunction:"none",more:N,subwidth:this.subWidth(N,y,20)}]);case 39:return this.showEffects&&(H=game.i18n.localize("CONDITION.add"),$={name:"CONDITION.add",id:"",icon:"icons/svg/aura.svg",cssClass:"effect",abbrev:H[0],subfunction:"addEffect"},p.length>0&&($.more=p,$.subwidth=this.subWidth(p,y)),o.effects=[$]),Z=Object.keys(o).reduce((function(t,r){return t+o[r].length}),0)+(v?3:0),m?(this.position.width=y,this.position.height=y*Z+14):(this.position.width=y*Z+14,this.position.height=y),mergeObject(r,{items:o,itemWidth:y,direction:h,count:Z,gmMode:v,darkness:(null===(t=canvas.scene)||void 0===t?void 0:t.darkness)||0,opacity:game.settings.get("dsa5","tokenhotbaropacity")}),B.abrupt("return",r);case 44:case"end":return B.stop()}}),_callee15,this)}))),function getData(){return i.apply(this,arguments)})},{key:"filterButtons",value:function filterButtons(t){switch(t.which){case 17:return;case 8:this.searching=this.searching.slice(0,-1);break;default:this.searching+=String.fromCharCode(t.which)}t.preventDefault(),t.stopPropagation();var r=this.searching.toLowerCase();(0,h.p0)(r);var a=$(t.currentTarget).find(".subbuttons li");a.find(".dsahidden").removeClass("dsahidden"),a.filter((function(){return-1==$(this).find("label").text().toLowerCase().trim().indexOf(r)})).addClass("dsahidden")}},{key:"render",value:(o=tokenHotbar2_asyncToGenerator(tokenHotbar2_regeneratorRuntime().mark((function _callee16(t){var r,a,o=arguments;return tokenHotbar2_regeneratorRuntime().wrap((function _callee16$(i){for(;;)switch(i.prev=i.next){case 0:return r=o.length>1&&void 0!==o[1]?o[1]:{},i.next=3,tokenHotbar2_get(tokenHotbar2_getPrototypeOf(TokenHotbar2.prototype),"render",this).call(this,t,r);case 3:return a=i.sent,this._element&&this._element.css({zIndex:61}),i.abrupt("return",a);case 6:case"end":return i.stop()}}),_callee16,this)}))),function render(t){return o.apply(this,arguments)})},{key:"setPosition",value:function setPosition(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=t.left,a=t.top,o=t.width,i=t.height,c=t.scale,u=tokenHotbar2_get(tokenHotbar2_getPrototypeOf(TokenHotbar2.prototype),"setPosition",this).call(this,{left:r,top:a,width:o,height:i,scale:c}),l=this.element[0];if(!l.style.width||o){var p=o||l.offsetWidth,d=l.style.maxWidth||window.innerWidth;u.width=o=Math.clamped(p,0,d),l.style.width=o+"px",o+u.left>window.innerWidth&&(r=u.left)}return game.settings.set("dsa5","tokenhotbarPosition",{left:u.left,top:u.top}),u}},{key:"updateDSA5Hotbar",value:(a=tokenHotbar2_asyncToGenerator(tokenHotbar2_regeneratorRuntime().mark((function _callee17(){var t,r;return tokenHotbar2_regeneratorRuntime().wrap((function _callee17$(a){for(;;)switch(a.prev=a.next){case 0:return t=canvas.tokens.controlled,this.actor=void 0,this.showEffects=!1,1===t.length&&(r=t[0].actor)&&r.isOwner&&(this.actor=r),t.length>=1&&(this.showEffects=!0),a.next=7,this.render(!0,{focus:!1});case 7:case"end":return a.stop()}}),_callee17,this)}))),function updateDSA5Hotbar(){return a.apply(this,arguments)})}],[{key:"registerTokenHotbar",value:function registerTokenHotbar(){game.dsa5.apps.tokenHotbar||(game.dsa5.apps.tokenHotbar=new TokenHotbar2,game.dsa5.apps.tokenHotbar.render(!0),Hooks.call("dsa5TokenHotbarReady",game.dsa5.apps.tokenHotbar))}},{key:"unregisterTokenHotbar",value:function unregisterTokenHotbar(){game.dsa5.apps.tokenHotbar&&(game.dsa5.apps.tokenHotbar.close(),game.dsa5.apps.tokenHotbar=void 0)}},{key:"hookUpdate",value:function hookUpdate(t){game.dsa5.apps.tokenHotbar&&t==getProperty(game.dsa5.apps.tokenHotbar,"actor.id")&&game.dsa5.apps.tokenHotbar.updateDSA5Hotbar()}},{key:"defaultOptions",get:function get(){var t=tokenHotbar2_get(tokenHotbar2_getPrototypeOf(TokenHotbar2),"defaultOptions",this),r=$("#hotbar").first().position(),a=game.settings.get("dsa5","tokenhotbarSize"),o=game.settings.get("dsa5","tokenhotbarPosition");return mergeObject(t,{classes:t.classes.concat(["dsa5","tokenQuickHot"]),itemWidth:a,resizable:!1,height:a+45,zIndex:61,left:r.left+8,top:r.top-a-25,template:"systems/dsa5/templates/status/tokenHotbar.html",title:"TokenHotbar"}),mergeObject(t,o),t}}]),TokenHotbar2}(),S=function(t){tokenHotbar2_inherits(AddEffectDialog,Dialog);var r,a,o,i,c=tokenHotbar2_createSuper(AddEffectDialog);function AddEffectDialog(){return tokenHotbar2_classCallCheck(this,AddEffectDialog),c.apply(this,arguments)}return tokenHotbar2_createClass(AddEffectDialog,[{key:"activateListeners",value:function activateListeners(t){var r=this;tokenHotbar2_get(tokenHotbar2_getPrototypeOf(AddEffectDialog.prototype),"activateListeners",this).call(this,t),t.find(".reactClick").mouseenter((function(t){if(0==t.currentTarget.getElementsByClassName("hovermenu").length){var a=document.createElement("div");a.classList.add("hovermenu"),a.style.cssText="font-size: var(--font-size-20);";var o=document.createElement("i");o.classList.add("fas","fa-cogs"),o.title=game.i18n.localize("ActiveEffects.custom"),o.addEventListener("click",function(){var t=tokenHotbar2_asyncToGenerator(tokenHotbar2_regeneratorRuntime().mark((function _callee18(t){return tokenHotbar2_regeneratorRuntime().wrap((function _callee18$(a){for(;;)switch(a.prev=a.next){case 0:return a.abrupt("return",r.configureEffect(t));case 1:case"end":return a.stop()}}),_callee18)})));return function(r){return t.apply(this,arguments)}}(),!1),a.appendChild(o),t.currentTarget.appendChild(a)}})),t.find(".reactClick").mouseleave((function(t){var a=t.toElement||t.relatedTarget;a.parentNode!=r&&a!=r&&t.currentTarget.querySelectorAll(".hovermenu").forEach((function(t){return t.remove()}))})),t.find(".quantity-click").mousedown((function(t){return y.Z.quantityClick(t)})),t.find(".reactClick").click((function(t){return r.addEffect(t.currentTarget.dataset.value)}));var a=t.find(".conditionSearch");a.keyup((function(a){return r._filterConditions($(a.currentTarget),t)})),a[0]&&a[0].addEventListener("search",(function filterConditions(a){return r._filterConditions($(a.currentTarget),t)}),!1)}},{key:"_filterConditions",value:function _filterConditions(t,r){if(null!=t.val()){var a=t.val().toLowerCase().trim(),o=r.find(".filterable");r.find(".filterHide").removeClass("filterHide"),o.filter((function(){return-1==$(this).find("span").text().toLowerCase().trim().indexOf(a)})).addClass("filterHide")}}},{key:"configureEffect",value:(i=tokenHotbar2_asyncToGenerator(tokenHotbar2_regeneratorRuntime().mark((function _callee20(t){var r,a,o=this;return tokenHotbar2_regeneratorRuntime().wrap((function _callee20$(i){for(;;)switch(i.prev=i.next){case 0:t.stopPropagation(),r=$(t.currentTarget).closest(".reactClick"),a=r.attr("data-value"),this.close(),AddEffectDialog.modifyEffectDialog(a,function(){var t=tokenHotbar2_asyncToGenerator(tokenHotbar2_regeneratorRuntime().mark((function _callee19(t,r){return tokenHotbar2_regeneratorRuntime().wrap((function _callee19$(a){for(;;)switch(a.prev=a.next){case 0:return a.abrupt("return",o.addEffect(t,r));case 1:case"end":return a.stop()}}),_callee19)})));return function(r,a){return t.apply(this,arguments)}}());case 5:case"end":return i.stop()}}),_callee20,this)}))),function configureEffect(t){return i.apply(this,arguments)})},{key:"addEffect",value:(o=tokenHotbar2_asyncToGenerator(tokenHotbar2_regeneratorRuntime().mark((function _callee21(t){var r,a,o,i,c,u=arguments;return tokenHotbar2_regeneratorRuntime().wrap((function _callee21$(l){for(;;)switch(l.prev=l.next){case 0:a=u.length>1&&void 0!==u[1]?u[1]:{},o=tokenHotbar2_createForOfIteratorHelper(canvas.tokens.controlled),l.prev=2,o.s();case 4:if((i=o.n()).done){l.next=10;break}return c=i.value,l.next=8,c.actor.addTimedCondition(t,1,!1,!1,a);case 8:l.next=4;break;case 10:l.next=15;break;case 12:l.prev=12,l.t0=l.catch(2),o.e(l.t0);case 15:return l.prev=15,o.f(),l.finish(15);case 18:null===(r=game.dsa5.apps.tokenHotbar)||void 0===r||r.render(!0),this.close();case 20:case"end":return l.stop()}}),_callee21,this,[[2,12,15,18]])}))),function addEffect(t){return o.apply(this,arguments)})}],[{key:"showDialog",value:(a=tokenHotbar2_asyncToGenerator(tokenHotbar2_regeneratorRuntime().mark((function _callee22(){var t,r;return tokenHotbar2_regeneratorRuntime().wrap((function _callee22$(a){for(;;)switch(a.prev=a.next){case 0:return t=duplicate(CONFIG.statusEffects).map((function(t){return{name:game.i18n.localize(t.name),icon:t.icon,description:game.i18n.localize(t.description),id:t.id}})).sort((function(t,r){return t.name.localeCompare(r.name)})),a.t0=AddEffectDialog,a.t1=game.i18n.localize("CONDITION.add"),a.next=5,renderTemplate("systems/dsa5/templates/dialog/addstatusdialog.html",{effects:t});case 5:a.t2=a.sent,a.t3={},a.t4={title:a.t1,content:a.t2,buttons:a.t3},(r=new a.t0(a.t4)).position.height=36*Math.ceil(t.length/3)+170,r.render(!0);case 11:case"end":return a.stop()}}),_callee22)}))),function showDialog(){return a.apply(this,arguments)})},{key:"modifyEffectDialog",value:(r=tokenHotbar2_asyncToGenerator(tokenHotbar2_regeneratorRuntime().mark((function _callee24(t,r){return tokenHotbar2_regeneratorRuntime().wrap((function _callee24$(a){for(;;)switch(a.prev=a.next){case 0:return a.t0=AddEffectDialog,a.t1=game.i18n.localize("CONDITION."+t),a.next=4,renderTemplate("systems/dsa5/templates/dialog/configurestatusdialog.html");case 4:a.t2=a.sent,a.t3={add:{icon:'',label:game.i18n.localize("CONDITION.add"),callback:function(){var a=tokenHotbar2_asyncToGenerator(tokenHotbar2_regeneratorRuntime().mark((function _callee23(a){var o,i,c;return tokenHotbar2_regeneratorRuntime().wrap((function _callee23$(u){for(;;)switch(u.prev=u.next){case 0:return o={},i="seconds"==a.find("[name=unit]:checked").val()?Math.round(a.find(".duration").val()/5):a.find(".duration").val(),c=a.find(".effectname").val(),i>0&&mergeObject(o,y.Z._buildDuration(i)),c&&(o.name=c),u.next=7,r(t,o);case 7:case"end":return u.stop()}}),_callee23)})));return function callback(t){return a.apply(this,arguments)}}()}},a.t4={title:a.t1,content:a.t2,default:"add",buttons:a.t3},new a.t0(a.t4).render(!0,{width:400,resizable:!1,classes:["dsa5","dialog"]});case 8:case"end":return a.stop()}}),_callee24)}))),function modifyEffectDialog(t,a){return r.apply(this,arguments)})},{key:"defaultOptions",get:function get(){var t=tokenHotbar2_get(tokenHotbar2_getPrototypeOf(AddEffectDialog),"defaultOptions",this);return mergeObject(t,{classes:["dsa5","tokenStatusEffects"],width:700,resizable:!0}),t}}]),AddEffectDialog}();function actor_sheet_typeof(t){return actor_sheet_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},actor_sheet_typeof(t)}function actor_sheet_toConsumableArray(t){return function actor_sheet_arrayWithoutHoles(t){if(Array.isArray(t))return actor_sheet_arrayLikeToArray(t)}(t)||function actor_sheet_iterableToArray(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||actor_sheet_unsupportedIterableToArray(t)||function actor_sheet_nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function actor_sheet_defineProperty(t,r,a){return r in t?Object.defineProperty(t,r,{value:a,enumerable:!0,configurable:!0,writable:!0}):t[r]=a,t}function actor_sheet_createForOfIteratorHelper(t,r){var a="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!a){if(Array.isArray(t)||(a=actor_sheet_unsupportedIterableToArray(t))||r&&t&&"number"==typeof t.length){a&&(t=a);var o=0,i=function F(){};return{s:i,n:function n(){return o>=t.length?{done:!0}:{done:!1,value:t[o++]}},e:function e(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var c,u=!0,l=!1;return{s:function s(){a=a.call(t)},n:function n(){var t=a.next();return u=t.done,t},e:function e(t){l=!0,c=t},f:function f(){try{u||null==a.return||a.return()}finally{if(l)throw c}}}}function actor_sheet_unsupportedIterableToArray(t,r){if(t){if("string"==typeof t)return actor_sheet_arrayLikeToArray(t,r);var a=Object.prototype.toString.call(t).slice(8,-1);return"Object"===a&&t.constructor&&(a=t.constructor.name),"Map"===a||"Set"===a?Array.from(t):"Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a)?actor_sheet_arrayLikeToArray(t,r):void 0}}function actor_sheet_arrayLikeToArray(t,r){(null==r||r>t.length)&&(r=t.length);for(var a=0,o=new Array(r);a=0;--o){var i=this.tryEntries[o],c=i.completion;if("root"===i.tryLoc)return handle("end");if(i.tryLoc<=this.prev){var u=a.call(i,"catchLoc"),l=a.call(i,"finallyLoc");if(u&&l){if(this.prev=0;--o){var i=this.tryEntries[o];if(i.tryLoc<=this.prev&&a.call(i,"finallyLoc")&&this.prev=0;--r){var a=this.tryEntries[r];if(a.finallyLoc===t)return this.complete(a.completion,a.afterLoc),resetTryEntry(a),l}},catch:function _catch(t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc===t){var o=a.completion;if("throw"===o.type){var i=o.arg;resetTryEntry(a)}return i}}throw new Error("illegal catch attempt")},delegateYield:function delegateYield(t,r,a){return this.delegate={iterator:values(t),resultName:r,nextLoc:a},"next"===this.method&&(this.arg=void 0),l}},t}function actor_sheet_asyncGeneratorStep(t,r,a,o,i,c,u){try{var l=t[c](u),p=l.value}catch(t){return void a(t)}l.done?r(p):Promise.resolve(p).then(o,i)}function actor_sheet_asyncToGenerator(t){return function(){var r=this,a=arguments;return new Promise((function(o,i){var c=t.apply(r,a);function _next(t){actor_sheet_asyncGeneratorStep(c,o,i,_next,_throw,"next",t)}function _throw(t){actor_sheet_asyncGeneratorStep(c,o,i,_next,_throw,"throw",t)}_next(void 0)}))}}function actor_sheet_classCallCheck(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}function actor_sheet_defineProperties(t,r){for(var a=0;a0&&void 0!==l[0]&&l[0],r=l.length>1&&void 0!==l[1]?l[1]:{},this._saveSearchFields(),this._saveCollapsed(),p.next=6,actor_sheet_get(actor_sheet_getPrototypeOf(ActorSheetDsa5.prototype),"_render",this).call(this,t,r);case 6:for(this._setCollapsed(),this._restoreSeachFields(),a=$(this._element),o={".close":"SHEET.Close",".configure-sheet":"SHEET.Configure",".configure-token":"SHEET.Token",".import":"SHEET.Import",".locksheet":"SHEET.Lock",".library":"SHEET.Library",".playerview":"SHEET.switchLimited",".actorConfig":"SHEET.actorConfig"},i=0,c=Object.keys(o);i'.concat(game.i18n.localize("TYPES.Item.aggregatedTest"),"");i.system.usedTestCount.value>=i.system.allowedTestCount.value?(l+="".concat(game.i18n.localize("Aggregated.noMoreAllowed")),ChatMessage.create(t.Z.chatDataSetup(l))):this.actor.setupSkill(u,{moreModifiers:[{name:game.i18n.localize("failedTests"),value:-1*i.system.previousFailedTests.value,selected:!0},{name:game.i18n.localize("Modifier"),value:i.system.baseModifier,selected:!0}]},this.getTokenId()).then((function(t){a.actor.basicTest(t).then((function(t){t.result.successLevel>0?(i.system.cummulatedQS.value=t.result.qualityStep+i.system.cummulatedQS.value,i.system.cummulatedQS.value=Math.min(10,i.system.cummulatedQS.value)):i.system.previousFailedTests.value+=1,i.system.usedTestCount.value+=1,a.actor.updateEmbeddedDocuments("Item",[i]).then((function(){var t=a.actor.items.get(o);t.postItem(),i.system.cummulatedQS.value>=10&&t.sheet.postFinishedItem()}))}))}))}},{key:"consumeItem",value:(de=actor_sheet_asyncToGenerator(actor_sheet_regeneratorRuntime().mark((function _callee3(t){var r=this;return actor_sheet_regeneratorRuntime().wrap((function _callee3$(a){for(;;)switch(a.prev=a.next){case 0:new Dialog({title:game.i18n.localize("SHEET.ConsumeItem")+": "+t.name,content:game.i18n.localize("SHEET.ConsumeItem")+": "+t.name,default:"yes",buttons:{Yes:{icon:'',label:game.i18n.localize("yes"),callback:function callback(){t.setupEffect(null,{},r.getTokenId())}},cancel:{icon:'',label:game.i18n.localize("cancel")}}}).render(!0);case 1:case"end":return a.stop()}}),_callee3)}))),function consumeItem(t){return de.apply(this,arguments)})},{key:"_advanceAttribute",value:(pe=actor_sheet_asyncToGenerator(actor_sheet_regeneratorRuntime().mark((function _callee4(r){var a,o;return actor_sheet_regeneratorRuntime().wrap((function _callee4$(i){for(;;)switch(i.prev=i.next){case 0:return a=Number(this.actor.system.characteristics[r].advances)+Number(this.actor.system.characteristics[r].initial),o=t.Z._calculateAdvCost(a,"E"),i.next=4,this._checkEnoughXP(o);case 4:if(!i.sent){i.next=7;break}return i.next=7,this._updateAPs(o,actor_sheet_defineProperty({},"system.characteristics.".concat(r,".advances"),Number(this.actor.system.characteristics[r].advances)+1));case 7:case"end":return i.stop()}}),_callee4,this)}))),function _advanceAttribute(t){return pe.apply(this,arguments)})},{key:"_refundAttributeAdvance",value:(fe=actor_sheet_asyncToGenerator(actor_sheet_regeneratorRuntime().mark((function _callee5(r){var a,o;return actor_sheet_regeneratorRuntime().wrap((function _callee5$(i){for(;;)switch(i.prev=i.next){case 0:if(a=Number(this.actor.system.characteristics[r].advances)+Number(this.actor.system.characteristics[r].initial),!(Number(this.actor.system.characteristics[r].advances)>0)){i.next=5;break}return o=-1*t.Z._calculateAdvCost(a,"E",0),i.next=5,this._updateAPs(o,actor_sheet_defineProperty({},"system.characteristics.".concat(r,".advances"),Number(this.actor.system.characteristics[r].advances)-1));case 5:case"end":return i.stop()}}),_callee5,this)}))),function _refundAttributeAdvance(t){return fe.apply(this,arguments)})},{key:"_rebuyPC",value:(le=actor_sheet_asyncToGenerator(actor_sheet_regeneratorRuntime().mark((function _callee6(t){return actor_sheet_regeneratorRuntime().wrap((function _callee6$(r){for(;;)switch(r.prev=r.next){case 0:if(!(this.actor.system.status[t].permanentLossSum>0)){r.next=6;break}return r.next=3,this._checkEnoughXP(2);case 3:if(!r.sent){r.next=6;break}return r.next=6,this._updateAPs(2,actor_sheet_defineProperty({},"system.status.".concat(t,".rebuy"),Number(this.actor.system.status[t].rebuy)+1));case 6:case"end":return r.stop()}}),_callee6,this)}))),function _rebuyPC(t){return le.apply(this,arguments)})},{key:"_refundPC",value:(ue=actor_sheet_asyncToGenerator(actor_sheet_regeneratorRuntime().mark((function _callee7(t){return actor_sheet_regeneratorRuntime().wrap((function _callee7$(r){for(;;)switch(r.prev=r.next){case 0:if(!(this.actor.system.status[t].rebuy>0)){r.next=3;break}return r.next=3,this._updateAPs(-2,actor_sheet_defineProperty({},"system.status.".concat(t,".rebuy"),Number(this.actor.system.status[t].rebuy)-1));case 3:case"end":return r.stop()}}),_callee7,this)}))),function _refundPC(t){return ue.apply(this,arguments)})},{key:"_advancePoints",value:(se=actor_sheet_asyncToGenerator(actor_sheet_regeneratorRuntime().mark((function _callee8(r){var a,o;return actor_sheet_regeneratorRuntime().wrap((function _callee8$(i){for(;;)switch(i.prev=i.next){case 0:return a=Number(this.actor.system.status[r].advances),o=t.Z._calculateAdvCost(a,"D"),i.next=4,this._checkEnoughXP(o);case 4:if(i.t0=i.sent,!i.t0){i.next=7;break}i.t0=this._checkMaximumPointAdvancement(r,a+1);case 7:if(!i.t0){i.next=10;break}return i.next=10,this._updateAPs(o,actor_sheet_defineProperty({},"system.status.".concat(r,".advances"),Number(this.actor.system.status[r].advances)+1));case 10:case"end":return i.stop()}}),_callee8,this)}))),function _advancePoints(t){return se.apply(this,arguments)})},{key:"_refundPointsAdvance",value:(ce=actor_sheet_asyncToGenerator(actor_sheet_regeneratorRuntime().mark((function _callee9(r){var a,o;return actor_sheet_regeneratorRuntime().wrap((function _callee9$(i){for(;;)switch(i.prev=i.next){case 0:if(!((a=Number(this.actor.system.status[r].advances))>0)){i.next=5;break}return o=-1*t.Z._calculateAdvCost(a,"D",0),i.next=5,this._updateAPs(o,actor_sheet_defineProperty({},"system.status.".concat(r,".advances"),Number(this.actor.system.status[r].advances)-1));case 5:case"end":return i.stop()}}),_callee9,this)}))),function _refundPointsAdvance(t){return ce.apply(this,arguments)})},{key:"_advanceItem",value:(ie=actor_sheet_asyncToGenerator(actor_sheet_regeneratorRuntime().mark((function _callee10(r){var a,o,i;return actor_sheet_regeneratorRuntime().wrap((function _callee10$(c){for(;;)switch(c.prev=c.next){case 0:return o=this.actor.items.get(r).toObject(),i=t.Z._calculateAdvCost(Number(o.system.talentValue.value),o.system.StF.value),c.next=4,this._checkEnoughXP(i);case 4:if(c.t0=c.sent,!c.t0){c.next=7;break}c.t0=null!==(a=this.actor._checkMaximumItemAdvancement(o,Number(o.system.talentValue.value)+1))&&void 0!==a&&a.result;case 7:if(!c.t0){c.next=12;break}return c.next=10,this.actor.updateEmbeddedDocuments("Item",[{_id:r,"system.talentValue.value":o.system.talentValue.value+1}]);case 10:return c.next=12,this._updateAPs(i);case 12:case"end":return c.stop()}}),_callee10,this)}))),function _advanceItem(t){return ie.apply(this,arguments)})},{key:"_refundItemAdvance",value:(oe=actor_sheet_asyncToGenerator(actor_sheet_regeneratorRuntime().mark((function _callee11(r){var a,o,i;return actor_sheet_regeneratorRuntime().wrap((function _callee11$(c){for(;;)switch(c.prev=c.next){case 0:if(a=this.actor.items.get(r).toObject(),o="combatskill"==a.type?6:0,!(a.system.talentValue.value>o)){c.next=8;break}return i=-1*t.Z._calculateAdvCost(Number(a.system.talentValue.value),a.system.StF.value,0),c.next=6,this.actor.updateEmbeddedDocuments("Item",[{_id:r,"system.talentValue.value":a.system.talentValue.value-1}]);case 6:return c.next=8,this._updateAPs(i);case 8:case"end":return c.stop()}}),_callee11,this)}))),function _refundItemAdvance(t){return oe.apply(this,arguments)})},{key:"_checkMaximumPointAdvancement",value:function _checkMaximumPointAdvancement(t,r){var a=!1;switch(t){case"wounds":a=r<=this.actor.system.characteristics.ko.value;break;case"astralenergy":a=r<=(null==this.actor.system.characteristics[this.actor.system.guidevalue.magical]?0:this.actor.system.characteristics[this.actor.system.guidevalue.magical].value*this.actor.system.energyfactor.magical);break;case"karmaenergy":a=r<=(null==this.actor.system.characteristics[this.actor.system.guidevalue.clerical]?0:this.actor.system.characteristics[this.actor.system.guidevalue.clerical].value*this.actor.system.energyfactor.clerical)}return a||ui.notifications.error(game.i18n.localize("DSAError.AdvanceMaximumReached")),a}},{key:"_openLibrary",value:(ae=actor_sheet_asyncToGenerator(actor_sheet_regeneratorRuntime().mark((function _callee12(){return actor_sheet_regeneratorRuntime().wrap((function _callee12$(t){for(;;)switch(t.prev=t.next){case 0:game.dsa5.itemLibrary.render(!0);case 1:case"end":return t.stop()}}),_callee12)}))),function _openLibrary(){return ae.apply(this,arguments)})},{key:"_configActor",value:(ne=actor_sheet_asyncToGenerator(actor_sheet_regeneratorRuntime().mark((function _callee13(){return actor_sheet_regeneratorRuntime().wrap((function _callee13$(t){for(;;)switch(t.prev=t.next){case 0:p.buildDialog(this.actor);case 1:case"end":return t.stop()}}),_callee13,this)}))),function _configActor(){return ne.apply(this,arguments)})},{key:"_getHeaderButtons",value:function _getHeaderButtons(){var t,r,a,o,i=this,c=actor_sheet_get(actor_sheet_getPrototypeOf(ActorSheetDsa5.prototype),"_getHeaderButtons",this).call(this);return c.unshift({class:"library",icon:"fas fa-university",onclick:(t=actor_sheet_asyncToGenerator(actor_sheet_regeneratorRuntime().mark((function _callee14(){return actor_sheet_regeneratorRuntime().wrap((function _callee14$(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",i._openLibrary());case 1:case"end":return t.stop()}}),_callee14)}))),function onclick(){return t.apply(this,arguments)})}),this.actor.isOwner&&(c.unshift({class:"actorConfig",icon:"fas fa-link",onclick:(a=actor_sheet_asyncToGenerator(actor_sheet_regeneratorRuntime().mark((function _callee15(){return actor_sheet_regeneratorRuntime().wrap((function _callee15$(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",i._configActor());case 1:case"end":return t.stop()}}),_callee15)}))),function onclick(){return a.apply(this,arguments)})}),c.unshift({class:"playerview",icon:"fas fa-toggle-on",onclick:(r=actor_sheet_asyncToGenerator(actor_sheet_regeneratorRuntime().mark((function _callee16(t){return actor_sheet_regeneratorRuntime().wrap((function _callee16$(r){for(;;)switch(r.prev=r.next){case 0:return r.abrupt("return",i._togglePlayerview(t));case 1:case"end":return r.stop()}}),_callee16)}))),function onclick(t){return r.apply(this,arguments)})})),this.actor.system.canAdvance&&c.unshift({class:"locksheet",icon:"fas fa-".concat(this.actor.system.sheetLocked.value?"":"un","lock"),onclick:(o=actor_sheet_asyncToGenerator(actor_sheet_regeneratorRuntime().mark((function _callee17(t){return actor_sheet_regeneratorRuntime().wrap((function _callee17$(r){for(;;)switch(r.prev=r.next){case 0:return r.abrupt("return",i._changeAdvanceLock(t));case 1:case"end":return r.stop()}}),_callee17)}))),function onclick(t){return o.apply(this,arguments)})}),c}},{key:"_changeAdvanceLock",value:(re=actor_sheet_asyncToGenerator(actor_sheet_regeneratorRuntime().mark((function _callee18(t){return actor_sheet_regeneratorRuntime().wrap((function _callee18$(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,this.actor.update({"system.sheetLocked.value":!this.actor.system.sheetLocked.value});case 2:$(t.currentTarget).find("i").toggleClass("fa-unlock fa-lock");case 3:case"end":return r.stop()}}),_callee18,this)}))),function _changeAdvanceLock(t){return re.apply(this,arguments)})},{key:"_checkEnoughXP",value:(te=actor_sheet_asyncToGenerator(actor_sheet_regeneratorRuntime().mark((function _callee19(t){return actor_sheet_regeneratorRuntime().wrap((function _callee19$(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,this.actor.checkEnoughXP(t);case 2:return r.abrupt("return",r.sent);case 3:case"end":return r.stop()}}),_callee19,this)}))),function _checkEnoughXP(t){return te.apply(this,arguments)})},{key:"advanceWrapper",value:(ee=actor_sheet_asyncToGenerator(actor_sheet_regeneratorRuntime().mark((function _callee20(t,r,a){var o,i;return actor_sheet_regeneratorRuntime().wrap((function _callee20$(c){for(;;)switch(c.prev=c.next){case 0:if(o=$(t.currentTarget),(i=o.find("i")).hasClass("fa-spin")){c.next=7;break}return i.addClass("fa-spin fa-spinner"),c.next=6,this[r](a);case 6:i.removeClass("fa-spin fa-spinner");case 7:case"end":return c.stop()}}),_callee20,this)}))),function advanceWrapper(t,r,a){return ee.apply(this,arguments)})},{key:"playerViewEnabled",value:function playerViewEnabled(){return getProperty(this.actor.system,"playerView")}},{key:"_togglePlayerview",value:function _togglePlayerview(t){this.actor.update({"system.playerView":!getProperty(this.actor.system,"playerView")})}},{key:"showLimited",value:function showLimited(){return!game.user.isGM&&this.actor.limited||this.playerViewEnabled()}},{key:"getTokenId",value:function getTokenId(){var t;return null===(t=this.token)||void 0===t?void 0:t.id}},{key:"rollDisease",value:function rollDisease(t){var r=this,a=this.actor.items.get(t),o=-1*this.actor.system.status.soulpower.max,i=-1*this.actor.system.status.toughness.max;a.setupEffect(void 0,{rollMode:"gmroll",manualResistance:{SKModifier:o,ZKModifier:i}}).then(function(){var t=actor_sheet_asyncToGenerator(actor_sheet_regeneratorRuntime().mark((function _callee21(t){var o;return actor_sheet_regeneratorRuntime().wrap((function _callee21$(i){for(;;)switch(i.prev=i.next){case 0:return i.next=2,a.itemTest(t);case 2:return o=i.sent,i.next=5,r.actor.updateEmbeddedDocuments("Item",[{_id:a.id,"system.duration.resolved":o.result.duration}]);case 5:case"end":return i.stop()}}),_callee21)})));return function(r){return t.apply(this,arguments)}}())}},{key:"swapWeaponHand",value:(X=actor_sheet_asyncToGenerator(actor_sheet_regeneratorRuntime().mark((function _callee22(t){var r,a;return actor_sheet_regeneratorRuntime().wrap((function _callee22$(o){for(;;)switch(o.prev=o.next){case 0:if(r=this._getItemId(t),a=this.actor.items.get(r),["Daggers","Fencing Weapons"].includes(game.i18n.localize("LocalizedCTs.".concat(a.system.combatskill.value)))){o.next=5;break}return o.next=5,this.actor.updateEmbeddedDocuments("Item",[{_id:r,"system.worn.wrongGrip":!a.system.worn.wrongGrip}]);case 5:case"end":return o.stop()}}),_callee22,this)}))),function swapWeaponHand(t){return X.apply(this,arguments)})},{key:"activateListeners",value:function activateListeners(r){var a=this;actor_sheet_get(actor_sheet_getPrototypeOf(ActorSheetDsa5.prototype),"activateListeners",this).call(this,r);var o=function posthand(t){a.actor.items.get(a._getItemId(t)).postItem()};r.find(".roll-disease").click((function(t){return a.rollDisease(a._getItemId(t))})),(0,h.Ee)(r),r.find(".condition-edit").click((function(t){a.actor.effects.get(t.currentTarget.dataset.id).sheet.render(!0)})),r.find(".ch-collapse").click((function(t){$(t.currentTarget).find("i").toggleClass("fa-angle-up fa-angle-down"),$(t.currentTarget).closest(".groupbox").find(".row-section:nth-child(2)").fadeToggle()})),r.find(".status-create").click((function(t){var r=$(t.currentTarget).closest(".statusEffectMenu").find("ul");r.fadeIn("fast",(function(){r.find("input").focus()}))})),r.find(".statusEffectMenu ul").mouseleave((function(t){return $(t.currentTarget).fadeOut()})),r.find(".roll-aggregated").mousedown((function(t){return a._handleAggregatedProbe(t)})),r.find(".skill-select").mousedown((function(t){var r=a._getItemId(t),o=a.actor.items.get(r);0==t.button?a.actor.setupSkill(o,{},a.getTokenId()).then((function(t){a.actor.basicTest(t)})):2==t.button&&o.sheet.render(!0)})),r.find(".spell-select").mousedown((function(t){var r=a._getItemId(t),o=a.actor.items.get(r);0==t.button?a.actor.setupSpell(o,{},a.getTokenId()).then((function(t){return a.actor.basicTest(t)})):2==t.button&&o.sheet.render(!0)})),r.find(".item-post").click((function(t){return o(t)})),r.find(".item-dropdown").click((function(t){t.preventDefault(),$(t.currentTarget).closest(".item").find(".expandDetails:first").toggleClass("shown")})),r.find(".condition-show").mousedown((function(t){t.preventDefault();var r=t.currentTarget.dataset.id,o=$(t.currentTarget).parents(".statusEffect").attr("data-descriptor");if(0==t.button){var i=$(t.currentTarget).parents(".statusEffect").attr("data-origin");if(i)fromUuid(i).then((function(t){return t.sheet.render(!0)}));else{var c,u;o?(c=CONFIG.statusEffects.find((function(t){return t.id==o})),u=$('
    ').concat(game.i18n.localize(c.name),": ").concat(game.i18n.localize(c.description),"
    "))):(c=a.actor.effects.find((function(t){return t.id==r})))&&(u=$('
    ').concat(game.i18n.localize(c.name),": ").concat(game.i18n.localize(c.flags.dsa5.description),"
    ")));var l=$(t.currentTarget).closest(".groupbox").find(".effectDescription");l.fadeOut("fast",(function(){l.html(u).fadeIn("fast")}))}}else 2!=t.button||t.currentTarget.dataset.locked||a._deleteActiveEffect(r)})),r.on("click",".chat-condition",(function(t){return c.Z.postStatus(t.currentTarget.dataset.id)})),r.find(".money-change, .skill-advances").focusin((function(t){a.currentFocus=$(t.currentTarget).closest("[data-item-id]").attr("data-item-id")})),r.find(".item-edit").click((function(t){t.preventDefault();var r=a._getItemId(t);a.actor.items.get(r).sheet.render(!0)})),r.find(".showApplication").mousedown((function(t){if(t.preventDefault(),2==t.button)a._deleteItem(t);else{var r=a._getItemId(t);a.actor.items.get(r).sheet.render(!0)}})),r.find(".ch-value").click((function(t){t.preventDefault();var r=t.currentTarget.attributes["data-char"].value;a.actor.setupCharacteristic(r,{},a.getTokenId()).then((function(t){return a.actor.basicTest(t)}))})),r.find(".ch-status").click((function(t){t.preventDefault(),a.actor.setupDodge({},a.getTokenId()).then((function(t){a.actor.basicTest(t)}))})),r.find(".ch-regenerate").click((function(t){t.preventDefault(),a.actor.setupRegeneration("regenerate",{},a.getTokenId()).then((function(t){return a.actor.basicTest(t)}))})),r.find(".ch-weaponless").click((function(t){t.preventDefault();var r=t.currentTarget.attributes["data-char"].value;a.actor.setupWeaponless(r,{},a.getTokenId()).then((function(t){return a.actor.basicTest(t)}))})),r.find(".ch-fallingDamage").click((function(t){t.preventDefault(),a.actor.setupFallingDamage({},a.getTokenId())})),r.find(".ch-rollCombat").click((function(t){t.preventDefault();var r=a._getItemId(t),o=t.currentTarget.dataset.mode,i=a.actor.items.get(r);a.actor.setupWeapon(i,o,{},a.getTokenId()).then((function(t){return a.actor.basicTest(t)}))}));var i=function deletehand(t){return a._deleteItem(t)};r.find(".cards .item").mouseenter((function(t){if(0==t.currentTarget.getElementsByClassName("hovermenu").length){var r=document.createElement("div");r.classList.add("hovermenu");var a=document.createElement("i");a.classList.add("fas","fa-times"),a.title=game.i18n.localize("SHEET.DeleteItem"),a.addEventListener("click",i,!1);var c=document.createElement("i");c.classList.add("fas","fa-comment"),c.title=game.i18n.localize("SHEET.PostItem"),c.addEventListener("click",o,!1),r.appendChild(c),r.appendChild(a),t.currentTarget.appendChild(r)}})),r.find(".cards .item").mouseleave((function(t){var r=t.toElement||t.relatedTarget;r&&r.parentNode!=a&&r!=a&&t.currentTarget.querySelectorAll(".hovermenu").forEach((function(t){return t.remove()}))}));var l=this.actor.uuid;r.find(".actorDrag").each((function(t,r){r.setAttribute("draggable",!0),r.addEventListener("dragstart",(function(t){var r={type:"Actor",uuid:l};t.dataTransfer.setData("text/plain",JSON.stringify(r))}))})),r.find(".filterTalents").click((function(t){$(t.currentTarget).closest(".content").find(".allTalents").toggleClass("showAll"),$(t.currentTarget).toggleClass("filtered")})),r.find(".charimg").mousedown((function(r){2==r.button&&t.Z.showArtwork(a.actor,!0)})),_.Z.bindRollCommands(r);var p=r.find(".talentSearch");p.keyup((function(t){return a._filterTalents($(t.currentTarget))})),p[0]&&p[0].addEventListener("search",(function filterTalents(t){return a._filterTalents($(t.currentTarget))}),!1);var g=r.find(".conditionSearch");g.keyup((function(t){return a._filterConditions($(t.currentTarget))})),g[0]&&g[0].addEventListener("search",(function filterConditions(t){return a._filterConditions($(t.currentTarget))}),!1);var v=r.find(".gearSearch");v.keyup((function(t){return a._filterGear($(t.currentTarget))})),v[0]&&v[0].addEventListener("search",(function filterGear(t){return a._filterGear($(t.currentTarget))}),!1),bindImgToCanvasDragStart(r,"img.charimg"),b.Z.activateListeners(r,this.actor),this._bindKeepFieldsEnabled(r),this.isEditable&&(r.find(".startCharacterBuilder").click((function(){return a.actor.setFlag("core","sheetClass","dsa5.DSACharBuilder")})),r.find(".schipUpdate").click((function(t){t.preventDefault();var r=Number(t.currentTarget.getAttribute("data-val"));1==r&&1==$(a.form).find(".fullSchip").length&&(r=0),a.actor.update({"system.status.fatePoints.value":r})})),r.find(".swapWeaponHand").click((function(t){return a.swapWeaponHand(t)})),r.find(".defenseToggle").click((function(){return a.actor.update({"system.config.defense":!a.actor.system.config.defense})})),r.find(".loadWeapon").mousedown(function(){var t=actor_sheet_asyncToGenerator(actor_sheet_regeneratorRuntime().mark((function _callee23(t){var r,o,i,c;return actor_sheet_regeneratorRuntime().wrap((function _callee23$(u){for(;;)switch(u.prev=u.next){case 0:if(r=a._getItemId(t),o=a.actor.items.get(r).toObject(),""!==getProperty(o,"system.currentAmmo.value")){u.next=4;break}return u.abrupt("return");case 4:return i={_id:r},0==t.button?(c="trait"==o.type?o.system.reloadTime.value:d.Z.calcLZ(o,a.actor),i["system.reloadTime.progress"]=Math.min(o.system.reloadTime.progress+1,c)):2==t.button&&(i["system.reloadTime.progress"]=0),u.next=8,a.actor.updateEmbeddedDocuments("Item",[i]);case 8:case"end":return u.stop()}}),_callee23)})));return function(r){return t.apply(this,arguments)}}()),r.find(".chargeSpell").mousedown(function(){var t=actor_sheet_asyncToGenerator(actor_sheet_regeneratorRuntime().mark((function _callee24(t){var r,o,i;return actor_sheet_regeneratorRuntime().wrap((function _callee24$(c){for(;;)switch(c.prev=c.next){case 0:return r=a._getItemId(t),o=a.actor.items.get(r).toObject(),i=Number(o.system.castingTime.modified),0==t.button?o.system.castingTime.progress=Math.min(o.system.castingTime.progress+1,i):2==t.button&&(o.system.castingTime.progress=0,o.system.castingTime.modified=0),c.next=6,a.actor.updateEmbeddedDocuments("Item",[o]);case 6:case"end":return c.stop()}}),_callee24)})));return function(r){return t.apply(this,arguments)}}()),r.find(".item-swapMag").click(function(){var t=actor_sheet_asyncToGenerator(actor_sheet_regeneratorRuntime().mark((function _callee25(t){return actor_sheet_regeneratorRuntime().wrap((function _callee25$(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,a.actor.swapMag(a._getItemId(t));case 2:case"end":return r.stop()}}),_callee25)})));return function(r){return t.apply(this,arguments)}}()),r.find(".ammo-selector").change(function(){var t=actor_sheet_asyncToGenerator(actor_sheet_regeneratorRuntime().mark((function _callee26(t){var r;return actor_sheet_regeneratorRuntime().wrap((function _callee26$(o){for(;;)switch(o.prev=o.next){case 0:return t.preventDefault(),r=a._getItemId(t),o.next=4,a.actor.updateEmbeddedDocuments("Item",[{_id:r,"system.currentAmmo.value":$(t.currentTarget).val()}]);case 4:case"end":return o.stop()}}),_callee26)})));return function(r){return t.apply(this,arguments)}}()),r.find(".item-toggle").click((function(t){var r=a._getItemId(t),o=a.actor.items.get(r).toObject();switch(o.type){case"armor":case"rangeweapon":case"meleeweapon":case"equipment":a.actor.updateEmbeddedDocuments("Item",[{_id:r,"system.worn.value":!o.system.worn.value}]),m.Z.playEquipmentWearStatusChange(o)}})),r.find(".quantity-click").mousedown((function(t){var r=a._getItemId(t),o=a.actor.items.get(r).toObject();y.Z.increment(t,o,"system.quantity.value",0),a.actor.updateEmbeddedDocuments("Item",[o])})),r.find(".status-add").mousedown(function(){var t=actor_sheet_asyncToGenerator(actor_sheet_regeneratorRuntime().mark((function _callee28(t){var r;return actor_sheet_regeneratorRuntime().wrap((function _callee28$(o){for(;;)switch(o.prev=o.next){case 0:if("custom"!=(r=t.currentTarget.dataset.id)){o.next=5;break}u.Z.createCustomEffect(a.actor),o.next=11;break;case 5:if(0!=t.button){o.next=10;break}return o.next=8,a.actor.addCondition(r,1,!1,!1);case 8:o.next=11;break;case 10:2==t.button&&S.modifyEffectDialog(r,function(){var t=actor_sheet_asyncToGenerator(actor_sheet_regeneratorRuntime().mark((function _callee27(t,r){return actor_sheet_regeneratorRuntime().wrap((function _callee27$(o){for(;;)switch(o.prev=o.next){case 0:return o.abrupt("return",a.actor.addTimedCondition(t,1,!1,!1,r));case 1:case"end":return o.stop()}}),_callee27)})));return function(r,a){return t.apply(this,arguments)}}());case 11:case"end":return o.stop()}}),_callee28)})));return function(r){return t.apply(this,arguments)}}()),r.find(".money-change").change(function(){var t=actor_sheet_asyncToGenerator(actor_sheet_regeneratorRuntime().mark((function _callee29(t){var r;return actor_sheet_regeneratorRuntime().wrap((function _callee29$(o){for(;;)switch(o.prev=o.next){case 0:return r=a._getItemId(t),o.next=3,a.actor.updateEmbeddedDocuments("Item",[{_id:r,"system.quantity.value":Number(t.target.value)}]);case 3:case"end":return o.stop()}}),_callee29)})));return function(r){return t.apply(this,arguments)}}()),r.find(".skill-advances").change(function(){var t=actor_sheet_asyncToGenerator(actor_sheet_regeneratorRuntime().mark((function _callee30(t){var r;return actor_sheet_regeneratorRuntime().wrap((function _callee30$(o){for(;;)switch(o.prev=o.next){case 0:return r=a._getItemId(t),o.next=3,a.actor.updateEmbeddedDocuments("Item",[{_id:r,"system.talentValue.value":Number(t.target.value)}]);case 3:case"end":return o.stop()}}),_callee30)})));return function(r){return t.apply(this,arguments)}}()),r.find(".advance-attribute").mousedown((function(t){return a.advanceWrapper(t,"_advanceAttribute",t.currentTarget.dataset.attr)})),r.find(".refund-attribute").mousedown((function(t){return a.advanceWrapper(t,"_refundAttributeAdvance",t.currentTarget.dataset.attr)})),r.find(".advance-item").mousedown((function(t){return a.advanceWrapper(t,"_advanceItem",a._getItemId(t))})),r.find(".refund-item").mousedown((function(t){return a.advanceWrapper(t,"_refundItemAdvance",a._getItemId(t))})),r.find(".advance-points").mousedown((function(t){return a.advanceWrapper(t,"_advancePoints",t.currentTarget.dataset.attr)})),r.find(".refund-points").mousedown((function(t){return a.advanceWrapper(t,"_refundPointsAdvance",t.currentTarget.dataset.attr)})),r.find(".rebuy-pc").mousedown((function(t){return a.advanceWrapper(t,"_rebuyPC",t.currentTarget.dataset.attr)})),r.find(".refund-pc").mousedown((function(t){return a.advanceWrapper(t,"_refundPC",t.currentTarget.dataset.attr)})),r.find(".onUseItem").mousedown((function(t){return a._onMacroUseItem(t)})),r.find(".traditionPayCost").mousedown((function(t){return a._payAeSpecialAbilityCost(t)})),r.find(".item-create").click((function(t){return a._onItemCreate(t)})),r.find(".condition-toggle").mousedown(function(){var t=actor_sheet_asyncToGenerator(actor_sheet_regeneratorRuntime().mark((function _callee31(t){var r,o;return actor_sheet_regeneratorRuntime().wrap((function _callee31$(i){for(;;)switch(i.prev=i.next){case 0:return r=$(t.currentTarget).parents(".statusEffect").attr("data-id"),o=a.actor.effects.get(r),i.next=4,o.update({disabled:!o.disabled});case 4:case"end":return i.stop()}}),_callee31)})));return function(r){return t.apply(this,arguments)}}()),r.find(".condition-value").mousedown(function(){var t=actor_sheet_asyncToGenerator(actor_sheet_regeneratorRuntime().mark((function _callee32(t){var r;return actor_sheet_regeneratorRuntime().wrap((function _callee32$(o){for(;;)switch(o.prev=o.next){case 0:if(r=$(t.currentTarget).parents(".statusEffect").attr("data-descriptor"),0!=t.button){o.next=6;break}return o.next=4,a.actor.addCondition(r,1,!1,!1);case 4:o.next=9;break;case 6:if(2!=t.button){o.next=9;break}return o.next=9,a.actor.removeCondition(r,1,!1);case 9:case"end":return o.stop()}}),_callee32)})));return function(r){return t.apply(this,arguments)}}()),r.find(".item-delete").click((function(t){return a._deleteItem(t)})),r.find(".tradition-delete").click((function(t){return a._deleteTraditionArtifact(t)})),r.find(".selectTraditionartifact").click((function(){return a.selectTraditionartifact()})),r.find(".consume-item").mousedown((function(t){if(2==t.button){var r=a._getItemId(t),o=a.actor.items.get(r);a.consumeItem(o)}})),r.find(".disableRegeneration").click((function(t){var r=t.currentTarget.dataset.type,o="system.repeatingEffects.disabled.".concat(r);a.actor.update(actor_sheet_defineProperty({},o,!getProperty(a.actor,o)))})))}},{key:"_bindKeepFieldsEnabled",value:function _bindKeepFieldsEnabled(t){var r=this;if(!this.isEditable){var a,o=actor_sheet_createForOfIteratorHelper(t.find(".keepFieldsEnabled"));try{for(o.s();!(a=o.n()).done;){var i=a.value,c=i.dataset.attr,u=i.dataset.name;$(i).find(".editor").append('')),$(i).find(".editor-edit").click((function(t){return r._openKeepFieldEditpage(t)}))}}catch(t){o.e(t)}finally{o.f()}}}},{key:"_openKeepFieldEditpage",value:function _openKeepFieldEditpage(t){var r=t.currentTarget.dataset.attr,a=t.currentTarget.dataset.name;new k(this.actor.id,r,a).render(!0)}},{key:"_onMacroUseItem",value:(Q=actor_sheet_asyncToGenerator(actor_sheet_regeneratorRuntime().mark((function _callee33(t){var r,a;return actor_sheet_regeneratorRuntime().wrap((function _callee33$(o){for(;;)switch(o.prev=o.next){case 0:return r=this.actor.items.get(this._getItemId(t)),a=new g.Z(r),o.next=4,a.executeOnUseEffect();case 4:case"end":return o.stop()}}),_callee33,this)}))),function _onMacroUseItem(t){return Q.apply(this,arguments)})},{key:"_payAeSpecialAbilityCost",value:(J=actor_sheet_asyncToGenerator(actor_sheet_regeneratorRuntime().mark((function _callee34(r){var a,o,i;return actor_sheet_regeneratorRuntime().wrap((function _callee34$(c){for(;;)switch(c.prev=c.next){case 0:if(a=this.actor.items.get(this._getItemId(r)),o=Number(getProperty(a,"system.AsPCost")),this.actor.applyMana(o,"AsP")){c.next=5;break}return c.abrupt("return");case 5:i=game.i18n.format("CHATNOTIFICATION.paysTraditionAbility",{name:this.actor.name,ability:a.name,cost:o}),2==r.button?ChatMessage.create(t.Z.chatDataSetup(i,"gmroll")):ChatMessage.create(t.Z.chatDataSetup(i));case 7:case"end":return c.stop()}}),_callee34,this)}))),function _payAeSpecialAbilityCost(t){return J.apply(this,arguments)})},{key:"_filterGear",value:function _filterGear(t){if(null!=t.val()){var r=t.val().toLowerCase().trim(),a=$(this.element).find(".inventory .item");a.removeClass("filterHide"),a.filter((function(){return-1==$(this).find("a.item-edit").text().toLowerCase().trim().indexOf(r)})).addClass("filterHide")}}},{key:"selectTraditionartifact",value:(K=actor_sheet_asyncToGenerator(actor_sheet_regeneratorRuntime().mark((function _callee35(){return actor_sheet_regeneratorRuntime().wrap((function _callee35$(t){for(;;)switch(t.prev=t.next){case 0:if(this.isEditable){t.next=2;break}return t.abrupt("return");case 2:new A(this.actor).render(!0);case 3:case"end":return t.stop()}}),_callee35,this)}))),function selectTraditionartifact(){return K.apply(this,arguments)})},{key:"_deleteTraditionArtifact",value:function _deleteTraditionArtifact(t){this.isEditable&&this.actor.items.get(this._getItemId(t)).update({"system.isArtifact":!1})}},{key:"_filterTalents",value:function _filterTalents(t){if(null!=t.val()){var r=t.val().toLowerCase().trim(),a=$(this.form).parent().find(".allTalents");a.find(".item, .table-header, .table-title").removeClass("filterHide"),a.addClass("showAll").find(".item").filter((function(){return-1==$(this).find(".talentName").text().toLowerCase().trim().indexOf(r)})).addClass("filterHide"),r.length>0?(a.find(".table-header, .table-title:not(:eq(0))").addClass("filterHide"),a.addClass("filterfull")):a.removeClass("filterfull")}}},{key:"_filterConditions",value:function _filterConditions(t){if(null!=t.val()){var r=t.val().toLowerCase().trim(),a=$(this.form).find(".statusEffectMenu li:not(.search)");a.removeClass("filterHide"),a.filter((function(){return-1==game.i18n.localize($(this).find("a").attr("data-tooltip")).toLowerCase().trim().indexOf(r)})).addClass("filterHide")}}},{key:"_deleteActiveEffect",value:(V=actor_sheet_asyncToGenerator(actor_sheet_regeneratorRuntime().mark((function _callee36(t){var r;return actor_sheet_regeneratorRuntime().wrap((function _callee36$(a){for(;;)switch(a.prev=a.next){case 0:if(this.isEditable){a.next=2;break}return a.abrupt("return");case 2:if(!(r=this.actor.effects.find((function(r){return r.id==t})))){a.next=8;break}if(!(this.token?this.token.actor:this.actor)){a.next=8;break}return a.next=8,this.actor.deleteEmbeddedDocuments("ActiveEffect",[r.id]);case 8:case"end":return a.stop()}}),_callee36,this)}))),function _deleteActiveEffect(t){return V.apply(this,arguments)})},{key:"_deleteItem",value:(Y=actor_sheet_asyncToGenerator(actor_sheet_regeneratorRuntime().mark((function _callee38(t){var r,a,o,i,c=this;return actor_sheet_regeneratorRuntime().wrap((function _callee38$(u){for(;;)switch(u.prev=u.next){case 0:if(this.isEditable){u.next=2;break}return u.abrupt("return");case 2:return r=this._getItemId(t),a=this.actor.items.get(r),o=game.i18n.format("DIALOG.DeleteItemDetail",{item:a.name}),u.next=7,renderTemplate("systems/dsa5/templates/dialog/delete-item-dialog.html",{message:o});case 7:return i=u.sent,u.next=10,new Promise((function(t,a){var o;new Dialog({title:game.i18n.localize("DIALOG.deleteConfirmation"),content:i,buttons:{Yes:{icon:'',label:game.i18n.localize("yes"),callback:(o=actor_sheet_asyncToGenerator(actor_sheet_regeneratorRuntime().mark((function _callee37(){return actor_sheet_regeneratorRuntime().wrap((function _callee37$(a){for(;;)switch(a.prev=a.next){case 0:return a.next=2,c._cleverDeleteItem(r);case 2:t(!0);case 3:case"end":return a.stop()}}),_callee37)}))),function callback(){return o.apply(this,arguments)})},cancel:{icon:'',label:game.i18n.localize("cancel")}},default:"Yes"}).render(!0)}));case 10:case"end":return u.stop()}}),_callee38,this)}))),function _deleteItem(t){return Y.apply(this,arguments)})},{key:"_cleverDeleteItem",value:(U=actor_sheet_asyncToGenerator(actor_sheet_regeneratorRuntime().mark((function _callee39(r){var o,c,u,l,p;return actor_sheet_regeneratorRuntime().wrap((function _callee39$(d){for(;;)switch(d.prev=d.next){case 0:o=this.actor.items.get(r),c=[r],d.t0=o.type,d.next="advantage"===d.t0||"disadvantage"===d.t0?5:"specialability"===d.t0?8:"blessing"===d.t0||"magictrick"===d.t0?11:"ritual"===d.t0||"ceremony"===d.t0||"liturgy"===d.t0||"spell"===d.t0?14:21;break;case 5:return d.next=7,a.Z.vantageRemoved(this.actor,o,!1);case 7:case 10:case 13:case 20:return d.abrupt("break",21);case 8:return d.next=10,i.Z.abilityRemoved(this.actor,o,!1);case 11:return d.next=13,this._updateAPs(-1,{},{render:!1});case 14:for(u=0,l=0;l<=o.system.talentValue.value;l++)u+=t.Z._calculateAdvCost(l,o.system.StF.value,0);return p=this.actor.items.filter((function(t){return"spellextension"==t.type&&o.type==t.system.category&&o.name==t.system.source})),p&&(u+=p.reduce((function(t,r){return t+(Number(r.system.APValue.value)||0)}),0),c.push.apply(c,actor_sheet_toConsumableArray(p.map((function(t){return t.id}))))),d.next=20,this._updateAPs(-1*u,{},{render:!1});case 21:return d.next=23,this.actor.deleteEmbeddedDocuments("Item",c);case 23:case"end":return d.stop()}}),_callee39,this)}))),function _cleverDeleteItem(t){return U.apply(this,arguments)})},{key:"_getItemId",value:function _getItemId(t){return $(t.currentTarget).closest(".item").attr("data-item-id")}},{key:"_addMoney",value:(q=actor_sheet_asyncToGenerator(actor_sheet_regeneratorRuntime().mark((function _callee40(t){var r,a;return actor_sheet_regeneratorRuntime().wrap((function _callee40$(o){for(;;)switch(o.prev=o.next){case 0:if(r=duplicate(this.actor.items.filter((function(t){return"money"==t.type}))),!(a=r.find((function(r){return r.name==t.name})))){o.next=8;break}return a.system.quantity.value+=t.system.quantity.value,o.next=6,this.actor.updateEmbeddedDocuments("Item",[a]);case 6:o.next=10;break;case 8:return o.next=10,this.actor.createEmbeddedDocuments("Item",[t]);case 10:case"end":return o.stop()}}),_callee40,this)}))),function _addMoney(t){return q.apply(this,arguments)})},{key:"_updateAPs",value:(B=actor_sheet_asyncToGenerator(actor_sheet_regeneratorRuntime().mark((function _callee41(t){var r,a,o=arguments;return actor_sheet_regeneratorRuntime().wrap((function _callee41$(i){for(;;)switch(i.prev=i.next){case 0:return r=o.length>1&&void 0!==o[1]?o[1]:{},a=o.length>2&&void 0!==o[2]?o[2]:{},i.next=4,this.actor._updateAPs(t,r,a);case 4:case"end":return i.stop()}}),_callee41,this)}))),function _updateAPs(t){return B.apply(this,arguments)})},{key:"_addVantage",value:(W=actor_sheet_asyncToGenerator(actor_sheet_regeneratorRuntime().mark((function _callee42(t,r){return actor_sheet_regeneratorRuntime().wrap((function _callee42$(o){for(;;)switch(o.prev=o.next){case 0:a.Z.needsAdoption(this.actor,t,r);case 1:case"end":return o.stop()}}),_callee42,this)}))),function _addVantage(t,r){return W.apply(this,arguments)})},{key:"_addSpecialAbility",value:(Z=actor_sheet_asyncToGenerator(actor_sheet_regeneratorRuntime().mark((function _callee43(t,r){return actor_sheet_regeneratorRuntime().wrap((function _callee43$(a){for(;;)switch(a.prev=a.next){case 0:i.Z.needsAdoption(this.actor,t,r);case 1:case"end":return a.stop()}}),_callee43,this)}))),function _addSpecialAbility(t,r){return Z.apply(this,arguments)})},{key:"_onDragStart",value:function _onDragStart(t){var r=t.currentTarget;if(!t.target.classList.contains("content-link")){var a;if(r.dataset.itemId)a=this.actor.items.get(r.dataset.itemId).toDragData(),r.dataset.mod&&(a.mod=r.dataset.mod);if(r.dataset.id)a=this.actor.effects.get(r.dataset.id).toDragData();a&&t.dataTransfer.setData("text/plain",JSON.stringify(a))}}},{key:"_handleSpellExtension",value:(H=actor_sheet_asyncToGenerator(actor_sheet_regeneratorRuntime().mark((function _callee44(r){var a,o;return actor_sheet_regeneratorRuntime().wrap((function _callee44$(i){for(;;)switch(i.prev=i.next){case 0:if(this.actor.items.find((function(t){return t.type==r.type&&t.name==r.name}))){i.next=19;break}if(r=duplicate(r),a=this.actor.items.find((function(t){return t.type==r.system.category&&t.name==r.system.source}))){i.next=8;break}ui.notifications.error(game.i18n.format("DSAError.noSpellForExtension",{name:r.system.source,category:t.Z.categoryLocalization(r.system.category),extension:r.name})),i.next=19;break;case 8:if(!(a.system.talentValue.value
    ',label:game.i18n.localize("CONDITION.shapeshift"),callback:function callback(){var a=game.dsa5.config.hooks.shapeshift;a.setShapeshift(r.actor,t),a.render(!0)}},horse:{icon:'',label:game.i18n.localize("RIDING.horse"),callback:function callback(){b.Z.setHorse(r.actor,t)}}}}).render(!0):b.Z.setHorse(this.actor,t);case 1:case"end":return a.stop()}}),_callee52,this)}))),function creatureDrop(t){return I.apply(this,arguments)})},{key:"_manageDragItems",value:(D=actor_sheet_asyncToGenerator(actor_sheet_regeneratorRuntime().mark((function _callee53(t,r){return actor_sheet_regeneratorRuntime().wrap((function _callee53$(a){for(;;)switch(a.prev=a.next){case 0:a.t0=r,a.next="disease"===a.t0?3:"meleeweapon"===a.t0||"rangeweapon"===a.t0||"equipment"===a.t0||"ammunition"===a.t0||"armor"===a.t0||"poison"===a.t0||"consumable"===a.t0||"plant"===a.t0?6:"disadvantage"===a.t0||"advantage"===a.t0?9:"specialability"===a.t0?12:"money"===a.t0?15:"ritual"===a.t0||"ceremony"===a.t0||"blessing"===a.t0||"magictrick"===a.t0||"liturgy"===a.t0||"spell"===a.t0||"magicalsign"===a.t0?18:"effectwrapper"===a.t0?21:"application"===a.t0?24:"spellextension"===a.t0?27:"creature"===a.t0?30:"skill"===a.t0||"imprint"===a.t0||"essence"===a.t0||"information"===a.t0?32:"patron"===a.t0||"demonmark"===a.t0?35:38;break;case 3:return a.next=5,this._addDisease(t);case 5:return a.abrupt("break",39);case 6:return a.next=8,this._addLoot(t);case 8:return a.abrupt("return",a.sent);case 9:return a.next=11,this._addVantage(t,r);case 11:return a.abrupt("break",39);case 12:return a.next=14,this._addSpecialAbility(t,r);case 14:return a.abrupt("break",39);case 15:return a.next=17,this._addMoney(t);case 17:return a.abrupt("break",39);case 18:return a.next=20,this._addSpellOrLiturgy(t);case 20:return a.abrupt("break",39);case 21:return a.next=23,this._handleEffectWrapper(t);case 23:return a.abrupt("break",39);case 24:return a.next=26,this._handleApplication(t);case 26:return a.abrupt("break",39);case 27:return a.next=29,this._handleSpellExtension(t);case 29:return a.abrupt("break",39);case 30:return this.creatureDrop(t),a.abrupt("break",39);case 32:return a.next=34,this._addUniqueItem(t);case 34:return a.abrupt("break",39);case 35:return a.next=37,this._addDemonMarkOrPatron(t);case 37:return a.abrupt("break",39);case 38:ui.notifications.error(game.i18n.format("DSAError.canNotBeAdded",{item:t.name,category:game.i18n.localize(t.type)}));case 39:case"end":return a.stop()}}),_callee53,this)}))),function _manageDragItems(t,r){return D.apply(this,arguments)})},{key:"_handleEffectWrapper",value:(C=actor_sheet_asyncToGenerator(actor_sheet_regeneratorRuntime().mark((function _callee54(t){return actor_sheet_regeneratorRuntime().wrap((function _callee54$(r){for(;;)switch(r.prev=r.next){case 0:this.actor.createEmbeddedDocuments("ActiveEffect",t.effects.map((function(t){return t.origin=null,t})));case 1:case"end":return r.stop()}}),_callee54,this)}))),function _handleEffectWrapper(t){return C.apply(this,arguments)})},{key:"_handleLookup",value:(E=actor_sheet_asyncToGenerator(actor_sheet_regeneratorRuntime().mark((function _callee55(r){var a,o,i,c;return actor_sheet_regeneratorRuntime().wrap((function _callee55$(u){for(;;)switch(u.prev=u.next){case 0:return u.next=2,t.Z.findAnyItem(r.items);case 2:if(!(a=u.sent)){u.next=10;break}o=actor_sheet_createForOfIteratorHelper(r.items);try{for(c=function _loop(){var t=i.value;if(t.count){var r=a.find((function(r){return r.name==t.name&&r.type==t.type}));r?(r.system.quantity.value=t.count,t.qs&&"consumable"==t.type&&(r.system.QL=t.qs)):ui.notifications.warn(game.i18n.format("DSAError.notFound",{category:t.type,name:t.name}))}},o.s();!(i=o.n()).done;)c()}catch(t){o.e(t)}finally{o.f()}return u.next=8,this.actor.createEmbeddedDocuments("Item",a);case 8:u.next=11;break;case 10:ui.notifications.error(game.i18n.format("DSAError.notFound",{category:thing.type,name:thing.name}));case 11:case"end":return u.stop()}}),_callee55,this)}))),function _handleLookup(t){return E.apply(this,arguments)})},{key:"_handleApplication",value:(P=actor_sheet_asyncToGenerator(actor_sheet_regeneratorRuntime().mark((function _callee56(t){return actor_sheet_regeneratorRuntime().wrap((function _callee56$(r){for(;;)switch(r.prev=r.next){case 0:if(t=duplicate(t),this.actor.items.find((function(r){return r.type==t.type&&r.name==t.name}))){r.next=5;break}return r.next=5,this.actor.createEmbeddedDocuments("Item",[t]);case 5:case"end":return r.stop()}}),_callee56,this)}))),function _handleApplication(t){return P.apply(this,arguments)})},{key:"_handleRemoveSourceOnDrop",value:(O=actor_sheet_asyncToGenerator(actor_sheet_regeneratorRuntime().mark((function _callee57(t){var r;return actor_sheet_regeneratorRuntime().wrap((function _callee57$(a){for(;;)switch(a.prev=a.next){case 0:if(!(r=t.parent)||!r.isOwner){a.next=4;break}return a.next=4,r.deleteEmbeddedDocuments("Item",[t._id]);case 4:case"end":return a.stop()}}),_callee57)}))),function _handleRemoveSourceOnDrop(t){return O.apply(this,arguments)})},{key:"_onDropItemCreate",value:(T=actor_sheet_asyncToGenerator(actor_sheet_regeneratorRuntime().mark((function _callee58(t){return actor_sheet_regeneratorRuntime().wrap((function _callee58$(r){for(;;)switch(r.prev=r.next){case 0:if(!(t instanceof Array)){r.next=2;break}return r.abrupt("return",this.actor.createEmbeddedDocuments("Item",t));case 2:return r.next=4,this._manageDragItems(t,t.type);case 4:return r.abrupt("return",r.sent);case 5:case"end":return r.stop()}}),_callee58,this)}))),function _onDropItemCreate(t){return T.apply(this,arguments)})},{key:"_onDropActor",value:(x=actor_sheet_asyncToGenerator(actor_sheet_regeneratorRuntime().mark((function _callee59(t,r){var a,o,i;return actor_sheet_regeneratorRuntime().wrap((function _callee59$(t){for(;;)switch(t.prev=t.next){case 0:if(this.actor.isOwner){t.next=2;break}return t.abrupt("return",!1);case 2:return t.next=4,(0,h.x8)(r,this.id,!1);case 4:if(a=t.sent,o=a.item,i=a.typeClass,!a.selfTarget){t.next=10;break}return t.abrupt("return");case 10:return t.next=12,this._manageDragItems(o,i);case 12:return t.abrupt("return",t.sent);case 13:case"end":return t.stop()}}),_callee59,this)}))),function _onDropActor(t,r){return x.apply(this,arguments)})},{key:"_onDropActiveEffect",value:(w=actor_sheet_asyncToGenerator(actor_sheet_regeneratorRuntime().mark((function _callee60(t,r){var a,o,i;return actor_sheet_regeneratorRuntime().wrap((function _callee60$(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,ActiveEffect.implementation.fromDropData(r);case 2:if(o=t.sent,this.actor.isOwner&&o){t.next=5;break}return t.abrupt("return",!1);case 5:if(this.actor.uuid!==(null===(a=o.parent)||void 0===a?void 0:a.uuid)){t.next=7;break}return t.abrupt("return",!1);case 7:return(i=o.toObject()).origin=this.actor.uuid,t.abrupt("return",ActiveEffect.create(i,{parent:this.actor}));case 10:case"end":return t.stop()}}),_callee60,this)}))),function _onDropActiveEffect(t,r){return w.apply(this,arguments)})},{key:"_onDropItem",value:(v=actor_sheet_asyncToGenerator(actor_sheet_regeneratorRuntime().mark((function _callee61(t,a){var o,i,c,u,l,p,d;return actor_sheet_regeneratorRuntime().wrap((function _callee61$(h){for(;;)switch(h.prev=h.next){case 0:if(this.actor.isOwner){h.next=2;break}return h.abrupt("return",!1);case 2:return h.next=4,Item.implementation.fromDropData(a);case 4:if(i=h.sent,c=i.toObject(),y.Z.obfuscateDropData(c,a.tabsinvisible),(l=$(t.target).parents(".item"))&&"bags"==l.attr("data-category")&&r.Z.equipmentCategories.includes(i.type)&&l.attr("data-item-id")!=i.id&&(u=l.attr("data-item-id")),!(p=this.actor.uuid===(null===(o=i.parent)||void 0===o?void 0:o.uuid))){h.next=28;break}if(!t.ctrlKey){h.next=16;break}return h.next=14,this.handleItemCopy(c,i.type);case 14:case 21:h.next=26;break;case 16:if(!u){h.next=23;break}return d={_id:i.id,"system.parent_id":u},i.system.worn&&i.system.worn.value&&(d["system.worn.value"]=!1),h.next=21,this.actor.updateEmbeddedDocuments("Item",[d]);case 23:if(!r.Z.equipmentCategories.includes(i.type)){h.next=26;break}return h.next=26,this.actor.updateEmbeddedDocuments("Item",[{_id:i.id,system:{parent_id:0}}]);case 26:h.next=30;break;case 28:return h.next=30,this._onDropItemCreate(c);case 30:if(!t.altKey||p||!r.Z.equipmentCategories.includes(i.type)){h.next=33;break}return h.next=33,this._handleRemoveSourceOnDrop(i);case 33:case"end":return h.stop()}}),_callee61,this)}))),function _onDropItem(t,r){return v.apply(this,arguments)})}],[{key:"defaultOptions",get:function get(){var t=actor_sheet_get(actor_sheet_getPrototypeOf(ActorSheetDsa5),"defaultOptions",this);return t.tabs=[{navSelector:".tabs",contentSelector:".content",initial:"skills"}],mergeObject(t,{width:770,height:740,scrollY:[".save-scroll"],dragDrop:[{dragSelector:".content .item",dropSelector:null},{dragSelector:".mainEffects .statusEffect",dropSelector:null}]}),t}}]),ActorSheetDsa5}(),A=function(t){actor_sheet_inherits(TraditionArtifactpicker,Application);var r,a=actor_sheet_createSuper(TraditionArtifactpicker);function TraditionArtifactpicker(t){var r,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return actor_sheet_classCallCheck(this,TraditionArtifactpicker),(r=a.call(this,o)).actor=t,r}return actor_sheet_createClass(TraditionArtifactpicker,[{key:"template",get:function get(){return"systems/dsa5/templates/actors/traditionPicker.html"}},{key:"getData",value:(r=actor_sheet_asyncToGenerator(actor_sheet_regeneratorRuntime().mark((function _callee62(t){var r,a;return actor_sheet_regeneratorRuntime().wrap((function _callee62$(o){for(;;)switch(o.prev=o.next){case 0:return o.next=2,actor_sheet_get(actor_sheet_getPrototypeOf(TraditionArtifactpicker.prototype),"getData",this).call(this,t);case 2:return r=o.sent,a=this.actor.items.filter((function(t){return["equipment","armor","rangeweapon","meleeweapon"].includes(t.type)})),mergeObject(r,{items:a}),o.abrupt("return",r);case 6:case"end":return o.stop()}}),_callee62,this)}))),function getData(t){return r.apply(this,arguments)})},{key:"activateListeners",value:function activateListeners(t){var r=this;actor_sheet_get(actor_sheet_getPrototypeOf(TraditionArtifactpicker.prototype),"activateListeners",this).call(this,t),t.find(".slot").click(function(){var t=actor_sheet_asyncToGenerator(actor_sheet_regeneratorRuntime().mark((function _callee63(t){var a;return actor_sheet_regeneratorRuntime().wrap((function _callee63$(o){for(;;)switch(o.prev=o.next){case 0:return a=r.actor.items.get(t.currentTarget.dataset.itemId),o.next=3,a.update({"system.isArtifact":!a.system.isArtifact});case 3:case"end":return o.stop()}}),_callee63)})));return function(r){return t.apply(this,arguments)}}())}}],[{key:"defaultOptions",get:function get(){var t=actor_sheet_get(actor_sheet_getPrototypeOf(TraditionArtifactpicker),"defaultOptions",this);return mergeObject(t,{width:440,resizable:!0}),t}}]),TraditionArtifactpicker}(),O=__webpack_require__(794);function dsa5_wizard_regeneratorRuntime(){dsa5_wizard_regeneratorRuntime=function _regeneratorRuntime(){return t};var t={},r=Object.prototype,a=r.hasOwnProperty,o="function"==typeof Symbol?Symbol:{},i=o.iterator||"@@iterator",c=o.asyncIterator||"@@asyncIterator",u=o.toStringTag||"@@toStringTag";function define(t,r,a){return Object.defineProperty(t,r,{value:a,enumerable:!0,configurable:!0,writable:!0}),t[r]}try{define({},"")}catch(t){define=function define(t,r,a){return t[r]=a}}function wrap(t,r,a,o){var i=r&&r.prototype instanceof Generator?r:Generator,c=Object.create(i.prototype),u=new Context(o||[]);return c._invoke=function(t,r,a){var o="suspendedStart";return function(i,c){if("executing"===o)throw new Error("Generator is already running");if("completed"===o){if("throw"===i)throw c;return doneResult()}for(a.method=i,a.arg=c;;){var u=a.delegate;if(u){var p=maybeInvokeDelegate(u,a);if(p){if(p===l)continue;return p}}if("next"===a.method)a.sent=a._sent=a.arg;else if("throw"===a.method){if("suspendedStart"===o)throw o="completed",a.arg;a.dispatchException(a.arg)}else"return"===a.method&&a.abrupt("return",a.arg);o="executing";var d=tryCatch(t,r,a);if("normal"===d.type){if(o=a.done?"completed":"suspendedYield",d.arg===l)continue;return{value:d.arg,done:a.done}}"throw"===d.type&&(o="completed",a.method="throw",a.arg=d.arg)}}}(t,a,u),c}function tryCatch(t,r,a){try{return{type:"normal",arg:t.call(r,a)}}catch(t){return{type:"throw",arg:t}}}t.wrap=wrap;var l={};function Generator(){}function GeneratorFunction(){}function GeneratorFunctionPrototype(){}var p={};define(p,i,(function(){return this}));var d=Object.getPrototypeOf,h=d&&d(d(values([])));h&&h!==r&&a.call(h,i)&&(p=h);var m=GeneratorFunctionPrototype.prototype=Generator.prototype=Object.create(p);function defineIteratorMethods(t){["next","throw","return"].forEach((function(r){define(t,r,(function(t){return this._invoke(r,t)}))}))}function AsyncIterator(t,r){function invoke(o,i,c,u){var l=tryCatch(t[o],t,i);if("throw"!==l.type){var p=l.arg,d=p.value;return d&&"object"==dsa5_wizard_typeof(d)&&a.call(d,"__await")?r.resolve(d.__await).then((function(t){invoke("next",t,c,u)}),(function(t){invoke("throw",t,c,u)})):r.resolve(d).then((function(t){p.value=t,c(p)}),(function(t){return invoke("throw",t,c,u)}))}u(l.arg)}var o;this._invoke=function(t,a){function callInvokeWithMethodAndArg(){return new r((function(r,o){invoke(t,a,r,o)}))}return o=o?o.then(callInvokeWithMethodAndArg,callInvokeWithMethodAndArg):callInvokeWithMethodAndArg()}}function maybeInvokeDelegate(t,r){var a=t.iterator[r.method];if(void 0===a){if(r.delegate=null,"throw"===r.method){if(t.iterator.return&&(r.method="return",r.arg=void 0,maybeInvokeDelegate(t,r),"throw"===r.method))return l;r.method="throw",r.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var o=tryCatch(a,t.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,l;var i=o.arg;return i?i.done?(r[t.resultName]=i.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=void 0),r.delegate=null,l):i:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,l)}function pushTryEntry(t){var r={tryLoc:t[0]};1 in t&&(r.catchLoc=t[1]),2 in t&&(r.finallyLoc=t[2],r.afterLoc=t[3]),this.tryEntries.push(r)}function resetTryEntry(t){var r=t.completion||{};r.type="normal",delete r.arg,t.completion=r}function Context(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(pushTryEntry,this),this.reset(!0)}function values(t){if(t){var r=t[i];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var o=-1,c=function next(){for(;++o=0;--o){var i=this.tryEntries[o],c=i.completion;if("root"===i.tryLoc)return handle("end");if(i.tryLoc<=this.prev){var u=a.call(i,"catchLoc"),l=a.call(i,"finallyLoc");if(u&&l){if(this.prev=0;--o){var i=this.tryEntries[o];if(i.tryLoc<=this.prev&&a.call(i,"finallyLoc")&&this.prev=0;--r){var a=this.tryEntries[r];if(a.finallyLoc===t)return this.complete(a.completion,a.afterLoc),resetTryEntry(a),l}},catch:function _catch(t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc===t){var o=a.completion;if("throw"===o.type){var i=o.arg;resetTryEntry(a)}return i}}throw new Error("illegal catch attempt")},delegateYield:function delegateYield(t,r,a){return this.delegate={iterator:values(t),resultName:r,nextLoc:a},"next"===this.method&&(this.arg=void 0),l}},t}function dsa5_wizard_typeof(t){return dsa5_wizard_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},dsa5_wizard_typeof(t)}function dsa5_wizard_createForOfIteratorHelper(t,r){var a="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!a){if(Array.isArray(t)||(a=function dsa5_wizard_unsupportedIterableToArray(t,r){if(!t)return;if("string"==typeof t)return dsa5_wizard_arrayLikeToArray(t,r);var a=Object.prototype.toString.call(t).slice(8,-1);"Object"===a&&t.constructor&&(a=t.constructor.name);if("Map"===a||"Set"===a)return Array.from(t);if("Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a))return dsa5_wizard_arrayLikeToArray(t,r)}(t))||r&&t&&"number"==typeof t.length){a&&(t=a);var o=0,i=function F(){};return{s:i,n:function n(){return o>=t.length?{done:!0}:{done:!1,value:t[o++]}},e:function e(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var c,u=!0,l=!1;return{s:function s(){a=a.call(t)},n:function n(){var t=a.next();return u=t.done,t},e:function e(t){l=!0,c=t},f:function f(){try{u||null==a.return||a.return()}finally{if(l)throw c}}}}function dsa5_wizard_arrayLikeToArray(t,r){(null==r||r>t.length)&&(r=t.length);for(var a=0,o=new Array(r);a1&&void 0!==arguments[1]?arguments[1]:",",o=[],i=game.i18n.localize("combatskillcountdivider")+":",c=dsa5_wizard_createForOfIteratorHelper(t.split(a));try{for(c.s();!(r=c.n()).done;){var u=r.value;if(u.includes(i)){var l=u.split(":");o.push({choices:l[1].split("/").map((function(t){return t.trim()})),allowedCount:Number(l[0].match(/\d/g))})}}}catch(t){c.e(t)}finally{c.f()}return o}},{key:"parseToItem",value:(m=dsa5_wizard_asyncToGenerator(dsa5_wizard_regeneratorRuntime().mark((function _callee3(a,o){var i=this;return dsa5_wizard_regeneratorRuntime().wrap((function _callee3$(c){for(;;)switch(c.prev=c.next){case 0:if(""!=a.trim()){c.next=2;break}return c.abrupt("return",[]);case 2:return c.next=4,Promise.all(a.split(", ").map(function(){var a=dsa5_wizard_asyncToGenerator(dsa5_wizard_regeneratorRuntime().mark((function _callee2(a){var c,u,l,p,d,h,m;return dsa5_wizard_regeneratorRuntime().wrap((function _callee2$(y){for(;;)switch(y.prev=y.next){case 0:return c=t.Z.parseAbilityString(a.trim()),y.next=3,i.findCompendiumItem(c.original,o);case 3:if(u=y.sent){y.next=8;break}return y.next=7,i.findCompendiumItem(c.name,o);case 7:u=y.sent;case 8:if(u)h=u.uuid,(u=duplicate(u)).uuid=h,u.tooltip=game.i18n.localize("Details"),(u=O.Z.reverseAdoptionCalculation(i.actor,c,u)).system.APValue&&(u.APunparseable=isNaN(u.system.APValue.value),u.apCost=u.APunparseable?u.system.APValue.value:c.step*Number(u.system.APValue.value));else if(i.attributes.includes(c.name)){for(l=0,p=i.actor.system.characteristics[game.dsa5.config.knownShortcuts[c.name.toLowerCase()][1]].value+1;p")),d=o.map((function(r){return t.Z.categoryLocalization(r)})).join("/"),i.errors.push("".concat(d,": ").concat(a)),u={name:a.trim(),notFound:!0,tooltip:game.i18n.localize("DSAError.itemNotFound"),apCost:"?"};return u.replaceName=c.original,u.step=c.step,m=null!=i.actor.items.find((function(t){return o.includes(t.type)&&t.name==c.original})),u.disabled=m||u.notFound||u.APunparseable,m&&(u.tooltip=game.i18n.localize("YouAlreadyHaveit")),y.abrupt("return",u);case 15:case"end":return y.stop()}}),_callee2)})));return function(t){return a.apply(this,arguments)}}()));case 4:return c.abrupt("return",c.sent);case 5:case"end":return c.stop()}}),_callee3)}))),function parseToItem(t,r){return m.apply(this,arguments)})},{key:"mergeLevels",value:function mergeLevels(t,r,a){var o=!1,i=t.find((function(t){return t.name==r.name&&t.type==r.type}));if(i){o=!0;var c=Number(getProperty(r,"system.step.value"));c&&(i.system.step.value=Math.min(i.system.step.value+=c,i.system[a].value))}else t.push(r);return o}},{key:"addSelections",value:(d=dsa5_wizard_asyncToGenerator(dsa5_wizard_regeneratorRuntime().mark((function _callee4(r){var o,c,u,l,p,d,h,m=arguments;return dsa5_wizard_regeneratorRuntime().wrap((function _callee4$(y){for(;;)switch(y.prev=y.next){case 0:o=!(m.length>1&&void 0!==m[1])||m[1],c=[],u=dsa5_wizard_createForOfIteratorHelper(r),y.prev=3,u.s();case 5:if((l=u.n()).done){y.next=31;break}if(p=l.value,""!=$(p).val()){y.next=10;break}return y.abrupt("continue",29);case 10:return y.next=12,fromUuid($(p).val());case 12:d=y.sent.toObject(),h=t.Z.parseAbilityString(d.name),d.name=$(p).attr("name"),y.t0=d.type,y.next="advantage"===y.t0||"disadvantage"===y.t0?18:"specialability"===y.t0?22:"magictrick"===y.t0?27:29;break;case 18:return d.system.step.value=Number(p.dataset.step),d=O.Z.reverseAdoptionCalculation(this.actor,h,d),this.mergeLevels(c,d,"max")||a.Z.vantageAdded(this.actor,d),y.abrupt("break",29);case 22:return d.system.step.value=Number(p.dataset.step),"true"==p.dataset.free&&(d.system.APValue.value=0),d=O.Z.reverseAdoptionCalculation(this.actor,h,d),this.mergeLevels(c,d,"maxRank")||i.Z.abilityAdded(this.actor,d),y.abrupt("break",29);case 27:return this.mergeLevels(c,d),y.abrupt("break",29);case 29:y.next=5;break;case 31:y.next=36;break;case 33:y.prev=33,y.t1=y.catch(3),u.e(y.t1);case 36:return y.prev=36,u.f(),y.finish(36);case 39:return y.next=41,this.actor.createEmbeddedDocuments("Item",c,{render:o});case 41:case"end":return y.stop()}}),_callee4,this,[[3,33,36,39]])}))),function addSelections(t){return d.apply(this,arguments)})},{key:"fixPreviousCosts",value:(p=dsa5_wizard_asyncToGenerator(dsa5_wizard_regeneratorRuntime().mark((function _callee5(t,r){var a,o,i;return dsa5_wizard_regeneratorRuntime().wrap((function _callee5$(c){for(;;)switch(c.prev=c.next){case 0:a=dsa5_wizard_createForOfIteratorHelper(r);try{for(i=function _loop2(){var r=o.value,a=t.find((function(t){return t.type==r.type&&t.name==r.name}));a&&(r.apCost-=a.apCost)},a.s();!(o=a.n()).done;)i()}catch(t){a.e(t)}finally{a.f()}case 2:case"end":return c.stop()}}),_callee5)}))),function fixPreviousCosts(t,r){return p.apply(this,arguments)})},{key:"alreadyAdded",value:(l=dsa5_wizard_asyncToGenerator(dsa5_wizard_regeneratorRuntime().mark((function _callee6(r,a){var o;return dsa5_wizard_regeneratorRuntime().wrap((function _callee6$(i){for(;;)switch(i.prev=i.next){case 0:if(""!=r){i.next=2;break}return i.abrupt("return",!1);case 2:return o=!1,i.next=5,new Promise((function(r,o){new Dialog({title:game.i18n.localize("DIALOG.warning"),content:game.i18n.format("DIALOG.alreadyAddedCharacterpart",{category:t.Z.categoryLocalization(a)}),default:"ok",buttons:{ok:{icon:'',label:game.i18n.localize("Ok"),default:!0,callback:function callback(){r(!1)}},cancel:{icon:'',label:game.i18n.localize("Cancel"),default:!0,callback:function callback(){r(!0)}}}}).render(!0)}));case 5:return o=i.sent,i.abrupt("return",o);case 7:case"end":return i.stop()}}),_callee6)}))),function alreadyAdded(t,r){return l.apply(this,arguments)})},{key:"updateSkill",value:(u=dsa5_wizard_asyncToGenerator(dsa5_wizard_regeneratorRuntime().mark((function _callee7(r,a){var o,i,c,u,l,p,d=this,h=arguments;return dsa5_wizard_regeneratorRuntime().wrap((function _callee7$(m){for(;;)switch(m.prev=m.next){case 0:o=h.length>2&&void 0!==h[2]?h[2]:1,i=!(h.length>3&&void 0!==h[3])||h[3],c=[],u=dsa5_wizard_createForOfIteratorHelper(r);try{for(p=function _loop3(){var r=l.value,u=t.Z.parseAbilityString(r.trim()),p=d.actor.items.find((function(t){return t.type==a&&t.name==u.name}));p?c.push({_id:p.id,"system.talentValue.value":Math.max(0,o*u.step+(i?Number(p.system.talentValue.value):0))}):(console.warn("Could not find ".concat(a," ").concat(r)),d.errors.push("".concat(t.Z.categoryLocalization(a),": ").concat(r)))},u.s();!(l=u.n()).done;)p()}catch(t){u.e(t)}finally{u.f()}return m.next=7,this.actor.updateEmbeddedDocuments("Item",c,{render:!1});case 7:case"end":return m.stop()}}),_callee7,this)}))),function updateSkill(t,r){return u.apply(this,arguments)})},{key:"getData",value:(c=dsa5_wizard_asyncToGenerator(dsa5_wizard_regeneratorRuntime().mark((function _callee8(t){var r;return dsa5_wizard_regeneratorRuntime().wrap((function _callee8$(a){for(;;)switch(a.prev=a.next){case 0:return a.next=2,dsa5_wizard_get(dsa5_wizard_getPrototypeOf(WizardDSA5.prototype),"getData",this).call(this,t);case 2:return r=a.sent,a.next=5,game.dsa5.itemLibrary.buildEquipmentIndex();case 5:return a.abrupt("return",r);case 6:case"end":return a.stop()}}),_callee8,this)}))),function getData(t){return c.apply(this,arguments)})},{key:"_validateInput",value:function _validateInput(t){var r,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this,o=/^exclusive_/,i=dsa5_wizard_createForOfIteratorHelper(t.find(".tab"));try{for(i.s();!(r=i.n()).done;){var c,u=r.value,l=$(u),p=new Set,d=dsa5_wizard_createForOfIteratorHelper(l.find(".exclusive"));try{for(d.s();!(c=d.n()).done;){var h=c.value;p.add(h.className.split(/\s+/).filter((function(t){return o.test(t)}))[0])}}catch(t){d.e(t)}finally{d.f()}var m,y=dsa5_wizard_createForOfIteratorHelper(p);try{for(y.s();!(m=y.n()).done;){var g=m.value,v=l.find(".allowedCount_"+g.split("_")[1]),_=Number(v.attr("data-count"));if(l.find(".".concat(g,":checked")).length!=_)return this._showInputValidation(v,l,a),!1}}catch(t){y.e(t)}finally{y.f()}}}catch(t){i.e(t)}finally{i.f()}return!0}},{key:"_showInputValidation",value:function _showInputValidation(t,r,a){ui.notifications.error(game.i18n.localize("DSAError.MissingChoices"));var o=t.closest(".tab").attr("data-tab");a.activateTab(o),WizardDSA5.flashElem(r.find(".tabs a[data-tab='".concat(o,"']"))),WizardDSA5.flashElem(t.closest("div"))}},{key:"activateListeners",value:function activateListeners(t){var r=this;dsa5_wizard_get(dsa5_wizard_getPrototypeOf(WizardDSA5.prototype),"activateListeners",this).call(this,t),(0,h.Ee)(t),t.find("button.ok").click((function(){r.updating||(r.updating=!0,r.updateCharacter($(r._element)).then((function(){return r.updating=!1})))})),t.find("button.cancel").click((function(){r.close()})),t.find(".show-item").click(function(){var t=dsa5_wizard_asyncToGenerator(dsa5_wizard_regeneratorRuntime().mark((function _callee9(t){var r;return dsa5_wizard_regeneratorRuntime().wrap((function _callee9$(a){for(;;)switch(a.prev=a.next){case 0:return r=t.currentTarget.dataset.uuid,a.next=3,fromUuid(r);case 3:a.sent.sheet.render(!0);case 5:case"end":return a.stop()}}),_callee9)})));return function(r){return t.apply(this,arguments)}}()),t.on("click",".searchableAbility a",(function(t){return(0,h.$8)(t)})),t.find(".exclusive").change((function(t){var r=$(t.currentTarget).closest(".tab"),a=$(t.currentTarget).attr("data-sel"),o=r.find(".allowedCount_".concat(a)),i=Number(o.attr("data-count"));if(r.find(".exclusive_".concat(a,":checked")).length>i)return t.currentTarget.checked=!1,void WizardDSA5.flashElem(o)}))}},{key:"finalizeUpdate",value:function finalizeUpdate(){0==this.errors.length?this.close():$(this._element).find(".dialog-buttons").html('

    '.concat(game.i18n.localize("DSAError.notUnderstood"),"

    • ").concat(this.errors.join("
    • "),"
    "))}}],[{key:"defaultOptions",get:function get(){var t=dsa5_wizard_get(dsa5_wizard_getPrototypeOf(WizardDSA5),"defaultOptions",this);return t.tabs=[{navSelector:".tabs",contentSelector:".content",initial:"description"}],mergeObject(t,{classes:t.classes.concat(["dsa5","largeDialog","generationWizard"]),width:770,height:740}),t.resizable=!0,t}},{key:"flashElem",value:function flashElem(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"emphasize";t.addClass(r),setTimeout((function(){t.removeClass(r)}),600)}}]),WizardDSA5}();function culture_wizard_typeof(t){return culture_wizard_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},culture_wizard_typeof(t)}function culture_wizard_regeneratorRuntime(){culture_wizard_regeneratorRuntime=function _regeneratorRuntime(){return t};var t={},r=Object.prototype,a=r.hasOwnProperty,o="function"==typeof Symbol?Symbol:{},i=o.iterator||"@@iterator",c=o.asyncIterator||"@@asyncIterator",u=o.toStringTag||"@@toStringTag";function define(t,r,a){return Object.defineProperty(t,r,{value:a,enumerable:!0,configurable:!0,writable:!0}),t[r]}try{define({},"")}catch(t){define=function define(t,r,a){return t[r]=a}}function wrap(t,r,a,o){var i=r&&r.prototype instanceof Generator?r:Generator,c=Object.create(i.prototype),u=new Context(o||[]);return c._invoke=function(t,r,a){var o="suspendedStart";return function(i,c){if("executing"===o)throw new Error("Generator is already running");if("completed"===o){if("throw"===i)throw c;return doneResult()}for(a.method=i,a.arg=c;;){var u=a.delegate;if(u){var p=maybeInvokeDelegate(u,a);if(p){if(p===l)continue;return p}}if("next"===a.method)a.sent=a._sent=a.arg;else if("throw"===a.method){if("suspendedStart"===o)throw o="completed",a.arg;a.dispatchException(a.arg)}else"return"===a.method&&a.abrupt("return",a.arg);o="executing";var d=tryCatch(t,r,a);if("normal"===d.type){if(o=a.done?"completed":"suspendedYield",d.arg===l)continue;return{value:d.arg,done:a.done}}"throw"===d.type&&(o="completed",a.method="throw",a.arg=d.arg)}}}(t,a,u),c}function tryCatch(t,r,a){try{return{type:"normal",arg:t.call(r,a)}}catch(t){return{type:"throw",arg:t}}}t.wrap=wrap;var l={};function Generator(){}function GeneratorFunction(){}function GeneratorFunctionPrototype(){}var p={};define(p,i,(function(){return this}));var d=Object.getPrototypeOf,h=d&&d(d(values([])));h&&h!==r&&a.call(h,i)&&(p=h);var m=GeneratorFunctionPrototype.prototype=Generator.prototype=Object.create(p);function defineIteratorMethods(t){["next","throw","return"].forEach((function(r){define(t,r,(function(t){return this._invoke(r,t)}))}))}function AsyncIterator(t,r){function invoke(o,i,c,u){var l=tryCatch(t[o],t,i);if("throw"!==l.type){var p=l.arg,d=p.value;return d&&"object"==culture_wizard_typeof(d)&&a.call(d,"__await")?r.resolve(d.__await).then((function(t){invoke("next",t,c,u)}),(function(t){invoke("throw",t,c,u)})):r.resolve(d).then((function(t){p.value=t,c(p)}),(function(t){return invoke("throw",t,c,u)}))}u(l.arg)}var o;this._invoke=function(t,a){function callInvokeWithMethodAndArg(){return new r((function(r,o){invoke(t,a,r,o)}))}return o=o?o.then(callInvokeWithMethodAndArg,callInvokeWithMethodAndArg):callInvokeWithMethodAndArg()}}function maybeInvokeDelegate(t,r){var a=t.iterator[r.method];if(void 0===a){if(r.delegate=null,"throw"===r.method){if(t.iterator.return&&(r.method="return",r.arg=void 0,maybeInvokeDelegate(t,r),"throw"===r.method))return l;r.method="throw",r.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var o=tryCatch(a,t.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,l;var i=o.arg;return i?i.done?(r[t.resultName]=i.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=void 0),r.delegate=null,l):i:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,l)}function pushTryEntry(t){var r={tryLoc:t[0]};1 in t&&(r.catchLoc=t[1]),2 in t&&(r.finallyLoc=t[2],r.afterLoc=t[3]),this.tryEntries.push(r)}function resetTryEntry(t){var r=t.completion||{};r.type="normal",delete r.arg,t.completion=r}function Context(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(pushTryEntry,this),this.reset(!0)}function values(t){if(t){var r=t[i];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var o=-1,c=function next(){for(;++o=0;--o){var i=this.tryEntries[o],c=i.completion;if("root"===i.tryLoc)return handle("end");if(i.tryLoc<=this.prev){var u=a.call(i,"catchLoc"),l=a.call(i,"finallyLoc");if(u&&l){if(this.prev=0;--o){var i=this.tryEntries[o];if(i.tryLoc<=this.prev&&a.call(i,"finallyLoc")&&this.prev=0;--r){var a=this.tryEntries[r];if(a.finallyLoc===t)return this.complete(a.completion,a.afterLoc),resetTryEntry(a),l}},catch:function _catch(t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc===t){var o=a.completion;if("throw"===o.type){var i=o.arg;resetTryEntry(a)}return i}}throw new Error("illegal catch attempt")},delegateYield:function delegateYield(t,r,a){return this.delegate={iterator:values(t),resultName:r,nextLoc:a},"next"===this.method&&(this.arg=void 0),l}},t}function culture_wizard_asyncGeneratorStep(t,r,a,o,i,c,u){try{var l=t[c](u),p=l.value}catch(t){return void a(t)}l.done?r(p):Promise.resolve(p).then(o,i)}function culture_wizard_asyncToGenerator(t){return function(){var r=this,a=arguments;return new Promise((function(o,i){var c=t.apply(r,a);function _next(t){culture_wizard_asyncGeneratorStep(c,o,i,_next,_throw,"next",t)}function _throw(t){culture_wizard_asyncGeneratorStep(c,o,i,_next,_throw,"throw",t)}_next(void 0)}))}}function culture_wizard_classCallCheck(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}function culture_wizard_defineProperties(t,r){for(var a=0;a0,l.t12=o.length>0,l.t13=i.length>0,l.t14=c.length>0,l.t15=c.length>1,l.t16=a.length>0||o.length>0,l.t17=i.length>0||c.length>0,l.next=44,TextEditor.enrichHTML(getProperty(this.culture.system,"clothing.value"),{secrets:!1,async:!0});case 44:return l.t18=l.sent,l.next=47,TextEditor.enrichHTML(getProperty(this.culture.system,"description.value"),{secrets:!1,async:!0});case 47:return l.t19=l.sent,l.t20={title:l.t4,culture:l.t5,description:l.t6,advantages:l.t7,disadvantages:l.t8,writings:l.t9,languages:l.t10,advantagesToChose:l.t11,disadvantagesToChose:l.t12,writingsToChose:l.t13,languagesToChose:l.t14,languagesToSelect:l.t15,vantagesToChose:l.t16,generalToChose:l.t17,enrichedClothing:l.t18,enrichedDescription:l.t19},(0,l.t2)(l.t3,l.t20),l.abrupt("return",r);case 51:case"end":return l.stop()}}),_callee,this)}))),function getData(t){return o.apply(this,arguments)})},{key:"addCulture",value:(a=culture_wizard_asyncToGenerator(culture_wizard_regeneratorRuntime().mark((function _callee2(t,r){return culture_wizard_regeneratorRuntime().wrap((function _callee2$(a){for(;;)switch(a.prev=a.next){case 0:this.actor=t,this.culture=duplicate(r);case 2:case"end":return a.stop()}}),_callee2,this)}))),function addCulture(t,r){return a.apply(this,arguments)})},{key:"_validateInput",value:function _validateInput(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this,a=t.find(".localKnowledge");if(""==a.val())return this._showInputValidation(a,t,r),!1;var o=t.find(".selectOnlyOne");if(o.length){var i=o.find(".optional:checked");if(1!=i.length)return this._showInputValidation(o,t,r),!1}return culture_wizard_get(culture_wizard_getPrototypeOf(CultureWizard.prototype),"_validateInput",this).call(this,t,r)}},{key:"updateCharacter",value:(r=culture_wizard_asyncToGenerator(culture_wizard_regeneratorRuntime().mark((function _callee3(t){var r,a,o,i,c=arguments;return culture_wizard_regeneratorRuntime().wrap((function _callee3$(u){for(;;)switch(u.prev=u.next){case 0:if(r=c.length>1&&void 0!==c[1]?c[1]:this,t.find("button.ok i").toggleClass("fa-check fa-spinner fa-spin"),a=Number(t.find(".apCost").text()),u.t1=!this._validateInput(t,r),u.t1){u.next=8;break}return u.next=7,this.actor.checkEnoughXP(a);case 7:u.t1=!u.sent;case 8:if(u.t0=u.t1,u.t0){u.next=13;break}return u.next=12,this.alreadyAdded(this.actor.system.details.culture.value,"culture");case 12:u.t0=u.sent;case 13:if(!u.t0){u.next=16;break}return t.find("button.ok i").toggleClass("fa-check fa-spinner fa-spin"),u.abrupt("return");case 16:return o={"system.details.culture.value":this.culture.name},u.next=19,this.findCompendiumItem("".concat(game.i18n.localize("LocalizedIDs.localKnowledge")," ()"),["specialability"]);case 19:if(!(i=u.sent)){u.next=26;break}return(i=duplicate(i)).name="".concat(game.i18n.localize("LocalizedIDs.localKnowledge")," (").concat(t.find(".localKnowledge").val(),")"),i.system.APValue.value=0,u.next=26,this.actor.createEmbeddedDocuments("Item",[i],{render:!1});case 26:return u.next=28,this.addSelections(t.find(".optional:checked"),!1);case 28:return u.next=30,this.actor._updateAPs(a,{},{render:!1});case 30:return u.next=32,this.updateSkill(this.culture.system.skills.value.split(","),"skill");case 32:return u.next=34,this.actor.update(o);case 34:this.finalizeUpdate();case 35:case"end":return u.stop()}}),_callee3,this)}))),function updateCharacter(t){return r.apply(this,arguments)})}],[{key:"defaultOptions",get:function get(){var t=culture_wizard_get(culture_wizard_getPrototypeOf(CultureWizard),"defaultOptions",this);return t.title=game.i18n.format("WIZARD.addItem",{item:"".concat(game.i18n.localize("TYPES.Item.culture"))}),t.template="systems/dsa5/templates/wizard/add-culture-wizard.html",t}}]),CultureWizard}(P);function career_wizard_typeof(t){return career_wizard_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},career_wizard_typeof(t)}function career_wizard_createForOfIteratorHelper(t,r){var a="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!a){if(Array.isArray(t)||(a=function career_wizard_unsupportedIterableToArray(t,r){if(!t)return;if("string"==typeof t)return career_wizard_arrayLikeToArray(t,r);var a=Object.prototype.toString.call(t).slice(8,-1);"Object"===a&&t.constructor&&(a=t.constructor.name);if("Map"===a||"Set"===a)return Array.from(t);if("Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a))return career_wizard_arrayLikeToArray(t,r)}(t))||r&&t&&"number"==typeof t.length){a&&(t=a);var o=0,i=function F(){};return{s:i,n:function n(){return o>=t.length?{done:!0}:{done:!1,value:t[o++]}},e:function e(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var c,u=!0,l=!1;return{s:function s(){a=a.call(t)},n:function n(){var t=a.next();return u=t.done,t},e:function e(t){l=!0,c=t},f:function f(){try{u||null==a.return||a.return()}finally{if(l)throw c}}}}function career_wizard_arrayLikeToArray(t,r){(null==r||r>t.length)&&(r=t.length);for(var a=0,o=new Array(r);a=0;--o){var i=this.tryEntries[o],c=i.completion;if("root"===i.tryLoc)return handle("end");if(i.tryLoc<=this.prev){var u=a.call(i,"catchLoc"),l=a.call(i,"finallyLoc");if(u&&l){if(this.prev=0;--o){var i=this.tryEntries[o];if(i.tryLoc<=this.prev&&a.call(i,"finallyLoc")&&this.prev=0;--r){var a=this.tryEntries[r];if(a.finallyLoc===t)return this.complete(a.completion,a.afterLoc),resetTryEntry(a),l}},catch:function _catch(t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc===t){var o=a.completion;if("throw"===o.type){var i=o.arg;resetTryEntry(a)}return i}}throw new Error("illegal catch attempt")},delegateYield:function delegateYield(t,r,a){return this.delegate={iterator:values(t),resultName:r,nextLoc:a},"next"===this.method&&(this.arg=void 0),l}},t}function career_wizard_asyncGeneratorStep(t,r,a,o,i,c,u){try{var l=t[c](u),p=l.value}catch(t){return void a(t)}l.done?r(p):Promise.resolve(p).then(o,i)}function career_wizard_asyncToGenerator(t){return function(){var r=this,a=arguments;return new Promise((function(o,i){var c=t.apply(r,a);function _next(t){career_wizard_asyncGeneratorStep(c,o,i,_next,_throw,"next",t)}function _throw(t){career_wizard_asyncGeneratorStep(c,o,i,_next,_throw,"throw",t)}_next(void 0)}))}}function career_wizard_defineProperties(t,r){for(var a=0;aa)return t.currentTarget.checked=!1,void P.flashElem(r.find(".maxTricks"))}var o=Number(r.attr("data-cost"));r.find(".optional:checked").each((function(){o+=Number($(this).attr("data-cost"))})),r.find(".attributes:checked").each((function(){o+=Number($(this).attr("data-cost"))}));var i=r.find(".apCost");i.text(o),P.flashElem(i,"emphasize2")}))}},{key:"_validateInput",value:function _validateInput(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this,a=t.find(".maxTricks"),o=Number(a.attr("data-spelltricklimit"))||0;return t.find(".exclusiveTricks:checked").length!=o?(this._showInputValidation(a,t,r),!1):career_wizard_get(career_wizard_getPrototypeOf(CareerWizard.prototype),"_validateInput",this).call(this,t,r)}},{key:"getData",value:(l=career_wizard_asyncToGenerator(career_wizard_regeneratorRuntime().mark((function _callee(t){var r,a,o,i,c,u,l,p,d,h,m,y,g;return career_wizard_regeneratorRuntime().wrap((function _callee$(v){for(;;)switch(v.prev=v.next){case 0:return v.next=2,career_wizard_get(career_wizard_getPrototypeOf(CareerWizard.prototype),"getData",this).call(this,t);case 2:return r=v.sent,v.next=5,this.parseToItem(this.career.system.requirements.value,["disadvantage","advantage","specialability"]);case 5:return a=v.sent,o=a.filter((function(t){return["advantage","disadvantage"].includes(t.type)&&!t.disabled})),v.next=9,this.parseToItem(this.career.system.recommendedAdvantages.value,["advantage"]);case 9:return i=v.sent,this.fixPreviousCosts(a,i),v.next=13,this.parseToItem(this.career.system.recommendedDisadvantages.value,["disadvantage"]);case 13:return c=v.sent,this.fixPreviousCosts(a,c),u=a.filter((function(t){return t.attributeRequirement})),l=this._parseAttributes(this.career.system.combatSkills.value,/,|;/),p=this._parseAttributes(this.career.system.specialAbilities.value),d=this._parseAttributes(this.career.system.spells.value),h=this._parseAttributes(this.career.system.liturgies.value),m=Number(this.career.system.APValue.value),y=a.reduce((function(t,r){return t+(r.disabled?0:Number(r.system.APValue.value)||0)}),0),g=a.filter((function(t){return"specialability"==t.type&&!t.disabled})),v.t0=mergeObject,v.t1=r,v.t2=game.i18n.format("WIZARD.addItem",{item:"".concat(game.i18n.localize("career")," ").concat(this.career.name)}),v.t3=this.career,v.t4=game.i18n.format("WIZARD.careerdescr",{career:this.career.name,cost:m+y}),v.t5=m,v.t6=i,v.t7=c,v.t8=o,v.t9=p,v.t10=d,v.t11=h,v.t12=g,v.t13=l,v.next=39,this.parseToItem(this.career.system.spelltricks.value,["magictrick"]);case 39:return v.t14=v.sent,v.t15=u,v.t16=i.length,v.t17=c.length,v.t18=i.length||c.length||o.length,v.t19=o.length,v.t20=g.length,v.t21=l.length,v.t22=this.career.system.spelltrickCount.value||d.length,v.t23=h.length,v.t24=u.length,v.t25=g.length||u.length||p.length,v.next=53,TextEditor.enrichHTML(getProperty(this.career.system,"clothing.value"),{secrets:!1,async:!0});case 53:return v.t26=v.sent,v.next=56,TextEditor.enrichHTML(getProperty(this.career.system,"description.value"),{secrets:!1,async:!0});case 56:return v.t27=v.sent,v.t28={title:v.t2,career:v.t3,description:v.t4,baseCost:v.t5,advantages:v.t6,disadvantages:v.t7,missingVantages:v.t8,specAbChoices:v.t9,spellChoices:v.t10,liturgyChoices:v.t11,missingSpecialabilities:v.t12,combatskillchoices:v.t13,spelltricks:v.t14,attributeRequirements:v.t15,advantagesToChose:v.t16,disadvantagesToChose:v.t17,vantagesToChose:v.t18,missingVantagesToChose:v.t19,missingSpecialabiltiesToChose:v.t20,combatToChose:v.t21,magicToChose:v.t22,religionToChose:v.t23,anyAttributeRequirements:v.t24,generalToChose:v.t25,enrichedClothing:v.t26,enrichedDescription:v.t27},(0,v.t0)(v.t1,v.t28),v.abrupt("return",r);case 60:case"end":return v.stop()}}),_callee,this)}))),function getData(t){return l.apply(this,arguments)})},{key:"addCareer",value:(u=career_wizard_asyncToGenerator(career_wizard_regeneratorRuntime().mark((function _callee2(t,r){return career_wizard_regeneratorRuntime().wrap((function _callee2$(a){for(;;)switch(a.prev=a.next){case 0:this.actor=t,this.career=duplicate(r);case 2:case"end":return a.stop()}}),_callee2,this)}))),function addCareer(t,r){return u.apply(this,arguments)})},{key:"setAbility",value:(c=career_wizard_asyncToGenerator(career_wizard_regeneratorRuntime().mark((function _callee3(r,a){var o,i,c,u,l,p,d,h=this,m=arguments;return career_wizard_regeneratorRuntime().wrap((function _callee3$(y){for(;;)switch(y.prev=y.next){case 0:if(o=m.length>2&&void 0!==m[2]?m[2]:[],""!=r.trim()){y.next=3;break}return y.abrupt("return");case 3:i=[],c=[],u=game.i18n.localize("combatskillcountdivider")+":",l=career_wizard_createForOfIteratorHelper(r.split(",").concat(o)),y.prev=7,d=career_wizard_regeneratorRuntime().mark((function _loop(){var r,o,l,d;return career_wizard_regeneratorRuntime().wrap((function _loop$(m){for(;;)switch(m.prev=m.next){case 0:if(!(r=p.value).includes(u)&&""!=r){m.next=3;break}return m.abrupt("return","continue");case 3:if(o=t.Z.parseAbilityString(r.trim()),!(l=h.actor.items.find((function(t){return a.includes(t.type)&&t.name==o.original})))){m.next=12;break}(l=duplicate(l)).system.talentValue?l.system.talentValue.value=o.step:l.system.step&&(l.system.step.value=o.step),l=O.Z.reverseAdoptionCalculation(h.actor,o,l),c.push(l),m.next=20;break;case 12:return m.next=14,h.findCompendiumItem(o.original,a);case 14:if(l=m.sent){m.next=19;break}return m.next=18,h.findCompendiumItem(o.name,a);case 18:l=m.sent;case 19:l?((l=duplicate(l)).name=o.original,l.system.talentValue?l.system.talentValue.value=o.step:l.system.step&&(l.system.step.value=o.step),l=O.Z.reverseAdoptionCalculation(h.actor,o,l),i.push(l)):(d=a.map((function(r){return t.Z.categoryLocalization(r)})).join("/"),h.errors.push("".concat(d,": ").concat(r)),ui.notifications.error(game.i18n.format("DSAError.notFound",{category:d,name:r})));case 20:case"end":return m.stop()}}),_loop)})),l.s();case 10:if((p=l.n()).done){y.next=17;break}return y.delegateYield(d(),"t0",12);case 12:if("continue"!==y.t0){y.next=15;break}return y.abrupt("continue",15);case 15:y.next=10;break;case 17:y.next=22;break;case 19:y.prev=19,y.t1=y.catch(7),l.e(y.t1);case 22:return y.prev=22,l.f(),y.finish(22);case 25:return y.next=27,this.actor.updateEmbeddedDocuments("Item",c,{render:!1});case 27:return y.next=29,this.actor.createEmbeddedDocuments("Item",i,{render:!1});case 29:case"end":return y.stop()}}),_callee3,this,[[7,19,22,25]])}))),function setAbility(t,r){return c.apply(this,arguments)})},{key:"addBlessing",value:(i=career_wizard_asyncToGenerator(career_wizard_regeneratorRuntime().mark((function _callee4(r,a){var o,i,c,u,l=this;return career_wizard_regeneratorRuntime().wrap((function _callee4$(p){for(;;)switch(p.prev=p.next){case 0:o=[],i=career_wizard_createForOfIteratorHelper(r),p.prev=2,u=career_wizard_regeneratorRuntime().mark((function _loop2(){var r,i,u;return career_wizard_regeneratorRuntime().wrap((function _loop2$(p){for(;;)switch(p.prev=p.next){case 0:if(r=c.value,""!=(i=r.trim())){p.next=4;break}return p.abrupt("return","continue");case 4:if(u=l.actor.items.find((function(t){return a==t.type&&t.name==i}))){p.next=10;break}return p.next=8,l.findCompendiumItem(i,[a]);case 8:(u=p.sent)?(u=duplicate(u),o.push(u)):(l.errors.push("".concat(t.Z.categoryLocalization(a),": ").concat(r)),ui.notifications.error(game.i18n.format("DSAError.notFound",{category:game.i18n.localize(a),name:i})));case 10:case"end":return p.stop()}}),_loop2)})),i.s();case 5:if((c=i.n()).done){p.next=12;break}return p.delegateYield(u(),"t0",7);case 7:if("continue"!==p.t0){p.next=10;break}return p.abrupt("continue",10);case 10:p.next=5;break;case 12:p.next=17;break;case 14:p.prev=14,p.t1=p.catch(2),i.e(p.t1);case 17:return p.prev=17,i.f(),p.finish(17);case 20:return p.next=22,this.actor.createEmbeddedDocuments("Item",o,{render:!1});case 22:case"end":return p.stop()}}),_callee4,this,[[2,14,17,20]])}))),function addBlessing(t,r){return i.apply(this,arguments)})},{key:"getExclusiveChoices",value:function getExclusiveChoices(t,r){var a,o=[],i=career_wizard_createForOfIteratorHelper(t.find("".concat(r,".exclusive:checked")));try{for(i.s();!(a=i.n()).done;){var c=a.value;o.push($(c).val())}}catch(t){i.e(t)}finally{i.f()}return o}},{key:"updateCharacter",value:(o=career_wizard_asyncToGenerator(career_wizard_regeneratorRuntime().mark((function _callee5(t){var r,a,o,i,c,u,l,p,d=arguments;return career_wizard_regeneratorRuntime().wrap((function _callee5$(h){for(;;)switch(h.prev=h.next){case 0:if(r=d.length>1&&void 0!==d[1]?d[1]:this,t.find("button.ok i").toggleClass("fa-check fa-spinner fa-spin"),a=Number(t.find(".apCost").text()),h.t1=!this._validateInput(t,r),h.t1){h.next=8;break}return h.next=7,this.actor.checkEnoughXP(a);case 7:h.t1=!h.sent;case 8:if(h.t0=h.t1,h.t0){h.next=13;break}return h.next=12,this.alreadyAdded(this.actor.system.details.career.value,"career");case 12:h.t0=h.sent;case 13:if(!h.t0){h.next=16;break}return t.find("button.ok i").toggleClass("fa-check fa-spinner fa-spin"),h.abrupt("return");case 16:o={"system.details.career.value":this.career.name,"system.freeLanguagePoints.value":this.career.system.languagePoints.value},i=career_wizard_createForOfIteratorHelper(t.find(".attributes"));try{for(i.s();!(c=i.n()).done;)u=c.value,l=$(u).attr("data-attribute").toLowerCase(),l=game.dsa5.config.knownShortcuts[l.toLowerCase()][1],Number(this.actor.system.characteristics[l].initial)+Number(this.actor.system.characteristics[l].advances)=t.length?{done:!0}:{done:!1,value:t[o++]}},e:function e(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var c,u=!0,l=!1;return{s:function s(){a=a.call(t)},n:function n(){var t=a.next();return u=t.done,t},e:function e(t){l=!0,c=t},f:function f(){try{u||null==a.return||a.return()}finally{if(l)throw c}}}}function species_wizard_arrayLikeToArray(t,r){(null==r||r>t.length)&&(r=t.length);for(var a=0,o=new Array(r);a=0;--o){var i=this.tryEntries[o],c=i.completion;if("root"===i.tryLoc)return handle("end");if(i.tryLoc<=this.prev){var u=a.call(i,"catchLoc"),l=a.call(i,"finallyLoc");if(u&&l){if(this.prev=0;--o){var i=this.tryEntries[o];if(i.tryLoc<=this.prev&&a.call(i,"finallyLoc")&&this.prev=0;--r){var a=this.tryEntries[r];if(a.finallyLoc===t)return this.complete(a.completion,a.afterLoc),resetTryEntry(a),l}},catch:function _catch(t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc===t){var o=a.completion;if("throw"===o.type){var i=o.arg;resetTryEntry(a)}return i}}throw new Error("illegal catch attempt")},delegateYield:function delegateYield(t,r,a){return this.delegate={iterator:values(t),resultName:r,nextLoc:a},"next"===this.method&&(this.arg=void 0),l}},t}function species_wizard_asyncGeneratorStep(t,r,a,o,i,c,u){try{var l=t[c](u),p=l.value}catch(t){return void a(t)}l.done?r(p):Promise.resolve(p).then(o,i)}function species_wizard_asyncToGenerator(t){return function(){var r=this,a=arguments;return new Promise((function(o,i){var c=t.apply(r,a);function _next(t){species_wizard_asyncGeneratorStep(c,o,i,_next,_throw,"next",t)}function _throw(t){species_wizard_asyncGeneratorStep(c,o,i,_next,_throw,"throw",t)}_next(void 0)}))}}function species_wizard_classCallCheck(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}function species_wizard_defineProperties(t,r){for(var a=0;a1)){u.next=9;break}return u.t0=o[0].trim(),u.next=5,i.parseToItem(o[1].trim(),r);case 5:u.t1=u.sent,c={name:u.t0,res:u.t1},u.next=13;break;case 9:return u.next=11,i.parseToItem(t,r);case 11:u.t2=u.sent,c={name:"",res:u.t2};case 13:return i.fixPreviousCosts(a,c.res),u.abrupt("return",c);case 15:case"end":return u.stop()}}),_callee)})));return function(r){return t.apply(this,arguments)}}()));case 2:return o=c.sent,c.abrupt("return",o);case 4:case"end":return c.stop()}}),_callee2)}))),function _toGroups(t,r,a){return c.apply(this,arguments)})},{key:"getData",value:(i=species_wizard_asyncToGenerator(species_wizard_regeneratorRuntime().mark((function _callee3(t){var r,a,o,i,c,u,l,p;return species_wizard_regeneratorRuntime().wrap((function _callee3$(d){for(;;)switch(d.prev=d.next){case 0:return d.next=2,species_wizard_get(species_wizard_getPrototypeOf(SpeciesWizard.prototype),"getData",this).call(this,t);case 2:return r=d.sent,d.next=5,this.parseToItem(this.species.system.requirements.value,["disadvantage","advantage"]);case 5:return a=d.sent,o=a.filter((function(t){return["advantage","disadvantage"].includes(t.type)&&!t.disabled})),d.next=9,this._toGroups(this.species.system.recommendedAdvantages.value,["advantage"],a);case 9:return i=d.sent,d.next=12,this._toGroups(this.species.system.recommendedDisadvantages.value,["disadvantage"],a);case 12:return c=d.sent,u=this._parseAttributes(this.species.system.attributeChange.value),l=Number(this.species.system.APValue.value),p=a.reduce((function(t,r){return t+(r.disabled?0:Number(r.system.APValue.value)||0)}),0),mergeObject(r,{title:game.i18n.format("WIZARD.addItem",{item:"".concat(game.i18n.localize("TYPES.Item.species")," ").concat(this.species.name)}),species:this.species,description:game.i18n.format("WIZARD.speciesdescr",{species:this.species.name,cost:l+p}),advantagegroups:i,baseCost:l,disadvantagegroups:c,missingVantages:o,attributeRequirements:u,hasLocalization:game.i18n.has("Racedescr.".concat(this.species.name)),anyAttributeRequirements:u.length>0,advantagesToChose:i.length>0,missingVantagesToChose:o.length>0,disadvantagesToChose:c.length>0,vantagesToChose:i.length>0||c.length>0||o.length>0,generalToChose:u.length>0}),d.abrupt("return",r);case 18:case"end":return d.stop()}}),_callee3,this)}))),function getData(t){return i.apply(this,arguments)})},{key:"addSpecies",value:(o=species_wizard_asyncToGenerator(species_wizard_regeneratorRuntime().mark((function _callee4(t,r){return species_wizard_regeneratorRuntime().wrap((function _callee4$(a){for(;;)switch(a.prev=a.next){case 0:this.actor=t,this.species=duplicate(r);case 2:case"end":return a.stop()}}),_callee4,this)}))),function addSpecies(t,r){return o.apply(this,arguments)})},{key:"updateCharacter",value:(a=species_wizard_asyncToGenerator(species_wizard_regeneratorRuntime().mark((function _callee5(t){var a,o,i,c,u,l,p,d,h,m,y,g,v=arguments;return species_wizard_regeneratorRuntime().wrap((function _callee5$(_){for(;;)switch(_.prev=_.next){case 0:if(a=v.length>1&&void 0!==v[1]?v[1]:this,t.find("button.ok i").toggleClass("fa-check fa-spinner fa-spin"),o=Number(t.find(".apCost").text()),_.t1=!this._validateInput(t,a),_.t1){_.next=8;break}return _.next=7,this.actor.checkEnoughXP(o);case 7:_.t1=!_.sent;case 8:if(_.t0=_.t1,_.t0){_.next=13;break}return _.next=12,this.alreadyAdded(this.actor.system.details.species.value,"species");case 12:_.t0=_.sent;case 13:if(!_.t0){_.next=16;break}return t.find("button.ok i").toggleClass("fa-check fa-spinner fa-spin"),_.abrupt("return");case 16:i={"system.details.species.value":this.species.name,"system.status.speed.initial":this.species.system.baseValues.speed.value,"system.status.soulpower.initial":this.species.system.baseValues.soulpower.value,"system.status.toughness.initial":this.species.system.baseValues.toughness.value,"system.status.wounds.initial":this.species.system.baseValues.wounds.value,"system.status.wounds.value":this.species.system.baseValues.wounds.value+2*this.actor.system.characteristics.ko.value},c=[],u=species_wizard_createForOfIteratorHelper(t.find(".exclusive:checked"));try{for(u.s();!(l=u.n()).done;)p=l.value,c.push($(p).val())}catch(t){u.e(t)}finally{u.f()}Object.keys(r.Z.characteristics).forEach((function(t){i["system.characteristics.".concat(t,".species")]=0})),d=species_wizard_createForOfIteratorHelper(this.species.system.attributeChange.value.split(",").concat(c)),_.prev=22,d.s();case 24:if((h=d.n()).done){_.next=34;break}if(!(m=h.value).includes(game.i18n.localize("combatskillcountdivider")+":")&&""!=m){_.next=28;break}return _.abrupt("continue",32);case 28:y=m.trim().split(" "),(g=game.dsa5.config.knownShortcuts[y[0].toLowerCase().trim()].slice(0))[g.length-1]="species",i["system.".concat(g.join("."))]=Number(y[1]);case 32:_.next=24;break;case 34:_.next=39;break;case 36:_.prev=36,_.t2=_.catch(22),d.e(_.t2);case 39:return _.prev=39,d.f(),_.finish(39);case 42:return _.next=44,this.actor._updateAPs(o,{},{render:!1});case 44:return _.next=46,this.addSelections(t.find(".optional:checked"),!1);case 46:return _.next=48,this.actor.update(i);case 48:return _.next=50,this.actor.removeCondition("incapacitated");case 50:this.finalizeUpdate();case 51:case"end":return _.stop()}}),_callee5,this,[[22,36,39,42]])}))),function updateCharacter(t){return a.apply(this,arguments)})}],[{key:"defaultOptions",get:function get(){var t=species_wizard_get(species_wizard_getPrototypeOf(SpeciesWizard),"defaultOptions",this);return t.title=game.i18n.format("WIZARD.addItem",{item:"".concat(game.i18n.localize("TYPES.Item.species"))}),t.template="systems/dsa5/templates/wizard/add-species-wizard.html",t}}]),SpeciesWizard}(P);function character_sheet_typeof(t){return character_sheet_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},character_sheet_typeof(t)}function character_sheet_regeneratorRuntime(){character_sheet_regeneratorRuntime=function _regeneratorRuntime(){return t};var t={},r=Object.prototype,a=r.hasOwnProperty,o="function"==typeof Symbol?Symbol:{},i=o.iterator||"@@iterator",c=o.asyncIterator||"@@asyncIterator",u=o.toStringTag||"@@toStringTag";function define(t,r,a){return Object.defineProperty(t,r,{value:a,enumerable:!0,configurable:!0,writable:!0}),t[r]}try{define({},"")}catch(t){define=function define(t,r,a){return t[r]=a}}function wrap(t,r,a,o){var i=r&&r.prototype instanceof Generator?r:Generator,c=Object.create(i.prototype),u=new Context(o||[]);return c._invoke=function(t,r,a){var o="suspendedStart";return function(i,c){if("executing"===o)throw new Error("Generator is already running");if("completed"===o){if("throw"===i)throw c;return doneResult()}for(a.method=i,a.arg=c;;){var u=a.delegate;if(u){var p=maybeInvokeDelegate(u,a);if(p){if(p===l)continue;return p}}if("next"===a.method)a.sent=a._sent=a.arg;else if("throw"===a.method){if("suspendedStart"===o)throw o="completed",a.arg;a.dispatchException(a.arg)}else"return"===a.method&&a.abrupt("return",a.arg);o="executing";var d=tryCatch(t,r,a);if("normal"===d.type){if(o=a.done?"completed":"suspendedYield",d.arg===l)continue;return{value:d.arg,done:a.done}}"throw"===d.type&&(o="completed",a.method="throw",a.arg=d.arg)}}}(t,a,u),c}function tryCatch(t,r,a){try{return{type:"normal",arg:t.call(r,a)}}catch(t){return{type:"throw",arg:t}}}t.wrap=wrap;var l={};function Generator(){}function GeneratorFunction(){}function GeneratorFunctionPrototype(){}var p={};define(p,i,(function(){return this}));var d=Object.getPrototypeOf,h=d&&d(d(values([])));h&&h!==r&&a.call(h,i)&&(p=h);var m=GeneratorFunctionPrototype.prototype=Generator.prototype=Object.create(p);function defineIteratorMethods(t){["next","throw","return"].forEach((function(r){define(t,r,(function(t){return this._invoke(r,t)}))}))}function AsyncIterator(t,r){function invoke(o,i,c,u){var l=tryCatch(t[o],t,i);if("throw"!==l.type){var p=l.arg,d=p.value;return d&&"object"==character_sheet_typeof(d)&&a.call(d,"__await")?r.resolve(d.__await).then((function(t){invoke("next",t,c,u)}),(function(t){invoke("throw",t,c,u)})):r.resolve(d).then((function(t){p.value=t,c(p)}),(function(t){return invoke("throw",t,c,u)}))}u(l.arg)}var o;this._invoke=function(t,a){function callInvokeWithMethodAndArg(){return new r((function(r,o){invoke(t,a,r,o)}))}return o=o?o.then(callInvokeWithMethodAndArg,callInvokeWithMethodAndArg):callInvokeWithMethodAndArg()}}function maybeInvokeDelegate(t,r){var a=t.iterator[r.method];if(void 0===a){if(r.delegate=null,"throw"===r.method){if(t.iterator.return&&(r.method="return",r.arg=void 0,maybeInvokeDelegate(t,r),"throw"===r.method))return l;r.method="throw",r.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var o=tryCatch(a,t.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,l;var i=o.arg;return i?i.done?(r[t.resultName]=i.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=void 0),r.delegate=null,l):i:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,l)}function pushTryEntry(t){var r={tryLoc:t[0]};1 in t&&(r.catchLoc=t[1]),2 in t&&(r.finallyLoc=t[2],r.afterLoc=t[3]),this.tryEntries.push(r)}function resetTryEntry(t){var r=t.completion||{};r.type="normal",delete r.arg,t.completion=r}function Context(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(pushTryEntry,this),this.reset(!0)}function values(t){if(t){var r=t[i];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var o=-1,c=function next(){for(;++o=0;--o){var i=this.tryEntries[o],c=i.completion;if("root"===i.tryLoc)return handle("end");if(i.tryLoc<=this.prev){var u=a.call(i,"catchLoc"),l=a.call(i,"finallyLoc");if(u&&l){if(this.prev=0;--o){var i=this.tryEntries[o];if(i.tryLoc<=this.prev&&a.call(i,"finallyLoc")&&this.prev=0;--r){var a=this.tryEntries[r];if(a.finallyLoc===t)return this.complete(a.completion,a.afterLoc),resetTryEntry(a),l}},catch:function _catch(t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc===t){var o=a.completion;if("throw"===o.type){var i=o.arg;resetTryEntry(a)}return i}}throw new Error("illegal catch attempt")},delegateYield:function delegateYield(t,r,a){return this.delegate={iterator:values(t),resultName:r,nextLoc:a},"next"===this.method&&(this.arg=void 0),l}},t}function character_sheet_asyncGeneratorStep(t,r,a,o,i,c,u){try{var l=t[c](u),p=l.value}catch(t){return void a(t)}l.done?r(p):Promise.resolve(p).then(o,i)}function character_sheet_classCallCheck(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}function character_sheet_defineProperties(t,r){for(var a=0;a=0;--o){var i=this.tryEntries[o],c=i.completion;if("root"===i.tryLoc)return handle("end");if(i.tryLoc<=this.prev){var u=a.call(i,"catchLoc"),l=a.call(i,"finallyLoc");if(u&&l){if(this.prev=0;--o){var i=this.tryEntries[o];if(i.tryLoc<=this.prev&&a.call(i,"finallyLoc")&&this.prev=0;--r){var a=this.tryEntries[r];if(a.finallyLoc===t)return this.complete(a.completion,a.afterLoc),resetTryEntry(a),l}},catch:function _catch(t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc===t){var o=a.completion;if("throw"===o.type){var i=o.arg;resetTryEntry(a)}return i}}throw new Error("illegal catch attempt")},delegateYield:function delegateYield(t,r,a){return this.delegate={iterator:values(t),resultName:r,nextLoc:a},"next"===this.method&&(this.arg=void 0),l}},t}function creature_sheet_asyncGeneratorStep(t,r,a,o,i,c,u){try{var l=t[c](u),p=l.value}catch(t){return void a(t)}l.done?r(p):Promise.resolve(p).then(o,i)}function creature_sheet_asyncToGenerator(t){return function(){var r=this,a=arguments;return new Promise((function(o,i){var c=t.apply(r,a);function _next(t){creature_sheet_asyncGeneratorStep(c,o,i,_next,_throw,"next",t)}function _throw(t){creature_sheet_asyncGeneratorStep(c,o,i,_next,_throw,"throw",t)}_next(void 0)}))}}function creature_sheet_classCallCheck(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}function creature_sheet_defineProperties(t,r){for(var a=0;a=0;--o){var i=this.tryEntries[o],c=i.completion;if("root"===i.tryLoc)return handle("end");if(i.tryLoc<=this.prev){var u=a.call(i,"catchLoc"),l=a.call(i,"finallyLoc");if(u&&l){if(this.prev=0;--o){var i=this.tryEntries[o];if(i.tryLoc<=this.prev&&a.call(i,"finallyLoc")&&this.prev=0;--r){var a=this.tryEntries[r];if(a.finallyLoc===t)return this.complete(a.completion,a.afterLoc),resetTryEntry(a),l}},catch:function _catch(t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc===t){var o=a.completion;if("throw"===o.type){var i=o.arg;resetTryEntry(a)}return i}}throw new Error("illegal catch attempt")},delegateYield:function delegateYield(t,r,a){return this.delegate={iterator:values(t),resultName:r,nextLoc:a},"next"===this.method&&(this.arg=void 0),l}},t}function obfuscatemixin_asyncGeneratorStep(t,r,a,o,i,c,u){try{var l=t[c](u),p=l.value}catch(t){return void a(t)}l.done?r(p):Promise.resolve(p).then(o,i)}function obfuscatemixin_asyncToGenerator(t){return function(){var r=this,a=arguments;return new Promise((function(o,i){var c=t.apply(r,a);function _next(t){obfuscatemixin_asyncGeneratorStep(c,o,i,_next,_throw,"next",t)}function _throw(t){obfuscatemixin_asyncGeneratorStep(c,o,i,_next,_throw,"throw",t)}_next(void 0)}))}}function obfuscatemixin_classCallCheck(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}function obfuscatemixin_defineProperties(t,r){for(var a=0;a0&&void 0!==v[0]&&v[0],r=v.length>1&&void 0!==v[1]?v[1]:{},_.next=4,obfuscatemixin_get(obfuscatemixin_getPrototypeOf(_class.prototype),"_render",this).call(this,t,r);case 4:a=!1,o=0,i=["details","effects","description","enchantment"];case 7:if(!(o'),h.length?h.replaceWith(m):u.append(" ".concat(m))):l&&(u.hasClass("active")&&(a=!0),u.remove(),"details"==c&&$(this._element).find('[name="system.price.value"],[name="system.price.raw"]').replaceWith(""));case 15:o++,_.next=7;break;case 18:if(!a){_.next=28;break}if(!(y=$(this._element).find("nav .item:first-child")).length){_.next=24;break}this.activateTab(y.attr("data-tab")),_.next=28;break;case 24:return _.next=26,renderTemplate("systems/dsa5/templates/items/obfuscatedItem.html",{item:this.item});case 26:g=_.sent,$(this._element).find(".content").html(g);case 28:case"end":return _.stop()}}),_callee2,this)}))),function _render(){return r.apply(this,arguments)})}]),_class}(t)},N=__webpack_require__(600);function item_sheet_typeof(t){return item_sheet_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},item_sheet_typeof(t)}function item_sheet_defineProperty(t,r,a){return r in t?Object.defineProperty(t,r,{value:a,enumerable:!0,configurable:!0,writable:!0}):t[r]=a,t}function item_sheet_createForOfIteratorHelper(t,r){var a="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!a){if(Array.isArray(t)||(a=function item_sheet_unsupportedIterableToArray(t,r){if(!t)return;if("string"==typeof t)return item_sheet_arrayLikeToArray(t,r);var a=Object.prototype.toString.call(t).slice(8,-1);"Object"===a&&t.constructor&&(a=t.constructor.name);if("Map"===a||"Set"===a)return Array.from(t);if("Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a))return item_sheet_arrayLikeToArray(t,r)}(t))||r&&t&&"number"==typeof t.length){a&&(t=a);var o=0,i=function F(){};return{s:i,n:function n(){return o>=t.length?{done:!0}:{done:!1,value:t[o++]}},e:function e(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var c,u=!0,l=!1;return{s:function s(){a=a.call(t)},n:function n(){var t=a.next();return u=t.done,t},e:function e(t){l=!0,c=t},f:function f(){try{u||null==a.return||a.return()}finally{if(l)throw c}}}}function item_sheet_arrayLikeToArray(t,r){(null==r||r>t.length)&&(r=t.length);for(var a=0,o=new Array(r);a=0;--o){var i=this.tryEntries[o],c=i.completion;if("root"===i.tryLoc)return handle("end");if(i.tryLoc<=this.prev){var u=a.call(i,"catchLoc"),l=a.call(i,"finallyLoc");if(u&&l){if(this.prev=0;--o){var i=this.tryEntries[o];if(i.tryLoc<=this.prev&&a.call(i,"finallyLoc")&&this.prev=0;--r){var a=this.tryEntries[r];if(a.finallyLoc===t)return this.complete(a.completion,a.afterLoc),resetTryEntry(a),l}},catch:function _catch(t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc===t){var o=a.completion;if("throw"===o.type){var i=o.arg;resetTryEntry(a)}return i}}throw new Error("illegal catch attempt")},delegateYield:function delegateYield(t,r,a){return this.delegate={iterator:values(t),resultName:r,nextLoc:a},"next"===this.method&&(this.arg=void 0),l}},t}function item_sheet_asyncGeneratorStep(t,r,a,o,i,c,u){try{var l=t[c](u),p=l.value}catch(t){return void a(t)}l.done?r(p):Promise.resolve(p).then(o,i)}function item_sheet_asyncToGenerator(t){return function(){var r=this,a=arguments;return new Promise((function(o,i){var c=t.apply(r,a);function _next(t){item_sheet_asyncGeneratorStep(c,o,i,_next,_throw,"next",t)}function _throw(t){item_sheet_asyncGeneratorStep(c,o,i,_next,_throw,"throw",t)}_next(void 0)}))}}function item_sheet_classCallCheck(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}function item_sheet_defineProperties(t,r){for(var a=0;a0&&void 0!==arguments[0]?arguments[0]:{},r=item_sheet_get(item_sheet_getPrototypeOf(ItemSheetdsa5.prototype),"_getSubmitData",this).call(this,t),a=foundry.utils.flattenObject(this.item.overrides||{});return Object.keys(a).forEach((function(t){return delete r[t]})),r}},{key:"_render",value:(c=item_sheet_asyncToGenerator(item_sheet_regeneratorRuntime().mark((function _callee(){var t,r,a=arguments;return item_sheet_regeneratorRuntime().wrap((function _callee$(o){for(;;)switch(o.prev=o.next){case 0:return t=a.length>0&&void 0!==a[0]&&a[0],r=a.length>1&&void 0!==a[1]?a[1]:{},o.next=4,item_sheet_get(item_sheet_getPrototypeOf(ItemSheetdsa5.prototype),"_render",this).call(this,t,r);case 4:$(this._element).find(".close").attr("data-tooltip","SHEET.Close"),$(this._element).find(".configure-sheet").attr("data-tooltip","SHEET.Configure"),$(this._element).find(".import").attr("data-tooltip","SHEET.Import"),$(this._element).find(".rolleffect").attr("data-tooltip","SHEET.RollEffect"),$(this._element).find(".showItemHead").attr("data-tooltip","SHEET.PostItem"),$(this._element).find(".consumeItem").attr("data-tooltip","SHEET.ConsumeItem"),$(this._element).find(".rollDamaged").attr("data-tooltip","DSASETTINGS.armorAndWeaponDamage"),$(this._element).find(".onUseEffect").attr("data-tooltip","SHEET.onUseEffect");case 12:case"end":return o.stop()}}),_callee,this)}))),function _render(){return c.apply(this,arguments)})},{key:"_getHeaderButtons",value:function _getHeaderButtons(){var t,r,a=this,o=item_sheet_get(item_sheet_getPrototypeOf(ItemSheetdsa5.prototype),"_getHeaderButtons",this).call(this);return o.unshift({class:"showItemHead",icon:"fas fa-comment",onclick:(t=item_sheet_asyncToGenerator(item_sheet_regeneratorRuntime().mark((function _callee2(){return item_sheet_regeneratorRuntime().wrap((function _callee2$(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",a.item.postItem());case 1:case"end":return t.stop()}}),_callee2)}))),function onclick(){return t.apply(this,arguments)})}),this.item.actor&&g.Z.getOnUseEffect(this.item)&&o.unshift({class:"onUseEffect",icon:"fas fa-dice-six",onclick:(r=item_sheet_asyncToGenerator(item_sheet_regeneratorRuntime().mark((function _callee3(){return item_sheet_regeneratorRuntime().wrap((function _callee3$(t){for(;;)switch(t.prev=t.next){case 0:new g.Z(a.item).executeOnUseEffect();case 2:case"end":return t.stop()}}),_callee3)}))),function onclick(){return r.apply(this,arguments)})}),o}},{key:"setupEffect",value:function setupEffect(t){var r=this;this.item.setupEffect().then((function(t){return r.item.itemTest(t)}))}},{key:"template",get:function get(){return"systems/dsa5/templates/items/item-".concat(this.item.type,"-sheet.html")}},{key:"_getItemId",value:function _getItemId(t){return $(t.currentTarget).parents(".item").attr("data-item-id")}},{key:"_advanceStep",value:function _advanceStep(){}},{key:"_refundStep",value:function _refundStep(){}},{key:"advanceWrapper",value:(i=item_sheet_asyncToGenerator(item_sheet_regeneratorRuntime().mark((function _callee4(t,r){var a,o;return item_sheet_regeneratorRuntime().wrap((function _callee4$(i){for(;;)switch(i.prev=i.next){case 0:if(a=$(t.currentTarget),(o=a.find("i")).hasClass("fa-spin")){i.next=7;break}return o.addClass("fa-spin fa-spinner"),i.next=6,this[r]();case 6:o.removeClass("fa-spin fa-spinner");case 7:case"end":return i.stop()}}),_callee4,this)}))),function advanceWrapper(t,r){return i.apply(this,arguments)})},{key:"activateListeners",value:function activateListeners(r){var a=this;item_sheet_get(item_sheet_getPrototypeOf(ItemSheetdsa5.prototype),"activateListeners",this).call(this,r),(0,h.Ee)(r),r.find(".advance-step").mousedown((function(t){return a.advanceWrapper(t,"_advanceStep")})),r.find(".refund-step").mousedown((function(t){return a.advanceWrapper(t,"_refundStep")})),r.find(".domainsPretty").click((function(t){$(t.currentTarget).hide(),$(t.currentTarget).next(".domainToggle").show()})),r.find('[data-edit="img"]').mousedown((function(r){2==r.button&&t.Z.showArtwork(a.item)})),r.find(".status-add").click((function(){u.Z.createCustomEffect(a.item,"",a.item.name)})),r.find(".condition-show").mousedown((function(t){t.preventDefault();var r=t.currentTarget.dataset.id;0==t.button?a.item.effects.get(r).sheet.render(!0):2==t.button&&a.item.deleteEmbeddedDocuments("ActiveEffect",[r])})),r.find(".select2").select2(),r.find(".condition-toggle").mousedown((function(t){var r=$(t.currentTarget).parents(".statusEffect").attr("data-id"),o=a.item.effects.get(r);o.update({disabled:!o.disabled})})),r.find(".condition-edit").click((function(t){a.item.effects.get(t.currentTarget.dataset.id).sheet.render(!0)})),_.Z.bindRollCommands(r),u.Z.bindButtons(r);var o=r.find(".item-header");if(o.length){var i=o.find("svg");if(i){new ResizeObserver((function(t){var r=t[0];(0,h.zJ)(i,r.contentRect.width)})).observe(o.get(0));var c=o.find("input");c.get(0).disabled||(i.click((function(){i.hide(),c.show(),c.focus()})),c.blur((function(){i.show(),c.hide()})))}}}},{key:"getData",value:(o=item_sheet_asyncToGenerator(item_sheet_regeneratorRuntime().mark((function _callee5(a){var o,i;return item_sheet_regeneratorRuntime().wrap((function _callee5$(c){for(;;)switch(c.prev=c.next){case 0:o=item_sheet_get(item_sheet_getPrototypeOf(ItemSheetdsa5.prototype),"getData",this).call(this,a).data,c.t0=this.item.type,c.next="skill"===c.t0?4:"application"===c.t0?10:"combatskill"===c.t0?16:"trait"===c.t0?21:24;break;case 4:return o.characteristics=r.Z.characteristics,o.skillGroups=r.Z.skillGroups,o.skillBurdens=r.Z.skillBurdens,o.hasLocalization=game.i18n.has("SKILLdescr.".concat(this.item.name)),o.StFs=r.Z.StFs,c.abrupt("break",24);case 10:return o.hasLocalization=game.i18n.has("APPLICATION.".concat(this.item.system.skill," - ").concat(this.item.name)),o.localization=game.i18n.localize("APPLICATION.".concat(this.item.system.skill," - ").concat(this.item.name)),c.next=14,t.Z.allSkillsList();case 14:return o.allSkills=c.sent,c.abrupt("break",24);case 16:return o.weapontypes=r.Z.weapontypes,o.guidevalues=r.Z.combatskillsGuidevalues,o.hasLocalization=game.i18n.has("Combatskilldescr.".concat(this.item.name)),o.StFs=r.Z.StFs,c.abrupt("break",24);case 21:return o.traitCategories=r.Z.traitCategories,o.ranges=r.Z.meleeRanges,c.abrupt("break",24);case 24:return o.isOwned=this.item.actor,o.editable=this.isEditable,o.isOwned&&(o.canAdvance=this.item.actor.canAdvance&&this._advancable(),i=getProperty(this.item,"flags.dsa5.customPriceTag"),!this.isEditable&&i&&(o.customPrice=i)),u.Z.prepareActiveEffects(this.item,o),o.item=this.item,o.armorAndWeaponDamage=game.settings.get("dsa5","armorAndWeaponDamage"),o.isGM=game.user.isGM,c.next=33,TextEditor.enrichHTML(getProperty(this.item.system,"description.value"),{secrets:this.object.isOwner,async:!0});case 33:return o.enrichedDescription=c.sent,c.next=36,TextEditor.enrichHTML(getProperty(this.item.system,"gmdescription.value"),{secrets:this.object.isOwner,async:!0});case 36:return o.enrichedGmdescription=c.sent,c.abrupt("return",o);case 38:case"end":return c.stop()}}),_callee5,this)}))),function getData(t){return o.apply(this,arguments)})},{key:"_advancable",value:function _advancable(){return!1}}],[{key:"defaultOptions",get:function get(){var t=item_sheet_get(item_sheet_getPrototypeOf(ItemSheetdsa5),"defaultOptions",this);return mergeObject(t,{tabs:[{navSelector:".tabs",contentSelector:".content"}],classes:t.classes.concat(["dsa5","item"]),width:471,height:500}),t}},{key:"setupSheets",value:function setupSheets(){Items.unregisterSheet("core",ItemSheet),Items.registerSheet("dsa5",ItemSheetdsa5,{makeDefault:!0}),Items.registerSheet("dsa5",se,{makeDefault:!0,types:["species"]}),Items.registerSheet("dsa5",ee,{makeDefault:!0,types:["career"]}),Items.registerSheet("dsa5",re,{makeDefault:!0,types:["culture"]}),Items.registerSheet("dsa5",fe,{makeDefault:!0,types:["advantage","disadvantage"]}),Items.registerSheet("dsa5",ue,{makeDefault:!0,types:["ritual","ceremony","liturgy","spell"]}),Items.registerSheet("dsa5",ce,{makeDefault:!0,types:["specialability"]}),Items.registerSheet("dsa5",oe,{makeDefault:!0,types:["meleeweapon"]}),Items.registerSheet("dsa5",ie,{makeDefault:!0,types:["poison"]}),Items.registerSheet("dsa5",ne,{makeDefault:!0,types:["disease"]}),Items.registerSheet("dsa5",te,{makeDefault:!0,types:["consumable"]}),Items.registerSheet("dsa5",le,{makeDefault:!0,types:["spellextension"]}),Items.registerSheet("dsa5",ae,{makeDefault:!0,types:["magictrick"]}),Items.registerSheet("dsa5",X,{makeDefault:!0,types:["blessing"]}),Items.registerSheet("dsa5",Q,{makeDefault:!0,types:["rangeweapon"]}),Items.registerSheet("dsa5",U,{makeDefault:!0,types:["equipment"]}),Items.registerSheet("dsa5",Y,{makeDefault:!0,types:["armor"]}),Items.registerSheet("dsa5",q,{makeDefault:!0,types:["ammunition"]}),Items.registerSheet("dsa5",V,{makeDefault:!0,types:["plant"]}),Items.registerSheet("dsa5",J,{makeDefault:!0,types:["magicalsign"]}),Items.registerSheet("dsa5",K,{makeDefault:!0,types:["patron"]}),Items.registerSheet("dsa5",B,{makeDefault:!0,types:["information"]}),Items.registerSheet("dsa5",Z,{makeDefault:!0,types:["aggregatedTest"]}),Items.unregisterSheet("dsa5",ItemSheetdsa5,{types:["armor","equipment","rangeweapon","blessing","magictrick","spellextension","consumable","aggregatedTest","species","career","culture","advantage","specialability","disadvantage","ritual","information","ceremony","liturgy","spell","disease","poison","meleeweapon","ammunition","plant","magicalsign","patron"]})}}]),ItemSheetdsa5}(),Z=function(r){item_sheet_inherits(AggregatedTestSheet,r);var a,o,i=item_sheet_createSuper(AggregatedTestSheet);function AggregatedTestSheet(){return item_sheet_classCallCheck(this,AggregatedTestSheet),i.apply(this,arguments)}return item_sheet_createClass(AggregatedTestSheet,[{key:"getData",value:(o=item_sheet_asyncToGenerator(item_sheet_regeneratorRuntime().mark((function _callee6(r){var a,o,i;return item_sheet_regeneratorRuntime().wrap((function _callee6$(c){for(;;)switch(c.prev=c.next){case 0:return c.next=2,item_sheet_get(item_sheet_getPrototypeOf(AggregatedTestSheet.prototype),"getData",this).call(this,r);case 2:if(a=c.sent,!(o=this.item.getFlag("dsa5","embeddedItem"))){c.next=8;break}return c.next=7,renderTemplate("systems/dsa5/templates/items/browse/".concat(o.type,".html"),{document:o});case 7:i=c.sent;case 8:return c.t0=mergeObject,c.t1=a,c.next=12,t.Z.allSkillsList();case 12:return c.t2=c.sent,c.t3=o,c.t4=i,c.t5={allSkills:c.t2,embeddedItem:c.t3,renderedItem:c.t4},(0,c.t0)(c.t1,c.t5),c.abrupt("return",a);case 18:case"end":return c.stop()}}),_callee6,this)}))),function getData(t){return o.apply(this,arguments)})},{key:"activateListeners",value:function activateListeners(t){var r=this;item_sheet_get(item_sheet_getPrototypeOf(AggregatedTestSheet.prototype),"activateListeners",this).call(this,t),t.find(".buildItem").click(item_sheet_asyncToGenerator(item_sheet_regeneratorRuntime().mark((function _callee7(){return item_sheet_regeneratorRuntime().wrap((function _callee7$(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",r.postFinishedItem());case 1:case"end":return t.stop()}}),_callee7)}))))}},{key:"postFinishedItem",value:(a=item_sheet_asyncToGenerator(item_sheet_regeneratorRuntime().mark((function _callee8(){var r,a,o;return item_sheet_regeneratorRuntime().wrap((function _callee8$(i){for(;;)switch(i.prev=i.next){case 0:if(this.item.actor){i.next=2;break}return i.abrupt("return");case 2:if(r=this.item.getFlag("dsa5","embeddedItem")){i.next=5;break}return i.abrupt("return");case 5:return i.next=7,renderTemplate("systems/dsa5/templates/chat/production-result.html",{actor:this.item.actor,item:r,actorImg:N.Z.videoOrImgTag(this.item.actor.img)});case 7:return a=i.sent,(o=t.Z.chatDataSetup(a)).flags={dsa5:{embeddedItem:r}},i.next=12,ChatMessage.create(o);case 12:case"end":return i.stop()}}),_callee8,this)}))),function postFinishedItem(){return a.apply(this,arguments)})}]),AggregatedTestSheet}(H),W=function(a){item_sheet_inherits(Enchantable,a);var o,i,c,u,l,p,d=item_sheet_createSuper(Enchantable);function Enchantable(){return item_sheet_classCallCheck(this,Enchantable),d.apply(this,arguments)}return item_sheet_createClass(Enchantable,[{key:"_onDrop",value:(p=item_sheet_asyncToGenerator(item_sheet_regeneratorRuntime().mark((function _callee9(t){return item_sheet_regeneratorRuntime().wrap((function _callee9$(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,this.enchant(t);case 2:if(!this.isPoisonable){r.next=5;break}return r.next=5,this.poison(t);case 5:case"end":return r.stop()}}),_callee9,this)}))),function _onDrop(t){return p.apply(this,arguments)})},{key:"enchant",value:(l=item_sheet_asyncToGenerator(item_sheet_regeneratorRuntime().mark((function _callee10(t){var r;return item_sheet_regeneratorRuntime().wrap((function _callee10$(a){for(;;)switch(a.prev=a.next){case 0:return r=JSON.parse(t.dataTransfer.getData("text/plain")),a.next=3,this._enchant([r]);case 3:case"end":return a.stop()}}),_callee10,this)}))),function enchant(t){return l.apply(this,arguments)})},{key:"_enchant",value:(u=item_sheet_asyncToGenerator(item_sheet_regeneratorRuntime().mark((function _callee11(t){var r,a,o,i,c,u,l,p,d;return item_sheet_regeneratorRuntime().wrap((function _callee11$(m){for(;;)switch(m.prev=m.next){case 0:if(!((r=this.item.getFlag("dsa5","enchantments")||[]).length+t.length>7)){m.next=3;break}return m.abrupt("return",ui.notifications.error(game.i18n.localize("DSAError.tooManyEnchants")));case 3:a=item_sheet_createForOfIteratorHelper(t),m.prev=4,a.s();case 6:if((o=a.n()).done){m.next=21;break}return i=o.value,m.next=10,(0,h.x8)(i,void 0,!1);case 10:if(c=m.sent,u=c.item,l=c.typeClass,c.selfTarget,!["spell","liturgy","ceremony","ritual"].includes(l)){m.next=19;break}if(u.pack){m.next=17;break}return m.abrupt("return",ui.notifications.error(game.i18n.localize("DSAError.onlyCompendiumSpells")));case 17:p={name:u.name,pack:u.pack,id:r.length,itemId:u.id,permanent:["liturgy","ceremony"].includes(l)||i.permanent,actorId:i.actorId,charged:!0,talisman:["liturgy","ceremony"].includes(l),fw:["liturgy","ceremony"].includes(l)?18:i.fw||0},r.push(p);case 19:m.next=6;break;case 21:m.next=26;break;case 23:m.prev=23,m.t0=m.catch(4),a.e(m.t0);case 26:return m.prev=26,a.f(),m.finish(26);case 29:if(!r.length){m.next=33;break}return d={flags:{dsa5:{enchantments:r}}},m.next=33,this.item.update(d);case 33:case"end":return m.stop()}}),_callee11,this,[[4,23,26,29]])}))),function _enchant(t){return u.apply(this,arguments)})},{key:"poison",value:(c=item_sheet_asyncToGenerator(item_sheet_regeneratorRuntime().mark((function _callee12(t){var r,a,o,i,c,u;return item_sheet_regeneratorRuntime().wrap((function _callee12$(l){for(;;)switch(l.prev=l.next){case 0:return r=JSON.parse(t.dataTransfer.getData("text/plain")),l.next=3,(0,h.x8)(r,void 0,!1);case 3:if(a=l.sent,o=a.item,i=a.typeClass,a.selfTarget,"poison"!=i){l.next=12;break}return c={name:o.name,pack:o.pack,itemId:o._id,permanent:!1,actorId:r.actorId},u={flags:{dsa5:{poison:c}}},l.next=12,this.item.update(u);case 12:case"end":return l.stop()}}),_callee12,this)}))),function poison(t){return c.apply(this,arguments)})},{key:"toggleChargedState",value:function toggleChargedState(t,r){var a,o=item_sheet_createForOfIteratorHelper(r);try{for(o.s();!(a=o.n()).done;){var i=a.value;if(i.id==t){i.charged=!(!i.talisman||!i.permanent)||!i.charged;break}}}catch(t){o.e(t)}finally{o.f()}this.item.update({flags:{dsa5:{enchantments:r}}})}},{key:"activateListeners",value:function activateListeners(r){var a=this;item_sheet_get(item_sheet_getPrototypeOf(Enchantable.prototype),"activateListeners",this).call(this,r),r.find(".ench-toggle-permanent").click((function(t){var r,o=a.enchantMentId(t),i=o.id,c=o.enchantments,u=item_sheet_createForOfIteratorHelper(c);try{for(u.s();!(r=u.n()).done;){var l=r.value;if(l.id==i){l.permanent=!l.permanent;break}}}catch(t){u.e(t)}finally{u.f()}a.item.update({flags:{dsa5:{enchantments:c}}})})),r.find(".ench-toggle-charge").click((function(t){var r=a.enchantMentId(t),o=r.id,i=r.enchantments;a.toggleChargedState(o,i)})),r.find(".ench-roll").click(function(){var r=item_sheet_asyncToGenerator(item_sheet_regeneratorRuntime().mark((function _callee14(r){var o,i,c,u,l,p;return item_sheet_regeneratorRuntime().wrap((function _callee14$(d){for(;;)switch(d.prev=d.next){case 0:if(o=a.enchantMentId(r),i=o.id,c=o.enchantments,(u=c.find((function(t){return t.id==i}))).charged){d.next=4;break}return d.abrupt("return",ui.notifications.error(game.i18n.localize("DSAError.NotEnoughCharges")));case 4:return d.next=6,a.getSpell(u);case 6:if(!(l=d.sent)){d.next=14;break}return(l=l.toObject()).system.talentValue.value=u.fw,d.next=12,t.Z.emptyActor(14,a.item.name);case 12:(p=d.sent).setupSpell(l,{},"emptyActor").then(function(){var r=item_sheet_asyncToGenerator(item_sheet_regeneratorRuntime().mark((function _callee13(r){var o;return item_sheet_regeneratorRuntime().wrap((function _callee13$(d){for(;;)switch(d.prev=d.next){case 0:return o=game.i18n.format("CHATNOTIFICATION.enchantmentUsed",{item:a.item.name,spell:l.name}),d.next=3,ChatMessage.create(t.Z.chatDataSetup(o));case 3:return d.next=5,p.basicTest(r);case 5:u.permanent?a.toggleChargedState(i,c):a.deleteEnchantment(i,c);case 6:case"end":return d.stop()}}),_callee13)})));return function(t){return r.apply(this,arguments)}}());case 14:case"end":return d.stop()}}),_callee14)})));return function(t){return r.apply(this,arguments)}}()),r.find(".ench-fw").change((function(t){var r=a.enchantMentId(t),o=r.id,i=r.enchantments,c=Number($(t.currentTarget).val());if(c){var u,l=item_sheet_createForOfIteratorHelper(i);try{for(l.s();!(u=l.n()).done;){var p=u.value;if(p.id==o){p.fw=c;break}}}catch(t){l.e(t)}finally{l.f()}a.item.update({flags:{dsa5:{enchantments:i}}})}})),r.find(".ench-delete").click((function(t){var r=a.enchantMentId(t),o=r.id,i=r.enchantments;a.deleteEnchantment(o,i)})),r.find(".ench-show").click(function(){var t=item_sheet_asyncToGenerator(item_sheet_regeneratorRuntime().mark((function _callee15(t){var r,o,i,c,u;return item_sheet_regeneratorRuntime().wrap((function _callee15$(l){for(;;)switch(l.prev=l.next){case 0:return r=a.enchantMentId(t),o=r.id,i=r.enchantments,c=i.find((function(t){return t.id==o})),l.next=4,a.getSpell(c);case 4:(u=l.sent)&&u.sheet.render(!0);case 6:case"end":return l.stop()}}),_callee15)})));return function(r){return t.apply(this,arguments)}}()),r.find(".poison-toggle-permanent").click((function(t){a.item.update({flags:{dsa5:{poison:{permanent:!a.item.flags.dsa5.poison.permanent}}}})})),r.find(".poison-delete").click((function(t){a.deletePoison()})),r.find(".poison-show").click(item_sheet_asyncToGenerator(item_sheet_regeneratorRuntime().mark((function _callee16(){var t;return item_sheet_regeneratorRuntime().wrap((function _callee16$(r){for(;;)switch(r.prev=r.next){case 0:if(a.item.actor&&(t=a.item.actor.items.find((function(t){return"poison"==t.type&&t.name==a.item.flags.dsa5.poison.name}))),t){r.next=5;break}return r.next=4,a.getSpell(a.item.flags.dsa5.poison);case 4:t=r.sent;case 5:t&&t.sheet.render(!0);case 6:case"end":return r.stop()}}),_callee16)}))))}},{key:"deletePoison",value:function deletePoison(){this.item.update(item_sheet_defineProperty({},"flags.dsa5.-=poison",null))}},{key:"deleteEnchantment",value:function deleteEnchantment(t,r){var a=r.findIndex((function(r){return r.id==t}));r.splice(a,1),this.item.update({flags:{dsa5:{enchantments:r}}})}},{key:"getSpell",value:(i=item_sheet_asyncToGenerator(item_sheet_regeneratorRuntime().mark((function _callee17(t){var r,a,o;return item_sheet_regeneratorRuntime().wrap((function _callee17$(i){for(;;)switch(i.prev=i.next){case 0:return i.next=2,game.packs.get(t.pack);case 2:if(r=i.sent){i.next=6;break}return ui.notifications.error(game.i18n.localize("DSAError.enchantmentNotFound")),i.abrupt("return");case 6:return i.next=8,r.getDocument(t.itemId);case 8:if(a=i.sent){i.next=17;break}return i.next=12,r.index.getName(t.name);case 12:if(!(o=i.sent)){i.next=17;break}return i.next=16,r.getDocument(o._id);case 16:a=i.sent;case 17:return a||ui.notifications.error(game.i18n.localize("DSAError.enchantmentNotFound")),i.abrupt("return",a);case 19:case"end":return i.stop()}}),_callee17)}))),function getSpell(t){return i.apply(this,arguments)})},{key:"enchantMentId",value:function enchantMentId(t){return{id:$(t.currentTarget).parents(".statusEffect").attr("data-id"),enchantments:this.item.getFlag("dsa5","enchantments")}}},{key:"prepareDomains",value:function prepareDomains(){var t=getProperty(this.item.system,"effect.attributes");if(t){var r=new RegExp(game.i18n.localize("WEAPON.magical"),"i"),a=new RegExp(game.i18n.localize("WEAPON.clerical"),"i");t=t.split(",").map((function(t){var o="";return r.test(t)?o="magical":a.test(t)&&(o="blessed"),'
  • ').concat(t,"
  • ")})).join("")}return t}},{key:"_canDragDrop",value:function _canDragDrop(t){return this.isEditable}},{key:"getData",value:(o=item_sheet_asyncToGenerator(item_sheet_regeneratorRuntime().mark((function _callee18(t){var a,o;return item_sheet_regeneratorRuntime().wrap((function _callee18$(i){for(;;)switch(i.prev=i.next){case 0:return i.next=2,item_sheet_get(item_sheet_getPrototypeOf(Enchantable.prototype),"getData",this).call(this,t);case 2:return(a=i.sent).enchantments=this.item.getFlag("dsa5","enchantments"),o=[],a.poison=this.item.getFlag("dsa5","poison"),a.poison&&o.push("poison"),a.enchantments&&a.enchantments.some((function(t){return!t.talisman}))&&o.push("enchantment"),a.enchantments&&a.enchantments.some((function(t){return t.talisman}))&&o.push("talisman"),a.enchantmentLabel=o.map((function(t){return game.i18n.localize(t)})).join("/"),a.traditionArtifacts=r.Z.traditionArtifacts,a.hasEnchantments=a.poison||a.enchantments&&a.enchantments.length>0,i.abrupt("return",a);case 13:case"end":return i.stop()}}),_callee18,this)}))),function getData(t){return o.apply(this,arguments)})}],[{key:"defaultOptions",get:function get(){var t=item_sheet_get(item_sheet_getPrototypeOf(Enchantable),"defaultOptions",this);return mergeObject(t,{dragDrop:[{dragSelector:".item-list .item",dropSelector:".content"}]}),t}}]),Enchantable}(H),B=function(r){item_sheet_inherits(InformationSheet,r);var a,o=item_sheet_createSuper(InformationSheet);function InformationSheet(){return item_sheet_classCallCheck(this,InformationSheet),o.apply(this,arguments)}return item_sheet_createClass(InformationSheet,[{key:"getData",value:(a=item_sheet_asyncToGenerator(item_sheet_regeneratorRuntime().mark((function _callee19(r){var a;return item_sheet_regeneratorRuntime().wrap((function _callee19$(o){for(;;)switch(o.prev=o.next){case 0:return o.next=2,item_sheet_get(item_sheet_getPrototypeOf(InformationSheet.prototype),"getData",this).call(this,r);case 2:return a=o.sent,o.t0=mergeObject,o.t1=a,o.next=7,t.Z.allSkillsList();case 7:return o.t2=o.sent,o.next=10,TextEditor.enrichHTML(this.item.system.qs1,{async:!0});case 10:return o.t3=o.sent,o.next=13,TextEditor.enrichHTML(this.item.system.qs2,{async:!0});case 13:return o.t4=o.sent,o.next=16,TextEditor.enrichHTML(this.item.system.qs3,{async:!0});case 16:return o.t5=o.sent,o.next=19,TextEditor.enrichHTML(this.item.system.qs4,{async:!0});case 19:return o.t6=o.sent,o.next=22,TextEditor.enrichHTML(this.item.system.qs5,{async:!0});case 22:return o.t7=o.sent,o.next=25,TextEditor.enrichHTML(this.item.system.qs6,{async:!0});case 25:return o.t8=o.sent,o.t9={allSkills:o.t2,enrichedqs1:o.t3,enrichedqs2:o.t4,enrichedqs3:o.t5,enrichedqs4:o.t6,enrichedqs5:o.t7,enrichedqs6:o.t8},(0,o.t0)(o.t1,o.t9),o.abrupt("return",a);case 29:case"end":return o.stop()}}),_callee19,this)}))),function getData(t){return a.apply(this,arguments)})}]),InformationSheet}(H),q=function(t){item_sheet_inherits(AmmunitionSheet,t);var a,o=item_sheet_createSuper(AmmunitionSheet);function AmmunitionSheet(t,r){var a;return item_sheet_classCallCheck(this,AmmunitionSheet),(a=o.call(this,t,r)).isPoisonable=!0,a}return item_sheet_createClass(AmmunitionSheet,[{key:"getData",value:(a=item_sheet_asyncToGenerator(item_sheet_regeneratorRuntime().mark((function _callee20(t){var a;return item_sheet_regeneratorRuntime().wrap((function _callee20$(o){for(;;)switch(o.prev=o.next){case 0:return o.next=2,item_sheet_get(item_sheet_getPrototypeOf(AmmunitionSheet.prototype),"getData",this).call(this,t);case 2:return(a=o.sent).ammunitiongroups=r.Z.ammunitiongroups,a.domains=this.prepareDomains(),o.abrupt("return",a);case 6:case"end":return o.stop()}}),_callee20,this)}))),function getData(t){return a.apply(this,arguments)})}]),AmmunitionSheet}(W),U=function(t){item_sheet_inherits(EquipmentSheet,t);var a,o,i,c=item_sheet_createSuper(EquipmentSheet);function EquipmentSheet(){return item_sheet_classCallCheck(this,EquipmentSheet),c.apply(this,arguments)}return item_sheet_createClass(EquipmentSheet,[{key:"getData",value:(i=item_sheet_asyncToGenerator(item_sheet_regeneratorRuntime().mark((function _callee21(t){var a,o,i=this;return item_sheet_regeneratorRuntime().wrap((function _callee21$(c){for(;;)switch(c.prev=c.next){case 0:return c.next=2,item_sheet_get(item_sheet_getPrototypeOf(EquipmentSheet.prototype),"getData",this).call(this,t);case 2:if(a=c.sent,c.t0=mergeObject,c.t1=a,c.t2=r.Z.equipmentTypes,c.t3=this.prepareDomains(),c.t4=game.user.isGM,c.t4){c.next=12;break}return c.next=11,game.settings.get("dsa5","playerCanEditSpellMacro");case 11:c.t4=c.sent;case 12:return c.t5=c.t4,c.t6={equipmentTypes:c.t2,domains:c.t3,canOnUseEffect:c.t5},(0,c.t0)(c.t1,c.t6),this.isBagWithContents()&&(o=0,mergeObject(a,{containerContent:this.item.actor.items.filter((function(t){return r.Z.equipmentCategories.includes(t.type)&&t.system.parent_id==i.item.id})).map((function(t){t.system.preparedWeight=parseFloat((t.system.weight.value*t.system.quantity.value).toFixed(3)),o+=Number(t.system.preparedWeight);var r=getProperty(t,"flags.dsa5.enchantments");return r&&r.length>0?t.enchantClass="rar":(t.system.effect&&""!=t.system.effect.value||t.effects.length>0)&&(t.enchantClass="common"),t})),weightSum:parseFloat(o.toFixed(3)),weightWidth:'style="width: '.concat(Math.min(this.item.system.capacity?o/this.item.system.capacity*100:0,100),'%"'),weightExceeded:o>Number(this.item.system.capacity)?"exceeded":""})),c.abrupt("return",a);case 17:case"end":return c.stop()}}),_callee21,this)}))),function getData(t){return i.apply(this,arguments)})},{key:"breakOverflow",value:(o=item_sheet_asyncToGenerator(item_sheet_regeneratorRuntime().mark((function _callee22(t,r){var a,o,i;return item_sheet_regeneratorRuntime().wrap((function _callee22$(c){for(;;)switch(c.prev=c.next){case 0:return c.t0=$,c.next=3,renderTemplate("systems/dsa5/templates/items/baghover.html",t);case 3:return c.t1=c.sent,a=(0,c.t0)(c.t1),o=r.offset().top+52,i=r.offset().left-75,a.appendTo($("body")),a.css({position:"absolute",left:i+"px",top:o+"px",bottom:"auto",right:"auto","z-index":1e4}),c.abrupt("return",a);case 10:case"end":return c.stop()}}),_callee22)}))),function breakOverflow(t,r){return o.apply(this,arguments)})},{key:"activateListeners",value:function activateListeners(t){var r=this;item_sheet_get(item_sheet_getPrototypeOf(EquipmentSheet.prototype),"activateListeners",this).call(this,t);var a=t.find(".slot");a.mouseenter(function(){var t=item_sheet_asyncToGenerator(item_sheet_regeneratorRuntime().mark((function _callee23(t){var a,o;return item_sheet_regeneratorRuntime().wrap((function _callee23$(i){for(;;)switch(i.prev=i.next){case 0:return a=$(t.currentTarget),i.next=3,r.breakOverflow({name:a.attr("data-name"),weight:a.attr("data-weight"),quantity:a.attr("data-quantity")},a);case 3:(o=i.sent).fadeIn(),a.mouseleave((function(){o.remove(),a.off("mouseleave")}));case 6:case"end":return i.stop()}}),_callee23)})));return function(r){return t.apply(this,arguments)}}()),a.mousedown(function(){var t=item_sheet_asyncToGenerator(item_sheet_regeneratorRuntime().mark((function _callee24(t){var a,o;return item_sheet_regeneratorRuntime().wrap((function _callee24$(i){for(;;)switch(i.prev=i.next){case 0:if(a=t.currentTarget.dataset.itemId,o=r.actor.items.get(a),0!=t.button){i.next=6;break}o.sheet.render(!0),i.next=11;break;case 6:if(2!=t.button){i.next=11;break}return $(".itemInfo").remove(),i.next=10,o.update({"system.parent_id":0});case 10:r.render(!0);case 11:case"end":return i.stop()}}),_callee24)})));return function(r){return t.apply(this,arguments)}}())}},{key:"isBagWithContents",value:function isBagWithContents(){return this.item.actor&&"bags"==getProperty(this.item,"system.equipmentType.value")}},{key:"_onDrop",value:(a=item_sheet_asyncToGenerator(item_sheet_regeneratorRuntime().mark((function _callee25(t){var a,o,i,c,u,l;return item_sheet_regeneratorRuntime().wrap((function _callee25$(p){for(;;)switch(p.prev=p.next){case 0:if(!this.isBagWithContents()){p.next=22;break}return a=JSON.parse(t.dataTransfer.getData("text/plain")),p.next=4,(0,h.x8)(a,void 0);case 4:if(o=p.sent,i=o.item,c=o.typeClass,o.selfTarget,u=this.item.id==i.id,l=this.item.parent.id==a.actorId,!r.Z.equipmentCategories.includes(c)||u){p.next=22;break}if(i.system.parent_id=this.item.id,i.system.worn&&i.system.worn.value&&(i.system.worn.value=!1),!l){p.next=18;break}return p.next=16,this.item.actor.updateEmbeddedDocuments("Item",[i]);case 16:p.next=20;break;case 18:return p.next=20,this.item.actor.sheet._addLoot(i);case 20:return this.render(!0),p.abrupt("return");case 22:return p.next=24,item_sheet_get(item_sheet_getPrototypeOf(EquipmentSheet.prototype),"_onDrop",this).call(this,t);case 24:case"end":return p.stop()}}),_callee25,this)}))),function _onDrop(t){return a.apply(this,arguments)})}]),EquipmentSheet}(z(W)),Y=function(t){item_sheet_inherits(ArmorSheet,t);var a,o=item_sheet_createSuper(ArmorSheet);function ArmorSheet(){return item_sheet_classCallCheck(this,ArmorSheet),o.apply(this,arguments)}return item_sheet_createClass(ArmorSheet,[{key:"getData",value:(a=item_sheet_asyncToGenerator(item_sheet_regeneratorRuntime().mark((function _callee26(t){var a;return item_sheet_regeneratorRuntime().wrap((function _callee26$(o){for(;;)switch(o.prev=o.next){case 0:return o.next=2,item_sheet_get(item_sheet_getPrototypeOf(ArmorSheet.prototype),"getData",this).call(this,t);case 2:if(a=o.sent,mergeObject(a,{domains:this.prepareDomains(),armorSubcategories:Object.keys(r.Z.armorSubcategories),breakPointRating:r.Z.armorSubcategories[this.item.system.subcategory]}),o.t0=game.user.isGM,o.t0){o.next=9;break}return o.next=8,game.settings.get("dsa5","playerCanEditSpellMacro");case 8:o.t0=o.sent;case 9:return a.canOnUseEffect=o.t0,o.abrupt("return",a);case 11:case"end":return o.stop()}}),_callee26,this)}))),function getData(t){return a.apply(this,arguments)})},{key:"_getHeaderButtons",value:function _getHeaderButtons(){var t,r=this,a=item_sheet_get(item_sheet_getPrototypeOf(ArmorSheet.prototype),"_getHeaderButtons",this).call(this);return this.item.isOwned&&game.settings.get("dsa5","armorAndWeaponDamage")&&this.item.system.structure.max>0&&a.unshift({class:"rollDamaged",icon:"fas fa-dice-d20",onclick:(t=item_sheet_asyncToGenerator(item_sheet_regeneratorRuntime().mark((function _callee27(){return item_sheet_regeneratorRuntime().wrap((function _callee27$(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",M.Z.breakingTest(r.item));case 1:case"end":return t.stop()}}),_callee27)}))),function onclick(){return t.apply(this,arguments)})}),a}}]),ArmorSheet}(z(W)),V=function(t){item_sheet_inherits(PlantSheet,t);var r,a=item_sheet_createSuper(PlantSheet);function PlantSheet(){return item_sheet_classCallCheck(this,PlantSheet),a.apply(this,arguments)}return item_sheet_createClass(PlantSheet,[{key:"getData",value:(r=item_sheet_asyncToGenerator(item_sheet_regeneratorRuntime().mark((function _callee28(t){var r;return item_sheet_regeneratorRuntime().wrap((function _callee28$(a){for(;;)switch(a.prev=a.next){case 0:return a.next=2,item_sheet_get(item_sheet_getPrototypeOf(PlantSheet.prototype),"getData",this).call(this,t);case 2:return(r=a.sent).attributes=Object.keys(r.system.planttype).map((function(t){return{name:t,checked:r.system.planttype[t]}})),a.next=6,TextEditor.enrichHTML(getProperty(this.item.system,"effect"),{secrets:this.object.isOwner,async:!0});case 6:return r.enrichedEffect=a.sent,a.next=9,TextEditor.enrichHTML(getProperty(this.item.system,"recipes"),{secrets:this.object.isOwner,async:!0});case 9:return r.enrichedRecipes=a.sent,a.next=12,TextEditor.enrichHTML(getProperty(this.item.system,"infos"),{secrets:this.object.isOwner,async:!0});case 12:return r.enrichedInformation=a.sent,a.abrupt("return",r);case 14:case"end":return a.stop()}}),_callee28,this)}))),function getData(t){return r.apply(this,arguments)})}]),PlantSheet}(z(H)),K=function(t){item_sheet_inherits(PatronSheet,t);var r,a=item_sheet_createSuper(PatronSheet);function PatronSheet(){return item_sheet_classCallCheck(this,PatronSheet),a.apply(this,arguments)}return item_sheet_createClass(PatronSheet,[{key:"getData",value:(r=item_sheet_asyncToGenerator(item_sheet_regeneratorRuntime().mark((function _callee29(t){var r;return item_sheet_regeneratorRuntime().wrap((function _callee29$(a){for(;;)switch(a.prev=a.next){case 0:return a.next=2,item_sheet_get(item_sheet_getPrototypeOf(PatronSheet.prototype),"getData",this).call(this,t);case 2:return(r=a.sent).patronCategories=[0,1,2,3].map((function(t){return{name:game.i18n.localize("PATRON.".concat(t)),val:t}})),r.priorities={0:game.i18n.localize("PATRON.primary"),1:game.i18n.localize("PATRON.secondary")},a.abrupt("return",r);case 6:case"end":return a.stop()}}),_callee29,this)}))),function getData(t){return r.apply(this,arguments)})}]),PatronSheet}(H),J=function(t){item_sheet_inherits(MagicalSignSheet,t);var r,a,o=item_sheet_createSuper(MagicalSignSheet);function MagicalSignSheet(){return item_sheet_classCallCheck(this,MagicalSignSheet),o.apply(this,arguments)}return item_sheet_createClass(MagicalSignSheet,[{key:"getData",value:(a=item_sheet_asyncToGenerator(item_sheet_regeneratorRuntime().mark((function _callee30(t){var r;return item_sheet_regeneratorRuntime().wrap((function _callee30$(a){for(;;)switch(a.prev=a.next){case 0:return a.next=2,item_sheet_get(item_sheet_getPrototypeOf(MagicalSignSheet.prototype),"getData",this).call(this,t);case 2:if((r=a.sent).categories={1:game.i18n.localize("TYPES.Item.magicalsign"),2:game.i18n.localize("additionalsign")},a.t0=game.user.isGM,a.t0){a.next=9;break}return a.next=8,game.settings.get("dsa5","playerCanEditSpellMacro");case 8:a.t0=a.sent;case 9:return r.canOnUseEffect=a.t0,a.abrupt("return",r);case 11:case"end":return a.stop()}}),_callee30,this)}))),function getData(t){return a.apply(this,arguments)})},{key:"_getHeaderButtons",value:function _getHeaderButtons(){var t,r=this,a=item_sheet_get(item_sheet_getPrototypeOf(MagicalSignSheet.prototype),"_getHeaderButtons",this).call(this);return this.item.isOwned&&a.unshift({class:"rolleffect",icon:"fas fa-dice-d20",onclick:(t=item_sheet_asyncToGenerator(item_sheet_regeneratorRuntime().mark((function _callee31(t){return item_sheet_regeneratorRuntime().wrap((function _callee31$(a){for(;;)switch(a.prev=a.next){case 0:return a.abrupt("return",r.setupEffect(t));case 1:case"end":return a.stop()}}),_callee31)}))),function onclick(r){return t.apply(this,arguments)})}),a}},{key:"setupEffect",value:(r=item_sheet_asyncToGenerator(item_sheet_regeneratorRuntime().mark((function _callee33(t){var r,a,o,i,c;return item_sheet_regeneratorRuntime().wrap((function _callee33$(t){for(;;)switch(t.prev=t.next){case 0:if(r=Number(this.item.system.asp)||0,!(this.item.actor.system.status.astralenergy.value

    ".concat(this.item.name,"

    ").concat(this.item.system.description.value,"

    ").concat(o.chatData(this.item.system,"").join("
    "),'

    '),a.setupSkill(i,{other:[c],subtitle:" (".concat(game.i18n.localize("TYPES.Item.magicalsign"),")")},void 0).then(function(){var t=item_sheet_asyncToGenerator(item_sheet_regeneratorRuntime().mark((function _callee32(t){var o;return item_sheet_regeneratorRuntime().wrap((function _callee32$(i){for(;;)switch(i.prev=i.next){case 0:return i.next=2,a.basicTest(t,{suppressMessage:!0});case 2:return(o=i.sent).result.preData.calculatedSpellModifiers={finalcost:r,costsMana:!0},i.next=6,j.Z.renderRollCard(o.cardOptions,o.result,o.options.rerenderMessage);case 6:case"end":return i.stop()}}),_callee32)})));return function(r){return t.apply(this,arguments)}}());case 8:case"end":return t.stop()}}),_callee33,this)}))),function setupEffect(t){return r.apply(this,arguments)})}]),MagicalSignSheet}(H),Q=function(a){item_sheet_inherits(RangeweaponSheet,a);var o,i=item_sheet_createSuper(RangeweaponSheet);function RangeweaponSheet(){return item_sheet_classCallCheck(this,RangeweaponSheet),i.apply(this,arguments)}return item_sheet_createClass(RangeweaponSheet,[{key:"_getHeaderButtons",value:function _getHeaderButtons(){var t,r=this,a=item_sheet_get(item_sheet_getPrototypeOf(RangeweaponSheet.prototype),"_getHeaderButtons",this).call(this);return this.item.isOwned&&game.settings.get("dsa5","armorAndWeaponDamage")&&this.item.system.structure.max>0&&a.unshift({class:"rollDamaged",icon:"fas fa-dice-d20",onclick:(t=item_sheet_asyncToGenerator(item_sheet_regeneratorRuntime().mark((function _callee34(){return item_sheet_regeneratorRuntime().wrap((function _callee34$(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",M.Z.breakingTest(r.item));case 1:case"end":return t.stop()}}),_callee34)}))),function onclick(){return t.apply(this,arguments)})}),a}},{key:"getData",value:(o=item_sheet_asyncToGenerator(item_sheet_regeneratorRuntime().mark((function _callee35(a){var o;return item_sheet_regeneratorRuntime().wrap((function _callee35$(i){for(;;)switch(i.prev=i.next){case 0:return i.next=2,item_sheet_get(item_sheet_getPrototypeOf(RangeweaponSheet.prototype),"getData",this).call(this,a);case 2:if(o=i.sent,i.t0=mergeObject,i.t1=o,i.t2=game.user.isGM,i.t2){i.next=10;break}return i.next=9,game.settings.get("dsa5","playerCanEditSpellMacro");case 9:i.t2=i.sent;case 10:return i.t3=i.t2,i.t4=r.Z.ammunitiongroups,i.next=14,t.Z.allCombatSkillsList("range");case 14:return i.t5=i.sent,i.t6=this.prepareDomains(),i.t7=r.Z.weaponStabilities[game.i18n.localize("LocalizedCTs.".concat(this.item.system.combatskill.value))],i.t8={canOnUseEffect:i.t3,ammunitiongroups:i.t4,combatskills:i.t5,domains:i.t6,breakPointRating:i.t7},(0,i.t0)(i.t1,i.t8),i.abrupt("return",o);case 20:case"end":return i.stop()}}),_callee35,this)}))),function getData(t){return o.apply(this,arguments)})}]),RangeweaponSheet}(z(W)),X=function(r){item_sheet_inherits(BlessingSheetDSA5,r);var a,o,i=item_sheet_createSuper(BlessingSheetDSA5);function BlessingSheetDSA5(){return item_sheet_classCallCheck(this,BlessingSheetDSA5),i.apply(this,arguments)}return item_sheet_createClass(BlessingSheetDSA5,[{key:"_getHeaderButtons",value:function _getHeaderButtons(){var t,r=this,a=item_sheet_get(item_sheet_getPrototypeOf(BlessingSheetDSA5.prototype),"_getHeaderButtons",this).call(this);return this.item.isOwned&&a.unshift({class:"rolleffect",icon:"fas fa-dice-d20",onclick:(t=item_sheet_asyncToGenerator(item_sheet_regeneratorRuntime().mark((function _callee36(t){return item_sheet_regeneratorRuntime().wrap((function _callee36$(a){for(;;)switch(a.prev=a.next){case 0:return a.abrupt("return",r.setupEffect(t));case 1:case"end":return a.stop()}}),_callee36)}))),function onclick(r){return t.apply(this,arguments)})}),a}},{key:"getData",value:(o=item_sheet_asyncToGenerator(item_sheet_regeneratorRuntime().mark((function _callee37(t){var r;return item_sheet_regeneratorRuntime().wrap((function _callee37$(a){for(;;)switch(a.prev=a.next){case 0:return a.next=2,item_sheet_get(item_sheet_getPrototypeOf(BlessingSheetDSA5.prototype),"getData",this).call(this,t);case 2:if(r=a.sent,a.t0=game.user.isGM,a.t0){a.next=8;break}return a.next=7,game.settings.get("dsa5","playerCanEditSpellMacro");case 7:a.t0=a.sent;case 8:return r.canOnUseEffect=a.t0,a.abrupt("return",r);case 10:case"end":return a.stop()}}),_callee37,this)}))),function getData(t){return o.apply(this,arguments)})},{key:"setupEffect",value:(a=item_sheet_asyncToGenerator(item_sheet_regeneratorRuntime().mark((function _callee38(r){var a,o;return item_sheet_regeneratorRuntime().wrap((function _callee38$(r){for(;;)switch(r.prev=r.next){case 0:if(!(this.item.actor.system.status.karmaenergy.value<1)){r.next=2;break}return r.abrupt("return",ui.notifications.error(game.i18n.localize("DSAError.NotEnoughKaP")));case 2:return a=game.dsa5.config.ItemSubclasses.magictrick,r.next=5,this.item.actor.update({"system.status.karmaenergy.value":this.item.actor.system.status.karmaenergy.value-=1});case 5:return o="

    ".concat(this.item.name," - ").concat(game.i18n.localize("blessing")," ").concat(game.i18n.localize("probe"),"

    ").concat(this.item.system.description.value,"

    ").concat(a.chatData(this.item.system,"").join("
    "),"

    "),r.next=8,ChatMessage.create(t.Z.chatDataSetup(o));case 8:case"end":return r.stop()}}),_callee38,this)}))),function setupEffect(t){return a.apply(this,arguments)})}]),BlessingSheetDSA5}(H),ee=function(t){item_sheet_inherits(ItemCareerDSA5,t);var a,o=item_sheet_createSuper(ItemCareerDSA5);function ItemCareerDSA5(){return item_sheet_classCallCheck(this,ItemCareerDSA5),o.apply(this,arguments)}return item_sheet_createClass(ItemCareerDSA5,[{key:"getData",value:(a=item_sheet_asyncToGenerator(item_sheet_regeneratorRuntime().mark((function _callee39(t){var a,o;return item_sheet_regeneratorRuntime().wrap((function _callee39$(i){for(;;)switch(i.prev=i.next){case 0:return i.next=2,item_sheet_get(item_sheet_getPrototypeOf(ItemCareerDSA5.prototype),"getData",this).call(this,t);case 2:return a=i.sent,(o=duplicate(r.Z.characteristics))["-"]="-",a.mageLevels=r.Z.mageLevels,a.guidevalues=o,i.next=9,TextEditor.enrichHTML(getProperty(this.item.system,"clothing.value"),{secrets:this.object.isOwner,async:!0});case 9:return a.enrichedClothing=i.sent,i.abrupt("return",a);case 11:case"end":return i.stop()}}),_callee39,this)}))),function getData(t){return a.apply(this,arguments)})}],[{key:"defaultOptions",get:function get(){var t=item_sheet_get(item_sheet_getPrototypeOf(ItemCareerDSA5),"defaultOptions",this);return mergeObject(t,{width:700,height:700}),t}}]),ItemCareerDSA5}(H),te=function(t){item_sheet_inherits(ConsumableSheetDSA5,t);var a,o=item_sheet_createSuper(ConsumableSheetDSA5);function ConsumableSheetDSA5(){return item_sheet_classCallCheck(this,ConsumableSheetDSA5),o.apply(this,arguments)}return item_sheet_createClass(ConsumableSheetDSA5,[{key:"_getHeaderButtons",value:function _getHeaderButtons(){var t,r=this,a=item_sheet_get(item_sheet_getPrototypeOf(ConsumableSheetDSA5.prototype),"_getHeaderButtons",this).call(this);return this.item.isOwned&&a.unshift({class:"consumeItem",icon:"fas fa-dice-d20",onclick:(t=item_sheet_asyncToGenerator(item_sheet_regeneratorRuntime().mark((function _callee40(t){return item_sheet_regeneratorRuntime().wrap((function _callee40$(a){for(;;)switch(a.prev=a.next){case 0:return a.abrupt("return",r.setupEffect(t));case 1:case"end":return a.stop()}}),_callee40)}))),function onclick(r){return t.apply(this,arguments)})}),a}},{key:"getData",value:(a=item_sheet_asyncToGenerator(item_sheet_regeneratorRuntime().mark((function _callee41(t){var a;return item_sheet_regeneratorRuntime().wrap((function _callee41$(o){for(;;)switch(o.prev=o.next){case 0:return o.next=2,item_sheet_get(item_sheet_getPrototypeOf(ConsumableSheetDSA5.prototype),"getData",this).call(this,t);case 2:return(a=o.sent).calculatedPrice=a.system.price.value*a.system.QL||0,a.availableSteps=a.system.QLList.split("\n").map((function(t,r){return r+1})),a.equipmentTypes=r.Z.equipmentTypes,o.next=8,TextEditor.enrichHTML(getProperty(this.item.system,"ingredients"),{secrets:this.object.isOwner,async:!0});case 8:return a.enrichedIngredients=o.sent,o.abrupt("return",a);case 10:case"end":return o.stop()}}),_callee41,this)}))),function getData(t){return a.apply(this,arguments)})},{key:"setupEffect",value:function setupEffect(t){this.item.setupEffect()}}],[{key:"defaultOptions",get:function get(){var t=item_sheet_get(item_sheet_getPrototypeOf(ConsumableSheetDSA5),"defaultOptions",this);return mergeObject(t,{width:480}),t}}]),ConsumableSheetDSA5}(z(H)),re=function(t){item_sheet_inherits(ItemCultureDSA5,t);var r,a=item_sheet_createSuper(ItemCultureDSA5);function ItemCultureDSA5(){return item_sheet_classCallCheck(this,ItemCultureDSA5),a.apply(this,arguments)}return item_sheet_createClass(ItemCultureDSA5,[{key:"getData",value:(r=item_sheet_asyncToGenerator(item_sheet_regeneratorRuntime().mark((function _callee42(t){var r;return item_sheet_regeneratorRuntime().wrap((function _callee42$(a){for(;;)switch(a.prev=a.next){case 0:return a.next=2,item_sheet_get(item_sheet_getPrototypeOf(ItemCultureDSA5.prototype),"getData",this).call(this,t);case 2:return r=a.sent,a.next=5,TextEditor.enrichHTML(getProperty(this.item.system,"clothing.value"),{secrets:this.object.isOwner,async:!0});case 5:return r.enrichedClothing=a.sent,a.abrupt("return",r);case 7:case"end":return a.stop()}}),_callee42,this)}))),function getData(t){return r.apply(this,arguments)})}],[{key:"defaultOptions",get:function get(){var t=item_sheet_get(item_sheet_getPrototypeOf(ItemCultureDSA5),"defaultOptions",this);return mergeObject(t,{width:700,height:700}),t}}]),ItemCultureDSA5}(H),ne=function(t){item_sheet_inherits(DiseaseSheetDSA5,t);var a,o=item_sheet_createSuper(DiseaseSheetDSA5);function DiseaseSheetDSA5(){return item_sheet_classCallCheck(this,DiseaseSheetDSA5),o.apply(this,arguments)}return item_sheet_createClass(DiseaseSheetDSA5,[{key:"_getHeaderButtons",value:function _getHeaderButtons(){var t,r=this,a=item_sheet_get(item_sheet_getPrototypeOf(DiseaseSheetDSA5.prototype),"_getHeaderButtons",this).call(this);return a.unshift({class:"rolleffect",icon:"fas fa-dice-d20",onclick:(t=item_sheet_asyncToGenerator(item_sheet_regeneratorRuntime().mark((function _callee43(t){return item_sheet_regeneratorRuntime().wrap((function _callee43$(a){for(;;)switch(a.prev=a.next){case 0:return a.abrupt("return",r.setupEffect(t));case 1:case"end":return a.stop()}}),_callee43)}))),function onclick(r){return t.apply(this,arguments)})}),a}},{key:"getData",value:(a=item_sheet_asyncToGenerator(item_sheet_regeneratorRuntime().mark((function _callee44(t){var a;return item_sheet_regeneratorRuntime().wrap((function _callee44$(o){for(;;)switch(o.prev=o.next){case 0:return o.next=2,item_sheet_get(item_sheet_getPrototypeOf(DiseaseSheetDSA5.prototype),"getData",this).call(this,t);case 2:return(a=o.sent).resistances=r.Z.magicResistanceModifiers,o.abrupt("return",a);case 5:case"end":return o.stop()}}),_callee44,this)}))),function getData(t){return a.apply(this,arguments)})}]),DiseaseSheetDSA5}(H),ae=function(r){item_sheet_inherits(MagictrickSheetDSA5,r);var a,o,i=item_sheet_createSuper(MagictrickSheetDSA5);function MagictrickSheetDSA5(){return item_sheet_classCallCheck(this,MagictrickSheetDSA5),i.apply(this,arguments)}return item_sheet_createClass(MagictrickSheetDSA5,[{key:"_getHeaderButtons",value:function _getHeaderButtons(){var t,r=this,a=item_sheet_get(item_sheet_getPrototypeOf(MagictrickSheetDSA5.prototype),"_getHeaderButtons",this).call(this);return this.item.isOwned&&a.unshift({class:"rolleffect",icon:"fas fa-dice-d20",onclick:(t=item_sheet_asyncToGenerator(item_sheet_regeneratorRuntime().mark((function _callee45(t){return item_sheet_regeneratorRuntime().wrap((function _callee45$(a){for(;;)switch(a.prev=a.next){case 0:return a.abrupt("return",r.setupEffect(t));case 1:case"end":return a.stop()}}),_callee45)}))),function onclick(r){return t.apply(this,arguments)})}),a}},{key:"getData",value:(o=item_sheet_asyncToGenerator(item_sheet_regeneratorRuntime().mark((function _callee46(t){var r;return item_sheet_regeneratorRuntime().wrap((function _callee46$(a){for(;;)switch(a.prev=a.next){case 0:return a.next=2,item_sheet_get(item_sheet_getPrototypeOf(MagictrickSheetDSA5.prototype),"getData",this).call(this,t);case 2:if(r=a.sent,a.t0=game.user.isGM,a.t0){a.next=8;break}return a.next=7,game.settings.get("dsa5","playerCanEditSpellMacro");case 7:a.t0=a.sent;case 8:return r.canOnUseEffect=a.t0,a.abrupt("return",r);case 10:case"end":return a.stop()}}),_callee46,this)}))),function getData(t){return o.apply(this,arguments)})},{key:"setupEffect",value:(a=item_sheet_asyncToGenerator(item_sheet_regeneratorRuntime().mark((function _callee47(r){var a,o;return item_sheet_regeneratorRuntime().wrap((function _callee47$(r){for(;;)switch(r.prev=r.next){case 0:if(!(this.item.actor.system.status.astralenergy.value<1)){r.next=2;break}return r.abrupt("return",ui.notifications.error(game.i18n.localize("DSAError.NotEnoughAsP")));case 2:return a=game.dsa5.config.ItemSubclasses.magictrick,r.next=5,this.item.actor.update({"system.status.astralenergy.value":this.item.actor.system.status.astralenergy.value-=1});case 5:return o="

    ".concat(this.item.name," - ").concat(game.i18n.localize("magictrick")," ").concat(game.i18n.localize("probe"),"

    ").concat(this.item.system.description.value,"

    ").concat(a.chatData(this.item.system,"").join("
    "),"

    "),r.next=8,ChatMessage.create(t.Z.chatDataSetup(o));case 8:case"end":return r.stop()}}),_callee47,this)}))),function setupEffect(t){return a.apply(this,arguments)})}]),MagictrickSheetDSA5}(H),oe=function(a){item_sheet_inherits(MeleeweaponSheetDSA5,a);var o,i=item_sheet_createSuper(MeleeweaponSheetDSA5);function MeleeweaponSheetDSA5(t,r){var a;return item_sheet_classCallCheck(this,MeleeweaponSheetDSA5),(a=i.call(this,t,r)).isPoisonable=!0,a}return item_sheet_createClass(MeleeweaponSheetDSA5,[{key:"getData",value:(o=item_sheet_asyncToGenerator(item_sheet_regeneratorRuntime().mark((function _callee48(a){var o,i,c,u,l,p,d,h=this;return item_sheet_regeneratorRuntime().wrap((function _callee48$(m){for(;;)switch(m.prev=m.next){case 0:return m.next=2,item_sheet_get(item_sheet_getPrototypeOf(MeleeweaponSheetDSA5.prototype),"getData",this).call(this,a);case 2:if(o=m.sent,i=mergeObject(duplicate(r.Z.characteristics),item_sheet_defineProperty({"ge/kk":game.i18n.localize("CHAR.GEKK")},"-","-")),c=y.Z.regex2h.test(this.item.name),u="",c){m.next=10;break}u="wrongGrip.yieldTwo",m.next=18;break;case 10:l=game.i18n.localize("LocalizedCTs.".concat(this.item.system.combatskill.value)),m.t0=l,m.next="Two-Handed Impact Weapons"===m.t0||"Two-Handed Swords"===m.t0?14:17;break;case 14:return p=new RegExp(game.i18n.localize("wrongGrip.wrongGripBastardRegex")),u=p.test(this.item.name)?"wrongGrip.yieldOneBastard":"wrongGrip.yieldOneSwordBlunt",m.abrupt("break",18);case 17:u="wrongGrip.yieldOnePolearms";case 18:return m.t1=mergeObject,m.t2=o,m.t3=i,m.t4=c,m.t5=c?"wrongGrip.oneHanded":"wrongGrip.twoHanded",m.t6=u,m.next=26,t.Z.allCombatSkillsList("melee");case 26:if(m.t7=m.sent,m.t8=r.Z.meleeRanges,m.t9=r.Z.shieldSizes,m.t10=y.Z.isShield(this.item),m.t11=this.prepareDomains(),m.t12=r.Z.weaponStabilities[game.i18n.localize("LocalizedCTs.".concat(this.item.system.combatskill.value))],m.t13={characteristics:m.t3,twoHanded:m.t4,wrongGripLabel:m.t5,wrongGripHint:m.t6,combatskills:m.t7,ranges:m.t8,shieldSizes:m.t9,isShield:m.t10,domains:m.t11,breakPointRating:m.t12},(0,m.t1)(m.t2,m.t13),this.item.actor&&(d=this.item.actor.items.find((function(t){return"combatskill"==t.type&&t.name==h.item.system.combatskill.value})),o.canBeOffHand=d&&!d.system.weapontype.twoHanded&&this.item.system.worn.value,o.canBeWrongGrip=!["Daggers","Fencing Weapons"].includes(game.i18n.localize("LocalizedCTs.".concat(this.item.system.combatskill.value)))),m.t14=game.user.isGM,m.t14){m.next=40;break}return m.next=39,game.settings.get("dsa5","playerCanEditSpellMacro");case 39:m.t14=m.sent;case 40:return o.canOnUseEffect=m.t14,m.abrupt("return",o);case 42:case"end":return m.stop()}}),_callee48,this)}))),function getData(t){return o.apply(this,arguments)})},{key:"_getHeaderButtons",value:function _getHeaderButtons(){var t,r=this,a=item_sheet_get(item_sheet_getPrototypeOf(MeleeweaponSheetDSA5.prototype),"_getHeaderButtons",this).call(this);return this.item.isOwned&&game.settings.get("dsa5","armorAndWeaponDamage")&&this.item.system.structure.max>0&&a.unshift({class:"rollDamaged",icon:"fas fa-dice-d20",onclick:(t=item_sheet_asyncToGenerator(item_sheet_regeneratorRuntime().mark((function _callee49(){return item_sheet_regeneratorRuntime().wrap((function _callee49$(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",M.Z.breakingTest(r.item));case 1:case"end":return t.stop()}}),_callee49)}))),function onclick(){return t.apply(this,arguments)})}),a}}]),MeleeweaponSheetDSA5}(z(W)),ie=function(t){item_sheet_inherits(PoisonSheetDSA5,t);var a,o=item_sheet_createSuper(PoisonSheetDSA5);function PoisonSheetDSA5(){return item_sheet_classCallCheck(this,PoisonSheetDSA5),o.apply(this,arguments)}return item_sheet_createClass(PoisonSheetDSA5,[{key:"_getHeaderButtons",value:function _getHeaderButtons(){var t,r=this,a=item_sheet_get(item_sheet_getPrototypeOf(PoisonSheetDSA5.prototype),"_getHeaderButtons",this).call(this);return a.unshift({class:"rolleffect",icon:"fas fa-dice-d20",onclick:(t=item_sheet_asyncToGenerator(item_sheet_regeneratorRuntime().mark((function _callee50(t){return item_sheet_regeneratorRuntime().wrap((function _callee50$(a){for(;;)switch(a.prev=a.next){case 0:return a.abrupt("return",r.setupEffect(t));case 1:case"end":return a.stop()}}),_callee50)}))),function onclick(r){return t.apply(this,arguments)})}),a}},{key:"getData",value:(a=item_sheet_asyncToGenerator(item_sheet_regeneratorRuntime().mark((function _callee51(t){var a;return item_sheet_regeneratorRuntime().wrap((function _callee51$(o){for(;;)switch(o.prev=o.next){case 0:return o.next=2,item_sheet_get(item_sheet_getPrototypeOf(PoisonSheetDSA5.prototype),"getData",this).call(this,t);case 2:return(a=o.sent).resistances=r.Z.magicResistanceModifiers,o.abrupt("return",a);case 5:case"end":return o.stop()}}),_callee51,this)}))),function getData(t){return a.apply(this,arguments)})}]),PoisonSheetDSA5}(z(H)),ce=function(t){item_sheet_inherits(SpecialAbilitySheetDSA5,t);var a,o,c,u=item_sheet_createSuper(SpecialAbilitySheetDSA5);function SpecialAbilitySheetDSA5(){return item_sheet_classCallCheck(this,SpecialAbilitySheetDSA5),u.apply(this,arguments)}return item_sheet_createClass(SpecialAbilitySheetDSA5,[{key:"_refundStep",value:(c=item_sheet_asyncToGenerator(item_sheet_regeneratorRuntime().mark((function _callee52(){var t;return item_sheet_regeneratorRuntime().wrap((function _callee52$(r){for(;;)switch(r.prev=r.next){case 0:if(!(this.item.system.step.value>1)){r.next=11;break}return r.next=3,i.Z.stepXPCost(this.item,this.item.system.step.value-1);case 3:return t=r.sent,r.next=6,i.Z.refundFreelanguage(this.item,this.item.actor,t,!1);case 6:return t=r.sent,r.next=9,this.item.actor._updateAPs(-1*t,{},{render:!1});case 9:return r.next=11,this.item.update({"system.step.value":this.item.system.step.value-1});case 11:case"end":return r.stop()}}),_callee52,this)}))),function _refundStep(){return c.apply(this,arguments)})},{key:"_advanceStep",value:(o=item_sheet_asyncToGenerator(item_sheet_regeneratorRuntime().mark((function _callee53(){var t;return item_sheet_regeneratorRuntime().wrap((function _callee53$(r){for(;;)switch(r.prev=r.next){case 0:if(!(this.item.system.step.value0}},{key:"getData",value:(a=item_sheet_asyncToGenerator(item_sheet_regeneratorRuntime().mark((function _callee54(t){var a;return item_sheet_regeneratorRuntime().wrap((function _callee54$(o){for(;;)switch(o.prev=o.next){case 0:return o.next=2,item_sheet_get(item_sheet_getPrototypeOf(SpecialAbilitySheetDSA5.prototype),"getData",this).call(this,t);case 2:if(a=o.sent,o.t0=mergeObject,o.t1=a,o.t2=r.Z.specialAbilityCategories,o.t3=r.Z.combatSkillSubCategories,o.t4=r.Z.traditionArtifacts,o.t5=game.user.isGM,o.t5){o.next=13;break}return o.next=12,game.settings.get("dsa5","playerCanEditSpellMacro");case 12:o.t5=o.sent;case 13:return o.t6=o.t5,o.t7={categories:o.t2,subCategories:o.t3,traditionArtifacts:o.t4,canOnUseEffect:o.t6},(0,o.t0)(o.t1,o.t7),o.abrupt("return",a);case 17:case"end":return o.stop()}}),_callee54,this)}))),function getData(t){return a.apply(this,arguments)})}]),SpecialAbilitySheetDSA5}(H),se=function(t){item_sheet_inherits(ItemSpeciesDSA5,t);var r,a=item_sheet_createSuper(ItemSpeciesDSA5);function ItemSpeciesDSA5(){return item_sheet_classCallCheck(this,ItemSpeciesDSA5),a.apply(this,arguments)}return item_sheet_createClass(ItemSpeciesDSA5,[{key:"getData",value:(r=item_sheet_asyncToGenerator(item_sheet_regeneratorRuntime().mark((function _callee55(t){var r;return item_sheet_regeneratorRuntime().wrap((function _callee55$(a){for(;;)switch(a.prev=a.next){case 0:return a.next=2,item_sheet_get(item_sheet_getPrototypeOf(ItemSpeciesDSA5.prototype),"getData",this).call(this,t);case 2:return r=a.sent,mergeObject(r,{hasLocalization:game.i18n.has("Racedescr.".concat(this.item.name))}),a.abrupt("return",r);case 5:case"end":return a.stop()}}),_callee55,this)}))),function getData(t){return r.apply(this,arguments)})}],[{key:"defaultOptions",get:function get(){var t=item_sheet_get(item_sheet_getPrototypeOf(ItemSpeciesDSA5),"defaultOptions",this);return mergeObject(t,{width:530,height:570}),t}}]),ItemSpeciesDSA5}(H),ue=function(t){item_sheet_inherits(SpellSheetDSA5,t);var a,o,i=item_sheet_createSuper(SpellSheetDSA5);function SpellSheetDSA5(){return item_sheet_classCallCheck(this,SpellSheetDSA5),i.apply(this,arguments)}return item_sheet_createClass(SpellSheetDSA5,[{key:"getData",value:(o=item_sheet_asyncToGenerator(item_sheet_regeneratorRuntime().mark((function _callee56(t){var a,o=this;return item_sheet_regeneratorRuntime().wrap((function _callee56$(i){for(;;)switch(i.prev=i.next){case 0:return i.next=2,item_sheet_get(item_sheet_getPrototypeOf(SpellSheetDSA5.prototype),"getData",this).call(this,t);case 2:return(a=i.sent).characteristics=r.Z.characteristics,a.StFs=r.Z.StFs,a.resistances=r.Z.magicResistanceModifiers,a.targetTypes=r.Z.areaTargetTypes,a.isOwned&&(a.extensions=this.item.actor.items.filter((function(t){return"spellextension"==t.type&&t.system.source==o.item.name&&o.item.type==t.system.category}))),i.abrupt("return",a);case 9:case"end":return i.stop()}}),_callee56,this)}))),function getData(t){return o.apply(this,arguments)})},{key:"activateListeners",value:function activateListeners(t){var r=this;item_sheet_get(item_sheet_getPrototypeOf(SpellSheetDSA5.prototype),"activateListeners",this).call(this,t),t.find(".item-edit").click((function(t){t.preventDefault();var a=r._getItemId(t);r.item.actor.items.get(a).sheet.render(!0)})),t.find(".item-delete").click((function(t){r._deleteItem(t)}))}},{key:"_deleteItem",value:function _deleteItem(t){var r=this,a=this._getItemId(t),o=this.actor.items.find((function(t){return t.id==a})),i=game.i18n.format("DIALOG.DeleteItemDetail",{item:o.name});renderTemplate("systems/dsa5/templates/dialog/delete-item-dialog.html",{message:i}).then((function(o){new Dialog({title:game.i18n.localize("DIALOG.deleteConfirmation"),content:o,buttons:{Yes:{icon:'',label:game.i18n.localize("yes"),callback:function callback(){r._cleverDeleteItem(a),$(t.currentTarget).closest(".item").remove()}},cancel:{icon:'',label:game.i18n.localize("cancel")}},default:"Yes"}).render(!0)}))}},{key:"_cleverDeleteItem",value:(a=item_sheet_asyncToGenerator(item_sheet_regeneratorRuntime().mark((function _callee57(t){var r;return item_sheet_regeneratorRuntime().wrap((function _callee57$(a){for(;;)switch(a.prev=a.next){case 0:return r=this.item.actor.items.find((function(r){return r.id==t})),a.next=3,this.item.actor._updateAPs(-1*r.system.APValue.value,{},{render:!1});case 3:return a.next=5,this.item.actor.deleteEmbeddedDocuments("Item",[t]);case 5:case"end":return a.stop()}}),_callee57,this)}))),function _cleverDeleteItem(t){return a.apply(this,arguments)})}]),SpellSheetDSA5}(H),le=function(t){item_sheet_inherits(SpellExtensionSheetDSA5,t);var r,a=item_sheet_createSuper(SpellExtensionSheetDSA5);function SpellExtensionSheetDSA5(){return item_sheet_classCallCheck(this,SpellExtensionSheetDSA5),a.apply(this,arguments)}return item_sheet_createClass(SpellExtensionSheetDSA5,[{key:"getData",value:(r=item_sheet_asyncToGenerator(item_sheet_regeneratorRuntime().mark((function _callee58(t){var r;return item_sheet_regeneratorRuntime().wrap((function _callee58$(a){for(;;)switch(a.prev=a.next){case 0:return a.next=2,item_sheet_get(item_sheet_getPrototypeOf(SpellExtensionSheetDSA5.prototype),"getData",this).call(this,t);case 2:return r=a.sent,mergeObject(r,{categories:{spell:"spell",liturgy:"liturgy",ritual:"ritual",ceremony:"ceremony"}}),a.abrupt("return",r);case 5:case"end":return a.stop()}}),_callee58,this)}))),function getData(t){return r.apply(this,arguments)})}]),SpellExtensionSheetDSA5}(H),fe=function(t){item_sheet_inherits(VantageSheetDSA5,t);var r,o,i,c=item_sheet_createSuper(VantageSheetDSA5);function VantageSheetDSA5(){return item_sheet_classCallCheck(this,VantageSheetDSA5),c.apply(this,arguments)}return item_sheet_createClass(VantageSheetDSA5,[{key:"_advancable",value:function _advancable(){return this.item.system.max.value>0}},{key:"getData",value:(i=item_sheet_asyncToGenerator(item_sheet_regeneratorRuntime().mark((function _callee59(t){var r;return item_sheet_regeneratorRuntime().wrap((function _callee59$(a){for(;;)switch(a.prev=a.next){case 0:return a.next=2,item_sheet_get(item_sheet_getPrototypeOf(VantageSheetDSA5.prototype),"getData",this).call(this,t);case 2:if(r=a.sent,a.t0=game.user.isGM,a.t0){a.next=8;break}return a.next=7,game.settings.get("dsa5","playerCanEditSpellMacro");case 7:a.t0=a.sent;case 8:return r.canOnUseEffect=a.t0,a.abrupt("return",r);case 10:case"end":return a.stop()}}),_callee59,this)}))),function getData(t){return i.apply(this,arguments)})},{key:"_refundStep",value:(o=item_sheet_asyncToGenerator(item_sheet_regeneratorRuntime().mark((function _callee60(){var t;return item_sheet_regeneratorRuntime().wrap((function _callee60$(r){for(;;)switch(r.prev=r.next){case 0:if(!(this.item.system.step.value>1)){r.next=11;break}return r.next=3,a.Z.stepXPCost(this.item,this.item.system.step.value-1);case 3:return t=r.sent,r.next=6,a.Z.reduceSingularVantages(this.item.actor,this.item,t);case 6:return t=r.sent,r.next=9,this.item.actor._updateAPs(-1*t,{},{render:!1});case 9:return r.next=11,this.item.update({"system.step.value":this.item.system.step.value-1});case 11:case"end":return r.stop()}}),_callee60,this)}))),function _refundStep(){return o.apply(this,arguments)})},{key:"_advanceStep",value:(r=item_sheet_asyncToGenerator(item_sheet_regeneratorRuntime().mark((function _callee61(){var t,r;return item_sheet_regeneratorRuntime().wrap((function _callee61$(o){for(;;)switch(o.prev=o.next){case 0:if(!(this.item.system.step.value=0;--o){var i=this.tryEntries[o],c=i.completion;if("root"===i.tryLoc)return handle("end");if(i.tryLoc<=this.prev){var u=a.call(i,"catchLoc"),l=a.call(i,"finallyLoc");if(u&&l){if(this.prev=0;--o){var i=this.tryEntries[o];if(i.tryLoc<=this.prev&&a.call(i,"finallyLoc")&&this.prev=0;--r){var a=this.tryEntries[r];if(a.finallyLoc===t)return this.complete(a.completion,a.afterLoc),resetTryEntry(a),l}},catch:function _catch(t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc===t){var o=a.completion;if("throw"===o.type){var i=o.arg;resetTryEntry(a)}return i}}throw new Error("illegal catch attempt")},delegateYield:function delegateYield(t,r,a){return this.delegate={iterator:values(t),resultName:r,nextLoc:a},"next"===this.method&&(this.arg=void 0),l}},t}function dicesonice_asyncGeneratorStep(t,r,a,o,i,c,u){try{var l=t[c](u),p=l.value}catch(t){return void a(t)}l.done?r(p):Promise.resolve(p).then(o,i)}function dicesonice_asyncToGenerator(t){return function(){var r=this,a=arguments;return new Promise((function(o,i){var c=t.apply(r,a);function _next(t){dicesonice_asyncGeneratorStep(c,o,i,_next,_throw,"next",t)}function _throw(t){dicesonice_asyncGeneratorStep(c,o,i,_next,_throw,"throw",t)}_next(void 0)}))}}function dicesonice_createForOfIteratorHelper(t,r){var a="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!a){if(Array.isArray(t)||(a=dicesonice_unsupportedIterableToArray(t))||r&&t&&"number"==typeof t.length){a&&(t=a);var o=0,i=function F(){};return{s:i,n:function n(){return o>=t.length?{done:!0}:{done:!1,value:t[o++]}},e:function e(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var c,u=!0,l=!1;return{s:function s(){a=a.call(t)},n:function n(){var t=a.next();return u=t.done,t},e:function e(t){l=!0,c=t},f:function f(){try{u||null==a.return||a.return()}finally{if(l)throw c}}}}function dicesonice_slicedToArray(t,r){return function dicesonice_arrayWithHoles(t){if(Array.isArray(t))return t}(t)||function dicesonice_iterableToArrayLimit(t,r){var a=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null==a)return;var o,i,c=[],u=!0,l=!1;try{for(a=a.call(t);!(u=(o=a.next()).done)&&(c.push(o.value),!r||c.length!==r);u=!0);}catch(t){l=!0,i=t}finally{try{u||null==a.return||a.return()}finally{if(l)throw i}}return c}(t,r)||dicesonice_unsupportedIterableToArray(t,r)||function dicesonice_nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function dicesonice_unsupportedIterableToArray(t,r){if(t){if("string"==typeof t)return dicesonice_arrayLikeToArray(t,r);var a=Object.prototype.toString.call(t).slice(8,-1);return"Object"===a&&t.constructor&&(a=t.constructor.name),"Map"===a||"Set"===a?Array.from(t):"Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a)?dicesonice_arrayLikeToArray(t,r):void 0}}function dicesonice_arrayLikeToArray(t,r){(null==r||r>t.length)&&(r=t.length);for(var a=0,o=new Array(r);a0&&void 0!==arguments[0])||arguments[0],a=new Set,o=dicesonice_createForOfIteratorHelper(DiceSoNiceCustomization.attrs);try{for(o.s();!(t=o.n()).done;){var i=t.value;a.add(game.settings.get("dsa5","dice3d_system_".concat(i)))}}catch(t){o.e(t)}finally{o.f()}a=Array.from(a),r&&this.preloadDiceAssets(a),game.socket.emit("system.dsa5",{type:"preloadDice3d",payload:a})}},{key:"requestDicePreloads",value:function requestDicePreloads(){this.collectPreloads(!1)}},{key:"preloadDiceAssets",value:(a=dicesonice_asyncToGenerator(dicesonice_regeneratorRuntime().mark((function _callee4(t){var r,a,o,i,c,u,l,p,d,h=this,m=arguments;return dicesonice_regeneratorRuntime().wrap((function _callee4$(y){for(;;)switch(y.prev=y.next){case 0:r=m.length>1&&void 0!==m[1]?m[1]:[],console.warn("loading",t),a=dicesonice_createForOfIteratorHelper(t),y.prev=3,a.s();case 5:if((o=a.n()).done){y.next=42;break}if(i=o.value,c=game.dice3d.DiceFactory.systems[i]){y.next=11;break}return this.unloadedModels.push(i),y.abrupt("continue",40);case 11:u=c.dice.filter((function(t){return 0==r.length||r.includes(t.type)})),l=dicesonice_createForOfIteratorHelper(u),y.prev=13,l.s();case 15:if((p=l.n()).done){y.next=32;break}if(d=p.value,y.prev=17,!d.modelFile){y.next=23;break}return y.next=21,d.loadModel(game.dice3d.DiceFactory.loaderGLTF);case 21:y.next=25;break;case 23:return y.next=25,d.loadTextures();case 25:y.next=30;break;case 27:y.prev=27,y.t0=y.catch(17),console.warn("Unable to load dice model",i,d);case 30:y.next=15;break;case 32:y.next=37;break;case 34:y.prev=34,y.t1=y.catch(13),l.e(y.t1);case 37:return y.prev=37,l.f(),y.finish(37);case 40:y.next=5;break;case 42:y.next=47;break;case 44:y.prev=44,y.t2=y.catch(3),a.e(y.t2);case 47:return y.prev=47,a.f(),y.finish(47);case 50:this.unloadedModels.length&&this.retries<6&&!this.retrying&&(this.retrying=!0,setTimeout((function(){h.retries+=1;var t=new Set(h.unloadedModels);h.unloadedModels=[],h.retrying=!1,h.preloadDiceAssets(t)}),1e4));case 51:case"end":return y.stop()}}),_callee4,this,[[3,44,47,50],[13,34,37,40],[17,27]])}))),function preloadDiceAssets(t){return a.apply(this,arguments)})},{key:"defaultOptions",get:function get(){var t=dicesonice_get(dicesonice_getPrototypeOf(DiceSoNiceCustomization),"defaultOptions",this);return mergeObject(t,{template:"systems/dsa5/templates/wizard/dicesonice-configuration.html",title:game.i18n.localize("DSASETTINGS.dicesonicesettings"),width:600}),t}}]),DiceSoNiceCustomization}();dicesonice_defineProperty(de,"unloadedModels",[]),dicesonice_defineProperty(de,"retries",0),dicesonice_defineProperty(de,"retrying",!1),dicesonice_defineProperty(de,"attrs",["mu","kl","in","ch","ff","ge","ko","kk","attack","dodge","parry","damage"]);var he=function(t){dicesonice_inherits(DiceSoNiceForm,FormApplication);var r=dicesonice_createSuper(DiceSoNiceForm);function DiceSoNiceForm(){return dicesonice_classCallCheck(this,DiceSoNiceForm),r.apply(this,arguments)}return dicesonice_createClass(DiceSoNiceForm,[{key:"render",value:function render(){game.dsa5.apps.DiceSoNiceCustomization.render(!0)}}]),DiceSoNiceForm}(),me=__webpack_require__(61);function actor_typeof(t){return actor_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},actor_typeof(t)}function actor_setPrototypeOf(t,r){return actor_setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function _setPrototypeOf(t,r){return t.__proto__=r,t},actor_setPrototypeOf(t,r)}function actor_createSuper(t){var r=function actor_isNativeReflectConstruct(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function _createSuperInternal(){var a,o=actor_getPrototypeOf(t);if(r){var i=actor_getPrototypeOf(this).constructor;a=Reflect.construct(o,arguments,i)}else a=o.apply(this,arguments);return actor_possibleConstructorReturn(this,a)}}function actor_possibleConstructorReturn(t,r){if(r&&("object"===actor_typeof(r)||"function"==typeof r))return r;if(void 0!==r)throw new TypeError("Derived constructors may only return object or undefined");return function actor_assertThisInitialized(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}function actor_getPrototypeOf(t){return actor_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function _getPrototypeOf(t){return t.__proto__||Object.getPrototypeOf(t)},actor_getPrototypeOf(t)}function actor_classCallCheck(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}function actor_defineProperties(t,r){for(var a=0;a=t.length?{done:!0}:{done:!1,value:t[o++]}},e:function e(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var c,u=!0,l=!1;return{s:function s(){a=a.call(t)},n:function n(){var t=a.next();return u=t.done,t},e:function e(t){l=!0,c=t},f:function f(){try{u||null==a.return||a.return()}finally{if(l)throw c}}}}function actor_unsupportedIterableToArray(t,r){if(t){if("string"==typeof t)return actor_arrayLikeToArray(t,r);var a=Object.prototype.toString.call(t).slice(8,-1);return"Object"===a&&t.constructor&&(a=t.constructor.name),"Map"===a||"Set"===a?Array.from(t):"Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a)?actor_arrayLikeToArray(t,r):void 0}}function actor_arrayLikeToArray(t,r){(null==r||r>t.length)&&(r=t.length);for(var a=0,o=new Array(r);a=0;--o){var i=this.tryEntries[o],c=i.completion;if("root"===i.tryLoc)return handle("end");if(i.tryLoc<=this.prev){var u=a.call(i,"catchLoc"),l=a.call(i,"finallyLoc");if(u&&l){if(this.prev=0;--o){var i=this.tryEntries[o];if(i.tryLoc<=this.prev&&a.call(i,"finallyLoc")&&this.prev=0;--r){var a=this.tryEntries[r];if(a.finallyLoc===t)return this.complete(a.completion,a.afterLoc),resetTryEntry(a),l}},catch:function _catch(t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc===t){var o=a.completion;if("throw"===o.type){var i=o.arg;resetTryEntry(a)}return i}}throw new Error("illegal catch attempt")},delegateYield:function delegateYield(t,r,a){return this.delegate={iterator:values(t),resultName:r,nextLoc:a},"next"===this.method&&(this.arg=void 0),l}},t}function actor_asyncGeneratorStep(t,r,a,o,i,c,u){try{var l=t[c](u),p=l.value}catch(t){return void a(t)}l.done?r(p):Promise.resolve(p).then(o,i)}function actor_asyncToGenerator(t){return function(){var r=this,a=arguments;return new Promise((function(o,i){var c=t.apply(r,a);function _next(t){actor_asyncGeneratorStep(c,o,i,_next,_throw,"next",t)}function _throw(t){actor_asyncGeneratorStep(c,o,i,_next,_throw,"throw",t)}_next(void 0)}))}}var ye=function(){function TokenHoverHud(){actor_classCallCheck(this,TokenHoverHud)}return actor_createClass(TokenHoverHud,null,[{key:"show",value:function show(t){var r,a;if(game.combat&&(null===(r=canvas.hud)||void 0===r||null===(a=r.token)||void 0===a||!a.rendered)){var o=t.actor.items.filter((function(t){return("meleeweapon"==t.type||"rangeweapon"==t.type)&&t.system.worn.value}));if(o.length){var i=o.map((function(t){return'')})).join(" "),c=$('
    ').concat(i,"
    "));$("#hud").append(c),this.position(c,t,o.length)}}}},{key:"position",value:function position(t,r,a){var o=r.document,i=canvas.dimensions.size/100,c=43*a,position={width:c,height:42,left:r.center.x-c/2*i,top:r.y+o.height*canvas.dimensions.size+32};1!==i&&(position.transform="scale(".concat(i,")")),t.css(position)}},{key:"hide",value:function hide(t){$("#hoverhud_".concat(t.id)).remove()}}]),TokenHoverHud}(),ge=function(t){!function actor_inherits(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(r&&r.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),r&&actor_setPrototypeOf(t,r)}(AskForNameDialog,Dialog);var r,a=actor_createSuper(AskForNameDialog);function AskForNameDialog(){return actor_classCallCheck(this,AskForNameDialog),a.apply(this,arguments)}return actor_createClass(AskForNameDialog,null,[{key:"getDialog",value:(r=actor_asyncToGenerator(actor_regeneratorRuntime().mark((function _callee9(t,r){return actor_regeneratorRuntime().wrap((function _callee9$(a){for(;;)switch(a.prev=a.next){case 0:new Dialog({title:game.i18n.localize("DSASETTINGS.obfuscateTokenNames"),content:' '),default:"Yes",buttons:{Yes:{icon:'',label:game.i18n.localize("yes"),callback:function(){var a=actor_asyncToGenerator(actor_regeneratorRuntime().mark((function _callee7(a){var o,i,c,u,l,p,d,h,m;return actor_regeneratorRuntime().wrap((function _callee7$(y){for(;;)switch(y.prev=y.next){case 0:if(o=t.id||t._id,i=a.find('[name="name"]').val(),2==r&&(c=canvas.scene.tokens.filter((function(t){return t.name===i})),c.length>0)){u=c.length,l=actor_createForOfIteratorHelper(c);try{for(l.s();!(p=l.n()).done;)d=p.value,(h=d.name.match(/\d+$/))&&Number(h[0])>u&&(u=Number(h[0]))}catch(t){l.e(t)}finally{l.f()}i="".concat(c[0].name.replace(/ \d{1,}$/,"")," ").concat(u+1)}return m=canvas.scene.tokens.get(o),y.next=6,m.update({name:i});case 6:case"end":return y.stop()}}),_callee7)})));return function callback(t){return a.apply(this,arguments)}}()},unknown:{icon:'',label:game.i18n.localize("unknown"),callback:function(){var r=actor_asyncToGenerator(actor_regeneratorRuntime().mark((function _callee8(){var r,a;return actor_regeneratorRuntime().wrap((function _callee8$(o){for(;;)switch(o.prev=o.next){case 0:return r=t.id||t._id,a=canvas.scene.tokens.get(r),o.next=4,a.update({name:game.i18n.localize("unknown")});case 4:case"end":return o.stop()}}),_callee8)})));return function callback(){return r.apply(this,arguments)}}()},cancel:{icon:'',label:game.i18n.localize("cancel")}}}).render(!0);case 1:case"end":return a.stop()}}),_callee9)}))),function getDialog(t,a){return r.apply(this,arguments)})}]),AskForNameDialog}();function createHotBarMacro(t,r,a,o){var i=game.macros.contents.find((function(a){return a.name===r&&a.command===t}));return i?game.user.assignHotbarMacro(i,o):Macro.create({name:r,type:"script",img:a,command:t},{displaySheet:!1}).then((function(t){return game.user.assignHotbarMacro(t,o)})),!1}var ve=__webpack_require__(118);function chatlog_createForOfIteratorHelper(t,r){var a="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!a){if(Array.isArray(t)||(a=function chatlog_unsupportedIterableToArray(t,r){if(!t)return;if("string"==typeof t)return chatlog_arrayLikeToArray(t,r);var a=Object.prototype.toString.call(t).slice(8,-1);"Object"===a&&t.constructor&&(a=t.constructor.name);if("Map"===a||"Set"===a)return Array.from(t);if("Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a))return chatlog_arrayLikeToArray(t,r)}(t))||r&&t&&"number"==typeof t.length){a&&(t=a);var o=0,i=function F(){};return{s:i,n:function n(){return o>=t.length?{done:!0}:{done:!1,value:t[o++]}},e:function e(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var c,u=!0,l=!1;return{s:function s(){a=a.call(t)},n:function n(){var t=a.next();return u=t.done,t},e:function e(t){l=!0,c=t},f:function f(){try{u||null==a.return||a.return()}finally{if(l)throw c}}}}function chatlog_arrayLikeToArray(t,r){(null==r||r>t.length)&&(r=t.length);for(var a=0,o=new Array(r);a').concat(h.results[m].result,""))}}catch(t){d.e(t)}finally{d.f()}var y={content:'
    \n
    \n '.concat(game.i18n.localize("Roll"),": ").concat(p.join(""),'\n
    \n
    \n ').concat(game.i18n.localize("initiative"),": ").concat(Math.floor(100*t.rolls[0]._total)/100,"\n
    \n
    "),flavor:void 0};t.updateSource(y)}}))}function tutorial_typeof(t){return tutorial_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},tutorial_typeof(t)}function tutorial_regeneratorRuntime(){tutorial_regeneratorRuntime=function _regeneratorRuntime(){return t};var t={},r=Object.prototype,a=r.hasOwnProperty,o="function"==typeof Symbol?Symbol:{},i=o.iterator||"@@iterator",c=o.asyncIterator||"@@asyncIterator",u=o.toStringTag||"@@toStringTag";function define(t,r,a){return Object.defineProperty(t,r,{value:a,enumerable:!0,configurable:!0,writable:!0}),t[r]}try{define({},"")}catch(t){define=function define(t,r,a){return t[r]=a}}function wrap(t,r,a,o){var i=r&&r.prototype instanceof Generator?r:Generator,c=Object.create(i.prototype),u=new Context(o||[]);return c._invoke=function(t,r,a){var o="suspendedStart";return function(i,c){if("executing"===o)throw new Error("Generator is already running");if("completed"===o){if("throw"===i)throw c;return doneResult()}for(a.method=i,a.arg=c;;){var u=a.delegate;if(u){var p=maybeInvokeDelegate(u,a);if(p){if(p===l)continue;return p}}if("next"===a.method)a.sent=a._sent=a.arg;else if("throw"===a.method){if("suspendedStart"===o)throw o="completed",a.arg;a.dispatchException(a.arg)}else"return"===a.method&&a.abrupt("return",a.arg);o="executing";var d=tryCatch(t,r,a);if("normal"===d.type){if(o=a.done?"completed":"suspendedYield",d.arg===l)continue;return{value:d.arg,done:a.done}}"throw"===d.type&&(o="completed",a.method="throw",a.arg=d.arg)}}}(t,a,u),c}function tryCatch(t,r,a){try{return{type:"normal",arg:t.call(r,a)}}catch(t){return{type:"throw",arg:t}}}t.wrap=wrap;var l={};function Generator(){}function GeneratorFunction(){}function GeneratorFunctionPrototype(){}var p={};define(p,i,(function(){return this}));var d=Object.getPrototypeOf,h=d&&d(d(values([])));h&&h!==r&&a.call(h,i)&&(p=h);var m=GeneratorFunctionPrototype.prototype=Generator.prototype=Object.create(p);function defineIteratorMethods(t){["next","throw","return"].forEach((function(r){define(t,r,(function(t){return this._invoke(r,t)}))}))}function AsyncIterator(t,r){function invoke(o,i,c,u){var l=tryCatch(t[o],t,i);if("throw"!==l.type){var p=l.arg,d=p.value;return d&&"object"==tutorial_typeof(d)&&a.call(d,"__await")?r.resolve(d.__await).then((function(t){invoke("next",t,c,u)}),(function(t){invoke("throw",t,c,u)})):r.resolve(d).then((function(t){p.value=t,c(p)}),(function(t){return invoke("throw",t,c,u)}))}u(l.arg)}var o;this._invoke=function(t,a){function callInvokeWithMethodAndArg(){return new r((function(r,o){invoke(t,a,r,o)}))}return o=o?o.then(callInvokeWithMethodAndArg,callInvokeWithMethodAndArg):callInvokeWithMethodAndArg()}}function maybeInvokeDelegate(t,r){var a=t.iterator[r.method];if(void 0===a){if(r.delegate=null,"throw"===r.method){if(t.iterator.return&&(r.method="return",r.arg=void 0,maybeInvokeDelegate(t,r),"throw"===r.method))return l;r.method="throw",r.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var o=tryCatch(a,t.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,l;var i=o.arg;return i?i.done?(r[t.resultName]=i.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=void 0),r.delegate=null,l):i:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,l)}function pushTryEntry(t){var r={tryLoc:t[0]};1 in t&&(r.catchLoc=t[1]),2 in t&&(r.finallyLoc=t[2],r.afterLoc=t[3]),this.tryEntries.push(r)}function resetTryEntry(t){var r=t.completion||{};r.type="normal",delete r.arg,t.completion=r}function Context(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(pushTryEntry,this),this.reset(!0)}function values(t){if(t){var r=t[i];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var o=-1,c=function next(){for(;++o=0;--o){var i=this.tryEntries[o],c=i.completion;if("root"===i.tryLoc)return handle("end");if(i.tryLoc<=this.prev){var u=a.call(i,"catchLoc"),l=a.call(i,"finallyLoc");if(u&&l){if(this.prev=0;--o){var i=this.tryEntries[o];if(i.tryLoc<=this.prev&&a.call(i,"finallyLoc")&&this.prev=0;--r){var a=this.tryEntries[r];if(a.finallyLoc===t)return this.complete(a.completion,a.afterLoc),resetTryEntry(a),l}},catch:function _catch(t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc===t){var o=a.completion;if("throw"===o.type){var i=o.arg;resetTryEntry(a)}return i}}throw new Error("illegal catch attempt")},delegateYield:function delegateYield(t,r,a){return this.delegate={iterator:values(t),resultName:r,nextLoc:a},"next"===this.method&&(this.arg=void 0),l}},t}function tutorial_asyncGeneratorStep(t,r,a,o,i,c,u){try{var l=t[c](u),p=l.value}catch(t){return void a(t)}l.done?r(p):Promise.resolve(p).then(o,i)}function tutorial_asyncToGenerator(t){return function(){var r=this,a=arguments;return new Promise((function(o,i){var c=t.apply(r,a);function _next(t){tutorial_asyncGeneratorStep(c,o,i,_next,_throw,"next",t)}function _throw(t){tutorial_asyncGeneratorStep(c,o,i,_next,_throw,"throw",t)}_next(void 0)}))}}function tutorial_defineProperties(t,r){for(var a=0;a=0;--o){var i=this.tryEntries[o],c=i.completion;if("root"===i.tryLoc)return handle("end");if(i.tryLoc<=this.prev){var u=a.call(i,"catchLoc"),l=a.call(i,"finallyLoc");if(u&&l){if(this.prev=0;--o){var i=this.tryEntries[o];if(i.tryLoc<=this.prev&&a.call(i,"finallyLoc")&&this.prev=0;--r){var a=this.tryEntries[r];if(a.finallyLoc===t)return this.complete(a.completion,a.afterLoc),resetTryEntry(a),l}},catch:function _catch(t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc===t){var o=a.completion;if("throw"===o.type){var i=o.arg;resetTryEntry(a)}return i}}throw new Error("illegal catch attempt")},delegateYield:function delegateYield(t,r,a){return this.delegate={iterator:values(t),resultName:r,nextLoc:a},"next"===this.method&&(this.arg=void 0),l}},t}function merchantmixin_createForOfIteratorHelper(t,r){var a="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!a){if(Array.isArray(t)||(a=merchantmixin_unsupportedIterableToArray(t))||r&&t&&"number"==typeof t.length){a&&(t=a);var o=0,i=function F(){};return{s:i,n:function n(){return o>=t.length?{done:!0}:{done:!1,value:t[o++]}},e:function e(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var c,u=!0,l=!1;return{s:function s(){a=a.call(t)},n:function n(){var t=a.next();return u=t.done,t},e:function e(t){l=!0,c=t},f:function f(){try{u||null==a.return||a.return()}finally{if(l)throw c}}}}function merchantmixin_unsupportedIterableToArray(t,r){if(t){if("string"==typeof t)return merchantmixin_arrayLikeToArray(t,r);var a=Object.prototype.toString.call(t).slice(8,-1);return"Object"===a&&t.constructor&&(a=t.constructor.name),"Map"===a||"Set"===a?Array.from(t):"Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a)?merchantmixin_arrayLikeToArray(t,r):void 0}}function merchantmixin_arrayLikeToArray(t,r){(null==r||r>t.length)&&(r=t.length);for(var a=0,o=new Array(r);a3&&void 0!==l[3])||l[3],i=this._getItemId(a),c=a.currentTarget.dataset.price,u=a.ctrlKey?10:1,!game.user.isGM){p.next=9;break}return p.next=7,this.constructor.finishTransaction(t,r,c,i,o,u);case 7:p.next=10;break;case 9:(this.constructor.noNeedToPay(r,t,c)||w.canPay(r,c,!0))&&game.socket.emit("system.dsa5",{type:"trade",payload:{target:this.constructor.transferTokenData(r),source:this.constructor.transferTokenData(t),price:c,itemId:i,buy:o,amount:u}});case 10:case"end":return p.stop()}}),_callee12,this)}))),function transferItem(t,r,a){return A.apply(this,arguments)})},{key:"getTradeFriend",value:function getTradeFriend(){return this.otherTradeFriend||game.user.character}},{key:"_manageDragItems",value:(T=merchantmixin_asyncToGenerator(merchantmixin_regeneratorRuntime().mark((function _callee13(t,r){return merchantmixin_regeneratorRuntime().wrap((function _callee13$(a){for(;;)switch(a.prev=a.next){case 0:a.t0=r,a.next="creature"===a.t0||"npc"===a.t0||"character"===a.t0?3:5;break;case 3:return this.setTradeFriend(t),a.abrupt("break",6);case 5:return a.abrupt("return",merchantmixin_get(merchantmixin_getPrototypeOf(_class.prototype),"_manageDragItems",this).call(this,t,r));case 6:case"end":return a.stop()}}),_callee13,this)}))),function _manageDragItems(t,r){return T.apply(this,arguments)})},{key:"_onDropActor",value:(S=merchantmixin_asyncToGenerator(merchantmixin_regeneratorRuntime().mark((function _callee14(t,r){var a,o,i,c,u;return merchantmixin_regeneratorRuntime().wrap((function _callee14$(t){for(;;)switch(t.prev=t.next){case 0:if(a=this.actor.limited,o=this.actor.isOwner,a||o){t.next=4;break}return t.abrupt("return",!1);case 4:return t.next=6,(0,h.x8)(r,this.id,!1);case 6:if(i=t.sent,c=i.item,u=i.typeClass,!i.selfTarget){t.next=12;break}return t.abrupt("return");case 12:if(!(o||a&&"Actor"==c.documentName)){t.next=16;break}return t.next=15,this._manageDragItems(c,u);case 15:return t.abrupt("return",t.sent);case 16:case"end":return t.stop()}}),_callee14,this)}))),function _onDropActor(t,r){return S.apply(this,arguments)})},{key:"setTradeFriend",value:function setTradeFriend(t){var r=game.actors.get(t._id);r.isOwner&&(this.otherTradeFriend=r,this.render(!0))}},{key:"_render",value:(x=merchantmixin_asyncToGenerator(merchantmixin_regeneratorRuntime().mark((function _callee15(){var t,r,a=arguments;return merchantmixin_regeneratorRuntime().wrap((function _callee15$(o){for(;;)switch(o.prev=o.next){case 0:if(t=a.length>0&&void 0!==a[0]&&a[0],r=a.length>1&&void 0!==a[1]?a[1]:{},game.user.isGM||"loot"!=getProperty(this.actor.system,"merchant.merchantType")||!getProperty(this.actor.system,"merchant.locked")){o.next=5;break}return AudioHelper.play({src:"sounds/lock.wav",loop:!1},!1),o.abrupt("return");case 5:return o.next=7,merchantmixin_get(merchantmixin_getPrototypeOf(_class.prototype),"_render",this).call(this,t,r);case 7:case"end":return o.stop()}}),_callee15,this)}))),function _render(){return x.apply(this,arguments)})},{key:"_togglePlayerview",value:function _togglePlayerview(t){this.actor.update({"system.merchant.playerView":!getProperty(this.actor.system,"merchant.playerView")})}},{key:"playerViewEnabled",value:function playerViewEnabled(){return getProperty(this.actor.system,"merchant.playerView")}},{key:"randomGoods",value:(k=merchantmixin_asyncToGenerator(merchantmixin_regeneratorRuntime().mark((function _callee16(t){var a,o=this;return merchantmixin_regeneratorRuntime().wrap((function _callee16$(i){for(;;)switch(i.prev=i.next){case 0:return i.next=2,renderTemplate("systems/dsa5/templates/dialog/randomGoods-dialog.html",{categories:r.Z.equipmentCategories});case 2:a=i.sent,new Dialog({title:game.i18n.localize("MERCHANT.randomGoods"),content:a,default:"yes",buttons:{Yes:{icon:'',label:game.i18n.localize("yes"),callback:function callback(r){return o.addRandomGoods(o.actor,r,t)}},cancel:{icon:'',label:game.i18n.localize("cancel")}}}).render(!0);case 4:case"end":return i.stop()}}),_callee16)}))),function randomGoods(t){return k.apply(this,arguments)})},{key:"clearInventory",value:(b=merchantmixin_asyncToGenerator(merchantmixin_regeneratorRuntime().mark((function _callee17(t){var r=this;return merchantmixin_regeneratorRuntime().wrap((function _callee17$(a){for(;;)switch(a.prev=a.next){case 0:new Dialog({title:game.i18n.localize("MERCHANT.clearInventory"),content:game.i18n.localize("MERCHANT.deleteAllGoods"),default:"yes",buttons:{Yes:{icon:'',label:game.i18n.localize("yes"),callback:function callback(){r.removeAllGoods(r.actor,t)}},cancel:{icon:'',label:game.i18n.localize("cancel")}}}).render(!0);case 1:case"end":return a.stop()}}),_callee17)}))),function clearInventory(t){return b.apply(this,arguments)})},{key:"addRandomGoods",value:(_=merchantmixin_asyncToGenerator(merchantmixin_regeneratorRuntime().mark((function _callee18(t,r,a){var o,i,c,u,l,p,d,h;return merchantmixin_regeneratorRuntime().wrap((function _callee18$(m){for(;;)switch(m.prev=m.next){case 0:if(o=$(a.currentTarget).text(),$(a.currentTarget).html(' '),i=[],r.find('input[type="checkbox"]:checked').each((function(){var t=$(this).val();i.push({name:t,count:Number(r.find('input[name="each_'.concat(t,'"]')).val()),number:Number(r.find('input[name="number_'.concat(t,'"]')).val())})})),(c=game.dsa5.itemLibrary).equipmentBuild){m.next=8;break}return m.next=8,c.buildEquipmentIndex();case 8:u=[],l=merchantmixin_regeneratorRuntime().mark((function _loop(){var t,r,a;return merchantmixin_regeneratorRuntime().wrap((function _loop$(o){for(;;)switch(o.prev=o.next){case 0:return r=d[p],o.next=3,c.getRandomItems(r.name,r.number);case 3:a=o.sent.map((function(t){var a=t.toObject();return a.system.quantity.value=r.count,a})),(t=u).push.apply(t,merchantmixin_toConsumableArray(a));case 5:case"end":return o.stop()}}),_loop)})),p=0,d=i;case 11:if(!(p1e4)return!1;var i="".concat(r.type,"_").concat(r.name);return!h.hasOwnProperty(i)&&(h[i]=!0)&&0==t.items.filter((function(t){return t.type==r.type&&t.name==r.name})).length})),m.next=20,t.createEmbeddedDocuments("Item",u);case 20:$(a.currentTarget).text(o);case 21:case"end":return m.stop()}}),_callee18)}))),function addRandomGoods(t,r,a){return _.apply(this,arguments)})},{key:"removeAllGoods",value:(v=merchantmixin_asyncToGenerator(merchantmixin_regeneratorRuntime().mark((function _callee19(t,a){var o,i;return merchantmixin_regeneratorRuntime().wrap((function _callee19$(c){for(;;)switch(c.prev=c.next){case 0:return o=$(a.currentTarget).text(),$(a.currentTarget).html(' '),i=t.items.filter((function(t){return r.Z.equipmentCategories.includes(t.type)&&!getProperty(t,"worn.value")})).map((function(t){return t.id})),c.next=5,t.deleteEmbeddedDocuments("Item",i);case 5:$(a.currentTarget).text(o);case 6:case"end":return c.stop()}}),_callee19)}))),function removeAllGoods(t,r){return v.apply(this,arguments)})},{key:"getData",value:(g=merchantmixin_asyncToGenerator(merchantmixin_regeneratorRuntime().mark((function _callee20(t){var r,a=this;return merchantmixin_regeneratorRuntime().wrap((function _callee20$(o){for(;;)switch(o.prev=o.next){case 0:return o.next=2,merchantmixin_get(merchantmixin_getPrototypeOf(_class.prototype),"getData",this).call(this,t);case 2:return(r=o.sent).merchantType=getProperty(this.actor.system,"merchant.merchantType")||"none",r.merchantTypes={none:game.i18n.localize("MERCHANT.typeNone"),merchant:game.i18n.localize("MERCHANT.typeMerchant"),loot:game.i18n.localize("MERCHANT.typeLoot"),epic:game.i18n.localize("MERCHANT.typeEpic")},r.invName=r.merchantTypes[r.merchantType],r.players=game.users.filter((function(t){return!t.isGM})).map((function(t){return t.allowedMerchant=a.actor.testUserPermission(t,"LIMITED",!1),t.buyingFactor=getProperty(a.actor.system,"merchant.factors.buyingFactor.".concat(t.id)),t.sellingFactor=getProperty(a.actor.system,"merchant.factors.sellingFactor.".concat(t.id)),t})),"epic"!=r.merchantType?(this.prepareStorage(r),this.merchantSheetActivated()&&(this.filterWornEquipment(r),this.prepareTradeFriend(r),0==r.prepare.inventory.misc.items.length&&(r.prepare.inventory.misc.show=!1))):(this.prepareStorage(r),r.garadanOptions={1:game.i18n.localize("GARADAN.1"),2:game.i18n.localize("GARADAN.2"),3:game.i18n.localize("GARADAN.3"),4:game.i18n.localize("GARADAN.4"),6:game.i18n.localize("GARADAN.6")}),r.hasOtherTradeFriend=!!this.otherTradeFriend,o.abrupt("return",r);case 10:case"end":return o.stop()}}),_callee20,this)}))),function getData(t){return g.apply(this,arguments)})},{key:"filterWornEquipment",value:function filterWornEquipment(t){for(var r=0,a=Object.entries(t.prepare.inventory);r0)){p.next=29;break}if(l=this.noNeedToPay(r,t,a),p.t0=l,p.t0){p.next=9;break}return p.next=8,w.payMoney(r,a,!0);case 8:p.t0=p.sent;case 9:if(!p.t0){p.next=29;break}if(getProperty(u,"system.worn.value")&&(u.system.worn.value=!1),!i){p.next=23;break}return p.next=15,this.updateTargetTransaction(r,u,c,t,a);case 15:return p.next=17,this.updateSourceTransaction(t,r,u,a,o,c);case 17:return p.next=19,this.transferNotification(u,r,t,i,a,c,l);case 19:return p.next=21,this.selfDestruction(t);case 21:p.next=29;break;case 23:return p.next=25,this.updateSourceTransaction(t,r,u,a,o,c);case 25:return p.next=27,this.updateTargetTransaction(r,u,c,t,a);case 27:return p.next=29,this.transferNotification(u,t,r,i,a,c,l);case 29:case"end":return p.stop()}}),_callee21,this)}))),function finishTransaction(t,r,a,o,i,c){return d.apply(this,arguments)})},{key:"isTemporaryToken",value:function isTemporaryToken(t){return"loot"==getProperty(t.system,"merchant.merchantType")&&getProperty(t.system,"merchant.temporary")}},{key:"selfDestruction",value:(p=merchantmixin_asyncToGenerator(merchantmixin_regeneratorRuntime().mark((function _callee22(t){var a;return merchantmixin_regeneratorRuntime().wrap((function _callee22$(o){for(;;)switch(o.prev=o.next){case 0:if(!this.isTemporaryToken(t)){o.next=10;break}if(t.items.some((function(t){return r.Z.equipmentCategories.includes(t.type)||"money"==t.type&&t.system.quantity.value>0}))){o.next=10;break}return game.socket.emit("system.dsa5",{type:"hideDeletedSheet",payload:{target:this.transferTokenData(t)}}),a=t.getActiveTokens().map((function(t){return t.id})),o.next=7,canvas.scene.deleteEmbeddedDocuments("Token",a);case 7:return o.next=9,game.actors.get(t.id).delete();case 9:this.hideDeletedSheet(t);case 10:case"end":return o.stop()}}),_callee22,this)}))),function selfDestruction(t){return p.apply(this,arguments)})},{key:"hideDeletedSheet",value:(l=merchantmixin_asyncToGenerator(merchantmixin_regeneratorRuntime().mark((function _callee23(t){return merchantmixin_regeneratorRuntime().wrap((function _callee23$(r){for(;;)switch(r.prev=r.next){case 0:t.sheet.close(!0);case 1:case"end":return r.stop()}}),_callee23)}))),function hideDeletedSheet(t){return l.apply(this,arguments)})},{key:"transferNotification",value:(u=merchantmixin_asyncToGenerator(merchantmixin_regeneratorRuntime().mark((function _callee24(r,a,o,i,c,u,l){var p,d,h,m;return merchantmixin_regeneratorRuntime().wrap((function _callee24$(y){for(;;)switch(y.prev=y.next){case 0:if(0!=(p=game.settings.get("dsa5","merchantNotification"))&&"service"!=getProperty(r,"system.equipmentType.value")){y.next=3;break}return y.abrupt("return");case 3:return d="MERCHANT."+(i?"buy":"sell")+(l?"Loot":"")+"Notification",h=game.i18n.format(d,{item:r.name,source:a.name,target:o.name,amount:u,price:c,buy:i}),m=t.Z.chatDataSetup(h),2==p&&(m.whisper=ChatMessage.getWhisperRecipients("GM").map((function(t){return t.id}))),y.next=9,ChatMessage.create(m);case 9:case"end":return y.stop()}}),_callee24)}))),function transferNotification(t,r,a,o,i,c,l){return u.apply(this,arguments)})},{key:"noNeedToPay",value:function noNeedToPay(t,r,a){return 0==a||"loot"==getProperty(t.system,"merchant.merchantType")||"loot"==getProperty(r.system,"merchant.merchantType")}},{key:"updateSourceTransaction",value:(c=merchantmixin_asyncToGenerator(merchantmixin_regeneratorRuntime().mark((function _callee25(t,r,a,o,i,c){var u;return merchantmixin_regeneratorRuntime().wrap((function _callee25$(l){for(;;)switch(l.prev=l.next){case 0:if(u=duplicate(a),!(Number(u.system.quantity.value)>c||"money"==u.type)){l.next=7;break}return u.system.quantity.value=Number(u.system.quantity.value)-c,l.next=5,t.updateEmbeddedDocuments("Item",[u]);case 5:l.next=9;break;case 7:return l.next=9,t.deleteEmbeddedDocuments("Item",[i]);case 9:if(this.noNeedToPay(t,r,o)){l.next=12;break}return l.next=12,w.getMoney(t,o,!0);case 12:case"end":return l.stop()}}),_callee25,this)}))),function updateSourceTransaction(t,r,a,o,i,u){return c.apply(this,arguments)})},{key:"updateTargetTransaction",value:(i=merchantmixin_asyncToGenerator(merchantmixin_regeneratorRuntime().mark((function _callee26(r,a,i,c,u){var l,p,d;return merchantmixin_regeneratorRuntime().wrap((function _callee26$(h){for(;;)switch(h.prev=h.next){case 0:if(l=duplicate(a),"service"!=getProperty(l,"system.equipmentType.value")){h.next=7;break}p=game.i18n.format("MERCHANT.buyNotification",{item:l.name,amount:i,source:r.name,target:c.name,price:u}),ChatMessage.create(t.Z.chatDataSetup(p)),h.next=16;break;case 7:if(d=r.items.find((function(t){return o.Z.areEquals(l,t)})),l.system.quantity.value=i,d){h.next=14;break}return h.next=12,r.createEmbeddedDocuments("Item",[l]);case 12:h.next=16;break;case 14:return h.next=16,o.Z.stackItems(d,l,r);case 16:case"end":return h.stop()}}),_callee26)}))),function updateTargetTransaction(t,r,a,o,c){return i.apply(this,arguments)})}]),_class}(a)},ke=function(t){merchantmixin_inherits(SelectTradefriendDialog,Dialog);var r,a=merchantmixin_createSuper(SelectTradefriendDialog);function SelectTradefriendDialog(){return merchantmixin_classCallCheck(this,SelectTradefriendDialog),a.apply(this,arguments)}return merchantmixin_createClass(SelectTradefriendDialog,[{key:"activateListeners",value:function activateListeners(t){var r=this;merchantmixin_get(merchantmixin_getPrototypeOf(SelectTradefriendDialog.prototype),"activateListeners",this).call(this,t),t.find(".combatant").click((function(t){return r.setTargetToUser(t)}))}},{key:"setTargetToUser",value:function setTargetToUser(t){this.actor.setTradeFriend({_id:t.currentTarget.dataset.id}),this.close()}}],[{key:"defaultOptions",get:function get(){var t=merchantmixin_get(merchantmixin_getPrototypeOf(SelectTradefriendDialog),"defaultOptions",this);return mergeObject(t,{}),t}},{key:"getDialog",value:(r=merchantmixin_asyncToGenerator(merchantmixin_regeneratorRuntime().mark((function _callee27(t){var r,a;return merchantmixin_regeneratorRuntime().wrap((function _callee27$(o){for(;;)switch(o.prev=o.next){case 0:if(!game.user.isGM){o.next=6;break}return o.next=3,game.dsa5.apps.gameMasterMenu.getTrackedHeros();case 3:o.t0=o.sent,o.next=7;break;case 6:o.t0=game.actors.filter((function(t){return t.isOwner}));case 7:return r=o.t0,o.t1=SelectTradefriendDialog,o.t2=game.i18n.localize("DIALOG.setTargetToUser"),o.next=12,renderTemplate("systems/dsa5/templates/dialog/selectTradeFriend.html",{users:r});case 12:return o.t3=o.sent,o.t4={},o.t5={title:o.t2,content:o.t3,default:"yes",buttons:o.t4},(a=new o.t1(o.t5)).actor=t,o.abrupt("return",a);case 18:case"end":return o.stop()}}),_callee27)}))),function getDialog(t){return r.apply(this,arguments)})}]),SelectTradefriendDialog}();function merchant_sheet_typeof(t){return merchant_sheet_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},merchant_sheet_typeof(t)}function merchant_sheet_defineProperties(t,r){for(var a=0;a=0;--o){var i=this.tryEntries[o],c=i.completion;if("root"===i.tryLoc)return handle("end");if(i.tryLoc<=this.prev){var u=a.call(i,"catchLoc"),l=a.call(i,"finallyLoc");if(u&&l){if(this.prev=0;--o){var i=this.tryEntries[o];if(i.tryLoc<=this.prev&&a.call(i,"finallyLoc")&&this.prev=0;--r){var a=this.tryEntries[r];if(a.finallyLoc===t)return this.complete(a.completion,a.afterLoc),resetTryEntry(a),l}},catch:function _catch(t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc===t){var o=a.completion;if("throw"===o.type){var i=o.arg;resetTryEntry(a)}return i}}throw new Error("illegal catch attempt")},delegateYield:function delegateYield(t,r,a){return this.delegate={iterator:values(t),resultName:r,nextLoc:a},"next"===this.method&&(this.arg=void 0),l}},t}function player_menu_subapps_asyncGeneratorStep(t,r,a,o,i,c,u){try{var l=t[c](u),p=l.value}catch(t){return void a(t)}l.done?r(p):Promise.resolve(p).then(o,i)}function player_menu_subapps_asyncToGenerator(t){return function(){var r=this,a=arguments;return new Promise((function(o,i){var c=t.apply(r,a);function _next(t){player_menu_subapps_asyncGeneratorStep(c,o,i,_next,_throw,"next",t)}function _throw(t){player_menu_subapps_asyncGeneratorStep(c,o,i,_next,_throw,"throw",t)}_next(void 0)}))}}function player_menu_subapps_defineProperties(t,r){for(var a=0;a=0;--o){var i=this.tryEntries[o],c=i.completion;if("root"===i.tryLoc)return handle("end");if(i.tryLoc<=this.prev){var u=a.call(i,"catchLoc"),l=a.call(i,"finallyLoc");if(u&&l){if(this.prev=0;--o){var i=this.tryEntries[o];if(i.tryLoc<=this.prev&&a.call(i,"finallyLoc")&&this.prev=0;--r){var a=this.tryEntries[r];if(a.finallyLoc===t)return this.complete(a.completion,a.afterLoc),resetTryEntry(a),l}},catch:function _catch(t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc===t){var o=a.completion;if("throw"===o.type){var i=o.arg;resetTryEntry(a)}return i}}throw new Error("illegal catch attempt")},delegateYield:function delegateYield(t,r,a){return this.delegate={iterator:values(t),resultName:r,nextLoc:a},"next"===this.method&&(this.arg=void 0),l}},t}function player_menu_createForOfIteratorHelper(t,r){var a="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!a){if(Array.isArray(t)||(a=player_menu_unsupportedIterableToArray(t))||r&&t&&"number"==typeof t.length){a&&(t=a);var o=0,i=function F(){};return{s:i,n:function n(){return o>=t.length?{done:!0}:{done:!1,value:t[o++]}},e:function e(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var c,u=!0,l=!1;return{s:function s(){a=a.call(t)},n:function n(){var t=a.next();return u=t.done,t},e:function e(t){l=!0,c=t},f:function f(){try{u||null==a.return||a.return()}finally{if(l)throw c}}}}function player_menu_unsupportedIterableToArray(t,r){if(t){if("string"==typeof t)return player_menu_arrayLikeToArray(t,r);var a=Object.prototype.toString.call(t).slice(8,-1);return"Object"===a&&t.constructor&&(a=t.constructor.name),"Map"===a||"Set"===a?Array.from(t):"Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a)?player_menu_arrayLikeToArray(t,r):void 0}}function player_menu_arrayLikeToArray(t,r){(null==r||r>t.length)&&(r=t.length);for(var a=0,o=new Array(r);a
    '),a.next=3,game.dsa5.itemLibrary.buildEquipmentIndex();case 3:r.render();case 4:case"end":return a.stop()}}),_callee3)})));return function(r){return t.apply(this,arguments)}}()),t.find(".item-edit").click((function(t){var a=$(t.currentTarget).closest(".item").attr("data-item-id");r.actor.items.get(a).sheet.render(!0)})),t.find(".selectableRow").click((function(t){return r.selectImprovement(t)})),t.find(".finalizeConjuration").click((function(){return r.finalizeConjuration()})),t.find(".ruleLink").click((function(t){return r.openRules(t)})),t.find(".openChar").click((function(){var t;null===(t=r.actor)||void 0===t||t.sheet.render(!0)})),t.find(".showEntity").click((function(t){t.stopPropagation();var r=function(){var r=player_menu_asyncToGenerator(player_menu_regeneratorRuntime().mark((function _callee4(){return player_menu_regeneratorRuntime().wrap((function _callee4$(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,fromUuid(t.currentTarget.dataset.uuid);case 2:r.sent.sheet.render(!0);case 3:case"end":return r.stop()}}),_callee4)})));return function fun(){return r.apply(this,arguments)}}();r()})),t.find(".moreModifiers").change((function(t){r.conjurationData.moreModifiers[r.conjurationData.conjurationType].find((function(r){return r.name==t.currentTarget.dataset.name})).selected=$(t.currentTarget).val()}));var a,o=player_menu_createForOfIteratorHelper(this.subApps);try{for(o.s();!(a=o.n()).done;){a.value.activateListeners(t)}}catch(t){o.e(t)}finally{o.f()}}},{key:"openRules",value:(c=player_menu_asyncToGenerator(player_menu_regeneratorRuntime().mark((function _callee6(t){var r,a,o;return player_menu_regeneratorRuntime().wrap((function _callee6$(i){for(;;)switch(i.prev=i.next){case 0:r=t.currentTarget.dataset.subapp,a=(r?this.subApps.find((function(t){return t.constructor.name==r})).constructor.rulePath:this.conjurationData.rules[this.conjurationData.conjurationType])[game.i18n.lang],o=function(){var t=player_menu_asyncToGenerator(player_menu_regeneratorRuntime().mark((function _callee5(){var t,r,o,i;return player_menu_regeneratorRuntime().wrap((function _callee5$(c){for(;;)switch(c.prev=c.next){case 0:return t=game.packs.get(a.pack),c.next=3,t.getDocuments({name:a.name});case 3:r=c.sent,o=player_menu_createForOfIteratorHelper(r);try{for(o.s();!(i=o.n()).done;)i.value.sheet.render(!0)}catch(t){o.e(t)}finally{o.f()}case 6:case"end":return c.stop()}}),_callee5)})));return function fun(){return t.apply(this,arguments)}}(),o();case 4:case"end":return i.stop()}}),_callee6,this)}))),function openRules(t){return c.apply(this,arguments)})},{key:"finalizeConjuration",value:function finalizeConjuration(){var t=this;if(this.conjurationData){if(!this.conjuration)return ui.notifications.warn(game.i18n.localize("DSAError.noConjurationActive"));var r,a=[],o=player_menu_createForOfIteratorHelper(this.conjurationData.selectedIds);try{var i=function _loop(){var o=r.value;a.push(t.conjurationData.modifiers[t.conjurationData.conjurationType].find((function(t){return t.id==o})))};for(o.s();!(r=o.n()).done;)i()}catch(t){o.e(t)}finally{o.f()}var c={source:this.conjuration.toObject(),creationData:{type:this.conjurationData.conjurationType,typeName:this.conjurationData.conjurationTypes[this.conjurationData.conjurationType],qs:this.conjurationData.qs,consumedQS:this.conjurationData.consumedQS,modifiers:a,entityIds:this.conjurationData.selectedEntityIds,packageIds:this.conjurationData.selectedPackageIds},summoner:{name:this.actor.name,img:this.actor.img}};game.user.isGM?PlayerMenu.createConjuration(c):(game.socket.emit("system.dsa5",{type:"summonCreature",payload:c}),ui.notifications.notify(game.i18n.localize("CONJURATION.requestSend")))}}},{key:"selectImprovement",value:function selectImprovement(t){var r=Number(t.currentTarget.dataset.max)||1,a=Number(t.currentTarget.dataset.selected)||0;a>=r?$(t.currentTarget).removeClass("selected"):($(t.currentTarget).addClass("selected"),t.currentTarget.dataset.selected=a+1);var o=[],i=[],c=[],u=0,l=0;$(this._element).find(".selectableRow.selected").each((function(t,r){for(var a=0;a0)){d.next=37;break}if(this.conjuration=a,this.conjurationData.selectedIds=[],this.conjurationData.selectedEntityIds=[],this.conjurationData.selectedPackageIds=[],"creature"!=a.type){d.next=35;break}o=0,i=Object.keys(this.conjurationData.conjurationTypes);case 27:if(!(o1&&(r.system.step={value:l[t.uuid]}),r})),S.next=18,Promise.all(this.creationData.packageIds.map((function(t){return fromUuid(t)})));case 18:if(h=S.sent.map((function(t){return t.toObject(!1)})),this.conjuration.effects.push({changes:[],duration:{},icon:"icons/svg/aura.svg",id:"services",name:game.i18n.localize("PLAYER.services"),flags:{dsa5:{value:o,editable:!0,max:500,description:"".concat(game.i18n.localize("PLAYER.conjuration")," ").concat(game.i18n.localize("PLAYER.services")),manual:o,auto:0,hideOnToken:!0,hidePlayers:!1}}}),!game.dsa5.apps.playerMenu.conjurationData.postFunction[this.creationData.type]){S.next=23;break}return S.next=23,game.dsa5.apps.playerMenu.conjurationData.postFunction[this.creationData.type](this.conjuration,this.creationData.qs-this.creationData.consumedQS,this.creationData.type);case 23:return"creature"!=this.conjuration.type||this.conjuration.system.creatureClass.value.includes(this.creationData.typeName)||(this.conjuration.system.creatureClass.value+=", ".concat(this.creationData.typeName)),S.next=26,d.Z.create(this.conjuration);case 26:return this.actor=S.sent,m=[].concat(player_menu_toConsumableArray(p),player_menu_toConsumableArray(h)).filter((function(t){return!x.conjuration.items.find((function(r){return r.type==t.type&&t.name==r.name}))})),S.next=30,this.actor.createEmbeddedDocuments("Item",m);case 30:y=player_menu_createForOfIteratorHelper(h),S.prev=31,y.s();case 33:if((g=y.n()).done){S.next=39;break}return v=g.value,S.next=37,R.Z.traitAdded(this.actor,v);case 37:S.next=33;break;case 39:S.next=44;break;case 41:S.prev=41,S.t0=S.catch(31),y.e(S.t0);case 44:return S.prev=44,y.f(),S.finish(44);case 47:_=player_menu_createForOfIteratorHelper(p),S.prev=48,_.s();case 50:if((b=_.n()).done){S.next=56;break}return k=b.value,S.next=54,R.Z.traitAdded(this.actor,k);case 54:S.next=50;break;case 56:S.next=61;break;case 58:S.prev=58,S.t1=S.catch(48),_.e(S.t1);case 61:return S.prev=61,_.f(),S.finish(61);case 64:return S.next=66,this.actor.update({"system.status.wounds.value":this.actor.system.status.wounds.max});case 66:return S.next=68,renderTemplate("systems/dsa5/templates/system/conjuration/chat.html",{actor:this.actor,modifiers:this.creationData.modifiers,summoner:this.summoner,summonerImg:N.Z.videoOrImgTag(this.summoner.img),conjureImg:N.Z.videoOrImgTag(this.actor.img),services:o});case 68:return w=S.sent,S.next=71,ChatMessage.create(t.Z.chatDataSetup(w));case 71:this.render();case 72:case"end":return S.stop()}}),_callee13,this,[[31,41,44,47],[48,58,61,64]])}))),function createActor(){return a.apply(this,arguments)})},{key:"activateListeners",value:function activateListeners(t){var r=this;player_menu_get(player_menu_getPrototypeOf(ConjurationRequest.prototype),"activateListeners",this).call(this,t),t.find(".createActor").click((function(){r.createActor()})),t.on("mousedown",".newNPC",function(){var t=player_menu_asyncToGenerator(player_menu_regeneratorRuntime().mark((function _callee14(t){var r;return player_menu_regeneratorRuntime().wrap((function _callee14$(a){for(;;)switch(a.prev=a.next){case 0:r=t.currentTarget.dataset.id,2==t.button&&(game.actors.get(r).delete(),$(t.currentTarget).remove());case 2:case"end":return a.stop()}}),_callee14)})));return function(r){return t.apply(this,arguments)}}()),t.on("click",".newNPC",function(){var t=player_menu_asyncToGenerator(player_menu_regeneratorRuntime().mark((function _callee15(t){var r;return player_menu_regeneratorRuntime().wrap((function _callee15$(a){for(;;)switch(a.prev=a.next){case 0:r=t.currentTarget.dataset.id,game.actors.get(r).sheet.render(!0);case 2:case"end":return a.stop()}}),_callee15)})));return function(r){return t.apply(this,arguments)}}()),t.on("dragstart",".newNPC",(function(t){t.stopPropagation();var r={type:"Actor",uuid:t.currentTarget.dataset.uuid};t.originalEvent.dataTransfer.setData("text/plain",JSON.stringify(r))})),t.find(".showEntity").click((function(t){t.stopPropagation();var r=function(){var r=player_menu_asyncToGenerator(player_menu_regeneratorRuntime().mark((function _callee16(){return player_menu_regeneratorRuntime().wrap((function _callee16$(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,fromUuid(t.currentTarget.dataset.uuid);case 2:r.sent.sheet.render(!0);case 3:case"end":return r.stop()}}),_callee16)})));return function fun(){return r.apply(this,arguments)}}();r()}))}}],[{key:"defaultOptions",get:function get(){var t=player_menu_get(player_menu_getPrototypeOf(ConjurationRequest),"defaultOptions",this);return t.tabs=[{navSelector:".tabs",contentSelector:".content",initial:"main"}],mergeObject(t,{classes:t.classes.concat(["dsa5","largeDialog"]),width:470}),t.template="systems/dsa5/templates/system/conjuration/request.html",t}}]),ConjurationRequest}(xe.Z),Oe=__webpack_require__(903);function itemDrop_typeof(t){return itemDrop_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},itemDrop_typeof(t)}function itemDrop_classCallCheck(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}function itemDrop_defineProperties(t,r){for(var a=0;a=t.length?{done:!0}:{done:!1,value:t[o++]}},e:function e(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var c,u=!0,l=!1;return{s:function s(){a=a.call(t)},n:function n(){var t=a.next();return u=t.done,t},e:function e(t){l=!0,c=t},f:function f(){try{u||null==a.return||a.return()}finally{if(l)throw c}}}}function itemDrop_regeneratorRuntime(){itemDrop_regeneratorRuntime=function _regeneratorRuntime(){return t};var t={},r=Object.prototype,a=r.hasOwnProperty,o="function"==typeof Symbol?Symbol:{},i=o.iterator||"@@iterator",c=o.asyncIterator||"@@asyncIterator",u=o.toStringTag||"@@toStringTag";function define(t,r,a){return Object.defineProperty(t,r,{value:a,enumerable:!0,configurable:!0,writable:!0}),t[r]}try{define({},"")}catch(t){define=function define(t,r,a){return t[r]=a}}function wrap(t,r,a,o){var i=r&&r.prototype instanceof Generator?r:Generator,c=Object.create(i.prototype),u=new Context(o||[]);return c._invoke=function(t,r,a){var o="suspendedStart";return function(i,c){if("executing"===o)throw new Error("Generator is already running");if("completed"===o){if("throw"===i)throw c;return doneResult()}for(a.method=i,a.arg=c;;){var u=a.delegate;if(u){var p=maybeInvokeDelegate(u,a);if(p){if(p===l)continue;return p}}if("next"===a.method)a.sent=a._sent=a.arg;else if("throw"===a.method){if("suspendedStart"===o)throw o="completed",a.arg;a.dispatchException(a.arg)}else"return"===a.method&&a.abrupt("return",a.arg);o="executing";var d=tryCatch(t,r,a);if("normal"===d.type){if(o=a.done?"completed":"suspendedYield",d.arg===l)continue;return{value:d.arg,done:a.done}}"throw"===d.type&&(o="completed",a.method="throw",a.arg=d.arg)}}}(t,a,u),c}function tryCatch(t,r,a){try{return{type:"normal",arg:t.call(r,a)}}catch(t){return{type:"throw",arg:t}}}t.wrap=wrap;var l={};function Generator(){}function GeneratorFunction(){}function GeneratorFunctionPrototype(){}var p={};define(p,i,(function(){return this}));var d=Object.getPrototypeOf,h=d&&d(d(values([])));h&&h!==r&&a.call(h,i)&&(p=h);var m=GeneratorFunctionPrototype.prototype=Generator.prototype=Object.create(p);function defineIteratorMethods(t){["next","throw","return"].forEach((function(r){define(t,r,(function(t){return this._invoke(r,t)}))}))}function AsyncIterator(t,r){function invoke(o,i,c,u){var l=tryCatch(t[o],t,i);if("throw"!==l.type){var p=l.arg,d=p.value;return d&&"object"==itemDrop_typeof(d)&&a.call(d,"__await")?r.resolve(d.__await).then((function(t){invoke("next",t,c,u)}),(function(t){invoke("throw",t,c,u)})):r.resolve(d).then((function(t){p.value=t,c(p)}),(function(t){return invoke("throw",t,c,u)}))}u(l.arg)}var o;this._invoke=function(t,a){function callInvokeWithMethodAndArg(){return new r((function(r,o){invoke(t,a,r,o)}))}return o=o?o.then(callInvokeWithMethodAndArg,callInvokeWithMethodAndArg):callInvokeWithMethodAndArg()}}function maybeInvokeDelegate(t,r){var a=t.iterator[r.method];if(void 0===a){if(r.delegate=null,"throw"===r.method){if(t.iterator.return&&(r.method="return",r.arg=void 0,maybeInvokeDelegate(t,r),"throw"===r.method))return l;r.method="throw",r.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var o=tryCatch(a,t.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,l;var i=o.arg;return i?i.done?(r[t.resultName]=i.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=void 0),r.delegate=null,l):i:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,l)}function pushTryEntry(t){var r={tryLoc:t[0]};1 in t&&(r.catchLoc=t[1]),2 in t&&(r.finallyLoc=t[2],r.afterLoc=t[3]),this.tryEntries.push(r)}function resetTryEntry(t){var r=t.completion||{};r.type="normal",delete r.arg,t.completion=r}function Context(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(pushTryEntry,this),this.reset(!0)}function values(t){if(t){var r=t[i];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var o=-1,c=function next(){for(;++o=0;--o){var i=this.tryEntries[o],c=i.completion;if("root"===i.tryLoc)return handle("end");if(i.tryLoc<=this.prev){var u=a.call(i,"catchLoc"),l=a.call(i,"finallyLoc");if(u&&l){if(this.prev=0;--o){var i=this.tryEntries[o];if(i.tryLoc<=this.prev&&a.call(i,"finallyLoc")&&this.prev=0;--r){var a=this.tryEntries[r];if(a.finallyLoc===t)return this.complete(a.completion,a.afterLoc),resetTryEntry(a),l}},catch:function _catch(t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc===t){var o=a.completion;if("throw"===o.type){var i=o.arg;resetTryEntry(a)}return i}}throw new Error("illegal catch attempt")},delegateYield:function delegateYield(t,r,a){return this.delegate={iterator:values(t),resultName:r,nextLoc:a},"next"===this.method&&(this.arg=void 0),l}},t}function itemDrop_toConsumableArray(t){return function itemDrop_arrayWithoutHoles(t){if(Array.isArray(t))return itemDrop_arrayLikeToArray(t)}(t)||function itemDrop_iterableToArray(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||itemDrop_unsupportedIterableToArray(t)||function itemDrop_nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function itemDrop_unsupportedIterableToArray(t,r){if(t){if("string"==typeof t)return itemDrop_arrayLikeToArray(t,r);var a=Object.prototype.toString.call(t).slice(8,-1);return"Object"===a&&t.constructor&&(a=t.constructor.name),"Map"===a||"Set"===a?Array.from(t):"Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a)?itemDrop_arrayLikeToArray(t,r):void 0}}function itemDrop_arrayLikeToArray(t,r){(null==r||r>t.length)&&(r=t.length);for(var a=0,o=new Array(r);a
    ',label:game.i18n.localize("yes"),callback:function(){var t=itemDrop_asyncToGenerator(itemDrop_regeneratorRuntime().mark((function _callee2(t){return itemDrop_regeneratorRuntime().wrap((function _callee2$(r){for(;;)switch(r.prev=r.next){case 0:return r.abrupt("return",Pe(i,o,a,Number(t.find('[name="count"]').val())));case 1:case"end":return r.stop()}}),_callee2)})));return function callback(r){return t.apply(this,arguments)}}()},cancel:{icon:'',label:game.i18n.localize("cancel")}}}).render(!0);case 10:case"end":return t.stop()}}),_callee3)})));return function handleItemDrop(r,a){return t.apply(this,arguments)}}(),Ce=function(){var t=itemDrop_asyncToGenerator(itemDrop_regeneratorRuntime().mark((function _callee4(t,r){var a,o,i,c,u,l,p,d,h,m;return itemDrop_regeneratorRuntime().wrap((function _callee4$(y){for(;;)switch(y.prev=y.next){case 0:a=r.x,o=r.y,i=0,c=t.grid.size,u=Math.ceil(Math.sqrt(r.ids.length)),l=itemDrop_createForOfIteratorHelper(r.ids),y.prev=6,l.s();case 8:if((p=l.n()).done){y.next=21;break}if(d=p.value,h=game.actors.get(d)){y.next=13;break}return y.abrupt("continue",19);case 13:return y.next=15,h.getTokenDocument({x:a,y:o,hidden:!1});case 15:(m=y.sent).constructor.create(m,{parent:t.scene}),u%i==0&&i>0?(o+=c,a=r.x):a+=c,i++;case 19:y.next=8;break;case 21:y.next=26;break;case 23:y.prev=23,y.t0=y.catch(6),l.e(y.t0);case 26:return y.prev=26,l.f(),y.finish(26);case 29:case"end":return y.stop()}}),_callee4,null,[[6,23,26,29]])})));return function handleGroupDrop(r,a){return t.apply(this,arguments)}}(),De=function connectHook(){Hooks.on("dropCanvasData",function(){var t=itemDrop_asyncToGenerator(itemDrop_regeneratorRuntime().mark((function _callee5(t,r){return itemDrop_regeneratorRuntime().wrap((function _callee5$(a){for(;;)switch(a.prev=a.next){case 0:if(game.settings.get("dsa5","enableItemDropToCanvas")||game.user.isGM||r.tokenId){a.next=2;break}return a.abrupt("return");case 2:if("Item"!=r.type){a.next=7;break}return Ee(t,r),a.abrupt("return",!1);case 7:if("GroupDrop"!=r.type){a.next=10;break}return Ce(t,r),a.abrupt("return",!1);case 10:case"end":return a.stop()}}),_callee5)})));return function(r,a){return t.apply(this,arguments)}}())},Ie=function(t){!function itemDrop_inherits(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(r&&r.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),r&&itemDrop_setPrototypeOf(t,r)}(DropToGroundDialog,Dialog);var r=itemDrop_createSuper(DropToGroundDialog);function DropToGroundDialog(){return itemDrop_classCallCheck(this,DropToGroundDialog),r.apply(this,arguments)}return function itemDrop_createClass(t,r,a){return r&&itemDrop_defineProperties(t.prototype,r),a&&itemDrop_defineProperties(t,a),Object.defineProperty(t,"prototype",{writable:!1}),t}(DropToGroundDialog,[{key:"activateListeners",value:function activateListeners(t){itemDrop_get(itemDrop_getPrototypeOf(DropToGroundDialog.prototype),"activateListeners",this).call(this,t),t.find('input[type="range"]').change((function(t){$(t.currentTarget).closest(".row-section").find(".range-value").html($(t.currentTarget).val())}))}}]),DropToGroundDialog}(),Re=__webpack_require__(846);function didyouknow_typeof(t){return didyouknow_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},didyouknow_typeof(t)}function didyouknow_regeneratorRuntime(){didyouknow_regeneratorRuntime=function _regeneratorRuntime(){return t};var t={},r=Object.prototype,a=r.hasOwnProperty,o="function"==typeof Symbol?Symbol:{},i=o.iterator||"@@iterator",c=o.asyncIterator||"@@asyncIterator",u=o.toStringTag||"@@toStringTag";function define(t,r,a){return Object.defineProperty(t,r,{value:a,enumerable:!0,configurable:!0,writable:!0}),t[r]}try{define({},"")}catch(t){define=function define(t,r,a){return t[r]=a}}function wrap(t,r,a,o){var i=r&&r.prototype instanceof Generator?r:Generator,c=Object.create(i.prototype),u=new Context(o||[]);return c._invoke=function(t,r,a){var o="suspendedStart";return function(i,c){if("executing"===o)throw new Error("Generator is already running");if("completed"===o){if("throw"===i)throw c;return doneResult()}for(a.method=i,a.arg=c;;){var u=a.delegate;if(u){var p=maybeInvokeDelegate(u,a);if(p){if(p===l)continue;return p}}if("next"===a.method)a.sent=a._sent=a.arg;else if("throw"===a.method){if("suspendedStart"===o)throw o="completed",a.arg;a.dispatchException(a.arg)}else"return"===a.method&&a.abrupt("return",a.arg);o="executing";var d=tryCatch(t,r,a);if("normal"===d.type){if(o=a.done?"completed":"suspendedYield",d.arg===l)continue;return{value:d.arg,done:a.done}}"throw"===d.type&&(o="completed",a.method="throw",a.arg=d.arg)}}}(t,a,u),c}function tryCatch(t,r,a){try{return{type:"normal",arg:t.call(r,a)}}catch(t){return{type:"throw",arg:t}}}t.wrap=wrap;var l={};function Generator(){}function GeneratorFunction(){}function GeneratorFunctionPrototype(){}var p={};define(p,i,(function(){return this}));var d=Object.getPrototypeOf,h=d&&d(d(values([])));h&&h!==r&&a.call(h,i)&&(p=h);var m=GeneratorFunctionPrototype.prototype=Generator.prototype=Object.create(p);function defineIteratorMethods(t){["next","throw","return"].forEach((function(r){define(t,r,(function(t){return this._invoke(r,t)}))}))}function AsyncIterator(t,r){function invoke(o,i,c,u){var l=tryCatch(t[o],t,i);if("throw"!==l.type){var p=l.arg,d=p.value;return d&&"object"==didyouknow_typeof(d)&&a.call(d,"__await")?r.resolve(d.__await).then((function(t){invoke("next",t,c,u)}),(function(t){invoke("throw",t,c,u)})):r.resolve(d).then((function(t){p.value=t,c(p)}),(function(t){return invoke("throw",t,c,u)}))}u(l.arg)}var o;this._invoke=function(t,a){function callInvokeWithMethodAndArg(){return new r((function(r,o){invoke(t,a,r,o)}))}return o=o?o.then(callInvokeWithMethodAndArg,callInvokeWithMethodAndArg):callInvokeWithMethodAndArg()}}function maybeInvokeDelegate(t,r){var a=t.iterator[r.method];if(void 0===a){if(r.delegate=null,"throw"===r.method){if(t.iterator.return&&(r.method="return",r.arg=void 0,maybeInvokeDelegate(t,r),"throw"===r.method))return l;r.method="throw",r.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var o=tryCatch(a,t.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,l;var i=o.arg;return i?i.done?(r[t.resultName]=i.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=void 0),r.delegate=null,l):i:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,l)}function pushTryEntry(t){var r={tryLoc:t[0]};1 in t&&(r.catchLoc=t[1]),2 in t&&(r.finallyLoc=t[2],r.afterLoc=t[3]),this.tryEntries.push(r)}function resetTryEntry(t){var r=t.completion||{};r.type="normal",delete r.arg,t.completion=r}function Context(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(pushTryEntry,this),this.reset(!0)}function values(t){if(t){var r=t[i];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var o=-1,c=function next(){for(;++o=0;--o){var i=this.tryEntries[o],c=i.completion;if("root"===i.tryLoc)return handle("end");if(i.tryLoc<=this.prev){var u=a.call(i,"catchLoc"),l=a.call(i,"finallyLoc");if(u&&l){if(this.prev=0;--o){var i=this.tryEntries[o];if(i.tryLoc<=this.prev&&a.call(i,"finallyLoc")&&this.prev=0;--r){var a=this.tryEntries[r];if(a.finallyLoc===t)return this.complete(a.completion,a.afterLoc),resetTryEntry(a),l}},catch:function _catch(t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc===t){var o=a.completion;if("throw"===o.type){var i=o.arg;resetTryEntry(a)}return i}}throw new Error("illegal catch attempt")},delegateYield:function delegateYield(t,r,a){return this.delegate={iterator:values(t),resultName:r,nextLoc:a},"next"===this.method&&(this.arg=void 0),l}},t}function didyouknow_asyncGeneratorStep(t,r,a,o,i,c,u){try{var l=t[c](u),p=l.value}catch(t){return void a(t)}l.done?r(p):Promise.resolve(p).then(o,i)}function didyouknow_asyncToGenerator(t){return function(){var r=this,a=arguments;return new Promise((function(o,i){var c=t.apply(r,a);function _next(t){didyouknow_asyncGeneratorStep(c,o,i,_next,_throw,"next",t)}function _throw(t){didyouknow_asyncGeneratorStep(c,o,i,_next,_throw,"throw",t)}_next(void 0)}))}}function didyouknow_defineProperties(t,r){for(var a=0;a0&&void 0!==a[0]?a[0]:8e3,!game.settings.get("dsa5","disableDidYouKnow")){o.next=3;break}return o.abrupt("return");case 3:fetch("systems/dsa5/lazy/didyouknow/".concat(game.i18n.lang,".json")).then(function(){var t=didyouknow_asyncToGenerator(didyouknow_regeneratorRuntime().mark((function _callee5(t){return didyouknow_regeneratorRuntime().wrap((function _callee5$(r){for(;;)switch(r.prev=r.next){case 0:return r.abrupt("return",t.json());case 1:case"end":return r.stop()}}),_callee5)})));return function(r){return t.apply(this,arguments)}}()).then(function(){var a=didyouknow_asyncToGenerator(didyouknow_regeneratorRuntime().mark((function _callee6(a){var o,i;return didyouknow_regeneratorRuntime().wrap((function _callee6$(c){for(;;)switch(c.prev=c.next){case 0:return o=a.data[Math.floor(Math.random()*a.data.length)],c.next=3,renderTemplate("systems/dsa5/templates/system/didyouknow.html",{msg:o,fadeOut:DidYouKnow.fadeOut});case 3:i=c.sent,$("body").append(i),r.activateListeners(),setTimeout((function(){DidYouKnow.fadeOut&&$(".didYouKnow").fadeOut(1e3,(function(){return $(".didYouKnow").remove()}))}),t);case 7:case"end":return c.stop()}}),_callee6)})));return function(t){return a.apply(this,arguments)}}());case 4:case"end":return o.stop()}}),_callee7)}))),function showOneMessage(){return t.apply(this,arguments)})}]),DidYouKnow}();function combat_tracker_typeof(t){return combat_tracker_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},combat_tracker_typeof(t)}function combat_tracker_toConsumableArray(t){return function combat_tracker_arrayWithoutHoles(t){if(Array.isArray(t))return combat_tracker_arrayLikeToArray(t)}(t)||function combat_tracker_iterableToArray(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||combat_tracker_unsupportedIterableToArray(t)||function combat_tracker_nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function combat_tracker_regeneratorRuntime(){combat_tracker_regeneratorRuntime=function _regeneratorRuntime(){return t};var t={},r=Object.prototype,a=r.hasOwnProperty,o="function"==typeof Symbol?Symbol:{},i=o.iterator||"@@iterator",c=o.asyncIterator||"@@asyncIterator",u=o.toStringTag||"@@toStringTag";function define(t,r,a){return Object.defineProperty(t,r,{value:a,enumerable:!0,configurable:!0,writable:!0}),t[r]}try{define({},"")}catch(t){define=function define(t,r,a){return t[r]=a}}function wrap(t,r,a,o){var i=r&&r.prototype instanceof Generator?r:Generator,c=Object.create(i.prototype),u=new Context(o||[]);return c._invoke=function(t,r,a){var o="suspendedStart";return function(i,c){if("executing"===o)throw new Error("Generator is already running");if("completed"===o){if("throw"===i)throw c;return doneResult()}for(a.method=i,a.arg=c;;){var u=a.delegate;if(u){var p=maybeInvokeDelegate(u,a);if(p){if(p===l)continue;return p}}if("next"===a.method)a.sent=a._sent=a.arg;else if("throw"===a.method){if("suspendedStart"===o)throw o="completed",a.arg;a.dispatchException(a.arg)}else"return"===a.method&&a.abrupt("return",a.arg);o="executing";var d=tryCatch(t,r,a);if("normal"===d.type){if(o=a.done?"completed":"suspendedYield",d.arg===l)continue;return{value:d.arg,done:a.done}}"throw"===d.type&&(o="completed",a.method="throw",a.arg=d.arg)}}}(t,a,u),c}function tryCatch(t,r,a){try{return{type:"normal",arg:t.call(r,a)}}catch(t){return{type:"throw",arg:t}}}t.wrap=wrap;var l={};function Generator(){}function GeneratorFunction(){}function GeneratorFunctionPrototype(){}var p={};define(p,i,(function(){return this}));var d=Object.getPrototypeOf,h=d&&d(d(values([])));h&&h!==r&&a.call(h,i)&&(p=h);var m=GeneratorFunctionPrototype.prototype=Generator.prototype=Object.create(p);function defineIteratorMethods(t){["next","throw","return"].forEach((function(r){define(t,r,(function(t){return this._invoke(r,t)}))}))}function AsyncIterator(t,r){function invoke(o,i,c,u){var l=tryCatch(t[o],t,i);if("throw"!==l.type){var p=l.arg,d=p.value;return d&&"object"==combat_tracker_typeof(d)&&a.call(d,"__await")?r.resolve(d.__await).then((function(t){invoke("next",t,c,u)}),(function(t){invoke("throw",t,c,u)})):r.resolve(d).then((function(t){p.value=t,c(p)}),(function(t){return invoke("throw",t,c,u)}))}u(l.arg)}var o;this._invoke=function(t,a){function callInvokeWithMethodAndArg(){return new r((function(r,o){invoke(t,a,r,o)}))}return o=o?o.then(callInvokeWithMethodAndArg,callInvokeWithMethodAndArg):callInvokeWithMethodAndArg()}}function maybeInvokeDelegate(t,r){var a=t.iterator[r.method];if(void 0===a){if(r.delegate=null,"throw"===r.method){if(t.iterator.return&&(r.method="return",r.arg=void 0,maybeInvokeDelegate(t,r),"throw"===r.method))return l;r.method="throw",r.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var o=tryCatch(a,t.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,l;var i=o.arg;return i?i.done?(r[t.resultName]=i.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=void 0),r.delegate=null,l):i:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,l)}function pushTryEntry(t){var r={tryLoc:t[0]};1 in t&&(r.catchLoc=t[1]),2 in t&&(r.finallyLoc=t[2],r.afterLoc=t[3]),this.tryEntries.push(r)}function resetTryEntry(t){var r=t.completion||{};r.type="normal",delete r.arg,t.completion=r}function Context(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(pushTryEntry,this),this.reset(!0)}function values(t){if(t){var r=t[i];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var o=-1,c=function next(){for(;++o=0;--o){var i=this.tryEntries[o],c=i.completion;if("root"===i.tryLoc)return handle("end");if(i.tryLoc<=this.prev){var u=a.call(i,"catchLoc"),l=a.call(i,"finallyLoc");if(u&&l){if(this.prev=0;--o){var i=this.tryEntries[o];if(i.tryLoc<=this.prev&&a.call(i,"finallyLoc")&&this.prev=0;--r){var a=this.tryEntries[r];if(a.finallyLoc===t)return this.complete(a.completion,a.afterLoc),resetTryEntry(a),l}},catch:function _catch(t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc===t){var o=a.completion;if("throw"===o.type){var i=o.arg;resetTryEntry(a)}return i}}throw new Error("illegal catch attempt")},delegateYield:function delegateYield(t,r,a){return this.delegate={iterator:values(t),resultName:r,nextLoc:a},"next"===this.method&&(this.arg=void 0),l}},t}function combat_tracker_createForOfIteratorHelper(t,r){var a="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!a){if(Array.isArray(t)||(a=combat_tracker_unsupportedIterableToArray(t))||r&&t&&"number"==typeof t.length){a&&(t=a);var o=0,i=function F(){};return{s:i,n:function n(){return o>=t.length?{done:!0}:{done:!1,value:t[o++]}},e:function e(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var c,u=!0,l=!1;return{s:function s(){a=a.call(t)},n:function n(){var t=a.next();return u=t.done,t},e:function e(t){l=!0,c=t},f:function f(){try{u||null==a.return||a.return()}finally{if(l)throw c}}}}function combat_tracker_unsupportedIterableToArray(t,r){if(t){if("string"==typeof t)return combat_tracker_arrayLikeToArray(t,r);var a=Object.prototype.toString.call(t).slice(8,-1);return"Object"===a&&t.constructor&&(a=t.constructor.name),"Map"===a||"Set"===a?Array.from(t):"Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a)?combat_tracker_arrayLikeToArray(t,r):void 0}}function combat_tracker_arrayLikeToArray(t,r){(null==r||r>t.length)&&(r=t.length);for(var a=0,o=new Array(r);a0){var h={name:p.name,remaining:d.Z.calcLZ(p,a.actor)-p.system.reloadTime.progress};h.remaining>0&&c.push(h)}else if(["spell","liturgy"].includes(p.type)&&p.system.castingTime.modified>0){var m={name:p.name,remaining:p.system.castingTime.modified-p.system.castingTime.progress};m.remaining>0&&c.push(m)}}}catch(t){l.e(t)}finally{l.f()}}(c=c.sort((function(t,r){return t.remaining-r.remaining}))).length>0&&(t.ongoings="".concat(game.i18n.localize("COMBATTRACKER.ongoing"),"
    ").concat(c.map((function(t){return"".concat(t.name," - ").concat(t.remaining)})).join("
    ")),t.ongoing=c[0].remaining),t.effects=new Set,a.token&&(a.token.effects.forEach((function(r){return t.effects.add(r)})),a.token.overlayEffect&&t.effects.add(a.token.overlayEffect)),a.actor&&a.actor.temporaryEffects.forEach((function(r){r.statuses.has(CONFIG.Combat.defeatedStatusId)?t.defeated=!0:!r.icon||!i||r.notApplicable||!game.user.isGM&&r.getFlag("dsa5","hidePlayers")||r.getFlag("dsa5","hideOnToken")||t.effects.add(r.icon)}))},a.s();!(o=a.n()).done;)i()}catch(t){a.e(t)}finally{a.f()}return c.abrupt("return",r);case 6:case"end":return c.stop()}}),_callee,this)}))),function getData(t){return r.apply(this,arguments)})}],[{key:"defaultOptions",get:function get(){return foundry.utils.mergeObject(combat_tracker_get(combat_tracker_getPrototypeOf(DSA5CombatTracker),"defaultOptions",this),{template:"/systems/dsa5/templates/system/combattracker.html"})}},{key:"runActAttackDialog",value:function runActAttackDialog(){if(game.combat){var t=game.combat.combatant;(game.user.isGM||t.isOwner)&&ve.HS.showDialog(t.actor,t.tokenId)}}}]),DSA5CombatTracker}(),Me=function(t){combat_tracker_inherits(DSA5Combat,Combat);var r,a,o,i,c=combat_tracker_createSuper(DSA5Combat);function DSA5Combat(t,r){return combat_tracker_classCallCheck(this,DSA5Combat),c.call(this,t,r)}return combat_tracker_createClass(DSA5Combat,[{key:"refreshTokenbars",value:(i=combat_tracker_asyncToGenerator(combat_tracker_regeneratorRuntime().mark((function _callee2(){return combat_tracker_regeneratorRuntime().wrap((function _callee2$(t){for(;;)switch(t.prev=t.next){case 0:game.dsa5.apps.tokenHotbar&&game.dsa5.apps.tokenHotbar.updateDSA5Hotbar();case 1:case"end":return t.stop()}}),_callee2)}))),function refreshTokenbars(){return i.apply(this,arguments)})},{key:"_onCreate",value:function _onCreate(t,r,a){combat_tracker_get(combat_tracker_getPrototypeOf(DSA5Combat.prototype),"_onCreate",this).call(this,t,r,a),this.refreshTokenbars()}},{key:"_onDelete",value:function _onDelete(t,r){combat_tracker_get(combat_tracker_getPrototypeOf(DSA5Combat.prototype),"_onDelete",this).call(this,t,r),this.refreshTokenbars()}},{key:"nextRound",value:(o=combat_tracker_asyncToGenerator(combat_tracker_regeneratorRuntime().mark((function _callee3(){var t,r,a;return combat_tracker_regeneratorRuntime().wrap((function _callee3$(o){for(;;)switch(o.prev=o.next){case 0:if(!game.user.isGM){o.next=20;break}t=combat_tracker_createForOfIteratorHelper(this.turns),o.prev=2,t.s();case 4:if((r=t.n()).done){o.next=10;break}return a=r.value,o.next=8,a.setFlag("dsa5","defenseCount",0);case 8:o.next=4;break;case 10:o.next=15;break;case 12:o.prev=12,o.t0=o.catch(2),t.e(o.t0);case 15:return o.prev=15,t.f(),o.finish(15);case 18:o.next=22;break;case 20:return o.next=22,game.socket.emit("system.dsa5",{type:"clearCombat",payload:{}});case 22:return o.next=24,combat_tracker_get(combat_tracker_getPrototypeOf(DSA5Combat.prototype),"nextRound",this).call(this);case 24:return o.abrupt("return",o.sent);case 25:case"end":return o.stop()}}),_callee3,this,[[2,12,15,18]])}))),function nextRound(){return o.apply(this,arguments)})},{key:"getDefenseCount",value:(a=combat_tracker_asyncToGenerator(combat_tracker_regeneratorRuntime().mark((function _callee4(t){var r;return combat_tracker_regeneratorRuntime().wrap((function _callee4$(a){for(;;)switch(a.prev=a.next){case 0:return r=this.getCombatantFromActor(t),a.abrupt("return",r&&r.getFlag("dsa5","defenseCount")||0);case 2:case"end":return a.stop()}}),_callee4,this)}))),function getDefenseCount(t){return a.apply(this,arguments)})},{key:"getCombatantFromActor",value:function getCombatantFromActor(t){var r;return(r=t.token?Array.from(this.combatants).find((function(r){return r.tokenId==t.token})):Array.from(this.combatants).find((function(r){return r.actorId==t.actor})))?this.combatants.get(r.id):void 0}},{key:"updateDefenseCount",value:(r=combat_tracker_asyncToGenerator(combat_tracker_regeneratorRuntime().mark((function _callee5(t){var r;return combat_tracker_regeneratorRuntime().wrap((function _callee5$(a){for(;;)switch(a.prev=a.next){case 0:if(!game.user.isGM){a.next=7;break}if(!(r=this.getCombatantFromActor(t))||getProperty(r.actor,"system.config.defense")){a.next=5;break}return a.next=5,r.setFlag("dsa5","defenseCount",(r.getFlag("dsa5","defenseCount")||0)+1);case 5:a.next=9;break;case 7:return a.next=9,game.socket.emit("system.dsa5",{type:"updateDefenseCount",payload:{speaker:t}});case 9:case"end":return a.stop()}}),_callee5,this)}))),function updateDefenseCount(t){return r.apply(this,arguments)})}]),DSA5Combat}(),je=function(t){combat_tracker_inherits(DSA5Combatant,Combatant);var r,a=combat_tracker_createSuper(DSA5Combatant);function DSA5Combatant(t,r){return combat_tracker_classCallCheck(this,DSA5Combatant),null==t.flags&&(t.flags={}),mergeObject(t.flags,{dsa5:{defenseCount:0}}),a.call(this,t,r)}return combat_tracker_createClass(DSA5Combatant,[{key:"recalcInitiative",value:(r=combat_tracker_asyncToGenerator(combat_tracker_regeneratorRuntime().mark((function _callee6(){var t,r;return combat_tracker_regeneratorRuntime().wrap((function _callee6$(a){for(;;)switch(a.prev=a.next){case 0:if(!this.initiative){a.next=10;break}return a.next=3,this.getFlag("dsa5","baseRoll");case 3:if(a.t0=a.sent,a.t0){a.next=6;break}a.t0=0;case 6:return t=a.t0,r={initiative:t+this.actor.system.status.initiative.value},a.next=10,this.update(r);case 10:case"end":return a.stop()}}),_callee6,this)}))),function recalcInitiative(){return r.apply(this,arguments)})}]),DSA5Combatant}();Hooks.on("preCreateCombatant",(function(r,a,o){var i=t.Z.getSpeaker({actor:r.actorId,scene:r.sceneId,token:r.token_id});if("loot"==getProperty(i.system,"merchant.merchantType"))return!1})),Hooks.on("updateCombatant",(function(t,r,a){if(game.user.isGM)if(r.initiative){if(!t.getFlag("dsa5","baseRoll")){var o="".concat(r.initiative).split("."),i=Number(o[0])-Math.round(t.actor.system.status.initiative.value);t.setFlag("dsa5","baseRoll",i)}}else"initiative"in r&&null==r.initiative&&t.update(function combat_tracker_defineProperty(t,r,a){return r in t?Object.defineProperty(t,r,{value:a,enumerable:!0,configurable:!0,writable:!0}):t[r]=a,t}({},"flags.dsa5.-=baseRoll",null))}));var Fe=function(){function RepeatingEffectsHelper(){combat_tracker_classCallCheck(this,RepeatingEffectsHelper)}var r,a,o,i,c,l;return combat_tracker_createClass(RepeatingEffectsHelper,null,[{key:"updateCombatHook",value:(l=combat_tracker_asyncToGenerator(combat_tracker_regeneratorRuntime().mark((function _callee7(t,r,a,o){return combat_tracker_regeneratorRuntime().wrap((function _callee7$(a){for(;;)switch(a.prev=a.next){case 0:if(r.round||r.turn){a.next=2;break}return a.abrupt("return");case 2:if(0==t.round||!t.turns||!t.active){a.next=6;break}if(!(t.previous.round0?"CHATNOTIFICATION.regenerates":"CHATNOTIFICATION.getsHurt"),d="".concat(t.actor.name," ").concat(p," ").concat(game.i18n.localize(i)," ").concat(l),h.next=19,this.sendEventMessage(d,r,t);case 19:if("wounds"!=i){h.next=24;break}return h.next=22,t.actor.applyDamage(-1*u.total);case 22:h.next=26;break;case 24:return h.next=26,t.actor.applyMana(-1*u.total,"astralenergy"==i?"AsP":"KaP");case 26:a++,h.next=2;break;case 29:case"end":return h.stop()}}),_callee9,this)}))),function startOfRoundEffects(t,r){return i.apply(this,arguments)})},{key:"applyBleeding",value:(o=combat_tracker_asyncToGenerator(combat_tracker_regeneratorRuntime().mark((function _callee10(t,r){var a;return combat_tracker_regeneratorRuntime().wrap((function _callee10$(o){for(;;)switch(o.prev=o.next){case 0:if(!(t.actor.system.status.wounds.value<1)){o.next=2;break}return o.abrupt("return");case 2:return a=game.i18n.format("CHATNOTIFICATION.bleeding",{actor:t.actor.name}),o.next=5,this.sendEventMessage(a,r,t);case 5:return o.next=7,t.actor.applyDamage(1);case 7:case"end":return o.stop()}}),_callee10,this)}))),function applyBleeding(t,r){return o.apply(this,arguments)})},{key:"applyBurning",value:(a=combat_tracker_asyncToGenerator(combat_tracker_regeneratorRuntime().mark((function _callee11(t,r,a){var o,i,c,l,p,d;return combat_tracker_regeneratorRuntime().wrap((function _callee11$(h){for(;;)switch(h.prev=h.next){case 0:if(!(t.actor.system.status.wounds.value<1)){h.next=2;break}return h.abrupt("return");case 2:return o=Number(r.getFlag("dsa5","value")),i=u.Z.resistantToEffect(t.actor,r),c={0:"1",1:"1d3",2:"1d6",3:"2d6"}[o-i]||"1",h.next=7,new Roll(c).evaluate({async:!0});case 7:return l=h.sent,h.next=10,l.render();case 10:return p=h.sent,d=game.i18n.format("CHATNOTIFICATION.burning.".concat(o),{actor:t.actor.name,damage:p}),h.next=14,this.sendEventMessage(d,a,t);case 14:return h.next=16,t.actor.applyDamage(l.total);case 16:case"end":return h.stop()}}),_callee11,this)}))),function applyBurning(t,r,o){return a.apply(this,arguments)})},{key:"sendEventMessage",value:(r=combat_tracker_asyncToGenerator(combat_tracker_regeneratorRuntime().mark((function _callee12(r,a,o){var i;return combat_tracker_regeneratorRuntime().wrap((function _callee12$(c){for(;;)switch(c.prev=c.next){case 0:if(!game.settings.get("dsa5","hideRegenerationToOwner")){c.next=7;break}return(i=a.combatants.get(o.id).players).push.apply(i,combat_tracker_toConsumableArray(game.users.filter((function(t){return t.isGM})).map((function(t){return t.id})))),c.next=5,ChatMessage.create(t.Z.chatDataSetup(r,void 0,void 0,i));case 5:c.next=9;break;case 7:return c.next=9,ChatMessage.create(t.Z.chatDataSetup(r));case 9:case"end":return c.stop()}}),_callee12)}))),function sendEventMessage(t,a,o){return r.apply(this,arguments)})}]),RepeatingEffectsHelper}();function dsa_ini_tracker_typeof(t){return dsa_ini_tracker_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},dsa_ini_tracker_typeof(t)}function dsa_ini_tracker_regeneratorRuntime(){dsa_ini_tracker_regeneratorRuntime=function _regeneratorRuntime(){return t};var t={},r=Object.prototype,a=r.hasOwnProperty,o="function"==typeof Symbol?Symbol:{},i=o.iterator||"@@iterator",c=o.asyncIterator||"@@asyncIterator",u=o.toStringTag||"@@toStringTag";function define(t,r,a){return Object.defineProperty(t,r,{value:a,enumerable:!0,configurable:!0,writable:!0}),t[r]}try{define({},"")}catch(t){define=function define(t,r,a){return t[r]=a}}function wrap(t,r,a,o){var i=r&&r.prototype instanceof Generator?r:Generator,c=Object.create(i.prototype),u=new Context(o||[]);return c._invoke=function(t,r,a){var o="suspendedStart";return function(i,c){if("executing"===o)throw new Error("Generator is already running");if("completed"===o){if("throw"===i)throw c;return doneResult()}for(a.method=i,a.arg=c;;){var u=a.delegate;if(u){var p=maybeInvokeDelegate(u,a);if(p){if(p===l)continue;return p}}if("next"===a.method)a.sent=a._sent=a.arg;else if("throw"===a.method){if("suspendedStart"===o)throw o="completed",a.arg;a.dispatchException(a.arg)}else"return"===a.method&&a.abrupt("return",a.arg);o="executing";var d=tryCatch(t,r,a);if("normal"===d.type){if(o=a.done?"completed":"suspendedYield",d.arg===l)continue;return{value:d.arg,done:a.done}}"throw"===d.type&&(o="completed",a.method="throw",a.arg=d.arg)}}}(t,a,u),c}function tryCatch(t,r,a){try{return{type:"normal",arg:t.call(r,a)}}catch(t){return{type:"throw",arg:t}}}t.wrap=wrap;var l={};function Generator(){}function GeneratorFunction(){}function GeneratorFunctionPrototype(){}var p={};define(p,i,(function(){return this}));var d=Object.getPrototypeOf,h=d&&d(d(values([])));h&&h!==r&&a.call(h,i)&&(p=h);var m=GeneratorFunctionPrototype.prototype=Generator.prototype=Object.create(p);function defineIteratorMethods(t){["next","throw","return"].forEach((function(r){define(t,r,(function(t){return this._invoke(r,t)}))}))}function AsyncIterator(t,r){function invoke(o,i,c,u){var l=tryCatch(t[o],t,i);if("throw"!==l.type){var p=l.arg,d=p.value;return d&&"object"==dsa_ini_tracker_typeof(d)&&a.call(d,"__await")?r.resolve(d.__await).then((function(t){invoke("next",t,c,u)}),(function(t){invoke("throw",t,c,u)})):r.resolve(d).then((function(t){p.value=t,c(p)}),(function(t){return invoke("throw",t,c,u)}))}u(l.arg)}var o;this._invoke=function(t,a){function callInvokeWithMethodAndArg(){return new r((function(r,o){invoke(t,a,r,o)}))}return o=o?o.then(callInvokeWithMethodAndArg,callInvokeWithMethodAndArg):callInvokeWithMethodAndArg()}}function maybeInvokeDelegate(t,r){var a=t.iterator[r.method];if(void 0===a){if(r.delegate=null,"throw"===r.method){if(t.iterator.return&&(r.method="return",r.arg=void 0,maybeInvokeDelegate(t,r),"throw"===r.method))return l;r.method="throw",r.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var o=tryCatch(a,t.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,l;var i=o.arg;return i?i.done?(r[t.resultName]=i.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=void 0),r.delegate=null,l):i:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,l)}function pushTryEntry(t){var r={tryLoc:t[0]};1 in t&&(r.catchLoc=t[1]),2 in t&&(r.finallyLoc=t[2],r.afterLoc=t[3]),this.tryEntries.push(r)}function resetTryEntry(t){var r=t.completion||{};r.type="normal",delete r.arg,t.completion=r}function Context(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(pushTryEntry,this),this.reset(!0)}function values(t){if(t){var r=t[i];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var o=-1,c=function next(){for(;++o=0;--o){var i=this.tryEntries[o],c=i.completion;if("root"===i.tryLoc)return handle("end");if(i.tryLoc<=this.prev){var u=a.call(i,"catchLoc"),l=a.call(i,"finallyLoc");if(u&&l){if(this.prev=0;--o){var i=this.tryEntries[o];if(i.tryLoc<=this.prev&&a.call(i,"finallyLoc")&&this.prev=0;--r){var a=this.tryEntries[r];if(a.finallyLoc===t)return this.complete(a.completion,a.afterLoc),resetTryEntry(a),l}},catch:function _catch(t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc===t){var o=a.completion;if("throw"===o.type){var i=o.arg;resetTryEntry(a)}return i}}throw new Error("illegal catch attempt")},delegateYield:function delegateYield(t,r,a){return this.delegate={iterator:values(t),resultName:r,nextLoc:a},"next"===this.method&&(this.arg=void 0),l}},t}function dsa_ini_tracker_asyncGeneratorStep(t,r,a,o,i,c,u){try{var l=t[c](u),p=l.value}catch(t){return void a(t)}l.done?r(p):Promise.resolve(p).then(o,i)}function dsa_ini_tracker_asyncToGenerator(t){return function(){var r=this,a=arguments;return new Promise((function(o,i){var c=t.apply(r,a);function _next(t){dsa_ini_tracker_asyncGeneratorStep(c,o,i,_next,_throw,"next",t)}function _throw(t){dsa_ini_tracker_asyncGeneratorStep(c,o,i,_next,_throw,"throw",t)}_next(void 0)}))}}function dsa_ini_tracker_classCallCheck(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}function dsa_ini_tracker_defineProperties(t,r){for(var a=0;a0&&void 0!==arguments[0]?arguments[0]:{},r=t.left,a=t.top,o=t.width,i=t.height,c=t.scale,u=dsa_ini_tracker_get(dsa_ini_tracker_getPrototypeOf(DSAIniTracker.prototype),"setPosition",this).call(this,{left:r,top:a,width:o,height:i,scale:c}),l=this.element[0];if(!l.style.width||o){var p=o||l.offsetWidth,d=l.style.maxWidth||window.innerWidth;u.width=o=Math.clamped(p,0,d),l.style.width=o+"px",o+u.left>window.innerWidth&&(r=u.left)}return game.settings.set("dsa5","iniTrackerPosition",{left:u.left,top:u.top}),u}},{key:"updateTracker",value:function updateTracker(t){this.combatData=t,this.render(!0,{focus:!1})}},{key:"getData",value:(i=dsa_ini_tracker_asyncToGenerator(dsa_ini_tracker_regeneratorRuntime().mark((function _callee(t){var r,a,o,i,c,u,l,p,d,h,m,y,g,v,_,b,k,w,x;return dsa_ini_tracker_regeneratorRuntime().wrap((function _callee$(t){for(;;)switch(t.prev=t.next){case 0:if(r=this.combatData,a=DSAIniTracker.defaultOptions.itemWidth,o=DSAIniTracker.defaultOptions.actorCount,i=r.round,c=r.turns,u=[],l=game.settings.get("core",Combat.CONFIG_SETTING).skipDefeated,p=c.some((function(t){return t.active})),d=r.turns.some((function(t){return t.owner&&!t.hasRolled&&(!game.user.isGM||r.combat.combatants.get(t.id).isNPC)})),c.length){for(h=[],m=o,y=!1,g=-1,v=0,_=0;0!=m&&_!=o;)k=duplicate(c[v]),w=r.combat.combatants.get(k.id),y&&v==g&&(k.css=k.css.replace("active","")),!i||k.active&&!y||!p&&!y?(y=!0,g=v):w.getFlag("dsa5","waitInit")!=r.round+_||w.defeated||!game.user.isGM&&w.hidden||u.push(k),!y||l&&w.defeated||!game.user.isGM&&w.hidden||(k.round=r.round+_,k.owner&&null!==(x=w.token)&&void 0!==x&&x.actor&&(k.maxLP=w.token.actor.system.status.wounds.max,k.currentLP=w.token.actor.system.status.wounds.value),b&&b!=k.round&&(k.newRound="newRound"),b=k.round,h.push(k),m--),++v>=c.length&&(v=0,_++);r.turns=h}return this.position.width=a*o+3*o+80,this.position.height=a+10,mergeObject(r,{itemWidth:a,unRolled:d,waitingTurns:u}),this.conditionalPanToCurrentCombatant(r),t.abrupt("return",r);case 15:case"end":return t.stop()}}),_callee,this)}))),function getData(t){return i.apply(this,arguments)})},{key:"hasChangedTurn",value:function hasChangedTurn(t){var r=t.turn!=this.lastTurnUpdate||t.round!=this.lastRoundUpdate;return this.lastTurnUpdate=t.turn,this.lastRoundUpdate=t.round,r}},{key:"conditionalPanToCurrentCombatant",value:(o=dsa_ini_tracker_asyncToGenerator(dsa_ini_tracker_regeneratorRuntime().mark((function _callee2(t){var r,a;return dsa_ini_tracker_regeneratorRuntime().wrap((function _callee2$(o){for(;;)switch(o.prev=o.next){case 0:if(game.settings.get("dsa5","enableCombatPan")){o.next=2;break}return o.abrupt("return");case 2:if(r=t.turns[0]){o.next=5;break}return o.abrupt("return");case 5:if((a=t.combat.combatants.get(r.id))&&this.hasChangedTurn(t)){o.next=8;break}return o.abrupt("return");case 8:setTimeout((function(){var t=a.token;t&&t.object&&t.object.isVisible&&(canvas.animatePan({x:t.x,y:t.y}),a.actor&&a.actor.isOwner&&t.object.control({releaseOthers:!0}))}),300);case 9:case"end":return o.stop()}}),_callee2,this)}))),function conditionalPanToCurrentCombatant(t){return o.apply(this,arguments)})},{key:"_onWheelResize",value:(a=dsa_ini_tracker_asyncToGenerator(dsa_ini_tracker_regeneratorRuntime().mark((function _callee3(t){var r;return dsa_ini_tracker_regeneratorRuntime().wrap((function _callee3$(a){for(;;)switch(a.prev=a.next){case 0:return r=game.settings.get("dsa5","iniTrackerSize"),r=t.originalEvent.deltaY>0?Math.min(140,r+5):Math.max(30,r-5),a.next=4,game.settings.set("dsa5","iniTrackerSize",r);case 4:return a.next=6,this.render(!0);case 6:case"end":return a.stop()}}),_callee3,this)}))),function _onWheelResize(t){return a.apply(this,arguments)})},{key:"activateListeners",value:function activateListeners(t){var r=this;dsa_ini_tracker_get(dsa_ini_tracker_getPrototypeOf(DSAIniTracker.prototype),"activateListeners",this).call(this,t);var a=t.find(".dragHandler");new Draggable(this,t,a[0],this.options.resizable),a.on("wheel",function(){var t=dsa_ini_tracker_asyncToGenerator(dsa_ini_tracker_regeneratorRuntime().mark((function _callee4(t){return dsa_ini_tracker_regeneratorRuntime().wrap((function _callee4$(a){for(;;)switch(a.prev=a.next){case 0:return t.stopPropagation(),t.preventDefault(),a.next=4,r._onWheelResize(t);case 4:return a.abrupt("return",!1);case 5:case"end":return a.stop()}}),_callee4)})));return function(r){return t.apply(this,arguments)}}()),t.find(".toggleTracker").click((function(){var t=ui.combat;t.renderPopout(t)})),t.find(".combat-control").click((function(t){return r._onCombatControl(t)}));var o=t.find(".iniItem");o.hover(this._onCombatantHoverIn.bind(this),this._onCombatantHoverOut.bind(this)),o.click(this._onCombatantMouseDown.bind(this)),t.find(".waitingTackerList .iniItem").mousedown((function(t){return r._onRightClick(t)})),t.find(".combatant-control").click((function(t){return r._onCombatantControl(t)})),t.find(".combatant .aggroButton").click((function(t){t.preventDefault(),t.stopPropagation(),Ge.runActAttackDialog()})),t.find(".rollMine").click((function(t){return r.rollMyChars()})),game.user.isGM&&t.find(".rolledInit").click((function(t){return r.editCombatant(t)}))}},{key:"rollMyChars",value:function rollMyChars(){game.user.isGM?this._getCombatApp().viewed.rollNPC({}):this._getCombatApp().viewed.rollAll({})}},{key:"_onRightClick",value:function _onRightClick(t){if(2==t.button){var r=game.combat.combatants.get(t.currentTarget.dataset.combatantId);r.isOwner&&r.unsetFlag("dsa5","waitInit")}}},{key:"editCombatant",value:function editCombatant(t){this._getCombatApp()._onConfigureCombatant($(t.currentTarget))}},{key:"_onCombatantControl",value:function _onCombatantControl(t){this._getCombatApp()._onCombatantControl(t)}},{key:"_onCombatControl",value:function _onCombatControl(t){"waitInit"==t.currentTarget.dataset.control?this.waitInit(t):this._getCombatApp()._onCombatControl(t)}},{key:"waitInit",value:(r=dsa_ini_tracker_asyncToGenerator(dsa_ini_tracker_regeneratorRuntime().mark((function _callee5(t){var r;return dsa_ini_tracker_regeneratorRuntime().wrap((function _callee5$(a){for(;;)switch(a.prev=a.next){case 0:return r=game.combat.combatants.get(game.combat.current.combatantId),a.next=3,r.setFlag("dsa5","waitInit",game.combat.current.round);case 3:t.currentTarget.dataset.control="nextTurn",this._getCombatApp()._onCombatControl(t);case 5:case"end":return a.stop()}}),_callee5,this)}))),function waitInit(t){return r.apply(this,arguments)})},{key:"_onCombatantHoverOut",value:function _onCombatantHoverOut(t){this._getCombatApp()._onCombatantHoverOut(t)}},{key:"_onCombatantHoverIn",value:function _onCombatantHoverIn(t){this._getCombatApp()._onCombatantHoverIn(t)}},{key:"_onCombatantMouseDown",value:function _onCombatantMouseDown(t){this._getCombatApp()._onCombatantMouseDown(t)}},{key:"_getCombatApp",value:function _getCombatApp(){return game.combats.apps[0]}},{key:"_canDragStart",value:function _canDragStart(t){return!1}},{key:"_canDragDrop",value:function _canDragDrop(t){return!1}},{key:"_onDragStart",value:function _onDragStart(t){var r=$(t.currentTarget).closestData("combatant-id");t.dataTransfer.setData("text/plain",JSON.stringify({type:"IniChange",combatantId:r}))}},{key:"_onDrop",value:function _onDrop(t){JSON.parse(t.dataTransfer.getData("text/plain")).type}}],[{key:"defaultOptions",get:function get(){var t=dsa_ini_tracker_get(dsa_ini_tracker_getPrototypeOf(DSAIniTracker),"defaultOptions",this);return mergeObject(t,{classes:t.classes.concat(["dsa5","initTracker"]),template:"systems/dsa5/templates/system/initracker.html",dragDrop:[{dragSelector:".iniItem",dropSelector:[".iniTrackerList"]}],top:100,left:170,title:"DSAIniTracker",itemWidth:game.settings.get("dsa5","iniTrackerSize"),actorCount:game.settings.get("dsa5","iniTrackerCount"),position:game.settings.get("dsa5","iniTrackerPosition")}),t}},{key:"connectHooks",value:function connectHooks(){Hooks.on("renderDSA5CombatTracker",(function(t,r,a){game.settings.get("dsa5","enableCombatFlow")&&(game.combat?(game.dsa5.apps.initTracker||(game.dsa5.apps.initTracker=new DSAIniTracker),game.dsa5.apps.initTracker.updateTracker(a)):game.dsa5.apps.initTracker&&(game.dsa5.apps.initTracker.close(),game.dsa5.apps.initTracker=void 0))}))}}]),DSAIniTracker}(),Ne=__webpack_require__(93),He=__webpack_require__(147);function ready_typeof(t){return ready_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},ready_typeof(t)}function ready_regeneratorRuntime(){ready_regeneratorRuntime=function _regeneratorRuntime(){return t};var t={},r=Object.prototype,a=r.hasOwnProperty,o="function"==typeof Symbol?Symbol:{},i=o.iterator||"@@iterator",c=o.asyncIterator||"@@asyncIterator",u=o.toStringTag||"@@toStringTag";function define(t,r,a){return Object.defineProperty(t,r,{value:a,enumerable:!0,configurable:!0,writable:!0}),t[r]}try{define({},"")}catch(t){define=function define(t,r,a){return t[r]=a}}function wrap(t,r,a,o){var i=r&&r.prototype instanceof Generator?r:Generator,c=Object.create(i.prototype),u=new Context(o||[]);return c._invoke=function(t,r,a){var o="suspendedStart";return function(i,c){if("executing"===o)throw new Error("Generator is already running");if("completed"===o){if("throw"===i)throw c;return doneResult()}for(a.method=i,a.arg=c;;){var u=a.delegate;if(u){var p=maybeInvokeDelegate(u,a);if(p){if(p===l)continue;return p}}if("next"===a.method)a.sent=a._sent=a.arg;else if("throw"===a.method){if("suspendedStart"===o)throw o="completed",a.arg;a.dispatchException(a.arg)}else"return"===a.method&&a.abrupt("return",a.arg);o="executing";var d=tryCatch(t,r,a);if("normal"===d.type){if(o=a.done?"completed":"suspendedYield",d.arg===l)continue;return{value:d.arg,done:a.done}}"throw"===d.type&&(o="completed",a.method="throw",a.arg=d.arg)}}}(t,a,u),c}function tryCatch(t,r,a){try{return{type:"normal",arg:t.call(r,a)}}catch(t){return{type:"throw",arg:t}}}t.wrap=wrap;var l={};function Generator(){}function GeneratorFunction(){}function GeneratorFunctionPrototype(){}var p={};define(p,i,(function(){return this}));var d=Object.getPrototypeOf,h=d&&d(d(values([])));h&&h!==r&&a.call(h,i)&&(p=h);var m=GeneratorFunctionPrototype.prototype=Generator.prototype=Object.create(p);function defineIteratorMethods(t){["next","throw","return"].forEach((function(r){define(t,r,(function(t){return this._invoke(r,t)}))}))}function AsyncIterator(t,r){function invoke(o,i,c,u){var l=tryCatch(t[o],t,i);if("throw"!==l.type){var p=l.arg,d=p.value;return d&&"object"==ready_typeof(d)&&a.call(d,"__await")?r.resolve(d.__await).then((function(t){invoke("next",t,c,u)}),(function(t){invoke("throw",t,c,u)})):r.resolve(d).then((function(t){p.value=t,c(p)}),(function(t){return invoke("throw",t,c,u)}))}u(l.arg)}var o;this._invoke=function(t,a){function callInvokeWithMethodAndArg(){return new r((function(r,o){invoke(t,a,r,o)}))}return o=o?o.then(callInvokeWithMethodAndArg,callInvokeWithMethodAndArg):callInvokeWithMethodAndArg()}}function maybeInvokeDelegate(t,r){var a=t.iterator[r.method];if(void 0===a){if(r.delegate=null,"throw"===r.method){if(t.iterator.return&&(r.method="return",r.arg=void 0,maybeInvokeDelegate(t,r),"throw"===r.method))return l;r.method="throw",r.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var o=tryCatch(a,t.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,l;var i=o.arg;return i?i.done?(r[t.resultName]=i.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=void 0),r.delegate=null,l):i:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,l)}function pushTryEntry(t){var r={tryLoc:t[0]};1 in t&&(r.catchLoc=t[1]),2 in t&&(r.finallyLoc=t[2],r.afterLoc=t[3]),this.tryEntries.push(r)}function resetTryEntry(t){var r=t.completion||{};r.type="normal",delete r.arg,t.completion=r}function Context(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(pushTryEntry,this),this.reset(!0)}function values(t){if(t){var r=t[i];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var o=-1,c=function next(){for(;++o=0;--o){var i=this.tryEntries[o],c=i.completion;if("root"===i.tryLoc)return handle("end");if(i.tryLoc<=this.prev){var u=a.call(i,"catchLoc"),l=a.call(i,"finallyLoc");if(u&&l){if(this.prev=0;--o){var i=this.tryEntries[o];if(i.tryLoc<=this.prev&&a.call(i,"finallyLoc")&&this.prev=0;--r){var a=this.tryEntries[r];if(a.finallyLoc===t)return this.complete(a.completion,a.afterLoc),resetTryEntry(a),l}},catch:function _catch(t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc===t){var o=a.completion;if("throw"===o.type){var i=o.arg;resetTryEntry(a)}return i}}throw new Error("illegal catch attempt")},delegateYield:function delegateYield(t,r,a){return this.delegate={iterator:values(t),resultName:r,nextLoc:a},"next"===this.method&&(this.arg=void 0),l}},t}function ready_asyncGeneratorStep(t,r,a,o,i,c,u){try{var l=t[c](u),p=l.value}catch(t){return void a(t)}l.done?r(p):Promise.resolve(p).then(o,i)}function ready_asyncToGenerator(t){return function(){var r=this,a=arguments;return new Promise((function(o,i){var c=t.apply(r,a);function _next(t){ready_asyncGeneratorStep(c,o,i,_next,_throw,"next",t)}function _throw(t){ready_asyncGeneratorStep(c,o,i,_next,_throw,"throw",t)}_next(void 0)}))}}function chat_context_typeof(t){return chat_context_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},chat_context_typeof(t)}function chat_context_regeneratorRuntime(){chat_context_regeneratorRuntime=function _regeneratorRuntime(){return t};var t={},r=Object.prototype,a=r.hasOwnProperty,o="function"==typeof Symbol?Symbol:{},i=o.iterator||"@@iterator",c=o.asyncIterator||"@@asyncIterator",u=o.toStringTag||"@@toStringTag";function define(t,r,a){return Object.defineProperty(t,r,{value:a,enumerable:!0,configurable:!0,writable:!0}),t[r]}try{define({},"")}catch(t){define=function define(t,r,a){return t[r]=a}}function wrap(t,r,a,o){var i=r&&r.prototype instanceof Generator?r:Generator,c=Object.create(i.prototype),u=new Context(o||[]);return c._invoke=function(t,r,a){var o="suspendedStart";return function(i,c){if("executing"===o)throw new Error("Generator is already running");if("completed"===o){if("throw"===i)throw c;return doneResult()}for(a.method=i,a.arg=c;;){var u=a.delegate;if(u){var p=maybeInvokeDelegate(u,a);if(p){if(p===l)continue;return p}}if("next"===a.method)a.sent=a._sent=a.arg;else if("throw"===a.method){if("suspendedStart"===o)throw o="completed",a.arg;a.dispatchException(a.arg)}else"return"===a.method&&a.abrupt("return",a.arg);o="executing";var d=tryCatch(t,r,a);if("normal"===d.type){if(o=a.done?"completed":"suspendedYield",d.arg===l)continue;return{value:d.arg,done:a.done}}"throw"===d.type&&(o="completed",a.method="throw",a.arg=d.arg)}}}(t,a,u),c}function tryCatch(t,r,a){try{return{type:"normal",arg:t.call(r,a)}}catch(t){return{type:"throw",arg:t}}}t.wrap=wrap;var l={};function Generator(){}function GeneratorFunction(){}function GeneratorFunctionPrototype(){}var p={};define(p,i,(function(){return this}));var d=Object.getPrototypeOf,h=d&&d(d(values([])));h&&h!==r&&a.call(h,i)&&(p=h);var m=GeneratorFunctionPrototype.prototype=Generator.prototype=Object.create(p);function defineIteratorMethods(t){["next","throw","return"].forEach((function(r){define(t,r,(function(t){return this._invoke(r,t)}))}))}function AsyncIterator(t,r){function invoke(o,i,c,u){var l=tryCatch(t[o],t,i);if("throw"!==l.type){var p=l.arg,d=p.value;return d&&"object"==chat_context_typeof(d)&&a.call(d,"__await")?r.resolve(d.__await).then((function(t){invoke("next",t,c,u)}),(function(t){invoke("throw",t,c,u)})):r.resolve(d).then((function(t){p.value=t,c(p)}),(function(t){return invoke("throw",t,c,u)}))}u(l.arg)}var o;this._invoke=function(t,a){function callInvokeWithMethodAndArg(){return new r((function(r,o){invoke(t,a,r,o)}))}return o=o?o.then(callInvokeWithMethodAndArg,callInvokeWithMethodAndArg):callInvokeWithMethodAndArg()}}function maybeInvokeDelegate(t,r){var a=t.iterator[r.method];if(void 0===a){if(r.delegate=null,"throw"===r.method){if(t.iterator.return&&(r.method="return",r.arg=void 0,maybeInvokeDelegate(t,r),"throw"===r.method))return l;r.method="throw",r.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var o=tryCatch(a,t.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,l;var i=o.arg;return i?i.done?(r[t.resultName]=i.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=void 0),r.delegate=null,l):i:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,l)}function pushTryEntry(t){var r={tryLoc:t[0]};1 in t&&(r.catchLoc=t[1]),2 in t&&(r.finallyLoc=t[2],r.afterLoc=t[3]),this.tryEntries.push(r)}function resetTryEntry(t){var r=t.completion||{};r.type="normal",delete r.arg,t.completion=r}function Context(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(pushTryEntry,this),this.reset(!0)}function values(t){if(t){var r=t[i];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var o=-1,c=function next(){for(;++o=0;--o){var i=this.tryEntries[o],c=i.completion;if("root"===i.tryLoc)return handle("end");if(i.tryLoc<=this.prev){var u=a.call(i,"catchLoc"),l=a.call(i,"finallyLoc");if(u&&l){if(this.prev=0;--o){var i=this.tryEntries[o];if(i.tryLoc<=this.prev&&a.call(i,"finallyLoc")&&this.prev=0;--r){var a=this.tryEntries[r];if(a.finallyLoc===t)return this.complete(a.completion,a.afterLoc),resetTryEntry(a),l}},catch:function _catch(t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc===t){var o=a.completion;if("throw"===o.type){var i=o.arg;resetTryEntry(a)}return i}}throw new Error("illegal catch attempt")},delegateYield:function delegateYield(t,r,a){return this.delegate={iterator:values(t),resultName:r,nextLoc:a},"next"===this.method&&(this.arg=void 0),l}},t}function chat_context_asyncGeneratorStep(t,r,a,o,i,c,u){try{var l=t[c](u),p=l.value}catch(t){return void a(t)}l.done?r(p):Promise.resolve(p).then(o,i)}function chat_context_asyncToGenerator(t){return function(){var r=this,a=arguments;return new Promise((function(o,i){var c=t.apply(r,a);function _next(t){chat_context_asyncGeneratorStep(c,o,i,_next,_throw,"next",t)}function _throw(t){chat_context_asyncGeneratorStep(c,o,i,_next,_throw,"throw",t)}_next(void 0)}))}}var $e=__webpack_require__(565);function statuseffect_typeof(t){return statuseffect_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},statuseffect_typeof(t)}function statuseffect_regeneratorRuntime(){statuseffect_regeneratorRuntime=function _regeneratorRuntime(){return t};var t={},r=Object.prototype,a=r.hasOwnProperty,o="function"==typeof Symbol?Symbol:{},i=o.iterator||"@@iterator",c=o.asyncIterator||"@@asyncIterator",u=o.toStringTag||"@@toStringTag";function define(t,r,a){return Object.defineProperty(t,r,{value:a,enumerable:!0,configurable:!0,writable:!0}),t[r]}try{define({},"")}catch(t){define=function define(t,r,a){return t[r]=a}}function wrap(t,r,a,o){var i=r&&r.prototype instanceof Generator?r:Generator,c=Object.create(i.prototype),u=new Context(o||[]);return c._invoke=function(t,r,a){var o="suspendedStart";return function(i,c){if("executing"===o)throw new Error("Generator is already running");if("completed"===o){if("throw"===i)throw c;return doneResult()}for(a.method=i,a.arg=c;;){var u=a.delegate;if(u){var p=maybeInvokeDelegate(u,a);if(p){if(p===l)continue;return p}}if("next"===a.method)a.sent=a._sent=a.arg;else if("throw"===a.method){if("suspendedStart"===o)throw o="completed",a.arg;a.dispatchException(a.arg)}else"return"===a.method&&a.abrupt("return",a.arg);o="executing";var d=tryCatch(t,r,a);if("normal"===d.type){if(o=a.done?"completed":"suspendedYield",d.arg===l)continue;return{value:d.arg,done:a.done}}"throw"===d.type&&(o="completed",a.method="throw",a.arg=d.arg)}}}(t,a,u),c}function tryCatch(t,r,a){try{return{type:"normal",arg:t.call(r,a)}}catch(t){return{type:"throw",arg:t}}}t.wrap=wrap;var l={};function Generator(){}function GeneratorFunction(){}function GeneratorFunctionPrototype(){}var p={};define(p,i,(function(){return this}));var d=Object.getPrototypeOf,h=d&&d(d(values([])));h&&h!==r&&a.call(h,i)&&(p=h);var m=GeneratorFunctionPrototype.prototype=Generator.prototype=Object.create(p);function defineIteratorMethods(t){["next","throw","return"].forEach((function(r){define(t,r,(function(t){return this._invoke(r,t)}))}))}function AsyncIterator(t,r){function invoke(o,i,c,u){var l=tryCatch(t[o],t,i);if("throw"!==l.type){var p=l.arg,d=p.value;return d&&"object"==statuseffect_typeof(d)&&a.call(d,"__await")?r.resolve(d.__await).then((function(t){invoke("next",t,c,u)}),(function(t){invoke("throw",t,c,u)})):r.resolve(d).then((function(t){p.value=t,c(p)}),(function(t){return invoke("throw",t,c,u)}))}u(l.arg)}var o;this._invoke=function(t,a){function callInvokeWithMethodAndArg(){return new r((function(r,o){invoke(t,a,r,o)}))}return o=o?o.then(callInvokeWithMethodAndArg,callInvokeWithMethodAndArg):callInvokeWithMethodAndArg()}}function maybeInvokeDelegate(t,r){var a=t.iterator[r.method];if(void 0===a){if(r.delegate=null,"throw"===r.method){if(t.iterator.return&&(r.method="return",r.arg=void 0,maybeInvokeDelegate(t,r),"throw"===r.method))return l;r.method="throw",r.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var o=tryCatch(a,t.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,l;var i=o.arg;return i?i.done?(r[t.resultName]=i.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=void 0),r.delegate=null,l):i:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,l)}function pushTryEntry(t){var r={tryLoc:t[0]};1 in t&&(r.catchLoc=t[1]),2 in t&&(r.finallyLoc=t[2],r.afterLoc=t[3]),this.tryEntries.push(r)}function resetTryEntry(t){var r=t.completion||{};r.type="normal",delete r.arg,t.completion=r}function Context(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(pushTryEntry,this),this.reset(!0)}function values(t){if(t){var r=t[i];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var o=-1,c=function next(){for(;++o=0;--o){var i=this.tryEntries[o],c=i.completion;if("root"===i.tryLoc)return handle("end");if(i.tryLoc<=this.prev){var u=a.call(i,"catchLoc"),l=a.call(i,"finallyLoc");if(u&&l){if(this.prev=0;--o){var i=this.tryEntries[o];if(i.tryLoc<=this.prev&&a.call(i,"finallyLoc")&&this.prev=0;--r){var a=this.tryEntries[r];if(a.finallyLoc===t)return this.complete(a.completion,a.afterLoc),resetTryEntry(a),l}},catch:function _catch(t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc===t){var o=a.completion;if("throw"===o.type){var i=o.arg;resetTryEntry(a)}return i}}throw new Error("illegal catch attempt")},delegateYield:function delegateYield(t,r,a){return this.delegate={iterator:values(t),resultName:r,nextLoc:a},"next"===this.method&&(this.arg=void 0),l}},t}function statuseffect_createForOfIteratorHelper(t,r){var a="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!a){if(Array.isArray(t)||(a=function statuseffect_unsupportedIterableToArray(t,r){if(!t)return;if("string"==typeof t)return statuseffect_arrayLikeToArray(t,r);var a=Object.prototype.toString.call(t).slice(8,-1);"Object"===a&&t.constructor&&(a=t.constructor.name);if("Map"===a||"Set"===a)return Array.from(t);if("Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a))return statuseffect_arrayLikeToArray(t,r)}(t))||r&&t&&"number"==typeof t.length){a&&(t=a);var o=0,i=function F(){};return{s:i,n:function n(){return o>=t.length?{done:!0}:{done:!1,value:t[o++]}},e:function e(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var c,u=!0,l=!1;return{s:function s(){a=a.call(t)},n:function n(){var t=a.next();return u=t.done,t},e:function e(t){l=!0,c=t},f:function f(){try{u||null==a.return||a.return()}finally{if(l)throw c}}}}function statuseffect_arrayLikeToArray(t,r){(null==r||r>t.length)&&(r=t.length);for(var a=0,o=new Array(r);a1&&!u.counterDrawn){var p=game.dsa5.config.effectTextStyle,d=game.settings.get("dsa5","statusEffectCounterColor");p._fill=/^#[0-9A-F]+$/.test(d)?d:"#000000";var h=this.effects.addChild(new PreciseText(u.counter,p));h.x=u.x,h.y=u.y,h.isCounter=!0,u.counterDrawn=!0}r++}}}catch(t){c.e(t)}finally{c.f()}},Token.prototype._drawEffect=function(){var t=statuseffect_asyncToGenerator(statuseffect_regeneratorRuntime().mark((function _callee2(t,r,a){var o,i;return statuseffect_regeneratorRuntime().wrap((function _callee2$(c){for(;;)switch(c.prev=c.next){case 0:if(t){c.next=2;break}return c.abrupt("return");case 2:return c.next=4,loadTexture(t,{fallback:"icons/svg/hazard.svg"});case 4:return o=c.sent,i=new PIXI.Sprite(o),r&&(i.tint=r),i.counter=a,c.abrupt("return",this.effects.addChild(i));case 9:case"end":return c.stop()}}),_callee2,this)})));return function(r,a,o){return t.apply(this,arguments)}}(),TokenHUD.prototype._onToggleEffect=function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};r.overlay;t.preventDefault();var a=t.currentTarget,o=a.dataset.statusId&&this.object.actor?CONFIG.statusEffects.find((function(t){return t.id===a.dataset.statusId})):a.getAttribute("src");if(o.flags.dsa5.editable)return 0==t.button?this.object.incrementCondition(o):2==t.button?this.object.decrementCondition(o):void 0},Token.prototype.incrementCondition=function(){var t=statuseffect_asyncToGenerator(statuseffect_regeneratorRuntime().mark((function _callee3(t){var r,a,o,i,c=arguments;return statuseffect_regeneratorRuntime().wrap((function _callee3$(u){for(;;)switch(u.prev=u.next){case 0:if(r=c.length>1&&void 0!==c[1]?c[1]:{},a=r.active,o=r.overlay,void 0!==o&&o,(i=this.actor.effects.find((function(r){return r.statuses.has(t.id)})))&&!Number.isNumeric(getProperty(i,"flags.dsa5.value"))){u.next=7;break}return u.next=5,this.actor.addCondition(t.id,1,!1,!1);case 5:u.next=10;break;case 7:if(!i){u.next=10;break}return u.next=10,this.actor.removeCondition(t.id,1,!1);case 10:return this.hasActiveHUD&&canvas.tokens.hud.refreshStatusIcons(),u.abrupt("return",a);case 12:case"end":return u.stop()}}),_callee3,this)})));return function(r){return t.apply(this,arguments)}}(),Token.prototype.decrementCondition=function(){var t=statuseffect_asyncToGenerator(statuseffect_regeneratorRuntime().mark((function _callee4(t){var r,a,o,i=arguments;return statuseffect_regeneratorRuntime().wrap((function _callee4$(c){for(;;)switch(c.prev=c.next){case 0:return r=i.length>1&&void 0!==i[1]?i[1]:{},a=r.active,o=r.overlay,void 0!==o&&o,this.actor.removeCondition(t.id,1,!1),this.hasActiveHUD&&canvas.tokens.hud.refreshStatusIcons(),c.abrupt("return",a);case 4:case"end":return c.stop()}}),_callee4,this)})));return function(r){return t.apply(this,arguments)}}();var t=Token.prototype._onClickLeft2;Token.prototype._onClickLeft2=function(r){var a=game.user.isGM||!$e.Z.isEnabled||!function isMerchant(t){return!!t&&["merchant","loot"].includes(getProperty(t.system,"merchant.merchantType"))}(this.actor)||$e.Z.inDistance(this);if(!a)return ui.notifications.warn(game.i18n.localize("DSAError.notInRangeToLoot"));t.call(this,r)}}function sidebar_createForOfIteratorHelper(t,r){var a="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!a){if(Array.isArray(t)||(a=function sidebar_unsupportedIterableToArray(t,r){if(!t)return;if("string"==typeof t)return sidebar_arrayLikeToArray(t,r);var a=Object.prototype.toString.call(t).slice(8,-1);"Object"===a&&t.constructor&&(a=t.constructor.name);if("Map"===a||"Set"===a)return Array.from(t);if("Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a))return sidebar_arrayLikeToArray(t,r)}(t))||r&&t&&"number"==typeof t.length){a&&(t=a);var o=0,i=function F(){};return{s:i,n:function n(){return o>=t.length?{done:!0}:{done:!1,value:t[o++]}},e:function e(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var c,u=!0,l=!1;return{s:function s(){a=a.call(t)},n:function n(){var t=a.next();return u=t.done,t},e:function e(t){l=!0,c=t},f:function f(){try{u||null==a.return||a.return()}finally{if(l)throw c}}}}function sidebar_arrayLikeToArray(t,r){(null==r||r>t.length)&&(r=t.length);for(var a=0,o=new Array(r);a=t.length?{done:!0}:{done:!1,value:t[o++]}},e:function e(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var c,u=!0,l=!1;return{s:function s(){a=a.call(t)},n:function n(){var t=a.next();return u=t.done,t},e:function e(t){l=!0,c=t},f:function f(){try{u||null==a.return||a.return()}finally{if(l)throw c}}}}function configuration_arrayLikeToArray(t,r){(null==r||r>t.length)&&(r=t.length);for(var a=0,o=new Array(r);a=0;--o){var i=this.tryEntries[o],c=i.completion;if("root"===i.tryLoc)return handle("end");if(i.tryLoc<=this.prev){var u=a.call(i,"catchLoc"),l=a.call(i,"finallyLoc");if(u&&l){if(this.prev=0;--o){var i=this.tryEntries[o];if(i.tryLoc<=this.prev&&a.call(i,"finallyLoc")&&this.prev=0;--r){var a=this.tryEntries[r];if(a.finallyLoc===t)return this.complete(a.completion,a.afterLoc),resetTryEntry(a),l}},catch:function _catch(t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc===t){var o=a.completion;if("throw"===o.type){var i=o.arg;resetTryEntry(a)}return i}}throw new Error("illegal catch attempt")},delegateYield:function delegateYield(t,r,a){return this.delegate={iterator:values(t),resultName:r,nextLoc:a},"next"===this.method&&(this.arg=void 0),l}},t}function configuration_asyncGeneratorStep(t,r,a,o,i,c,u){try{var l=t[c](u),p=l.value}catch(t){return void a(t)}l.done?r(p):Promise.resolve(p).then(o,i)}function configuration_asyncToGenerator(t){return function(){var r=this,a=arguments;return new Promise((function(o,i){var c=t.apply(r,a);function _next(t){configuration_asyncGeneratorStep(c,o,i,_next,_throw,"next",t)}function _throw(t){configuration_asyncGeneratorStep(c,o,i,_next,_throw,"throw",t)}_next(void 0)}))}}var We=function exportSetting(t){var r=Array.from(game.settings.settings);t.find('[name="exportOnlyDSA"]').is(":checked")&&(r=r.filter((function(t){return/^dsa5\./.test(t[0])})));var a,o={},i=/(^dsa5\.(selectedActors|trackedActors|groupschips|tokenhotbarPosition|iniTrackerPosition|migrationVersion)$|^dsa5\.breadcrumbs_)/,c=configuration_createForOfIteratorHelper(r);try{for(c.s();!(a=c.n()).done;){var u=a.value;if(!i.test(u[0])){var l=u[0].split("."),p=l.shift(),d=l.join(".");o[u[0]]=game.settings.get(p,d)}}}catch(t){c.e(t)}finally{c.f()}saveDataToFile(JSON.stringify(o,null,2),"text/json","fvtt-DSA5-Configuration.json")},Be=function(){var t=configuration_asyncToGenerator(configuration_regeneratorRuntime().mark((function _callee8(t){var r,a;return configuration_regeneratorRuntime().wrap((function _callee8$(o){for(;;)switch(o.prev=o.next){case 0:if((a=t.find("form")[0]).data.files.length){o.next=3;break}return o.abrupt("return",null===(r=ui.notifications)||void 0===r?void 0:r.error("You did not upload a data file!"));case 3:readTextFromFile(a.data.files[0]).then(function(){var t=configuration_asyncToGenerator(configuration_regeneratorRuntime().mark((function _callee7(t){var r,a,o,i,c,u,l,p;return configuration_regeneratorRuntime().wrap((function _callee7$(d){for(;;)switch(d.prev=d.next){case 0:r=JSON.parse(t),a=Array.from(game.settings.settings).map((function(t){return t[0]})),o=0,i=Object.keys(r);case 3:if(!(o',label:game.i18n.localize("Export"),callback:function callback(t){return We(t)}},import:{icon:'',label:game.i18n.localize("Import"),callback:function callback(t){return Be(t)}}}}).render(!0);case 4:case"end":return r.stop()}}),_callee9)}))),function render(){return r.apply(this,arguments)})}]),ExportForm}(),Ye=function(t){configuration_inherits(ConfigureTokenHotbar,FormApplication);var r,a,o,i=configuration_createSuper(ConfigureTokenHotbar);function ConfigureTokenHotbar(){return configuration_classCallCheck(this,ConfigureTokenHotbar),i.apply(this,arguments)}return configuration_createClass(ConfigureTokenHotbar,[{key:"template",get:function get(){return"systems/dsa5/templates/dialog/configureTokenhotbar.html"}},{key:"activateListeners",value:function activateListeners(t){var r=this;configuration_get(configuration_getPrototypeOf(ConfigureTokenHotbar.prototype),"activateListeners",this).call(this,t),t.find(".resetTokenhotbar").click((function(t){return r.resetTokenHotbar(t)})),t.find("select, input").change(function(){var t=configuration_asyncToGenerator(configuration_regeneratorRuntime().mark((function _callee10(t){var r,a,o;return configuration_regeneratorRuntime().wrap((function _callee10$(i){for(;;)switch(i.prev=i.next){case 0:return a=t.currentTarget.name.split("."),o="Number"==t.currentTarget.dataset.dtype?Number(t.currentTarget.value):t.currentTarget.value,"checkbox"==t.currentTarget.type&&(o=t.currentTarget.checked),i.next=5,game.settings.set(a[0],a[1],o);case 5:null===(r=game.dsa5.apps.tokenHotbar)||void 0===r||r.render(!0);case 6:case"end":return i.stop()}}),_callee10)})));return function(r){return t.apply(this,arguments)}}()),t.find(".bags .slot").click((function(t){return r._onMasterFunctionClicked(t)}))}},{key:"_onMasterFunctionClicked",value:(o=configuration_asyncToGenerator(configuration_regeneratorRuntime().mark((function _callee11(t){var r,a,o;return configuration_regeneratorRuntime().wrap((function _callee11$(i){for(;;)switch(i.prev=i.next){case 0:return a=t.currentTarget.dataset.id,(o=game.settings.get("dsa5","enableMasterTokenFunctions"))[a]=!o[a],i.next=5,game.settings.set("dsa5","enableMasterTokenFunctions",o);case 5:$(t.currentTarget).toggleClass("deactivated",o[a]),game.dsa5.apps.tokenHotbar.gmItems.find((function(t){return t.id==a})).disabled=o[a],null===(r=game.dsa5.apps.tokenHotbar)||void 0===r||r.render(!0);case 8:case"end":return i.stop()}}),_callee11)}))),function _onMasterFunctionClicked(t){return o.apply(this,arguments)})},{key:"getData",value:(a=configuration_asyncToGenerator(configuration_regeneratorRuntime().mark((function _callee12(t){var r;return configuration_regeneratorRuntime().wrap((function _callee12$(a){for(;;)switch(a.prev=a.next){case 0:return a.next=2,configuration_get(configuration_getPrototypeOf(ConfigureTokenHotbar.prototype),"getData",this).call(this,t);case 2:return r=a.sent,mergeObject(r,{tokenhotbarSize:game.settings.get("dsa5","tokenhotbarSize"),tokenhotbarLayout:game.settings.get("dsa5","tokenhotbarLayout"),disableTokenhotbarMaster:game.settings.get("dsa5","disableTokenhotbarMaster"),disableTokenhotbar:game.settings.get("dsa5","disableTokenhotbar"),isGM:game.user.isGM,gmButtons:game.dsa5.apps.tokenHotbar.gmItems}),a.abrupt("return",r);case 5:case"end":return a.stop()}}),_callee12,this)}))),function getData(t){return a.apply(this,arguments)})},{key:"resetTokenHotbar",value:(r=configuration_asyncToGenerator(configuration_regeneratorRuntime().mark((function _callee13(t){var r,a;return configuration_regeneratorRuntime().wrap((function _callee13$(o){for(;;)switch(o.prev=o.next){case 0:return t.preventDefault(),t.stopPropagation(),o.next=4,game.settings.set("dsa5","tokenhotbarPosition",{});case 4:return o.next=6,game.settings.set("dsa5","tokenhotbarLayout",0);case 6:return o.next=8,game.settings.set("dsa5","tokenhotbarSize",35);case 8:null===(r=game.dsa5.apps.tokenHotbar)||void 0===r||r.resetPosition(),null===(a=game.dsa5.apps.tokenHotbar)||void 0===a||a.render(!0);case 10:case"end":return o.stop()}}),_callee13)}))),function resetTokenHotbar(t){return r.apply(this,arguments)})}],[{key:"defaultOptions",get:function get(){var t=configuration_get(configuration_getPrototypeOf(ConfigureTokenHotbar),"defaultOptions",this);return mergeObject(t,{title:game.i18n.localize("DSASETTINGS.configureTokenbar")}),t}}]),ConfigureTokenHotbar}();function journal_typeof(t){return journal_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},journal_typeof(t)}function journal_regeneratorRuntime(){journal_regeneratorRuntime=function _regeneratorRuntime(){return t};var t={},r=Object.prototype,a=r.hasOwnProperty,o="function"==typeof Symbol?Symbol:{},i=o.iterator||"@@iterator",c=o.asyncIterator||"@@asyncIterator",u=o.toStringTag||"@@toStringTag";function define(t,r,a){return Object.defineProperty(t,r,{value:a,enumerable:!0,configurable:!0,writable:!0}),t[r]}try{define({},"")}catch(t){define=function define(t,r,a){return t[r]=a}}function wrap(t,r,a,o){var i=r&&r.prototype instanceof Generator?r:Generator,c=Object.create(i.prototype),u=new Context(o||[]);return c._invoke=function(t,r,a){var o="suspendedStart";return function(i,c){if("executing"===o)throw new Error("Generator is already running");if("completed"===o){if("throw"===i)throw c;return doneResult()}for(a.method=i,a.arg=c;;){var u=a.delegate;if(u){var p=maybeInvokeDelegate(u,a);if(p){if(p===l)continue;return p}}if("next"===a.method)a.sent=a._sent=a.arg;else if("throw"===a.method){if("suspendedStart"===o)throw o="completed",a.arg;a.dispatchException(a.arg)}else"return"===a.method&&a.abrupt("return",a.arg);o="executing";var d=tryCatch(t,r,a);if("normal"===d.type){if(o=a.done?"completed":"suspendedYield",d.arg===l)continue;return{value:d.arg,done:a.done}}"throw"===d.type&&(o="completed",a.method="throw",a.arg=d.arg)}}}(t,a,u),c}function tryCatch(t,r,a){try{return{type:"normal",arg:t.call(r,a)}}catch(t){return{type:"throw",arg:t}}}t.wrap=wrap;var l={};function Generator(){}function GeneratorFunction(){}function GeneratorFunctionPrototype(){}var p={};define(p,i,(function(){return this}));var d=Object.getPrototypeOf,h=d&&d(d(values([])));h&&h!==r&&a.call(h,i)&&(p=h);var m=GeneratorFunctionPrototype.prototype=Generator.prototype=Object.create(p);function defineIteratorMethods(t){["next","throw","return"].forEach((function(r){define(t,r,(function(t){return this._invoke(r,t)}))}))}function AsyncIterator(t,r){function invoke(o,i,c,u){var l=tryCatch(t[o],t,i);if("throw"!==l.type){var p=l.arg,d=p.value;return d&&"object"==journal_typeof(d)&&a.call(d,"__await")?r.resolve(d.__await).then((function(t){invoke("next",t,c,u)}),(function(t){invoke("throw",t,c,u)})):r.resolve(d).then((function(t){p.value=t,c(p)}),(function(t){return invoke("throw",t,c,u)}))}u(l.arg)}var o;this._invoke=function(t,a){function callInvokeWithMethodAndArg(){return new r((function(r,o){invoke(t,a,r,o)}))}return o=o?o.then(callInvokeWithMethodAndArg,callInvokeWithMethodAndArg):callInvokeWithMethodAndArg()}}function maybeInvokeDelegate(t,r){var a=t.iterator[r.method];if(void 0===a){if(r.delegate=null,"throw"===r.method){if(t.iterator.return&&(r.method="return",r.arg=void 0,maybeInvokeDelegate(t,r),"throw"===r.method))return l;r.method="throw",r.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var o=tryCatch(a,t.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,l;var i=o.arg;return i?i.done?(r[t.resultName]=i.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=void 0),r.delegate=null,l):i:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,l)}function pushTryEntry(t){var r={tryLoc:t[0]};1 in t&&(r.catchLoc=t[1]),2 in t&&(r.finallyLoc=t[2],r.afterLoc=t[3]),this.tryEntries.push(r)}function resetTryEntry(t){var r=t.completion||{};r.type="normal",delete r.arg,t.completion=r}function Context(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(pushTryEntry,this),this.reset(!0)}function values(t){if(t){var r=t[i];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var o=-1,c=function next(){for(;++o=0;--o){var i=this.tryEntries[o],c=i.completion;if("root"===i.tryLoc)return handle("end");if(i.tryLoc<=this.prev){var u=a.call(i,"catchLoc"),l=a.call(i,"finallyLoc");if(u&&l){if(this.prev=0;--o){var i=this.tryEntries[o];if(i.tryLoc<=this.prev&&a.call(i,"finallyLoc")&&this.prev=0;--r){var a=this.tryEntries[r];if(a.finallyLoc===t)return this.complete(a.completion,a.afterLoc),resetTryEntry(a),l}},catch:function _catch(t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc===t){var o=a.completion;if("throw"===o.type){var i=o.arg;resetTryEntry(a)}return i}}throw new Error("illegal catch attempt")},delegateYield:function delegateYield(t,r,a){return this.delegate={iterator:values(t),resultName:r,nextLoc:a},"next"===this.method&&(this.arg=void 0),l}},t}function journal_asyncGeneratorStep(t,r,a,o,i,c,u){try{var l=t[c](u),p=l.value}catch(t){return void a(t)}l.done?r(p):Promise.resolve(p).then(o,i)}function journal_asyncToGenerator(t){return function(){var r=this,a=arguments;return new Promise((function(o,i){var c=t.apply(r,a);function _next(t){journal_asyncGeneratorStep(c,o,i,_next,_throw,"next",t)}function _throw(t){journal_asyncGeneratorStep(c,o,i,_next,_throw,"throw",t)}_next(void 0)}))}}function increaseFontSize(t){return _increaseFontSize.apply(this,arguments)}function _increaseFontSize(){return(_increaseFontSize=journal_asyncToGenerator(journal_regeneratorRuntime().mark((function _callee3(t){var a,o;return journal_regeneratorRuntime().wrap((function _callee3$(i){for(;;)switch(i.prev=i.next){case 0:if(a=game.settings.get("dsa5","journalFontSizeIndex"),(o=a+1)!=r.Z.journalFontSizes.length+1){i.next=10;break}return o=0,i.next=6,game.settings.set("dsa5","journalFontSizeIndex",o);case 6:t.css("fontSize",""),(0,h.p0)(game.i18n.format("CHATNOTIFICATION.fontsize",{size:"Default "})),i.next=13;break;case 10:return i.next=12,game.settings.set("dsa5","journalFontSizeIndex",o);case 12:setOuterFontSize(t);case 13:case"end":return i.stop()}}),_callee3)})))).apply(this,arguments)}function setOuterFontSize(t){var a=game.settings.get("dsa5","journalFontSizeIndex"),o=r.Z.journalFontSizes[a-1]||14;(0,h.p0)(game.i18n.format("CHATNOTIFICATION.fontsize",{size:o})),t.css("fontSize","".concat(o,"px"))}function tokenHUD_typeof(t){return tokenHUD_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},tokenHUD_typeof(t)}function tokenHUD_createForOfIteratorHelper(t,r){var a="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!a){if(Array.isArray(t)||(a=function tokenHUD_unsupportedIterableToArray(t,r){if(!t)return;if("string"==typeof t)return tokenHUD_arrayLikeToArray(t,r);var a=Object.prototype.toString.call(t).slice(8,-1);"Object"===a&&t.constructor&&(a=t.constructor.name);if("Map"===a||"Set"===a)return Array.from(t);if("Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a))return tokenHUD_arrayLikeToArray(t,r)}(t))||r&&t&&"number"==typeof t.length){a&&(t=a);var o=0,i=function F(){};return{s:i,n:function n(){return o>=t.length?{done:!0}:{done:!1,value:t[o++]}},e:function e(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var c,u=!0,l=!1;return{s:function s(){a=a.call(t)},n:function n(){var t=a.next();return u=t.done,t},e:function e(t){l=!0,c=t},f:function f(){try{u||null==a.return||a.return()}finally{if(l)throw c}}}}function tokenHUD_arrayLikeToArray(t,r){(null==r||r>t.length)&&(r=t.length);for(var a=0,o=new Array(r);a=0;--o){var i=this.tryEntries[o],c=i.completion;if("root"===i.tryLoc)return handle("end");if(i.tryLoc<=this.prev){var u=a.call(i,"catchLoc"),l=a.call(i,"finallyLoc");if(u&&l){if(this.prev=0;--o){var i=this.tryEntries[o];if(i.tryLoc<=this.prev&&a.call(i,"finallyLoc")&&this.prev=0;--r){var a=this.tryEntries[r];if(a.finallyLoc===t)return this.complete(a.completion,a.afterLoc),resetTryEntry(a),l}},catch:function _catch(t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc===t){var o=a.completion;if("throw"===o.type){var i=o.arg;resetTryEntry(a)}return i}}throw new Error("illegal catch attempt")},delegateYield:function delegateYield(t,r,a){return this.delegate={iterator:values(t),resultName:r,nextLoc:a},"next"===this.method&&(this.arg=void 0),l}},t}function tokenHUD_defineProperty(t,r,a){return r in t?Object.defineProperty(t,r,{value:a,enumerable:!0,configurable:!0,writable:!0}):t[r]=a,t}function tokenHUD_asyncGeneratorStep(t,r,a,o,i,c,u){try{var l=t[c](u),p=l.value}catch(t){return void a(t)}l.done?r(p):Promise.resolve(p).then(o,i)}function tokenHUD_asyncToGenerator(t){return function(){var r=this,a=arguments;return new Promise((function(o,i){var c=t.apply(r,a);function _next(t){tokenHUD_asyncGeneratorStep(c,o,i,_next,_throw,"next",t)}function _throw(t){tokenHUD_asyncGeneratorStep(c,o,i,_next,_throw,"throw",t)}_next(void 0)}))}}function swarmButtons(t,r,a){if(game.user.isGM){var o=t.object.actor;if(o.isToken)if(canvas.tokens.controlled.length>=2){var i=o._id;if(!canvas.tokens.controlled.every((function(t){var r;return(null===(r=t.actor)||void 0===r?void 0:r._id)==i})))return;r.find(".col.left").prepend(swarmHud("swarm.combine"));var c=r.find('.control-icon[data-action="swarm"]');c.click((function(){!function combineSwarm(t,r){return _combineSwarm.apply(this,arguments)}(o,t.object.document),c.remove()}))}else if(o.isSwarm()){r.find(".col.left").prepend(swarmHud("swarm.split"));var u=r.find('.control-icon[data-action="swarm"]');u.click((function(){!function splitSwarm(t,r){return _splitSwarm.apply(this,arguments)}(o,t.object.document),u.remove()}))}}}var Ve=function(t){!function tokenHUD_inherits(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(r&&r.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),r&&tokenHUD_setPrototypeOf(t,r)}(SwarmDialog,Dialog);var r=tokenHUD_createSuper(SwarmDialog);function SwarmDialog(){return tokenHUD_classCallCheck(this,SwarmDialog),r.apply(this,arguments)}return function tokenHUD_createClass(t,r,a){return r&&tokenHUD_defineProperties(t.prototype,r),a&&tokenHUD_defineProperties(t,a),Object.defineProperty(t,"prototype",{writable:!1}),t}(SwarmDialog,[{key:"activateListeners",value:function activateListeners(t){tokenHUD_get(tokenHUD_getPrototypeOf(SwarmDialog.prototype),"activateListeners",this).call(this,t),t.find('input[type="range"]').change((function(t){$(t.currentTarget).closest(".row-section").find(".range-value").html($(t.currentTarget).val())}))}}]),SwarmDialog}();function swarmHud(t){return'
    ')}function _splitSwarm(){return _splitSwarm=tokenHUD_asyncToGenerator(tokenHUD_regeneratorRuntime().mark((function _callee3(t,r){var a,o;return tokenHUD_regeneratorRuntime().wrap((function _callee3$(i){for(;;)switch(i.prev=i.next){case 0:return a=Number(t.system.swarm.count)-1,i.next=3,renderTemplate("systems/dsa5/templates/dialog/swarm-split-dialog.html",{actor:t,maxSplitsize:a});case 3:o=i.sent,new Ve({title:game.i18n.localize("swarm.split"),content:o,default:"yes",buttons:{Yes:{icon:'',label:game.i18n.localize("ok"),callback:function(){var a=tokenHUD_asyncToGenerator(tokenHUD_regeneratorRuntime().mark((function _callee2(a){var o,i,c,u,l,p;return tokenHUD_regeneratorRuntime().wrap((function _callee2$(d){for(;;)switch(d.prev=d.next){case 0:return o=Number(a.find('input[type="range"]').val()),i=deepClone(r),c=Math.floor(t.system.status.wounds.value/t.system.swarm.count*o),u=t.system.status.wounds.value-c,d.next=6,t.update({"system.swarm.count":t.system.swarm.count-o,"system.status.wounds.value":u},{skipSwarmUpdate:!0});case 6:return d.next=8,canvas.scene.createEmbeddedDocuments("Token",[i]);case 8:return d.next=10,i.actor.update({"system.swarm.count":o,"system.status.wounds.value":c},{skipSwarmUpdate:!0});case 10:return l=["x","y"][Math.floor(2*Math.random())],p=Math.random()>.5?1:-1,d.next=14,canvas.scene.updateEmbeddedDocuments("Token",[tokenHUD_defineProperty({_id:i.id},l,r[l]+canvas.scene.grid.size*p)]);case 14:case"end":return d.stop()}}),_callee2)})));return function callback(t){return a.apply(this,arguments)}}()},delete:{icon:'',label:game.i18n.localize("cancel")}}}).render(!0);case 5:case"end":return i.stop()}}),_callee3)}))),_splitSwarm.apply(this,arguments)}function _combineSwarm(){return(_combineSwarm=tokenHUD_asyncToGenerator(tokenHUD_regeneratorRuntime().mark((function _callee4(t,r){var a,o,i,c,u,l,p;return tokenHUD_regeneratorRuntime().wrap((function _callee4$(t){for(;;)switch(t.prev=t.next){case 0:a=0,o=0,i=tokenHUD_createForOfIteratorHelper(canvas.tokens.controlled);try{for(i.s();!(c=i.n()).done;)l=c.value,a+=Number(null===(u=l.actor.system.swarm)||void 0===u?void 0:u.count)||1,o+=Number(l.actor.system.status.wounds.value)}catch(t){i.e(t)}finally{i.f()}return t.next=6,r.actor.update({"system.swarm.count":a,"system.status.wounds.value":o},{skipSwarmUpdate:!0});case 6:return p=canvas.tokens.controlled.map((function(t){return t.id})).filter((function(t){return t!=r.id})),t.next=9,canvas.scene.updateEmbeddedDocuments("Token",p.map((function(t){return{_id:t,x:r.x,y:r.y}})));case 9:return t.next=11,canvas.scene.deleteEmbeddedDocuments("Token",p);case 11:case"end":return t.stop()}}),_callee4)})))).apply(this,arguments)}function tokenHUD(){Hooks.on("renderTokenHUD",(function(t,r,a){ye.hide(t.object);var o=t.object.actor;o&&(!function addThirdBarToHUD(t,r,a){if(r.system.isPriest&&r.system.isMage){var o=r.system.status.karmaenergy.value,i='
    ');t.find(".col.middle").prepend(i),t.find(".bar3 input").change(function(){var t=tokenHUD_asyncToGenerator(tokenHUD_regeneratorRuntime().mark((function _callee(t){var o,i,c,u,l;return tokenHUD_regeneratorRuntime().wrap((function _callee$(p){for(;;)switch(p.prev=p.next){case 0:return o=t.currentTarget,i=o.value.trim(),c=i.startsWith("+")||i.startsWith("-"),i.startsWith("=")&&(i=i.slice(1)),u=Number(i),l=o.name.split(".").reduce((function(t,r){return t[r]}),r),p.next=8,r.update(tokenHUD_defineProperty({},o.name,c?l+u:u));case 8:a.clear();case 9:case"end":return p.stop()}}),_callee)})));return function(r){return t.apply(this,arguments)}}())}}(r,o,t),game.dsa5.apps.LightDialog&&game.dsa5.apps.LightDialog.lightHud(r,o,a),swarmButtons(t,r)),r.find('.control-icon[data-action="target"]').mousedown((function(t){2==t.button&&(game.user.updateTokenTargets([]),$(t.currentTarget).click(),t.preventDefault())})),r.find(".attribute input").off("change"),b.Z.renderTokenHUD(t,r,a)}))}var Ke=__webpack_require__(416);function keybindings_typeof(t){return keybindings_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},keybindings_typeof(t)}function keybindings_regeneratorRuntime(){keybindings_regeneratorRuntime=function _regeneratorRuntime(){return t};var t={},r=Object.prototype,a=r.hasOwnProperty,o="function"==typeof Symbol?Symbol:{},i=o.iterator||"@@iterator",c=o.asyncIterator||"@@asyncIterator",u=o.toStringTag||"@@toStringTag";function define(t,r,a){return Object.defineProperty(t,r,{value:a,enumerable:!0,configurable:!0,writable:!0}),t[r]}try{define({},"")}catch(t){define=function define(t,r,a){return t[r]=a}}function wrap(t,r,a,o){var i=r&&r.prototype instanceof Generator?r:Generator,c=Object.create(i.prototype),u=new Context(o||[]);return c._invoke=function(t,r,a){var o="suspendedStart";return function(i,c){if("executing"===o)throw new Error("Generator is already running");if("completed"===o){if("throw"===i)throw c;return doneResult()}for(a.method=i,a.arg=c;;){var u=a.delegate;if(u){var p=maybeInvokeDelegate(u,a);if(p){if(p===l)continue;return p}}if("next"===a.method)a.sent=a._sent=a.arg;else if("throw"===a.method){if("suspendedStart"===o)throw o="completed",a.arg;a.dispatchException(a.arg)}else"return"===a.method&&a.abrupt("return",a.arg);o="executing";var d=tryCatch(t,r,a);if("normal"===d.type){if(o=a.done?"completed":"suspendedYield",d.arg===l)continue;return{value:d.arg,done:a.done}}"throw"===d.type&&(o="completed",a.method="throw",a.arg=d.arg)}}}(t,a,u),c}function tryCatch(t,r,a){try{return{type:"normal",arg:t.call(r,a)}}catch(t){return{type:"throw",arg:t}}}t.wrap=wrap;var l={};function Generator(){}function GeneratorFunction(){}function GeneratorFunctionPrototype(){}var p={};define(p,i,(function(){return this}));var d=Object.getPrototypeOf,h=d&&d(d(values([])));h&&h!==r&&a.call(h,i)&&(p=h);var m=GeneratorFunctionPrototype.prototype=Generator.prototype=Object.create(p);function defineIteratorMethods(t){["next","throw","return"].forEach((function(r){define(t,r,(function(t){return this._invoke(r,t)}))}))}function AsyncIterator(t,r){function invoke(o,i,c,u){var l=tryCatch(t[o],t,i);if("throw"!==l.type){var p=l.arg,d=p.value;return d&&"object"==keybindings_typeof(d)&&a.call(d,"__await")?r.resolve(d.__await).then((function(t){invoke("next",t,c,u)}),(function(t){invoke("throw",t,c,u)})):r.resolve(d).then((function(t){p.value=t,c(p)}),(function(t){return invoke("throw",t,c,u)}))}u(l.arg)}var o;this._invoke=function(t,a){function callInvokeWithMethodAndArg(){return new r((function(r,o){invoke(t,a,r,o)}))}return o=o?o.then(callInvokeWithMethodAndArg,callInvokeWithMethodAndArg):callInvokeWithMethodAndArg()}}function maybeInvokeDelegate(t,r){var a=t.iterator[r.method];if(void 0===a){if(r.delegate=null,"throw"===r.method){if(t.iterator.return&&(r.method="return",r.arg=void 0,maybeInvokeDelegate(t,r),"throw"===r.method))return l;r.method="throw",r.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var o=tryCatch(a,t.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,l;var i=o.arg;return i?i.done?(r[t.resultName]=i.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=void 0),r.delegate=null,l):i:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,l)}function pushTryEntry(t){var r={tryLoc:t[0]};1 in t&&(r.catchLoc=t[1]),2 in t&&(r.finallyLoc=t[2],r.afterLoc=t[3]),this.tryEntries.push(r)}function resetTryEntry(t){var r=t.completion||{};r.type="normal",delete r.arg,t.completion=r}function Context(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(pushTryEntry,this),this.reset(!0)}function values(t){if(t){var r=t[i];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var o=-1,c=function next(){for(;++o=0;--o){var i=this.tryEntries[o],c=i.completion;if("root"===i.tryLoc)return handle("end");if(i.tryLoc<=this.prev){var u=a.call(i,"catchLoc"),l=a.call(i,"finallyLoc");if(u&&l){if(this.prev=0;--o){var i=this.tryEntries[o];if(i.tryLoc<=this.prev&&a.call(i,"finallyLoc")&&this.prev=0;--r){var a=this.tryEntries[r];if(a.finallyLoc===t)return this.complete(a.completion,a.afterLoc),resetTryEntry(a),l}},catch:function _catch(t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc===t){var o=a.completion;if("throw"===o.type){var i=o.arg;resetTryEntry(a)}return i}}throw new Error("illegal catch attempt")},delegateYield:function delegateYield(t,r,a){return this.delegate={iterator:values(t),resultName:r,nextLoc:a},"next"===this.method&&(this.arg=void 0),l}},t}function keybindings_asyncGeneratorStep(t,r,a,o,i,c,u){try{var l=t[c](u),p=l.value}catch(t){return void a(t)}l.done?r(p):Promise.resolve(p).then(o,i)}function keybindings(){var r;game.keybindings.register("dsa5","masterMenu",{name:"gmMenu",hint:game.i18n.localize("KEYBINDINGS.masterMenu"),editable:[{key:"KeyM"}],onDown:function onDown(){return t.Z.renderToggle(game.dsa5.apps.gameMasterMenu)},restricted:!0}),game.keybindings.register("dsa5","journalBrowser",{name:"Book.Wizard",hint:game.i18n.localize("KEYBINDINGS.journalBrowser"),editable:[{key:"KeyJ"}],onDown:function onDown(){return t.Z.renderToggle(game.dsa5.apps.journalBrowser)}}),game.keybindings.register("dsa5","library",{name:"ItemLibrary",hint:game.i18n.localize("KEYBINDINGS.library"),editable:[{key:"KeyL"}],onDown:function onDown(){return t.Z.renderToggle(game.dsa5.itemLibrary)}}),game.keybindings.register("dsa5","attacktest",{name:"attacktest",hint:game.i18n.localize("KEYBINDINGS.attack"),editable:[{key:"KeyB"}],onDown:function onDown(){return Ge.runActAttackDialog()}}),game.keybindings.register("dsa5","combatTrackerNext",{name:"COMBAT.TurnNext",hint:game.i18n.localize("COMBAT.TurnNext"),editable:[{key:"KeyN"}],onDown:function onDown(){return Je("nextTurn")}}),game.keybindings.register("dsa5","combatTrackerPrevious",{name:"COMBAT.TurnPrev",hint:game.i18n.localize("COMBAT.TurnPrev"),editable:[{key:"KeyV"}],onDown:function onDown(){return Je("previousTurn")}}),game.keybindings.register("dsa5","setTargetToUser",{name:"DIALOG.setTargetToUser",hint:game.i18n.localize("DIALOG.setTargetToUserHint"),editable:[],onDown:(r=function keybindings_asyncToGenerator(t){return function(){var r=this,a=arguments;return new Promise((function(o,i){var c=t.apply(r,a);function _next(t){keybindings_asyncGeneratorStep(c,o,i,_next,_throw,"next",t)}function _throw(t){keybindings_asyncGeneratorStep(c,o,i,_next,_throw,"throw",t)}_next(void 0)}))}}(keybindings_regeneratorRuntime().mark((function _callee(){return keybindings_regeneratorRuntime().wrap((function _callee$(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,Ke.Z0.getDialog();case 2:return t.abrupt("return",t.sent.render(!0));case 3:case"end":return t.stop()}}),_callee)}))),function onDown(){return r.apply(this,arguments)}),restricted:!0})}var Je=function combatTurn(t){var r,a;(null===(r=game.combat)||void 0===r||null===(a=r.combatant)||void 0===a?void 0:a.isOwner)&&game.combat[t]()};function dsarolls_createForOfIteratorHelper(t,r){var a="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!a){if(Array.isArray(t)||(a=function dsarolls_unsupportedIterableToArray(t,r){if(!t)return;if("string"==typeof t)return dsarolls_arrayLikeToArray(t,r);var a=Object.prototype.toString.call(t).slice(8,-1);"Object"===a&&t.constructor&&(a=t.constructor.name);if("Map"===a||"Set"===a)return Array.from(t);if("Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a))return dsarolls_arrayLikeToArray(t,r)}(t))||r&&t&&"number"==typeof t.length){a&&(t=a);var o=0,i=function F(){};return{s:i,n:function n(){return o>=t.length?{done:!0}:{done:!1,value:t[o++]}},e:function e(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var c,u=!0,l=!1;return{s:function s(){a=a.call(t)},n:function n(){var t=a.next();return u=t.done,t},e:function e(t){l=!0,c=t},f:function f(){try{u||null==a.return||a.return()}finally{if(l)throw c}}}}function dsarolls_arrayLikeToArray(t,r){(null==r||r>t.length)&&(r=t.length);for(var a=0,o=new Array(r);a=t.length?{done:!0}:{done:!1,value:t[o++]}},e:function e(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var c,u=!0,l=!1;return{s:function s(){a=a.call(t)},n:function n(){var t=a.next();return u=t.done,t},e:function e(t){l=!0,c=t},f:function f(){try{u||null==a.return||a.return()}finally{if(l)throw c}}}}function adventure_wizard_unsupportedIterableToArray(t,r){if(t){if("string"==typeof t)return adventure_wizard_arrayLikeToArray(t,r);var a=Object.prototype.toString.call(t).slice(8,-1);return"Object"===a&&t.constructor&&(a=t.constructor.name),"Map"===a||"Set"===a?Array.from(t):"Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a)?adventure_wizard_arrayLikeToArray(t,r):void 0}}function adventure_wizard_arrayLikeToArray(t,r){(null==r||r>t.length)&&(r=t.length);for(var a=0,o=new Array(r);a=0;--o){var i=this.tryEntries[o],c=i.completion;if("root"===i.tryLoc)return handle("end");if(i.tryLoc<=this.prev){var u=a.call(i,"catchLoc"),l=a.call(i,"finallyLoc");if(u&&l){if(this.prev=0;--o){var i=this.tryEntries[o];if(i.tryLoc<=this.prev&&a.call(i,"finallyLoc")&&this.prev=0;--r){var a=this.tryEntries[r];if(a.finallyLoc===t)return this.complete(a.completion,a.afterLoc),resetTryEntry(a),l}},catch:function _catch(t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc===t){var o=a.completion;if("throw"===o.type){var i=o.arg;resetTryEntry(a)}return i}}throw new Error("illegal catch attempt")},delegateYield:function delegateYield(t,r,a){return this.delegate={iterator:values(t),resultName:r,nextLoc:a},"next"===this.method&&(this.arg=void 0),l}},t}function adventure_wizard_asyncGeneratorStep(t,r,a,o,i,c,u){try{var l=t[c](u),p=l.value}catch(t){return void a(t)}l.done?r(p):Promise.resolve(p).then(o,i)}function adventure_wizard_asyncToGenerator(t){return function(){var r=this,a=arguments;return new Promise((function(o,i){var c=t.apply(r,a);function _next(t){adventure_wizard_asyncGeneratorStep(c,o,i,_next,_throw,"next",t)}function _throw(t){adventure_wizard_asyncGeneratorStep(c,o,i,_next,_throw,"throw",t)}_next(void 0)}))}}function adventure_wizard_classCallCheck(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}function adventure_wizard_defineProperties(t,r){for(var a=0;a0&&void 0!==a[0]&&a[0],r=a.length>1&&void 0!==a[1]?a[1]:{},o.next=4,adventure_wizard_get(adventure_wizard_getPrototypeOf(BookWizard.prototype),"_render",this).call(this,t,r);case 4:$(this._element).find(".library").attr("data-tooltip","Book.home"),$(this._element).find(".increaseFontSize").attr("data-tooltip","SHEET.increaseFontSize");case 6:case"end":return o.stop()}}),_callee3,this)}))),function _render(){return O.apply(this,arguments)})},{key:"_showBooks",value:function _showBooks(){this.book=null,this.bookData=null,this.selectedChapter=null,this.selectedType=null,this.journals=null,this.actors=null,this.scenes=null,this.content=void 0,this.journalIndex=null,this.fulltextsearch=!0,this.currentType=void 0,this.selectedSubChapter=void 0,this.loadPage(this._element)}},{key:"toggleBookVisibility",value:(A=adventure_wizard_asyncToGenerator(adventure_wizard_regeneratorRuntime().mark((function _callee4(t,r,a){var o,i,c,u,l,p,d,h,m;return adventure_wizard_regeneratorRuntime().wrap((function _callee4$(y){for(;;)switch(y.prev=y.next){case 0:return(o=game.settings.get("dsa5","expansionPermissions"))[t]=a,y.next=4,game.settings.set("dsa5","expansionPermissions",o);case 4:return i=this[r].find((function(r){return r.id==t})),y.next=7,fetch(i.path);case 7:return y.next=9,y.sent.json();case 9:c=y.sent,u=0,l=["actors","journal","scenes"];case 12:if(!(u').concat(t.name,"")})),$(this._element).find(".tocContent").html("
      ".concat(a.join("\n"),"
    ")),o.next=23;break;case 19:return o.next=21,this.getToc();case 21:r=o.sent,$(this._element).find(".adventureWizard > .row-section > .toc").html(r).find(".filterJournals").focus();case 23:case"end":return o.stop()}}),_callee11,this)}))),function filterToc(t){return w.apply(this,arguments)})},{key:"showJournal",value:(k=adventure_wizard_asyncToGenerator(adventure_wizard_regeneratorRuntime().mark((function _callee12(t){var r,a,o,i,c,u,l,p,d,h,m,y=this;return adventure_wizard_regeneratorRuntime().wrap((function _callee12$(g){for(;;)switch(g.prev=g.next){case 0:r="",a=adventure_wizard_createForOfIteratorHelper(t.pages),g.prev=2,a.s();case 4:if((o=a.n()).done){g.next=18;break}return i=o.value,c=t.sheet.getPageSheet(i.id),g.next=9,c.getData();case 9:return u=g.sent,g.next=12,c._renderInner(u);case 12:l=g.sent.get(),p=$(l[l.length-1]).html(),"video"==i.type&&(p='
    '.concat(p,"
    ")),r+=p;case 16:g.next=4;break;case 18:g.next=23;break;case 20:g.prev=20,g.t0=g.catch(2),a.e(g.t0);case 23:return g.prev=23,a.f(),g.finish(23);case 26:return d=this.findSceneNote(t.getFlag("dsa5","initId")),g.next=29,TextEditor.enrichHTML(r,{secrets:game.user.isGM,async:!0});case 29:h=g.sent,this.content='

    ').concat(t.name,'
    ').concat(d,'

    ').concat(h),(m=$(this._element).find(".chapter")).html(this.content),this.selectedSubChapter=t.id,$(this._element).find(".subChapter").removeClass("selected"),$(this._element).find('[data-jid="'.concat(t.id,'"]')).addClass("selected"),bindImgToCanvasDragStart(m),m.find(".documentName-link, .entity-link, .content-link").click((function(t){var r=$(t.currentTarget);y.bookData&&r.attr("data-pack")==y.bookData.journal&&(t.stopPropagation(),y.loadJournalById(r.attr("data-id")))}));case 38:case"end":return g.stop()}}),_callee12,this,[[2,20,23,26]])}))),function showJournal(t){return k.apply(this,arguments)})},{key:"findSceneNote",value:function findSceneNote(t){if(t){var r=game.journal.find((function(r){return r.getFlag("dsa5","initId")==t}));if(r&&r.sceneNote)return'')}return""}},{key:"importBook",value:(b=adventure_wizard_asyncToGenerator(adventure_wizard_regeneratorRuntime().mark((function _callee13(){return adventure_wizard_regeneratorRuntime().wrap((function _callee13$(t){for(;;)switch(t.prev=t.next){case 0:game.user.isGM&&(new Xe).render(this.bookData.moduleName);case 1:case"end":return t.stop()}}),_callee13,this)}))),function importBook(){return b.apply(this,arguments)})},{key:"loadBook",value:(v=adventure_wizard_asyncToGenerator(adventure_wizard_regeneratorRuntime().mark((function _callee16(t,r,a){var o=this;return adventure_wizard_regeneratorRuntime().wrap((function _callee16$(i){for(;;)switch(i.prev=i.next){case 0:return a||(a=this.currentType),this.currentType=a,this.book=this[a].find((function(r){return r.id==t})),i.next=5,fetch(this.book.path).then(function(){var t=adventure_wizard_asyncToGenerator(adventure_wizard_regeneratorRuntime().mark((function _callee14(t){return adventure_wizard_regeneratorRuntime().wrap((function _callee14$(r){for(;;)switch(r.prev=r.next){case 0:return r.abrupt("return",t.json());case 1:case"end":return r.stop()}}),_callee14)})));return function(r){return t.apply(this,arguments)}}()).then(function(){var t=adventure_wizard_asyncToGenerator(adventure_wizard_regeneratorRuntime().mark((function _callee15(t){var a,i;return adventure_wizard_regeneratorRuntime().wrap((function _callee15$(c){for(;;)switch(c.prev=c.next){case 0:return o.bookData=t,a=game.packs.get(t.journal),c.next=4,a.getIndex();case 4:return c.next=6,a.getDocuments();case 6:if(i=c.sent,o.journals=i,!t.actors){c.next=14;break}return a=game.packs.get(t.actors),c.next=12,a.getIndex();case 12:i=c.sent,o.actors=i;case 14:if(!t.scenes){c.next=20;break}return a=game.packs.get(t.scenes),c.next=18,a.getIndex();case 18:i=c.sent,o.scenes=i;case 20:o.checkChapters(a),o.loadPage(r);case 22:case"end":return c.stop()}}),_callee15)})));return function(r){return t.apply(this,arguments)}}());case 5:case"end":return i.stop()}}),_callee16,this)}))),function loadBook(t,r,a){return v.apply(this,arguments)})},{key:"checkChapters",value:function checkChapters(t){this.bookData.chapters||(this.bookData.isDynamic=!0,this.bookData.chapters=[{name:game.i18n.localize("".concat(this.bookData.moduleName,".name")),content:t.folders.map((function(t){return{name:t.name,id:t.id}}))}])}},{key:"prefillActors",value:(g=adventure_wizard_asyncToGenerator(adventure_wizard_regeneratorRuntime().mark((function _callee17(t){var r,a,o,i,c,u,l=this;return adventure_wizard_regeneratorRuntime().wrap((function _callee17$(p){for(;;)switch(p.prev=p.next){case 0:if(t.actors){p.next=2;break}return p.abrupt("return",[]);case 2:return r=[],p.next=5,game.folders.contents.find((function(t){return t.name==game.i18n.localize("".concat(l.bookData.moduleName,".name"))&&"Actor"==t.type&&null==t.folder}));case 5:if(!(a=p.sent)){p.next=12;break}return p.next=9,game.folders.contents.filter((function(t){var r;return"Actor"==t.type&&(null===(r=t.folder)||void 0===r?void 0:r.id)==a.id})).map((function(t){return t.id}));case 9:p.t0=p.sent,p.next=13;break;case 12:p.t0=void 0;case 13:o=p.t0,i=adventure_wizard_createForOfIteratorHelper(t.actors);try{for(u=function _loop(){var t,a,i,u=c.value,p=null!=o&&o.length?game.actors.contents.find((function(t){var r;return t.name==u&&o.includes(null===(r=t.folder)||void 0===r?void 0:r.id)})):void 0,d=void 0,h=null===(t=p)||void 0===t?void 0:t.id,m=null===(a=p)||void 0===a?void 0:a.uuid;p||(p=l.actors.find((function(t){return t.name==u})),d=l.bookData.actors,h=null===(i=p)||void 0===i?void 0:i._id,m=p?"Compendium.".concat(d,".").concat(h):void 0),r.push({name:u,actor:p,pack:d,id:h,uuid:m})},i.s();!(c=i.n()).done;)u()}catch(t){i.e(t)}finally{i.f()}return p.abrupt("return",r);case 17:case"end":return p.stop()}}),_callee17)}))),function prefillActors(t){return g.apply(this,arguments)})},{key:"popJournal",value:(y=adventure_wizard_asyncToGenerator(adventure_wizard_regeneratorRuntime().mark((function _callee18(t){return adventure_wizard_regeneratorRuntime().wrap((function _callee18$(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,fromUuid(t);case 2:r.sent.sheet.render(!0);case 4:case"end":return r.stop()}}),_callee18)}))),function popJournal(t){return y.apply(this,arguments)})},{key:"showSzene",value:(m=adventure_wizard_asyncToGenerator(adventure_wizard_regeneratorRuntime().mark((function _callee19(t){var r,a,o=arguments;return adventure_wizard_regeneratorRuntime().wrap((function _callee19$(i){for(;;)switch(i.prev=i.next){case 0:if(r=o.length>1&&void 0!==o[1]?o[1]:"activate",a=game.scenes.contents.find((function(r){return r.name==t}))){i.next=4;break}return i.abrupt("return",ui.notifications.error(game.i18n.localize("DSAError.sceneNotInitialized")));case 4:i.t0=r,i.next="activate"===i.t0?7:"view"===i.t0?9:"toggle"===i.t0?11:13;break;case 7:return a.activate(),i.abrupt("break",13);case 9:return a.view(),i.abrupt("break",13);case 11:return a.update({navigation:!a.navigation}),i.abrupt("break",13);case 13:case"end":return i.stop()}}),_callee19)}))),function showSzene(t){return m.apply(this,arguments)})},{key:"getChapter",value:(d=adventure_wizard_asyncToGenerator(adventure_wizard_regeneratorRuntime().mark((function _callee20(){var t,r,a,o,i,c,u,l=this;return adventure_wizard_regeneratorRuntime().wrap((function _callee20$(p){for(;;)switch(p.prev=p.next){case 0:if(!this.book){p.next=42;break}if(!this.content){p.next=3;break}return p.abrupt("return",this.content);case 3:if(!this.selectedChapter){p.next=37;break}if("prep"!=this.selectedChapter){p.next=14;break}t={initDescr:game.i18n.format("".concat(this.bookData.moduleName,".importContent"),{defaultText:game.i18n.localize("importDefault")})},r=this.bookData.modules,a=adventure_wizard_createForOfIteratorHelper(r);try{for(a.s();!(o=a.n()).done;)(i=o.value).enabled=this.moduleEnabled(i.id)}catch(t){a.e(t)}finally{a.f()}return p.next=11,renderTemplate("systems/dsa5/templates/wizard/adventure/adventure_preparation.html",{modules:r,info:t});case 11:case 17:case 30:case 36:case 39:case 44:return p.abrupt("return",p.sent);case 14:if("foundryUsage"!=this.selectedChapter){p.next=18;break}return p.next=17,renderTemplate("systems/dsa5/templates/wizard/adventure/adventure_foundry.html");case 18:if(c=this.bookData.chapters.find((function(t){return t.name==l.selectedType})).content.find((function(t){return t.id==l.selectedChapter})),u=this.getSubChapters(),!c.scenes&&!c.actors&&0!=u.length){p.next=33;break}return p.t0=renderTemplate,p.t1=c,p.t2=this.getSubChapters(),p.next=26,this.prefillActors(c);case 26:return p.t3=p.sent,p.t4={chapter:p.t1,subChapters:p.t2,actors:p.t3},p.next=30,(0,p.t0)("systems/dsa5/templates/wizard/adventure/adventure_chapter.html",p.t4);case 33:return this.selectedSubChapter=u[0].id,p.next=36,this.loadJournalById(u[0].id);case 37:return p.next=39,renderTemplate("systems/dsa5/templates/wizard/adventure/adventure_cover.html",{book:this.book,bookData:this.bookData});case 42:return p.next=44,renderTemplate("systems/dsa5/templates/wizard/adventure/adventure_intro.html",{rshs:this.filterBooks(this.rshs),rules:this.filterBooks(this.books),adventures:this.filterBooks(this.adventures),isGM:game.user.isGM});case 45:case"end":return p.stop()}}),_callee20,this)}))),function getChapter(){return d.apply(this,arguments)})},{key:"filterBooks",value:function filterBooks(t){var r,a=game.settings.get("dsa5","expansionPermissions"),o=adventure_wizard_createForOfIteratorHelper(t);try{for(o.s();!(r=o.n()).done;){var i=r.value;null!=a[i.id]&&(i.visible=a[i.id])}}catch(t){o.e(t)}finally{o.f()}return game.user.isGM?t:t.filter((function(t){return null==t.visible||t.visible})).sort((function(t,r){return t.id.localeCompare(r.id)}))}},{key:"getSubChapters",value:function getSubChapters(){var t=this;return(this.bookData.isDynamic?this.journals.filter((function(r){return r.folder.id==t.selectedChapter})).sort((function(t,r){return t.sort>r.sort?1:-1})):this.journals.filter((function(r){return r.flags.dsa5.parent==t.selectedChapter})).sort((function(t,r){return t.flags.dsa5.sort>r.flags.dsa5.sort?1:-1}))).map((function(r){return{name:r.name,id:r.id,cssClass:r.id==t.selectedSubChapter?"selected":""}}))}},{key:"getToc",value:(p=adventure_wizard_asyncToGenerator(adventure_wizard_regeneratorRuntime().mark((function _callee21(){var t,r,a,o,i,c=this;return adventure_wizard_regeneratorRuntime().wrap((function _callee21$(u){for(;;)switch(u.prev=u.next){case 0:if(t=[],!this.book){u.next=29;break}if(t.push.apply(t,adventure_wizard_toConsumableArray(duplicate(this.bookData.chapters))),!this.selectedChapter){u.next=24;break}a=adventure_wizard_createForOfIteratorHelper(t),u.prev=5,a.s();case 7:if((o=a.n()).done){u.next=14;break}if(i=o.value,!(r=i.content.find((function(t){return t.id==c.selectedChapter})))){u.next=12;break}return u.abrupt("break",14);case 12:u.next=7;break;case 14:u.next=19;break;case 16:u.prev=16,u.t0=u.catch(5),a.e(u.t0);case 19:return u.prev=19,a.f(),u.finish(19);case 22:r.cssClass="selected",r.subChapters=this.getSubChapters();case 24:return u.next=26,renderTemplate("systems/dsa5/templates/wizard/adventure/adventure_toc.html",{chapters:t,book:this.book,fulltextsearch:this.fulltextsearch?"on":""});case 26:return u.abrupt("return",u.sent);case 29:return u.abrupt("return",'
    ');case 30:case"end":return u.stop()}}),_callee21,this,[[5,16,19,22]])}))),function getToc(){return p.apply(this,arguments)})},{key:"loadPage",value:(l=adventure_wizard_asyncToGenerator(adventure_wizard_regeneratorRuntime().mark((function _callee22(t){var r,a;return adventure_wizard_regeneratorRuntime().wrap((function _callee22$(o){for(;;)switch(o.prev=o.next){case 0:return o.next=2,this.getChapter();case 2:return r=o.sent,o.next=5,this.getToc();case 5:a=o.sent,t.find(".toc").html(a),t.find(".chapter").html(r);case 8:case"end":return o.stop()}}),_callee22,this)}))),function loadPage(t){return l.apply(this,arguments)})},{key:"getData",value:(c=adventure_wizard_asyncToGenerator(adventure_wizard_regeneratorRuntime().mark((function _callee23(t){var a,o,i,c,u;return adventure_wizard_regeneratorRuntime().wrap((function _callee23$(l){for(;;)switch(l.prev=l.next){case 0:return l.next=2,adventure_wizard_get(adventure_wizard_getPrototypeOf(BookWizard.prototype),"getData",this).call(this,t);case 2:return a=l.sent,l.next=5,this.getChapter();case 5:return o=l.sent,l.next=8,this.getToc();case 8:return i=l.sent,c=game.settings.get("dsa5","journalFontSizeIndex"),u=r.Z.journalFontSizes[c-1]||14,mergeObject(a,{adventure:this.bookData,currentChapter:o,breadcrumbs:this.renderBreadcrumbs(),toc:i,fontSize:u}),l.abrupt("return",a);case 13:case"end":return l.stop()}}),_callee23,this)}))),function getData(t){return c.apply(this,arguments)})},{key:"pinJournal",value:(i=adventure_wizard_asyncToGenerator(adventure_wizard_regeneratorRuntime().mark((function _callee24(t){var r,a,o,i=arguments;return adventure_wizard_regeneratorRuntime().wrap((function _callee24$(c){for(;;)switch(c.prev=c.next){case 0:if(a=i.length>1&&void 0!==i[1]?i[1]:void 0,o=this.readBreadCrumbs(),a){c.next=18;break}return c.next=5,fromUuid(t);case 5:if(c.t2=r=c.sent,c.t1=null===c.t2,c.t1){c.next=9;break}c.t1=void 0===r;case 9:if(!c.t1){c.next=13;break}c.t3=void 0,c.next=14;break;case 13:c.t3=r.name;case 14:if(c.t0=c.t3,c.t0){c.next=17;break}c.t0="";case 17:a=c.t0;case 18:o[t]=a,game.settings.set("dsa5","breadcrumbs_".concat(game.world.id),JSON.stringify(o)),this.render(!0);case 21:case"end":return c.stop()}}),_callee24,this)}))),function pinJournal(t){return i.apply(this,arguments)})},{key:"unpinJournal",value:function unpinJournal(t){var r=this.readBreadCrumbs();delete r[t],game.settings.set("dsa5","breadcrumbs_".concat(game.world.id),JSON.stringify(r)),this.render(!0)}},{key:"_canDragDrop",value:function _canDragDrop(t){return!0}},{key:"_onDrop",value:(o=adventure_wizard_asyncToGenerator(adventure_wizard_regeneratorRuntime().mark((function _callee25(t){var r;return adventure_wizard_regeneratorRuntime().wrap((function _callee25$(a){for(;;)switch(a.prev=a.next){case 0:a.prev=0,r=JSON.parse(t.dataTransfer.getData("text/plain")),a.next=7;break;case 4:return a.prev=4,a.t0=a.catch(0),a.abrupt("return",!1);case 7:"JournalEntry"==r.type&&this.pinJournal(r.pack?"Compendium.".concat(r.pack,".").concat(r.id):"JournalEntry.".concat(r.id));case 8:case"end":return a.stop()}}),_callee25,this,[[0,4]])}))),function _onDrop(t){return o.apply(this,arguments)})},{key:"readBreadCrumbs",value:function readBreadCrumbs(){var t={};try{t=JSON.parse(game.settings.get("dsa5","breadcrumbs_".concat(game.world.id)))}catch(t){console.log("No Journalbrowser notes found")}return t}},{key:"renderBreadcrumbs",value:function renderBreadcrumbs(){var t=this.readBreadCrumbs(),r=Object.entries(t).map((function(t){return'
    ').concat(t[1],"
    ")}));return r.length>0?'"):""}},{key:"moduleEnabled",value:function moduleEnabled(r){return t.Z.moduleEnabled(r)}}],[{key:"defaultOptions",get:function get(){var t=adventure_wizard_get(adventure_wizard_getPrototypeOf(BookWizard),"defaultOptions",this);return t.tabs=[{navSelector:".tabs",contentSelector:".content",initial:"description"}],mergeObject(t,{classes:t.classes.concat(["dsa5","largeDialog","noscrollWizard","bookWizardsheet"]),width:800,height:880,template:"systems/dsa5/templates/wizard/adventure/adventure_wizard.html",title:game.i18n.localize("Book.Wizard"),resizable:!0,dragDrop:[{dragSelector:".item-list .item",dropSelector:null}]}),t}},{key:"initHook",value:function initHook(){BookWizard.wizard=new BookWizard,game.dsa5.apps.journalBrowser=BookWizard.wizard,Hooks.on("renderJournalDirectory",(function(t,r){var a=$('
    '),o=$('"));o.click((function(){BookWizard.wizard.render(!0)})),a.append(o),r.find(".header-actions:first-child").after(a)}))}}]),BookWizard}();!function adventure_wizard_defineProperty(t,r,a){return r in t?Object.defineProperty(t,r,{value:a,enumerable:!0,configurable:!0,writable:!0}):t[r]=a,t}(Qe,"wizard",void 0);var Xe=function(t){adventure_wizard_inherits(InitializerForm,FormApplication);var r=adventure_wizard_createSuper(InitializerForm);function InitializerForm(){return adventure_wizard_classCallCheck(this,InitializerForm),r.apply(this,arguments)}return adventure_wizard_createClass(InitializerForm,[{key:"render",value:function render(t){new game.dsa5.apps.DSA5Initializer("DSA5 Module Initialization",game.i18n.format("".concat(t,".importContent"),{defaultText:game.i18n.localize("importDefault")}),t,game.i18n.lang).render(!0)}}]),InitializerForm}(),et=function(){function JournalSearch(t){adventure_wizard_classCallCheck(this,JournalSearch);var r=t.pages.find((function(t){return!0})).text.content;this.document={name:t.name,data:$("
    ").html(r).text(),id:t.id}}return adventure_wizard_createClass(JournalSearch,[{key:"name",get:function get(){return this.document.name}},{key:"data",get:function get(){return this.document.data}},{key:"id",get:function get(){return this.document.id}}]),JournalSearch}(),tt=__webpack_require__(5);function masters_menu_typeof(t){return masters_menu_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},masters_menu_typeof(t)}function masters_menu_slicedToArray(t,r){return function masters_menu_arrayWithHoles(t){if(Array.isArray(t))return t}(t)||function masters_menu_iterableToArrayLimit(t,r){var a=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null==a)return;var o,i,c=[],u=!0,l=!1;try{for(a=a.call(t);!(u=(o=a.next()).done)&&(c.push(o.value),!r||c.length!==r);u=!0);}catch(t){l=!0,i=t}finally{try{u||null==a.return||a.return()}finally{if(l)throw i}}return c}(t,r)||masters_menu_unsupportedIterableToArray(t,r)||function masters_menu_nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function masters_menu_createForOfIteratorHelper(t,r){var a="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!a){if(Array.isArray(t)||(a=masters_menu_unsupportedIterableToArray(t))||r&&t&&"number"==typeof t.length){a&&(t=a);var o=0,i=function F(){};return{s:i,n:function n(){return o>=t.length?{done:!0}:{done:!1,value:t[o++]}},e:function e(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var c,u=!0,l=!1;return{s:function s(){a=a.call(t)},n:function n(){var t=a.next();return u=t.done,t},e:function e(t){l=!0,c=t},f:function f(){try{u||null==a.return||a.return()}finally{if(l)throw c}}}}function masters_menu_unsupportedIterableToArray(t,r){if(t){if("string"==typeof t)return masters_menu_arrayLikeToArray(t,r);var a=Object.prototype.toString.call(t).slice(8,-1);return"Object"===a&&t.constructor&&(a=t.constructor.name),"Map"===a||"Set"===a?Array.from(t):"Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a)?masters_menu_arrayLikeToArray(t,r):void 0}}function masters_menu_arrayLikeToArray(t,r){(null==r||r>t.length)&&(r=t.length);for(var a=0,o=new Array(r);a=0;--o){var i=this.tryEntries[o],c=i.completion;if("root"===i.tryLoc)return handle("end");if(i.tryLoc<=this.prev){var u=a.call(i,"catchLoc"),l=a.call(i,"finallyLoc");if(u&&l){if(this.prev=0;--o){var i=this.tryEntries[o];if(i.tryLoc<=this.prev&&a.call(i,"finallyLoc")&&this.prev=0;--r){var a=this.tryEntries[r];if(a.finallyLoc===t)return this.complete(a.completion,a.afterLoc),resetTryEntry(a),l}},catch:function _catch(t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc===t){var o=a.completion;if("throw"===o.type){var i=o.arg;resetTryEntry(a)}return i}}throw new Error("illegal catch attempt")},delegateYield:function delegateYield(t,r,a){return this.delegate={iterator:values(t),resultName:r,nextLoc:a},"next"===this.method&&(this.arg=void 0),l}},t}function masters_menu_asyncGeneratorStep(t,r,a,o,i,c,u){try{var l=t[c](u),p=l.value}catch(t){return void a(t)}l.done?r(p):Promise.resolve(p).then(o,i)}function masters_menu_asyncToGenerator(t){return function(){var r=this,a=arguments;return new Promise((function(o,i){var c=t.apply(r,a);function _next(t){masters_menu_asyncGeneratorStep(c,o,i,_next,_throw,"next",t)}function _throw(t){masters_menu_asyncGeneratorStep(c,o,i,_next,_throw,"throw",t)}_next(void 0)}))}}function masters_menu_get(){return masters_menu_get="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function _get(t,r,a){var o=masters_menu_superPropBase(t,r);if(o){var i=Object.getOwnPropertyDescriptor(o,r);return i.get?i.get.call(arguments.length<3?t:a):i.value}},masters_menu_get.apply(this,arguments)}function masters_menu_superPropBase(t,r){for(;!Object.prototype.hasOwnProperty.call(t,r)&&null!==(t=masters_menu_getPrototypeOf(t)););return t}function masters_menu_inherits(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(r&&r.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),r&&masters_menu_setPrototypeOf(t,r)}function masters_menu_setPrototypeOf(t,r){return masters_menu_setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function _setPrototypeOf(t,r){return t.__proto__=r,t},masters_menu_setPrototypeOf(t,r)}function masters_menu_createSuper(t){var r=function masters_menu_isNativeReflectConstruct(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function _createSuperInternal(){var a,o=masters_menu_getPrototypeOf(t);if(r){var i=masters_menu_getPrototypeOf(this).constructor;a=Reflect.construct(o,arguments,i)}else a=o.apply(this,arguments);return masters_menu_possibleConstructorReturn(this,a)}}function masters_menu_possibleConstructorReturn(t,r){if(r&&("object"===masters_menu_typeof(r)||"function"==typeof r))return r;if(void 0!==r)throw new TypeError("Derived constructors may only return object or undefined");return function masters_menu_assertThisInitialized(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}function masters_menu_getPrototypeOf(t){return masters_menu_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function _getPrototypeOf(t){return t.__proto__||Object.getPrototypeOf(t)},masters_menu_getPrototypeOf(t)}function masters_menu_classCallCheck(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}function masters_menu_defineProperties(t,r){for(var a=0;a0&&void 0!==a[0]&&a[0],r=a.length>1&&void 0!==a[1]?a[1]:{},game.user.isGM){o.next=4;break}return o.abrupt("return",ui.notifications.error("DSAError.onlyGMallowed"));case 4:return o.next=6,masters_menu_get(masters_menu_getPrototypeOf(GameMasterMenu.prototype),"_render",this).call(this,t,r);case 6:case"end":return o.stop()}}),_callee3,this)}))),function _render(){return A.apply(this,arguments)})},{key:"getSelectedActors",value:function getSelectedActors(){for(var t=game.settings.get("dsa5","selectedActors"),r=game.settings.get("dsa5","trackedActors"),a={},o=0,i=Object.keys(t);o-1)){i.next=10;break}return a.splice(o,1),i.next=9,game.settings.set("dsa5","trackedActors",{actors:a});case 9:this.render(!0);case 10:case"end":return i.stop()}}),_callee9,this)}))),function _deleteHero(t){return T.apply(this,arguments)})},{key:"updateHeroOrder",value:(S=masters_menu_asyncToGenerator(masters_menu_regeneratorRuntime().mark((function _callee10(t){var r,a,o,i;return masters_menu_regeneratorRuntime().wrap((function _callee10$(c){for(;;)switch(c.prev=c.next){case 0:r=[],a=masters_menu_createForOfIteratorHelper(t.querySelectorAll(".hero"));try{for(a.s();!(o=a.n()).done;)i=o.value,r.push(i.dataset.id)}catch(t){a.e(t)}finally{a.f()}return c.next=5,game.settings.set("dsa5","trackedActors",{actors:r});case 5:case"end":return c.stop()}}),_callee10)}))),function updateHeroOrder(t){return S.apply(this,arguments)})},{key:"updateDarkness",value:(x=masters_menu_asyncToGenerator(masters_menu_regeneratorRuntime().mark((function _callee11(t){return masters_menu_regeneratorRuntime().wrap((function _callee11$(r){for(;;)switch(r.prev=r.next){case 0:canvas.scene&&canvas.scene.update({darkness:Number(t.currentTarget.value)},{animateDarkness:3e3});case 1:case"end":return r.stop()}}),_callee11)}))),function updateDarkness(t){return x.apply(this,arguments)})},{key:"updateSightThreshold",value:(k=masters_menu_asyncToGenerator(masters_menu_regeneratorRuntime().mark((function _callee12(t){var r,a,o;return masters_menu_regeneratorRuntime().wrap((function _callee12$(i){for(;;)switch(i.prev=i.next){case 0:return r=Number(t.currentTarget.dataset.index),a=Number(t.currentTarget.value),(o=game.settings.get("dsa5","sightOptions").split("|"))[r]=a,i.next=6,game.settings.set("dsa5","sightOptions",o.join("|"));case 6:case"end":return i.stop()}}),_callee12)}))),function updateSightThreshold(t){return k.apply(this,arguments)})},{key:"getGroupSchipSetting",value:function getGroupSchipSetting(){return game.settings.get("dsa5","groupschips").split("/").map((function(t){return Number(t)}))}},{key:"changeGroupSchipCount",value:(b=masters_menu_asyncToGenerator(masters_menu_regeneratorRuntime().mark((function _callee13(t){var r;return masters_menu_regeneratorRuntime().wrap((function _callee13$(a){for(;;)switch(a.prev=a.next){case 0:return(r=this.getGroupSchipSetting())[1]=Math.max(0,r[1]+t),r[0]=Math.min(r[1],r[0]),a.next=5,game.settings.set("dsa5","groupschips",r.join("/"));case 5:case"end":return a.stop()}}),_callee13,this)}))),function changeGroupSchipCount(t){return b.apply(this,arguments)})},{key:"changeGroupSchip",value:(_=masters_menu_asyncToGenerator(masters_menu_regeneratorRuntime().mark((function _callee14(t){var r,a;return masters_menu_regeneratorRuntime().wrap((function _callee14$(o){for(;;)switch(o.prev=o.next){case 0:return 1==(r=Number(t.currentTarget.getAttribute("data-val")))&&1==$(t.currentTarget).closest(".col").find(".fullSchip").length&&(r=0),(a=this.getGroupSchipSetting())[0]=r,o.next=6,game.settings.set("dsa5","groupschips",a.join("/"));case 6:case"end":return o.stop()}}),_callee14,this)}))),function changeGroupSchip(t){return _.apply(this,arguments)})},{key:"_randomPlayer",value:(v=masters_menu_asyncToGenerator(masters_menu_regeneratorRuntime().mark((function _callee15(t,r){var a,o,i=this;return masters_menu_regeneratorRuntime().wrap((function _callee15$(c){for(;;)switch(c.prev=c.next){case 0:return a=t.find(".hero"),c.next=3,this.rollRandomPlayer(2==r.button);case 3:o=c.sent,$(r.currentTarget).find("i").addClass("fa-spin"),a.removeClass("victim"),setTimeout((function(){$(i._element).find('.hero[data-id="'.concat(o,'"]')).addClass("victim"),$(r.currentTarget).find("i").removeClass("fa-spin")}),500);case 7:case"end":return c.stop()}}),_callee15,this)}))),function _randomPlayer(t,r){return v.apply(this,arguments)})},{key:"rollRandomPlayer",value:(g=masters_menu_asyncToGenerator(masters_menu_regeneratorRuntime().mark((function _callee16(t){var r,o,i,c,u,l,p,d,h;return masters_menu_regeneratorRuntime().wrap((function _callee16$(m){for(;;)switch(m.prev=m.next){case 0:if(r={},o=1,i=this.getSelectedActors(),c=0!=Object.values(i).filter((function(t){return t})).length,!this.heros.length){m.next=8;break}m.t0=this.heros,m.next=11;break;case 8:return m.next=10,this.getTrackedHeros();case 10:m.t0=m.sent;case 11:u=m.t0,l=masters_menu_createForOfIteratorHelper(u),m.prev=13,l.s();case 15:if((p=l.n()).done){m.next=25;break}if(d=p.value,i[d.id]||!c){m.next=19;break}return m.abrupt("continue",23);case 19:r[o]=d.id,o++,t&&a.Z.hasVantage(d,game.i18n.localize("LocalizedIDs.misfortune"))&&(r[o]=d.id,o++),t&&d.hasCondition("badluck")&&(r[o]=d.id,o++);case 23:m.next=15;break;case 25:m.next=30;break;case 27:m.prev=27,m.t1=m.catch(13),l.e(m.t1);case 30:return m.prev=30,l.f(),m.finish(30);case 33:return m.next=35,new Roll("1d".concat(o-1)).evaluate({async:!0});case 35:return h=m.sent.total,m.abrupt("return",r[h]);case 37:case"end":return m.stop()}}),_callee16,this,[[13,27,30,33]])}))),function rollRandomPlayer(t){return g.apply(this,arguments)})},{key:"doPayment",value:(m=masters_menu_asyncToGenerator(masters_menu_regeneratorRuntime().mark((function _callee17(t,r){var a,o,i,c;return masters_menu_regeneratorRuntime().wrap((function _callee17$(u){for(;;)switch(u.prev=u.next){case 0:return a=game.actors.filter((function(r){return t.includes(r.id)})),o=this.getNames(a),u.next=4,renderTemplate("systems/dsa5/templates/dialog/master-dialog-award.html",{text:game.i18n.localize(game.i18n.format(r?"MASTER.payText":"MASTER.getPaidText",{heros:o}))});case 4:i=u.sent,c=function callback(t){var o,i=t.find(".input-text").val(),c=masters_menu_createForOfIteratorHelper(a);try{for(c.s();!(o=c.n()).done;){var u=o.value;w.handlePayAction(void 0,r,i,u)}}catch(t){c.e(t)}finally{c.f()}},this.buildDialog(game.i18n.localize(r?"MASTER.payTT":"PAYMENT.payButton"),i,c);case 7:case"end":return u.stop()}}),_callee17,this)}))),function doPayment(t,r){return m.apply(this,arguments)})},{key:"getPaid",value:(d=masters_menu_asyncToGenerator(masters_menu_regeneratorRuntime().mark((function _callee18(t){return masters_menu_regeneratorRuntime().wrap((function _callee18$(r){for(;;)switch(r.prev=r.next){case 0:this.doPayment(t,!1);case 1:case"end":return r.stop()}}),_callee18,this)}))),function getPaid(t){return d.apply(this,arguments)})},{key:"getExp",value:(p=masters_menu_asyncToGenerator(masters_menu_regeneratorRuntime().mark((function _callee20(r){var a,o,i,c=this;return masters_menu_regeneratorRuntime().wrap((function _callee20$(u){for(;;)switch(u.prev=u.next){case 0:return a=game.actors.filter((function(t){return r.includes(t.id)})),u.next=3,renderTemplate("systems/dsa5/templates/dialog/master-dialog-award.html",{text:game.i18n.localize(game.i18n.format("MASTER.awardXPText",{heros:this.getNames(a)}))});case 3:o=u.sent,i=function(){var r=masters_menu_asyncToGenerator(masters_menu_regeneratorRuntime().mark((function _callee19(r){var o,i,u,l,p,d,h,m;return masters_menu_regeneratorRuntime().wrap((function _callee19$(y){for(;;)switch(y.prev=y.next){case 0:if(o=Number(r.find(".input-text").val()),i=Math.max(1,Math.round(.25*o)),u=[],l=[],isNaN(o)){y.next=30;break}p=masters_menu_createForOfIteratorHelper(a),y.prev=6,p.s();case 8:if((d=p.n()).done){y.next=16;break}return h=d.value,m=o,h.system.isFamiliar||h.system.isPet?(m=i,l.push(h)):u.push(h),y.next=14,h.update({"system.details.experience.total":h.system.details.experience.total+m});case 14:y.next=8;break;case 16:y.next=21;break;case 18:y.prev=18,y.t0=y.catch(6),p.e(y.t0);case 21:return y.prev=21,p.f(),y.finish(21);case 24:if(!(u.length>0)){y.next=27;break}return y.next=27,ChatMessage.create(t.Z.chatDataSetup(game.i18n.format("MASTER.xpMessage",{heros:c.getNames(u),number:o})));case 27:if(!(l.length>0)){y.next=30;break}return y.next=30,ChatMessage.create(t.Z.chatDataSetup(game.i18n.format("MASTER.xpMessage",{heros:c.getNames(l),number:o})));case 30:case"end":return y.stop()}}),_callee19,null,[[6,18,21,24]])})));return function callback(t){return r.apply(this,arguments)}}(),this.buildDialog(game.i18n.localize("MASTER.awardXP"),o,i);case 6:case"end":return u.stop()}}),_callee20,this)}))),function getExp(t){return p.apply(this,arguments)})},{key:"getNames",value:function getNames(t){return t.map((function(t){return t.name})).join(", ")}},{key:"buildDialog",value:function buildDialog(t,r,a){new tt.Z({title:t,content:r,default:"yes",buttons:{Yes:{icon:'',label:game.i18n.localize("yes"),callback:function callback(t){a(t)}},cancel:{icon:'',label:game.i18n.localize("cancel")}}}).render(!0)}},{key:"_canDragDrop",value:function _canDragDrop(t){return!0}},{key:"_onDrop",value:(l=masters_menu_asyncToGenerator(masters_menu_regeneratorRuntime().mark((function _callee21(t){var r,a;return masters_menu_regeneratorRuntime().wrap((function _callee21$(o){for(;;)switch(o.prev=o.next){case 0:return o.prev=0,r=JSON.parse(t.dataTransfer.getData("text/plain")),o.next=4,Actor.implementation.fromDropData(r);case 4:r=o.sent,o.next=10;break;case 7:return o.prev=7,o.t0=o.catch(0),o.abrupt("return",!1);case 10:if("Actor"!=r.documentName){o.next=18;break}if(-1!=(a=(a=game.settings.get("dsa5","trackedActors")).actors||[]).indexOf(r.id)||r.pack){o.next=18;break}return a.push(r.id),o.next=17,game.settings.set("dsa5","trackedActors",{actors:a});case 17:this.render(!0);case 18:case"end":return o.stop()}}),_callee21,this,[[0,7]])}))),function _onDrop(t){return l.apply(this,arguments)})},{key:"selectedIDs",value:function selectedIDs(){for(var t=[],r=this.getSelectedActors(),a=0,o=Object.entries(r);a0)){a.next=6;break}r=game.actors.filter((function(r){return t.actors.includes(r.id)})).sort((function(r,a){return t.actors.indexOf(r.id)-t.actors.indexOf(a.id)})),a.next=9;break;case 6:return r=game.actors.filter((function(t){return t.hasPlayerOwner})),a.next=9,game.settings.set("dsa5","trackedActors",{actors:r.map((function(t){return t.id}))});case 9:return a.abrupt("return",r);case 10:case"end":return a.stop()}}),_callee24)}))),function getTrackedHeros(){return i.apply(this,arguments)})},{key:"getData",value:(o=masters_menu_asyncToGenerator(masters_menu_regeneratorRuntime().mark((function _callee25(r){var a,o,i,c,u,l,p,d,h,m,g,v,_,b;return masters_menu_regeneratorRuntime().wrap((function _callee25$(k){for(;;)switch(k.prev=k.next){case 0:return k.next=2,masters_menu_get(masters_menu_getPrototypeOf(GameMasterMenu.prototype),"getData",this).call(this,r);case 2:return o=k.sent,k.next=5,this.getTrackedHeros();case 5:i=k.sent,c=y.Z.getGroupSchips(),u=game.settings.get("dsa5","sightOptions").split("|"),l=/ \[[a-zA-Zäöü\d-]+\]/,p=[1,2,3,4].map((function(t){return{label:game.i18n.localize("VisionDisruption.step".concat(t)).replace(l,""),value:u[t-1]}})),o.sceneConfig={sceneAutomationEnabled:game.settings.get("dsa5","sightAutomationEnabled"),enableDPS:game.settings.get("dsa5","enableDPS"),lightSightCompensationEnabled:game.settings.get("dsa5","lightSightCompensationEnabled"),visions:p,darkness:(null===(a=canvas.scene)||void 0===a?void 0:a.darkness)||0},this.heros=i,d=this.getSelectedActors(),h=[],m=masters_menu_createForOfIteratorHelper(i);try{for(m.s();!(g=m.n()).done;)v=g.value,_=duplicate(v),mergeObject(_,{id:v.id,uuid:v.uuid,selected:d[v.id],schips:v.schipshtml(),purse:v.items.filter((function(t){return"money"==t.type})).sort((function(t,r){return r.system.price.value-t.system.price.value})).map((function(t){return'').concat(t.system.quantity.value,"")})).join(" - "),advantages:v.items.filter((function(t){return"advantage"==t.type})).map((function(t){return{name:t.name,uuid:t.uuid}})),disadvantages:v.items.filter((function(t){return"disadvantage"==t.type})).map((function(t){return{name:t.name,uuid:t.uuid}})),system:{status:{wounds:{max:v.system.status.wounds.max},astralenergy:{max:v.system.status.astralenergy.max},karmaenergy:{max:v.system.status.karmaenergy.max}},isMage:v.system.isMage,isPriest:v.system.isPriest}}),h.push(_)}catch(t){m.e(t)}finally{m.f()}if(this.abilities){k.next=21;break}return k.next=19,t.Z.allSkillsList();case 19:b=k.sent,this.abilities=b.map((function(t){return{name:t,type:"skill"}})).concat(Object.values(game.dsa5.config.characteristics).map((function(t){return{name:game.i18n.localize(t),type:"attribute"}})).concat({name:game.i18n.localize("regenerate"),type:"regeneration"})).sort((function(t,r){return t.name.localeCompare(r.name)}));case 21:if(k.t0=mergeObject,k.t1=o,k.t2=h,k.t3=this.abilities,k.t4=c,k.t5=this.lastSkill,k.t6=this.randomCreation.map((function(t){return t.template})),!game.dsa5.apps.LightDialog){k.next=34;break}return k.next=31,game.dsa5.apps.LightDialog.getButtonHTML();case 31:k.t7=k.sent,k.next=35;break;case 34:k.t7="";case 35:return k.t8=k.t7,k.t9={heros:k.t2,abilities:k.t3,groupschips:k.t4,lastSkill:k.t5,randomCreation:k.t6,lightButton:k.t8},(0,k.t0)(k.t1,k.t9),k.abrupt("return",o);case 39:case"end":return k.stop()}}),_callee25,this)}))),function getData(t){return o.apply(this,arguments)})},{key:"registerRandomCreation",value:function registerRandomCreation(t){this.randomCreation.push(t)}}],[{key:"defaultOptions",get:function get(){var t=masters_menu_get(masters_menu_getPrototypeOf(GameMasterMenu),"defaultOptions",this);return t.tabs=[{navSelector:".tabs",contentSelector:".content",initial:"main"}],mergeObject(t,{classes:t.classes.concat(["dsa5","largeDialog","masterMenu","sheet"]),width:470,height:740,title:game.i18n.localize("gmMenu"),dragDrop:[{dragSelector:null,dropSelector:null}]}),t.template="systems/dsa5/templates/system/mastermenu.html",t.resizable=!0,t}}]),GameMasterMenu}();function creature_merchant_sheet_typeof(t){return creature_merchant_sheet_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},creature_merchant_sheet_typeof(t)}function creature_merchant_sheet_classCallCheck(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}function creature_merchant_sheet_defineProperties(t,r){for(var a=0;a=0;--o){var i=this.tryEntries[o],c=i.completion;if("root"===i.tryLoc)return handle("end");if(i.tryLoc<=this.prev){var u=a.call(i,"catchLoc"),l=a.call(i,"finallyLoc");if(u&&l){if(this.prev=0;--o){var i=this.tryEntries[o];if(i.tryLoc<=this.prev&&a.call(i,"finallyLoc")&&this.prev=0;--r){var a=this.tryEntries[r];if(a.finallyLoc===t)return this.complete(a.completion,a.afterLoc),resetTryEntry(a),l}},catch:function _catch(t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc===t){var o=a.completion;if("throw"===o.type){var i=o.arg;resetTryEntry(a)}return i}}throw new Error("illegal catch attempt")},delegateYield:function delegateYield(t,r,a){return this.delegate={iterator:values(t),resultName:r,nextLoc:a},"next"===this.method&&(this.arg=void 0),l}},t}function init_asyncGeneratorStep(t,r,a,o,i,c,u){try{var l=t[c](u),p=l.value}catch(t){return void a(t)}l.done?r(p):Promise.resolve(p).then(o,i)}function init_asyncToGenerator(t){return function(){var r=this,a=arguments;return new Promise((function(o,i){var c=t.apply(r,a);function _next(t){init_asyncGeneratorStep(c,o,i,_next,_throw,"next",t)}function _throw(t){init_asyncGeneratorStep(c,o,i,_next,_throw,"throw",t)}_next(void 0)}))}}function init_classCallCheck(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}function init_defineProperties(t,r){for(var a=0;a0&&void 0!==r[0]?r[0]:{},["de","en"].includes(game.i18n.lang)){a.next=3;break}return a.abrupt("return");case 3:return a.abrupt("return",init_get(init_getPrototypeOf(ForbiddenLanguageDialog.prototype),"close",this).call(this,t));case 4:case"end":return a.stop()}}),_callee,this)}))),function close(){return r.apply(this,arguments)})}]),ForbiddenLanguageDialog}(),ut=function showForbiddenLanguageDialog(){var t,r,a,o={title:game.i18n.localize("language"),content:"

    Your foundry language is not supported by this system. Due to technical reasons your foundry language setting has to be switched to either english or german.

    ",buttons:{de:{icon:'',label:"en",callback:(a=init_asyncToGenerator(init_regeneratorRuntime().mark((function _callee2(){return init_regeneratorRuntime().wrap((function _callee2$(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,game.settings.set("core","language","de");case 2:foundry.utils.debouncedReload();case 3:case"end":return t.stop()}}),_callee2)}))),function callback(){return a.apply(this,arguments)})},en:{icon:'',label:"de",callback:(r=init_asyncToGenerator(init_regeneratorRuntime().mark((function _callee3(){return init_regeneratorRuntime().wrap((function _callee3$(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,game.settings.set("core","language","en");case 2:foundry.utils.debouncedReload();case 3:case"end":return t.stop()}}),_callee3)}))),function callback(){return r.apply(this,arguments)})},logout:{icon:'',label:game.i18n.localize("SETTINGS.Logout"),callback:(t=init_asyncToGenerator(init_regeneratorRuntime().mark((function _callee4(){return init_regeneratorRuntime().wrap((function _callee4$(t){for(;;)switch(t.prev=t.next){case 0:ui.menu.items.logout.onClick();case 1:case"end":return t.stop()}}),_callee4)}))),function callback(){return t.apply(this,arguments)})}}};new st(o).render(!0)},lt=function showWrongLanguageDialog(t){var r,a={title:game.i18n.localize("DSASETTINGS.forceLanguage"),content:game.i18n.format("DSAError.wrongLanguage",{lang:t}),buttons:{ok:{icon:'',label:game.i18n.localize("ok"),callback:(r=init_asyncToGenerator(init_regeneratorRuntime().mark((function _callee5(){return init_regeneratorRuntime().wrap((function _callee5$(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,game.settings.set("core","language",t);case 2:foundry.utils.debouncedReload();case 3:case"end":return r.stop()}}),_callee5)}))),function callback(){return r.apply(this,arguments)})},cancel:{icon:'',label:game.i18n.localize("cancel")}}};new Dialog(a).render(!0)};var ft=function(t){init_inherits(DaylightIlluminationShader,AdaptiveIlluminationShader);var r=init_createSuper(DaylightIlluminationShader);function DaylightIlluminationShader(){return init_classCallCheck(this,DaylightIlluminationShader),r.apply(this,arguments)}return init_createClass(DaylightIlluminationShader)}();function macroControl_defineProperties(t,r){for(var a=0;a1&&void 0!==arguments[1]?arguments[1]:0;Oe.Z.showRQMessage(t,r)}},{key:"requestGC",value:function requestGC(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};Oe.Z.showGCMessage(t,r,a)}},{key:"rollCh",value:function rollCh(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};c.Z.check3D20(void 0,t,r)}},{key:"itemMacroById",value:function itemMacroById(t,r,a,o){var i=game.actors.get(t),c=i?i.items.find((function(t){return t.name===r&&t.type==a})):null;this.runItem(i,c,r,o)}},{key:"itemMacro",value:function itemMacro(t,r,a){var o,i=ChatMessage.getSpeaker();i.token&&(o=game.actors.tokens[i.token]),o||(o=game.actors.get(i.actor));var c=o?o.items.find((function(a){return a.name===t&&a.type==r})):null;this.runItem(o,c,t,a,i.token)}},{key:"charMacroById",value:function charMacroById(t,r){var a=game.actors.get(r);this.runChar(a,t)}},{key:"charMacro",value:function charMacro(t){var r,a=ChatMessage.getSpeaker();a.token&&(r=game.actors.tokens[a.token]),r||(r=game.actors.get(a.actor)),this.runChar(r,t,a.token)}},{key:"runWeaponless",value:function runWeaponless(t,r,a){if(!t)return ui.notifications.error(game.i18n.format("DSAError.MacroItemMissing",{item:r}));var o=r.split("Weaponless")[0];t.setupWeaponless(o,{},a).then((function(r){t.basicTest(r)}))}},{key:"runChar",value:function runChar(t,r,a){if(!t)return ui.notifications.error(game.i18n.format("DSAError.MacroItemMissing",{item:r}));t.setupDodge({},a).then((function(r){t.basicTest(r)}))}},{key:"runItem",value:function runItem(t,r,a,o,i){if(!t)return ui.notifications.error(game.i18n.format("DSAError.MacroItemMissing",{item:a}));switch(r.type){case"combatskill":case"trait":case"meleeweapon":return t.setupWeapon(r,o.mod,o,i).then((function(r){t.basicTest(r)}));case"rangeweapon":return t.setupWeapon(r,"attack",o,i).then((function(r){t.basicTest(r)}));case"skill":return t.setupSkill(r,o,i).then((function(r){t.basicTest(r)}));case"ceremony":case"ritual":case"spell":case"liturgy":return t.setupSpell(r,o,i).then((function(r){t.basicTest(r)}))}}}]),MacroDSA5}();function ownKeys(t,r){var a=Object.keys(t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);r&&(o=o.filter((function(r){return Object.getOwnPropertyDescriptor(t,r).enumerable}))),a.push.apply(a,o)}return a}function _objectSpread(t){for(var r=1;r=t.length?{done:!0}:{done:!1,value:t[o++]}},e:function e(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var c,u=!0,l=!1;return{s:function s(){a=a.call(t)},n:function n(){var t=a.next();return u=t.done,t},e:function e(t){l=!0,c=t},f:function f(){try{u||null==a.return||a.return()}finally{if(l)throw c}}}}function itemlibrary_unsupportedIterableToArray(t,r){if(t){if("string"==typeof t)return itemlibrary_arrayLikeToArray(t,r);var a=Object.prototype.toString.call(t).slice(8,-1);return"Object"===a&&t.constructor&&(a=t.constructor.name),"Map"===a||"Set"===a?Array.from(t):"Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a)?itemlibrary_arrayLikeToArray(t,r):void 0}}function itemlibrary_arrayLikeToArray(t,r){(null==r||r>t.length)&&(r=t.length);for(var a=0,o=new Array(r);a=0;--o){var i=this.tryEntries[o],c=i.completion;if("root"===i.tryLoc)return handle("end");if(i.tryLoc<=this.prev){var u=a.call(i,"catchLoc"),l=a.call(i,"finallyLoc");if(u&&l){if(this.prev=0;--o){var i=this.tryEntries[o];if(i.tryLoc<=this.prev&&a.call(i,"finallyLoc")&&this.prev=0;--r){var a=this.tryEntries[r];if(a.finallyLoc===t)return this.complete(a.completion,a.afterLoc),resetTryEntry(a),l}},catch:function _catch(t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc===t){var o=a.completion;if("throw"===o.type){var i=o.arg;resetTryEntry(a)}return i}}throw new Error("illegal catch attempt")},delegateYield:function delegateYield(t,r,a){return this.delegate={iterator:values(t),resultName:r,nextLoc:a},"next"===this.method&&(this.arg=void 0),l}},t}function itemlibrary_asyncGeneratorStep(t,r,a,o,i,c,u){try{var l=t[c](u),p=l.value}catch(t){return void a(t)}l.done?r(p):Promise.resolve(p).then(o,i)}function itemlibrary_asyncToGenerator(t){return function(){var r=this,a=arguments;return new Promise((function(o,i){var c=t.apply(r,a);function _next(t){itemlibrary_asyncGeneratorStep(c,o,i,_next,_throw,"next",t)}function _throw(t){itemlibrary_asyncGeneratorStep(c,o,i,_next,_throw,"throw",t)}_next(void 0)}))}}function itemlibrary_classCallCheck(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}function itemlibrary_defineProperties(t,r){for(var a=0;a1&&void 0!==arguments[1]?arguments[1]:{};itemlibrary_classCallCheck(this,SearchDocument);var a=t.documentName||t.type;switch(t.documentName){case"Actor":case"Item":a=t.type}var o="";if(game.settings.get("dsa5","indexDescription"))switch(a){case"creature":case"npc":case"character":o=getProperty(t,"system.description.value");break;case"JournalEntry":o=getProperty(t,"system.content");break;default:o=getProperty(t,"description.value")}this.document={name:t.name,filterType:a,data:$("
    ").html(o).text(),id:t.id||t._id,visible:!t.visible||t.visible,compendium:t.compendium?t.compendium.metadata.packageName:r.packageName||"",pack:t.pack||(r.packageName?r.id:void 0),img:t.img}}var t,r;return itemlibrary_createClass(SearchDocument,[{key:"uuid",get:function get(){if(this.document.compendium)return"Compendium.".concat(this.document.pack,".").concat(this.document.id);switch(this.itemType){case"character":case"creature":case"npc":return"Actor.".concat(this.id);case"JournalEntry":return"JournalEntry.".concat(this.id);default:return"Item.".concat(this.id)}}},{key:"name",get:function get(){return this.document.name}},{key:"data",get:function get(){return this.document.data}},{key:"id",get:function get(){return this.document.id}},{key:"itemType",get:function get(){return this.document.filterType}},{key:"getItem",value:(r=itemlibrary_asyncToGenerator(itemlibrary_regeneratorRuntime().mark((function _callee(){return itemlibrary_regeneratorRuntime().wrap((function _callee$(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,fromUuid(this.uuid);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),_callee,this)}))),function getItem(){return r.apply(this,arguments)})},{key:"hasPermission",value:function hasPermission(){return this.document.visible}},{key:"render",value:(t=itemlibrary_asyncToGenerator(itemlibrary_regeneratorRuntime().mark((function _callee2(){return itemlibrary_regeneratorRuntime().wrap((function _callee2$(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.getItem();case 2:t.sent.sheet.render(!0);case 3:case"end":return t.stop()}}),_callee2,this)}))),function render(){return t.apply(this,arguments)})},{key:"compendium",get:function get(){return this.document.compendium}},{key:"img",get:function get(){return"JournalEntry"==this.itemType?"systems/dsa5/icons/categories/DSA-Auge.webp":this.document.img}}]),SearchDocument}(),yt=function(t){itemlibrary_inherits(AdvancedSearchDocument,t);var r=itemlibrary_createSuper(AdvancedSearchDocument);function AdvancedSearchDocument(t,a){var o;itemlibrary_classCallCheck(this,AdvancedSearchDocument),o=r.call(this,t);var i,c=itemlibrary_createForOfIteratorHelper(ht[a]||[]);try{for(c.s();!(i=c.n()).done;){var u=i.value;o[u.attr]=u.attr.split(".").reduce((function(t,r){return void 0===t[r]?{}:t[r]}),t.system)}}catch(t){c.e(t)}finally{c.f()}return o}return itemlibrary_createClass(AdvancedSearchDocument)}(mt),gt=function(r){itemlibrary_inherits(DSA5ItemLibrary,Application);var a,o,i,c,u,l,p,d,m,y,g,v,_,b,k,w=itemlibrary_createSuper(DSA5ItemLibrary);function DSA5ItemLibrary(t){var r;return itemlibrary_classCallCheck(this,DSA5ItemLibrary),(r=w.call(this,t)).advancedFiltering=!1,r.journalBuild=!1,r.journalWorldBuild=!1,r.equipmentBuild=!1,r.equipmentWorldBuild,r.zooBuild=!1,r.zooWorldBuild=!1,r.currentDetailFilter={equipment:[],character:[],spell:[],journal:[],zoo:[]},r.journalIndex=new FlexSearch({encode:"simple",tokenize:"reverse",cache:!0,doc:{id:"id",field:["name","data"]}}),r.equipmentIndex=new FlexSearch({encode:"simple",tokenize:"reverse",cache:!0,doc:{id:"id",field:["name","data","itemType"]}}),r.zooIndex=new FlexSearch({encode:"simple",tokenize:"reverse",cache:!0,doc:{id:"id",field:["name","data","itemType"]}}),r.detailFilter={},r.pages={equipment:{},character:{},spell:{},journal:{},zoo:{}},r.filters={equipment:{categories:{armor:!1,ammunition:!1,equipment:!1,meleeweapon:!1,rangeweapon:!1,poison:!1,disease:!1,consumable:!1,plant:!1},filterBy:{search:""}},character:{categories:{career:!1,advantage:!1,combatskill:!1,culture:!1,disadvantage:!1,trait:!1,skill:!1,specialability:!1,species:!1,application:!1,demonmark:!1,patron:!1,essence:!1,imprint:!1},filterBy:{search:""}},spell:{categories:{blessing:!1,ceremony:!1,liturgy:!1,magictrick:!1,ritual:!1,spell:!1,spellextension:!1,magicalsign:!1},filterBy:{search:""}},journal:{categories:{},filterBy:{search:""}},zoo:{categories:{npc:!1,character:!1,creature:!1},filterBy:{search:""}}},r}return itemlibrary_createClass(DSA5ItemLibrary,[{key:"getData",value:(k=itemlibrary_asyncToGenerator(itemlibrary_regeneratorRuntime().mark((function _callee3(t){var r;return itemlibrary_regeneratorRuntime().wrap((function _callee3$(a){for(;;)switch(a.prev=a.next){case 0:return a.next=2,itemlibrary_get(itemlibrary_getPrototypeOf(DSA5ItemLibrary.prototype),"getData",this).call(this,t);case 2:if((r=a.sent).categories=this.translateFilters(),r.isGM=game.user.isGM,r.items=this.items,r.advancedMode=this.advancedFiltering?"on":"",r.worldIndexed=game.settings.get("dsa5","indexWorldItems")?"on":"",r.fullTextEnabled=game.settings.get("dsa5","indexDescription")?"on":"",r.filterDuplicateItems=game.settings.get("dsa5","filterDuplicateItems")?"on":"",r.browseEnabled=this.browseEnabled?"on":"",!this.advancedFiltering){a.next=15;break}return a.next=14,this.buildDetailFilter("tbd",this.subcategory);case 14:r.advancedFilter=a.sent;case 15:return a.abrupt("return",r);case 16:case"end":return a.stop()}}),_callee3,this)}))),function getData(t){return k.apply(this,arguments)})},{key:"translateFilters",value:function translateFilters(){return{equipment:this.buildFilter(this.filters.equipment),character:this.buildFilter(this.filters.character),spell:this.buildFilter(this.filters.spell),zoo:this.buildFilter(this.filters.zoo,"Actor"),journal:this.buildFilter(this.filters.journal)}}},{key:"purgeAdvancedFilters",value:function purgeAdvancedFilters(){var t=this;for(var r in this.filters)for(var a in this.filters[r].categories)this.filters[r].categories[a]=!1;$(this._element).find('.filter[type="checkbox"]').prop("checked",!1),this.buildDetailFilter("none","none").then((function(r){$(t._element).find(".advancedSearch .groupbox").html(r)}))}},{key:"buildFilter",value:function buildFilter(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"Item",a=[];return Object.keys(t.categories).forEach((function(o){a.push({label:game.i18n.localize("TYPES.".concat(r,".").concat(o)),selected:t.categories[o],key:o})})),a=a.sort((function(t,r){return t.label.localeCompare(r.label)}))}},{key:"getRandomItems",value:(b=itemlibrary_asyncToGenerator(itemlibrary_regeneratorRuntime().mark((function _callee4(t,r){var a,o;return itemlibrary_regeneratorRuntime().wrap((function _callee4$(i){for(;;)switch(i.prev=i.next){case 0:return a=[],o=this.equipmentIndex,i.t0=a.push,i.t1=a,i.t2=itemlibrary_toConsumableArray,i.next=7,o.search(t,{field:["itemType"]});case 7:return i.t3=i.sent,i.t4=(0,i.t2)(i.t3),i.t0.apply.call(i.t0,i.t1,i.t4),i.next=12,Promise.all(this.shuffle(a.filter((function(t){return t.hasPermission}))).slice(0,r+5).map((function(t){return t.getItem()})));case 12:return i.abrupt("return",i.sent.filter((function(t){var r=t.getFlag("dsa5","enchantments");return!r||!r.find((function(t){return t.talisman}))})).slice(0,r));case 13:case"end":return i.stop()}}),_callee4,this)}))),function getRandomItems(t,r){return b.apply(this,arguments)})},{key:"shuffle",value:function shuffle(t){for(var r,a,o=t.length;0!==o;)a=Math.floor(Math.random()*o),r=t[o-=1],t[o]=t[a],t[a]=r;return t}},{key:"findCompendiumItem",value:(_=itemlibrary_asyncToGenerator(itemlibrary_regeneratorRuntime().mark((function _callee5(t,r){var a,o,i,c=arguments;return itemlibrary_regeneratorRuntime().wrap((function _callee5$(u){for(;;)switch(u.prev=u.next){case 0:if(a=!(c.length>2&&void 0!==c[2])||c[2],this.equipmentBuild){u.next=4;break}return u.next=4,this.buildEquipmentIndex();case 4:return o={field:["name"],where:{itemType:r}},u.next=7,this.equipmentIndex.search(t,o);case 7:return i=u.sent,a&&(i=i.filter((function(t){return""!=t.compendium}))),u.next=11,Promise.all(i.map((function(t){return t.getItem()})));case 11:return u.abrupt("return",u.sent);case 12:case"end":return u.stop()}}),_callee5,this)}))),function findCompendiumItem(t,r){return _.apply(this,arguments)})},{key:"getCategoryItems",value:(v=itemlibrary_asyncToGenerator(itemlibrary_regeneratorRuntime().mark((function _callee6(t){var r,a,o,i=arguments;return itemlibrary_regeneratorRuntime().wrap((function _callee6$(c){for(;;)switch(c.prev=c.next){case 0:return r=i.length>1&&void 0!==i[1]&&i[1],a=i.length>2&&void 0!==i[2]&&i[2],c.next=4,this.buildEquipmentIndex();case 4:if(o=this.equipmentIndex.search(t,{field:["itemType"]}),!r){c.next=11;break}return c.next=8,Promise.all(o.map((function(t){return t.getItem()})));case 8:return c.abrupt("return",c.sent.map((function(t){return t.toObject()})));case 11:if(!a){c.next=15;break}return c.next=14,Promise.all(o.map((function(t){return t.getItem()})));case 14:return c.abrupt("return",c.sent);case 15:return c.abrupt("return",o);case 16:case"end":return c.stop()}}),_callee6,this)}))),function getCategoryItems(t){return v.apply(this,arguments)})},{key:"executeAdvancedFilter",value:(g=itemlibrary_asyncToGenerator(itemlibrary_regeneratorRuntime().mark((function _callee7(t,r,a,o,i){var c,u,l,p,d,h,m,y=arguments;return itemlibrary_regeneratorRuntime().wrap((function _callee7$(g){for(;;)switch(g.prev=g.next){case 0:return c=y.length>5&&void 0!==y[5]?y[5]:[],u=function selFnct(t){var r,o=itemlibrary_createForOfIteratorHelper(a);try{for(o.s();!(r=o.n()).done;){var i=r.value;if(i[2]?t[i[0]]!=i[1]:-1==t[i[0]].indexOf(i[1]))return!1}}catch(t){o.e(t)}finally{o.f()}return!0},l=function txtFnct(t){var r,a=itemlibrary_createForOfIteratorHelper(o);try{for(a.s();!(r=a.n()).done;){var i=r.value;if(-1==t[i[0]].toLowerCase().indexOf(i[1]))return!1}}catch(t){a.e(t)}finally{a.f()}return!0},p=function cbFnct(t){var r,a=itemlibrary_createForOfIteratorHelper(i);try{for(a.s();!(r=a.n()).done;){var o=r.value;if(t[o[0]]!=o[1])return!1}}catch(t){a.e(t)}finally{a.f()}return!0},d=function rangeFct(t){var r,a=itemlibrary_createForOfIteratorHelper(c);try{for(a.s();!(r=a.n()).done;){var o=r.value;if(t[o[0]]o[2])return!1}}catch(t){a.e(t)}finally{a.f()}return!0},h=r.where((function(r){return(""==t||-1!=r.name.toLowerCase().indexOf(t))&&u(r)&&l(r)&&p(r)&&d(r)})),m=(m=h).filter((function(t){return t.hasPermission})).sort((function(t,r){return t.name.toLowerCase()>r.name.toLowerCase()?1:-1})),g.abrupt("return",m);case 9:case"end":return g.stop()}}),_callee7)}))),function executeAdvancedFilter(t,r,a,o,i){return g.apply(this,arguments)})},{key:"advancedFilterStuff",value:(y=itemlibrary_asyncToGenerator(itemlibrary_regeneratorRuntime().mark((function _callee8(t,r){var a,o,i,c,u,l,p,d,h,m,y,g,v,_,b,k,w,x,S,T;return itemlibrary_regeneratorRuntime().wrap((function _callee8$(r){for(;;)switch(r.prev=r.next){case 0:a=$(this._element).find(".detailFilters"),o=a.attr("data-subc"),i=this.filters[t].filterBy.search.toLowerCase(),c=this.detailFilter[o],u=[],l=[],p=[],d=itemlibrary_createForOfIteratorHelper(a.find("select"));try{for(d.s();!(h=d.n()).done;)m=h.value,""!=(y=$(m).val())&&u.push([$(m).attr("name"),y,"true"!=m.dataset.notstrict])}catch(t){d.e(t)}finally{d.f()}g=itemlibrary_createForOfIteratorHelper(a.find('input[type="text"]:not(.manualFilter)'));try{for(g.s();!(v=g.n()).done;)_=v.value,""!=(b=$(_).val())&&l.push([$(_).attr("name"),b.toLowerCase()])}catch(t){g.e(t)}finally{g.f()}k=itemlibrary_createForOfIteratorHelper(a.find('input[type="checkbox"]:checked:not(.manualFilter)'));try{for(k.s();!(w=k.n()).done;)x=w.value,""!=(S=$(x).val())&&p.push([$(x).attr("name"),S.toLowerCase()])}catch(t){k.e(t)}finally{k.f()}return r.next=15,this.executeAdvancedFilter(i,c,u,l,p);case 15:return T=r.sent,this.setBGImage(T,t),T=this.filterDuplications(T),r.abrupt("return",T);case 19:case"end":return r.stop()}}),_callee8,this)}))),function advancedFilterStuff(t,r){return y.apply(this,arguments)})},{key:"filterDuplications",value:function filterDuplications(t){return game.settings.get("dsa5","filterDuplicateItems")&&(t=itemlibrary_toConsumableArray(new Map(t.map((function(t){return["".concat(t.name,"_").concat(t.type),t]}))).values())),t}},{key:"filterStuff",value:(m=itemlibrary_asyncToGenerator(itemlibrary_regeneratorRuntime().mark((function _callee9(t,r,a){var o,i,c,u,l,p,d,h;return itemlibrary_regeneratorRuntime().wrap((function _callee9$(m){for(;;)switch(m.prev=m.next){case 0:for(l in o=this.filters[t].filterBy.search,i={field:["name","data"],limit:60,page:a||!0},c=[],u=!1,this.filters[t].categories)this.filters[t].categories[l]&&(d=void 0,""==o?d=r.search(l,{field:["itemType"],limit:60,page:a||!0}):(h=duplicate(i),mergeObject(h,{where:{itemType:l}}),d=r.search(o,h)),this.pages[t].next=d.next,(p=c).push.apply(p,itemlibrary_toConsumableArray(d.result))),u=this.filters[t].categories[l]||u;return u||(c=r.search(o,i),this.pages[t].next=c.next),c=(c=c.result?c.result:c).filter((function(t){return t.hasPermission})).sort((function(t,r){return t.name.toLowerCase()>r.name.toLowerCase()?1:-1})),this.setBGImage(c,t),c=this.filterDuplications(c),m.abrupt("return",c);case 11:case"end":return m.stop()}}),_callee9,this)}))),function filterStuff(t,r,a){return m.apply(this,arguments)})},{key:"setBGImage",value:function setBGImage(t,r){$(this._element).find(".".concat(r," .libcontainer"))["".concat(t.length>0?"remove":"add","Class")]("libraryImg")}},{key:"getItemTemplate",value:(d=itemlibrary_asyncToGenerator(itemlibrary_regeneratorRuntime().mark((function _callee11(t,r){return itemlibrary_regeneratorRuntime().wrap((function _callee11$(a){for(;;)switch(a.prev=a.next){case 0:if(!this.browseEnabled||"Item"!=r){a.next=6;break}return a.next=3,Promise.all(t.map(function(){var t=itemlibrary_asyncToGenerator(itemlibrary_regeneratorRuntime().mark((function _callee10(t){var r,a,o;return itemlibrary_regeneratorRuntime().wrap((function _callee10$(i){for(;;)switch(i.prev=i.next){case 0:return r="systems/dsa5/templates/items/browse/".concat(t.document.filterType,".html"),i.next=3,fromUuid(t.uuid);case 3:return a=i.sent,i.t0=renderTemplate,i.t1=r,i.t2=itemlibrary_objectSpread,i.t3={document:a,isGM:game.user.isGM},i.next=10,a.sheet.getData();case 10:return i.t4=i.sent,i.t5=(0,i.t2)(i.t3,i.t4),i.next=14,(0,i.t0)(i.t1,i.t5);case 14:return o=i.sent,i.abrupt("return",'
    ').concat(o,"
    "));case 16:case"end":return i.stop()}}),_callee10)})));return function(r){return t.apply(this,arguments)}}()));case 3:return a.abrupt("return",a.sent.join("\n"));case 6:return a.next=9,renderTemplate("systems/dsa5/templates/system/libraryItem.html",{items:t});case 9:return a.abrupt("return",a.sent);case 10:case"end":return a.stop()}}),_callee11,this)}))),function getItemTemplate(t,r){return d.apply(this,arguments)})},{key:"renderResult",value:(p=itemlibrary_asyncToGenerator(itemlibrary_regeneratorRuntime().mark((function _callee12(t,r,a,o){var i,c,u,l;return itemlibrary_regeneratorRuntime().wrap((function _callee12$(p){for(;;)switch(p.prev=p.next){case 0:return i=a.index,c=a.itemType,u=t.find(".searchResult .item-list"),p.next=4,this.getItemTemplate(r,c);case 4:l=p.sent,o||u.empty(),(l=$(l)).each((function(){var t=$(this);t.attr("draggable",!0).on("dragstart",(function(r){var a=i.find($(t).attr("data-item-id"));r.originalEvent.dataTransfer.setData("text/plain",JSON.stringify({type:c,uuid:a.uuid}))}))})),u.append(l);case 9:case"end":return p.stop()}}),_callee12,this)}))),function renderResult(t,r,a,o){return p.apply(this,arguments)})},{key:"filterItems",value:(l=itemlibrary_asyncToGenerator(itemlibrary_regeneratorRuntime().mark((function _callee13(t,r,a){var o,i;return itemlibrary_regeneratorRuntime().wrap((function _callee13$(c){for(;;)switch(c.prev=c.next){case 0:if(o=this.selectIndex(r),!this.advancedFiltering||"journal"==r){c.next=7;break}return c.next=4,this.advancedFilterStuff(r,a);case 4:c.t0=c.sent,c.next=10;break;case 7:return c.next=9,this.filterStuff(r,o.index,a);case 9:c.t0=c.sent;case 10:return i=c.t0,c.next=13,this.renderResult(t,i,o,a);case 13:return c.abrupt("return",i);case 14:case"end":return c.stop()}}),_callee13,this)}))),function filterItems(t,r,a){return l.apply(this,arguments)})},{key:"selectIndex",value:function selectIndex(t){var r="Item",a=this.equipmentIndex;switch(t){case"zoo":r="Actor",a=this.zooIndex;break;case"journal":r="JournalEntry",a=this.journalIndex}return{index:a,itemType:r}}},{key:"_render",value:(u=itemlibrary_asyncToGenerator(itemlibrary_regeneratorRuntime().mark((function _callee14(){var t,r,a=arguments;return itemlibrary_regeneratorRuntime().wrap((function _callee14$(o){for(;;)switch(o.prev=o.next){case 0:return t=a.length>0&&void 0!==a[0]&&a[0],r=a.length>1&&void 0!==a[1]?a[1]:{},o.next=4,itemlibrary_get(itemlibrary_getPrototypeOf(DSA5ItemLibrary.prototype),"_render",this).call(this,t,r);case 4:this.buildEquipmentIndex();case 5:case"end":return o.stop()}}),_callee14,this)}))),function _render(){return u.apply(this,arguments)})},{key:"buildEquipmentIndex",value:(c=itemlibrary_asyncToGenerator(itemlibrary_regeneratorRuntime().mark((function _callee15(){return itemlibrary_regeneratorRuntime().wrap((function _callee15$(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._createIndex("equipment","Item",game.items);case 2:case"end":return t.stop()}}),_callee15,this)}))),function buildEquipmentIndex(){return c.apply(this,arguments)})},{key:"_createIndex",value:(i=itemlibrary_asyncToGenerator(itemlibrary_regeneratorRuntime().mark((function _callee17(t,r,a){var o,i,c,u,l,p,d,h,m=this;return itemlibrary_regeneratorRuntime().wrap((function _callee17$(y){for(;;)switch(y.prev=y.next){case 0:if(!this["".concat(t,"Build")]){y.next=2;break}return y.abrupt("return");case 2:return SceneNavigation.displayProgressBar({label:game.i18n.format("Library.loading",{item:""}),pct:0}),o=$(this._element).find('*[data-tab="'.concat(t,'"]')),this.showLoading(o,t),i=game.packs.filter((function(t){return t.documentName==r&&(game.user.isGM||!t.private)})),c=100/(i.length+1),u=c,l=["name","system.type","system.description.value","img"],p="Actor"==r?function func(t){return t.getIndex({actorFields:l})}:"JournalEntry"==r?function func(t){return t.getDocuments()}:function func(t){return t.getDocuments({type__in:game.system.documentTypes.Item})},d=this.indexWorldItems(a,t),SceneNavigation.displayProgressBar({label:game.i18n.format("Library.loading",{item:"world items"}),pct:Math.round(c)}),h=i.map(function(){var t=itemlibrary_asyncToGenerator(itemlibrary_regeneratorRuntime().mark((function _callee16(t){var r;return itemlibrary_regeneratorRuntime().wrap((function _callee16$(a){for(;;)switch(a.prev=a.next){case 0:return a.next=2,p(t);case 2:r=a.sent,u+=c,SceneNavigation.displayProgressBar({label:game.i18n.format("Library.loading",{item:"".concat(t.metadata.label," (").concat(t.metadata.id,")")}),pct:Math.round(u)}),d.push.apply(d,itemlibrary_toConsumableArray(r.map((function(r){return new mt(r,t.metadata)}))));case 6:case"end":return a.stop()}}),_callee16)})));return function(r){return t.apply(this,arguments)}}()),y.abrupt("return",Promise.all(h).then((function(r){m["".concat(t,"Index")].add(d),m["".concat(t,"Build")]=!0,SceneNavigation.displayProgressBar({label:game.i18n.format("Library.loading",{item:""}),pct:100}),m.hideLoading(o,t)})));case 14:case"end":return y.stop()}}),_callee17,this)}))),function _createIndex(t,r,a){return i.apply(this,arguments)})},{key:"subcategoryFields",value:function subcategoryFields(t){var r,a=["name","itemType"],o=itemlibrary_createForOfIteratorHelper(ht[t]||[]);try{for(o.s();!(r=o.n()).done;){var i=r.value;a.push(i.attr)}}catch(t){o.e(t)}finally{o.f()}return a}},{key:"indexWorldItems",value:function indexWorldItems(t,r){var a=[];return game.settings.get("dsa5","indexWorldItems")&&(a.push.apply(a,itemlibrary_toConsumableArray(t.filter((function(t){return t.visible})).map((function(t){return new mt(t)})))),this["".concat(r,"WorldBuild")]=!0),a}},{key:"createDetailIndex",value:(o=itemlibrary_asyncToGenerator(itemlibrary_regeneratorRuntime().mark((function _callee18(t,r){var a,o,i,c,u,l,p,d,h,m,y,g,v,_,b,k,w,x,S,T;return itemlibrary_regeneratorRuntime().wrap((function _callee18$(A){for(;;)switch(A.prev=A.next){case 0:if(this.detailFilter[r]){A.next=39;break}a=this.subcategoryFields(r),(o=$(this._element).find('*[data-tab="'.concat(t,'"]'))).find(".searchResult ul").html(""),this.showLoading(o,t),this.detailFilter[r]=new FlexSearch({encode:"simple",tokenize:"full",cache:!0,doc:{id:"id",field:a}}),i=this.selectIndex(t),c=i.index,u=i.itemType,l="Item"==u?game.items:game.actors,p=l.filter((function(t){return t.visible&&t.type==r})).map((function(t){return new yt(t,r)})),d=c.search(r,{field:["itemType"]}),h={},m=itemlibrary_createForOfIteratorHelper(d),A.prev=12,m.s();case 14:if((y=m.n()).done){A.next=22;break}if((g=y.value).document.pack){A.next=18;break}return A.abrupt("continue",20);case 18:h[g.document.pack]||(h[g.document.pack]=[]),h[g.document.pack].push(g.document.id);case 20:A.next=14;break;case 22:A.next=27;break;case 24:A.prev=24,A.t0=A.catch(12),m.e(A.t0);case 27:return A.prev=27,m.f(),A.finish(27);case 30:for(v=[],_=0,b=Object.entries(h);_".concat(game.i18n.localize("Library.selectAdvanced"),"

    "));case 12:case"end":return c.stop()}}),_callee19,this)}))),function buildDetailFilter(t,r){return a.apply(this,arguments)})},{key:"checkWorldStuffIndex",value:function checkWorldStuffIndex(){game.settings.get("dsa5","indexWorldItems")&&(!this.journalWorldBuild&&this.journalBuild&&this.journalIndex.add(this.indexWorldItems(game.journal,"journal")),!this.equipmentWorldBuild&&this.equipmentBuild&&this.equipmentIndex.add(this.indexWorldItems(game.items,"equipment")),!this.zooWorldBuild&&this.zooBuild&&this.zooIndex.add(this.indexWorldItems(game.actors,"zoo")))}},{key:"activateListeners",value:function activateListeners(r){var a=this;itemlibrary_get(itemlibrary_getPrototypeOf(DSA5ItemLibrary.prototype),"activateListeners",this).call(this,r),(0,h.Ee)(r),r.on("click",".searchableAbility a",(function(t){return(0,h.$8)(t)})),r.on("click",".toggleAdvancedMode",(function(){a.advancedFiltering=!a.advancedFiltering,a.advancedFiltering?($(a._element).find(".toggleAdvancedMode").addClass("on"),$(a._element).find(".advancedSearch").fadeIn(),a.purgeAdvancedFilters()):($(a._element).find(".toggleAdvancedMode").removeClass("on"),$(a._element).find(".advancedSearch").fadeOut())})),r.on("change",".detailFilters input, .detailFilters select",(function(){var t=$(a._element).find(".tab.active"),r=t.attr("data-tab");a.filterItems(t,r)})),r.on("click",".filter",function(){var t=itemlibrary_asyncToGenerator(itemlibrary_regeneratorRuntime().mark((function _callee20(t){var r,o,i,c;return itemlibrary_regeneratorRuntime().wrap((function _callee20$(u){for(;;)switch(u.prev=u.next){case 0:if(r=$(t.currentTarget).closest(".tab"),o=r.attr("data-tab"),i=t.currentTarget.dataset.category,c=$(t.currentTarget).is(":checked"),!a.advancedFiltering||!c){u.next=13;break}return a.purgeAdvancedFilters(),a.subcategory=i,$(t.currentTarget).prop("checked",c),u.t0=$(a._element).find(".advancedSearch .groupbox"),u.next=11,a.buildDetailFilter(o,i);case 11:u.t1=u.sent,u.t0.html.call(u.t0,u.t1);case 13:a.filters[o].categories[i]=c,a.filterItems(r,o);case 15:case"end":return u.stop()}}),_callee20)})));return function(r){return t.apply(this,arguments)}}()),r.on("click",".item-name",(function(t){a.getItemFromHTML(t).render()})),r.on("mousedown",".item-name",(function(r){2==r.button&&t.Z.showArtwork(a.getItemFromHTML(r))})),r.on("keyup",".filterBy-search",(function(t){var r=$(t.currentTarget).closest(".tab"),o=r.attr("data-tab");a.filters[o].filterBy.search=$(t.currentTarget).val(),a.filterItems(r,o)})),r.on("click",".show-item",function(){var t=itemlibrary_asyncToGenerator(itemlibrary_regeneratorRuntime().mark((function _callee21(t){var r,a;return itemlibrary_regeneratorRuntime().wrap((function _callee21$(o){for(;;)switch(o.prev=o.next){case 0:return r=t.currentTarget.dataset.uuid,o.next=3,fromUuid(r);case 3:(a=o.sent)&&a.sheet.render(!0);case 5:case"end":return o.stop()}}),_callee21)})));return function(r){return t.apply(this,arguments)}}()),r.find('*[data-tab="journal"]').click((function(t){a._createIndex("journal","JournalEntry",game.journal)})),r.find('*[data-tab="zoo"]').click((function(t){a._createIndex("zoo","Actor",game.actors)})),r.find(".showDetails").click((function(t){var a=t.currentTarget.dataset.btn;$(t.currentTarget).find("i").toggleClass("fa-caret-left fa-caret-right"),r.find(".".concat(a," .detailBox")).toggleClass("dsahidden")})),r.find(".toggleWorldIndex").click((function(t){game.settings.set("dsa5","indexWorldItems",!game.settings.get("dsa5","indexWorldItems")),a.checkWorldStuffIndex(),$(t.currentTarget).toggleClass("on")})),r.find(".fulltextsearch").click((function(t){game.settings.set("dsa5","indexDescription",!game.settings.get("dsa5","indexDescription")),$(t.currentTarget).toggleClass("on")})),r.find(".browseEnabled").click((function(t){a.browseEnabled=!a.browseEnabled,$(t.currentTarget).toggleClass("on")})),r.find(".filterDuplicateItems").click((function(t){game.settings.set("dsa5","filterDuplicateItems",!game.settings.get("dsa5","filterDuplicateItems")),$(t.currentTarget).toggleClass("on")}));var o=this;$(this._element).find(".window-content").on("scroll.infinit",debounce((function(t){if(!o.advancedFiltering){var a=$(t.target),i=a.scrollTop()+a.innerHeight()>=a[0].scrollHeight-100,c=r.find(".tabs .item.active").attr("data-tab");if(i&&o.pages[c].next){var u=r.find(".tab.active");o.filterItems.call(o,u,c,o.pages[c].next)}}}),100))}},{key:"getItemFromHTML",value:function getItemFromHTML(t){var r=$(t.currentTarget).parents(".browser-item").attr("data-item-id");switch($(t.currentTarget).closest(".tab").attr("data-tab")){case"zoo":return this.zooIndex.find(r);case"journal":return this.journalIndex.find(r);default:return this.equipmentIndex.find(r)}}},{key:"showLoading",value:function showLoading(t,r){this.setBGImage([1],r),$('
    '.concat(game.i18n.localize("Library.buildingIndex"),"
    ")).appendTo(t.find(".searchResult"))}},{key:"hideLoading",value:function hideLoading(t,r){this.setBGImage([],r),t.find(".loader").remove()}}],[{key:"defaultOptions",get:function get(){var t=itemlibrary_get(itemlibrary_getPrototypeOf(DSA5ItemLibrary),"defaultOptions",this);return t.id="DSA5ItemLibrary",t.classes.push("dsa5","itemlibrary"),t.height=800,t.width=800,t.resizable=!0,t.title=game.i18n.localize("ItemLibrary"),t.template="systems/dsa5/templates/system/itemlibrary.html",t.tabs=[{navSelector:".tabs",contentSelector:".content",initial:"equipment"}],t}}]),DSA5ItemLibrary}();function initializer_typeof(t){return initializer_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},initializer_typeof(t)}function initializer_slicedToArray(t,r){return function initializer_arrayWithHoles(t){if(Array.isArray(t))return t}(t)||function initializer_iterableToArrayLimit(t,r){var a=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null==a)return;var o,i,c=[],u=!0,l=!1;try{for(a=a.call(t);!(u=(o=a.next()).done)&&(c.push(o.value),!r||c.length!==r);u=!0);}catch(t){l=!0,i=t}finally{try{u||null==a.return||a.return()}finally{if(l)throw i}}return c}(t,r)||initializer_unsupportedIterableToArray(t,r)||function initializer_nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function initializer_createForOfIteratorHelper(t,r){var a="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!a){if(Array.isArray(t)||(a=initializer_unsupportedIterableToArray(t))||r&&t&&"number"==typeof t.length){a&&(t=a);var o=0,i=function F(){};return{s:i,n:function n(){return o>=t.length?{done:!0}:{done:!1,value:t[o++]}},e:function e(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var c,u=!0,l=!1;return{s:function s(){a=a.call(t)},n:function n(){var t=a.next();return u=t.done,t},e:function e(t){l=!0,c=t},f:function f(){try{u||null==a.return||a.return()}finally{if(l)throw c}}}}function initializer_unsupportedIterableToArray(t,r){if(t){if("string"==typeof t)return initializer_arrayLikeToArray(t,r);var a=Object.prototype.toString.call(t).slice(8,-1);return"Object"===a&&t.constructor&&(a=t.constructor.name),"Map"===a||"Set"===a?Array.from(t):"Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a)?initializer_arrayLikeToArray(t,r):void 0}}function initializer_arrayLikeToArray(t,r){(null==r||r>t.length)&&(r=t.length);for(var a=0,o=new Array(r);a=0;--o){var i=this.tryEntries[o],c=i.completion;if("root"===i.tryLoc)return handle("end");if(i.tryLoc<=this.prev){var u=a.call(i,"catchLoc"),l=a.call(i,"finallyLoc");if(u&&l){if(this.prev=0;--o){var i=this.tryEntries[o];if(i.tryLoc<=this.prev&&a.call(i,"finallyLoc")&&this.prev=0;--r){var a=this.tryEntries[r];if(a.finallyLoc===t)return this.complete(a.completion,a.afterLoc),resetTryEntry(a),l}},catch:function _catch(t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc===t){var o=a.completion;if("throw"===o.type){var i=o.arg;resetTryEntry(a)}return i}}throw new Error("illegal catch attempt")},delegateYield:function delegateYield(t,r,a){return this.delegate={iterator:values(t),resultName:r,nextLoc:a},"next"===this.method&&(this.arg=void 0),l}},t}function initializer_asyncGeneratorStep(t,r,a,o,i,c,u){try{var l=t[c](u),p=l.value}catch(t){return void a(t)}l.done?r(p):Promise.resolve(p).then(o,i)}function initializer_asyncToGenerator(t){return function(){var r=this,a=arguments;return new Promise((function(o,i){var c=t.apply(r,a);function _next(t){initializer_asyncGeneratorStep(c,o,i,_next,_throw,"next",t)}function _throw(t){initializer_asyncGeneratorStep(c,o,i,_next,_throw,"throw",t)}_next(void 0)}))}}function initializer_classCallCheck(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}function initializer_defineProperties(t,r){for(var a=0;a3&&void 0!==arguments[3]?arguments[3]:"";initializer_classCallCheck(this,DSA5Initializer);var c,u,l={title:t,content:r,buttons:{initialize:{label:game.i18n.localize("initialize"),callback:(u=initializer_asyncToGenerator(initializer_regeneratorRuntime().mark((function _callee(){return initializer_regeneratorRuntime().wrap((function _callee$(t){for(;;)switch(t.prev=t.next){case 0:if(!o.lock){t.next=2;break}return t.abrupt("return");case 2:return t.next=4,o.initialize();case 4:case"end":return t.stop()}}),_callee)}))),function callback(){return u.apply(this,arguments)})},cancel:{label:game.i18n.localize("cancel"),callback:(c=initializer_asyncToGenerator(initializer_regeneratorRuntime().mark((function _callee2(){return initializer_regeneratorRuntime().wrap((function _callee2$(t){for(;;)switch(t.prev=t.next){case 0:if(!o.lock){t.next=2;break}return t.abrupt("return");case 2:return t.next=4,o.dontInitialize();case 4:case"end":return t.stop()}}),_callee2)}))),function callback(){return c.apply(this,arguments)})}}};return(o=p.call(this,l)).module=a,o.lang=i,o.folders={},o.journals={},o.scenes={},o.actors={},o.lock=!1,o}return function initializer_createClass(t,r,a){return r&&initializer_defineProperties(t.prototype,r),a&&initializer_defineProperties(t,a),Object.defineProperty(t,"prototype",{writable:!1}),t}(DSA5Initializer,[{key:"initNotes",value:(l=initializer_asyncToGenerator(initializer_regeneratorRuntime().mark((function _callee3(t,r,a){var o,i,c,u,l=this;return initializer_regeneratorRuntime().wrap((function _callee3$(p){for(;;)switch(p.prev=p.next){case 0:return p.next=2,this.getFolderForType("JournalEntry");case 2:o=p.sent,i=initializer_createForOfIteratorHelper(t.notes),p.prev=4,u=initializer_regeneratorRuntime().mark((function _loop(){var i,u,p,d,h,m;return initializer_regeneratorRuntime().wrap((function _loop$(y){for(;;)switch(y.prev=y.next){case 0:if(i=c.value,y.prev=1,u=r.find((function(t){return t.flags.dsa5.initId==i.entryId})),a.has(u._id)){y.next=26;break}if(p=getProperty(u,"flags.dsa5.parent"),d=o,!l.folders[p]){y.next=10;break}d=l.folders[p],y.next=14;break;case 10:if(!p){y.next=14;break}return y.next=13,l.getFolderForType("JournalEntry",o.id,p,0,getProperty(u,"flags.dsa5.foldercolor")||"");case 13:d=y.sent;case 14:if(u.folder=d.id,!(h=game.journal.find((function(t){var r;return t.name==u.name&&(null===(r=t.folder)||void 0===r?void 0:r.id)==d.id&&t.flags.dsa5.initId==i.entryId})))){y.next=22;break}return y.next=19,h.update(u);case 19:a.set(u._id,h.id),y.next=26;break;case 22:return y.next=24,JournalEntry.create(u);case 24:m=y.sent,a.set(u._id,m.id);case 26:i.entryId=a.get(u._id),y.next=32;break;case 29:y.prev=29,y.t0=y.catch(1),console.warn("Could not initialize Scene Notes for scene :".concat(t.name)+y.t0);case 32:case"end":return y.stop()}}),_loop,null,[[1,29]])})),i.s();case 7:if((c=i.n()).done){p.next=11;break}return p.delegateYield(u(),"t0",9);case 9:p.next=7;break;case 11:p.next=16;break;case 13:p.prev=13,p.t1=p.catch(4),i.e(p.t1);case 16:return p.prev=16,i.f(),p.finish(16);case 19:case"end":return p.stop()}}),_callee3,this,[[4,13,16,19]])}))),function initNotes(t,r,a){return l.apply(this,arguments)})},{key:"initScenes",value:(u=initializer_asyncToGenerator(initializer_regeneratorRuntime().mark((function _callee4(t){var r,a,o,i,c,u,l,p,d,h,m,y,g,v,_,b,k,w,x,S,T,A,O=this;return initializer_regeneratorRuntime().wrap((function _callee4$(P){for(;;)switch(P.prev=P.next){case 0:return P.next=2,this.getFolderForType("Scene");case 2:return r=P.sent,a=game.packs.get(t.scenes),P.next=6,a.getDocuments();case 6:return o=P.sent.map((function(t){return t.toObject()})),i=game.packs.get(t.journal),P.next=10,i.getDocuments();case 10:c=P.sent.map((function(t){return t.toObject()})),u=[],l=[],p=new Map,d=!1,h=initializer_createForOfIteratorHelper(o),P.prev=16,y=initializer_regeneratorRuntime().mark((function _loop2(){var t,a,o,i,h;return initializer_regeneratorRuntime().wrap((function _loop2$(y){for(;;)switch(y.prev=y.next){case 0:if(t=m.value,a=d,o=game.scenes.find((function(a){var o;return a.name==t.name&&(null===(o=a.folder)||void 0===o?void 0:o.id)==r.id})),d||!o){y.next=10;break}return y.next=6,new Promise((function(r,a){new Dialog({title:game.i18n.localize("Book.sceneReset"),content:game.i18n.format("Book.sceneResetDescription",{name:t.name}),default:"Yes",buttons:{Yes:{icon:'',label:game.i18n.localize("yes"),callback:function callback(){r([!0,!1])}},all:{icon:'',label:game.i18n.localize("LocalizedIDs.all"),callback:function callback(){r([!0,!0])}},cancel:{icon:'',label:game.i18n.localize("cancel"),callback:function callback(){r([!1,!1])}}},close:function close(){r([!1,!1])}}).render(!0)}));case 6:i=y.sent,h=initializer_slicedToArray(i,2),a=h[0],d=h[1];case 10:if(!o||a){y.next=13;break}return O.scenes[o.name]=o,y.abrupt("return","continue");case 13:return t.folder=r.id,y.next=16,O.initNotes(t,c,p);case 16:o?(t._id=o.id,l.push(t)):u.push(t);case 17:case"end":return y.stop()}}),_loop2)})),h.s();case 19:if((m=h.n()).done){P.next=26;break}return P.delegateYield(y(),"t0",21);case 21:if("continue"!==P.t0){P.next=24;break}return P.abrupt("continue",24);case 24:P.next=19;break;case 26:P.next=31;break;case 28:P.prev=28,P.t1=P.catch(16),h.e(P.t1);case 31:return P.prev=31,h.f(),P.finish(31);case 34:return P.next=36,Scene.create(u,{dsaInit:!0});case 36:g=P.sent,v=initializer_createForOfIteratorHelper(g),P.prev=38,v.s();case 40:if((_=v.n()).done){P.next=50;break}return b=_.value,this.scenes[b.name]=b,P.next=45,b.createThumbnail();case 45:return k=P.sent,P.next=48,b.update({thumb:k.thumb},{diff:!1});case 48:P.next=40;break;case 50:P.next=55;break;case 52:P.prev=52,P.t2=P.catch(38),v.e(P.t2);case 55:return P.prev=55,v.f(),P.finish(55);case 58:w=0,x=l;case 59:if(!(w
    '),r={},i.prev=4,!game.settings.settings.has("".concat(this.module,".initialized"))){i.next=8;break}return i.next=8,game.settings.set(this.module,"initialized",!0);case 8:i.next=12;break;case 10:i.prev=10,i.t0=i.catch(4);case 12:return i.prev=12,i.next=15,fetch("modules/".concat(this.module,"/adventure").concat(this.lang,".json")).then(function(){var t=initializer_asyncToGenerator(initializer_regeneratorRuntime().mark((function _callee5(t){return initializer_regeneratorRuntime().wrap((function _callee5$(r){for(;;)switch(r.prev=r.next){case 0:return r.abrupt("return",t.json());case 1:case"end":return r.stop()}}),_callee5)})));return function(r){return t.apply(this,arguments)}}()).then(function(){var t=initializer_asyncToGenerator(initializer_regeneratorRuntime().mark((function _callee6(t){return initializer_regeneratorRuntime().wrap((function _callee6$(a){for(;;)switch(a.prev=a.next){case 0:r=t;case 1:case"end":return a.stop()}}),_callee6)})));return function(r){return t.apply(this,arguments)}}());case 15:i.next=27;break;case 17:return i.prev=17,i.t1=i.catch(12),i.prev=19,i.next=22,fetch("modules/".concat(this.module,"/adventure.json")).then(function(){var t=initializer_asyncToGenerator(initializer_regeneratorRuntime().mark((function _callee7(t){return initializer_regeneratorRuntime().wrap((function _callee7$(r){for(;;)switch(r.prev=r.next){case 0:return r.abrupt("return",t.json());case 1:case"end":return r.stop()}}),_callee7)})));return function(r){return t.apply(this,arguments)}}()).then(function(){var t=initializer_asyncToGenerator(initializer_regeneratorRuntime().mark((function _callee8(t){return initializer_regeneratorRuntime().wrap((function _callee8$(a){for(;;)switch(a.prev=a.next){case 0:r=t;case 1:case"end":return a.stop()}}),_callee8)})));return function(r){return t.apply(this,arguments)}}());case 22:i.next=27;break;case 24:i.prev=24,i.t2=i.catch(19),console.warn("Could not find book data for ".concat(this.module," import."));case 27:return i.next=29,fetch("modules/".concat(this.module,"/initialization").concat(this.lang,".json")).then(function(){var t=initializer_asyncToGenerator(initializer_regeneratorRuntime().mark((function _callee9(t){return initializer_regeneratorRuntime().wrap((function _callee9$(r){for(;;)switch(r.prev=r.next){case 0:return r.abrupt("return",t.json());case 1:case"end":return r.stop()}}),_callee9)})));return function(r){return t.apply(this,arguments)}}()).then(function(){var t=initializer_asyncToGenerator(initializer_regeneratorRuntime().mark((function _callee13(t){var i,c,u,l,p,d,h,m,y,g,v;return initializer_regeneratorRuntime().wrap((function _callee13$(_){for(;;)switch(_.prev=_.next){case 0:if(!(i=t.folders)){_.next=17;break}return _.next=4,a.getFolderForType("JournalEntry");case 4:return c=_.sent,u=t.folders[0].name,c&&(a.folders[c.data.name]=c,t.folders.shift()),_.next=9,Folder.create(i);case 9:l=_.sent,Array.isArray(l)||(l=[l]),p=initializer_createForOfIteratorHelper(l);try{for(p.s();!(d=p.n()).done;)h=d.value,a.folders[h.data.name]=h}catch(t){p.e(t)}finally{p.f()}for(y in m=[],a.folders)g=a.folders[y].getFlag("dsa5","parent"),(v=g==u?game.i18n.localize("".concat(a.module,".name")):g)&&m.push({_id:a.folders[y].id,parent:a.folders[v].id});return _.next=17,Folder.updateDocuments(m);case 17:if(!(t.items&&t.items.length>0)){_.next=19;break}return _.delegateYield(initializer_regeneratorRuntime().mark((function _callee10(){var r,i,c,u,l,p;return initializer_regeneratorRuntime().wrap((function _callee10$(d){for(;;)switch(d.prev=d.next){case 0:return d.next=2,a.getFolderForType("Item");case 2:r=d.sent,i=[],c=[],u=initializer_createForOfIteratorHelper(t.items);try{for(p=function _loop3(){var t=l.value;t.folder=r.id;var a=game.items.find((function(a){var o;return a.name==t.name&&(null===(o=a.folder)||void 0===o?void 0:o.id)==r.id}));a?(t._id=a.id,c.push(t)):i.push(t)},u.s();!(l=u.n()).done;)p()}catch(t){u.e(t)}finally{u.f()}return d.next=9,o.Z.create(i);case 9:return d.next=11,o.Z.updateDocuments(c);case 11:case"end":return d.stop()}}),_callee10)}))(),"t0",19);case 19:if(!t.playlists){_.next=21;break}return _.delegateYield(initializer_regeneratorRuntime().mark((function _callee11(){var r,o,i,c,u,l,p,d;return initializer_regeneratorRuntime().wrap((function _callee11$(h){for(;;)switch(h.prev=h.next){case 0:return h.next=2,a.getFolderForType("Playlist");case 2:return r=h.sent,o=[],i=[],c=game.packs.get(t.playlists),h.next=8,c.getDocuments();case 8:u=h.sent.map((function(t){return t.toObject()})),l=initializer_createForOfIteratorHelper(u);try{for(d=function _loop4(){var t=p.value;t.folder=r.id;var a=game.playlists.find((function(a){var o;return a.name==t.name&&(null===(o=a.folder)||void 0===o?void 0:o.id)==r.id}));a?(t._id=a.data._id,i.push(t)):o.push(t)},l.s();!(p=l.n()).done;)d()}catch(t){l.e(t)}finally{l.f()}return h.next=13,Playlist.create(o,{keepId:!0});case 13:return h.next=15,Playlist.updateDocuments(i);case 15:case"end":return h.stop()}}),_callee11)}))(),"t1",21);case 21:if(!t.scenes){_.next=24;break}return _.next=24,a.initScenes(t);case 24:if(!t.actors){_.next=26;break}return _.delegateYield(initializer_regeneratorRuntime().mark((function _callee12(){var o,i,c,u,l,p,d,h,m,y,g,v,_,b,k,w,x,S,T,A,O,P,E,C;return initializer_regeneratorRuntime().wrap((function _callee12$(D){for(;;)switch(D.prev=D.next){case 0:return D.next=2,a.getFolderForType("Actor");case 2:return o=D.sent,i=game.packs.get(t.actors),D.next=6,i.getDocuments();case 6:if(c=D.sent.map((function(t){return t.toObject()})),u=[],l=[],p=new Map,d=0,!getProperty(r,"chapters")){D.next=50;break}h=initializer_createForOfIteratorHelper(r.chapters),D.prev=13,h.s();case 15:if((m=h.n()).done){D.next=42;break}y=m.value,g=initializer_createForOfIteratorHelper(y.content),D.prev=18,g.s();case 20:if((v=g.n()).done){D.next=32;break}if(!(_=v.value).actors){D.next=30;break}b=!1,k=initializer_createForOfIteratorHelper(_.actors);try{for(k.s();!(w=k.n()).done;)x=w.value,p.has(x)||(p.set(x,_.name),b=!0)}catch(t){k.e(t)}finally{k.f()}if(!b){D.next=30;break}return D.next=29,a.getFolderForType("Actor",o.id,_.name,d);case 29:d+=1;case 30:D.next=20;break;case 32:D.next=37;break;case 34:D.prev=34,D.t0=D.catch(18),g.e(D.t0);case 37:return D.prev=37,g.f(),D.finish(37);case 40:D.next=15;break;case 42:D.next=47;break;case 44:D.prev=44,D.t1=D.catch(13),h.e(D.t1);case 47:return D.prev=47,h.f(),D.finish(47);case 50:S=initializer_createForOfIteratorHelper(c),D.prev=51,A=initializer_regeneratorRuntime().mark((function _loop5(){var t,r,i;return initializer_regeneratorRuntime().wrap((function _loop5$(c){for(;;)switch(c.prev=c.next){case 0:if(t=T.value,!p.has(t.name)){c.next=7;break}return c.next=4,a.getFolderForType("Actor",o.id,p.get(t.name));case 4:c.t0=c.sent,c.next=8;break;case 7:c.t0=o;case 8:if(r=c.t0,t.folder=r.id,t._id&&delete t._id,!(i=game.actors.find((function(a){var i;return a.name==t.name&&[o.id,r.id].includes(null===(i=a.folder)||void 0===i?void 0:i.id)})))){c.next=19;break}return t._id=i.id,c.next=16,i.deleteEmbeddedDocuments("Item",i.items.map((function(t){return t.id})));case 16:l.push(t),c.next=20;break;case 19:u.push(t);case 20:case"end":return c.stop()}}),_loop5)})),S.s();case 54:if((T=S.n()).done){D.next=58;break}return D.delegateYield(A(),"t2",56);case 56:D.next=54;break;case 58:D.next=63;break;case 60:D.prev=60,D.t3=D.catch(51),S.e(D.t3);case 63:return D.prev=63,S.f(),D.finish(63);case 66:return D.next=68,Actor.create(u);case 68:return O=D.sent,D.next=71,Actor.updateDocuments(l);case 71:P=initializer_createForOfIteratorHelper(O);try{for(P.s();!(E=P.n()).done;)C=E.value,a.actors[C.name]=C}catch(t){P.e(t)}finally{P.f()}case 73:case"end":return D.stop()}}),_callee12,null,[[13,44,47,50],[18,34,37,40],[51,60,63,66]])}))(),"t2",26);case 26:case"end":return _.stop()}}),_callee13)})));return function(r){return t.apply(this,arguments)}}());case 29:return this.lock=!1,t.find("i").remove(),ui.notifications.notify(game.i18n.localize("initComplete")),i.next=34,this.close();case 34:case"end":return i.stop()}}),_callee14,this,[[4,10],[12,17],[19,24]])}))),function initialize(){return c.apply(this,arguments)})},{key:"dontInitialize",value:(i=initializer_asyncToGenerator(initializer_regeneratorRuntime().mark((function _callee15(){return initializer_regeneratorRuntime().wrap((function _callee15$(t){for(;;)switch(t.prev=t.next){case 0:if(!game.settings.settings.has("".concat(this.module,".initialized"))){t.next=3;break}return t.next=3,game.settings.set(this.module,"initialized",!0);case 3:return ui.notifications.notify(game.i18n.localize("initSkipped")),t.next=6,this.close();case 6:case"end":return t.stop()}}),_callee15,this)}))),function dontInitialize(){return i.apply(this,arguments)})},{key:"submit",value:function submit(t){try{t.callback&&t.callback(this.options.jQuery?this.element:this.element[0])}catch(t){throw ui.notifications.error(t),new Error(t)}}},{key:"getFolderForType",value:(a=initializer_asyncToGenerator(initializer_regeneratorRuntime().mark((function _callee16(r){var a,o,i,c,u=arguments;return initializer_regeneratorRuntime().wrap((function _callee16$(l){for(;;)switch(l.prev=l.next){case 0:return a=u.length>1&&void 0!==u[1]?u[1]:null,o=u.length>2&&void 0!==u[2]?u[2]:null,i=u.length>3&&void 0!==u[3]?u[3]:0,c=u.length>4&&void 0!==u[4]?u[4]:"",o||(o=game.i18n.localize("".concat(this.module,".name"))),l.abrupt("return",t.Z.getFolderForType(r,a,o,i,c));case 6:case"end":return l.stop()}}),_callee16,this)}))),function getFolderForType(t){return a.apply(this,arguments)})}]),DSA5Initializer}();function ChatMessageDSA5_typeof(t){return ChatMessageDSA5_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},ChatMessageDSA5_typeof(t)}function ChatMessageDSA5_classCallCheck(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}function ChatMessageDSA5_defineProperties(t,r){for(var a=0;a=t.length?{done:!0}:{done:!1,value:t[o++]}},e:function e(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var c,u=!0,l=!1;return{s:function s(){a=a.call(t)},n:function n(){var t=a.next();return u=t.done,t},e:function e(t){l=!0,c=t},f:function f(){try{u||null==a.return||a.return()}finally{if(l)throw c}}}}function hotbar_arrayLikeToArray(t,r){(null==r||r>t.length)&&(r=t.length);for(var a=0,o=new Array(r);a=0;--o){var i=this.tryEntries[o],c=i.completion;if("root"===i.tryLoc)return handle("end");if(i.tryLoc<=this.prev){var u=a.call(i,"catchLoc"),l=a.call(i,"finallyLoc");if(u&&l){if(this.prev=0;--o){var i=this.tryEntries[o];if(i.tryLoc<=this.prev&&a.call(i,"finallyLoc")&&this.prev=0;--r){var a=this.tryEntries[r];if(a.finallyLoc===t)return this.complete(a.completion,a.afterLoc),resetTryEntry(a),l}},catch:function _catch(t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc===t){var o=a.completion;if("throw"===o.type){var i=o.arg;resetTryEntry(a)}return i}}throw new Error("illegal catch attempt")},delegateYield:function delegateYield(t,r,a){return this.delegate={iterator:values(t),resultName:r,nextLoc:a},"next"===this.method&&(this.arg=void 0),l}},t}function hotbar_asyncGeneratorStep(t,r,a,o,i,c,u){try{var l=t[c](u),p=l.value}catch(t){return void a(t)}l.done?r(p):Promise.resolve(p).then(o,i)}function hotbar_asyncToGenerator(t){return function(){var r=this,a=arguments;return new Promise((function(o,i){var c=t.apply(r,a);function _next(t){hotbar_asyncGeneratorStep(c,o,i,_next,_throw,"next",t)}function _throw(t){hotbar_asyncGeneratorStep(c,o,i,_next,_throw,"throw",t)}_next(void 0)}))}}function hotbar_classCallCheck(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}function hotbar_defineProperties(t,r){for(var a=0;a0&&void 0!==a[0]&&a[0],r=a.length>1&&void 0!==a[1]?a[1]:{},o.next=4,hotbar_get(hotbar_getPrototypeOf(DSA5Hotbar.prototype),"_render",this).call(this,t,r);case 4:this.addContextColor();case 5:case"end":return o.stop()}}),_callee,this)}))),function _render(){return o.apply(this,arguments)})},{key:"collapse",value:(a=hotbar_asyncToGenerator(hotbar_regeneratorRuntime().mark((function _callee2(){return hotbar_regeneratorRuntime().wrap((function _callee2$(t){for(;;)switch(t.prev=t.next){case 0:if(!this._collapsed){t.next=2;break}return t.abrupt("return",!0);case 2:return $(this.element).addClass("collapsedHotbar"),t.abrupt("return",hotbar_get(hotbar_getPrototypeOf(DSA5Hotbar.prototype),"collapse",this).call(this));case 4:case"end":return t.stop()}}),_callee2,this)}))),function collapse(){return a.apply(this,arguments)})},{key:"expand",value:(r=hotbar_asyncToGenerator(hotbar_regeneratorRuntime().mark((function _callee3(){return hotbar_regeneratorRuntime().wrap((function _callee3$(t){for(;;)switch(t.prev=t.next){case 0:if(this._collapsed){t.next=2;break}return t.abrupt("return",!0);case 2:return $(this.element).removeClass("collapsedHotbar"),t.abrupt("return",hotbar_get(hotbar_getPrototypeOf(DSA5Hotbar.prototype),"expand",this).call(this));case 4:case"end":return t.stop()}}),_callee3,this)}))),function expand(){return r.apply(this,arguments)})},{key:"addContextColor",value:function addContextColor(){var t,r=new RegExp(" ".concat(game.i18n.localize("CHAR.PARRY"),"$")),a=new RegExp(" ".concat(game.i18n.localize("CHAR.ATTACK"),"$")),o=$(this._element).find("#macro-list"),i=hotbar_createForOfIteratorHelper(this.macros);try{for(i.s();!(t=i.n()).done;){var c=t.value;c.macro&&(r.test(c.macro.name)?o.find('[data-macro-id="'.concat(c.macro.id,'"]')).addClass("parry"):a.test(c.macro.name)&&o.find('[data-macro-id="'.concat(c.macro.id,'"]')).addClass("attack"))}}catch(t){i.e(t)}finally{i.f()}}}]),DSA5Hotbar}();function roll_memory_defineProperties(t,r){for(var a=0;a0&&setProperty(this,this.getPath(t,r,a),i)}},{key:"recall",value:function recall(t,r,a){return getProperty(this,this.getPath(t,r,a))}},{key:"formDataSerialize",value:function formDataSerialize(t){var r=t.find("form"),a={};return r.find("select").each((function(){var t=$(this).attr("name");RollMemory.wantedKeys.includes(t)&&(a[t]=$(this).val())})),r.find('input[type="checkbox"]').each((function(){var t=$(this).attr("name");RollMemory.wantedKeys.includes(t)&&(a[t]=this.checked)})),r.find(".specAbs.active").each((function(){a.specAbs||(a.specAbs=[]),a.specAbs.push({id:$(this).attr("data-id"),step:$(this).attr("data-step")})})),t.find('[name="situationalModifiers"] option').each((function(){a.situationalModifiers||(a.situationalModifiers=[]),a.situationalModifiers.push({name:$(this).text().trim(),selected:this.selected})})),a}}],[{key:"wantedKeys",get:function get(){var t=["vision","targetMovement","shooterMovement","quickChange","mountOptions","narrowSpace","advantageousPosition","doubleAttack","reduceCostSpell","forceSpell","increaseCastingTime","decreaseCastingTime","removeGesture","removeFormula"];return $e.Z.isEnabled||t.push("distance"),t}}]),RollMemory}(),xt=__webpack_require__(430);function dsa_active_effects_typeof(t){return dsa_active_effects_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},dsa_active_effects_typeof(t)}function dsa_active_effects_regeneratorRuntime(){dsa_active_effects_regeneratorRuntime=function _regeneratorRuntime(){return t};var t={},r=Object.prototype,a=r.hasOwnProperty,o="function"==typeof Symbol?Symbol:{},i=o.iterator||"@@iterator",c=o.asyncIterator||"@@asyncIterator",u=o.toStringTag||"@@toStringTag";function define(t,r,a){return Object.defineProperty(t,r,{value:a,enumerable:!0,configurable:!0,writable:!0}),t[r]}try{define({},"")}catch(t){define=function define(t,r,a){return t[r]=a}}function wrap(t,r,a,o){var i=r&&r.prototype instanceof Generator?r:Generator,c=Object.create(i.prototype),u=new Context(o||[]);return c._invoke=function(t,r,a){var o="suspendedStart";return function(i,c){if("executing"===o)throw new Error("Generator is already running");if("completed"===o){if("throw"===i)throw c;return doneResult()}for(a.method=i,a.arg=c;;){var u=a.delegate;if(u){var p=maybeInvokeDelegate(u,a);if(p){if(p===l)continue;return p}}if("next"===a.method)a.sent=a._sent=a.arg;else if("throw"===a.method){if("suspendedStart"===o)throw o="completed",a.arg;a.dispatchException(a.arg)}else"return"===a.method&&a.abrupt("return",a.arg);o="executing";var d=tryCatch(t,r,a);if("normal"===d.type){if(o=a.done?"completed":"suspendedYield",d.arg===l)continue;return{value:d.arg,done:a.done}}"throw"===d.type&&(o="completed",a.method="throw",a.arg=d.arg)}}}(t,a,u),c}function tryCatch(t,r,a){try{return{type:"normal",arg:t.call(r,a)}}catch(t){return{type:"throw",arg:t}}}t.wrap=wrap;var l={};function Generator(){}function GeneratorFunction(){}function GeneratorFunctionPrototype(){}var p={};define(p,i,(function(){return this}));var d=Object.getPrototypeOf,h=d&&d(d(values([])));h&&h!==r&&a.call(h,i)&&(p=h);var m=GeneratorFunctionPrototype.prototype=Generator.prototype=Object.create(p);function defineIteratorMethods(t){["next","throw","return"].forEach((function(r){define(t,r,(function(t){return this._invoke(r,t)}))}))}function AsyncIterator(t,r){function invoke(o,i,c,u){var l=tryCatch(t[o],t,i);if("throw"!==l.type){var p=l.arg,d=p.value;return d&&"object"==dsa_active_effects_typeof(d)&&a.call(d,"__await")?r.resolve(d.__await).then((function(t){invoke("next",t,c,u)}),(function(t){invoke("throw",t,c,u)})):r.resolve(d).then((function(t){p.value=t,c(p)}),(function(t){return invoke("throw",t,c,u)}))}u(l.arg)}var o;this._invoke=function(t,a){function callInvokeWithMethodAndArg(){return new r((function(r,o){invoke(t,a,r,o)}))}return o=o?o.then(callInvokeWithMethodAndArg,callInvokeWithMethodAndArg):callInvokeWithMethodAndArg()}}function maybeInvokeDelegate(t,r){var a=t.iterator[r.method];if(void 0===a){if(r.delegate=null,"throw"===r.method){if(t.iterator.return&&(r.method="return",r.arg=void 0,maybeInvokeDelegate(t,r),"throw"===r.method))return l;r.method="throw",r.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var o=tryCatch(a,t.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,l;var i=o.arg;return i?i.done?(r[t.resultName]=i.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=void 0),r.delegate=null,l):i:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,l)}function pushTryEntry(t){var r={tryLoc:t[0]};1 in t&&(r.catchLoc=t[1]),2 in t&&(r.finallyLoc=t[2],r.afterLoc=t[3]),this.tryEntries.push(r)}function resetTryEntry(t){var r=t.completion||{};r.type="normal",delete r.arg,t.completion=r}function Context(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(pushTryEntry,this),this.reset(!0)}function values(t){if(t){var r=t[i];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var o=-1,c=function next(){for(;++o=0;--o){var i=this.tryEntries[o],c=i.completion;if("root"===i.tryLoc)return handle("end");if(i.tryLoc<=this.prev){var u=a.call(i,"catchLoc"),l=a.call(i,"finallyLoc");if(u&&l){if(this.prev=0;--o){var i=this.tryEntries[o];if(i.tryLoc<=this.prev&&a.call(i,"finallyLoc")&&this.prev=0;--r){var a=this.tryEntries[r];if(a.finallyLoc===t)return this.complete(a.completion,a.afterLoc),resetTryEntry(a),l}},catch:function _catch(t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc===t){var o=a.completion;if("throw"===o.type){var i=o.arg;resetTryEntry(a)}return i}}throw new Error("illegal catch attempt")},delegateYield:function delegateYield(t,r,a){return this.delegate={iterator:values(t),resultName:r,nextLoc:a},"next"===this.method&&(this.arg=void 0),l}},t}function dsa_active_effects_asyncGeneratorStep(t,r,a,o,i,c,u){try{var l=t[c](u),p=l.value}catch(t){return void a(t)}l.done?r(p):Promise.resolve(p).then(o,i)}function dsa_active_effects_asyncToGenerator(t){return function(){var r=this,a=arguments;return new Promise((function(o,i){var c=t.apply(r,a);function _next(t){dsa_active_effects_asyncGeneratorStep(c,o,i,_next,_throw,"next",t)}function _throw(t){dsa_active_effects_asyncGeneratorStep(c,o,i,_next,_throw,"throw",t)}_next(void 0)}))}}function dsa_active_effects_ownKeys(t,r){var a=Object.keys(t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);r&&(o=o.filter((function(r){return Object.getOwnPropertyDescriptor(t,r).enumerable}))),a.push.apply(a,o)}return a}function dsa_active_effects_objectSpread(t){for(var r=1;r=t.length?{done:!0}:{done:!1,value:t[o++]}},e:function e(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var c,u=!0,l=!1;return{s:function s(){a=a.call(t)},n:function n(){var t=a.next();return u=t.done,t},e:function e(t){l=!0,c=t},f:function f(){try{u||null==a.return||a.return()}finally{if(l)throw c}}}}function dsa_active_effects_arrayLikeToArray(t,r){(null==r||r>t.length)&&(r=t.length);for(var a=0,o=new Array(r);a')+t.split(",").map((function(t){return"".concat(t,"")})).join(", ")+""}(t,r)},hasLocalization:function hasLocalization(t,r){var a=t.string||t;return game.i18n.has(a)?game.i18n.localize(a):r||""},replaceConditions:t.Z.replaceConditions,floor:function floor(t){return Math.floor(Number(t))},br:function br(t){return t.replace(/\n/g,"
    ")},getAttr:function getAttr(t,r,a){return t.system.characteristics[r][a]},hasElem:function hasElem(t,r){return t.filter((function(t){return r==t})).length},situationalTooltip:function situationalTooltip(t){var r=game.i18n.localize(pe[t.type]||"Modifier"),a="".concat(t.name,"
    ").concat(r,": ").concat(t.value);return t.source&&(a+="
    ".concat(game.i18n.localize("source"),": ").concat(t.source)),a},grouped_each:function grouped_each(t,r,a){var o,i="",c=[];if(r&&r.length>0){for(o=0;o0&&o%t==0&&(i+=a.fn(c),c=[]),c.push(r[o]);i+=a.fn(c)}return i},plantify:function plantify(t){return game.i18n.localize("PLANT.avLevels.".concat(t||0))},oddLength:function oddLength(t){return t.length%2==1}})}(),function dicesonice(){Hooks.once("init",(function(){game.dsa5.apps.DiceSoNiceCustomization=new de})),Hooks.once("diceSoNiceReady",(function(t,r,a,o){t.addColorset({name:"mu",description:"DSA5.mu",category:"DSA5.dies",foreground:"#FFFFFF",background:"#b3241a",edge:"#b3241a",outline:"#FFFFFF",texture:"none"}),t.addColorset({name:"kl",description:"DSA5.kl",category:"DSA5.dies",foreground:"#FFFFFF",background:"#8259a3",edge:"#8259a3",outline:"#FFFFFF",texture:"none"}),t.addColorset({name:"in",description:"DSA5.in",category:"DSA5.dies",foreground:"#FFFFFF",background:"#388834",edge:"#388834",outline:"#FFFFFF",texture:"none"}),t.addColorset({name:"ch",description:"DSA5.ch",category:"DSA5.dies",foreground:"#FFFFFF",background:"#0d0d0d",edge:"#0d0d0d",outline:"#FFFFFF",texture:"none"}),t.addColorset({name:"ff",description:"DSA5.ff",category:"DSA5.dies",foreground:"#000000",background:"#d5b467",edge:"#d5b467",outline:"#FFFFFF",texture:"none"}),t.addColorset({name:"ge",description:"DSA5.ge",category:"DSA5.dies",foreground:"#000000",background:"#688ec4",edge:"#688ec4",outline:"#FFFFFF",texture:"none"}),t.addColorset({name:"ko",description:"DSA5.ko",category:"DSA5.dies",foreground:"#000000",background:"#a3a3a3",edge:"#a3a3a3",outline:"#FFFFFF",texture:"none"}),t.addColorset({name:"kk",description:"DSA5.kk",category:"DSA5.dies",foreground:"#000000",background:"#d6a878",edge:"#d6a878",outline:"#FFFFFF",texture:"none"}),t.addColorset({name:"attack",description:"DSA5.attack",category:"DSA5.dies",foreground:"#FFFFFF",background:"#b3241a",edge:"#b3241a",outline:"#b3241a",texture:"none"}),t.addColorset({name:"dodge",description:"DSA5.dodge",category:"DSA5.dies",foreground:"#FFFFFF",background:"#388834",edge:"#388834",outline:"#FFFFFF",texture:"none"}),t.addColorset({name:"parry",description:"DSA5.parry",category:"DSA5.dies",foreground:"#FFFFFF",background:"#388834",edge:"#388834",outline:"#FFFFFF",texture:"none"}),game.dsa5.apps.DiceSoNiceCustomization.initConfigs(),de.onConnect()}))}(),function actor(){function checkIniChange(t){if(game.combat&&t.changes.some((function(t){return/(system\.status\.initiative|system\.characteristics.mu|system\.characteristics\.ge)/.test(t.key)}))){var r=t.parent.id,a=game.combat.combatants.find((function(t){return t.actor.id==r}));a&&a.recalcInitiative()}}Hooks.on("preDeleteActiveEffect",(function(t,r,a){if(!r.noHook){var o,i=t.parent;if(i&&"Actor"==i.documentName&&getProperty(t,"flags.dsa5.maintain")){var c=[t._id],u=t.name.replace("("+game.i18n.localize("maintainCost")+")","").trim(),l=i.effects.filter((function(r){return r.name.startsWith(u)&&!r.origin&&r.id!=t._id})),p=game.i18n.format("DIALOG.updateMaintainSpell",{actor:i.name});return l&&(p+="

    ".concat(game.i18n.localize("DIALOG.dependentMaintainEffects"),"

    "),p+=l.map((function(t){return'

    ')})).join("")),new Dialog({title:t.name,content:p,default:"yes",buttons:{Yes:{icon:'',label:game.i18n.localize("HELP.pay"),callback:(o=actor_asyncToGenerator(actor_regeneratorRuntime().mark((function _callee(){var r;return actor_regeneratorRuntime().wrap((function _callee$(a){for(;;)switch(a.prev=a.next){case 0:return a.next=2,i.applyMana(Number(getProperty(t,"flags.dsa5.maintain")),getProperty(t,"flags.dsa5.payType"));case 2:a.sent&&(r={startTime:game.time.worldTime},game.combat&&(r.startRound=game.combat.round,r.startTurn=game.combat.turn),i.updateEmbeddedDocuments("ActiveEffect",[{_id:t._id,duration:r}]));case 4:case"end":return a.stop()}}),_callee)}))),function callback(){return o.apply(this,arguments)})},delete:{icon:'',label:game.i18n.localize("delete"),callback:function callback(t){var r,a=actor_createForOfIteratorHelper(t.find(".effectRemoveSelector:checked"));try{for(a.s();!(r=a.n()).done;){var o=r.value;c.push($(o).val())}}catch(t){a.e(t)}finally{a.f()}i.deleteEmbeddedDocuments("ActiveEffect",c,{noHook:!0})}}}}).render(!0),!1}}})),Hooks.on("updateActor",(function(t,r){!game.user.isGM&&t.limited&&hasProperty(r,"system.merchant.hidePlayer")&&ui.sidebar.render(!0)})),Hooks.on("deleteActiveEffect",(function(r,a){if(t.Z.isActiveGM()&&!a.noHook){var o=r.parent;if(o&&"Actor"==o.documentName){var i=actor_toConsumableArray(r.statuses)[0];if("bloodrush"==i)return o.addCondition("stunned",2,!1,!1),!1;if("dead"==i&&game.combat)return o.markDead(!1),!1;if(me.Z.onEffectRemove(o,r),!1===Hooks.call("deleteActorActiveEffect",o,r))return!1}}})),Hooks.on("dropActorSheetData",(function(t,r,a){var o;switch(null===(o=a.data)||void 0===o?void 0:o.type){case"condition":return t.addCondition(a.data.payload.id,1,!1,!1),!1;case"lookup":return r._handleLookup(a.data),!1;case"fullpack":return r._addFullPack(a.data),!1}})),Hooks.on("createActiveEffect",(function(a,o,i){t.Z.isActiveGM()&&(checkIniChange(a),r(a))})),Hooks.on("deleteActiveEffect",(function(r,a,o){t.Z.isActiveGM()&&checkIniChange(r)})),Hooks.on("updateActiveEffect",(function(r,a,i){t.Z.isActiveGM()&&(checkIniChange(r),o(r))}));var r=function(){var t=actor_asyncToGenerator(actor_regeneratorRuntime().mark((function _callee2(t){var r,a;return actor_regeneratorRuntime().wrap((function _callee2$(i){for(;;)switch(i.prev=i.next){case 0:if(r=t.parent){i.next=3;break}return i.abrupt("return");case 3:return i.next=5,o(t,{},r);case 5:if("dead"!=(a=actor_toConsumableArray(t.statuses)[0])||!game.combat){i.next=11;break}return i.next=9,r.markDead(!0);case 9:i.next=14;break;case 11:if("unconscious"!=a){i.next=14;break}return i.next=14,r.addCondition("prone");case 14:case"end":return i.stop()}}),_callee2)})));return function createEffects(r){return t.apply(this,arguments)}}(),o=function(){var r=actor_asyncToGenerator(actor_regeneratorRuntime().mark((function _callee3(r){var o,i,c,u,l,p,d,h,m,y,g=arguments;return actor_regeneratorRuntime().wrap((function _callee3$(v){for(;;)switch(v.prev=v.next){case 0:if(o=g.length>1&&void 0!==g[1]?g[1]:{},(i=g.length>2?g[2]:void 0)||(i=r.parent),i&&"Actor"==i.documentName){v.next=5;break}return v.abrupt("return");case 5:c=/^system\.condition\./,u=actor_createForOfIteratorHelper(r.changes||[]);try{for(u.s();!(l=u.n()).done;)p=l.value,c.test(p.key)&&2==p.mode&&(o[p.key.split(".")[2]]=Number(p.value))}catch(t){u.e(t)}finally{u.f()}d=0,h=Object.keys(o);case 9:if(!(d=4)){v.next=32;break}if("inpain"!=m){v.next=17;break}return v.next=15,i.initResistPainRoll(r);case 15:v.next=32;break;case 17:if(!["encumbered","stunned","feared","confused","trance"].includes(m)){v.next=22;break}return v.next=20,i.addCondition("incapacitated");case 20:v.next=32;break;case 22:if("paralysed"!=m){v.next=27;break}return v.next=25,i.addCondition("rooted");case 25:v.next=32;break;case 27:if(!["drunken","exhaustion"].includes(m)){v.next=32;break}return v.next=30,i.addCondition("stunned");case 30:return v.next=32,i.removeCondition(m);case 32:if(!((Number(o.inpain)||0)>0&&!i.hasCondition("bloodrush")&&i.system.condition.inpain>0&&a.Z.hasVantage(i,game.i18n.localize("LocalizedIDs.frenzy")))){v.next=37;break}return v.next=35,i.addCondition("bloodrush");case 35:y=t.Z.replaceConditions("".concat(game.i18n.format("CHATNOTIFICATION.gainsBloodrush",{character:""+i.name+""}))),ChatMessage.create(t.Z.chatDataSetup(y));case 37:d++,v.next=9;break;case 40:case"end":return v.stop()}}),_callee3)})));return function countableDependentEffects(t){return r.apply(this,arguments)}}(),i=function(){var t=actor_asyncToGenerator(actor_regeneratorRuntime().mark((function _callee4(t,r){return actor_regeneratorRuntime().wrap((function _callee4$(a){for(;;)switch(a.prev=a.next){case 0:(game.dsa5.apps.AskForNameDialog||ge).getDialog(t,r);case 2:case"end":return a.stop()}}),_callee4)})));return function askForName(r,a){return t.apply(this,arguments)}}(),c=function(){var r=actor_asyncToGenerator(actor_regeneratorRuntime().mark((function _callee5(r){var a,o,i,c,u,l,p,d,h,m,g,v,_,b,k,w,x,S,T,A;return actor_regeneratorRuntime().wrap((function _callee5$(O){for(;;)switch(O.prev=O.next){case 0:if(t.Z.isActiveGM()){O.next=2;break}return O.abrupt("return");case 2:if(!game.settings.get("dsa5","randomWeaponSelection")||"character"==r.actor.type){O.next=70;break}a=[],o=[],i=[],c=actor_createForOfIteratorHelper(r.actor.items);try{for(c.s();!(u=c.n()).done;)"meleeweapon"==(l=u.value).type&&l.system.worn.value?y.Z.isShield(l)?o.push(l):a.push(l):"rangeweapon"==l.type&&l.system.worn.value&&i.push(l)}catch(t){c.e(t)}finally{c.f()}if(p=[],!a.length){O.next=49;break}d=a[Math.floor(Math.random()*a.length)],h=d._id,!y.Z.regex2h.test(d.name)&&o.length&&(m=o[Math.floor(Math.random()*o.length)]._id),g=actor_createForOfIteratorHelper(a),O.prev=14,g.s();case 16:if((v=g.n()).done){O.next=23;break}if((_=v.value)._id!=h){O.next=20;break}return O.abrupt("continue",21);case 20:p.push({_id:_._id,system:{worn:{value:!1}}});case 21:O.next=16;break;case 23:O.next=28;break;case 25:O.prev=25,O.t0=O.catch(14),g.e(O.t0);case 28:return O.prev=28,g.f(),O.finish(28);case 31:b=actor_createForOfIteratorHelper(o),O.prev=32,b.s();case 34:if((k=b.n()).done){O.next=41;break}if((w=k.value)._id!=m){O.next=38;break}return O.abrupt("continue",39);case 38:p.push({_id:w._id,system:{worn:{value:!1}}});case 39:O.next=34;break;case 41:O.next=46;break;case 43:O.prev=43,O.t1=O.catch(32),b.e(O.t1);case 46:return O.prev=46,b.f(),O.finish(46);case 49:if(!i.length){O.next=69;break}x=i[Math.floor(Math.random()*i.length)]._id,S=actor_createForOfIteratorHelper(i),O.prev=52,S.s();case 54:if((T=S.n()).done){O.next=61;break}if((A=T.value)._id!=x){O.next=58;break}return O.abrupt("continue",59);case 58:p.push({_id:A._id,system:{worn:{value:!1}}});case 59:O.next=54;break;case 61:O.next=66;break;case 63:O.prev=63,O.t2=O.catch(52),S.e(O.t2);case 66:return O.prev=66,S.f(),O.finish(66);case 69:p.length&&r.actor.updateEmbeddedDocuments("Item",p);case 70:case"end":return O.stop()}}),_callee5,null,[[14,25,28,31],[32,43,46,49],[52,63,66,69]])})));return function randomWeaponSelection(t){return r.apply(this,arguments)}}(),u=function(){var r=actor_asyncToGenerator(actor_regeneratorRuntime().mark((function _callee6(r,a){var o,c,u,l,p,d,h,m,y;return actor_regeneratorRuntime().wrap((function _callee6$(g){for(;;)switch(g.prev=g.next){case 0:if(t.Z.isActiveGM()){g.next=2;break}return g.abrupt("return");case 2:if(!(o=r.actor).hasPlayerOwner){g.next=5;break}return g.abrupt("return");case 5:if(0!=(c=Number(game.settings.get("dsa5","obfuscateTokenNames")))&&"loot"!=getProperty(o,"merchant.merchantType")){g.next=8;break}return g.abrupt("return");case 8:if(u=canvas.scene.tokens.filter((function(t){return t.actor&&t.actor.id===o.id})),l=game.i18n.localize("unknown"),![2,4].includes(c)){g.next=16;break}if(r.id||r._id){g.next=14;break}return g.abrupt("return");case 14:return i(r,c),g.abrupt("return");case 16:if(u.length>0&&c<3){p=u.length,d=actor_createForOfIteratorHelper(u);try{for(d.s();!(h=d.n()).done;)m=h.value,(y=m.name.match(/\d+$/))&&Number(y[0])>p&&(p=Number(y[0]))}catch(t){d.e(t)}finally{d.f()}l="".concat(u[0].name.replace(/ \d{1,}$/,"")," ").concat(p+1)}a.name=l;case 18:case"end":return g.stop()}}),_callee6)})));return function obfuscateName(t,a){return r.apply(this,arguments)}}();Hooks.on("updateToken",(function(t,r,a){b.Z.updateTokenHook(t,r,a)})),Hooks.on("deleteToken",(function(t){b.Z.deleteTokenHook(t),ye.hide(t)})),Hooks.on("preCreateToken",(function(r,a,o,i){var c=r.actor;if(c){var l={};"loot"==getProperty(c,"system.merchant.merchantType")?mergeObject(l,{displayBars:0}):getProperty(c,"system.config.autoBar")&&(mergeObject(l,{bar1:{attribute:"status.wounds"}}),c.system.isMage?mergeObject(l,{bar2:{attribute:"status.astralenergy"}}):c.system.isPriest?mergeObject(l,{bar2:{attribute:"status.karmaenergy"}}):mergeObject(l,{bar2:{attribute:"tbd"}})),getProperty(c,"system.config.autoSize")&&t.Z.calcTokenSize(c,l),u(r,l),r.updateSource(l)}})),Hooks.on("createToken",(function(t,r,a){r.noHook||(u(t,{}),c(t),b.Z.createTokenHook(t,r,a))})),Hooks.on("hoverToken",(function(t,r){game.settings.get("dsa5","showWeaponsOnHover")&&(r?ye.show(t):ye.hide(t))}))}(),function macro_support(){Hooks.on("hotbarDrop",(function(t,r,a){if("dodge"==r.mod){var o={name:game.i18n.localize(r.mod),img:"systems/dsa5/icons/categories/Dodge.webp"};return createHotBarMacro(game.user.isGM||null==r.actorId?'game.dsa5.macro.charMacro("'.concat(r.mod,'")'):'game.dsa5.macro.charMacroById("'.concat(r.mod,'", "').concat(r.actorId,'")'),o.name,o.img,a)}if("attackWeaponless"==r.mod||"parryWeaponless"==r.mod){var i={name:game.i18n.localize(r.mod),img:"systems/dsa5/icons/categories/attack_weaponless.webp"};return createHotBarMacro(game.user.isGM||null==r.actorId?'game.dsa5.macro.weaponLessMacro("'.concat(r.mod,'")'):'game.dsa5.macro.weaponLessMacroId("'.concat(r.mod,'", "').concat(r.actorId,'")'),i.name,i.img,a)}if("Item"==r.type){var c=fromUuidSync(r.uuid);if(!["ritual","ceremony","meleeweapon","rangeweapon","skill","combatskill","spell","liturgy","char","trait"].includes(c.type))return;if(!("meleeweapon"!=c.type&&"combatskill"!=c.type||["attack","parry"].includes(r.mod)))return;if(("rangeweapon"==c.type||"trait"==c.type)&&!["attack"].includes(r.mod))return;var u='{mod: "'.concat(r.mod,'"}');return createHotBarMacro(game.user.isGM||null==r.actorId?'game.dsa5.macro.itemMacro("'.concat(c.name,'", "').concat(c.type,'", ').concat(u,");"):'game.dsa5.macro.itemMacroById("'.concat(r.actorId,'", "').concat(c.name,'", "').concat(c.type,'", ').concat(u,")"),null==r.mod?c.name:"".concat(c.name," - ").concat(game.i18n.localize("CHAR."+r.mod.toUpperCase())),c.img,a)}if("Actor"==r.type||"JournalEntry"==r.type){var l=fromUuidSync(r.uuid);return createHotBarMacro("(await fromUuid('".concat(r.uuid,"')).sheet.render(true)"),l.name,l.img,a)}}))}(),chatlog(),function ready(){Hooks.on("ready",ready_asyncToGenerator(ready_regeneratorRuntime().mark((function _callee(){var a;return ready_regeneratorRuntime().wrap((function _callee$(i){for(;;)switch(i.prev=i.next){case 0:if(game.socket.on("system.dsa5",(function(t){if("hideDeletedSheet"===t.type){var r=t.payload.target.token?game.actors.tokens[t.payload.target.token]:game.actors.get(t.payload.target.actor);we.hideDeletedSheet(r)}})),game.user.isGM&&game.socket.on("system.dsa5",(function(a){var o,i,c;if(t.Z.isActiveGM())switch(a.type){case"updateKeepField":r.Z.allowedforeignfields.includes(a.payload.field)&&game.actors.get(a.payload.actorId).update((o={},i=a.payload.field,c=a.payload.updateData,i in o?Object.defineProperty(o,i,{value:c,enumerable:!0,configurable:!0,writable:!0}):o[i]=c,o));break;case"target":var u=game.scenes.get(a.payload.scene);new Token(u.getEmbeddedDocument("Token",a.payload.target)).actor.update({"flags.oppose":a.payload.opposeFlag});break;case"addEffect":me.Z.applyEffect(a.payload.id,a.payload.mode,a.payload.actors);break;case"updateMsg":game.messages.get(a.payload.id).update(a.payload.updateData);break;case"deleteMsg":game.messages.get(a.payload.id).delete();break;case"showDamage":N.Z.showDamage(game.messages.get(a.payload.id),a.payload.hide);break;case"hideQueryButton":N.Z.hideReactionButton(a.payload.id);break;case"updateGroupCheck":Oe.Z.rerenderGC(game.messages.get(a.payload.messageId),a.payload.data);break;case"updateAttackMessage":game.messages.get(a.payload.messageId).update({"flags.data.unopposedStartMessage":a.payload.startMessageId});break;case"clearCombat":game.combat&&game.combat.nextRound();break;case"clearOpposed":N.Z.clearOpposed(game.actors.get(a.payload.actorId));break;case"updateDefenseCount":game.combat&&game.combat.updateDefenseCount(a.payload.speaker);break;case"trade":var l=a.payload.source.token?game.actors.tokens[a.payload.source.token]:game.actors.get(a.payload.source.actor),p=a.payload.target.token?game.actors.tokens[a.payload.target.token]:game.actors.get(a.payload.target.actor);we.finishTransaction(l,p,a.payload.price,a.payload.itemId,a.payload.buy,a.payload.amount);break;case"playWhisperSound":a.payload.whisper.includes(game.user.id)&&AudioHelper.play({src:a.payload.soundPath,volume:.8,loop:!1},!1);break;case"socketedConditionAddActor":fromUuid(a.payload.id).then((function(t){new g.Z(t).socketedConditionAddActor(a.payload.actors.map((function(t){return game.actors.get(t)})),a.payload.data)}));break;case"socketedConditionAdd":fromUuid(a.payload.id).then((function(t){new g.Z(t).socketedConditionAdd(a.payload.targets,a.payload.data)}));break;case"socketedRemoveCondition":fromUuid(a.payload.id).then((function(t){new g.Z(t).socketedRemoveCondition(a.payload.targets,a.payload.coreId)}));break;case"socketedActorTransformation":fromUuid(a.payload.id).then((function(t){new g.Z(t).socketedActorTransformation(a.payload.targets,a.payload.update)}));break;case"itemDrop":var h=a.payload.sourceActorId?game.actors.get(a.payload.sourceActorId):void 0;fromUuid(a.payload.itemId).then((function(t){Pe(h,t,a.payload.data,a.payload.amount)}));break;case"finalizeFoodContribution":case"hideDeletedSheet":case"finalizeidentification":case"updateHits":case"hideResistButton":break;case"reduceGroupSchip":d.Z.reduceGroupSchip();break;case"summonCreature":Te.createConjuration(a.payload);break;default:console.warn("Unhandled socket data type ".concat(a.type))}})),i.t1=t.Z.moduleEnabled("vtta-tokenizer"),!i.t1){i.next=7;break}return i.next=6,game.settings.get("dsa5","tokenizerSetup");case 6:i.t1=!i.sent;case 7:if(i.t0=i.t1,!i.t0){i.next=10;break}i.t0=game.user.isGM;case 10:if(!i.t0){i.next=19;break}return i.next=13,game.settings.set("vtta-tokenizer","default-frame-pc","[data] systems/dsa5/icons/backgrounds/token_green.webp");case 13:return i.next=15,game.settings.set("vtta-tokenizer","default-frame-npc","[data] systems/dsa5/icons/backgrounds/token_black.webp");case 15:return i.next=17,game.settings.set("vtta-tokenizer","default-frame-neutral","[data] systems/dsa5/icons/backgrounds/token_blue.webp");case 17:return i.next=19,game.settings.set("dsa5","tokenizerSetup",!0);case 19:if(i.t3=t.Z.moduleEnabled("dice-so-nice"),!i.t3){i.next=24;break}return i.next=23,game.settings.get("dsa5","diceSetup");case 23:i.t3=!i.sent;case 24:if(i.t2=i.t3,!i.t2){i.next=27;break}i.t2=game.user.isGM;case 27:if(!i.t2){i.next=32;break}return i.next=30,game.settings.set("dice-so-nice","immediatelyDisplayChatMessages",!0);case 30:return i.next=32,game.settings.set("dsa5","diceSetup",!0);case 32:return i.next=34,_e.firstTimeMessage();case 34:o.Z.setupSubClasses(),Le.showOneMessage(),game.settings.get("dsa5","disableTokenhotbar")||x.registerTokenHotbar(),De(),ze.connectHooks(),a=function hook(t){"settings"==t.tabName&&(Ne.Z.travelAgency(),Hooks.off("changeSidebarTab",hook))},Hooks.on("changeSidebarTab",a),(0,Re.v)(),(0,He.Y)();case 43:case"end":return i.stop()}}),_callee)}))))}(),function chat_context(){var r=function fateAvailable(r,a){return t.Z.fateAvailable(r,a)},a=function canHurt(r){var a,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"damage.value",i=game.messages.get(r.attr("data-message-id")).flags.opposeData,c=!!i&&(null===(a=t.Z.getSpeaker(i.speakerDefend))||void 0===a?void 0:a.isOwner);return((game.user.isGM||c)&&r.find(".opposed-card").length||r.find(".dice-roll").length)&&(getProperty(i,o)||0)>0},o=function canHurtSP(t){return a(t,"damage.sp")},i=function canCostMana(t){var r=game.messages.get(t.attr("data-message-id"));return!(!r.speaker.actor||!r.flags.data||!game.actors.get(r.speaker.actor).isOwner&&!game.user.isGM)&&(["liturgy","ceremony","spell","ritual","magicalsign"].includes(r.flags.data.preData.source.type)||getProperty(r.flags.data.preData,"calculatedSpellModifiers.costsMana"))},c=function canUnhideData(t){if(game.user.isGM&&game.settings.get("dsa5","hideOpposedDamage")){var r=game.messages.get(t.attr("data-message-id"));return"hideData"in r.flags&&r.flags.hideData}return!1},u=function canHideData(t){if(game.user.isGM&&game.settings.get("dsa5","hideOpposedDamage")){var r=game.messages.get(t.attr("data-message-id"));return"hideData"in r.flags&&!r.flags.hideData}return!1},l=function canImproveRoll(t){var a=arguments.length>1&&void 0!==arguments[1]&&arguments[1],o=game.messages.get(t.attr("data-message-id"));if(o.speaker.actor&&o.flags.data&&o.flags.data.postData.successLevel>-2){var i=game.actors.get(o.speaker.actor);if(i.isOwner&&r(i,a)){var c=o.flags.data.preData.source.type,u=o.flags.data.preData.mode||"";["skill","spell","liturgy","ritual","ceremony"].includes(c)&&(c="char");var l=game.i18n.localize("SCHIPSKILLS.".concat(c).concat(u));return!o.flags.data.fateImproved&&i.items.getName(l)}}return!1},p=function canImproveRollGroup(t){return l(t,!0)},h=function canIncreaseQS(t){var a=arguments.length>1&&void 0!==arguments[1]&&arguments[1],o=game.messages.get(t.attr("data-message-id"));if(o.speaker.actor&&o.flags.data){var i=game.actors.get(o.speaker.actor);if(i.isOwner&&r(i,a)&&!o.flags.data.fatePointAddQSUsed)return o.flags.data.postData.successLevel>0&&null!=o.flags.data.postData.qualityStep}return!1},m=function canIncreaseQSGroup(t){return h(t,!0)},y=function isTalented(t){var r=game.messages.get(t.attr("data-message-id"));if(r.speaker.actor&&r.flags.data){var a=game.actors.get(r.speaker.actor);if(a.isOwner)return null!=a.items.find((function(t){return t.name=="".concat(game.i18n.localize("LocalizedIDs.aptitude")," (").concat(r.flags.data.preData.source.name,")")}))&&!r.flags.data.talentedRerollUsed}return!1},g=function canRerollDamage(t){var a=arguments.length>1&&void 0!==arguments[1]&&arguments[1],o=game.messages.get(t.attr("data-message-id"));if(o.speaker.actor&&o.flags.data){var i=game.actors.get(o.speaker.actor);if(i.isOwner&&r(i,a))return null!=o.flags.data.postData.damageRoll&&!o.flags.data.fatePointDamageRerollUsed}return!1},v=function canRerollDamageGroup(t){return g(t,!0)},_=function canReroll(t){var a=arguments.length>1&&void 0!==arguments[1]&&arguments[1],o=game.messages.get(t.attr("data-message-id"));if(o.speaker.actor&&o.flags.data){var i=game.actors.get(o.speaker.actor);if(i.isOwner&&r(i,a))return!(o.flags.data.fatePointRerollUsed||"regenerate"==o.flags.data.postData.rollType)}return!1},b=function canRerollGroup(t){return _(t,!0)},k=function canHeal(t){var r=game.messages.get(t.attr("data-message-id"));return!!(r.speaker.actor&&r.flags.data&&game.actors.get(r.speaker.actor).isOwner&&["LeP","KaP","AsP"].some((function(t){return null!=getProperty(r.flags,"data.postData.".concat(t))})))&&!r.flags.data.healApplied},w=function showHideData(t){if(game.user.isGM){var r=game.messages.get(t.attr("data-message-id"));if("hideData"in r.flags){var a=!r.flags.hideData,o=$(r.content);o.find(".hideAnchor")[a?"addClass":"removeClass"]("hideData"),o=$("
    ").append(o),r.update({content:o.html(),"flags.hideData":a})}}},x=function canApplyDefaultRolls(t){var r=game.messages.get(t.data("messageId"));return!(!r||!canvas.tokens)&&r.isRoll&&r.isContentVisible&&canvas.tokens.controlled.length&&t.find(".dice-roll").length},S=function useFate(t,r){var a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,o=game.messages.get(t.attr("data-message-id"));game.actors.get(o.speaker.actor).useFateOnRoll(o,r,a)},T=function(){var r=chat_context_asyncToGenerator(chat_context_regeneratorRuntime().mark((function _callee(r,a){var o,i,c,u,l,p,d=arguments;return chat_context_regeneratorRuntime().wrap((function _callee$(h){for(;;)switch(h.prev=h.next){case 0:if(o=d.length>2&&void 0!==d[2]?d[2]:1,i=game.messages.get(r.attr("data-message-id")),c=i.flags.opposeData,u=null==c?void 0:c.speakerDefend,(l=t.Z.getSpeaker(u)).isOwner){h.next=7;break}return h.abrupt("return",ui.notifications.error(game.i18n.localize("DSAError.DamagePermission")));case 7:return h.next=9,l.applyDamage(c.damage[a]*o);case 9:if(p={"flags.data.damageApplied":!0,content:i.content.replace(/hideAnchor">/,'hideAnchor">'))},!game.user.isGM){h.next=15;break}return h.next=13,i.update(p);case 13:h.next=16;break;case 15:game.socket.emit("system.dsa5",{type:"updateMsg",payload:{id:r.attr("data-message-id"),updateData:p}});case 16:case"end":return h.stop()}}),_callee)})));return function applyDamage(t,a){return r.apply(this,arguments)}}(),A=function applyChatCardDamage(t,r){var a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,o=game.messages.get(t.data("messageId")).rolls[0];return Promise.all(canvas.tokens.controlled.map((function(t){var i=t.actor,c=Math.round(("sp"!=r?o.total-d.Z.armorValue(i).armor:o.total)*a);return i.applyDamage(Math.max(0,c))})))},O=function(){var r=chat_context_asyncToGenerator(chat_context_regeneratorRuntime().mark((function _callee2(r){var a,o,i,c,u,l,p,d,h,m,y,g,v,_,b;return chat_context_regeneratorRuntime().wrap((function _callee2$(k){for(;;)switch(k.prev=k.next){case 0:if(a=game.messages.get(r.attr("data-message-id")),o=a.flags.data,(i=t.Z.getSpeaker(a.speaker)).isOwner){k.next=5;break}return k.abrupt("return",ui.notifications.error(game.i18n.localize("DSAError.DamagePermission")));case 5:return c=o.preData.calculatedSpellModifiers.maintainCost.trim(),u=["ritual","spell"].includes(o.preData.source.type)||getProperty(o.preData.calculatedSpellModifiers,"costsMana")?"AsP":"KaP",k.next=9,i.applyMana(o.preData.calculatedSpellModifiers.finalcost,u);case 9:if(l=k.sent,!(c&&0!=c&&l&&o.postData.successLevel>0)){k.next=36;break}p=o.preData.source.name,k.prev=12,d=c.match(/^\d{1,3}/)[0],h=(h=c.replace(/^\d{1,3}/,"").match(/\d{1,3}/))&&Number(h[0])||1,m={name:"".concat(p," (").concat(game.i18n.localize("maintainCost"),")"),icon:"icons/svg/daze.svg",flags:{dsa5:{value:null,editable:!0,description:c,maintain:d,payType:u,custom:!0}},changes:[],duration:{}},y=[{regEx:new RegExp(game.i18n.localize("DSAREGEXmaintain.combatRounds"),"gi"),seconds:5},{regEx:new RegExp(game.i18n.localize("DSAREGEXmaintain.minutes"),"gi"),seconds:60},{regEx:new RegExp(game.i18n.localize("DSAREGEXmaintain.hours"),"gi"),seconds:3600},{regEx:new RegExp(game.i18n.localize("DSAREGEXmaintain.days"),"gi"),seconds:86400},{regEx:new RegExp(game.i18n.localize("DSAREGEXmaintain.seconds"),"gi"),seconds:1},{regEx:new RegExp(game.i18n.localize("DSAREGEXmaintain.weeks"),"gi"),seconds:604800},{regEx:new RegExp(game.i18n.localize("DSAREGEXmaintain.months"),"gi"),seconds:2592e3},{regEx:new RegExp(game.i18n.localize("DSAREGEXmaintain.years"),"gi"),seconds:3024e4}],g=0,v=y;case 19:if(!(g/,'')});case 38:case"end":return k.stop()}}),_callee2,null,[[12,33]])})));return function payMana(t){return r.apply(this,arguments)}}();Hooks.on("getChatLogEntryContext",(function(r,d){var P,E;d.push({name:game.i18n.localize("CHATCONTEXT.hideData"),icon:'',condition:u,callback:function callback(t){w(t)}},{name:game.i18n.localize("CHATCONTEXT.showData"),icon:'',condition:c,callback:function callback(t){w(t)}},{name:game.i18n.localize("regenerate"),icon:'',condition:k,callback:(E=chat_context_asyncToGenerator(chat_context_regeneratorRuntime().mark((function _callee3(r){var a,o;return chat_context_regeneratorRuntime().wrap((function _callee3$(i){for(;;)switch(i.prev=i.next){case 0:return i.next=2,game.messages.get(r.attr("data-message-id"));case 2:if(a=i.sent,(o=t.Z.getSpeaker(a.speaker)).isOwner){i.next=6;break}return i.abrupt("return",ui.notifications.error(game.i18n.localize("DSAError.DamagePermission")));case 6:return i.next=8,a.update({"flags.data.healApplied":!0,content:a.content.replace(/<\/div>$/,'
    ')});case 8:return i.next=10,o.applyRegeneration(a.flags.data.postData.LeP,a.flags.data.postData.AsP,a.flags.data.postData.KaP);case 10:case"end":return i.stop()}}),_callee3)}))),function callback(t){return E.apply(this,arguments)})},{name:game.i18n.localize("CHATCONTEXT.ApplyMana"),icon:'',condition:i,callback:(P=chat_context_asyncToGenerator(chat_context_regeneratorRuntime().mark((function _callee4(t){return chat_context_regeneratorRuntime().wrap((function _callee4$(r){for(;;)switch(r.prev=r.next){case 0:O(t);case 1:case"end":return r.stop()}}),_callee4)}))),function callback(t){return P.apply(this,arguments)})},{name:game.i18n.localize("CHATCONTEXT.ApplyDamage"),icon:'',condition:a,callback:function callback(t){T(t,"value")}},{name:game.i18n.localize("CHATCONTEXT.ApplyDamageSP"),icon:'',condition:o,callback:function callback(t){T(t,"sp")}},{name:game.i18n.localize("CHATCONTEXT.ApplyDamage"),icon:'',condition:x,callback:function callback(t){A(t,"value")}},{name:game.i18n.localize("CHATCONTEXT.ApplyDamageSP"),icon:'',condition:x,callback:function callback(t){A(t,"sp")}},{name:game.i18n.localize("CHATCONTEXT.Reroll"),icon:'',condition:_,callback:function callback(t){S(t,"reroll")}},{name:game.i18n.localize("CHATCONTEXT.RerollGroup"),icon:'',condition:b,callback:function callback(t){S(t,"reroll",1)}},{name:game.i18n.localize("CHATCONTEXT.talentedReroll"),icon:'',condition:y,callback:function callback(t){S(t,"isTalented")}},{name:game.i18n.localize("CHATCONTEXT.AddQS"),icon:'',condition:h,callback:function callback(t){S(t,"addQS")}},{name:game.i18n.localize("CHATCONTEXT.AddQSGroup"),icon:'',condition:m,callback:function callback(t){S(t,"addQS",1)}},{name:game.i18n.localize("CHATCONTEXT.rerollDamage"),icon:'',condition:g,callback:function callback(t){S(t,"rerollDamage")}},{name:game.i18n.localize("CHATCONTEXT.rerollDamageGroup"),icon:'',condition:v,callback:function callback(t){S(t,"rerollDamage",1)}},{name:game.i18n.localize("CHATCONTEXT.improveFate"),icon:'',condition:l,callback:function callback(t){S(t,"Improve")}},{name:game.i18n.localize("CHATCONTEXT.improveFateGroup"),icon:'',condition:p,callback:function callback(t){S(t,"Improve",1)}}),game.settings.get("dsa5","doubleDamageOptions")&&d.push({name:game.i18n.localize("CHATCONTEXT.ApplyDamage")+" x2",icon:'',condition:a,callback:function callback(t){T(t,"value",2)}},{name:game.i18n.localize("CHATCONTEXT.ApplyDamageSP")+" x2",icon:'',condition:o,callback:function callback(t){T(t,"sp",2)}},{name:game.i18n.localize("CHATCONTEXT.ApplyDamage")+" x2",icon:'',condition:x,callback:function callback(t){A(t,"value",2)}},{name:game.i18n.localize("CHATCONTEXT.ApplyDamageSP")+" x2",icon:'',condition:x,callback:function callback(t){A(t,"sp",2)}})}))}(),statuseffect(),function sidebar(){Hooks.on("renderSettings",(function(t,r,a){var o=$('"));o.click((function(){window.open("https://github.com/Plushtoast/dsa5-foundryVTT/issues","_blank")})),r.find("#settings-documentation").append(o),(o=$('"))).click((function(){window.open("https://github.com/Plushtoast/dsa5-foundryVTT/wiki","_blank")})),r.find("#settings-documentation").append(o),(o=$('')).click((function(){window.open(game.i18n.localize("fshopLink"),"_blank")})),r.find("#settings-documentation").append(o);var i=game.system.title.split("/")["de"==game.i18n.lang?0:1],c=r.find("#game-details .system .system-info").html();r.find("#game-details .system").html(''.concat(i,'').concat(c,""))})),Hooks.on("renderCompendiumDirectory",(function(t,r,a){var o=$('"));r.find(".header-actions").append(o),o.click((function(){game.dsa5.itemLibrary.render(!0)})),r.find('li[data-pack="dsa5.money"]').remove()})),Hooks.once("renderCompendiumDirectory",(function(t,r,a){var o,i="de"==game.i18n.lang?"en":"de",c=sidebar_createForOfIteratorHelper(game.packs.filter((function(t){return getProperty(t.metadata,"flags.dsalang")==i})));try{var u=function _loop(){var t=o.value,a="".concat(t.metadata.packageName,".").concat(t.metadata.name);game.packs.delete(a),game.data.packs=game.data.packs.filter((function(t){return t.id!=a})),r.find('li[data-pack="'.concat(a,'"]')).remove()};for(c.s();!(o=c.n()).done;)u()}catch(t){c.e(t)}finally{c.f()}})),Hooks.on("renderActorDirectory",(function(t,r,a){if(!game.user.isGM){var o,i=sidebar_createForOfIteratorHelper(t.documents.filter((function(t){return t.isMerchant()&&getProperty(t,"system.merchant.hidePlayer")})));try{for(i.s();!(o=i.n()).done;){var c=o.value;r.find('[data-document-id="'.concat(c.id,'"]')).remove()}}catch(t){i.e(t)}finally{i.f()}}}))}(),function journal(){Hooks.on("renderJournalSheet",(function(t,r,a){r.find(".close").attr("data-tooltip","SHEET.Close"),r.find(".entry-image").attr("data-tooltip","SHEET.imageView"),r.find(".entry-text").attr("data-tooltip","SHEET.textView"),r.find(".share-image").attr("data-tooltip","SHEET.showToPlayers"),r.find(".import").attr("data-tooltip","SHEET.import"),r.find(".panMapNote").attr("data-tooltip","SHEET.panMapNote"),r.find(".increaseFontSize").attr("data-tooltip","SHEET.increaseFontSize")})),Hooks.on("renderJournalPageSheet",(function(t,r,a){_.Z.bindRollCommands(r),u.Z.bindButtons(r),r.find("img").mousedown((function(r){2==r.button&&game.dsa5.apps.DSA5_Utility.showArtwork({name:t.name,uuid:"",img:$(r.currentTarget).attr("src")})})),bindImgToCanvasDragStart(r)})),Hooks.on("getJournalSheetHeaderButtons",(function(t,r){var a,o;r.unshift({class:"increaseFontSize",icon:"fas fa-arrows-up-down",onclick:(a=journal_asyncToGenerator(journal_regeneratorRuntime().mark((function _callee(){return journal_regeneratorRuntime().wrap((function _callee$(r){for(;;)switch(r.prev=r.next){case 0:return r.abrupt("return",increaseFontSize($(t._element).find(".journal-page-content")));case 1:case"end":return r.stop()}}),_callee)}))),function onclick(){return a.apply(this,arguments)})}),(t.document.sceneNote||t.document.pages.some((function(t){return t.sceneNote})))&&r.unshift({class:"panMapNote",icon:"fas fa-map-pin",onclick:(o=journal_asyncToGenerator(journal_regeneratorRuntime().mark((function _callee2(){var r,a;return journal_regeneratorRuntime().wrap((function _callee2$(o){for(;;)switch(o.prev=o.next){case 0:if(r=t._getCurrentPage(),!(a=Array.from(t.document.pages))[r].sceneNote){o.next=6;break}doc=a[r],o.next=13;break;case 6:if(!t.document.sceneNote){o.next=10;break}doc=t.document,o.next=13;break;case 10:if(doc=a.find((function(t){return t.sceneNote})),doc){o.next=13;break}return o.abrupt("return");case 13:canvas.notes.panToNote(doc.sceneNote);case 14:case"end":return o.stop()}}),_callee2)}))),function onclick(){return o.apply(this,arguments)})})}))}(),tokenHUD(),Ze.Z(),function scene(){Hooks.on("preCreateScene",(function(t,r,a,o){var i,c;null!==(i=r.grid)&&void 0!==i&&i.units||t.updateSource({grid:{units:game.i18n.localize("gridUnits")}}),!a.dsaInit&&null!==(c=r.notes)&&void 0!==c&&c.some((function(t){return getProperty(t,"flags.dsa5.initName")}))&&ui.notifications.warn(game.i18n.localize("DSAError.mapsViaJournalbrowser"))})),Hooks.on("preCreateActiveEffect",(function(t,r,a,o){if("Actor"==t.parent.documentName){var i={duration:{}};t.duration.startTime||(i.duration.startTime=game.time.worldTime),game.combat?(i.duration.combat=game.combat.id,i.duration.startRound=game.combat.round,i.duration.startTurn=game.combat.turn,!t.duration.rounds&&t.duration.seconds&&(i.duration.rounds=t.duration.seconds/5),t.updateSource(i)):t.updateSource(i)}}))}(),function dsarolls(){Roll.prototype.editRollAtIndex=function(t){var r,a=[],o=dsarolls_createForOfIteratorHelper(t);try{for(o.s();!(r=o.n()).done;){var i,c=r.value,u=c.index,l=c.val,p=0,d=dsarolls_createForOfIteratorHelper(this.terms);try{for(d.s();!(i=d.n()).done;){var h=i.value,m=h instanceof DiceTerm||"DiceTerm"==h.class||h instanceof Die||"Die"==h.class,y=h instanceof OperatorTerm;if(m||h.faces){if(h.results[u-p]){var g=h.results[u-p].result;h.results[u-p].result=l,a.push(g)}m||(h.total=h.results.reduce((function(t,r){return t+r.result}),0)),p+=h.results.length}else y||"OperatorTerm"!=h.class&&!h.operator||(h.total=h.operator)}}catch(t){d.e(t)}finally{d.f()}a.push(0)}}catch(t){o.e(t)}finally{o.f()}return this._total=this._evaluateTotal(),a}}()}()})()})(); \ No newline at end of file +(()=>{"use strict";var __webpack_modules__={369:(t,r,a)=>{a.d(r,{Z:()=>S});var o=a(491),i=a(577),c=a(562),u=a(600),l=a(538),p=a(272),d=a(173),h=a(973),m=a(839),y=a(101),g=a(122),v=a(707),_=a(702),b=a(61),k=a(803),w=a(472),x=a(169);function _typeof(t){return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},_typeof(t)}function ownKeys(t,r){var a=Object.keys(t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);r&&(o=o.filter((function(r){return Object.getOwnPropertyDescriptor(t,r).enumerable}))),a.push.apply(a,o)}return a}function _objectSpread(t){for(var r=1;r=0;--o){var i=this.tryEntries[o],c=i.completion;if("root"===i.tryLoc)return handle("end");if(i.tryLoc<=this.prev){var u=a.call(i,"catchLoc"),l=a.call(i,"finallyLoc");if(u&&l){if(this.prev=0;--o){var i=this.tryEntries[o];if(i.tryLoc<=this.prev&&a.call(i,"finallyLoc")&&this.prev=0;--r){var a=this.tryEntries[r];if(a.finallyLoc===t)return this.complete(a.completion,a.afterLoc),resetTryEntry(a),l}},catch:function _catch(t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc===t){var o=a.completion;if("throw"===o.type){var i=o.arg;resetTryEntry(a)}return i}}throw new Error("illegal catch attempt")},delegateYield:function delegateYield(t,r,a){return this.delegate={iterator:values(t),resultName:r,nextLoc:a},"next"===this.method&&(this.arg=void 0),l}},t}function asyncGeneratorStep(t,r,a,o,i,c,u){try{var l=t[c](u),p=l.value}catch(t){return void a(t)}l.done?r(p):Promise.resolve(p).then(o,i)}function _asyncToGenerator(t){return function(){var r=this,a=arguments;return new Promise((function(o,i){var c=t.apply(r,a);function _next(t){asyncGeneratorStep(c,o,i,_next,_throw,"next",t)}function _throw(t){asyncGeneratorStep(c,o,i,_next,_throw,"throw",t)}_next(void 0)}))}}function _createForOfIteratorHelper(t,r){var a="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!a){if(Array.isArray(t)||(a=_unsupportedIterableToArray(t))||r&&t&&"number"==typeof t.length){a&&(t=a);var o=0,i=function F(){};return{s:i,n:function n(){return o>=t.length?{done:!0}:{done:!1,value:t[o++]}},e:function e(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var c,u=!0,l=!1;return{s:function s(){a=a.call(t)},n:function n(){var t=a.next();return u=t.done,t},e:function e(t){l=!0,c=t},f:function f(){try{u||null==a.return||a.return()}finally{if(l)throw c}}}}function _unsupportedIterableToArray(t,r){if(t){if("string"==typeof t)return _arrayLikeToArray(t,r);var a=Object.prototype.toString.call(t).slice(8,-1);return"Object"===a&&t.constructor&&(a=t.constructor.name),"Map"===a||"Set"===a?Array.from(t):"Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a)?_arrayLikeToArray(t,r):void 0}}function _arrayLikeToArray(t,r){(null==r||r>t.length)&&(r=t.length);for(var a=0,o=new Array(r);ar.reduce((function(t,r){return t+Number(r.system.encumbrance.value)}),0))for(var o=0,i=[game.i18n.localize("CHARAbbrev.GS"),game.i18n.localize("CHARAbbrev.INI")];o0&&(r+=p.Z.vantageStep(this,game.i18n.localize("LocalizedIDs.sensitiveToPain"))+p.Z.vantageStep(this,game.i18n.localize("LocalizedIDs.fragileAnimal"))),r=Math.clamped(r,0,4),t.condition.inpain=r}},{key:"woundPain",value:function woundPain(t){var r=0;t.status.wounds.max>0&&("creature"!=this.type||t.status.wounds.max>=20?(r=Math.floor(4*(1-t.status.wounds.value/t.status.wounds.max)),t.status.wounds.value<=5&&(r=4)):r=Math.floor(5-5*t.status.wounds.value/t.status.wounds.max));return Math.clamped(r,0,4)}},{key:"calcSpeed",value:function calcSpeed(t,r,a){if(a){if(t.status.speed.max=a.system.status.speed.max,!t.status.speed.max){var o=a.system;a.calcSpeed(o,a.hasCondition("fixated"))}t.status.speed.max=a.system.status.speed.max}else{var i;t.status.speed.max=t.status.speed.initial+(t.status.speed.modifier||0)+(t.status.speed.gearmodifier||0),t.status.speed.max=Math.round(Math.max(0,t.status.speed.max-Math.min(4,this.calcEncumbrance(t)))*t.status.speed.multiplier),this.hasCondition("bloodrush")||(t.status.speed.max=Math.max(0,t.status.speed.max-((null===(i=t.condition)||void 0===i?void 0:i.inpain)||0)));var c=this.hasCondition("paralysed");c&&(t.status.speed.max=Math.round(t.status.speed.max*(1-.25*c.flags.dsa5.value))),r||this.hasCondition("rooted")||this.hasCondition("incapacitated")?t.status.speed.max=0:this.hasCondition("prone")&&(t.status.speed.max=Math.min(1,t.status.speed.max)),x.Z.updateRiderSpeed(this,t.status.speed.max)}}},{key:"calcEncumbrance",value:function calcEncumbrance(t){var r;return Math.clamped((null===(r=t.condition)||void 0===r?void 0:r.encumbered)||0,0,4)}},{key:"calcInitiative",value:function calcInitiative(t,r,a){if("character"==this.type||"npc"==this.type?t.status.initiative.value=Math.round((t.characteristics.mu.value+t.characteristics.ge.value)/2)+(t.status.initiative.modifier||0):t.status.initiative.value=t.status.initiative.current+(t.status.initiative.modifier||0),a){if(t.status.initiative.value=a.system.status.initiative.value,!t.status.initiative.value){var o=a.system;a.calcInitiative(o,a.calcEncumbrance(o)),t.status.initiative.value=o.status.initiative.value}}else{t.status.initiative.value+=(t.status.initiative.gearmodifier||0)-Math.min(4,r);var i=Number((.01*t.status.initiative.value).toFixed(2));t.status.initiative.value*=t.status.initiative.multiplier||1,t.status.initiative.value=Math.round(t.status.initiative.value)+i}}},{key:"creatureType",get:function get(){return w.Z.creatureTypeName(this)}},{key:"prepareMerchant",value:(X=_asyncToGenerator(_regeneratorRuntime().mark((function _callee(){var t;return _regeneratorRuntime().wrap((function _callee$(r){for(;;)switch(r.prev=r.next){case 0:if("loot"!=getProperty(this,"system.merchant.merchantType")){r.next=11;break}if(!getProperty(this,"system.merchant.locked")||this.hasCondition("locked")){r.next=6;break}return r.next=4,this.addCondition(Actordsa5.lockedCondition());case 4:r.next=11;break;case 6:if(getProperty(this,"system.merchant.locked")){r.next=11;break}if(!(t=this.effects.find((function(t){return t.statuses.has("locked")})))){r.next=11;break}return r.next=11,this.deleteEmbeddedDocuments("ActiveEffect",[t.id]);case 11:case"end":return r.stop()}}),_callee,this)}))),function prepareMerchant(){return X.apply(this,arguments)})},{key:"applyActiveEffects",value:function applyActiveEffects(){var t,r=this,a={};null!==(t=this.statuses)&&void 0!==t||(this.statuses=new Set);for(var o=new Map,i=0,c=Object.values(CONFIG.specialStatusEffects);i2&&void 0!==l[2]&&l[2],o=!(l.length>3&&void 0!==l[3])||l[3],i=foundry.utils.getProperty(this.system,t),o?(a&&(r=Math.clamped(i.min||0,Number(i.value)+r,i.max)),c=_defineProperty({},"system.".concat(t,".value"),r)):(a&&(r=Number(i)+r),c=_defineProperty({},"system.".concat(t),r)),u=Hooks.call("modifyTokenAttribute",{attribute:t,value:r,isDelta:a,isBar:o},c),p.abrupt("return",!1!==u?this.update(c):this);case 6:case"end":return p.stop()}}),_callee2,this)}))),function modifyTokenAttribute(t,r){return Q.apply(this,arguments)})},{key:"schipshtml",value:function schipshtml(){for(var t=[],r=1;r<=Number(this.system.status.fatePoints.max);r++)t.push({value:r,cssClass:r<=Number(this.system.status.fatePoints.value)?"fullSchip":"emptySchip"});return t}},{key:"prepareItems",value:function prepareItems(t){var r,a,c,u,l,p,d=this,h=this.toObject(!1),m=[],y=[],v=[],b=[],k=[],w=[],S=[],T=[],A=[],O=[],P=Object.fromEntries(Object.keys(i.Z.specialAbilityCategories).map((function(t){return[t,[]]}))),E=Object.fromEntries(Object.keys(i.Z.traitCategories).map((function(t){return[t,[]]}))),C=[],D=[],I=[],R=[],L={hasSpells:this.system.isMage,hasPrayers:this.system.isPriest,liturgy:[],spell:[],ritual:[],ceremony:[],blessing:[],magictrick:[],magicalsign:[]},G={spell:{},ritual:{},ceremony:{},liturgy:{}},M=this.hasPlayerOwner?g.Z.getGroupSchips():[],j=this.schipshtml(),z={meleeweapons:{items:[],show:!1,dataType:"meleeweapon"},rangeweapons:{items:[],show:!1,dataType:"rangeweapon"},armor:{items:[],show:!1,dataType:"armor"},ammunition:{items:[],show:!1,dataType:"ammunition"},plant:{items:[],show:!1,dataType:"plant"},poison:{items:[],show:!1,dataType:"poison"}};for(var N in i.Z.equipmentTypes)z[N]={items:[],show:!1,dataType:N};z.misc.show=!0;var H={coins:[],total:0,show:!0};h.items=h.items.sort((function(t,r){return t.name.localeCompare(r.name)}));var $,Z=h.system.totalArmor||0,W={body:[],social:[],knowledge:[],trade:[],nature:[]},B=new Map,q=_createForOfIteratorHelper(h.items.filter((function(t){return"equipment"==t.type&&"bags"==t.system.equipmentType.value})));try{for(q.s();!($=q.n()).done;){var U=$.value;B.set(U._id,[])}}catch(t){q.e(t)}finally{q.f()}var Y,V=new Map,K=[],J=!1,Q=x.Z.getHorse(this,!0),X=_createForOfIteratorHelper(h.items);try{for(X.s();!(Y=X.n()).done;){var ee=Y.value;try{var te=getProperty(ee,"system.parent_id");if("ammunition"==ee.type&&K.push(Actordsa5._prepareitemStructure(ee)),te&&te!=ee._id&&B.has(te)){B.get(te).push(ee);continue}switch(t.details&&t.details.includes(ee._id)&&(ee.detailed="shown"),ee.system.isArtifact&&(ee.volume=i.Z.traditionArtifacts[ee.system.artifact]||0,ee.volumeFinal=0,R.push(ee)),ee.type){case"skill":W[ee.system.group.value].push(this._perpareItemAdvancementCost(ee));break;case"information":T.push(ee);break;case"aggregatedTest":b.push(ee);break;case"spellextension":G[ee.system.category][ee.system.source]?G[ee.system.category][ee.system.source].push(ee.name):G[ee.system.category][ee.system.source]=[ee.name];break;case"ritual":case"spell":case"liturgy":case"ceremony":L[ee.type].push(Actordsa5.buildSpellChargeProgress(this._perpareItemAdvancementCost(ee)));break;case"magicalsign":case"magictrick":case"blessing":L[ee.type].push(ee);break;case"trait":switch(ee.system.traitType.value){case"rangeAttack":ee=Actordsa5._prepareRangeTrait(ee);break;case"meleeAttack":ee=Actordsa5._prepareMeleetrait(ee);break;case"armor":Z+=Number(ee.system.at.value)}E[ee.system.traitType.value].push(ee),J=!0;break;case"combatskill":m.push(Actordsa5._calculateCombatSkillValues(ee,this.system));break;case"ammunition":z.ammunition.items.push(Actordsa5.prepareMag(ee)),z.ammunition.show=!0;break;case"meleeweapon":ee.toggleValue=ee.system.worn.value||!1,ee.toggle=!0,this._setOnUseEffect(ee),z.meleeweapons.items.push(Actordsa5._prepareitemStructure(ee)),z.meleeweapons.show=!0,ee.toggleValue&&S.push(ee);break;case"rangeweapon":ee.toggleValue=ee.system.worn.value||!1,ee.toggle=!0,this._setOnUseEffect(ee),z.rangeweapons.items.push(Actordsa5._prepareitemStructure(ee)),z.rangeweapons.show=!0;break;case"armor":ee.toggleValue=ee.system.worn.value||!1,z.armor.items.push(Actordsa5._prepareitemStructure(ee)),z.armor.show=!0,ee.toggle=!0,this._setOnUseEffect(ee),ee.system.worn.value&&(ee.system.protection.value=_.Z.armorWearModifier(ee,ee.system.protection.value),Z+=Number(ee.system.protection.value),C.push(ee));break;case"poison":case"plant":z[ee.type].items.push(ee),z[ee.type].show=!0;break;case"consumable":z[ee.system.equipmentType.value].items.push(Actordsa5._prepareConsumable(ee)),z[ee.system.equipmentType.value].show=!0;break;case"equipment":ee.toggle=getProperty(ee,"system.worn.wearable")||!1,ee.toggle&&(ee.toggleValue=ee.system.worn.value||!1),this._setOnUseEffect(ee),z[ee.system.equipmentType.value].items.push(Actordsa5._prepareitemStructure(ee)),z[ee.system.equipmentType.value].show=!0;break;case"money":H.coins.push(ee),H.total+=ee.system.quantity.value*ee.system.price.value;break;case"advantage":this._setOnUseEffect(ee),y.push(ee);break;case"disadvantage":this._setOnUseEffect(ee),v.push(ee);break;case"specialability":this._setOnUseEffect(ee),this._setAEPayments(ee),P[ee.system.category.value].push(ee);break;case"disease":k.push(ee);break;case"patron":P.magical.push(ee);break;case"demonmark":w.push(ee);break;case"essence":A.push(ee);break;case"imprint":O.push(ee);break;case"application":V.has(ee.system.skill)?V.get(ee.system.skill).push(ee):V.set(ee.system.skill,[ee])}}catch(t){this._itemPreparationError(ee,t)}}}catch(t){X.e(t)}finally{X.f()}var re,ne=_createForOfIteratorHelper(z.bags.items);try{for(ne.s();!(re=ne.n()).done;){var ae=re.value;this._setBagContent(ae,B)}}catch(t){ne.e(t)}finally{ne.f()}for(var oe=0,ie=Object.entries(G);oer.system.price.value?-1:1})),(r=P.magical).push.apply(r,_toConsumableArray(P.pact)),(a=P.clerical).push.apply(a,_toConsumableArray(P.ceremonial));var Se,Te=_createForOfIteratorHelper(P.staff);try{var Ae=function _loop6(){var t=Se.value,r=R.find((function(r){return r.system.artifact==t.system.artifact}));if(r){null==r.abilities&&(r.abilities=[]),r.abilities.push(t);var a=Number(t.system.volume)||0;r[a>0?"volumeFinal":"volume"]+=Math.abs(a)*Number(t.system.step.value)}else P.magical.push(t)};for(Te.s();!(Se=Te.n()).done;)Ae()}catch(t){Te.e(t)}finally{Te.f()}var Oe=duplicate(i.Z.characteristics);return Oe["-"]="-",{totalWeight:parseFloat(this.system.totalWeight.toFixed(3)),traditionArtifacts:R,armorSum:Z,spellArmor:h.system.spellArmor||0,liturgyArmor:h.system.liturgyArmor||0,money:H,encumbrance:(null===(c=this.system.condition)||void 0===c?void 0:c.encumbered)||0,carrycapacity:this.system.carrycapacity,isSwarm:this.isSwarm(),canSwarm:!this.prototypeToken.actorLink,wornRangedWeapons:D,wornMeleeWeapons:I,horseActor:Q,advantages:y,disadvantages:v,specAbs:P,information:T,aggregatedtests:b,wornArmor:C,essence:A,imprint:O,inventory:z,hasTrait:J,demonmarks:w,diseases:k,canBuild:game.dsa5.sheets.DSACharBuilder&&!(null!==(u=h.system.details.species)&&void 0!==u&&u.value),itemModifiers:this.system.itemModifiers,languagePoints:{used:(null===(l=h.system.freeLanguagePoints)||void 0===l?void 0:l.used)||0,available:(null===(p=h.system.freeLanguagePoints)||void 0===p?void 0:p.value)||0},schips:j,groupschips:M,guidevalues:Oe,magic:L,traits:E,combatskills:m,canAdvance:this.canAdvance,sheetLocked:h.system.sheetLocked.value,bodyAttrs:["ff","ge","ko","kk"],mentalAttrs:["mu","kl","in","ch"],allSkillsLeft:{body:W.body,social:W.social,nature:W.nature},allSkillsRight:{knowledge:W.knowledge,trade:W.trade}}}},{key:"isSwarm",value:function isSwarm(){return this.system.swarm.count>1&&!this.prototypeToken.actorLink}},{key:"getArmorEncumbrance",value:function getArmorEncumbrance(t,r){var a=r.reduce((function(t,r){return r.system.calculatedEncumbrance=Number(r.system.encumbrance.value)+_.Z.armorEncumbranceModifier(r),r.system.damageToolTip=_.Z.damageTooltip(r),t+r.system.calculatedEncumbrance}),0),o=x.Z.isRiding(this)?-1:0;return Math.max(0,a-d.Z.abilityStep(t,game.i18n.localize("LocalizedIDs.inuredToEncumbrance"))+o)}},{key:"_calcBagweight",value:function _calcBagweight(t,r){var a=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],o=0;if(r.has(t._id)){var i=0;!t.system.worn.value&&a&&(o-=t.system.preparedWeight);var c,u=_createForOfIteratorHelper(r.get(t._id));try{for(u.s();!(c=u.n()).done;){var l=c.value;l.system.preparedWeight=Number(parseFloat((l.system.weight.value*l.system.quantity.value).toFixed(3))),r.has(l._id)?i+=this._calcBagweight(l,r,!1):i+=l.system.preparedWeight}}catch(t){u.e(t)}finally{u.f()}a?t.system.worn.value&&(o+=i):o+=i+t.system.preparedWeight,t.system.bagweight="".concat(i.toFixed(3),"/").concat(t.system.capacity)}return o}},{key:"_setBagContent",value:function _setBagContent(t,r){if(r.has(t._id)){t.children=[];var a,o=_createForOfIteratorHelper(r.get(t._id));try{for(o.s();!(a=o.n()).done;){var i=a.value;t.children.push(Actordsa5._prepareitemStructure(Actordsa5._prepareConsumable(i))),r.has(i._id)&&this._setBagContent(i,r)}}catch(t){o.e(t)}finally{o.f()}}}},{key:"isMerchant",value:function isMerchant(){return["merchant","loot"].includes(getProperty(this,"system.merchant.merchantType"))}},{key:"_itemPreparationError",value:function _itemPreparationError(t,r){console.error("Something went wrong with preparing item "+t.name+": "+r),console.warn(r),console.warn(t),ui.notifications.error("Something went wrong with preparing item "+t.name+": "+r)}},{key:"_applyModiferTransformations",value:function _applyModiferTransformations(t){this.system.itemModifiers={};for(var r=0,a=Object.keys(t);r1&&void 0!==c[1]?c[1]:{},a=c.length>2&&void 0!==c[2]?c[2]:{},!Actordsa5.canAdvance(this)){u.next=13;break}if(isNaN(t)||null==t){u.next=12;break}return o=Number(t),r["system.details.experience.spent"]=Number(this.system.details.experience.spent)+o,u.next=8,this.update(r,a);case 8:i=game.i18n.format(o>0?"advancementCost":"refundCost",{cost:Math.abs(o)}),(0,v.p0)(i),u.next=13;break;case 12:ui.notifications.error(game.i18n.localize("DSAError.APUpdateError"));case 13:case"end":return u.stop()}}),_callee3,this)}))),function _updateAPs(t){return J.apply(this,arguments)})},{key:"checkEnoughXP",value:(K=_asyncToGenerator(_regeneratorRuntime().mark((function _callee4(t){var r,a,o,c,u;return _regeneratorRuntime().wrap((function _callee4$(l){for(;;)switch(l.prev=l.next){case 0:if(Actordsa5.canAdvance(this)){l.next=2;break}return l.abrupt("return",!0);case 2:if(!isNaN(t)&&null!=t){l.next=4;break}return l.abrupt("return",!0);case 4:if(!(Number(this.system.details.experience.total)-Number(this.system.details.experience.spent)>=t)){l.next=8;break}return l.abrupt("return",!0);case 8:if(0!=Number(this.system.details.experience.total)){l.next=24;break}return l.next=11,renderTemplate("systems/dsa5/templates/dialog/parts/expChoices.html",{entries:i.Z.startXP});case 11:return r=l.sent,a=0,o=!1,l.next=16,new Promise((function(t,a){new Dialog({title:game.i18n.localize("DSAError.NotEnoughXP"),content:r,default:"yes",buttons:{Yes:{icon:'',label:game.i18n.localize("yes"),callback:function callback(r){t([!0,r.find(".APsel")[0].value])}},cancel:{icon:'',label:game.i18n.localize("cancel"),callback:function callback(){t([!1,0])}}}}).render(!0)}));case 16:if(c=l.sent,u=_slicedToArray(c,2),o=u[0],a=u[1],!o){l.next=24;break}return l.next=23,this.update({"system.details.experience.total":Number(a)});case 23:return l.abrupt("return",!0);case 24:return ui.notifications.error(game.i18n.localize("DSAError.NotEnoughXP")),l.abrupt("return",!1);case 26:case"end":return l.stop()}}),_callee4,this)}))),function checkEnoughXP(t){return K.apply(this,arguments)})},{key:"setupWeapon",value:function setupWeapon(t,r,a,o){return a.mode=r,m.Z.getSubClass(t.type).setupDialog(null,a,t,this,o)}},{key:"setupWeaponless",value:function setupWeaponless(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},a=arguments.length>2?arguments[2]:void 0,o=foundry.utils.duplicate(i.Z.defaultWeapon);o.name=game.i18n.localize("".concat(t,"Weaponless")),o.system.combatskill={value:game.i18n.localize("LocalizedIDs.wrestle")},o.system.damageThreshold.value=14;var c=[];return d.Z.hasAbility(this,game.i18n.localize("LocalizedIDs.mightyAstralBody"))&&c.push(game.i18n.localize("magical")),d.Z.hasAbility(this,game.i18n.localize("LocalizedIDs.mightyKarmalBody"))&&c.push(game.i18n.localize("blessed")),mergeObject(o,{system:{effect:{attributes:c.join(", ")}}}),r.mode=t,m.Z.getSubClass(o.type).setupDialog(null,r,o,this,a)}},{key:"setupSpell",value:function setupSpell(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},a=arguments.length>2?arguments[2]:void 0;return m.Z.getSubClass(t.type).setupDialog(null,r,t,this,a)}},{key:"setupSkill",value:function setupSkill(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},a=arguments.length>2?arguments[2]:void 0;return m.Z.getSubClass(t.type).setupDialog(null,r,t,this,a)}},{key:"tokenScrollingText",value:function tokenScrollingText(t){var r,a,o=_createForOfIteratorHelper(this.isToken?[null===(r=this.token)||void 0===r?void 0:r.object]:this.getActiveTokens(!0));try{for(o.s();!(a=o.n()).done;){var i=a.value;if(i){var c,u=0,l=_createForOfIteratorHelper(t);try{for(l.s();!(c=l.n()).done;){var p=c.value;canvas.interface.createScrollingText(i.center,p.value,{anchor:u,direction:p.value>0?2:1,fontSize:game.settings.get("dsa5","scrollingFontsize"),stroke:p.stroke,strokeThickness:1,jitter:.25,duration:1e3}),u+=1}}catch(t){l.e(t)}finally{l.f()}}}}catch(t){o.e(t)}finally{o.f()}}},{key:"_preUpdate",value:(V=_asyncToGenerator(_regeneratorRuntime().mark((function _callee5(t,r,a){var o,i,c,u,l,p,d,h,m,y;return _regeneratorRuntime().wrap((function _callee5$(g){for(;;)switch(g.prev=g.next){case 0:return g.next=2,_get(_getPrototypeOf(Actordsa5.prototype),"_preUpdate",this).call(this,t,r,a);case 2:for(o={wounds:9109504,astralenergy:723929,karmaenergy:303670},i=[],c=0,u=Object.keys(o);c=0)){i.next=8;break}return i.next=5,this.update(_defineProperty({},"data.status.".concat(a,".value"),o));case 5:return i.abrupt("return",!0);case 8:return ui.notifications.error(game.i18n.localize("DSAError.NotEnough".concat(r))),i.abrupt("return",!1);case 10:case"end":return i.stop()}}),_callee8,this)}))),function applyMana(t,r){return q.apply(this,arguments)})},{key:"preparePostRollAction",value:function preparePostRollAction(t){var r=t.flags.data,a={flags:{img:t.flags.img},rollMode:r.rollMode,speaker:t.speaker,template:r.template,title:r.title,user:t.user};return r.attackerMessage&&(a.attackerMessage=r.attackerMessage),r.defenderMessage&&(a.defenderMessage=r.defenderMessage),r.unopposedStartMessage&&(a.unopposedStartMessage=r.unopposedStartMessage),a}},{key:"resetTargetAndMessage",value:function resetTargetAndMessage(t,r){var a;null!==(a=t.originalTargets)&&void 0!==a&&a.size&&(game.user.targets=t.originalTargets,game.user.targets.user=game.user),!t.defenderMessage&&t.startMessagesList&&(r.startMessagesList=t.startMessagesList)}},{key:"fatererollDamage",value:(B=_asyncToGenerator(_regeneratorRuntime().mark((function _callee9(t,r,a,i,u,l){var p,d,h;return _regeneratorRuntime().wrap((function _callee9$(m){for(;;)switch(m.prev=m.next){case 0:return r.fatePointDamageRerollUsed=!0,this.resetTargetAndMessage(u,r),p=u.postData.damageRoll,m.t0=c.Z,m.next=6,new Roll(p.formula||p._formula).evaluate({async:!0});case 6:return m.t1=m.sent,m.next=9,m.t0.manualRolls.call(m.t0,m.t1,"CHATCONTEXT.rerollDamage");case 9:for(d=m.sent,h=0;h'.concat(game.i18n.localize("CHATFATE.fatepointUsed"),"\n ").concat(game.i18n.format("CHATFATE.isTalented",{character:""+this.name+""}),"
    "),h.next=5,renderTemplate("systems/dsa5/templates/dialog/isTalentedReroll-dialog.html",{testData:a,postData:u.postData});case 5:p=h.sent,new l.Z({title:game.i18n.localize("CHATFATE.selectDice"),content:p,buttons:{Yes:{icon:'',label:game.i18n.localize("Ok"),callback:function(){var l=_asyncToGenerator(_regeneratorRuntime().mark((function _callee10(l){var p,h,m,y,g,v,_,b,k,w,x,S,T;return _regeneratorRuntime().wrap((function _callee10$(A){for(;;)switch(A.prev=A.next){case 0:if(!((p=l.find(".dieSelected").map((function(){return Number($(this).attr("data-index"))})).get()).length>0)){A.next=23;break}h=[],m=_createForOfIteratorHelper(p);try{for(m.s();!(y=m.n()).done;)g=y.value,v=a.roll.terms[2*g],h.push(v.number+"d"+v.faces+"["+v.options.colorset+"]")}catch(t){m.e(t)}finally{m.f()}return A.t0=c.Z,A.next=8,new Roll(h.join("+")).evaluate({async:!0});case 8:return A.t1=A.sent,A.next=11,A.t0.manualRolls.call(A.t0,A.t1,"CHATCONTEXT.talentedReroll");case 11:return h=A.sent,A.next=14,c.Z.showDiceSoNice(h,a.rollMode);case 14:_=0,b=[],k=_createForOfIteratorHelper(p);try{for(k.s();!(w=k.n()).done;)x=w.value,S=a.source.system["characteristic".concat(x+1)],T=S?game.i18n.localize("CHARAbbrev.".concat(S.value.toUpperCase()))+" - ":"",b.push("".concat(T).concat(a.roll.terms[2*x].results[0].result,"/").concat(h.terms[2*_].results[0].result)),a.roll.terms[2*x].results[0].result=Math.min(h.terms[2*_].results[0].result,a.roll.terms[2*x].results[0].result),_+=1}catch(t){k.e(t)}finally{k.f()}return t+="".concat(game.i18n.localize("Roll"),": ").concat(b.join(", ")),ChatMessage.create(o.Z.chatDataSetup(t)),d["".concat(u.postData.postFunction)]({testData:a,cardOptions:r},{rerenderMessage:i}),A.next=23,i.update({"flags.data.talentedRerollUsed":!0});case 23:case"end":return A.stop()}}),_callee10)})));return function callback(t){return l.apply(this,arguments)}}()},cancel:{icon:'',label:game.i18n.localize("cancel")}},default:"Yes"}).render(!0);case 7:case"end":return h.stop()}}),_callee11,this)}))),function fateisTalented(t,r,a,o,i){return W.apply(this,arguments)})},{key:"fatereroll",value:(Z=_asyncToGenerator(_regeneratorRuntime().mark((function _callee13(t,r,a,i,u,p){var d,h=this;return _regeneratorRuntime().wrap((function _callee13$(m){for(;;)switch(m.prev=m.next){case 0:return r.fatePointDamageRerollUsed=!0,this.resetTargetAndMessage(u,r),m.next=4,renderTemplate("systems/dsa5/templates/dialog/fateReroll-dialog.html",{testData:a,postData:u.postData,singleDie:1==u.postData.characteristics.length});case 4:d=m.sent,new l.Z({title:game.i18n.localize("CHATFATE.selectDice"),content:d,buttons:{Yes:{icon:'',label:game.i18n.localize("Ok"),callback:function(){var l=_asyncToGenerator(_regeneratorRuntime().mark((function _callee12(l){var d,m,y,g,v,_,b,k,w,x,S,T,A,O,P,E;return _regeneratorRuntime().wrap((function _callee12$(C){for(;;)switch(C.prev=C.next){case 0:if(!((d=l.find(".dieSelected").map((function(){return Number($(this).attr("data-index"))})).get()).length>0)){C.next=28;break}m=[],y=_createForOfIteratorHelper(d);try{for(y.s();!(g=y.n()).done;)v=g.value,_=a.roll.terms[2*v],m.push(_.number+"d"+_.faces+"["+_.options.colorset+"]")}catch(t){y.e(t)}finally{y.f()}return C.t0=c.Z,C.next=8,new Roll(m.join("+")).evaluate({async:!0});case 8:return C.t1=C.sent,C.next=11,C.t0.manualRolls.call(C.t0,C.t1,"CHATCONTEXT.Reroll");case 11:return m=C.sent,C.next=14,c.Z.showDiceSoNice(m,a.rollMode);case 14:b=0,k=[],w=o.Z.getSpeaker(a.extra.speaker),x=game.i18n.localize("LocalizedIDs.traditionPhex"),S=w.items.some((function(t){return"specialability"==t.type&&t.name==x})),T=_createForOfIteratorHelper(d);try{for(T.s();!(A=T.n()).done;)O=A.value,P=a.source.system["characteristic".concat(O+1)],E=P?"".concat(game.i18n.localize("CHARAbbrev.".concat(P.value.toUpperCase()))," - "):"",k.push("".concat(E).concat(a.roll.terms[2*O].results[0].result,"/").concat(m.terms[2*b].results[0].result)),a.roll.terms[2*O].results[0].result=S?Math.min(m.terms[2*b].results[0].result,a.roll.terms[2*O].results[0].result):m.terms[2*b].results[0].result,b+=1}catch(t){T.e(t)}finally{T.f()}return t+="
    ".concat(game.i18n.localize("Roll"),": ").concat(k.join(", ")),ChatMessage.create(o.Z.chatDataSetup(t)),h["".concat(u.postData.postFunction)]({testData:a,cardOptions:r},{rerenderMessage:i}),C.next=26,i.update({"flags.data.fatePointRerollUsed":!0});case 26:return C.next=28,h.reduceSchips(p);case 28:case"end":return C.stop()}}),_callee12)})));return function callback(t){return l.apply(this,arguments)}}()},cancel:{icon:'',label:game.i18n.localize("cancel")}},default:"Yes"}).render(!0);case 6:case"end":return m.stop()}}),_callee13,this)}))),function fatereroll(t,r,a,o,i,c){return Z.apply(this,arguments)})},{key:"fateaddQS",value:(H=_asyncToGenerator(_regeneratorRuntime().mark((function _callee14(t,r,a,i,c,u){return _regeneratorRuntime().wrap((function _callee14$(l){for(;;)switch(l.prev=l.next){case 0:return ChatMessage.create(o.Z.chatDataSetup(t)),game.user.targets.forEach((function(t){return t.setTarget(!1,{user:game.user,releaseOthers:!1,groupSelection:!0})})),r.fatePointAddQSUsed=!0,a.qualityStep=1,this["".concat(c.postData.postFunction)]({testData:a,cardOptions:r},{rerenderMessage:i}),l.next=7,i.update({"flags.data.fatePointAddQSUsed":!0});case 7:return l.next=9,this.reduceSchips(u);case 9:case"end":return l.stop()}}),_callee14,this)}))),function fateaddQS(t,r,a,o,i,c){return H.apply(this,arguments)})},{key:"fateImprove",value:(N=_asyncToGenerator(_regeneratorRuntime().mark((function _callee16(t,r,a,i,c,u){var p,d,h,m=this;return _regeneratorRuntime().wrap((function _callee16$(y){for(;;)switch(y.prev=y.next){case 0:if(ChatMessage.create(o.Z.chatDataSetup(t)),this.resetTargetAndMessage(c,r),p=i.flags.data.preData.source.type,!["spell","liturgy","ceremony","ritual","skill"].includes(p)){y.next=10;break}return y.next=6,renderTemplate("systems/dsa5/templates/dialog/fateImprove-dialog.html",{testData:a,postData:c.postData});case 6:d=y.sent,new l.Z({title:game.i18n.localize("CHATFATE.selectDice"),content:d,buttons:{Yes:{icon:'',label:game.i18n.localize("Ok"),callback:function(){var t=_asyncToGenerator(_regeneratorRuntime().mark((function _callee15(t){var o,l,p;return _regeneratorRuntime().wrap((function _callee15$(d){for(;;)switch(d.prev=d.next){case 0:if(o=[0,0,0],1!=(l=t.find(".dieSelected").map((function(){return Number($(this).attr("data-index"))})).get()).length){d.next=12;break}return o[l]=2,p={name:game.i18n.localize("CHATCONTEXT.improveFate"),value:o.join("|"),type:"roll"},a.roll.terms[2*l].results[0].result=Math.max(1,a.roll.terms[2*l].results[0].result-2),a.situationalModifiers.push(p),m["".concat(c.postData.postFunction)]({testData:a,cardOptions:r},{rerenderMessage:i}),d.next=10,i.update({"flags.data.fateImproved":!0});case 10:return d.next=12,m.reduceSchips(u);case 12:case"end":return d.stop()}}),_callee15)})));return function callback(r){return t.apply(this,arguments)}}()},cancel:{icon:'',label:game.i18n.localize("cancel")}},default:"Yes"}).render(!0),y.next=18;break;case 10:return h={name:game.i18n.localize("CHATCONTEXT.improveFate"),value:2,type:"roll"},a.situationalModifiers.push(h),a.roll.terms[0].results[0].result=Math.max(1,a.roll.terms[0].results[0].result-2),this["".concat(c.postData.postFunction)]({testData:a,cardOptions:r},{rerenderMessage:i}),y.next=16,i.update({"flags.data.fateImproved":!0});case 16:return y.next=18,this.reduceSchips(u);case 18:case"end":return y.stop()}}),_callee16,this)}))),function fateImprove(t,r,a,o,i,c){return N.apply(this,arguments)})},{key:"reduceSchips",value:(z=_asyncToGenerator(_regeneratorRuntime().mark((function _callee17(t){return _regeneratorRuntime().wrap((function _callee17$(r){for(;;)switch(r.prev=r.next){case 0:if(0!=t){r.next=5;break}return r.next=3,this.update({"system.status.fatePoints.value":this.system.status.fatePoints.value-1});case 3:r.next=7;break;case 5:return r.next=7,Actordsa5.reduceGroupSchip();case 7:case"end":return r.stop()}}),_callee17,this)}))),function reduceSchips(t){return z.apply(this,arguments)})},{key:"useFateOnRoll",value:(j=_asyncToGenerator(_regeneratorRuntime().mark((function _callee18(t,r,a){var i,c,u,l,p,d;return _regeneratorRuntime().wrap((function _callee18$(h){for(;;)switch(h.prev=h.next){case 0:("isTalented"==r||o.Z.fateAvailable(this,1==a))&&(i=t.flags.data,c=this.preparePostRollAction(t),0==a?(u=this.system.status.fatePoints.value-1,l="PointsRemaining"):(u=game.settings.get("dsa5","groupschips").split("/")[0],l="GroupPointsRemaining"),p='

    '.concat(game.i18n.localize("CHATFATE.fatepointUsed"),"

    \n ").concat(game.i18n.format("CHATFATE."+r,{character:""+this.name+""}),"
    \n ").concat(game.i18n.localize("CHATFATE.".concat(l)),": ").concat(u),(d=i.preData).extra.actor=o.Z.getSpeaker(d.extra.speaker).toObject(!1),this["fate".concat(r)](p,c,d,t,i,a));case 1:case"end":return h.stop()}}),_callee18,this)}))),function useFateOnRoll(t,r,a){return j.apply(this,arguments)})},{key:"horseSpeed",get:function get(){return x.Z.getHorseSpeed(this)}},{key:"setupFallingDamage",value:function setupFallingDamage(t,r){var a=this,o=game.i18n.localize("fallingDamage"),i=this.items.find((function(t){return"skill"==t.type&&t.name==game.i18n.localize("LocalizedIDs.bodyControl")})).toObject(),u={subtitle:" (".concat(o,")"),postFunction:{functionName:"game.dsa5.entities.Actordsa5.updateFallingDamage",options:t,tokenId:r,speaker:m.Z.buildSpeaker(this,r)}};this.setupSkill(i,u,r).then(function(){var t=_asyncToGenerator(_regeneratorRuntime().mark((function _callee19(t){var r;return _regeneratorRuntime().wrap((function _callee19$(o){for(;;)switch(o.prev=o.next){case 0:return t.testData.opposable=!1,o.next=3,a.basicTest(t,{suppressMessage:!0});case 3:return r=o.sent,o.next=6,Actordsa5.updateFallingDamage(u.postFunction,r);case 6:return o.next=8,c.Z.renderRollCard(r.cardOptions,r.result,r.options.rerenderMessage);case 8:case"end":return o.stop()}}),_callee19)})));return function(r){return t.apply(this,arguments)}}())}},{key:"_setupFallingHeight",value:function _setupFallingHeight(t,r){var a=game.i18n.localize("fallingDamage"),o={source:{type:"fallingDamage"},opposable:!1,extra:{actor:this.toObject(!1),options:t,speaker:m.Z.buildSpeaker(this,r)}},u={title:a,template:"/systems/dsa5/templates/dialog/fallingdamage-dialog.html",data:{rollMode:t.rollMode,situationalModifiers:[],fallingFloorOptions:i.Z.fallingConditions,modifier:t.modifier||0},callback:function callback(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return o.situationalModifiers=[],o.situationalModifiers.push({name:game.i18n.localize("fallingFloor"),value:t.find('[name="fallingFloor"]').val()}),l.rollMode=t.find('[name="rollMode"]').val(),o.fallingHeight=t.find('[name="testModifier"]').val(),mergeObject(o.extra.options,r),{testData:o,cardOptions:l}}},l=this._setupCardOptions("systems/dsa5/templates/chat/roll/fallingdamage-card.html",a,r);return c.Z.setupDialog({dialogOptions:u,testData:o,cardOptions:l})}},{key:"setupRegeneration",value:function setupRegeneration(t){var r=this,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=arguments.length>2?arguments[2]:void 0,u=game.i18n.localize("regenerationTest"),l={source:{type:"regenerate",system:{}},opposable:!1,extra:{statusId:t,actor:this.toObject(!1),options:a,speaker:m.Z.buildSpeaker(this,o)}};l.extra.actor.isMage=this.system.isMage,l.extra.actor.isPriest=this.system.isPriest;var p=h.Z.getRollModifiers(l.extra.actor,l.source),d={title:u,template:"/systems/dsa5/templates/dialog/regeneration-dialog.html",data:{rollMode:a.rollMode,regenerationInterruptOptions:i.Z.regenerationInterruptOptions,regnerationCampLocations:i.Z.regnerationCampLocations,showAspModifier:this.system.isMage,showKapModifier:this.system.isPriest,situationalModifiers:p,modifier:a.modifier||0},callback:function callback(t){var a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};l.situationalModifiers=Actordsa5._parseModifiers(t),y.rollMode=t.find('[name="rollMode"]').val(),l.situationalModifiers.push({name:game.i18n.localize("camplocation")+" - "+t.find('[name="regnerationCampLocations"] option:selected').text(),value:t.find('[name="regnerationCampLocations"]').val()},{name:game.i18n.localize("interruption")+" - "+t.find('[name="regenerationInterruptOptions"] option:selected').text(),value:t.find('[name="regenerationInterruptOptions"]').val()}),l.regenerationFactor=t.find('[name="badEnvironment"]').is(":checked")?.5:1;for(var o=["LeP","KaP","AsP"],i={},c=0,u=o;c0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1?arguments[1]:void 0,a="dodge",o=this.system.status[a],i=game.i18n.localize(a)+" "+game.i18n.localize("Test"),u={source:{system:o,type:a},opposable:!1,extra:{statusId:a,actor:this.toObject(!1),options:t,speaker:m.Z.buildSpeaker(this,r)}},l=[game.i18n.localize(a),game.i18n.localize("LocalizedIDs.wrestle")],p=m.Z.buildCombatSpecAbs(this,["Combat"],l,"parry"),d=h.Z.getRollModifiers(u.extra.actor,u.source),y=m.Z.getDefenseMalus(d,this),v=g.Z.multipleDefenseValue(this,u.source),_={title:i,template:"/systems/dsa5/templates/dialog/combatskill-enhanced-dialog.html",data:{rollMode:t.rollMode,combatSpecAbs:p,showDefense:!0,situationalModifiers:d,isRangeAttack:y,defenseCountString:game.i18n.format("defenseCount",{malus:v}),isDodge:!0},callback:function callback(t){var r,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return b.rollMode=t.find('[name="rollMode"]').val(),u.situationalModifiers=Actordsa5._parseModifiers(t),(r=u.situationalModifiers).push.apply(r,_toConsumableArray(m.Z.getSpecAbModifiers(t,"parry"))),u.situationalModifiers.push({name:game.i18n.localize("attackFromBehind"),value:t.find('[name="attackFromBehind"]').is(":checked")?-4:0},{name:game.i18n.format("defenseCount",{malus:v}),value:(Number(t.find('[name="defenseCount"]').val())||0)*v},{name:game.i18n.localize("advantageousPosition"),value:t.find('[name="advantageousPosition"]').is(":checked")?2:0}),mergeObject(u.extra.options,a),{testData:u,cardOptions:b}}},b=this._setupCardOptions("systems/dsa5/templates/chat/roll/status-card.html",i,r);return c.Z.setupDialog({dialogOptions:_,testData:u,cardOptions:b})}},{key:"setupCharacteristic",value:function setupCharacteristic(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},a=arguments.length>2?arguments[2]:void 0,u=duplicate(this.system.characteristics[t]),l=o.Z.attributeLocalization(t)+" "+game.i18n.localize("Test");u.attr=t;var p={opposable:!1,source:{type:"char",system:u},extra:{characteristicId:t,actor:this.toObject(!1),options:r,speaker:m.Z.buildSpeaker(this,a)}},d={title:l,template:"/systems/dsa5/templates/dialog/characteristic-dialog.html",data:{rollMode:r.rollMode,difficultyLabels:i.Z.attributeDifficultyLabels,modifier:r.modifier||0},callback:function callback(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return h.rollMode=t.find('[name="rollMode"]').val(),p.testDifficulty=i.Z.attributeDifficultyModifiers[t.find('[name="testDifficulty"]').val()],p.situationalModifiers=Actordsa5._parseModifiers(t),mergeObject(p.extra.options,r),{testData:p,cardOptions:h}}},h=this._setupCardOptions("systems/dsa5/templates/chat/roll/characteristic-card.html",l,a);return c.Z.setupDialog({dialogOptions:d,testData:p,cardOptions:h})}},{key:"actorEffects",value:(M=_asyncToGenerator(_regeneratorRuntime().mark((function _callee20(){var t,r;return _regeneratorRuntime().wrap((function _callee20$(a){for(;;)switch(a.prev=a.next){case 0:return t=["dead"],r=game.user.isGM||this.testUserPermission(game.user,"OBSERVER")||!game.settings.get("dsa5","hideEffects"),a.abrupt("return",r?this.effects.filter((function(t){return t.isVisibleEffect()})):this.effects.filter((function(r){return t.some((function(t){return r.statuses.has(t)}))})));case 3:case"end":return a.stop()}}),_callee20,this)}))),function actorEffects(){return M.apply(this,arguments)})},{key:"_preCreate",value:(G=_asyncToGenerator(_regeneratorRuntime().mark((function _callee21(t,r,a){var o;return _regeneratorRuntime().wrap((function _callee21$(i){for(;;)switch(i.prev=i.next){case 0:return i.next=2,_get(_getPrototypeOf(Actordsa5.prototype),"_preCreate",this).call(this,t,r,a);case 2:o={},t.img||(o.img="icons/svg/mystery-man-black.svg"),"character"==t.type&&mergeObject(o,{prototypeToken:{sight:{enabled:!0},actorLink:!0}}),this.updateSource(o);case 6:case"end":return i.stop()}}),_callee21,this)}))),function _preCreate(t,r,a){return G.apply(this,arguments)})},{key:"_setupCardOptions",value:function _setupCardOptions(t,r,a){var o,i,c=null===(o=game.canvas)||void 0===o||null===(i=o.tokens)||void 0===i?void 0:i.get(a),u={speaker:{alias:c?c.name:this.prototypeToken.name,actor:this.id},title:r,template:t,flags:{img:this.prototypeToken.randomImg?this.img:this.prototypeToken.img}};if(this.token)u.speaker.alias=this.token.name,u.speaker.token=this.token.id,u.speaker.scene=canvas.scene.id,u.flags.img=this.token.img;else{var l=ChatMessage.getSpeaker();l.actor==this.id&&(u.speaker.alias=l.alias,u.speaker.token=l.token,u.speaker.scene=l.scene,u.flags.img=l.token?canvas.tokens.get(l.token).img:u.flags.img)}return u}},{key:"swapMag",value:(L=_asyncToGenerator(_regeneratorRuntime().mark((function _callee22(t){var r,a;return _regeneratorRuntime().wrap((function _callee22$(o){for(;;)switch(o.prev=o.next){case 0:if(r=this.items.get(t),!((a=this.items.get(r.system.currentAmmo.value))&&a.system.quantity.value>1)){o.next=7;break}return o.next=5,this.updateEmbeddedDocuments("Item",[{_id:a.id,"system.quantity.value":a.system.quantity.value-1,"system.mag.value":a.system.mag.max}]);case 5:return k.Z.playEquipmentWearStatusChange(a),o.abrupt("return",a);case 7:return ui.notifications.error(game.i18n.localize("DSAError.NoAmmo")),o.abrupt("return",void 0);case 9:case"end":return o.stop()}}),_callee22,this)}))),function swapMag(t){return L.apply(this,arguments)})},{key:"payMiracles",value:(R=_asyncToGenerator(_regeneratorRuntime().mark((function _callee23(t){var r,a,o;return _regeneratorRuntime().wrap((function _callee23$(i){for(;;)switch(i.prev=i.next){case 0:if(t.extra.miraclePaid){i.next=8;break}if(t.extra.miraclePaid=!0,r=t.situationalModifiers.some((function(t){return t.name.trim()==game.i18n.localize("LocalizedIDs.miracleMight")})),a=t.situationalModifiers.some((function(t){return t.name.trim()==game.i18n.localize("LocalizedIDs.miracle")})),!(o=r?6:a?4:0)){i.next=8;break}return i.next=8,this.update({"system.status.karmaenergy.value":this.system.status.karmaenergy.value-o});case 8:case"end":return i.stop()}}),_callee23,this)}))),function payMiracles(t){return R.apply(this,arguments)})},{key:"consumeAmmunition",value:(I=_asyncToGenerator(_regeneratorRuntime().mark((function _callee24(t){var r;return _regeneratorRuntime().wrap((function _callee24$(a){for(;;)switch(a.prev=a.next){case 0:if(!t.extra.ammo||t.extra.ammoDecreased){a.next=9;break}if(t.extra.ammoDecreased=!0,!t.extra.ammo._id){a.next=7;break}return r={_id:t.extra.ammo._id},"mag"==t.extra.ammo.system.ammunitiongroup.value?t.extra.ammo.system.mag.value<=0?(t.extra.ammo.system.quantity.value--,r["system.quantity.value"]=t.extra.ammo.system.quantity.value,r["system.mag.value"]=t.extra.ammo.system.mag.max-1):r["system.mag.value"]=t.extra.ammo.system.mag.value-1:(t.extra.ammo.system.quantity.value--,r["system.quantity.value"]=t.extra.ammo.system.quantity.value),a.next=7,this.updateEmbeddedDocuments("Item",[r,{_id:t.source._id,"system.reloadTime.progress":0}]);case 7:case 13:a.next=18;break;case 9:if("rangeweapon"!=t.source.type&&("trait"!=t.source.type||"rangeAttack"!=t.source.system.traitType.value)||t.extra.ammoDecreased){a.next=15;break}return t.extra.ammoDecreased=!0,a.next=13,this.updateEmbeddedDocuments("Item",[{_id:t.source._id,"system.reloadTime.progress":0}]);case 15:if(!["spell","liturgy"].includes(t.source.type)||"emptyActor"==t.extra.speaker.token){a.next=18;break}return a.next=18,this.updateEmbeddedDocuments("Item",[{_id:t.source._id,"system.castingTime.progress":0,"system.castingTime.modified":0}]);case 18:case"end":return a.stop()}}),_callee24,this)}))),function consumeAmmunition(t){return I.apply(this,arguments)})},{key:"_checkMaximumItemAdvancement",value:function _checkMaximumItemAdvancement(t,r){var a=this,o=0;switch(t.type){case"combatskill":o=Math.max.apply(Math,_toConsumableArray(t.system.guidevalue.value.split("/").map((function(t){return a.system.characteristics[t].value}))))+2+p.Z.vantageStep(this,"".concat(game.i18n.localize("LocalizedIDs.exceptionalCombatTechnique")," (").concat(t.name,")"));break;case"spell":case"ritual":var i,c=0,u=_createForOfIteratorHelper(t.system.feature.replace(/\(a-z äöü\-\)/gi,"").split(",").map((function(t){return t.trim()})));try{for(u.s();!(i=u.n()).done;){var l=i.value;if(d.Z.hasAbility(this,"".concat(game.i18n.localize("LocalizedIDs.propertyKnowledge")," (").concat(l,")"))){c=this.maxByAttr(t);break}}}catch(t){u.e(t)}finally{u.f()}o=Math.max(14+p.Z.vantageStep(this,"".concat(game.i18n.localize("LocalizedIDs.exceptionalSkill")," (").concat(t.name,")")),c);break;case"liturgy":case"ceremony":var h=new RegExp("^".concat(game.i18n.localize("LocalizedIDs.aspectKnowledge"))),m=0;this.items.filter((function(t){return"specialability"==t.type&&h.test(t.name)})).some((function(r){return t.system.distribution.value.includes(r.name.split("(")[1].split(")")[0])}))&&(m=this.maxByAttr(t)),o=Math.max(14+p.Z.vantageStep(this,"".concat(game.i18n.localize("LocalizedIDs.exceptionalSkill")," (").concat(t.name,")")),m);break;case"skill":o=this.maxByAttr(t)}var y=r<=o;return y||ui.notifications.error(game.i18n.localize("DSAError.AdvanceMaximumReached")),{result:y,max:o}}},{key:"maxByAttr",value:function maxByAttr(t){return Math.max.apply(Math,[this.system.characteristics[t.system.characteristic1.value].value,this.system.characteristics[t.system.characteristic2.value].value,this.system.characteristics[t.system.characteristic3.value].value])+2+p.Z.vantageStep(this,"".concat(game.i18n.localize("LocalizedIDs.exceptionalSkill")," (").concat(t.name,")"))}},{key:"basicTest",value:(D=_asyncToGenerator(_regeneratorRuntime().mark((function _callee25(t){var r,a,o,i,l,p,d,h=arguments;return _regeneratorRuntime().wrap((function _callee25$(m){for(;;)switch(m.prev=m.next){case 0:return r=t.testData,a=t.cardOptions,o=h.length>1&&void 0!==h[1]?h[1]:{},m.next=4,c.Z.rollDices(r,a);case 4:return r=m.sent,m.next=7,c.Z.rollTest(r);case 7:return i=m.sent,r.extra.options.other&&(i.other||(i.other=[]),(l=i.other).push.apply(l,_toConsumableArray(r.extra.options.other))),i.postFunction="basicTest",game.user.targets.size&&(a.isOpposedTest=r.opposable,p=" - ".concat(game.i18n.localize("Opposed")),a.isOpposedTest&&a.title.match(p+"$")!=p&&(a.title+=p)),m.next=13,this.consumeAmmunition(r);case 13:return m.next=15,this.payMiracles(r);case 15:if(o.suppressMessage){m.next=22;break}return m.next=18,c.Z.renderRollCard(a,i,o.rerenderMessage);case 18:return d=m.sent,m.next=21,u.Z.handleOpposedTarget(d);case 21:i.messageId=d.id;case 22:return m.abrupt("return",{result:i,cardOptions:a,options:o});case 23:case"end":return m.stop()}}),_callee25,this)}))),function basicTest(t){return D.apply(this,arguments)})},{key:"addCondition",value:(C=_asyncToGenerator(_regeneratorRuntime().mark((function _callee26(t){var r,a,o,i,c=arguments;return _regeneratorRuntime().wrap((function _callee26$(u){for(;;)switch(u.prev=u.next){case 0:if(a=c.length>1&&void 0!==c[1]?c[1]:1,o=c.length>2&&void 0!==c[2]&&c[2],i=!(c.length>3&&void 0!==c[3])||c[3],"bleeding"!=t&&"bleeding"!=t.id){u.next=7;break}return u.next=6,g.Z.bleedingMessage(this);case 6:case 12:return u.abrupt("return",u.sent);case 7:if(!this.isToken||null!==(r=this.token)&&void 0!==r&&r.object){u.next=10;break}return console.warn("Actor token object is null for",this.name),u.abrupt("return");case 10:return u.next=12,h.Z.addCondition(this,t,a,o,i);case 13:case"end":return u.stop()}}),_callee26,this)}))),function addCondition(t){return C.apply(this,arguments)})},{key:"addTimedCondition",value:(E=_asyncToGenerator(_regeneratorRuntime().mark((function _callee27(t){var r,a,o,i,c=arguments;return _regeneratorRuntime().wrap((function _callee27$(u){for(;;)switch(u.prev=u.next){case 0:if(r=c.length>1&&void 0!==c[1]?c[1]:1,a=c.length>2&&void 0!==c[2]&&c[2],o=!(c.length>3&&void 0!==c[3])||c[3],i=c.length>4&&void 0!==c[4]?c[4]:{},"bleeding"!=t&&"bleeding"!=t.id){u.next=8;break}return u.next=7,g.Z.bleedingMessage(this);case 7:case 11:return u.abrupt("return",u.sent);case 8:return"string"==typeof t&&i.duration&&((t=duplicate(CONFIG.statusEffects.find((function(r){return r.id==t})))).flags.dsa5.description=game.i18n.localize(t.name),t.name=game.i18n.localize(t.name),delete t.description,delete t.flags.dsa5.value,delete t.flags.dsa5.max,delete t.id,mergeObject(t,i)),u.next=11,h.Z.addCondition(this,t,r,a,o);case 12:case"end":return u.stop()}}),_callee27,this)}))),function addTimedCondition(t){return E.apply(this,arguments)})},{key:"initResistPainRoll",value:(P=_asyncToGenerator(_regeneratorRuntime().mark((function _callee28(t){var r,a;return _regeneratorRuntime().wrap((function _callee28$(t){for(;;)switch(t.prev=t.next){case 0:if(r=game.settings.get("dsa5","selfControlOnPain"),!this.hasCondition("incapacitated")){t.next=3;break}return t.abrupt("return");case 3:if(2!=r&&(1!=r||this.hasPlayerOwner)){t.next=7;break}return t.next=6,this.addCondition("incapacitated");case 6:return t.abrupt("return");case 7:return t.next=9,renderTemplate("systems/dsa5/templates/chat/roll/resist-pain.html",{actor:this});case 9:return a=t.sent,t.next=12,ChatMessage.create(o.Z.chatDataSetup(a));case 12:case"end":return t.stop()}}),_callee28,this)}))),function initResistPainRoll(t){return P.apply(this,arguments)})},{key:"finishResistPainRoll",value:(O=_asyncToGenerator(_regeneratorRuntime().mark((function _callee30(){var t,r,a=this;return _regeneratorRuntime().wrap((function _callee30$(o){for(;;)switch(o.prev=o.next){case 0:r=this.items.find((function(t){return t.name==game.i18n.localize("LocalizedIDs.selfControl")&&"skill"==t.type})),this.setupSkill(r,{subtitle:" (".concat(game.i18n.localize("ActiveEffects.resistRoll"),")")},null===(t=this.token)||void 0===t?void 0:t.id).then(function(){var t=_asyncToGenerator(_regeneratorRuntime().mark((function _callee29(t){return _regeneratorRuntime().wrap((function _callee29$(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,a.basicTest(t);case 2:(r.sent.result.successLevel||0)<1&&a.addCondition("incapacitated");case 5:case"end":return r.stop()}}),_callee29)})));return function(r){return t.apply(this,arguments)}}());case 2:case"end":return o.stop()}}),_callee30,this)}))),function finishResistPainRoll(){return O.apply(this,arguments)})},{key:"removeCondition",value:(A=_asyncToGenerator(_regeneratorRuntime().mark((function _callee31(t){var r,a,o,i=arguments;return _regeneratorRuntime().wrap((function _callee31$(c){for(;;)switch(c.prev=c.next){case 0:return r=i.length>1&&void 0!==i[1]?i[1]:1,a=!(i.length>2&&void 0!==i[2])||i[2],o=i.length>3&&void 0!==i[3]&&i[3],c.next=5,h.Z.removeCondition(this,t,r,a,o);case 5:return c.abrupt("return",c.sent);case 6:case"end":return c.stop()}}),_callee31,this)}))),function removeCondition(t){return A.apply(this,arguments)})},{key:"hasCondition",value:function hasCondition(t){return h.Z.hasCondition(this,t)}},{key:"markDead",value:(T=_asyncToGenerator(_regeneratorRuntime().mark((function _callee32(t){var r,a,o,i;return _regeneratorRuntime().wrap((function _callee32$(c){for(;;)switch(c.prev=c.next){case 0:r=this.getActiveTokens(),a=_createForOfIteratorHelper(r),c.prev=2,a.s();case 4:if((o=a.n()).done){c.next=11;break}if(!(i=o.value).combatant){c.next=9;break}return c.next=9,i.combatant.update({defeated:t});case 9:c.next=4;break;case 11:c.next=16;break;case 13:c.prev=13,c.t0=c.catch(2),a.e(c.t0);case 16:return c.prev=16,a.f(),c.finish(16);case 19:case"end":return c.stop()}}),_callee32,this,[[2,13,16,19]])}))),function markDead(t){return T.apply(this,arguments)})}],[{key:"create",value:(S=_asyncToGenerator(_regeneratorRuntime().mark((function _callee33(t,r){var a,i,c;return _regeneratorRuntime().wrap((function _callee33$(u){for(;;)switch(u.prev=u.next){case 0:if(!(t instanceof Array||t.items)){u.next=4;break}return u.next=3,_get(_getPrototypeOf(Actordsa5),"create",this).call(this,t,r);case 3:return u.abrupt("return",u.sent);case 4:return t.img&&"icons/svg/mystery-man.svg"!=t.img||(t.img="icons/svg/mystery-man-black.svg"),u.next=7,o.Z.allSkills();case 7:if(u.t0=u.sent,u.t0){u.next=10;break}u.t0=[];case 10:return a=u.t0,u.next=13,o.Z.allCombatSkills();case 13:if(u.t1=u.sent,u.t1){u.next=16;break}u.t1=[];case 16:return i=u.t1,u.next=19,o.Z.allMoneyItems();case 19:if(u.t2=u.sent,u.t2){u.next=22;break}u.t2=[];case 22:return c=u.t2,t.items=[].concat(_toConsumableArray(a),_toConsumableArray(i),_toConsumableArray(c)),"character"!=t.type&&(t.system={status:{fatePoints:{current:0,value:0}}}),"creature"!=t.type&&[void 0,0].includes(getProperty(t,"system.status.wounds.value"))&&mergeObject(t,{system:{status:{wounds:{value:16}}}}),u.next=28,_get(_getPrototypeOf(Actordsa5),"create",this).call(this,t,r);case 28:return u.abrupt("return",u.sent);case 29:case"end":return u.stop()}}),_callee33,this)}))),function create(t,r){return S.apply(this,arguments)})},{key:"lockedCondition",value:function lockedCondition(){return{id:"locked",name:game.i18n.localize("MERCHANT.locked"),icon:"icons/svg/padlock.svg",flags:{dsa5:{value:null,editable:!0,noEffect:!0,hidePlayers:!0,description:game.i18n.localize("MERCHANT.locked"),custom:!0}}}}},{key:"canAdvance",value:function canAdvance(t){return t.canAdvance}},{key:"armorValue",value:function armorValue(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},a=t.items.filter((function(t){return"armor"==t.type&&1==t.system.worn.value}));r.origin&&(a=a.map((function(a){var o=mergeObject(duplicate(r),{armor:a});return b.Z.applyRollTransformation(t,o,4).options.armor})));var o=a.reduce((function(t,r){return t+_.Z.armorWearModifier(r,r.system.protection.value)}),0),i=t.items.filter((function(t){return"trait"==t.type&&"armor"==t.system.traitType.value})).reduce((function(t,r){return t+Number(r.system.at.value)}),0);return{wornArmor:a,armor:o+i+(t.system.totalArmor||0)}}},{key:"_calculateCombatSkillValues",value:function _calculateCombatSkillValues(t,r){if("melee"==t.system.weapontype.value){var a=t.system.guidevalue.value.split("/").map((function(t){return Number(r.characteristics[t].initial)+Number(r.characteristics[t].modifier)+Number(r.characteristics[t].advances)+Number(r.characteristics[t].gearmodifier)})),i=Math.max.apply(Math,_toConsumableArray(a));t.system.parry.value=Math.ceil(t.system.talentValue.value/2)+Math.max(0,Math.floor((i-8)/3))+Number(game.settings.get("dsa5","higherDefense"));var c=r.characteristics.mu.initial+r.characteristics.mu.modifier+r.characteristics.mu.advances+r.characteristics.mu.gearmodifier;t.system.attack.value=t.system.talentValue.value+Math.max(0,Math.floor((c-8)/3))}else{t.system.parry.value=0;var u=r.characteristics.ff.initial+r.characteristics.ff.modifier+r.characteristics.ff.advances+r.characteristics.ff.gearmodifier;t.system.attack.value=t.system.talentValue.value+Math.max(0,Math.floor((u-8)/3))}return t.cost=game.i18n.format("advancementCost",{cost:o.Z._calculateAdvCost(t.system.talentValue.value,t.system.StF.value)}),t}},{key:"reduceGroupSchip",value:(a=_asyncToGenerator(_regeneratorRuntime().mark((function _callee34(){var t;return _regeneratorRuntime().wrap((function _callee34$(r){for(;;)switch(r.prev=r.next){case 0:if(!game.user.isGM){r.next=7;break}return(t=game.settings.get("dsa5","groupschips").split("/").map((function(t){return Number(t)})))[0]=t[0]-1,r.next=5,game.settings.set("dsa5","groupschips",t.join("/"));case 5:r.next=8;break;case 7:game.socket.emit("system.dsa5",{type:"reduceGroupSchip",payload:{}});case 8:case"end":return r.stop()}}),_callee34)}))),function reduceGroupSchip(){return a.apply(this,arguments)})},{key:"updateFallingDamage",value:(r=_asyncToGenerator(_regeneratorRuntime().mark((function _callee35(t,r,a){var i,c,u,l,p;return _regeneratorRuntime().wrap((function _callee35$(a){for(;;)switch(a.prev=a.next){case 0:return i=2*(r.result.qualityStep||0),mergeObject(t.options,{availableQs:i}),c=o.Z.getSpeaker(t.speaker),a.next=5,c._setupFallingHeight(t.options,t.tokenId);case 5:return u=a.sent,a.next=8,c.basicTest(u,{suppressMessage:!0});case 8:return l=a.sent,a.next=11,renderTemplate("systems/dsa5/templates/chat/roll/fallingdamage-card.html",l);case 11:p=a.sent,r.result.other||(r.result.other=[]),r.result.other.push(p),r.chatData&&(r.chatData.other=[p]);case 15:case"end":return a.stop()}}),_callee35)}))),function updateFallingDamage(t,a,o){return r.apply(this,arguments)})},{key:"_parseModifiers",value:function _parseModifiers(t,r){var a=[];return t.find('[name="situationalModifiers"] option:selected').each((function(){var t=$(this).val(),r={name:$(this).text().trim().split("[")[0],value:isNaN(t)?t:Number(t),type:$(this).attr("data-type")};"dmg"==r.type&&(r.damageBonus=r.value,r.value=0),$(this).attr("data-specAbId")&&(r.specAbId=$(this).attr("data-specAbId")),$(this).attr("data-armorPen")&&(r.armorPen=$(this).attr("data-armorPen")),a.push(r)})),a.push({name:game.i18n.localize("manual"),value:Number(t.find('[name="testModifier"]').val()),type:""}),a}},{key:"_prepareConsumable",value:function _prepareConsumable(t){return t.system.maxCharges&&(t.consumable=!0,t.structureMax=t.system.maxCharges,t.structureCurrent=t.system.charges),t}},{key:"prepareMag",value:function prepareMag(t){return"mag"==t.system.ammunitiongroup.value&&(t.structureMax=t.system.mag.max,t.structureCurrent=t.system.mag.value),t}},{key:"_prepareitemStructure",value:function _prepareitemStructure(t){t.system.structure&&0!=t.system.structure.max&&(t.structureMax=t.system.structure.max,t.structureCurrent=t.system.structure.value);var r=getProperty(t,"flags.dsa5.enchantments");if(r&&r.length>0)t.enchantClass="rar";else if(t.effects.length>0)t.enchantClass="common";else if(t.system.effect&&""!=t.system.effect.value)if("armor"==t.type){var a,o=_createForOfIteratorHelper(t.system.effect.value.split(/,|;/).map((function(t){return t.trim()})));try{for(o.s();!(a=o.n()).done;){var i=a.value.replace(/(\s+)/g," ").trim().split(" ");if(2!=i.length||![game.i18n.localize("CHARAbbrev.INI").toLowerCase(),game.i18n.localize("CHARAbbrev.GS").toLowerCase()].includes(i[1].toLowerCase())||isNaN(i[0])||-1!=i[0]){t.enchantClass="common";break}}}catch(t){o.e(t)}finally{o.f()}}else t.enchantClass="common";return t}},{key:"_prepareMeleetrait",value:function _prepareMeleetrait(t){return t.attack=Number(t.system.at.value),0!=t.system.pa&&(t.parry=t.system.pa),this._parseDmg(t)}},{key:"_prepareMeleeWeapon",value:function _prepareMeleeWeapon(t,r,a){var o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,i=r.find((function(r){return r.name==t.system.combatskill.value}));if(i){t.attack=Number(i.system.attack.value)+Number(t.system.atmod.value);var c=t.system.guidevalue.value.split("/").map((function(t){return a.system.characteristics[t]?Number(a.system.characteristics[t].initial)+Number(a.system.characteristics[t].modifier)+Number(a.system.characteristics[t].advances)+Number(a.system.characteristics[t].gearmodifier):0})),u=Math.ceil(i.system.talentValue.value/2)+Math.max(0,Math.floor((Math.max.apply(Math,_toConsumableArray(c))-8)/3))+Number(game.settings.get("dsa5","higherDefense"));t.parry=u+Number(t.system.pamod.value)+(g.Z.isShield(t)?Number(t.system.pamod.value):0),t.yieldedTwoHand=g.Z.isYieldedTwohanded(t),t.yieldedTwoHand||(o||(o=duplicate(a.items).filter((function(r){return"meleeweapon"==r.type&&r.system.worn.value&&r._id!=t._id&&!g.Z.isYieldedTwohanded(r)}))),o.length>0&&(t.parry+=Math.max.apply(Math,_toConsumableArray(o.map((function(t){return t.system.pamod.offhandMod})))),t.attack+=Math.max.apply(Math,_toConsumableArray(o.map((function(t){return t.system.atmod.offhandMod}))))));var l=0;if(t.system.worn.wrongGrip)if(t.yieldedTwoHand)t.parry-=1,l=1;else{t.system.reach.value="medium";var p=game.i18n.localize("LocalizedCTs.".concat(t.system.combatskill.value));switch(p){case"Two-Handed Impact Weapons":case"Two-Handed Swords":t.parry-=3;var d=new RegExp(game.i18n.localize("wrongGrip.wrongGripBastardRegex"));if(d.test(t.name))l=-2;else{var h=game.i18n.localize("wrongGrip.oneHanded");t.gripDamageText=" (".concat(h," * 0.5)"),t.dmgMultipliers=[{name:h,val:"0.5"}]}break;default:t.parry-=1,l=-1}}if("-"!=(t=this._parseDmg(t)).system.guidevalue.value){var m=Math.max.apply(Math,_toConsumableArray(t.system.guidevalue.value.split("/").map((function(t){return Number(a.system.characteristics[t].value)})))),y=Math.max(m-Number(t.system.damageThreshold.value),0)+l;y>0&&(t.extraDamage=y,t.damageAdd=Roll.safeEval(t.damageAdd+" + "+Number(y)),t.damageAdd=(t.damageAdd>0?"+":"")+t.damageAdd)}_.Z.weaponWearModifier(t),t.system.damageToolTip=_.Z.damageTooltip(t)}else ui.notifications.error(game.i18n.format("DSAError.unknownCombatSkill",{skill:t.system.combatskill.value,item:t.name}));return t}},{key:"_prepareRangeTrait",value:function _prepareRangeTrait(t){return t.attack=Number(t.system.at.value),t.LZ=Number(t.system.reloadTime.value),t.LZ>0&&Actordsa5.buildReloadProgress(t),this._parseDmg(t)}},{key:"calcLZ",value:function calcLZ(t,r){var a=1,i=0;t.system.combatskill.value==game.i18n.localize("LocalizedIDs.Throwing Weapons")?i=-1*d.Z.abilityStep(r,game.i18n.localize("LocalizedIDs.quickdraw")):t.system.combatskill.value==game.i18n.localize("LocalizedIDs.Crossbows")&&d.Z.hasAbility(r,"".concat(game.i18n.localize("LocalizedIDs.quickload")," (").concat(game.i18n.localize("LocalizedIDs.Crossbows"),")"))?a=.5:i=-1*d.Z.abilityStep(r,"".concat(game.i18n.localize("LocalizedIDs.quickload")," (").concat(game.i18n.localize(t.system.combatskill.value),")"));var c="".concat(t.system.reloadTime.value).split("/");if("mag"==t.system.ammunitiongroup.value){var u=r.items.find((function(r){return r.id==t.system.currentAmmo.value||r._id==t.system.currentAmmo.value})),l=0;u&&(u=o.Z.toObjectIfPossible(u)).system.mag.value<=0&&(l=1),c=c[l]||c[0]}else c=c[0];return Math.max(0,Math.round(Number(c)*a)+i)}},{key:"_parseDmg",value:function _parseDmg(t){var r,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:void 0,o=new Roll(t.system.damage.value.replace(/[Ww]/g,"d"),{async:!1}),i="",c="",u="+",l=_createForOfIteratorHelper(o.terms);try{for(l.s();!(r=l.n()).done;){var p=r.value;p.faces?i=p.number+"d"+p.faces:p.operator?u=p.operator:p.number&&(c+=Number("".concat(u).concat(p.number)))}}catch(t){l.e(t)}finally{l.f()}if(a){var d=getProperty(a,"system.damageMod");Number(d)?c+="+".concat(Number(d)):d&&(t.damageBonusDescription=", ".concat(d," ").concat(game.i18n.localize("CHARAbbrev.damage")," ").concat(a.name))}return c&&(c=Roll.safeEval(c)),t.damagedie=i||"0d6",t.damageAdd=""!=c?(Number(c)>=0?"+":"")+c:"",t}},{key:"buildReloadProgress",value:function buildReloadProgress(t){var r=t.system.reloadTime.progress/t.LZ;t.title=game.i18n.format("WEAPON.loading",{status:"".concat(t.system.reloadTime.progress,"/").concat(t.LZ)}),t.progress="".concat(t.system.reloadTime.progress,"/").concat(t.LZ),r>=1&&(t.title=game.i18n.localize("WEAPON.loaded")),this.progressTransformation(t,r)}},{key:"progressTransformation",value:function progressTransformation(t,r){r>=.5?(t.transformRight="181deg",t.transformLeft="".concat(Math.round(360*r-179),"deg")):(t.transformRight="".concat(Math.round(360*r+1),"deg"),t.transformLeft=0)}},{key:"buildSpellChargeProgress",value:function buildSpellChargeProgress(t){if(t.LZ=Number(t.system.castingTime.modified)||0,t.LZ>1){var r=t.system.castingTime.progress/t.LZ;t.title=game.i18n.format("SPELL.loading",{status:"".concat(t.system.castingTime.progress,"/").concat(t.LZ)}),t.progress="".concat(t.system.castingTime.progress,"/").concat(t.LZ),this.progressTransformation(t,r)}return t}},{key:"_prepareRangeWeapon",value:function _prepareRangeWeapon(t,r,a,o){var i,c=a.find((function(r){return r.name==t.system.combatskill.value}));if(t.calculatedRange=t.system.reach.value,c){if(t.attack=Number(c.system.attack.value),"-"!=t.system.ammunitiongroup.value&&(t.ammo=r.filter((function(r){return r.system.ammunitiongroup.value==t.system.ammunitiongroup.value})),i=r.find((function(r){return r._id==t.system.currentAmmo.value})))){var u=Number(i.system.rangeMultiplier)||1;t.calculatedRange=t.calculatedRange.split("/").map((function(t){return Math.round(Number(t)*u)})).join("/"),t.attack+=Number(i.system.atmod)||0,"mag"==i.system.ammunitiongroup.value&&(t.ammoMax=i.system.mag.max,t.ammoCurrent=i.system.mag.value)}t.LZ=Actordsa5.calcLZ(t,o),t.LZ>0&&Actordsa5.buildReloadProgress(t),_.Z.weaponWearModifier(t),t.system.damageToolTip=_.Z.damageTooltip(t)}else ui.notifications.error(game.i18n.format("DSAError.unknownCombatSkill",{skill:t.system.combatskill.value,item:t.name}));return this._parseDmg(t,i)}}]),Actordsa5}();_defineProperty(S,"_baseCarryItems",new Set(["armor","meleeweapon","ammunition","rangeweapon","plant","poison","money","consumable","equipment"])),_defineProperty(S,"_mageSpecs",new Set(["magical","staff","pact"])),_defineProperty(S,"_clericSpecs",new Set(["ceremonial","clerical"]))},416:(t,r,a)=>{a.d(r,{TB:()=>l,Z0:()=>u,xb:()=>c});var o=a(565),i=a(491);function _typeof(t){return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},_typeof(t)}function _regeneratorRuntime(){_regeneratorRuntime=function _regeneratorRuntime(){return t};var t={},r=Object.prototype,a=r.hasOwnProperty,o="function"==typeof Symbol?Symbol:{},i=o.iterator||"@@iterator",c=o.asyncIterator||"@@asyncIterator",u=o.toStringTag||"@@toStringTag";function define(t,r,a){return Object.defineProperty(t,r,{value:a,enumerable:!0,configurable:!0,writable:!0}),t[r]}try{define({},"")}catch(t){define=function define(t,r,a){return t[r]=a}}function wrap(t,r,a,o){var i=r&&r.prototype instanceof Generator?r:Generator,c=Object.create(i.prototype),u=new Context(o||[]);return c._invoke=function(t,r,a){var o="suspendedStart";return function(i,c){if("executing"===o)throw new Error("Generator is already running");if("completed"===o){if("throw"===i)throw c;return doneResult()}for(a.method=i,a.arg=c;;){var u=a.delegate;if(u){var p=maybeInvokeDelegate(u,a);if(p){if(p===l)continue;return p}}if("next"===a.method)a.sent=a._sent=a.arg;else if("throw"===a.method){if("suspendedStart"===o)throw o="completed",a.arg;a.dispatchException(a.arg)}else"return"===a.method&&a.abrupt("return",a.arg);o="executing";var d=tryCatch(t,r,a);if("normal"===d.type){if(o=a.done?"completed":"suspendedYield",d.arg===l)continue;return{value:d.arg,done:a.done}}"throw"===d.type&&(o="completed",a.method="throw",a.arg=d.arg)}}}(t,a,u),c}function tryCatch(t,r,a){try{return{type:"normal",arg:t.call(r,a)}}catch(t){return{type:"throw",arg:t}}}t.wrap=wrap;var l={};function Generator(){}function GeneratorFunction(){}function GeneratorFunctionPrototype(){}var p={};define(p,i,(function(){return this}));var d=Object.getPrototypeOf,h=d&&d(d(values([])));h&&h!==r&&a.call(h,i)&&(p=h);var m=GeneratorFunctionPrototype.prototype=Generator.prototype=Object.create(p);function defineIteratorMethods(t){["next","throw","return"].forEach((function(r){define(t,r,(function(t){return this._invoke(r,t)}))}))}function AsyncIterator(t,r){function invoke(o,i,c,u){var l=tryCatch(t[o],t,i);if("throw"!==l.type){var p=l.arg,d=p.value;return d&&"object"==_typeof(d)&&a.call(d,"__await")?r.resolve(d.__await).then((function(t){invoke("next",t,c,u)}),(function(t){invoke("throw",t,c,u)})):r.resolve(d).then((function(t){p.value=t,c(p)}),(function(t){return invoke("throw",t,c,u)}))}u(l.arg)}var o;this._invoke=function(t,a){function callInvokeWithMethodAndArg(){return new r((function(r,o){invoke(t,a,r,o)}))}return o=o?o.then(callInvokeWithMethodAndArg,callInvokeWithMethodAndArg):callInvokeWithMethodAndArg()}}function maybeInvokeDelegate(t,r){var a=t.iterator[r.method];if(void 0===a){if(r.delegate=null,"throw"===r.method){if(t.iterator.return&&(r.method="return",r.arg=void 0,maybeInvokeDelegate(t,r),"throw"===r.method))return l;r.method="throw",r.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var o=tryCatch(a,t.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,l;var i=o.arg;return i?i.done?(r[t.resultName]=i.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=void 0),r.delegate=null,l):i:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,l)}function pushTryEntry(t){var r={tryLoc:t[0]};1 in t&&(r.catchLoc=t[1]),2 in t&&(r.finallyLoc=t[2],r.afterLoc=t[3]),this.tryEntries.push(r)}function resetTryEntry(t){var r=t.completion||{};r.type="normal",delete r.arg,t.completion=r}function Context(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(pushTryEntry,this),this.reset(!0)}function values(t){if(t){var r=t[i];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var o=-1,c=function next(){for(;++o=0;--o){var i=this.tryEntries[o],c=i.completion;if("root"===i.tryLoc)return handle("end");if(i.tryLoc<=this.prev){var u=a.call(i,"catchLoc"),l=a.call(i,"finallyLoc");if(u&&l){if(this.prev=0;--o){var i=this.tryEntries[o];if(i.tryLoc<=this.prev&&a.call(i,"finallyLoc")&&this.prev=0;--r){var a=this.tryEntries[r];if(a.finallyLoc===t)return this.complete(a.completion,a.afterLoc),resetTryEntry(a),l}},catch:function _catch(t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc===t){var o=a.completion;if("throw"===o.type){var i=o.arg;resetTryEntry(a)}return i}}throw new Error("illegal catch attempt")},delegateYield:function delegateYield(t,r,a){return this.delegate={iterator:values(t),resultName:r,nextLoc:a},"next"===this.method&&(this.arg=void 0),l}},t}function asyncGeneratorStep(t,r,a,o,i,c,u){try{var l=t[c](u),p=l.value}catch(t){return void a(t)}l.done?r(p):Promise.resolve(p).then(o,i)}function _asyncToGenerator(t){return function(){var r=this,a=arguments;return new Promise((function(o,i){var c=t.apply(r,a);function _next(t){asyncGeneratorStep(c,o,i,_next,_throw,"next",t)}function _throw(t){asyncGeneratorStep(c,o,i,_next,_throw,"throw",t)}_next(void 0)}))}}function _classCallCheck(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}function _defineProperties(t,r){for(var a=0;a',label:game.i18n.localize("yes"),callback:function callback(r){a.postContent(r,t)}},cancel:{icon:'',label:game.i18n.localize("cancel")}},o.t4={title:o.t1,content:o.t2,default:"yes",buttons:o.t3},new o.t0(o.t4).render(!0);case 9:case"end":return o.stop()}}),_callee5)}))),function getDialog(t){return a.apply(this,arguments)})},{key:"postContent",value:(r=_asyncToGenerator(_regeneratorRuntime().mark((function _callee6(t,r){var a,o;return _regeneratorRuntime().wrap((function _callee6$(c){for(;;)switch(c.prev=c.next){case 0:a=i.Z.chatDataSetup(r),t.find("#sel_all").is(":checked")||(o=[],t.find(".usersel:checked").each((function(){o.push($(this).val())})),a.whisper=o),ChatMessage.create(a);case 3:case"end":return c.stop()}}),_callee6)}))),function postContent(t,a){return r.apply(this,arguments)})}]),UserMultipickDialog}()},70:(t,r,a)=>{a.d(r,{Z:()=>v});var o=a(369),i=a(839),c=a(577),u=a(562),l=a(169),p=a(122),d=a(491),h=a(538),m=a(5),y=a(973),g=a(565);function _typeof(t){return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},_typeof(t)}function _toConsumableArray(t){return function _arrayWithoutHoles(t){if(Array.isArray(t))return _arrayLikeToArray(t)}(t)||function _iterableToArray(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||_unsupportedIterableToArray(t)||function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function _regeneratorRuntime(){_regeneratorRuntime=function _regeneratorRuntime(){return t};var t={},r=Object.prototype,a=r.hasOwnProperty,o="function"==typeof Symbol?Symbol:{},i=o.iterator||"@@iterator",c=o.asyncIterator||"@@asyncIterator",u=o.toStringTag||"@@toStringTag";function define(t,r,a){return Object.defineProperty(t,r,{value:a,enumerable:!0,configurable:!0,writable:!0}),t[r]}try{define({},"")}catch(t){define=function define(t,r,a){return t[r]=a}}function wrap(t,r,a,o){var i=r&&r.prototype instanceof Generator?r:Generator,c=Object.create(i.prototype),u=new Context(o||[]);return c._invoke=function(t,r,a){var o="suspendedStart";return function(i,c){if("executing"===o)throw new Error("Generator is already running");if("completed"===o){if("throw"===i)throw c;return doneResult()}for(a.method=i,a.arg=c;;){var u=a.delegate;if(u){var p=maybeInvokeDelegate(u,a);if(p){if(p===l)continue;return p}}if("next"===a.method)a.sent=a._sent=a.arg;else if("throw"===a.method){if("suspendedStart"===o)throw o="completed",a.arg;a.dispatchException(a.arg)}else"return"===a.method&&a.abrupt("return",a.arg);o="executing";var d=tryCatch(t,r,a);if("normal"===d.type){if(o=a.done?"completed":"suspendedYield",d.arg===l)continue;return{value:d.arg,done:a.done}}"throw"===d.type&&(o="completed",a.method="throw",a.arg=d.arg)}}}(t,a,u),c}function tryCatch(t,r,a){try{return{type:"normal",arg:t.call(r,a)}}catch(t){return{type:"throw",arg:t}}}t.wrap=wrap;var l={};function Generator(){}function GeneratorFunction(){}function GeneratorFunctionPrototype(){}var p={};define(p,i,(function(){return this}));var d=Object.getPrototypeOf,h=d&&d(d(values([])));h&&h!==r&&a.call(h,i)&&(p=h);var m=GeneratorFunctionPrototype.prototype=Generator.prototype=Object.create(p);function defineIteratorMethods(t){["next","throw","return"].forEach((function(r){define(t,r,(function(t){return this._invoke(r,t)}))}))}function AsyncIterator(t,r){function invoke(o,i,c,u){var l=tryCatch(t[o],t,i);if("throw"!==l.type){var p=l.arg,d=p.value;return d&&"object"==_typeof(d)&&a.call(d,"__await")?r.resolve(d.__await).then((function(t){invoke("next",t,c,u)}),(function(t){invoke("throw",t,c,u)})):r.resolve(d).then((function(t){p.value=t,c(p)}),(function(t){return invoke("throw",t,c,u)}))}u(l.arg)}var o;this._invoke=function(t,a){function callInvokeWithMethodAndArg(){return new r((function(r,o){invoke(t,a,r,o)}))}return o=o?o.then(callInvokeWithMethodAndArg,callInvokeWithMethodAndArg):callInvokeWithMethodAndArg()}}function maybeInvokeDelegate(t,r){var a=t.iterator[r.method];if(void 0===a){if(r.delegate=null,"throw"===r.method){if(t.iterator.return&&(r.method="return",r.arg=void 0,maybeInvokeDelegate(t,r),"throw"===r.method))return l;r.method="throw",r.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var o=tryCatch(a,t.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,l;var i=o.arg;return i?i.done?(r[t.resultName]=i.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=void 0),r.delegate=null,l):i:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,l)}function pushTryEntry(t){var r={tryLoc:t[0]};1 in t&&(r.catchLoc=t[1]),2 in t&&(r.finallyLoc=t[2],r.afterLoc=t[3]),this.tryEntries.push(r)}function resetTryEntry(t){var r=t.completion||{};r.type="normal",delete r.arg,t.completion=r}function Context(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(pushTryEntry,this),this.reset(!0)}function values(t){if(t){var r=t[i];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var o=-1,c=function next(){for(;++o=0;--o){var i=this.tryEntries[o],c=i.completion;if("root"===i.tryLoc)return handle("end");if(i.tryLoc<=this.prev){var u=a.call(i,"catchLoc"),l=a.call(i,"finallyLoc");if(u&&l){if(this.prev=0;--o){var i=this.tryEntries[o];if(i.tryLoc<=this.prev&&a.call(i,"finallyLoc")&&this.prev=0;--r){var a=this.tryEntries[r];if(a.finallyLoc===t)return this.complete(a.completion,a.afterLoc),resetTryEntry(a),l}},catch:function _catch(t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc===t){var o=a.completion;if("throw"===o.type){var i=o.arg;resetTryEntry(a)}return i}}throw new Error("illegal catch attempt")},delegateYield:function delegateYield(t,r,a){return this.delegate={iterator:values(t),resultName:r,nextLoc:a},"next"===this.method&&(this.arg=void 0),l}},t}function asyncGeneratorStep(t,r,a,o,i,c,u){try{var l=t[c](u),p=l.value}catch(t){return void a(t)}l.done?r(p):Promise.resolve(p).then(o,i)}function _asyncToGenerator(t){return function(){var r=this,a=arguments;return new Promise((function(o,i){var c=t.apply(r,a);function _next(t){asyncGeneratorStep(c,o,i,_next,_throw,"next",t)}function _throw(t){asyncGeneratorStep(c,o,i,_next,_throw,"throw",t)}_next(void 0)}))}}function _createForOfIteratorHelper(t,r){var a="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!a){if(Array.isArray(t)||(a=_unsupportedIterableToArray(t))||r&&t&&"number"==typeof t.length){a&&(t=a);var o=0,i=function F(){};return{s:i,n:function n(){return o>=t.length?{done:!0}:{done:!1,value:t[o++]}},e:function e(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var c,u=!0,l=!1;return{s:function s(){a=a.call(t)},n:function n(){var t=a.next();return u=t.done,t},e:function e(t){l=!0,c=t},f:function f(){try{u||null==a.return||a.return()}finally{if(l)throw c}}}}function _unsupportedIterableToArray(t,r){if(t){if("string"==typeof t)return _arrayLikeToArray(t,r);var a=Object.prototype.toString.call(t).slice(8,-1);return"Object"===a&&t.constructor&&(a=t.constructor.name),"Map"===a||"Set"===a?Array.from(t):"Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a)?_arrayLikeToArray(t,r):void 0}}function _arrayLikeToArray(t,r){(null==r||r>t.length)&&(r=t.length);for(var a=0,o=new Array(r);a0),o.find(".step").text(m.Z.roman[i]),r.checkCounterAttack(a),r.calculateModifier()}})),t.find(".opportunityAttack").change((function(r){if($(r.currentTarget).is(":checked")){var a,o=_createForOfIteratorHelper(t.find(".specAbs"));try{for(o.s();!(a=o.n()).done;){var i=a.value;$(i).removeClass("active").attr("data-step",0).find(".step").text("")}}catch(t){o.e(t)}finally{o.f()}}})),t.on("change","input,select",(function(t){return r.calculateModifier(t)})),t.find(".modifiers option").mousedown((function(t){r.calculateModifier(t)})),t.find(".quantity-click").mousedown((function(t){return r.calculateModifier(t)}));var o=this.readTargets();this.calculateModifier();var i=this;this.checkTargets=setInterval((function(){o=i.compareTargets(t,o)}),500)}},{key:"checkCounterAttack",value:function checkCounterAttack(t){if("parry"!=!this.dialogData.mode){var r=d.Z.getSpeaker(this.dialogData.speaker);if(r)if(r.items.get(t.currentTarget.dataset.id).name==game.i18n.localize("LocalizedIDs.counterAttack")){this.dialogData.counterAttack=0==t.button,this.prepareWeapon();var a=0==t.button?"attack":"parry",o=r.items.get(this.dialogData.source._id),c=y.Z.getRollModifiers(r,o,{mode:a});i.Z.getSubClass(o.type).getSituationalModifiers(c,r,{mode:a},o),"attack"==a&&(c=c.filter((function(t){return"defenseMalus"!=t.type})));var u=$(this._element).find("[name=situationalModifiers]");if(c.length>0){if(0==u.length){var l='
    \n \n '.concat(w,"")}},{key:"activateListeners",value:function activateListeners(t){_get(_getPrototypeOf(DSAActiveEffectConfig.prototype),"activateListeners",this).call(this,t);var r=this.dropDownMenu();t.find(".changes-list .effect-change .key").append(r),t.find(".selMenu").select2({width:"element"}).change((function(t){var r=$(t.currentTarget);r.siblings("input").val(r.val());var a=r.closest(".effect-change"),o=r.find("option:selected");a.find(".mode select").val(o.attr("data-mode")),a.find(".value input").attr("placeholder",o.attr("data-ph")),r.blur()})),t.find(".select2").each((function(t,r){$(r)[0].style.removeProperty("width")}))}}],[{key:"defaultOptions",get:function get(){return mergeObject(_get(_getPrototypeOf(DSAActiveEffectConfig),"defaultOptions",this),{resizable:!0})}},{key:"onEffectRemove",value:function(){var _onEffectRemove=_asyncToGenerator(_regeneratorRuntime().mark((function _callee3(actor,effect){var onRemoveMacro;return _regeneratorRuntime().wrap((function _callee3$(_context3){for(;;)switch(_context3.prev=_context3.next){case 0:if(onRemoveMacro=getProperty(effect,"flags.dsa5.onRemove"),!onRemoveMacro){_context3.next=8;break}if(game.user.can("MACRO_SCRIPT")){_context3.next=6;break}ui.notifications.warn("You are not allowed to use JavaScript macros."),_context3.next=8;break;case 6:return _context3.next=8,eval("(async () => {".concat(onRemoveMacro,"})()"));case 8:case"end":return _context3.stop()}}),_callee3)})));function onEffectRemove(t,r){return _onEffectRemove.apply(this,arguments)}return onEffectRemove}()},{key:"applyRollTransformation",value:function applyRollTransformation(actor,options,functionID){var msg="",source=options.origin,_iterator4=_createForOfIteratorHelper(source.effects),_step4;try{for(_iterator4.s();!(_step4=_iterator4.n()).done;){var ef=_step4.value;try{Number(getProperty(ef,"flags.dsa5.advancedFunction"))==functionID&&eval(getProperty(ef,"flags.dsa5.args3"))}catch(t){console.warn("Unable to apply advanced effect",t,ef)}}}catch(t){_iterator4.e(t)}finally{_iterator4.f()}return options.origin=source,{msg,options}}},{key:"applyAdvancedFunction",value:function(){var _applyAdvancedFunction=_asyncToGenerator(_regeneratorRuntime().mark((function _callee4(actor,effects,source,testData,sourceActor){var skipResistRolls,msg,resistRolls,effectApplied,effectsWithChanges,effectNames,_iterator5,_step5,_loop,_args5=arguments;return _regeneratorRuntime().wrap((function _callee4$(_context5){for(;;)switch(_context5.prev=_context5.next){case 0:skipResistRolls=!(_args5.length>5&&void 0!==_args5[5])||_args5[5],msg="",resistRolls=[],effectApplied=!1,effectsWithChanges=[],effectNames=new Set,_iterator5=_createForOfIteratorHelper(effects),_context5.prev=7,_loop=_regeneratorRuntime().mark((function _loop(){var ef,specStep,customEf,qs,resistRoll,skills,mod,effect,value,creatures;return _regeneratorRuntime().wrap((function _loop$(_context4){for(;;)switch(_context4.prev=_context4.next){case 0:if(ef=_step5.value,ef.origin&&delete ef.origin,specStep=Number(getProperty(ef,"flags.dsa5.specStep"))||0,_context4.prev=3,customEf=Number(getProperty(ef,"flags.dsa5.advancedFunction")),qs=Math.min(testData.qualityStep||0,6),resistRoll=getProperty(ef,"flags.dsa5.resistRoll"),!resistRoll||skipResistRolls){_context4.next=13;break}skills=resistRoll.split(" "),mod="".concat(skills.pop()),resistRolls.push({skill:skills.join(" "),mod:Math.round(Roll.safeEval("".concat(mod).replace(/q(l|s)/i,qs).replace("step",specStep)))||0,effect:ef,target:actor,token:actor.token?actor.token.id:void 0}),_context4.next=37;break;case 13:if(effectApplied=!0,effectNames.has(ef.name)||effectNames.add(ef.name),ef.changes&&ef.changes.length>0&&effectsWithChanges.push(ef),!customEf){_context4.next=37;break}_context4.t0=customEf,_context4.next=1===_context4.t0?20:2===_context4.t0?27:3===_context4.t0?34:37;break;case 20:return effect=duplicate(CONFIG.statusEffects.find((function(t){return t.id==getProperty(ef,"flags.dsa5.args0")}))),value="".concat(getProperty(ef,"flags.dsa5.args1"))||"1",effect.duration=ef.duration,value=/,/.test(value)?Number(value.split(",")[qs-1]):Number(value.replace(game.i18n.localize("CHARAbbrev.QS"),qs)),_context4.next=26,actor.addCondition(effect,value,!1,!1);case 26:return _context4.abrupt("break",37);case 27:if(game.user.can("MACRO_SCRIPT")){_context4.next=31;break}ui.notifications.warn("You are not allowed to use JavaScript macros."),_context4.next=33;break;case 31:return _context4.next=33,eval("(async () => {".concat(getProperty(ef,"flags.dsa5.args3"),"})()"));case 33:return _context4.abrupt("break",37);case 34:return creatures=(getProperty(ef,"flags.dsa5.args4")||"").split(",").map((function(t){return"@Compendium[".concat(t.trim().replace(/(@Compendium\[|\])/),"]")})).join(" "),msg+="

    ".concat(game.i18n.localize("ActiveEffects.advancedFunctions.creature"),":

    ").concat(creatures,"

    "),_context4.abrupt("break",37);case 37:_context4.next=44;break;case 39:_context4.prev=39,_context4.t1=_context4.catch(3),console.warn("Unable to apply advanced effect"),console.warn(_context4.t1),console.warn(ef);case 44:case"end":return _context4.stop()}}),_loop,null,[[3,39]])})),_iterator5.s();case 10:if((_step5=_iterator5.n()).done){_context5.next=14;break}return _context5.delegateYield(_loop(),"t0",12);case 12:_context5.next=10;break;case 14:_context5.next=19;break;case 16:_context5.prev=16,_context5.t1=_context5.catch(7),_iterator5.e(_context5.t1);case 19:return _context5.prev=19,_iterator5.f(),_context5.finish(19);case 22:return _context5.next=24,actor.createEmbeddedDocuments("ActiveEffect",effectsWithChanges.map((function(t){return t.origin=actor.uuid,t})));case 24:return _context5.abrupt("return",{msg,resistRolls,effectApplied,effectNames:Array.from(effectNames)});case 25:case"end":return _context5.stop()}}),_callee4,null,[[7,16,19,22]])})));function applyAdvancedFunction(t,r,a,o,i){return _applyAdvancedFunction.apply(this,arguments)}return applyAdvancedFunction}()},{key:"resistEffect",value:(_resistEffect=_asyncToGenerator(_regeneratorRuntime().mark((function _callee6(t){var r,a,o,i,c=this;return _regeneratorRuntime().wrap((function _callee6$(u){for(;;)switch(u.prev=u.next){case 0:r=t.currentTarget.dataset,a={token:r.token,actor:r.actor,scene:canvas.id},(o=_system_utility_dsa5_js__WEBPACK_IMPORTED_MODULE_3__.Z.getSpeaker(a))?(i=o.items.find((function(t){return"skill"==t.type&&t.name==r.skill})),o.setupSkill(i,{modifier:r.mod},r.token).then(function(){var t=_asyncToGenerator(_regeneratorRuntime().mark((function _callee5(t){return _regeneratorRuntime().wrap((function _callee5$(i){for(;;)switch(i.prev=i.next){case 0:return t.testData.opposable=!1,i.next=3,o.basicTest(t);case 3:if(!((i.sent.result.qualityStep||0)<1)){i.next=8;break}return i.next=8,c.applyEffect(r.message,r.mode,[a],{effectIds:[r.effect],skipResistRolls:!0});case 8:case"end":return i.stop()}}),_callee5)})));return function(r){return t.apply(this,arguments)}}())):console.warn("Actor not found for resist roll.");case 4:case"end":return u.stop()}}),_callee6)}))),function resistEffect(t){return _resistEffect.apply(this,arguments)})},{key:"applyEffect",value:(_applyEffect=_asyncToGenerator(_regeneratorRuntime().mark((function _callee7(t,r,a){var o,i,c,u,l,p,d,h,m,y,g,v,_,b,k,w,x,S,T,A,O=arguments;return _regeneratorRuntime().wrap((function _callee7$(P){for(;;)switch(P.prev=P.next){case 0:return o=O.length>3&&void 0!==O[3]?O[3]:{},i=game.messages.get(t),c=i.flags.data.preData.source,u=i.flags.data.postData,l=i.speaker,["poison","disease"].includes(c.type)&&(u.qualityStep=u.successLevel>0?2:1),p=_system_utility_dsa5_js__WEBPACK_IMPORTED_MODULE_3__.Z.getSpeaker(l)||_system_utility_dsa5_js__WEBPACK_IMPORTED_MODULE_3__.Z.getSpeaker(getProperty(i.flags,"data.preData.extra.speaker"))||game.actors.get(getProperty(i.flags,"data.preData.extra.actor.id")),d=p,P.next=10,this._parseEffectDuration(c,u,i.flags.data.preData,p);case 10:if(h=P.sent.filter((function(t){return!getProperty(t,"flags.dsa5.applyToOwner")})),o.effectIds&&(h=h.filter((function(t){return o.effectIds.includes(t._id)}))),m=[],"self"==r?p&&m.push(p):a?m=a.map((function(t){return _system_utility_dsa5_js__WEBPACK_IMPORTED_MODULE_3__.Z.getSpeaker(t)})):game.user.targets.size&&game.user.targets.forEach((function(t){t.actor&&m.push(t.actor)})),!game.user.isGM){P.next=47;break}y=_createForOfIteratorHelper(m),P.prev=16,y.s();case 18:if((g=y.n()).done){P.next=37;break}return v=g.value,P.next=22,DSAActiveEffectConfig.applyAdvancedFunction(v,h,c,u,d,o.skipResistRolls||!1);case 22:if(_=P.sent,b=_.msg,k=_.resistRolls,w=_.effectApplied,x=_.effectNames,!w){P.next=32;break}return T=game.i18n.format("ActiveEffects.appliedEffect",{target:(null===(S=v.token)||void 0===S?void 0:S.name)||v.name,source:x.join(", ")}),A="".concat(T).concat(b||""),P.next=32,ChatMessage.create(_system_utility_dsa5_js__WEBPACK_IMPORTED_MODULE_3__.Z.chatDataSetup(A));case 32:if(!k.length){P.next=35;break}return P.next=35,this.createResistRollMessage(k,t,r);case 35:P.next=18;break;case 37:P.next=42;break;case 39:P.prev=39,P.t0=P.catch(16),y.e(P.t0);case 42:return P.prev=42,y.f(),P.finish(42);case 45:P.next=48;break;case 47:game.socket.emit("system.dsa5",{type:"addEffect",payload:{mode:r,id:t,actors:m.map((function(t){return{token:t.token?t.token.id:void 0,actor:t.id,scene:canvas.scene.id}}))}});case 48:case"end":return P.stop()}}),_callee7,this,[[16,39,42,45]])}))),function applyEffect(t,r,a){return _applyEffect.apply(this,arguments)})},{key:"createResistRollMessage",value:(_createResistRollMessage=_asyncToGenerator(_regeneratorRuntime().mark((function _callee8(t,r,a){var o,i,c,u;return _regeneratorRuntime().wrap((function _callee8$(l){for(;;)switch(l.prev=l.next){case 0:o=_createForOfIteratorHelper(t),l.prev=1,o.s();case 3:if((i=o.n()).done){l.next=12;break}return c=i.value,l.next=7,renderTemplate("systems/dsa5/templates/chat/roll/resist-roll.html",{resist:c,id:r,mode:a});case 7:return u=l.sent,l.next=10,ChatMessage.create(_system_utility_dsa5_js__WEBPACK_IMPORTED_MODULE_3__.Z.chatDataSetup(u));case 10:l.next=3;break;case 12:l.next=17;break;case 14:l.prev=14,l.t0=l.catch(1),o.e(l.t0);case 17:return l.prev=17,o.f(),l.finish(17);case 20:case"end":return l.stop()}}),_callee8,null,[[1,14,17,20]])}))),function createResistRollMessage(t,r,a){return _createResistRollMessage.apply(this,arguments)})},{key:"_parseEffectDuration",value:(_parseEffectDuration2=_asyncToGenerator(_regeneratorRuntime().mark((function _callee9(t,r,a,o){var i,c,u,l,p,d,h,m,y,g,v,_,b,k,w,x,S,T,A,O,P,E,C,D,I,R,L;return _regeneratorRuntime().wrap((function _callee9$(G){for(;;)switch(G.prev=G.next){case 0:i={},c=_createForOfIteratorHelper(a.situationalModifiers.filter((function(t){return t.specAbId})));try{for(c.s();!(u=c.n()).done;)l=u.value,i[l.specAbId]=l.step}catch(t){c.e(t)}finally{c.f()}p=Object.keys(i),d=o?o.items.filter((function(t){return p.includes(t.id)})):[],h=t.effects?duplicate(t.effects):[],m=_createForOfIteratorHelper(d);try{for(m.s();!(y=m.n()).done;){g=y.value,v=duplicate(g).effects,_=_createForOfIteratorHelper(v);try{for(_.s();!(b=_.n()).done;)k=b.value,setProperty(k,"flags.dsa5.specStep",i[g.id])}catch(t){_.e(t)}finally{_.f()}h.push.apply(h,_toConsumableArray(v))}}catch(t){m.e(t)}finally{m.f()}w=(w=getProperty(t,"system.duration.value")||"").replace(" x "," * ").replace(game.i18n.localize("CHARAbbrev.QS"),r.qualityStep),G.prev=10,x=[{regEx:new RegExp(game.i18n.localize("DSAREGEX.combatRounds"),"gi"),seconds:5},{regEx:new RegExp(game.i18n.localize("DSAREGEX.minutes"),"gi"),seconds:60},{regEx:new RegExp(game.i18n.localize("DSAREGEX.hours"),"gi"),seconds:3600},{regEx:new RegExp(game.i18n.localize("DSAREGEX.days"),"gi"),seconds:86400},{regEx:new RegExp(game.i18n.localize("DSAREGEXmaintain.weeks"),"gi"),seconds:604800},{regEx:new RegExp(game.i18n.localize("DSAREGEXmaintain.months"),"gi"),seconds:2592e3},{regEx:new RegExp(game.i18n.localize("DSAREGEXmaintain.years"),"gi"),seconds:3024e4}],S=0,T=x;case 13:if(!(S{a.d(r,{Z:()=>u});var o=a(947),i=a(577),c=a(472);function _typeof(t){return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},_typeof(t)}function _get(){return _get="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function _get(t,r,a){var o=_superPropBase(t,r);if(o){var i=Object.getOwnPropertyDescriptor(o,r);return i.get?i.get.call(arguments.length<3?t:a):i.value}},_get.apply(this,arguments)}function _superPropBase(t,r){for(;!Object.prototype.hasOwnProperty.call(t,r)&&null!==(t=_getPrototypeOf(t)););return t}function _inherits(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(r&&r.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),r&&_setPrototypeOf(t,r)}function _setPrototypeOf(t,r){return _setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function _setPrototypeOf(t,r){return t.__proto__=r,t},_setPrototypeOf(t,r)}function _createSuper(t){var r=function _isNativeReflectConstruct(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function _createSuperInternal(){var a,o=_getPrototypeOf(t);if(r){var i=_getPrototypeOf(this).constructor;a=Reflect.construct(o,arguments,i)}else a=o.apply(this,arguments);return _possibleConstructorReturn(this,a)}}function _possibleConstructorReturn(t,r){if(r&&("object"===_typeof(r)||"function"==typeof r))return r;if(void 0!==r)throw new TypeError("Derived constructors may only return object or undefined");return function _assertThisInitialized(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}function _getPrototypeOf(t){return _getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function _getPrototypeOf(t){return t.__proto__||Object.getPrototypeOf(t)},_getPrototypeOf(t)}function _slicedToArray(t,r){return function _arrayWithHoles(t){if(Array.isArray(t))return t}(t)||function _iterableToArrayLimit(t,r){var a=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null==a)return;var o,i,c=[],u=!0,l=!1;try{for(a=a.call(t);!(u=(o=a.next()).done)&&(c.push(o.value),!r||c.length!==r);u=!0);}catch(t){l=!0,i=t}finally{try{u||null==a.return||a.return()}finally{if(l)throw i}}return c}(t,r)||_unsupportedIterableToArray(t,r)||function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function _regeneratorRuntime(){_regeneratorRuntime=function _regeneratorRuntime(){return t};var t={},r=Object.prototype,a=r.hasOwnProperty,o="function"==typeof Symbol?Symbol:{},i=o.iterator||"@@iterator",c=o.asyncIterator||"@@asyncIterator",u=o.toStringTag||"@@toStringTag";function define(t,r,a){return Object.defineProperty(t,r,{value:a,enumerable:!0,configurable:!0,writable:!0}),t[r]}try{define({},"")}catch(t){define=function define(t,r,a){return t[r]=a}}function wrap(t,r,a,o){var i=r&&r.prototype instanceof Generator?r:Generator,c=Object.create(i.prototype),u=new Context(o||[]);return c._invoke=function(t,r,a){var o="suspendedStart";return function(i,c){if("executing"===o)throw new Error("Generator is already running");if("completed"===o){if("throw"===i)throw c;return doneResult()}for(a.method=i,a.arg=c;;){var u=a.delegate;if(u){var p=maybeInvokeDelegate(u,a);if(p){if(p===l)continue;return p}}if("next"===a.method)a.sent=a._sent=a.arg;else if("throw"===a.method){if("suspendedStart"===o)throw o="completed",a.arg;a.dispatchException(a.arg)}else"return"===a.method&&a.abrupt("return",a.arg);o="executing";var d=tryCatch(t,r,a);if("normal"===d.type){if(o=a.done?"completed":"suspendedYield",d.arg===l)continue;return{value:d.arg,done:a.done}}"throw"===d.type&&(o="completed",a.method="throw",a.arg=d.arg)}}}(t,a,u),c}function tryCatch(t,r,a){try{return{type:"normal",arg:t.call(r,a)}}catch(t){return{type:"throw",arg:t}}}t.wrap=wrap;var l={};function Generator(){}function GeneratorFunction(){}function GeneratorFunctionPrototype(){}var p={};define(p,i,(function(){return this}));var d=Object.getPrototypeOf,h=d&&d(d(values([])));h&&h!==r&&a.call(h,i)&&(p=h);var m=GeneratorFunctionPrototype.prototype=Generator.prototype=Object.create(p);function defineIteratorMethods(t){["next","throw","return"].forEach((function(r){define(t,r,(function(t){return this._invoke(r,t)}))}))}function AsyncIterator(t,r){function invoke(o,i,c,u){var l=tryCatch(t[o],t,i);if("throw"!==l.type){var p=l.arg,d=p.value;return d&&"object"==_typeof(d)&&a.call(d,"__await")?r.resolve(d.__await).then((function(t){invoke("next",t,c,u)}),(function(t){invoke("throw",t,c,u)})):r.resolve(d).then((function(t){p.value=t,c(p)}),(function(t){return invoke("throw",t,c,u)}))}u(l.arg)}var o;this._invoke=function(t,a){function callInvokeWithMethodAndArg(){return new r((function(r,o){invoke(t,a,r,o)}))}return o=o?o.then(callInvokeWithMethodAndArg,callInvokeWithMethodAndArg):callInvokeWithMethodAndArg()}}function maybeInvokeDelegate(t,r){var a=t.iterator[r.method];if(void 0===a){if(r.delegate=null,"throw"===r.method){if(t.iterator.return&&(r.method="return",r.arg=void 0,maybeInvokeDelegate(t,r),"throw"===r.method))return l;r.method="throw",r.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var o=tryCatch(a,t.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,l;var i=o.arg;return i?i.done?(r[t.resultName]=i.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=void 0),r.delegate=null,l):i:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,l)}function pushTryEntry(t){var r={tryLoc:t[0]};1 in t&&(r.catchLoc=t[1]),2 in t&&(r.finallyLoc=t[2],r.afterLoc=t[3]),this.tryEntries.push(r)}function resetTryEntry(t){var r=t.completion||{};r.type="normal",delete r.arg,t.completion=r}function Context(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(pushTryEntry,this),this.reset(!0)}function values(t){if(t){var r=t[i];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var o=-1,c=function next(){for(;++o=0;--o){var i=this.tryEntries[o],c=i.completion;if("root"===i.tryLoc)return handle("end");if(i.tryLoc<=this.prev){var u=a.call(i,"catchLoc"),l=a.call(i,"finallyLoc");if(u&&l){if(this.prev=0;--o){var i=this.tryEntries[o];if(i.tryLoc<=this.prev&&a.call(i,"finallyLoc")&&this.prev=0;--r){var a=this.tryEntries[r];if(a.finallyLoc===t)return this.complete(a.completion,a.afterLoc),resetTryEntry(a),l}},catch:function _catch(t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc===t){var o=a.completion;if("throw"===o.type){var i=o.arg;resetTryEntry(a)}return i}}throw new Error("illegal catch attempt")},delegateYield:function delegateYield(t,r,a){return this.delegate={iterator:values(t),resultName:r,nextLoc:a},"next"===this.method&&(this.arg=void 0),l}},t}function asyncGeneratorStep(t,r,a,o,i,c,u){try{var l=t[c](u),p=l.value}catch(t){return void a(t)}l.done?r(p):Promise.resolve(p).then(o,i)}function _asyncToGenerator(t){return function(){var r=this,a=arguments;return new Promise((function(o,i){var c=t.apply(r,a);function _next(t){asyncGeneratorStep(c,o,i,_next,_throw,"next",t)}function _throw(t){asyncGeneratorStep(c,o,i,_next,_throw,"throw",t)}_next(void 0)}))}}function _toConsumableArray(t){return function _arrayWithoutHoles(t){if(Array.isArray(t))return _arrayLikeToArray(t)}(t)||function _iterableToArray(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||_unsupportedIterableToArray(t)||function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function _createForOfIteratorHelper(t,r){var a="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!a){if(Array.isArray(t)||(a=_unsupportedIterableToArray(t))||r&&t&&"number"==typeof t.length){a&&(t=a);var o=0,i=function F(){};return{s:i,n:function n(){return o>=t.length?{done:!0}:{done:!1,value:t[o++]}},e:function e(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var c,u=!0,l=!1;return{s:function s(){a=a.call(t)},n:function n(){var t=a.next();return u=t.done,t},e:function e(t){l=!0,c=t},f:function f(){try{u||null==a.return||a.return()}finally{if(l)throw c}}}}function _unsupportedIterableToArray(t,r){if(t){if("string"==typeof t)return _arrayLikeToArray(t,r);var a=Object.prototype.toString.call(t).slice(8,-1);return"Object"===a&&t.constructor&&(a=t.constructor.name),"Map"===a||"Set"===a?Array.from(t):"Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a)?_arrayLikeToArray(t,r):void 0}}function _arrayLikeToArray(t,r){(null==r||r>t.length)&&(r=t.length);for(var a=0,o=new Array(r);a1&&void 0!==arguments[1]?arguments[1]:"",a=arguments.length>2?arguments[2]:void 0;a=a||game.i18n.localize("CONDITION.custom"),""==r&&(r=a),t.addCondition({name:a,icon:"icons/svg/aura.svg",origin:t.uuid,flags:{dsa5:{value:null,editable:!0,description:r,custom:!0}}})}},{key:"prepareActiveEffects",value:function prepareActiveEffects(t,r){var a=duplicate(CONFIG.statusEffects),o=[];r.conditions=[],r.transferedConditions=[];var c,u=_createForOfIteratorHelper(t.effects.filter((function(r){return game.user.isGM||"Item"==t.documentName||!r.getFlag("dsa5","hidePlayers")})));try{for(u.s();!(c=u.n()).done;){var l=c.value;l.disabled=l.disabled,l.boolean=null==l.getFlag("dsa5","value"),l.icon=l.icon;var p=_toConsumableArray(l.statuses)[0];p&&(l.value=l.getFlag("dsa5","value"),l.editable=l.getFlag("dsa5","editable"),l.descriptor=p,l.manual=l.getFlag("dsa5","manual"),o.push(p)),l.origin!=t.uuid&&l.origin||l.notApplicable?l.notApplicable||r.transferedConditions.push(l):r.conditions.push(l)}}catch(t){u.e(t)}finally{u.f()}r.manualConditions=a.filter((function(t){return!o.includes(t.id)}));for(var d=[],h=function _loop(){var r=y[m];if(t.system.condition[r]){var a=i.Z.statusEffects.find((function(t){return t.id==r}));a&&d.push({icon:a.icon,id:r,name:game.i18n.localize(a.name),value:t.system.condition[r]})}},m=0,y=Object.keys((null===(g=t.system)||void 0===g?void 0:g.condition)||{});m2&&void 0!==u[2]?u[2]:1,o=u.length>3&&void 0!==u[3]&&u[3],i=!(u.length>4&&void 0!==u[4])||u[4],t.isOwner){l.next=5;break}return l.abrupt("return","Not owned");case 5:if(!t.compendium){l.next=7;break}return l.abrupt("return","Can not add in compendium");case 7:if(!(o&&a<1)){l.next=9;break}return l.abrupt("return",this.removeCondition(t,r,a,i,o));case 9:if("string"==typeof r&&(r=duplicate(CONFIG.statusEffects.find((function(t){return t.id==r})))),r){l.next=12;break}return l.abrupt("return","No Effect Found");case 12:if(!(c=this.hasCondition(t,r.id))||null!=c.flags.dsa5.value){l.next=17;break}return l.abrupt("return",c);case 17:if(!c){l.next=21;break}return l.next=20,DSA5StatusEffects.updateEffect(t,c,a,o,i,r);case 20:case 23:return l.abrupt("return",l.sent);case 21:return l.next=23,DSA5StatusEffects.createEffect(t,r,a,i);case 24:case"end":return l.stop()}}),_callee,this)}))),function addCondition(t,r){return p.apply(this,arguments)})},{key:"hasCondition",value:function hasCondition(t,r){return!(null==t||!r)&&(!!t.effects&&t.effects.find((function(t){return t.statuses.has(r)})))}},{key:"removeCondition",value:(l=_asyncToGenerator(_regeneratorRuntime().mark((function _callee2(t,r){var a,o,i,c,u,l=arguments;return _regeneratorRuntime().wrap((function _callee2$(p){for(;;)switch(p.prev=p.next){case 0:if(a=l.length>2&&void 0!==l[2]?l[2]:1,o=!(l.length>3&&void 0!==l[3])||l[3],i=l.length>4&&void 0!==l[4]&&l[4],t.isOwner){p.next=5;break}return p.abrupt("return","Not owned");case 5:if("string"==typeof r&&(r=duplicate(CONFIG.statusEffects.find((function(t){return t.id==r})))),r){p.next=8;break}return p.abrupt("return","No Effect Found");case 8:if(!(c=this.hasCondition(t,r.id))||null!=c.flags.dsa5.value){p.next=17;break}return t.token&&(t=t.token.actor),p.next=13,t.deleteEmbeddedDocuments("ActiveEffect",[c.id]);case 13:return u=p.sent,p.abrupt("return",u);case 17:if(!c){p.next=21;break}return p.next=20,DSA5StatusEffects.removeEffect(t,c,a,i,o);case 20:return p.abrupt("return",p.sent);case 21:case"end":return p.stop()}}),_callee2,this)}))),function removeCondition(t,r){return l.apply(this,arguments)})},{key:"immuneToEffect",value:function immuneToEffect(t,r){var a=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];if(r.id&&hasProperty(r,"flags.dsa5.max")){var o,i=getProperty(t,"system.immunities")||[];if(i.includes(r.id)&&(o={name:t.name,condition:game.i18n.localize("CONDITION.".concat(r.id))}),!o&&"Actor"==t.documentName){var u,l=c.Z.detectCreatureType(t),p=_createForOfIteratorHelper(l);try{for(p.s();!(u=p.n()).done;){var d=u.value;if(d.ignoredCondition(r.id)){o={name:"".concat(t.name," (").concat(d.getName(),")"),condition:game.i18n.localize("CONDITION.".concat(r.id))};break}}}catch(t){p.e(t)}finally{p.f()}}if(o&&ui.notifications&&!a){var h=game.i18n.format("DSAError.conditionInvalidToCreature",{name:o.name,condition:o.condition});ui.notifications.warn(h)}}}},{key:"resistantToEffect",value:function resistantToEffect(t,r){var a=_toConsumableArray(r.statuses)[0];return a?(getProperty(t,"system.resistances.effects")||[]).reduce((function(t,r){return r.target==a&&(t+=Number(r.value)),t}),0):0}},{key:"createEffect",value:(u=_asyncToGenerator(_regeneratorRuntime().mark((function _callee3(t,r,a,o){var i,c;return _regeneratorRuntime().wrap((function _callee3$(u){for(;;)switch(u.prev=u.next){case 0:return r.name=game.i18n.localize(r.name),this.immuneToEffect(t,r,!1),o?(r.flags.dsa5.auto=Math.min(r.flags.dsa5.max,a),r.flags.dsa5.manual=0):(r.flags.dsa5.manual=Math.min(r.flags.dsa5.max,a),r.flags.dsa5.auto=0),r.flags.dsa5.value=Math.min(4,r.flags.dsa5.manual+r.flags.dsa5.auto),r.id&&(r.statuses=[r.id]),"dead"==r.id&&(r["flags.core.overlay"]=!0),i=duplicate(r),(game.dsa5.config.statusEffectClasses[r.id]||DSA5StatusEffects).levelDependentEffects(r,i),u.next=10,t.createEmbeddedDocuments("ActiveEffect",[i]);case 10:return c=u.sent,delete r.id,u.abrupt("return",c);case 13:case"end":return u.stop()}}),_callee3,this)}))),function createEffect(t,r,a,o){return u.apply(this,arguments)})},{key:"removeEffect",value:(a=_asyncToGenerator(_regeneratorRuntime().mark((function _callee4(t,r,a,o,i){var c,u,l;return _regeneratorRuntime().wrap((function _callee4$(p){for(;;)switch(p.prev=p.next){case 0:if(c=i?o?a:Math.max(0,r.flags.dsa5.auto-a):r.flags.dsa5.auto,u=i?r.flags.dsa5.manual:o?a:r.flags.dsa5.manual-a,!((l={flags:{dsa5:{auto:c,manual:u,value:Math.max(0,Math.min(r.flags.dsa5.max,u+c))}}}).flags.dsa5.auto<1&&0==l.flags.dsa5.manual)){p.next=9;break}return p.next=6,t.deleteEmbeddedDocuments("ActiveEffect",[r.id]);case 6:case 12:return p.abrupt("return",p.sent);case 9:return(game.dsa5.config.statusEffectClasses[_toConsumableArray(r.statuses)[0]]||DSA5StatusEffects).levelDependentEffects(r,l),p.next=12,r.update(l);case 13:case"end":return p.stop()}}),_callee4)}))),function removeEffect(t,r,o,i,c){return a.apply(this,arguments)})},{key:"levelDependentEffects",value:(r=_asyncToGenerator(_regeneratorRuntime().mark((function _callee5(t,r){return _regeneratorRuntime().wrap((function _callee5$(t){for(;;)switch(t.prev=t.next){case 0:case"end":return t.stop()}}),_callee5)}))),function levelDependentEffects(t,a){return r.apply(this,arguments)})},{key:"updateEffect",value:(t=_asyncToGenerator(_regeneratorRuntime().mark((function _callee6(t,r,a,o,i){var c,u,l,p,d=arguments;return _regeneratorRuntime().wrap((function _callee6$(h){for(;;)switch(h.prev=h.next){case 0:if(c=d.length>5&&void 0!==d[5]?d[5]:void 0,this.immuneToEffect(t,r,!0),i?(l=Math.min(r.flags.dsa5.max,o?a:r.flags.dsa5.auto+a),u=l-r.flags.dsa5.auto,p={flags:{dsa5:{auto:l,manual:r.flags.dsa5.manual}}}):(l=o?a:r.flags.dsa5.manual+a,u=l-r.flags.dsa5.manual,p={flags:{dsa5:{manual:l,auto:r.flags.dsa5.auto}}}),0!=u){h.next=5;break}return h.abrupt("return",r);case 5:return p.flags.dsa5.value=Math.max(0,Math.min(r.flags.dsa5.max,p.flags.dsa5.manual+p.flags.dsa5.auto)),c.duration&&(p.duration=c.duration,p.duration.startTime=game.time.worldTime),(game.dsa5.config.statusEffectClasses[_toConsumableArray(r.statuses)[0]]||DSA5StatusEffects).levelDependentEffects(r,p),h.next=10,r.update(p);case 10:return h.abrupt("return",r);case 11:case"end":return h.stop()}}),_callee6,this)}))),function updateEffect(r,a,o,i,c){return t.apply(this,arguments)})},{key:"calculateRollModifier",value:function calculateRollModifier(t,r,a){return null==t.flags.dsa5.value||"regenerate"==a.type?0:DSA5StatusEffects.clampedCondition(r,t)}},{key:"clampedCondition",value:function clampedCondition(t,r){var a=_toConsumableArray(r.statuses)[0];if(!a)return 0;var o=Number(r.flags.dsa5.max),i=-1*Math.clamped(t.system.condition[a]||0,0,o),c=this.resistantToEffect(t,r);return Math.clamped(i+c,-1*o,0)}},{key:"ModifierIsSelected",value:function ModifierIsSelected(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return"damage"!=r.mode}},{key:"getDamageBonus",value:function getDamageBonus(){return 0}},{key:"getRollModifiers",value:function getRollModifiers(t,r){var a,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},c=game.i18n.localize("status")+"/"+game.i18n.localize("condition"),u=[],l=[],p=_createForOfIteratorHelper(t.effects);try{for(p.s();!(a=p.n()).done;){var d=a.value;if(!d.disabled){var h=_toConsumableArray(d.statuses)[0],m=game.dsa5.config.statusEffectClasses[h]||DSA5StatusEffects,y=m.calculateRollModifier(d,t,r,o);h&&l.push(h),0!=y&&u.push({name:d.name,value:y,selected:m.ModifierIsSelected(r,o,t),source:c})}}}catch(t){p.e(t)}finally{p.f()}for(var g=function _loop2(){var a=_slicedToArray(_[v],2),p=a[0],d=a[1];if(d&&!l.includes(p)){var h=duplicate(i.Z.statusEffects.find((function(t){return t.id==p})));if(!h)return"continue";var m=game.dsa5.config.statusEffectClasses[p]||DSA5StatusEffects;h.flags.dsa5.value=d,h.statuses=[p];var y=m.calculateRollModifier(h,t,r,o);0!=y&&u.push({name:h.name,value:y,selected:m.ModifierIsSelected(r,o,t),source:c})}},v=0,_=Object.entries(t.system.condition);v<_.length;v++)g();return u}}]),DSA5StatusEffects}(),l=function(t){_inherits(EncumberedEffect,t);var r=_createSuper(EncumberedEffect);function EncumberedEffect(){return _classCallCheck(this,EncumberedEffect),r.apply(this,arguments)}return _createClass(EncumberedEffect,null,[{key:"ModifierIsSelected",value:function ModifierIsSelected(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},a="skill"==t.type&&"yes"==t.system.burden.value,o=["rangeweapon"].includes(t.type)&&"damage"!=r.mode&&game.settings.get("dsa5","encumbranceForRange"),i=!["skill","spell","ritual","ceremony","liturgy","rangeweapon"].includes(t.type)&&"damage"!=r.mode;return a||i||o}},{key:"calculateRollModifier",value:function calculateRollModifier(t,r,a){var o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return"regenerate"==a.type||"skill"==a.type&&"no"==a.system.burden.value?0:_get(_getPrototypeOf(EncumberedEffect),"calculateRollModifier",this).call(this,t,r,a,o)}}]),EncumberedEffect}(u),p=function(t){_inherits(ProneEffect,t);var r=_createSuper(ProneEffect);function ProneEffect(){return _classCallCheck(this,ProneEffect),r.apply(this,arguments)}return _createClass(ProneEffect,null,[{key:"calculateRollModifier",value:function calculateRollModifier(t,r,a){var o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return"regenerate"==a.type?0:"dodge"==a.type?-2:o.mode?"attack"==o.mode?-4:-2:0}}]),ProneEffect}(u),d=function(t){_inherits(RaptureEffect,t);var r=_createSuper(RaptureEffect);function RaptureEffect(){return _classCallCheck(this,RaptureEffect),r.apply(this,arguments)}return _createClass(RaptureEffect,null,[{key:"calculateRollModifier",value:function calculateRollModifier(t,r,a){var o=new RegExp("".concat(game.i18n.localize("combatskill")," "),"gi"),i=r.system.happyTalents.value.split(/;|,/).map((function(t){return t.replace(o,"").trim()}));return i.includes(a.name)&&["skill","combatskill"].includes(a.type)||["rangeweapon","meleeweapon"].includes(a.type)&&i.includes(a.system.combatskill.value)||["ceremony","liturgy"].includes(a.type)?-1*this.clampedCondition(r,t)-1:["ritual","spell","skill","combatskill"].includes(a.type)?this.clampedCondition(r,t):(a.type,0)}}]),RaptureEffect}(u),h=function(t){_inherits(DeafEffect,t);var r=_createSuper(DeafEffect);function DeafEffect(){return _classCallCheck(this,DeafEffect),r.apply(this,arguments)}return _createClass(DeafEffect,null,[{key:"calculateRollModifier",value:function calculateRollModifier(t,r,a){return"regenerate"==a.type?0:"skill"==a.type&&a.name==game.i18n.localize("LocalizedIDs.perception")?-3:0}}]),DeafEffect}(u),m=function(t){_inherits(BloodrushEffect,t);var r=_createSuper(BloodrushEffect);function BloodrushEffect(){return _classCallCheck(this,BloodrushEffect),r.apply(this,arguments)}return _createClass(BloodrushEffect,null,[{key:"calculateRollModifier",value:function calculateRollModifier(t,r,a){var o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return"regenerate"==a.type?0:"skill"==a.type?a.name==game.i18n.localize("LocalizedIDs.featOfStrength")?2:0:"attack"==o.mode?4:0}}]),BloodrushEffect}(u),y=function(t){_inherits(PainEffect,t);var r=_createSuper(PainEffect);function PainEffect(){return _classCallCheck(this,PainEffect),r.apply(this,arguments)}return _createClass(PainEffect,null,[{key:"ModifierIsSelected",value:function ModifierIsSelected(t){var r=arguments.length>2?arguments[2]:void 0;return null==r.effects.find((function(t){return Array.from(t.statuses).includes("bloodrush")}))}}]),PainEffect}(u),g=function(t){_inherits(TranceEffect,t);var r=_createSuper(TranceEffect);function TranceEffect(){return _classCallCheck(this,TranceEffect),r.apply(this,arguments)}return _createClass(TranceEffect,null,[{key:"calculateRollModifier",value:function calculateRollModifier(t,r,a){if("regenerate"==a.type)return 0;switch(Number(this.clampedCondition(r,t))){case-2:var o=new RegExp("".concat(game.i18n.localize("combatskill")," "),"gi"),i=r.system.happyTalents.value.split(/;|,/).map((function(t){return t.replace(o,"").trim()}));if(i.includes(a.name)&&["skill","combatskill"].includes(a.type)||["rangeweapon","meleeweapon"].includes(a.type)&&i.includes(a.system.combatskill.value)||["ceremony","liturgy"].includes(a.type))return-2;case-3:return-3}return 0}}]),TranceEffect}(u),v=function(t){_inherits(DrunkenEffect,t);var r=_createSuper(DrunkenEffect);function DrunkenEffect(){return _classCallCheck(this,DrunkenEffect),r.apply(this,arguments)}return _createClass(DrunkenEffect,null,[{key:"calculateRollModifier",value:function calculateRollModifier(t,r,a){return"regenerate"==a.type?0:"skill"==a.type&&a.name==game.i18n.localize("LocalizedIDs.gambling")?Math.clamped(this.clampedCondition(r,t),-3,0):0}}]),DrunkenEffect}(u),_=function(t){_inherits(BurningEffect,t);var r=_createSuper(BurningEffect);function BurningEffect(){return _classCallCheck(this,BurningEffect),r.apply(this,arguments)}return _createClass(BurningEffect,null,[{key:"calculateRollModifier",value:function calculateRollModifier(t,r,a){return"regenerate"==a.type?0:"skill"==a.type&&a.name==game.i18n.localize("LocalizedIDs.bodyControl")?Math.clamped(this.clampedCondition(r,t)+1,-2,0):0}}]),BurningEffect}(u),b=function(t){_inherits(ArousalEffect,t);var r=_createSuper(ArousalEffect);function ArousalEffect(){return _classCallCheck(this,ArousalEffect),r.apply(this,arguments)}return _createClass(ArousalEffect,null,[{key:"calculateRollModifier",value:function calculateRollModifier(t,r,a){return 0}}]),ArousalEffect}(u),k=function(t){_inherits(SikaryanlossEffect,t);var r=_createSuper(SikaryanlossEffect);function SikaryanlossEffect(){return _classCallCheck(this,SikaryanlossEffect),r.apply(this,arguments)}return _createClass(SikaryanlossEffect,null,[{key:"calculateRollModifier",value:function calculateRollModifier(t,r,a){return"skill"==a.type&&a.name==game.i18n.localize("LocalizedIDs.willpower")?2*(this.clampedCondition(r,t)+1):"regenerate"==a.type?this.clampedCondition(r,t):0}}]),SikaryanlossEffect}(u),w=function(t){_inherits(DesireEffect,t);var r=_createSuper(DesireEffect);function DesireEffect(){return _classCallCheck(this,DesireEffect),r.apply(this,arguments)}return _createClass(DesireEffect,null,[{key:"calculateRollModifier",value:function calculateRollModifier(t,r,a){return"skill"==a.type&&a.name==game.i18n.localize("LocalizedIDs.willpower")?Math.clamped(this.clampedCondition(r,t),-3,0):0}}]),DesireEffect}(u),x=function(t){_inherits(TheriakEffect,t);var r=_createSuper(TheriakEffect);function TheriakEffect(){return _classCallCheck(this,TheriakEffect),r.apply(this,arguments)}return _createClass(TheriakEffect,null,[{key:"calculateRollModifier",value:function calculateRollModifier(t,r,a){return"regenerate"==a.type?-1*this.clampedCondition(r,t):0}}]),TheriakEffect}(u),S=function(t){_inherits(SunkenEffect,t);var r=_createSuper(SunkenEffect);function SunkenEffect(){return _classCallCheck(this,SunkenEffect),r.apply(this,arguments)}return _createClass(SunkenEffect,null,[{key:"calculateRollModifier",value:function calculateRollModifier(t,r,a){return"skill"==a.type&&"body"==a.system.group.value?-1*Math.clamped(this.clampedCondition(r,t)-1,3,0):0}}]),SunkenEffect}(u),T=function(t){_inherits(HungerEffect,t);var r=_createSuper(HungerEffect);function HungerEffect(){return _classCallCheck(this,HungerEffect),r.apply(this,arguments)}return _createClass(HungerEffect,null,[{key:"calculateRollModifier",value:function calculateRollModifier(t,r,a){return"regenerate"==a.type?-1*Math.pow(2,-1*this.clampedCondition(r,t)-1):0}}]),HungerEffect}(u),A=function(t){_inherits(ThirstEffect,t);var r=_createSuper(ThirstEffect);function ThirstEffect(){return _classCallCheck(this,ThirstEffect),r.apply(this,arguments)}return _createClass(ThirstEffect,null,[{key:"calculateRollModifier",value:function calculateRollModifier(t,r,a){var o=this.clampedCondition(r,t);return"regenerate"==a.type?1==o?-1:-5*o:Math.clamped(o-1,0,3)}},{key:"levelDependentEffects",value:function levelDependentEffects(t,r){r.changes={1:[],2:[{key:"system.condition.stunned",mode:2,value:.5}],3:[{key:"system.condition.stunned",mode:2,value:2/3}],4:[{key:"system.condition.stunned",mode:2,value:3/4}]}[r.flags.dsa5.value]}}]),ThirstEffect}(u),O=function(t){_inherits(HeatEffect,t);var r=_createSuper(HeatEffect);function HeatEffect(){return _classCallCheck(this,HeatEffect),r.apply(this,arguments)}return _createClass(HeatEffect,null,[{key:"levelDependentEffects",value:function levelDependentEffects(t,r){r.changes={1:[{key:"system.condition.stunned",mode:2,value:1},{key:"system.condition.confused",mode:2,value:1}],2:[{key:"system.condition.stunned",mode:2,value:1},{key:"system.condition.confused",mode:2,value:.5}],3:[{key:"system.condition.stunned",mode:2,value:1},{key:"system.condition.confused",mode:2,value:2/3}],4:[{key:"system.condition.stunned",mode:2,value:1},{key:"system.condition.confused",mode:2,value:.5}]}[r.flags.dsa5.value]}}]),HeatEffect}(u),P=function(t){_inherits(ColdEffect,t);var r=_createSuper(ColdEffect);function ColdEffect(){return _classCallCheck(this,ColdEffect),r.apply(this,arguments)}return _createClass(ColdEffect,null,[{key:"levelDependentEffects",value:function levelDependentEffects(t,r){r.changes={1:[{key:"system.condition.confused",mode:2,value:1},{key:"system.condition.paralysed",mode:2,value:1}],2:[{key:"system.condition.confused",mode:2,value:1},{key:"system.condition.paralysed",mode:2,value:.5}],3:[{key:"system.condition.confused",mode:2,value:1},{key:"system.condition.paralysed",mode:2,value:2/3}],4:[{key:"system.condition.confused",mode:2,value:1},{key:"system.condition.paralysed",mode:2,value:.5}]}[r.flags.dsa5.value]}}]),ColdEffect}(u),E=function(t){_inherits(NoModifierEffect,t);var r=_createSuper(NoModifierEffect);function NoModifierEffect(){return _classCallCheck(this,NoModifierEffect),r.apply(this,arguments)}return _createClass(NoModifierEffect,null,[{key:"calculateRollModifier",value:function calculateRollModifier(t,r,a){return 0}}]),NoModifierEffect}(u);i.Z.statusEffectClasses={inpain:y,heat:O,cold:P,encumbered:l,stunned:u,raptured:d,feared:u,paralysed:u,confused:u,prone:p,deaf:h,bloodrush:m,trance:g,drunken:v,arousal:b,burning:_,sikaryanloss:k,desire:w,theriak:x,services:E,sunken:S,hunger:T,thirst:A}},272:(t,r,a)=>{a.d(r,{Z:()=>u});var o=a(577),i=a(794),c=a(492);function _typeof(t){return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},_typeof(t)}function _toConsumableArray(t){return function _arrayWithoutHoles(t){if(Array.isArray(t))return _arrayLikeToArray(t)}(t)||function _iterableToArray(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function _unsupportedIterableToArray(t,r){if(!t)return;if("string"==typeof t)return _arrayLikeToArray(t,r);var a=Object.prototype.toString.call(t).slice(8,-1);"Object"===a&&t.constructor&&(a=t.constructor.name);if("Map"===a||"Set"===a)return Array.from(t);if("Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a))return _arrayLikeToArray(t,r)}(t)||function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function _arrayLikeToArray(t,r){(null==r||r>t.length)&&(r=t.length);for(var a=0,o=new Array(r);a=0;--o){var i=this.tryEntries[o],c=i.completion;if("root"===i.tryLoc)return handle("end");if(i.tryLoc<=this.prev){var u=a.call(i,"catchLoc"),l=a.call(i,"finallyLoc");if(u&&l){if(this.prev=0;--o){var i=this.tryEntries[o];if(i.tryLoc<=this.prev&&a.call(i,"finallyLoc")&&this.prev=0;--r){var a=this.tryEntries[r];if(a.finallyLoc===t)return this.complete(a.completion,a.afterLoc),resetTryEntry(a),l}},catch:function _catch(t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc===t){var o=a.completion;if("throw"===o.type){var i=o.arg;resetTryEntry(a)}return i}}throw new Error("illegal catch attempt")},delegateYield:function delegateYield(t,r,a){return this.delegate={iterator:values(t),resultName:r,nextLoc:a},"next"===this.method&&(this.arg=void 0),l}},t}function asyncGeneratorStep(t,r,a,o,i,c,u){try{var l=t[c](u),p=l.value}catch(t){return void a(t)}l.done?r(p):Promise.resolve(p).then(o,i)}function _asyncToGenerator(t){return function(){var r=this,a=arguments;return new Promise((function(o,i){var c=t.apply(r,a);function _next(t){asyncGeneratorStep(c,o,i,_next,_throw,"next",t)}function _throw(t){asyncGeneratorStep(c,o,i,_next,_throw,"throw",t)}_next(void 0)}))}}function _classCallCheck(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}function _defineProperties(t,r){for(var a=0;a2&&void 0!==i[2])||i[2],game.dsa5.config.removevantageRules[r.name]&&game.dsa5.config.removevantageRules[r.name](t,r),o=AdvantageRulesDSA5.calcAPCostSum(r),c.next=5,AdvantageRulesDSA5.removeSingularVantages(t,r,o);case 5:return o=c.sent,c.next=8,t._updateAPs(-1*o,{},{render:a});case 8:case"end":return c.stop()}}),_callee2)}))),function vantageRemoved(t,r){return i.apply(this,arguments)})},{key:"_vantageReturnFunction",value:(a=_asyncToGenerator(_regeneratorRuntime().mark((function _callee3(t,r,a,i){var c,u,l,p;return _regeneratorRuntime().wrap((function _callee3$(d){for(;;)switch(d.prev=d.next){case 0:if(null!=r){d.next=2;break}return d.abrupt("return");case 2:if(r=duplicate(r),/,/.test(r.system.APValue.value)&&(c=r.name.replace(" ()",""),r.system.APValue.value=r.system.APValue.value.split(",")[t.items.filter((function(t){return t.type==r.type&&t.name.includes(c)})).length].trim()),null!=i&&(AdvantageRulesDSA5.simpleAdoption(r,i,r.name,o.Z.vantagesNeedingAdaption),r.name="".concat(r.name.replace(" ()","")," (").concat(i.name,")"),i.data&&(r.system.APValue.value=r.system.APValue.value.split("/")[i.system.StF.value.charCodeAt(0)-65].trim())),!(u=t.items.find((function(t){return t.type==a&&t.name==r.name})))){d.next=25;break}if(p=duplicate(u),l=Number(/;/.test(p.system.APValue.value)?p.system.APValue.value.split(";").map((function(t){return Number(t.trim())}))[p.system.step.value]:p.system.APValue.value),d.t0=p.system.step.value+1<=p.system.max.value,!d.t0){d.next=14;break}return d.next=13,t.checkEnoughXP(l);case 13:d.t0=d.sent;case 14:if(!d.t0){d.next=23;break}return p.system.step.value+=1,l=this.addSingularVantages(t,p,l),d.next=19,t._updateAPs(l,{},{render:!1});case 19:return d.next=21,t.updateEmbeddedDocuments("Item",[p]);case 21:return d.next=23,AdvantageRulesDSA5.vantageAdded(t,p);case 23:d.next=35;break;case 25:return d.next=27,t.checkEnoughXP(l=Number(r.system.APValue.value.split(";").map((function(t){return t.trim()}))[0]));case 27:if(!d.sent){d.next=35;break}return d.next=30,AdvantageRulesDSA5.vantageAdded(t,r);case 30:return l=this.addSingularVantages(t,r,l),d.next=33,t._updateAPs(l,{},{render:!1});case 33:return d.next=35,t.createEmbeddedDocuments("Item",[r]);case 35:case"end":return d.stop()}}),_callee3,this)}))),function _vantageReturnFunction(t,r,o,i){return a.apply(this,arguments)})},{key:"needsAdoption",value:(r=_asyncToGenerator(_regeneratorRuntime().mark((function _callee4(t,r,a){var i,u,l;return _regeneratorRuntime().wrap((function _callee4$(p){for(;;)switch(p.prev=p.next){case 0:if(!o.Z.vantagesNeedingAdaption[r.name]){p.next=17;break}if("text"!=o.Z.vantagesNeedingAdaption[r.name].items){p.next=8;break}return p.next=4,renderTemplate("systems/dsa5/templates/dialog/requires-adoption-string-dialog.html",{original:r});case 4:i=p.sent,u=function callback(o){var i={name:o.find('[name="entryselection"]').val()};AdvantageRulesDSA5._vantageReturnFunction(t,r,a,i)},p.next=13;break;case 8:return l=t.items.filter((function(t){return o.Z.vantagesNeedingAdaption[r.name].items.includes(t.type)})),p.next=11,renderTemplate("systems/dsa5/templates/dialog/requires-adoption-dialog.html",{items:l,original:r});case 11:i=p.sent,u=function callback(o){var i=l.find((function(t){return t.name==o.find('[name="entryselection"]').val()}));AdvantageRulesDSA5._vantageReturnFunction(t,r,a,i)};case 13:return p.next=15,new c.Z({title:game.i18n.localize("DIALOG.ItemRequiresAdoption"),content:i,buttons:{Yes:{icon:'',label:game.i18n.localize("yes"),callback:u},cancel:{icon:'',label:game.i18n.localize("cancel")}},default:"Yes"}).render(!0);case 15:p.next=18;break;case 17:AdvantageRulesDSA5._vantageReturnFunction(t,r,a,null);case 18:case"end":return p.stop()}}),_callee4)}))),function needsAdoption(t,a,o){return r.apply(this,arguments)})},{key:"addSingularVantages",value:function addSingularVantages(t,r,a){return AdvantageRulesDSA5._calculateSingularVantages(r,t,a,(function filter(t,r,a){return"disadvantage"==t.type&&r.test(t.name)}))}},{key:"removeSingularVantages",value:function removeSingularVantages(t,r,a){return AdvantageRulesDSA5._calculateSingularVantages(r,t,a,(function filter(t,r,a){return"disadvantage"==t.type&&r.test(t.name)&&t.name!=a.name}))}},{key:"_calculateSingularVantages",value:function _calculateSingularVantages(t,r,a,o){var i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:function(t,r){return Math.min(0,t-r)};if("disadvantage"!=t.type)return a;for(var c=function _loop(){var c=l[u],p=new RegExp("^".concat(game.i18n.localize("LocalizedIDs."+c)," \\("));if(p.test(t.name)){var d=r.items.filter((function(r){return o(r,p,t)})),h=Math.min.apply(Math,[0].concat(_toConsumableArray(d.map((function(t){return AdvantageRulesDSA5.calcAPCostSum(t)}))))),m=AdvantageRulesDSA5.calcAPCostSum(t);a=i(m,h)}},u=0,l=["principles","obligations"];u2&&void 0!==arguments[2]?arguments[2]:1,o=arguments.length>3&&void 0!==arguments[3]&&arguments[3],i=arguments.length>4&&void 0!==arguments[4]&&arguments[4];return _get(_getPrototypeOf(AdvantageRulesDSA5),"itemAsModifier",this).call(this,t,r,a,["advantage","disadvantage"],o,i)}}]),AdvantageRulesDSA5}(i.Z);i.Z.children.AdvantageRulesDSA5=u},231:(t,r,a)=>{a.d(r,{Z:()=>l});var o=a(947),i=a(903),c=a(491),u=a(416);function _typeof(t){return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},_typeof(t)}function _regeneratorRuntime(){_regeneratorRuntime=function _regeneratorRuntime(){return t};var t={},r=Object.prototype,a=r.hasOwnProperty,o="function"==typeof Symbol?Symbol:{},i=o.iterator||"@@iterator",c=o.asyncIterator||"@@asyncIterator",u=o.toStringTag||"@@toStringTag";function define(t,r,a){return Object.defineProperty(t,r,{value:a,enumerable:!0,configurable:!0,writable:!0}),t[r]}try{define({},"")}catch(t){define=function define(t,r,a){return t[r]=a}}function wrap(t,r,a,o){var i=r&&r.prototype instanceof Generator?r:Generator,c=Object.create(i.prototype),u=new Context(o||[]);return c._invoke=function(t,r,a){var o="suspendedStart";return function(i,c){if("executing"===o)throw new Error("Generator is already running");if("completed"===o){if("throw"===i)throw c;return doneResult()}for(a.method=i,a.arg=c;;){var u=a.delegate;if(u){var p=maybeInvokeDelegate(u,a);if(p){if(p===l)continue;return p}}if("next"===a.method)a.sent=a._sent=a.arg;else if("throw"===a.method){if("suspendedStart"===o)throw o="completed",a.arg;a.dispatchException(a.arg)}else"return"===a.method&&a.abrupt("return",a.arg);o="executing";var d=tryCatch(t,r,a);if("normal"===d.type){if(o=a.done?"completed":"suspendedYield",d.arg===l)continue;return{value:d.arg,done:a.done}}"throw"===d.type&&(o="completed",a.method="throw",a.arg=d.arg)}}}(t,a,u),c}function tryCatch(t,r,a){try{return{type:"normal",arg:t.call(r,a)}}catch(t){return{type:"throw",arg:t}}}t.wrap=wrap;var l={};function Generator(){}function GeneratorFunction(){}function GeneratorFunctionPrototype(){}var p={};define(p,i,(function(){return this}));var d=Object.getPrototypeOf,h=d&&d(d(values([])));h&&h!==r&&a.call(h,i)&&(p=h);var m=GeneratorFunctionPrototype.prototype=Generator.prototype=Object.create(p);function defineIteratorMethods(t){["next","throw","return"].forEach((function(r){define(t,r,(function(t){return this._invoke(r,t)}))}))}function AsyncIterator(t,r){function invoke(o,i,c,u){var l=tryCatch(t[o],t,i);if("throw"!==l.type){var p=l.arg,d=p.value;return d&&"object"==_typeof(d)&&a.call(d,"__await")?r.resolve(d.__await).then((function(t){invoke("next",t,c,u)}),(function(t){invoke("throw",t,c,u)})):r.resolve(d).then((function(t){p.value=t,c(p)}),(function(t){return invoke("throw",t,c,u)}))}u(l.arg)}var o;this._invoke=function(t,a){function callInvokeWithMethodAndArg(){return new r((function(r,o){invoke(t,a,r,o)}))}return o=o?o.then(callInvokeWithMethodAndArg,callInvokeWithMethodAndArg):callInvokeWithMethodAndArg()}}function maybeInvokeDelegate(t,r){var a=t.iterator[r.method];if(void 0===a){if(r.delegate=null,"throw"===r.method){if(t.iterator.return&&(r.method="return",r.arg=void 0,maybeInvokeDelegate(t,r),"throw"===r.method))return l;r.method="throw",r.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var o=tryCatch(a,t.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,l;var i=o.arg;return i?i.done?(r[t.resultName]=i.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=void 0),r.delegate=null,l):i:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,l)}function pushTryEntry(t){var r={tryLoc:t[0]};1 in t&&(r.catchLoc=t[1]),2 in t&&(r.finallyLoc=t[2],r.afterLoc=t[3]),this.tryEntries.push(r)}function resetTryEntry(t){var r=t.completion||{};r.type="normal",delete r.arg,t.completion=r}function Context(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(pushTryEntry,this),this.reset(!0)}function values(t){if(t){var r=t[i];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var o=-1,c=function next(){for(;++o=0;--o){var i=this.tryEntries[o],c=i.completion;if("root"===i.tryLoc)return handle("end");if(i.tryLoc<=this.prev){var u=a.call(i,"catchLoc"),l=a.call(i,"finallyLoc");if(u&&l){if(this.prev=0;--o){var i=this.tryEntries[o];if(i.tryLoc<=this.prev&&a.call(i,"finallyLoc")&&this.prev=0;--r){var a=this.tryEntries[r];if(a.finallyLoc===t)return this.complete(a.completion,a.afterLoc),resetTryEntry(a),l}},catch:function _catch(t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc===t){var o=a.completion;if("throw"===o.type){var i=o.arg;resetTryEntry(a)}return i}}throw new Error("illegal catch attempt")},delegateYield:function delegateYield(t,r,a){return this.delegate={iterator:values(t),resultName:r,nextLoc:a},"next"===this.method&&(this.arg=void 0),l}},t}function asyncGeneratorStep(t,r,a,o,i,c,u){try{var l=t[c](u),p=l.value}catch(t){return void a(t)}l.done?r(p):Promise.resolve(p).then(o,i)}function _asyncToGenerator(t){return function(){var r=this,a=arguments;return new Promise((function(o,i){var c=t.apply(r,a);function _next(t){asyncGeneratorStep(c,o,i,_next,_throw,"next",t)}function _throw(t){asyncGeneratorStep(c,o,i,_next,_throw,"throw",t)}_next(void 0)}))}}function _defineProperties(t,r){for(var a=0;a1&&void 0!==arguments[1]?arguments[1]:void 0;t=t.replace(/(-|\+)?\d+/g,"").trim();var a=DSA5ChatAutoCompletion.skills.filter((function(a){return-1!=a.name.toLowerCase().trim().indexOf(t)&&(null==r||r==a.type)})).slice(0,5);return this._checkEmpty(a),a}},{key:"_filterCH",value:function _filterCH(t,r){this._setList(this._getSkills(t),"CH",r)}},{key:"_filterSK",value:function _filterSK(t,r){this._setList(this._getSkills(t),"SK",r)}},{key:"_filterRQ",value:function _filterRQ(t,r){this._setList(this._getSkills(t),"RQ",r)}},{key:"_filterGC",value:function _filterGC(t,r){this._setList(this._getSkills(t,"skill"),"GC",r)}},{key:"_setList",value:function _setList(t,r,a){var o=$('
      '.concat(t.map((function(t){return'
    • ').concat(t.name,"
    • ")})).join(""),"
    "));o.find(".quick-item:first").addClass("focus");var i=$(a.currentTarget).closest("#chat-form"),c=i.find(".quickfind");c.length?c.replaceWith(o):i.append(o)}},{key:"_navigateQuickFind",value:function _navigateQuickFind(t){if(this.filtering){var r=$(t.currentTarget).closest("#chat-form").find(".focus");switch(t.which){case 38:return r.prev(".quick-item").length&&r.removeClass("focus").prev(".quick-item").addClass("focus"),!1;case 40:return r.next(".quick-item").length&&r.removeClass("focus").next(".quick-item").addClass("focus"),!1;case 13:if("W"==r.attr("data-category"))break;return t.stopPropagation(),t.preventDefault(),this._quickSelect(r),!1;case 9:return t.stopPropagation(),t.preventDefault(),this._completeCurrentEntry(r),!1}}return!0}},{key:"_quickSelect",value:function _quickSelect(t){var r=t.attr("data-category");switch(r){case"NM":case"GC":case"RQ":case"CH":this["_quick".concat(r)](t);break;case"W":this._completeCurrentEntry(t);break;default:var a=DSA5ChatAutoCompletion._getActor(),o=a.actor,i=a.tokenId;o&&(this._resetChatAutoCompletion(t),this["_quick".concat(r)](t,o,i))}}},{key:"_quickW",value:function _quickW(t,r,a){}},{key:"_quickCH",value:function _quickCH(t){o.Z.check3D20(t),this._resetChatAutoCompletion(t)}},{key:"_quickSK",value:function _quickSK(t,r,a){switch(t.attr("data-type")){case"skill":var o=r.items.find((function(r){return r.name==t.text()&&"skill"==r.type}));o&&r.setupSkill(o,{},a).then((function(t){r.basicTest(t)}));break;case"attribute":var i=Object.keys(game.dsa5.config.characteristics).find((function(r){return game.i18n.localize(game.dsa5.config.characteristics[r])==t.text()}));r.setupCharacteristic(i,{},a).then((function(t){r.basicTest(t)}));break;case"regeneration":r.setupRegeneration("regenerate",{},a).then((function(t){r.basicTest(t)}))}}},{key:"_resetChatAutoCompletion",value:function _resetChatAutoCompletion(t){var r=t.closest("#chat-form");r.find("#chat-message").val(""),r.find(".quickfind").remove()}},{key:"_quickGC",value:function _quickGC(t){var r=Number($("#chat-message").val().match(/(-|\+)?\d+/g))||0;this._resetChatAutoCompletion(t),i.Z.showGCMessage(t.text(),r)}},{key:"_quickRQ",value:function _quickRQ(t){var r=Number($("#chat-message").val().match(/(-|\+)?\d+/g))||0;this._resetChatAutoCompletion(t),i.Z.showRQMessage(t.text(),r)}},{key:"_quickPA",value:function _quickPA(t,r,a){var o=t.text();if(this.combatConstants.dodge==o)r.setupDodge({},a).then((function(t){r.basicTest(t)}));else if(this.combatConstants.parryWeaponless==o)r.setupWeaponless("parry",{},a).then((function(t){r.basicTest(t)}));else{var i=["meleeweapon"],c=r.items.find((function(r){return i.includes(r.type)&&r.name==t.text()}));c&&r.setupWeapon(c,"parry",{},a).then((function(t){r.basicTest(t)}))}}},{key:"_quickAT",value:function _quickAT(t,r,a){var o=t.text();if(this.combatConstants.attackWeaponless==o)r.setupWeaponless("attack",{},a).then((function(t){r.basicTest(t)}));else{var i=["meleeweapon","rangeweapon"],c=["meleeAttack","rangeAttack"],u=r.items.find((function(r){return i.includes(r.type)&&r.name==t.text()}));u||(u=r.items.find((function(r){return"trait"==r.type&&r.name==t.text()&&c.includes(r.system.traitType.value)}))),u&&r.setupWeapon(u,"attack",{},a).then((function(t){r.basicTest(t)}))}}},{key:"_quickSP",value:function _quickSP(t,r,a){var o=["ritual","spell"],i=r.items.find((function(r){return o.includes(r.type)&&r.name==t.text()}));i&&r.setupSpell(i,{},a).then((function(t){r.basicTest(t)}))}},{key:"_quickLI",value:function _quickLI(t,r,a){var o=["liturgy","ceremony"],i=r.items.find((function(r){return o.includes(r.type)&&r.name==t.text()}));i&&r.setupSpell(i,{},a).then((function(t){r.basicTest(t)}))}}],[{key:"_getActor",value:function _getActor(){var t,r=ChatMessage.getSpeaker();return r.token&&(t=game.actors.tokens[r.token]),t||(t=game.actors.get(r.actor)),t?{actor:t,tokenId:r.token}:(ui.notifications.error(game.i18n.localize("DSAError.noProperActor")),{})}},{key:"infoItemAsync",value:(t=_asyncToGenerator(_regeneratorRuntime().mark((function _callee4(t){return _regeneratorRuntime().wrap((function _callee4$(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,fromUuid(t);case 2:r.sent.postItem();case 4:case"end":return r.stop()}}),_callee4)}))),function infoItemAsync(r){return t.apply(this,arguments)})},{key:"bindRollCommands",value:function bindRollCommands(t){var r=this;t.on("click",".request-roll",(function(t){return i.Z.showRQMessage(t.currentTarget.dataset.name,Number(t.currentTarget.dataset.modifier)||0),t.stopPropagation(),!1})),t.on("click",".postInfo",(function(t){var a=fromUuidSync(t.currentTarget.dataset.uuid);return a&&("function"==typeof a.postItem?a.postItem():r.infoItemAsync(t.currentTarget.dataset.uuid)),t.stopPropagation(),!1})),t.on("click",".postContentChat",function(){var t=_asyncToGenerator(_regeneratorRuntime().mark((function _callee5(t){var r;return _regeneratorRuntime().wrap((function _callee5$(a){for(;;)switch(a.prev=a.next){case 0:r=$(t.currentTarget).closest(".postChatSection").find(".postChatContent").html(),u.TB.getDialog(r);case 2:case"end":return a.stop()}}),_callee5)})));return function(r){return t.apply(this,arguments)}}()),t.on("click",".request-GC",(function(t){return i.Z.showGCMessage(t.currentTarget.dataset.name,Number(t.currentTarget.dataset.modifier)||0),t.stopPropagation(),!1})),t.on("click",".request-CH",(function(t){return o.Z.check3D20(void 0,t.currentTarget.dataset.name,{modifier:Number(t.currentTarget.dataset.modifier)||0}),t.stopPropagation(),!1}))}}]),DSA5ChatAutoCompletion}();_defineProperty(l,"skills",[]),_defineProperty(l,"cmds",["sk","at","pa","sp","li","rq","gc","w","ch"])},947:(t,r,a)=>{a.d(r,{Z:()=>p});var o=a(577),i=a(491),c=a(586),u=a(122),l=a(147);function _typeof(t){return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},_typeof(t)}function _regeneratorRuntime(){_regeneratorRuntime=function _regeneratorRuntime(){return t};var t={},r=Object.prototype,a=r.hasOwnProperty,o="function"==typeof Symbol?Symbol:{},i=o.iterator||"@@iterator",c=o.asyncIterator||"@@asyncIterator",u=o.toStringTag||"@@toStringTag";function define(t,r,a){return Object.defineProperty(t,r,{value:a,enumerable:!0,configurable:!0,writable:!0}),t[r]}try{define({},"")}catch(t){define=function define(t,r,a){return t[r]=a}}function wrap(t,r,a,o){var i=r&&r.prototype instanceof Generator?r:Generator,c=Object.create(i.prototype),u=new Context(o||[]);return c._invoke=function(t,r,a){var o="suspendedStart";return function(i,c){if("executing"===o)throw new Error("Generator is already running");if("completed"===o){if("throw"===i)throw c;return doneResult()}for(a.method=i,a.arg=c;;){var u=a.delegate;if(u){var p=maybeInvokeDelegate(u,a);if(p){if(p===l)continue;return p}}if("next"===a.method)a.sent=a._sent=a.arg;else if("throw"===a.method){if("suspendedStart"===o)throw o="completed",a.arg;a.dispatchException(a.arg)}else"return"===a.method&&a.abrupt("return",a.arg);o="executing";var d=tryCatch(t,r,a);if("normal"===d.type){if(o=a.done?"completed":"suspendedYield",d.arg===l)continue;return{value:d.arg,done:a.done}}"throw"===d.type&&(o="completed",a.method="throw",a.arg=d.arg)}}}(t,a,u),c}function tryCatch(t,r,a){try{return{type:"normal",arg:t.call(r,a)}}catch(t){return{type:"throw",arg:t}}}t.wrap=wrap;var l={};function Generator(){}function GeneratorFunction(){}function GeneratorFunctionPrototype(){}var p={};define(p,i,(function(){return this}));var d=Object.getPrototypeOf,h=d&&d(d(values([])));h&&h!==r&&a.call(h,i)&&(p=h);var m=GeneratorFunctionPrototype.prototype=Generator.prototype=Object.create(p);function defineIteratorMethods(t){["next","throw","return"].forEach((function(r){define(t,r,(function(t){return this._invoke(r,t)}))}))}function AsyncIterator(t,r){function invoke(o,i,c,u){var l=tryCatch(t[o],t,i);if("throw"!==l.type){var p=l.arg,d=p.value;return d&&"object"==_typeof(d)&&a.call(d,"__await")?r.resolve(d.__await).then((function(t){invoke("next",t,c,u)}),(function(t){invoke("throw",t,c,u)})):r.resolve(d).then((function(t){p.value=t,c(p)}),(function(t){return invoke("throw",t,c,u)}))}u(l.arg)}var o;this._invoke=function(t,a){function callInvokeWithMethodAndArg(){return new r((function(r,o){invoke(t,a,r,o)}))}return o=o?o.then(callInvokeWithMethodAndArg,callInvokeWithMethodAndArg):callInvokeWithMethodAndArg()}}function maybeInvokeDelegate(t,r){var a=t.iterator[r.method];if(void 0===a){if(r.delegate=null,"throw"===r.method){if(t.iterator.return&&(r.method="return",r.arg=void 0,maybeInvokeDelegate(t,r),"throw"===r.method))return l;r.method="throw",r.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var o=tryCatch(a,t.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,l;var i=o.arg;return i?i.done?(r[t.resultName]=i.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=void 0),r.delegate=null,l):i:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,l)}function pushTryEntry(t){var r={tryLoc:t[0]};1 in t&&(r.catchLoc=t[1]),2 in t&&(r.finallyLoc=t[2],r.afterLoc=t[3]),this.tryEntries.push(r)}function resetTryEntry(t){var r=t.completion||{};r.type="normal",delete r.arg,t.completion=r}function Context(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(pushTryEntry,this),this.reset(!0)}function values(t){if(t){var r=t[i];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var o=-1,c=function next(){for(;++o=0;--o){var i=this.tryEntries[o],c=i.completion;if("root"===i.tryLoc)return handle("end");if(i.tryLoc<=this.prev){var u=a.call(i,"catchLoc"),l=a.call(i,"finallyLoc");if(u&&l){if(this.prev=0;--o){var i=this.tryEntries[o];if(i.tryLoc<=this.prev&&a.call(i,"finallyLoc")&&this.prev=0;--r){var a=this.tryEntries[r];if(a.finallyLoc===t)return this.complete(a.completion,a.afterLoc),resetTryEntry(a),l}},catch:function _catch(t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc===t){var o=a.completion;if("throw"===o.type){var i=o.arg;resetTryEntry(a)}return i}}throw new Error("illegal catch attempt")},delegateYield:function delegateYield(t,r,a){return this.delegate={iterator:values(t),resultName:r,nextLoc:a},"next"===this.method&&(this.arg=void 0),l}},t}function asyncGeneratorStep(t,r,a,o,i,c,u){try{var l=t[c](u),p=l.value}catch(t){return void a(t)}l.done?r(p):Promise.resolve(p).then(o,i)}function _asyncToGenerator(t){return function(){var r=this,a=arguments;return new Promise((function(o,i){var c=t.apply(r,a);function _next(t){asyncGeneratorStep(c,o,i,_next,_throw,"next",t)}function _throw(t){asyncGeneratorStep(c,o,i,_next,_throw,"throw",t)}_next(void 0)}))}}function _defineProperties(t,r){for(var a=0;a');r.click((function(){DSA5ChatListeners.getHelp()})),$(t.find(".control-buttons")).prepend(r),t.on("click",".showPatchViewer",(function(){return(0,c.j)()})),t.on("click",".functionswitch",(function(t){return u.Z[t.currentTarget.dataset.function](t)})),t.on("click",".panToToken",(function(t){return DSA5ChatListeners.panToToken(t)})),t.on("click",".popoutImage",(function(t){return(0,l.d)(t)}))}},{key:"panToToken",value:(a=_asyncToGenerator(_regeneratorRuntime().mark((function _callee(t){var r;return _regeneratorRuntime().wrap((function _callee$(a){for(;;)switch(a.prev=a.next){case 0:return a.next=2,fromUuid(t.currentTarget.dataset.uuid);case 2:if(r=a.sent){a.next=5;break}return a.abrupt("return");case 5:if(canvas.animatePan({x:r.x,y:r.y}),r.isOwner){a.next=8;break}return a.abrupt("return");case 8:r.object.control({releaseOthers:!0});case 9:case"end":return a.stop()}}),_callee)}))),function panToToken(t){return a.apply(this,arguments)})},{key:"postStatus",value:function postStatus(t){var r=CONFIG.statusEffects.find((function(r){return r.id==t})),a='

    ').concat(game.i18n.localize(r.name),"

    ").concat(game.i18n.localize(r.description),"

    ");ChatMessage.create(i.Z.chatDataSetup(a,"roll"))}},{key:"getHelp",value:function getHelp(){var t=o.Z.helpContent.map((function(t){return"

    ".concat(game.i18n.localize("HELP.".concat(t.name)),"

    \n

    ").concat(game.i18n.localize("HELP.command"),": ").concat(t.command,"

    \n

    ").concat(game.i18n.localize("HELP.example"),": ").concat(t.example,"

    \n

    ").concat(game.i18n.localize("Description"),": ").concat(game.i18n.localize("HELP.descr".concat(t.name)))})).join("")+"
    \n

    ".concat(game.i18n.localize("HELP.default"),"

    ");ChatMessage.create(i.Z.chatDataSetup(t,"roll"))}},{key:"showConditions",value:function showConditions(){var t=duplicate(CONFIG.statusEffects).map((function(t){return t.name=game.i18n.localize(t.name),t})).sort((function(t,r){return t.name.localeCompare(r.name)})).map((function(t){return'').concat(t.name,"")})).join(" ");ChatMessage.create(i.Z.chatDataSetup(t,"roll"))}},{key:"check3D20",value:(r=_asyncToGenerator(_regeneratorRuntime().mark((function _callee2(t,r){var a,o,c,u=arguments;return _regeneratorRuntime().wrap((function _callee2$(l){for(;;)switch(l.prev=l.next){case 0:if(a=u.length>2&&void 0!==u[2]?u[2]:{},o=12,!t){l.next=10;break}return t=t.get(0),l.next=6,i.Z.skillByName(t.textContent);case 6:r=l.sent,t.dataset.attrs&&(o=t.dataset.attrs.split("|")),l.next=14;break;case 10:if(!r){l.next=14;break}return l.next=13,i.Z.skillByName(r);case 13:r=l.sent;case 14:return r&&(r=r.toObject()),r||(r={name:"3d20",type:"skill",system:{talentValue:{value:0},characteristic1:{value:"mu"},characteristic2:{value:"kl"},characteristic3:{value:"in"},RPr:{value:"no"},burden:{value:"no"}}}),l.next=18,i.Z.emptyActor(o);case 18:(c=l.sent).setupSkill(r,a,"emptyActor").then((function(t){c.basicTest(t)}));case 20:case"end":return l.stop()}}),_callee2)}))),function check3D20(t,a){return r.apply(this,arguments)})},{key:"showTables",value:(t=_asyncToGenerator(_regeneratorRuntime().mark((function _callee3(){var t;return _regeneratorRuntime().wrap((function _callee3$(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,renderTemplate("systems/dsa5/templates/tables/systemtables.html",{tables:o.Z.systemTables});case 2:t=r.sent,ChatMessage.create(i.Z.chatDataSetup(t,"roll"));case 4:case"end":return r.stop()}}),_callee3)}))),function showTables(){return t.apply(this,arguments)})}]),DSA5ChatListeners}()},577:(t,r,a)=>{a.d(r,{Z:()=>i});var o={statusEffects:[{icon:"icons/svg/skull.svg",id:"dead",name:"CONDITION.defeated",label:"CONDITION.defeated",description:"CONDITIONDESCRIPTION.defeated",flags:{dsa5:{value:null,editable:!0}}},{id:"inpain",name:"CONDITION.inpain",icon:"icons/svg/blood.svg",description:"CONDITIONDESCRIPTION.inpain",changes:[{key:"system.condition.inpain",mode:2,value:1}],flags:{dsa5:{value:1,editable:!0,max:4}}},{id:"prone",name:"CONDITION.prone",icon:"icons/svg/falling.svg",description:"CONDITIONDESCRIPTION.prone",flags:{dsa5:{value:null,editable:!0}}},{id:"unconscious",name:"CONDITION.unconscious",icon:"icons/svg/unconscious.svg",description:"CONDITIONDESCRIPTION.unconscious",flags:{dsa5:{value:null,editable:!0}}},{id:"rooted",name:"CONDITION.rooted",icon:"icons/svg/net.svg",description:"CONDITIONDESCRIPTION.rooted",flags:{dsa5:{value:null,editable:!0}}},{id:"fixated",name:"CONDITION.fixated",icon:"icons/svg/padlock.svg",description:"CONDITIONDESCRIPTION.fixated",flags:{dsa5:{value:null,editable:!0}}},{id:"surprised",name:"CONDITION.surprised",icon:"icons/svg/hazard.svg",description:"CONDITIONDESCRIPTION.surprised",flags:{dsa5:{value:null,editable:!0}}},{id:"blind",name:"CONDITION.blind",icon:"icons/svg/blind.svg",description:"CONDITIONDESCRIPTION.blind",flags:{dsa5:{value:null,editable:!0}}},{id:"poisoned",name:"CONDITION.poisoned",icon:"icons/svg/poison.svg",description:"CONDITIONDESCRIPTION.poisoned",flags:{dsa5:{value:null,editable:!0}}},{id:"sick",name:"CONDITION.sick",icon:"icons/svg/biohazard.svg",description:"CONDITIONDESCRIPTION.sick",flags:{dsa5:{value:null,editable:!0}}},{id:"deaf",name:"CONDITION.deaf",icon:"icons/svg/deaf.svg",description:"CONDITIONDESCRIPTION.deaf",flags:{dsa5:{value:null,editable:!0}}},{id:"burning",name:"CONDITION.burning",icon:"icons/svg/fire.svg",description:"CONDITIONDESCRIPTION.burning",flags:{dsa5:{value:1,editable:!0,max:3}}},{id:"invisible",name:"CONDITION.invisible",icon:"icons/svg/circle.svg",description:"CONDITIONDESCRIPTION.invisible",flags:{dsa5:{value:null,editable:!0}}},{id:"constricted",name:"CONDITION.constricted",icon:"icons/svg/cave.svg",description:"CONDITIONDESCRIPTION.constricted",flags:{dsa5:{value:null,editable:!0}}},{id:"bloodrush",name:"CONDITION.bloodrush",icon:"icons/svg/bones.svg",description:"CONDITIONDESCRIPTION.bloodrush",changes:[{key:"system.skillModifiers.step",mode:0,value:"Kraftakt 2;Feat of Strength 2"}],flags:{dsa5:{value:null,editable:!0}}},{id:"mute",name:"CONDITION.mute",icon:"icons/svg/silenced.svg",description:"CONDITIONDESCRIPTION.mute",flags:{dsa5:{value:null,editable:!0}}},{id:"incapacitated",name:"CONDITION.incapacitated",icon:"icons/svg/sleep.svg",description:"CONDITIONDESCRIPTION.incapacitated",flags:{dsa5:{value:null,editable:!0}}},{id:"encumbered",name:"CONDITION.encumbered",icon:"icons/svg/anchor.svg",changes:[{key:"system.condition.encumbered",mode:2,value:1}],description:"CONDITIONDESCRIPTION.encumbered",flags:{dsa5:{value:1,editable:!0,max:4}}},{id:"stunned",name:"CONDITION.stunned",icon:"icons/svg/daze.svg",changes:[{key:"system.condition.stunned",mode:2,value:1}],description:"CONDITIONDESCRIPTION.stunned",flags:{dsa5:{value:1,editable:!0,max:4}}},{id:"raptured",name:"CONDITION.raptured",icon:"icons/svg/ice-aura.svg",changes:[{key:"system.condition.raptured",mode:2,value:1}],description:"CONDITIONDESCRIPTION.raptured",flags:{dsa5:{value:1,editable:!0,max:4}}},{id:"feared",name:"CONDITION.feared",icon:"icons/svg/terror.svg",description:"CONDITIONDESCRIPTION.feared",changes:[{key:"system.condition.feared",mode:2,value:1}],flags:{dsa5:{value:1,editable:!0,max:4}}},{id:"paralysed",name:"CONDITION.paralysed",icon:"icons/svg/paralysis.svg",description:"CONDITIONDESCRIPTION.paralysed",changes:[{key:"system.condition.paralysed",mode:2,value:1}],flags:{dsa5:{value:1,editable:!0,max:4}}},{id:"confused",name:"CONDITION.confused",icon:"icons/svg/stoned.svg",description:"CONDITIONDESCRIPTION.confused",changes:[{key:"system.condition.confused",mode:2,value:1}],flags:{dsa5:{value:1,editable:!0,max:4}}},{id:"minorSpirits",name:"CONDITION.minorSpirits",icon:"icons/svg/terror.svg",description:"CONDITIONDESCRIPTION.minorSpirits",changes:[{key:"system.skillModifiers.global",mode:0,value:-1}],duration:{seconds:600},flags:{dsa5:{value:null,editable:!0}}},{id:"services",name:"PLAYER.services",icon:"icons/svg/aura.svg",description:"CONDITIONDESCRIPTION.services",flags:{dsa5:{value:1,editable:!0,max:500,hideOnToken:!0}}}],armorSubcategories:{0:4,1:5,2:6,3:8,4:9,5:13,6:12,7:11,8:10},weaponStabilities:{Blowpipes:10,Bows:4,Brawling:12,"Chain Weapons":10,Crossbows:6,Daggers:14,Discuses:12,Fans:13,"Fencing Weapons":8,"Impact Weapons":12,Lances:6,Pikes:12,Polearms:12,Shields:10,Slingshots:4,Swords:13,"Throwing Weapons":10,"Two-Handed Impact Weapons":11,"Two-Handed Swords":12,Whips:4},journalFontSizes:[8,10,12,14,16,18,20,24,28,32],styles:{"dsa5-immersive":"dsaStyle.immersive","dsa5-naked":"dsaStyle.naked"},fallingConditions:{normal:0,soft1:-1,soft2:-2,soft3:-3,soft4:-4,rough1:1,rough2:2,rough3:3,rough4:4},combatSkillSubCategories:{0:"COMBATSKILLCATEGORY.0",1:"COMBATSKILLCATEGORY.1",2:"COMBATSKILLCATEGORY.2",3:"COMBATSKILLCATEGORY.3",4:"COMBATSKILLCATEGORY.4"}};o.effectTextStyle=CONFIG.canvasTextStyle.clone(),o.effectTextStyle.fontSize="30",o.effectTextStyle.fontFamily="GentiumBasic",o.knownShortcuts={},o.gearModifyableCalculatedAttributes=["fatePoints","initiative","speed","astralenergy","karmaenergy","wounds","dodge","soulpower","toughness"],o.defaultWeapon={name:"default",type:"meleeweapon",effects:[],system:{type:"meleeweapon",crit:1,botch:20,reach:{value:"short"},damage:{value:"1d6"},atmod:{value:0,offHandMod:0},pamod:{value:0,offHandMod:0},guidevalue:{value:"ge/kk"},damageThreshold:{value:"5000"},worn:{offhand:!1}}},o.asyncHooks={postProcessDSARoll:[]},o.characteristics={mu:"CHAR.MU",kl:"CHAR.KL",in:"CHAR.IN",ch:"CHAR.CH",ff:"CHAR.FF",ge:"CHAR.GE",ko:"CHAR.KO",kk:"CHAR.KK"},o.equipmentTypes={misc:"Equipment.misc",clothes:"Equipment.clothes",tools:"Equipment.tools",light:"Equipment.light",healing:"Equipment.healing",bags:"Equipment.bags",wealth:"Equipment.wealth",writing:"Equipment.writing",alchemy:"Equipment.alchemy",service:"Equipment.service",luxus:"Equipment.luxus",blessed:"Equipment.blessed",food:"Equipment.food"},o.equipmentCategories=["meleeweapon","rangeweapon","equipment","ammunition","armor","poison","consumable","plant"],o.systemTables=[{name:"Defense",attrs:'data-weaponless="false"',roll:"botch-roll",pack:{de:"dsa5.patzer",en:"dsa5.botch"},setting:{module:"dsa5",key:"defenseBotchTableEnabled"}},{name:"Melee",attrs:'data-weaponless="false"',roll:"botch-roll",pack:{de:"dsa5.patzer",en:"dsa5.botch"},setting:{module:"dsa5",key:"meleeBotchTableEnabled"}},{name:"Range",attrs:'data-weaponless="false"',roll:"botch-roll",pack:{de:"dsa5.patzer",en:"dsa5.botch"},setting:{module:"dsa5",key:"rangeBotchTableEnabled"}},{name:"Liturgy",attrs:"",roll:"botch-roll",pack:{de:"dsa5.patzer",en:"dsa5.botch"},setting:{module:"",key:""}},{name:"Spell",attrs:"",roll:"botch-roll",pack:{de:"dsa5.patzer",en:"dsa5.botch"},setting:{module:"",key:""}}],o.morePackages={packages:{},names:{de:[],en:[]}},o.narrowSpaceModifiers={weaponshort:{attack:0,parry:0,label:"NarrowSpaceModifiers.weapon.short"},weaponmedium:{attack:-4,parry:-4,label:"NarrowSpaceModifiers.weapon.medium"},weaponlong:{attack:-8,parry:-8,label:"NarrowSpaceModifiers.weapon.long"},shieldshort:{attack:-2,parry:-2,label:"NarrowSpaceModifiers.shield.short"},shieldmedium:{attack:-4,parry:-3,label:"NarrowSpaceModifiers.shield.medium"},shieldlong:{attack:-6,parry:-4,label:"NarrowSpaceModifiers.shield.long"}},o.traditionArtifacts={Animistenwaffe:15,Bannschwert:15,Druidendolch:15,Druidensichel:12,Zauberkleidung:15,Magierkugel:12,Zauberinstrument:15,Narrenkappe:15,Hexenkessel:15,Krallenkette:12,Lebensring:12,Alchimistenschale:15,"Scharlatanische Zauberkugel":15,Sippenchronik:15,Schelmenspielzeug:12,Zauberstecken:0,Magierstab:18,Trinkhorn:12,Schuppenbeutel:18,"Kristallomantische Kristallkugel":15,Echsenhaube:12},o.moneyNames={D:"Money-D",S:"Money-S",H:"Money-H",K:"Money-K"},o.areaTargetTypes={cube:"rect",line:"ray",sphere:"circle",cone:"cone"},o.rangeMods={short:{damage:1,attack:2},medium:{damage:0,attack:0},long:{damage:-1,attack:-2},rangesense:{damage:-1,attack:-1},extreme:{damage:-2,attack:-4}},o.regnerationCampLocations={0:"regnerationCampLocations.normal","-1":"regnerationCampLocations.bad",1:"regnerationCampLocations.good"},o.regenerationInterruptOptions={0:"regenerationInterruptOptions.none","-1":"regenerationInterruptOptions.small","-2":"regenerationInterruptOptions.big"},o.targetMomevementOptions={0:"rangeMovementOptions.SLOW","-2":"rangeMovementOptions.FAST",2:"rangeMovementOptions.STATIONARY"},o.allowedforeignfields=["system.details.notes.value"],o.shooterMovementOptions={0:"rangeMovementOptions.SHOOTERSTATIONARY","-2":"rangeMovementOptions.SHOOTERMOVING","-4":"rangeMovementOptions.SHOOTERRUNNING"},o.mountedRangeOptionsSpecAb={STATIONARY:"0",SCHRITT:"0",TROT:"-5000",GALOPP:"-4"},o.mountedRangeOptions={STATIONARY:"0",SCHRITT:"-4",TROT:"-5000",GALOPP:"-8"},o.drivingArcherOptions={STATIONARY:"0",SCHRITT:"-2",GALOPP:"-4"},o.aimOptions={0:"aimOptions.0",2:"aimOptions.1",4:"aimOptions.2"},o.traitCategories={meleeAttack:"closeCombatAttacks",rangeAttack:"rangeCombatAttacks",armor:"armor",general:"general",familiar:"familiar",trick:"trick",training:"training",entity:"entityAbility",summoning:"summoningPackage"},o.ritualLocationModifiers={0:"-",1:"RITUALMODIFIER.holysite","-3":"RITUALMODIFIER.wrongsite"},o.ritualTimeModifiers={0:"-",1:"RITUALMODIFIER.matchingConstellation","-1":"RITUALMODIFIER.wrongConstellation"},o.ceremonyLocationModifiers={0:"-",2:"CEREMONYMODIFIER.holysite",1:"CEREMONYMODIFIER.temple","-1":"CEREMONYMODIFIER.otherTemple","-2":"CEREMONYMODIFIER.enemyGod","-3":"CEREMONYMODIFIER.archDemon","-4":"CEREMONYMODIFIER.nameless","-5":"CEREMONYMODIFIER.nemesis"},o.advancementCosts={A:[1,1,1,1,1,1,1,1,1,1,1,1,1,2,3,4,5,6,7,8,9,10,11,12,13,14],B:[2,2,2,2,2,2,2,2,2,2,2,2,2,4,6,8,10,12,14,16,18,20,22,24,26,28],C:[3,3,3,3,3,3,3,3,3,3,3,3,3,6,9,12,15,18,21,24,27,30,33,36,39,42],D:[4,4,4,4,4,4,4,4,4,4,4,4,4,8,12,16,20,24,28,32,36,40,44,48,52,56],E:[15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,30,45,60,75,90,105,120,135,150,165,180]},o.hooks={},o.startXP={900:"EXP.inexperienced",1e3:"EXP.average",1100:"EXP.experienced",1200:"EXP.competent",1400:"EXP.masterful",1700:"EXP.brillant",2100:"EXP.legendary"},o.helpContent=[{name:"pay",command:"/pay [0-9]+",example:"/pay 5.03"},{name:"getPaid",command:"/getPaid [0-9]+",example:"/getPaid 5.03"},{name:"quickAbility",command:"/sk [a-z]*, /sp [a-z]*, /li [a-z]*, /at [a-z]*, /pa [a-z]*",example:"/sk betören"},{name:"conditions",command:"/conditions",example:"/conditions"},{name:"tables",command:"/tables",example:"/tables"},{name:"request",command:"/rq",example:"/rq betören"},{name:"threeD20Check",command:"/ch",example:"/ch"},{name:"groupcheck",command:"/gc",example:"/gc"}],o.ceremonyTimeModifiers={0:"-",1:"CEREMONYMODIFIER.monthGod",2:"CEREMONYMODIFIER.celebration","-5":"CEREMONYMODIFIER.namelessDays"},o.mageLevels={mundane:"mundane",clerical:"clerical",magical:"magical"},o.specialAbilityCategories={general:"general",Combat:"Combat",fatePoints:"fatePoints",magical:"magical",clerical:"clerical",language:"language",animal:"animal",staff:"traditionArtifact",ceremonial:"ceremonialItem",pact:"pactgift"},o.addvantageRules={},o.removevantageRules={},o.vantagesNeedingAdaption={},o.addAbilityRules={},o.removeAbilityRules={},o.AbilitiesNeedingAdaption={},o.addTraitRules={},o.rangeWeaponModifiers={short:"RangeMod.short",medium:"RangeMod.medium",long:"RangeMod.long",rangesense:"RangeMod.rangesense",extreme:"RangeMod.extreme"},o.meleeRangesArray=["short","medium","long"],o.meleeRanges={short:"Range-short",medium:"Range-medium",long:"Range-long"},o.weapontypes={melee:"meleeweapon",range:"rangeweapon"},o.ammunitiongroups={"-":"-",arrow:"arrow",bolt:"bolt",bullet:"bullet",stone:"stone",dart:"dart",mag:"mag",infinite:"infinite"},o.combatskillsGuidevalues={ff:"CHAR.FF",ge:"CHAR.GE",kk:"CHAR.KK","ge/kk":"CHAR.GEKK"},o.skillDifficultyModifiers={eeasy:5,veasy:3,easy:1,challenging:0,difficult:-1,hard:-3,vhard:-5},o.magicResistanceModifiers={"-":"-",SK:"soulpower",ZK:"toughness"},o.sizeCategories={tiny:"SIZE.tiny",small:"SIZE.small",average:"SIZE.average",big:"SIZE.big",giant:"SIZE.giant"},o.tokenSizeCategories={tiny:.5,small:.8,average:1,big:2,giant:4},o.rangeSizeCategories={tiny:"RANGESIZE.tiny",small:"RANGESIZE.small",average:"RANGESIZE.average",big:"RANGESIZE.big",giant:"RANGESIZE.giant"},o.meleeSizeCategories={tiny:"MELEESIZE.tiny",small:"MELEESIZE.small",average:"MELEESIZE.average",big:"MELEESIZE.big",giant:"MELEESIZE.giant"},o.shieldSizes={short:"SIZE.small",medium:"SIZE.average",long:"SIZE.big"},o.rangeSizeModifier={tiny:-8,small:-4,average:0,big:4,giant:8},o.meleeSizeModifier={tiny:-4,small:0,average:0,big:0,giant:0},o.rangeVision={0:"VisionDisruption.step0","-2":"VisionDisruption.step1","-4":"VisionDisruption.step2","-6":"VisionDisruption.step3","-5000":"VisionDisruption.step4"},o.meleeRangeVision=function(t){return function _defineProperty(t,r,a){return r in t?Object.defineProperty(t,r,{value:a,enumerable:!0,configurable:!0,writable:!0}):t[r]=a,t}({"+0":"meleeVisionDisruption.0","-1":"meleeVisionDisruption.1","-2":"meleeVisionDisruption.2","-3":"meleeVisionDisruption.3"},"attack"==t?"*0,5":"-5000","meleeVisionDisruption.4")},o.attributeDifficultyModifiers={eeasy:6,veasy:4,easy:2,challenging:0,difficult:-2,hard:-4,vhard:-6},o.skillDifficultyLabels={eeasy:"Skill-eeasy",veasy:"Skill-veasy",easy:"Skill-easy",challenging:"Skill-challenging",difficult:"Skill-difficult",hard:"Skill-hard",vhard:"Skill-vhard"},o.attributeDifficultyLabels={eeasy:"Attribute-eeasy",veasy:"Attribute-veasy",easy:"Attribute-easy",challenging:"Attribute-challenging",difficult:"Attribute-difficult",hard:"Attribute-hard",vhard:"Attribute-vhard"},o.skillGroups={body:"SKILL.body",social:"SKILL.social",knowledge:"SKILL.knowledge",trade:"SKILL.trade",nature:"SKILL.nature"},o.features=["Object","Spheres","Influence","Clairvoyance","Healing","Transformation","Telekinesis","Elemental","Illusion","Anti-Magic","Demonic","Temporal"],o.skillBurdens={yes:"yes",no:"no",maybe:"maybe"},o.StFs={A:"A",B:"B",C:"C",D:"D"},o.noteIcons={"Griffin Shield":"systems/dsa5/icons/thirdparty/griffinshield.svg","At Sea":"systems/dsa5/icons/thirdparty/at-sea.svg","Medieval Gate":"systems/dsa5/icons/thirdparty/medieval-gate.svg","Position Marker":"systems/dsa5/icons/thirdparty/position-marker.svg",River:"systems/dsa5/icons/thirdparty/river.svg",Trail:"systems/dsa5/icons/thirdparty/trail.svg"},CONFIG.time.roundTime=5,CONFIG.time.turnTime=0;const i=o},472:(t,r,a)=>{a.d(r,{Z:()=>i});var o=a(491);function _typeof(t){return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},_typeof(t)}function _get(){return _get="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function _get(t,r,a){var o=_superPropBase(t,r);if(o){var i=Object.getOwnPropertyDescriptor(o,r);return i.get?i.get.call(arguments.length<3?t:a):i.value}},_get.apply(this,arguments)}function _superPropBase(t,r){for(;!Object.prototype.hasOwnProperty.call(t,r)&&null!==(t=_getPrototypeOf(t)););return t}function _inherits(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(r&&r.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),r&&_setPrototypeOf(t,r)}function _setPrototypeOf(t,r){return _setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function _setPrototypeOf(t,r){return t.__proto__=r,t},_setPrototypeOf(t,r)}function _createSuper(t){var r=function _isNativeReflectConstruct(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function _createSuperInternal(){var a,o=_getPrototypeOf(t);if(r){var i=_getPrototypeOf(this).constructor;a=Reflect.construct(o,arguments,i)}else a=o.apply(this,arguments);return _possibleConstructorReturn(this,a)}}function _possibleConstructorReturn(t,r){if(r&&("object"===_typeof(r)||"function"==typeof r))return r;if(void 0!==r)throw new TypeError("Derived constructors may only return object or undefined");return function _assertThisInitialized(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}function _getPrototypeOf(t){return _getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function _getPrototypeOf(t){return t.__proto__||Object.getPrototypeOf(t)},_getPrototypeOf(t)}function _toConsumableArray(t){return function _arrayWithoutHoles(t){if(Array.isArray(t))return _arrayLikeToArray(t)}(t)||function _iterableToArray(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||_unsupportedIterableToArray(t)||function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function _createForOfIteratorHelper(t,r){var a="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!a){if(Array.isArray(t)||(a=_unsupportedIterableToArray(t))||r&&t&&"number"==typeof t.length){a&&(t=a);var o=0,i=function F(){};return{s:i,n:function n(){return o>=t.length?{done:!0}:{done:!1,value:t[o++]}},e:function e(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var c,u=!0,l=!1;return{s:function s(){a=a.call(t)},n:function n(){var t=a.next();return u=t.done,t},e:function e(t){l=!0,c=t},f:function f(){try{u||null==a.return||a.return()}finally{if(l)throw c}}}}function _unsupportedIterableToArray(t,r){if(t){if("string"==typeof t)return _arrayLikeToArray(t,r);var a=Object.prototype.toString.call(t).slice(8,-1);return"Object"===a&&t.constructor&&(a=t.constructor.name),"Map"===a||"Set"===a?Array.from(t):"Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a)?_arrayLikeToArray(t,r):void 0}}function _arrayLikeToArray(t,r){(null==r||r>t.length)&&(r=t.length);for(var a=0,o=new Array(r);a=0;--o){var i=this.tryEntries[o],c=i.completion;if("root"===i.tryLoc)return handle("end");if(i.tryLoc<=this.prev){var u=a.call(i,"catchLoc"),l=a.call(i,"finallyLoc");if(u&&l){if(this.prev=0;--o){var i=this.tryEntries[o];if(i.tryLoc<=this.prev&&a.call(i,"finallyLoc")&&this.prev=0;--r){var a=this.tryEntries[r];if(a.finallyLoc===t)return this.complete(a.completion,a.afterLoc),resetTryEntry(a),l}},catch:function _catch(t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc===t){var o=a.completion;if("throw"===o.type){var i=o.arg;resetTryEntry(a)}return i}}throw new Error("illegal catch attempt")},delegateYield:function delegateYield(t,r,a){return this.delegate={iterator:values(t),resultName:r,nextLoc:a},"next"===this.method&&(this.arg=void 0),l}},t}function asyncGeneratorStep(t,r,a,o,i,c,u){try{var l=t[c](u),p=l.value}catch(t){return void a(t)}l.done?r(p):Promise.resolve(p).then(o,i)}function _asyncToGenerator(t){return function(){var r=this,a=arguments;return new Promise((function(o,i){var c=t.apply(r,a);function _next(t){asyncGeneratorStep(c,o,i,_next,_throw,"next",t)}function _throw(t){asyncGeneratorStep(c,o,i,_next,_throw,"throw",t)}_next(void 0)}))}}Hooks.once("i18nInit",_asyncToGenerator(_regeneratorRuntime().mark((function _callee(){var t;return _regeneratorRuntime().wrap((function _callee$(r){for(;;)switch(r.prev=r.next){case 0:if(i.creatureData){r.next=11;break}return r.next=3,fetch("systems/dsa5/lazy/creaturetype/".concat(game.i18n.lang,".json"));case 3:return t=r.sent,r.next=6,t.json();case 6:i.creatureData=r.sent,i.magical=game.i18n.localize("WEAPON.magical"),i.clerical=game.i18n.localize("WEAPON.clerical"),i.silverPlated=game.i18n.localize("WEAPON.silverPlated"),game.dsa5.apps.CreatureType=i;case 11:case"end":return r.stop()}}),_callee)}))));var i=function(){function CreatureType(t){_classCallCheck(this,CreatureType),this.creatureClass=t,this.spellImmunities=[],this.poisonImmunity=!1,this.diseaseImmunity=!1}return _createClass(CreatureType,[{key:"getName",value:function getName(){var t=this;return Object.keys(CreatureType.creatureData.types).find((function(r){return CreatureType.creatureData.types[r]==t.constructor.name}))}},{key:"ignoredCondition",value:function ignoredCondition(t){return!1}},{key:"damageModifier",value:function damageModifier(t){return[]}},{key:"spellImmunity",value:function spellImmunity(t){return this.spellImmunities.some((function(r){return t.includes(r)}))}},{key:"spellArmorModifier",value:function spellArmorModifier(t){return 0}},{key:"poisonImmunity",value:function poisonImmunity(){return this.poisonImmunity}},{key:"diseaseImmunity",value:function diseaseImmunity(){return this.diseaseImmunity}},{key:"spellResistanceModifier",value:function spellResistanceModifier(t){return 0}},{key:"weaponAttributes",value:function weaponAttributes(t){return getProperty(t,"system.effect.attributes")||""}},{key:"getTypeByClass",value:function getTypeByClass(t){return Object.keys(CreatureType.creatureData.types).find((function(r){return CreatureType.creatureData.types[r]===t}))}},{key:"isAttackItem",value:function isAttackItem(t){return["meleeweapon","trait","rangeweapon"].includes(t.type)&&function isNotEmpty(t){return!(!t||0===t.length)}(this.weaponAttributes(t))}},{key:"attributesRegex",value:function attributesRegex(t){var r=this.weaponAttributes(t);return new RegExp("(".concat(r.split(",").map((function(t){return o.Z.escapeRegex(t.split("(")[0].trim())})).join("|"),")"),"i")}}],[{key:"detectCreatureType",value:function detectCreatureType(t){var r=this,a="creature"==t.type?t.system.creatureClass.value:t.system.details.species.value;return Object.keys(CreatureType.creatureData.types).filter((function(t){return a.indexOf(t)>=0})).map((function(t){return r.getClass(CreatureType.creatureData.types[t],a)}))}},{key:"getClass",value:function getClass(t,r){return new(0,{DemonType:d,ChimeraType:u,DaimonidType:l,DragonType:p,ElementalType:h,FairyType:m,GhostType:y,GolemType:g,HomunculiType:v,IntelligentCreatureType:_,PlantType:b,AnimalType:k,UndeadType:w,SupernaturalType:x,MagicalConstructType:S,WerCreatureType:T,VampireType:A}[t])(r)}},{key:"checkImmunity",value:function checkImmunity(t){var r=[];switch(t.preData.source.type){case"poison":case"disease":var a=function(){var a,o=game.i18n.localize("LocalizedIDs.immuneTo")+" ("+t.preData.source.name+")",i=_createForOfIteratorHelper(game.user.targets);try{for(i.s();!(a=i.n()).done;){var c=a.value,u=c.actor,l=u.items.find((function(t){return t.name==o&&"advantage"==t.type}));if(l)r.push({name:l.name,uuid:l.uuid,target:u.name,condition:t.preData.source.name});else{var p,d=_createForOfIteratorHelper(CreatureType.detectCreatureType(c.actor));try{for(d.s();!(p=d.n()).done;){var h=p.value;if(h["".concat(t.preData.source.type,"Immunity")]){r.push({name:t.preData.source.name,target:"".concat(u.name," (").concat(h.getName(),")"),condition:t.preData.source.name});break}}}catch(t){d.e(t)}finally{d.f()}}}}catch(t){i.e(t)}finally{i.f()}return"break"}();if("break"===a)break;case"spell":case"ritual":var o,i=_createForOfIteratorHelper(game.user.targets);try{for(i.s();!(o=i.n()).done;){var c,u=o.value,l=CreatureType.detectCreatureType(u.actor),p=t.preData.source.system.feature.split(",").map((function(t){return t.trim()})),d=!1,h=_createForOfIteratorHelper(l);try{for(h.s();!(c=h.n()).done;){var m,y=c.value,g=_createForOfIteratorHelper(p);try{for(g.s();!(m=g.n()).done;){var v=m.value;if(y.spellImmunities.includes(v)){r.push({name:t.preData.source.name,target:"".concat(u.actor.name," (").concat(y.getName(),")"),condition:"".concat(game.i18n.localize("feature")," ").concat(v)}),d=!0;break}}}catch(t){g.e(t)}finally{g.f()}if(d)break}}catch(t){h.e(t)}finally{h.f()}}}catch(t){i.e(t)}finally{i.f()}}return r}},{key:"creatureTypeName",value:function creatureTypeName(t){if("creature"==t.type){var r=t.system.creatureClass.value;return Object.keys(CreatureType.creatureData.types).filter((function(t){return r.indexOf(t)>=0}))[0]}return t.system.details.species.value}},{key:"addCreatureTypeModifiers",value:function addCreatureTypeModifiers(t,r,a,o){var i,c=CreatureType.detectCreatureType(t),u=["spell","ceremony","liturgy","ritual"].includes(r.type),l=_createForOfIteratorHelper(c);try{for(l.s();!(i=l.n()).done;){var p=i.value,d=p.damageModifier(r);if(u){var h,m=_createForOfIteratorHelper(d);try{for(m.s();!(h=m.n()).done;){h.value.armorPen=p.spellResistanceModifier(t)}}catch(t){m.e(t)}finally{m.f()}}a.push.apply(a,_toConsumableArray(d))}}catch(t){l.e(t)}finally{l.f()}a.push.apply(a,_toConsumableArray(this.creatureBonusDamage(t,o))),CreatureType.addVulnerabilitiesToSource(t,r,a)}},{key:"addVulnerabilitiesToSource",value:function addVulnerabilitiesToSource(t,r,a){var o=getProperty(t,"system.vulnerabilities");o&&(["meleeweapon","rangeweapon"].includes(r.type)&&getProperty(o,"combatskill").reduce((function(t,o){if(o.target==r.system.combatskill.value){var i=(/\*/.test(o.value)?Number(o.value.replace("*",""))>1:Number(o.value)>0)?"WEAPON.vulnerableTo":"WEAPON.resistantTo";a.push.apply(a,_toConsumableArray(CreatureType.buildDamageMod("".concat(game.i18n.format(i,{name:r.system.combatskill.value})," (").concat(o.source,")"),o.value)))}}),a))}},{key:"creatureBonusDamage",value:function creatureBonusDamage(t,r){var a,o=[],i="creature"==t.type?t.system.creatureClass.value:t.system.details.species.value,c=_createForOfIteratorHelper(getProperty(r,"system.creatureBonus"));try{for(c.s();!(a=c.n()).done;){var u=a.value;i.indexOf(u.target)>=0&&o.push.apply(o,_toConsumableArray(this.buildDamageMod(u.source,u.value,!0)))}}catch(t){c.e(t)}finally{c.f()}return o}},{key:"buildDamageMod",value:function buildDamageMod(t,r){var a=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];return[{name:t,value:r,selected:a,type:"dmg",source:game.i18n.localize("target")}]}}]),CreatureType}();_defineProperty(i,"creatureData",void 0),_defineProperty(i,"magical",void 0),_defineProperty(i,"clerical",void 0);var c=function(t){_inherits(VulnerableToLifeGods,t);var r=_createSuper(VulnerableToLifeGods);function VulnerableToLifeGods(){return _classCallCheck(this,VulnerableToLifeGods),r.apply(this,arguments)}return _createClass(VulnerableToLifeGods,[{key:"damageModifier",value:function damageModifier(t){if(this.isAttackItem(t)){var r,a=this.attributesRegex(t),o=_createForOfIteratorHelper(i.creatureData.godOfLife);try{for(o.s();!(r=o.n()).done;){var c=r.value,u="".concat(i.clerical," (").concat(c,")");if(a.test(u))return i.buildDamageMod(u,"*2")}}catch(t){o.e(t)}finally{o.f()}}return _get(_getPrototypeOf(VulnerableToLifeGods.prototype),"damageModifier",this).call(this,t)}}]),VulnerableToLifeGods}(i),u=function(t){_inherits(ChimeraType,t);var r=_createSuper(ChimeraType);function ChimeraType(){return _classCallCheck(this,ChimeraType),r.apply(this,arguments)}return _createClass(ChimeraType)}(c),l=function(t){_inherits(DaimonidType,t);var r=_createSuper(DaimonidType);function DaimonidType(t){var a;return _classCallCheck(this,DaimonidType),(a=r.call(this,t)).spellImmunities=["Influence","Transformation"].map((function(t){return game.i18n.localize("Features.".concat(t))})),a}return _createClass(DaimonidType,[{key:"damageModifier",value:function damageModifier(t){if(this.isAttackItem(t)&&this.attributesRegex(t).test(i.clerical))return i.buildDamageMod(i.clerical,"*2");return _get(_getPrototypeOf(DaimonidType.prototype),"damageModifier",this).call(this,t)}}]),DaimonidType}(i),p=function(t){_inherits(DragonType,t);var r=_createSuper(DragonType);function DragonType(){return _classCallCheck(this,DragonType),r.apply(this,arguments)}return _createClass(DragonType)}(i),d=function(t){_inherits(DemonType,t);var r=_createSuper(DemonType);function DemonType(t){var a;return _classCallCheck(this,DemonType),(a=r.call(this,t)).spellImmunities=["Influence","Transformation","Healing","Illusion"].map((function(t){return game.i18n.localize("Features.".concat(t))})),a.poisonImmunity=!0,a.diseaseImmunity=!0,a}return _createClass(DemonType,[{key:"damageModifier",value:function damageModifier(t){if(this.isAttackItem(t)){var r=this.attributesRegex(t);if(r.test(i.clerical))return i.buildDamageMod("".concat(i.clerical," (").concat(i.creatureData.opposingGod,")"),"*2",!1);if(r.test(i.magical))return _get(_getPrototypeOf(DemonType.prototype),"damageModifier",this).call(this,t)}else if(["spell","ceremony","liturgy","ritual"].includes(t.type))return _get(_getPrototypeOf(DemonType.prototype),"damageModifier",this).call(this,t);return i.buildDamageMod(this.getTypeByClass("DemonType"),"*0.5")}},{key:"spellArmorModifier",value:function spellArmorModifier(t){return Number(t.system.status.soulpower.max)}},{key:"spellResistanceModifier",value:function spellResistanceModifier(t){return Number(t.system.status.soulpower.max)}},{key:"ignoredCondition",value:function ignoredCondition(t){return!0}}]),DemonType}(i),h=function(t){_inherits(ElementalType,t);var r=_createSuper(ElementalType);function ElementalType(t){var a;return _classCallCheck(this,ElementalType),(a=r.call(this,t)).poisonImmunity=!0,a.diseaseImmunity=!0,a}return _createClass(ElementalType,[{key:"damageModifier",value:function damageModifier(t){if(this.isAttackItem(t)){if(this.attributesRegex(t).test(i.magical))return _get(_getPrototypeOf(ElementalType.prototype),"damageModifier",this).call(this,t)}else if(["spell","ceremony","liturgy","ritual"].includes(t.type))return i.buildDamageMod(this.getTypeByClass("ElementalType"),"*1");return i.buildDamageMod(this.getTypeByClass("ElementalType"),"*0.5")}},{key:"spellArmorModifier",value:function spellArmorModifier(t){return Number(t.system.status.soulpower.max)}},{key:"spellResistanceModifier",value:function spellResistanceModifier(t){return Number(t.system.status.soulpower.max)}},{key:"ignoredCondition",value:function ignoredCondition(t){return!0}}]),ElementalType}(i),m=function(t){_inherits(FairyType,t);var r=_createSuper(FairyType);function FairyType(t){var a;return _classCallCheck(this,FairyType),(a=r.call(this,t)).spellImmunities=["Illusion"].map((function(t){return game.i18n.localize("Features.".concat(t))})),a.poisonImmunity=!0,a.diseaseImmunity=!0,a}return _createClass(FairyType)}(i),y=function(t){_inherits(GhostType,t);var r=_createSuper(GhostType);function GhostType(t){var a;return _classCallCheck(this,GhostType),(a=r.call(this,t)).spellImmunities=["Illusion","Healing","Telekinesis","Transformation"].map((function(t){return game.i18n.localize("Features.".concat(t))})),a.poisonImmunity=!0,a.diseaseImmunity=!0,a}return _createClass(GhostType,[{key:"damageModifier",value:function damageModifier(t){if(this.isAttackItem(t)){var r,a=this.attributesRegex(t),o=_createForOfIteratorHelper(i.creatureData.godOfDeath);try{for(o.s();!(r=o.n()).done;){var c=r.value,u="".concat(i.clerical," (").concat(c,")");if(a.test(u))return[]}}catch(t){o.e(t)}finally{o.f()}if((a=this.attributesRegex(t)).test(i.clerical))return i.buildDamageMod(i.clerical,"*0.5");if(a.test(i.magical))return i.buildDamageMod(i.magical,"*0.5")}else if(["spell","ceremony","liturgy","ritual"].includes(t.type))return i.buildDamageMod(i.magical,"*0.5");return i.buildDamageMod(this.getTypeByClass("GhostType"),"*0")}},{key:"ignoredCondition",value:function ignoredCondition(t){return!["feared","inpain","confused"].includes(t)}}]),GhostType}(i),g=function(t){_inherits(GolemType,t);var r=_createSuper(GolemType);function GolemType(t){var a;return _classCallCheck(this,GolemType),(a=r.call(this,t)).spellImmunities=["Transformation"].map((function(t){return game.i18n.localize("Features.".concat(t))})),a.poisonImmunity=!0,a.diseaseImmunity=!0,a}return _createClass(GolemType,[{key:"ignoredCondition",value:function ignoredCondition(t){return!["confused","paralysed"].includes(t)}}]),GolemType}(c),v=function(t){_inherits(HomunculiType,t);var r=_createSuper(HomunculiType);function HomunculiType(t){var a;return _classCallCheck(this,HomunculiType),(a=r.call(this,t)).spellImmunities=["Healing"].map((function(t){return game.i18n.localize("Features.".concat(t))})),a}return _createClass(HomunculiType,[{key:"ignoredCondition",value:function ignoredCondition(t){return!["inpain","encumbered","stunned","feared","paralysed","confused"].includes(t)}}]),HomunculiType}(c),_=function(t){_inherits(IntelligentCreatureType,t);var r=_createSuper(IntelligentCreatureType);function IntelligentCreatureType(){return _classCallCheck(this,IntelligentCreatureType),r.apply(this,arguments)}return _createClass(IntelligentCreatureType)}(i),b=function(t){_inherits(PlantType,t);var r=_createSuper(PlantType);function PlantType(){return _classCallCheck(this,PlantType),r.apply(this,arguments)}return _createClass(PlantType)}(i),k=function(t){_inherits(AnimalType,t);var r=_createSuper(AnimalType);function AnimalType(){return _classCallCheck(this,AnimalType),r.apply(this,arguments)}return _createClass(AnimalType)}(i),w=function(t){_inherits(UndeadType,t);var r=_createSuper(UndeadType);function UndeadType(t){var a;return _classCallCheck(this,UndeadType),(a=r.call(this,t)).spellImmunities=["Influence","Healing","Illusion"].map((function(t){return game.i18n.localize("Features.".concat(t))})),a.poisonImmunity=!0,a.diseaseImmunity=!0,a}return _createClass(UndeadType,[{key:"damageModifier",value:function damageModifier(t){if(this.isAttackItem(t)){var r,a=this.attributesRegex(t),o=_createForOfIteratorHelper(i.creatureData.godOfDeath);try{for(o.s();!(r=o.n()).done;){var c=r.value,u="".concat(i.clerical," (").concat(c,")");if(a.test(u))return i.buildDamageMod(u,"*2")}}catch(t){o.e(t)}finally{o.f()}}return _get(_getPrototypeOf(UndeadType.prototype),"damageModifier",this).call(this,t)}},{key:"ignoredCondition",value:function ignoredCondition(t){return!["paralysed"].includes(t)}}]),UndeadType}(i),x=function(t){_inherits(SupernaturalType,t);var r=_createSuper(SupernaturalType);function SupernaturalType(){return _classCallCheck(this,SupernaturalType),r.apply(this,arguments)}return _createClass(SupernaturalType)}(i),S=function(t){_inherits(MagicalConstructType,t);var r=_createSuper(MagicalConstructType);function MagicalConstructType(t){var a;return _classCallCheck(this,MagicalConstructType),(a=r.call(this,t)).spellImmunities=["Transformation"].map((function(t){return game.i18n.localize("Features.".concat(t))})),a.poisonImmunity=!0,a.diseaseImmunity=!0,a}return _createClass(MagicalConstructType,[{key:"ignoredCondition",value:function ignoredCondition(t){return!["stunned","feared","paralysed","confused"].includes(t)}}]),MagicalConstructType}(i),T=function(t){_inherits(WerCreatureType,t);var r=_createSuper(WerCreatureType);function WerCreatureType(){return _classCallCheck(this,WerCreatureType),r.apply(this,arguments)}return _createClass(WerCreatureType,[{key:"damageModifier",value:function damageModifier(t){if(this.isAttackItem(t)){if(this.attributesRegex(t).test(i.silverPlated))return i.buildDamageMod(this.getTypeByClass("WerCreatureType"),"*2")}else if(["spell","ceremony","liturgy","ritual"].includes(t.type))return _get(_getPrototypeOf(WerCreatureType.prototype),"damageModifier",this).call(this,t);return i.buildDamageMod(this.getTypeByClass("WerCreatureType"),"*0.5")}}]),WerCreatureType}(i),A=function(t){_inherits(VampireType,t);var r=_createSuper(VampireType);function VampireType(){return _classCallCheck(this,VampireType),r.apply(this,arguments)}return _createClass(VampireType,[{key:"damageModifier",value:function damageModifier(t){return["spell","ceremony","liturgy","ritual"].includes(t.type)?_get(_getPrototypeOf(VampireType.prototype),"damageModifier",this).call(this,t):i.buildDamageMod(this.getTypeByClass("VampireType"),"*0.5")}}]),VampireType}(i)},565:(t,r,a)=>{a.d(r,{Z:()=>i});var o=a(272);function _createForOfIteratorHelper(t,r){var a="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!a){if(Array.isArray(t)||(a=function _unsupportedIterableToArray(t,r){if(!t)return;if("string"==typeof t)return _arrayLikeToArray(t,r);var a=Object.prototype.toString.call(t).slice(8,-1);"Object"===a&&t.constructor&&(a=t.constructor.name);if("Map"===a||"Set"===a)return Array.from(t);if("Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a))return _arrayLikeToArray(t,r)}(t))||r&&t&&"number"==typeof t.length){a&&(t=a);var o=0,i=function F(){};return{s:i,n:function n(){return o>=t.length?{done:!0}:{done:!1,value:t[o++]}},e:function e(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var c,u=!0,l=!1;return{s:function s(){a=a.call(t)},n:function n(){var t=a.next();return u=t.done,t},e:function e(t){l=!0,c=t},f:function f(){try{u||null==a.return||a.return()}finally{if(l)throw c}}}}function _arrayLikeToArray(t,r){(null==r||r>t.length)&&(r=t.length);for(var a=0,o=new Array(r);a=u,p=c.object.document.config.dim>=u;if((l||p)&&((!1===c.data.walls||c.shape.contains(t.center.x,t.center.y))&&(r=l||r,a=p||a),r))break}else if(r=r||c.data.bright>0,a=a||c.data.dim>0,r)break}}catch(t){i.e(t)}finally{i.f()}}return{bright:r,dim:a}}},{key:"isEnabled",get:function get(){var t,r,a=null===(t=canvas)||void 0===t||null===(r=t.scene)||void 0===r?void 0:r.getFlag("dsa5","enableDPS");return a?"2"==a:game.settings.get("dsa5","enableDPS")}},{key:"lightLevel",value:function lightLevel(t,r){if(canvas.scene&&game.settings.get("dsa5","sightAutomationEnabled")){for(var a,i=0,c=(null===(a=canvas.scene)||void 0===a?void 0:a.darkness)||0,u=game.settings.get("dsa5","sightOptions").split("|").map((function(t){return Number(t)}));u[i]<=c;)i+=1;if(t){var l=o.Z.vantageStep(t,game.i18n.localize("LocalizedIDs.darksight")),p=Number(getProperty(t,"system.sightModifier.value"))||0,d=Number(getProperty(t,"system.sightModifier.maxLevel"))||3,h=Array.from(game.user.targets);if(h.length){h=h[0];var m=DPS.inLight(h),y=0;m.bright?y=-2:m.dim&&(y=-1),i=Math.max(i+y,0)}i<=d&&i>0&&(i=l>1?0:Math.clamped(i+p-l,0,4))}var g=r.find('[name="vision"] option:nth-child('.concat(i+1,")"));g.length&&(g[0].selected=!0)}}},{key:"distanceModifier",value:function distanceModifier(t,r,a){if(!DPS.isEnabled||!t)return 1;var o,i={},c=_createForOfIteratorHelper(game.user.targets);try{for(c.s();!(o=c.n()).done;){var u=o.value,l=DPS.rangeFinder(t,u);(i.distanceSum||0)\n \n \n
    ");r.find(".dpsSelector").remove(),r.find('.tab[data-tab="grid"]').append(i)}))},562:(__unused_webpack_module,__webpack_exports__,__webpack_require__)=>{__webpack_require__.d(__webpack_exports__,{Z:()=>DiceDSA5});var _actor_actor_dsa5_js__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__(369),_config_dsa5_js__WEBPACK_IMPORTED_MODULE_1__=__webpack_require__(577),_dialog_dialog_dsa5_js__WEBPACK_IMPORTED_MODULE_2__=__webpack_require__(538),_utility_dsa5_js__WEBPACK_IMPORTED_MODULE_3__=__webpack_require__(491),_advantage_rules_dsa5_js__WEBPACK_IMPORTED_MODULE_4__=__webpack_require__(272),_specialability_rules_dsa5_js__WEBPACK_IMPORTED_MODULE_5__=__webpack_require__(173),_trait_rules_dsa5_js__WEBPACK_IMPORTED_MODULE_6__=__webpack_require__(101),_item_item_dsa5_js__WEBPACK_IMPORTED_MODULE_7__=__webpack_require__(839),_status_status_effects_js__WEBPACK_IMPORTED_MODULE_8__=__webpack_require__(973),_opposed_dsa5_js__WEBPACK_IMPORTED_MODULE_9__=__webpack_require__(600),_status_active_effects_js__WEBPACK_IMPORTED_MODULE_10__=__webpack_require__(61),_dsa_soundeffect_js__WEBPACK_IMPORTED_MODULE_11__=__webpack_require__(803),_equipment_damage_js__WEBPACK_IMPORTED_MODULE_12__=__webpack_require__(702),_dialog_dialog_equipmentdamage_js__WEBPACK_IMPORTED_MODULE_13__=__webpack_require__(266),_tables_dsatables_js__WEBPACK_IMPORTED_MODULE_14__=__webpack_require__(430),_request_roll_js__WEBPACK_IMPORTED_MODULE_15__=__webpack_require__(903),_measuretemplate_js__WEBPACK_IMPORTED_MODULE_16__=__webpack_require__(174),_tables_tableEffects_js__WEBPACK_IMPORTED_MODULE_17__=__webpack_require__(585),_creature_type_js__WEBPACK_IMPORTED_MODULE_18__=__webpack_require__(472);function _typeof(t){return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},_typeof(t)}function _defineProperty(t,r,a){return r in t?Object.defineProperty(t,r,{value:a,enumerable:!0,configurable:!0,writable:!0}):t[r]=a,t}function _slicedToArray(t,r){return _arrayWithHoles(t)||_iterableToArrayLimit(t,r)||_unsupportedIterableToArray(t,r)||_nonIterableRest()}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _iterableToArrayLimit(t,r){var a=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=a){var o,i,c=[],u=!0,l=!1;try{for(a=a.call(t);!(u=(o=a.next()).done)&&(c.push(o.value),!r||c.length!==r);u=!0);}catch(t){l=!0,i=t}finally{try{u||null==a.return||a.return()}finally{if(l)throw i}}return c}}function _arrayWithHoles(t){if(Array.isArray(t))return t}function _createForOfIteratorHelper(t,r){var a="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!a){if(Array.isArray(t)||(a=_unsupportedIterableToArray(t))||r&&t&&"number"==typeof t.length){a&&(t=a);var o=0,i=function F(){};return{s:i,n:function n(){return o>=t.length?{done:!0}:{done:!1,value:t[o++]}},e:function e(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var c,u=!0,l=!1;return{s:function s(){a=a.call(t)},n:function n(){var t=a.next();return u=t.done,t},e:function e(t){l=!0,c=t},f:function f(){try{u||null==a.return||a.return()}finally{if(l)throw c}}}}function _toConsumableArray(t){return _arrayWithoutHoles(t)||_iterableToArray(t)||_unsupportedIterableToArray(t)||_nonIterableSpread()}function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray(t,r){if(t){if("string"==typeof t)return _arrayLikeToArray(t,r);var a=Object.prototype.toString.call(t).slice(8,-1);return"Object"===a&&t.constructor&&(a=t.constructor.name),"Map"===a||"Set"===a?Array.from(t):"Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a)?_arrayLikeToArray(t,r):void 0}}function _iterableToArray(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}function _arrayWithoutHoles(t){if(Array.isArray(t))return _arrayLikeToArray(t)}function _arrayLikeToArray(t,r){(null==r||r>t.length)&&(r=t.length);for(var a=0,o=new Array(r);a=0;--o){var i=this.tryEntries[o],c=i.completion;if("root"===i.tryLoc)return handle("end");if(i.tryLoc<=this.prev){var u=a.call(i,"catchLoc"),l=a.call(i,"finallyLoc");if(u&&l){if(this.prev=0;--o){var i=this.tryEntries[o];if(i.tryLoc<=this.prev&&a.call(i,"finallyLoc")&&this.prev=0;--r){var a=this.tryEntries[r];if(a.finallyLoc===t)return this.complete(a.completion,a.afterLoc),resetTryEntry(a),l}},catch:function _catch(t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc===t){var o=a.completion;if("throw"===o.type){var i=o.arg;resetTryEntry(a)}return i}}throw new Error("illegal catch attempt")},delegateYield:function delegateYield(t,r,a){return this.delegate={iterator:values(t),resultName:r,nextLoc:a},"next"===this.method&&(this.arg=void 0),l}},t}function asyncGeneratorStep(t,r,a,o,i,c,u){try{var l=t[c](u),p=l.value}catch(t){return void a(t)}l.done?r(p):Promise.resolve(p).then(o,i)}function _asyncToGenerator(t){return function(){var r=this,a=arguments;return new Promise((function(o,i){var c=t.apply(r,a);function _next(t){asyncGeneratorStep(c,o,i,_next,_throw,"next",t)}function _throw(t){asyncGeneratorStep(c,o,i,_next,_throw,"throw",t)}_next(void 0)}))}}function _classCallCheck(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}function _defineProperties(t,r){for(var a=0;a0,h.t3=u,h.t4=r.data.rollMode||i,h.t5=CONFIG.Dice.rollModes,h.next=20,this.getDefenseCount(a);case 20:if(h.t6=h.sent,h.t7=l,h.t8={hasSituationalModifiers:h.t2,situationalModifiers:h.t3,rollMode:h.t4,rollModes:h.t5,defenseCount:h.t6,targets:h.t7},(0,h.t0)(h.t1,h.t8),mergeObject(o,{user:game.user.id}),a.extra.options.bypass){h.next=33;break}return p=_dialog_dialog_dsa5_js__WEBPACK_IMPORTED_MODULE_2__.Z.getDialogForItem(a,r.data),h.next=29,renderTemplate(r.template,r.data);case 29:return d=h.sent,h.abrupt("return",new Promise((function(t,o){new p({title:r.title,content:d,buttons:p.getRollButtons(a,r,t,o),default:"rollButton"}).recallSettings(a.extra.speaker,a.source,a.mode,r.data).render(!0)})));case 33:return o.rollMode=a.extra.options.rollMode||i,a.situationalModifiers||(a.situationalModifiers=[]),h.abrupt("return",{testData:a,cardOptions:o});case 36:case"end":return h.stop()}}),_callee3,this)}))),function setupDialog(t){return _setupDialog.apply(this,arguments)})},{key:"getDefenseCount",value:(_getDefenseCount=_asyncToGenerator(_regeneratorRuntime().mark((function _callee4(t){return _regeneratorRuntime().wrap((function _callee4$(r){for(;;)switch(r.prev=r.next){case 0:if(!game.combat){r.next=4;break}return r.next=3,game.combat.getDefenseCount(t.extra.speaker);case 3:return r.abrupt("return",r.sent);case 4:return r.abrupt("return",0);case 5:case"end":return r.stop()}}),_callee4)}))),function getDefenseCount(t){return _getDefenseCount.apply(this,arguments)})},{key:"_rollSingleD20",value:(_rollSingleD=_asyncToGenerator(_regeneratorRuntime().mark((function _callee5(t,r,a,o,i){var c,u,l,p,d,h,m,y,g,v,_,b,k,w,x=arguments;return _regeneratorRuntime().wrap((function _callee5$(S){for(;;)switch(S.prev=S.next){case 0:return c=x.length>5&&void 0!==x[5]?x[5]:"",u=x.length>6&&void 0!==x[6]?x[6]:1,l="",p=[],r+=o,r=Math.round(r*u),d=r-t.terms[0].results[0].result,h=game.dsa5.apps.DiceSoNiceCustomization.getAttributeConfiguration(a),p.push({char:a,res:t.terms[0].results[0].result,suc:d>=0,tar:r}),S.next=11,new Roll("1d20").evaluate({async:!0});case 11:if(m=S.sent,y=d>=0?1:-1,g=20,v=1,"meleeweapon"==i.source.type&&(g=Math.min(i.extra.actor.system.meleeStats.botch,i.source.system.botch),v=Math.max(i.extra.actor.system.meleeStats.crit,i.source.system.crit)),"rangeweapon"==i.source.type&&(g=Math.min(i.extra.actor.system.rangeStats.botch,i.source.system.botch),v=Math.max(i.extra.actor.system.rangeStats.crit,i.source.system.crit)),/(\(|,)( )?i\)$/.test(i.source.name)&&(_specialability_rules_dsa5_js__WEBPACK_IMPORTED_MODULE_5__.Z.hasAbility(i.extra.actor,game.i18n.localize("LocalizedIDs.improvisedWeaponMaster"))||(g=Math.min(19,g)),this._appendSituationalModifiers(i,"".concat(game.i18n.localize("CHAR.ATTACK")," - ").concat(game.i18n.localize("WEAPON.improvised")),2,"defenseMalus")),i.situationalModifiers.find((function(t){return t.name==game.i18n.localize("opportunityAttack")&&0!=t.value}))&&(g=50,v=-50),1!=t.terms[0].results.filter((function(t){return t.result<=v})).length){S.next=41;break}if(l=game.i18n.localize("CriticalSuccess"),!game.settings.get("dsa5","noConfirmationRoll")){S.next=25;break}y=3,S.next=39;break;case 25:return S.next=27,DiceDSA5.manualRolls(m,"confirmationRoll",i.extra.options);case 27:if(m=S.sent,_=r-m.terms[0].results[0].result,!_advantage_rules_dsa5_js__WEBPACK_IMPORTED_MODULE_4__.Z.hasVantage(i.extra.actor,"".concat(game.i18n.localize("LocalizedIDs.weaponAptitude")," (").concat(c,")"))||_>=0){S.next=36;break}return b=m.terms[0].results[0].result,S.next=33,new Roll("1d20").evaluate({async:!0});case 33:m=S.sent,_=r-m.terms[0].results[0].result,l+=", "+game.i18n.format("usedWeaponExpertise",{a:b,b:m.terms[0].results[0].result});case 36:this._addRollDiceSoNice(i,m,h),p.push({char:a,res:m.terms[0].results[0].result,suc:_>=0,tar:r}),y=_>=0?3:2;case 39:S.next=61;break;case 41:if(1!=t.terms[0].results.filter((function(t){return t.result>=g})).length){S.next=61;break}if(l=game.i18n.localize("CriticalFailure"),!game.settings.get("dsa5","noConfirmationRoll")){S.next=47;break}y=-3,S.next=61;break;case 47:return S.next=49,DiceDSA5.manualRolls(m,"confirmationRoll",i.extra.options);case 49:if(m=S.sent,k=r-m.terms[0].results[0].result,!_advantage_rules_dsa5_js__WEBPACK_IMPORTED_MODULE_4__.Z.hasVantage(i.extra.actor,"".concat(game.i18n.localize("LocalizedIDs.weaponAptitude")," (").concat(c,")"))||k>=0){S.next=58;break}return w=m.terms[0].results[0].result,S.next=55,new Roll("1d20").evaluate({async:!0});case 55:m=S.sent,k=r-m.terms[0].results[0].result,l+=", "+game.i18n.format("usedWeaponExpertise",{a:w,b:m.terms[0].results[0].result});case 58:this._addRollDiceSoNice(i,m,h),p.push({char:a,res:m.terms[0].results[0].result,suc:k>=0,tar:r}),y=k>=0?-2:-3;case 61:return""==l?l=game.i18n.localize(d>=0?"Success":"Failure"):game.settings.get("dsa5","noConfirmationRoll")||(3==Math.abs(y)?l="".concat(game.i18n.localize("confirmed")," ").concat(l):2==Math.abs(y)&&(l="".concat(game.i18n.localize("unconfirmed")," ").concat(l))),S.abrupt("return",{successLevel:y,characteristics:p,description:l,preData:i,modifiers:o,extra:{}});case 63:case"end":return S.stop()}}),_callee5,this)}))),function _rollSingleD20(t,r,a,o,i){return _rollSingleD.apply(this,arguments)})},{key:"rollFallingDamage",value:(_rollFallingDamage=_asyncToGenerator(_regeneratorRuntime().mark((function _callee6(t){var r,a,o,i,c,u;return _regeneratorRuntime().wrap((function _callee6$(l){for(;;)switch(l.prev=l.next){case 0:r=t.roll,a=[],o=_createForOfIteratorHelper(r.terms[0].results);try{for(o.s();!(i=o.n()).done;)c=i.value,a.push({char:"damage",res:c.result,suc:!1})}catch(t){o.e(t)}finally{o.f()}return l.t0=t,l.next=7,this._situationalModifiers(t);case 7:return l.t1=l.sent,l.t2={},l.t3=Math.max(0,r.total),l.t4=r.formula,l.t5=a,u={rollType:"fallingDamage",preData:l.t0,modifiers:l.t1,extra:l.t2,damage:l.t3,formula:l.t4,characteristics:l.t5},l.abrupt("return",u);case 14:case"end":return l.stop()}}),_callee6,this)}))),function rollFallingDamage(t){return _rollFallingDamage.apply(this,arguments)})},{key:"rollRegeneration",value:(_rollRegeneration=_asyncToGenerator(_regeneratorRuntime().mark((function _callee7(t){var r,a,o,i,c,u,l,p,d,h,m,y;return _regeneratorRuntime().wrap((function _callee7$(g){for(;;)switch(g.prev=g.next){case 0:return g.next=2,this._situationalModifiers(t);case 2:if(r=g.sent,a=t.roll,o=[],i={rollType:"regenerate",preData:t,modifiers:r,extra:{}},c=[],t.regenerateLeP&&c.push("LeP"),t.extra.actor.system.isMage&&t.regenerateAsP&&c.push("AsP"),t.extra.actor.system.isPriest&&t.regenerateKaP&&c.push("KaP"),u=0,!t.extra.actor.effects.some((function(t){return t.statuses.includes("sick")}))){g.next=18;break}this._appendSituationalModifiers(t,game.i18n.localize("CONDITION.sick"),"*0"),l=_createForOfIteratorHelper(c);try{for(l.s();!(p=l.n()).done;)d=p.value,o.push({char:d,res:0,die:"d6"}),i[d]=0,u+=2}catch(t){l.e(t)}finally{l.f()}g.next=51;break;case 18:h=_createForOfIteratorHelper(c),g.prev=19,h.s();case 21:if((m=h.n()).done){g.next=43;break}return y=m.value,this._appendSituationalModifiers(t,game.i18n.localize("LocalizedIDs.regeneration".concat(y)),_advantage_rules_dsa5_js__WEBPACK_IMPORTED_MODULE_4__.Z.vantageStep(t.extra.actor,game.i18n.localize("LocalizedIDs.regeneration".concat(y))),y),this._appendSituationalModifiers(t,game.i18n.localize("LocalizedIDs.weakRegeneration".concat(y)),-1*_advantage_rules_dsa5_js__WEBPACK_IMPORTED_MODULE_4__.Z.vantageStep(t.extra.actor,game.i18n.localize("LocalizedIDs.weakRegeneration".concat(y))),y),this._appendSituationalModifiers(t,game.i18n.localize("LocalizedIDs.advancedRegeneration".concat(y)),_specialability_rules_dsa5_js__WEBPACK_IMPORTED_MODULE_5__.Z.abilityStep(t.extra.actor,game.i18n.localize("LocalizedIDs.advancedRegeneration".concat(y))),y),this._appendSituationalModifiers(t,"".concat(game.i18n.localize("CHARAbbrev.".concat(y))," ").concat(game.i18n.localize("Modifier")),t["".concat(y,"Modifier")],y),this._appendSituationalModifiers(t,"".concat(game.i18n.localize("CHARAbbrev.".concat(y))," ").concat(game.i18n.localize("regenerate")),t["regeneration".concat(y)],y),o.push({char:y,res:a.terms[u].results[0].result,die:"d6"}),g.t0=Math,g.t1=Math,g.t2=Number(a.terms[u].results[0].result)+Number(r),g.next=34,this._situationalModifiers(t,y);case 34:g.t3=g.sent,g.t4=g.t2+g.t3,g.t5=g.t1.max.call(g.t1,0,g.t4),g.t6=Number(t.regenerationFactor),g.t7=g.t5*g.t6,i[y]=g.t0.round.call(g.t0,g.t7),u+=2;case 41:g.next=21;break;case 43:g.next=48;break;case 45:g.prev=45,g.t8=g.catch(19),h.e(g.t8);case 48:return g.prev=48,h.f(),g.finish(48);case 51:return i.characteristics=o,g.abrupt("return",i);case 53:case"end":return g.stop()}}),_callee7,this,[[19,45,48,51]])}))),function rollRegeneration(t){return _rollRegeneration.apply(this,arguments)})},{key:"rollStatus",value:(_rollStatus=_asyncToGenerator(_regeneratorRuntime().mark((function _callee8(t){var r,a,o;return _regeneratorRuntime().wrap((function _callee8$(i){for(;;)switch(i.prev=i.next){case 0:if(i.t0=t.roll,i.t0){i.next=5;break}return i.next=4,new Roll("1d20").evaluate({async:!0});case 4:i.t0=i.sent;case 5:return r=i.t0,i.t1=this,i.t2=r,i.t3=t.source.system.max,i.t4=t.extra.statusId,i.next=12,this._situationalModifiers(t);case 12:return i.t5=i.sent,i.t6=t,i.t7=this._situationalMultipliers(t),i.next=17,i.t1._rollSingleD20.call(i.t1,i.t2,i.t3,i.t4,i.t5,i.t6,"",i.t7);case 17:if((a=i.sent).rollType="dodge",!(o="dodge"==t.extra.statusId)||3!=a.successLevel){i.next=30;break}return i.next=23,_tables_dsatables_js__WEBPACK_IMPORTED_MODULE_14__.Z.tableEnabledFor("criticalMeleeDefense");case 23:if(!i.sent){i.next=27;break}a.description+=_tables_dsatables_js__WEBPACK_IMPORTED_MODULE_14__.Z.rollCritBotchButton("criticalMeleeDefense",!1,t,t),i.next=28;break;case 27:a.description+=_tables_dsatables_js__WEBPACK_IMPORTED_MODULE_14__.Z.defaultParryCrit();case 28:i.next=41;break;case 30:if(!o||-3!=a.successLevel){i.next=41;break}return i.next=33,_tables_dsatables_js__WEBPACK_IMPORTED_MODULE_14__.Z.tableEnabledFor("Defense");case 33:if(!i.sent){i.next=37;break}a.description+=_tables_dsatables_js__WEBPACK_IMPORTED_MODULE_14__.Z.rollCritBotchButton("Defense",!0,t,t),i.next=41;break;case 37:return i.t8=a.description,i.next=40,_tables_dsatables_js__WEBPACK_IMPORTED_MODULE_14__.Z.defaultBotch();case 40:a.description=i.t8+=i.sent;case 41:return i.abrupt("return",a);case 42:case"end":return i.stop()}}),_callee8,this)}))),function rollStatus(t){return _rollStatus.apply(this,arguments)})},{key:"rollAttribute",value:(_rollAttribute=_asyncToGenerator(_regeneratorRuntime().mark((function _callee9(t){var r,a;return _regeneratorRuntime().wrap((function _callee9$(o){for(;;)switch(o.prev=o.next){case 0:if(!t.roll){o.next=4;break}o.t0=t.roll,o.next=7;break;case 4:return o.next=6,new Roll("1d20").evaluate({async:!0});case 6:o.t0=o.sent;case 7:return r=o.t0,this._appendSituationalModifiers(t,game.i18n.localize("Difficulty"),t.testDifficulty),o.t1=this,o.t2=r,o.t3=t.source.system.value,o.t4=t.extra.characteristicId,o.next=15,this._situationalModifiers(t);case 15:return o.t5=o.sent,o.t6=t,o.t7=this._situationalMultipliers(t),o.next=20,o.t1._rollSingleD20.call(o.t1,o.t2,o.t3,o.t4,o.t5,o.t6,"",o.t7);case 20:return(a=o.sent).rollType="attribute",o.abrupt("return",a);case 23:case"end":return o.stop()}}),_callee9,this)}))),function rollAttribute(t){return _rollAttribute.apply(this,arguments)})},{key:"damageFormula",value:(_damageFormula=_asyncToGenerator(_regeneratorRuntime().mark((function _callee10(t){var r,a,o;return _regeneratorRuntime().wrap((function _callee10$(i){for(;;)switch(i.prev=i.next){case 0:return"meleeweapon"==t.source.type?(a=_actor_actor_dsa5_js__WEBPACK_IMPORTED_MODULE_0__.Z._calculateCombatSkillValues(t.extra.actor.items.find((function(r){return"combatskill"==r.type&&r.name==t.source.system.combatskill.value})),t.extra.actor.system),r=_actor_actor_dsa5_js__WEBPACK_IMPORTED_MODULE_0__.Z._prepareMeleeWeapon(t.source,[a],t.extra.actor)):"rangeweapon"==t.source.type?(o=_actor_actor_dsa5_js__WEBPACK_IMPORTED_MODULE_0__.Z._calculateCombatSkillValues(t.extra.actor.items.find((function(r){return"combatskill"==r.type&&r.name==t.source.system.combatskill.value})),t.extra.actor.system),r=_actor_actor_dsa5_js__WEBPACK_IMPORTED_MODULE_0__.Z._prepareRangeWeapon(t.source,[],[o],t.extra.actor)):r=t.source.system,i.abrupt("return",t.source.system.damage.value.replace(/[Ww]/g,"d")+"+".concat(r.extraDamage||0));case 2:case"end":return i.stop()}}),_callee10)}))),function damageFormula(t){return _damageFormula.apply(this,arguments)})},{key:"rollDamage",value:(_rollDamage=_asyncToGenerator(_regeneratorRuntime().mark((function _callee11(t){var r,a,o,i,c,u,l,p,d,h;return _regeneratorRuntime().wrap((function _callee11$(m){for(;;)switch(m.prev=m.next){case 0:return m.next=2,this._situationalModifiers(t);case 2:r=m.sent,a=[],o=t.roll,i=o.total+r,c=_createForOfIteratorHelper(o.terms);try{for(c.s();!(u=c.n()).done;)if((l=u.value)instanceof Die||"Die"==l.class){p=_createForOfIteratorHelper(l.results);try{for(p.s();!(d=p.n()).done;)h=d.value,a.push({char:t.mode,res:h.result,die:"d"+l.faces})}catch(t){p.e(t)}finally{p.f()}}}catch(t){c.e(t)}finally{c.f()}return m.abrupt("return",{rollType:"damage",damage:i,characteristics:a,preData:t,modifiers:r,extra:{}});case 9:case"end":return m.stop()}}),_callee11,this)}))),function rollDamage(t){return _rollDamage.apply(this,arguments)})},{key:"_situationalModifiers",value:(_situationalModifiers2=_asyncToGenerator(_regeneratorRuntime().mark((function _callee12(t){var r,a,o,i,c,u,l=arguments;return _regeneratorRuntime().wrap((function _callee12$(p){for(;;)switch(p.prev=p.next){case 0:r=l.length>1&&void 0!==l[1]?l[1]:"",a=0,o=_createForOfIteratorHelper(t.situationalModifiers),p.prev=3,o.s();case 5:if((i=o.n()).done){p.next=18;break}if(null!=(c=i.value).value){p.next=9;break}return p.abrupt("continue",16);case 9:if(p.t0=Number(c.value),p.t0){p.next=14;break}return p.next=13,this._stringToRoll(c.value);case 13:p.t0=p.sent;case 14:u=p.t0,a+=c.type==r||""==r&&null==c.type?u:0;case 16:p.next=5;break;case 18:p.next=23;break;case 20:p.prev=20,p.t1=p.catch(3),o.e(p.t1);case 23:return p.prev=23,o.f(),p.finish(23);case 26:return p.abrupt("return",a);case 27:case"end":return p.stop()}}),_callee12,this,[[3,20,23,26]])}))),function _situationalModifiers(t){return _situationalModifiers2.apply(this,arguments)})},{key:"_situationalPartCheckModifiers",value:function _situationalPartCheckModifiers(t){return t.situationalModifiers.reduce((function(t,r){if("TPM"==r.type){var a=r.value.split("|");return 3!=a.length||(t[0]=t[0]+Number(a[0]),t[1]=t[1]+Number(a[1]),t[2]=t[2]+Number(a[2])),t}return t}),[0,0,0])}},{key:"_situationalMultipliers",value:function _situationalMultipliers(t){return t.situationalModifiers.reduce((function(t,r){return t*("*"==r.type&&Number("".concat(r.value).replace(/,/,"."))||1)}),1)}},{key:"_appendSituationalModifiers",value:function _appendSituationalModifiers(t,r,a){var o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"",i=t.situationalModifiers.find((function(t){return t.name==r}));i?i.value=a:t.situationalModifiers.push({name:r,value:a,type:o})}},{key:"rollCombatTrait",value:(_rollCombatTrait=_asyncToGenerator(_regeneratorRuntime().mark((function _callee13(t){var r,a,o,i,c,u,l,p;return _regeneratorRuntime().wrap((function _callee13$(d){for(;;)switch(d.prev=d.next){case 0:if(d.t0=t.roll,d.t0){d.next=5;break}return d.next=4,new Roll("1d20").evaluate({async:!0});case 4:d.t0=d.sent;case 5:return r=d.t0,a=t.source,o="meleeAttack"==a.system.traitType.value,i="attack"==t.mode,o&&(c={system:{combatskill:{value:"-"},reach:{value:a.system.reach.value}}},this._appendSituationalModifiers(t,game.i18n.localize("opposingWeaponSize"),this._compareWeaponReach(c,t))),d.t1=this,d.t2=r,d.t3=Number(i?a.system.at.value:a.system.pa),d.t4=t.mode,d.next=16,this._situationalModifiers(t);case 16:return d.t5=d.sent,d.t6=t,d.t7=this._situationalMultipliers(t),d.next=21,d.t1._rollSingleD20.call(d.t1,d.t2,d.t3,d.t4,d.t5,d.t6,"",d.t7);case 21:return u=d.sent,l=u.successLevel>0,d.next=25,this.detailedWeaponResult(u,t,a);case 25:if(!i||!l){d.next=28;break}return d.next=28,DiceDSA5.evaluateDamage(t,u,a,!o,u.doubleDamage);case 28:return u.rollType="weapon",(p=DiceDSA5.parseEffect(a))&&(u.parsedEffect=p),d.abrupt("return",u);case 32:case"end":return d.stop()}}),_callee13,this)}))),function rollCombatTrait(t){return _rollCombatTrait.apply(this,arguments)})},{key:"_stringToRoll",value:(_stringToRoll2=_asyncToGenerator(_regeneratorRuntime().mark((function _callee14(t,r){var a,o,i,c,u;return _regeneratorRuntime().wrap((function _callee14$(l){for(;;)switch(l.prev=l.next){case 0:return a=[],o=/\d{1}[dDwW]\d/g,(i="".concat(t)).replace(o,(function(t){a.push(new Roll(t.replace(/[Ww]/,"d")).evaluate({async:!0}))})),l.next=6,Promise.all(a);case 6:return c=l.sent,u=i.replace(o,(function(){var t=c.shift();return r&&DiceDSA5._addRollDiceSoNice(r,t,game.dsa5.apps.DiceSoNiceCustomization.getAttributeConfiguration("ch")),t.total})),l.next=10,Roll.safeEval(u);case 10:return l.abrupt("return",l.sent);case 11:case"end":return l.stop()}}),_callee14)}))),function _stringToRoll(t,r){return _stringToRoll2.apply(this,arguments)})},{key:"evaluateDamage",value:(_evaluateDamage=_asyncToGenerator(_regeneratorRuntime().mark((function _callee15(t,r,a,o,i){var c,u,l,p,d,h,m,y,g,v,_,b,k,w,x,S,T,A,O,P,E,C,D,I,R,L,G,M;return _regeneratorRuntime().wrap((function _callee15$(j){for(;;)switch(j.prev=j.next){case 0:c=a.system.damage.value.replace(/[Ww]/g,"d"),u=[],l=a.dmgMultipliers||[],p=l.map((function(t){return"".concat(t.name," *").concat(t.val)})),d=[],h=0,m=_createForOfIteratorHelper(t.situationalModifiers),j.prev=7,m.s();case 9:if((y=m.n()).done){j.next=33;break}if(g=y.value,v=0,g.armorPen&&d.push(g.armorPen),!g.damageBonus){j.next=31;break}if(!/^\*/.test(g.damageBonus)){j.next=17;break}return l.push({name:g.name,val:Number(g.damageBonus.replace("*",""))}),j.abrupt("continue",31);case 17:return _=/^=/.test(g.damageBonus),b="".concat(g.damageBonus).replace(/^=/,""),j.next=21,DiceDSA5._stringToRoll(b,t);case 21:if(k=j.sent,v=k*(g.step||1),!_){j.next=29;break}return c=b.replace(/[Ww]/,"d"),u.push({name:g.name,roll:k}),j.abrupt("continue",31);case 29:g.damageBonus=k,h+=v;case 31:j.next=9;break;case 33:j.next=38;break;case 35:j.prev=35,j.t0=j.catch(7),m.e(j.t0);case 38:return j.prev=38,m.f(),j.finish(38);case 41:if(!t.damageRoll){j.next=45;break}j.t1=t.damageRoll,j.next=53;break;case 45:return j.t2=DiceDSA5,j.next=48,new Roll(c).evaluate({async:!0});case 48:return j.t3=j.sent,j.t4=t.extra.options,j.next=52,j.t2.manualRolls.call(j.t2,j.t3,"CHAR.DAMAGE",j.t4);case 52:j.t1=j.sent;case 53:w=j.t1,x=w.total,S=0,T=_createForOfIteratorHelper(w.terms);try{for(T.s();!(A=T.n()).done;)if((O=A.value)instanceof Die||"Die"==O.class){P=_createForOfIteratorHelper(O.results);try{for(P.s();!(E=P.n()).done;)C=E.value,S+=Number(C.result),r.characteristics.push({char:"damage",res:C.result,die:"d"+O.faces})}catch(t){P.e(t)}finally{P.f()}}}catch(t){T.e(t)}finally{T.f()}if(D=x-S,!(u.length>0)){j.next=63;break}p.push(u[0].name+" "+x),j.next=74;break;case 63:return x+=h,p.push(game.i18n.localize("Roll")+" "+S),0!=D&&p.push(game.i18n.localize("weaponModifier")+" "+D),t.situationalModifiers.reduce((function(t,r){if(r.damageBonus){var a=/^\*/.test(r.damageBonus)?r.damageBonus:Number(r.damageBonus)*(r.step||1);p.push("".concat(r.name," ").concat(a))}}),p),t.situationalModifiers.find((function(t){return t.name.indexOf(game.i18n.localize("CONDITION.bloodrush"))>-1}))&&(x+=2,p.push(game.i18n.localize("CONDITION.bloodrush")+" 2")),a.extraDamage&&(x=Number(a.extraDamage)+Number(x),p.push(game.i18n.localize("damageThreshold")+" "+a.extraDamage)),I=t.extra.actor.system[o?"rangeStats":"meleeStats"].damage,j.next=72,DiceDSA5._stringToRoll(I,t);case 72:0!=(R=j.sent)&&(x+=R,p.push(game.i18n.localize("statuseffects")+" "+R));case 74:i&&(x*=i,p.push(game.i18n.format("doubleDamage",{x:i}))),L=_createForOfIteratorHelper(l);try{for(L.s();!(G=L.n()).done;)M=G.value,x*=M.val}catch(t){L.e(t)}finally{L.f()}r.armorPen=d,r.damagedescription=p.join(", "),r.damage=Math.round(x),r.damageRoll=duplicate(w);case 81:case"end":return j.stop()}}),_callee15,null,[[7,35,38,41]])}))),function evaluateDamage(t,r,a,o,i){return _evaluateDamage.apply(this,arguments)})},{key:"rollWeapon",value:(_rollWeapon=_asyncToGenerator(_regeneratorRuntime().mark((function _callee16(t){var r,a,o,i,c,u,l,p;return _regeneratorRuntime().wrap((function _callee16$(d){for(;;)switch(d.prev=d.next){case 0:if(d.t0=t.roll,d.t0){d.next=5;break}return d.next=4,new Roll("1d20").evaluate({async:!0});case 4:d.t0=d.sent;case 5:return r=d.t0,o=t.source,i=o.system.combatskill.value,c=_actor_actor_dsa5_js__WEBPACK_IMPORTED_MODULE_0__.Z._calculateCombatSkillValues(t.extra.actor.items.find((function(t){return"combatskill"==t.type&&t.name==i})),t.extra.actor.system),(u="meleeweapon"==o.type)?(a=_actor_actor_dsa5_js__WEBPACK_IMPORTED_MODULE_0__.Z._prepareMeleeWeapon(o,[c],t.extra.actor),"attack"==t.mode&&this._appendSituationalModifiers(t,game.i18n.localize("opposingWeaponSize"),this._compareWeaponReach(a,t))):a=_actor_actor_dsa5_js__WEBPACK_IMPORTED_MODULE_0__.Z._prepareRangeWeapon(o,[],[c],t.extra.actor),d.t1=this,d.t2=r,d.t3=a[t.mode],d.t4=t.mode,d.next=17,this._situationalModifiers(t);case 17:return d.t5=d.sent,d.t6=t,d.t7=i,d.t8=this._situationalMultipliers(t),d.next=23,d.t1._rollSingleD20.call(d.t1,d.t2,d.t3,d.t4,d.t5,d.t6,d.t7,d.t8);case 23:return l=d.sent,d.next=26,this.detailedWeaponResult(l,t,o);case 26:if(!("attack"==t.mode&&l.successLevel>0)||t.extra.counterAttack){d.next=29;break}return d.next=29,DiceDSA5.evaluateDamage(t,l,a,!u,l.doubleDamage);case 29:return t.extra.counterAttack&&(_utility_dsa5_js__WEBPACK_IMPORTED_MODULE_3__.Z.getSpeaker(t.extra.speaker).addCondition("stunned"),l.description+=", "+_utility_dsa5_js__WEBPACK_IMPORTED_MODULE_3__.Z.replaceConditions(game.i18n.localize("stunnedByCounterAttack"))),l.rollType="weapon",(p=DiceDSA5.parseEffect(a))&&(l.parsedEffect=p),d.abrupt("return",l);case 34:case"end":return d.stop()}}),_callee16,this)}))),function rollWeapon(t){return _rollWeapon.apply(this,arguments)})},{key:"detailedWeaponResult",value:(_detailedWeaponResult=_asyncToGenerator(_regeneratorRuntime().mark((function _callee17(t,r,a){var o,i,c;return _regeneratorRuntime().wrap((function _callee17$(u){for(;;)switch(u.prev=u.next){case 0:o="attack"==r.mode&&!r.extra.counterAttack,i="meleeweapon"==a.type||"meleeAttack"==getProperty(a,"system.traitType.value"),u.t0=t.successLevel,u.next=3===u.t0?5:-3===u.t0?34:2===u.t0?67:-2===u.t0?69:70;break;case 5:if(!o){u.next=17;break}return u.next=8,_tables_dsatables_js__WEBPACK_IMPORTED_MODULE_14__.Z.tableEnabledFor("criticalAttack");case 8:if(!u.sent){u.next=12;break}t.description+=_tables_dsatables_js__WEBPACK_IMPORTED_MODULE_14__.Z.rollCritBotchButton("criticalAttack",!1,r),u.next=14;break;case 12:t.description+=_tables_dsatables_js__WEBPACK_IMPORTED_MODULE_14__.Z.defaultAttackCrit(!0),t.doubleDamage=2;case 14:t.halfDefense=!0,u.next=33;break;case 17:if(u.t1=r.isRangeDefense,!u.t1){u.next=22;break}return u.next=21,_tables_dsatables_js__WEBPACK_IMPORTED_MODULE_14__.Z.tableEnabledFor("criticalRangeDefense");case 21:u.t1=u.sent;case 22:if(!u.t1){u.next=26;break}t.description+=_tables_dsatables_js__WEBPACK_IMPORTED_MODULE_14__.Z.rollCritBotchButton("criticalRangeDefense",!1,r),u.next=33;break;case 26:return u.next=28,_tables_dsatables_js__WEBPACK_IMPORTED_MODULE_14__.Z.tableEnabledFor("criticalMeleeDefense");case 28:if(!u.sent){u.next=32;break}t.description+=_tables_dsatables_js__WEBPACK_IMPORTED_MODULE_14__.Z.rollCritBotchButton("criticalMeleeDefense",!1,r),u.next=33;break;case 32:t.description+=_tables_dsatables_js__WEBPACK_IMPORTED_MODULE_14__.Z.defaultParryCrit();case 33:return u.abrupt("break",70);case 34:if(c=getProperty(a,"system.combatskill.value")==game.i18n.localize("LocalizedIDs.wrestle")||"trait"==a.type,u.t2=o&&i,!u.t2){u.next=40;break}return u.next=39,_tables_dsatables_js__WEBPACK_IMPORTED_MODULE_14__.Z.tableEnabledFor("Melee");case 39:u.t2=u.sent;case 40:if(!u.t2){u.next=44;break}t.description+=_tables_dsatables_js__WEBPACK_IMPORTED_MODULE_14__.Z.rollCritBotchButton("Melee",c,r),u.next=66;break;case 44:if(u.t3=o,!u.t3){u.next=49;break}return u.next=48,_tables_dsatables_js__WEBPACK_IMPORTED_MODULE_14__.Z.tableEnabledFor("Range");case 48:u.t3=u.sent;case 49:if(!u.t3){u.next=53;break}t.description+=_tables_dsatables_js__WEBPACK_IMPORTED_MODULE_14__.Z.rollCritBotchButton("Range",!1,r),u.next=66;break;case 53:if(u.t4=!o,!u.t4){u.next=58;break}return u.next=57,_tables_dsatables_js__WEBPACK_IMPORTED_MODULE_14__.Z.tableEnabledFor("Defense");case 57:u.t4=u.sent;case 58:if(!u.t4){u.next=62;break}t.description+=_tables_dsatables_js__WEBPACK_IMPORTED_MODULE_14__.Z.rollCritBotchButton("Defense",c,r),u.next=66;break;case 62:return u.t5=t.description,u.next=65,_tables_dsatables_js__WEBPACK_IMPORTED_MODULE_14__.Z.defaultBotch();case 65:t.description=u.t5+=u.sent;case 66:return u.abrupt("break",70);case 67:return o&&(t.description+=_tables_dsatables_js__WEBPACK_IMPORTED_MODULE_14__.Z.defaultAttackCrit(!1),t.halfDefense=!0),u.abrupt("break",70);case 69:return u.abrupt("break",70);case 70:case"end":return u.stop()}}),_callee17)}))),function detailedWeaponResult(t,r,a){return _detailedWeaponResult.apply(this,arguments)})},{key:"_addRollDiceSoNice",value:(_addRollDiceSoNice2=_asyncToGenerator(_regeneratorRuntime().mark((function _callee18(t,r,a){var o;return _regeneratorRuntime().wrap((function _callee18$(i){for(;;)switch(i.prev=i.next){case 0:if(!t.rollMode){i.next=4;break}for(o=0;o1&&void 0!==b[1]?b[1]:"",!(a=b.length>2&&void 0!==b[2]?b[2]:{}).cheat&&!game.settings.get("dsa5","allowPhysicalDice")){k.next=21;break}if(a.predefinedResult){k.next=20;break}o=!1,c=[],u=_createForOfIteratorHelper(t.terms);try{for(u.s();!(l=u.n()).done;)if((p=l.value)instanceof Die||"Die"==p.class){d=_createForOfIteratorHelper(p.results);try{for(d.s();!(h=d.n()).done;)m=h.value,c.push({faces:p.faces,val:m.result})}catch(t){d.e(t)}finally{d.f()}}}catch(t){u.e(t)}finally{u.f()}return k.next=10,renderTemplate("systems/dsa5/templates/dialog/manualroll-dialog.html",{dice:c,description:r});case 10:return y=k.sent,k.next=13,new Promise((function(t,r){new _dialog_dialog_dsa5_js__WEBPACK_IMPORTED_MODULE_2__.Z({title:game.i18n.localize(a.cheat?"DIALOG.cheat":"DSASETTINGS.allowPhysicalDice"),content:y,default:"ok",buttons:{ok:{icon:'',label:game.i18n.localize("yes"),callback:function callback(r){t([!0,r])}},cancel:{icon:'',label:game.i18n.localize("cancel"),callback:function callback(){t([!1,0])}}}}).render(!0)}));case 13:g=k.sent,v=_slicedToArray(g,2),o=v[0],i=v[1],o&&(_=[],i.find(".dieInput").each((function(t){var r=Number($(this).val());r>0&&_.push({val:r,index:t}),t++})),t.editRollAtIndex(_)),k.next=21;break;case 20:t.editRollAtIndex(a.predefinedResult);case 21:return k.abrupt("return",t);case 22:case"end":return k.stop()}}),_callee20)}))),function manualRolls(t){return _manualRolls.apply(this,arguments)})},{key:"parseEffect",value:function parseEffect(t){var r=t.system.effect?t.system.effect.value:void 0,a=[];if(r){var o,i=/^[a-z]+\|[öäüÖÄÜa-zA-z ]+$/,c=_createForOfIteratorHelper(r.split(";"));try{for(c.s();!(o=c.n()).done;){var u=o.value;i.test(u.trim())&&function(){var t=u.split("|").map((function(t){return t.trim()}));if("condition"==t[0]){var r=CONFIG.statusEffects.find((function(r){return r.id==t[1]}));a.push('\n ').concat(game.i18n.localize(r.name),"\n "))}else a.push('').concat(game.i18n.localize(t[0]),": ").concat(t[1],""))}()}}catch(t){c.e(t)}finally{c.f()}}var l=getProperty(t,"flags.dsa5.poison");return l&&a.push('').concat(game.i18n.localize("poison"),": ").concat(l.name,"")),a.join(", ")}},{key:"calculateEnergyCost",value:(_calculateEnergyCost=_asyncToGenerator(_regeneratorRuntime().mark((function _callee21(t,r,a){var o,i,c,u,l,p,d,h;return _regeneratorRuntime().wrap((function _callee21$(m){for(;;)switch(m.prev=m.next){case 0:return o=[],r.successLevel<0&&(p=["traditionWitch","traditionFjarning","braniborian"].map((function(t){return game.i18n.localize("LocalizedIDs.".concat(t))})),d=a.extra.actor.items.some((function(t){return"specialability"==t.type&&p.includes(t.name)}))?3:2,r.preData.calculatedSpellModifiers.finalcost=Math.round(r.preData.calculatedSpellModifiers.finalcost/d)),t?(l="KaPCost",i=game.i18n.localize("LocalizedIDs.weakKarmicBody"),c=game.i18n.localize("LocalizedIDs.".concat(r.successLevel>0?"mightyKarmaControl":"karmaControl")),u={val:"kapModifier",name:"KaP"}):(l="AsPCost",i=game.i18n.localize("LocalizedIDs.weakAstralBody"),c=game.i18n.localize("LocalizedIDs.".concat(r.successLevel>0?"energyControl":"smallEnergyControl")),u={val:"aspModifier",name:"AsP"}),m.t0=o,m.t1={name:i,value:_advantage_rules_dsa5_js__WEBPACK_IMPORTED_MODULE_4__.Z.vantageStep(a.extra.actor,i)},m.t2={name:c,value:-1*_specialability_rules_dsa5_js__WEBPACK_IMPORTED_MODULE_5__.Z.abilityStep(a.extra.actor,c)},m.t3="".concat(game.i18n.localize("statuseffects")," (").concat(game.i18n.localize("CHARAbbrev."+u.name),")"),m.t4=a.extra.actor.system[u.val],m.next=10,this._situationalModifiers(a,l);case 10:m.t5=m.sent,m.t6=m.t4+m.t5,m.t7={name:m.t3,value:m.t6},m.t0.push.call(m.t0,m.t1,m.t2,m.t7),o=o.filter((function(t){return 0!=t.value})),r.preData.calculatedSpellModifiers.description=o.map((function(t){return"".concat(t.name," ").concat(t.value)})).join("\n"),r.preData.calculatedSpellModifiers.finalcost=Math.max(1,Number(r.preData.calculatedSpellModifiers.finalcost)+o.reduce((function(t,r){return t+r.value}),0)),r.successLevel>0&&0!=r.preData.calculatedSpellModifiers.maintainCost&&((h=r.preData.calculatedSpellModifiers.maintainCost.split(" "))[0]=Math.round(Number(h[0])),r.preData.calculatedSpellModifiers.finalcost+=h[0],r.preData.calculatedSpellModifiers.maintainCost=h.join(" "));case 18:case"end":return m.stop()}}),_callee21,this)}))),function calculateEnergyCost(t,r,a){return _calculateEnergyCost.apply(this,arguments)})},{key:"rollSpell",value:(_rollSpell=_asyncToGenerator(_regeneratorRuntime().mark((function _callee22(t){var r,a,o,i,c,u,l,p,d,h,m,y,g,v,_,b,k;return _regeneratorRuntime().wrap((function _callee22$(w){for(;;)switch(w.prev=w.next){case 0:return w.next=2,this._rollThreeD20(t);case 2:if(r=w.sent,a=["ceremony","liturgy"].includes(t.source.type),r.rollType=t.source.type,r.preData.calculatedSpellModifiers.finalcost=r.preData.calculatedSpellModifiers.cost,!(r.successLevel>=2)){w.next=16;break}return w.next=9,new Roll("1d6").evaluate({async:!0});case 9:o=w.sent.total,r.description=r.description+", "+game.i18n.localize("additionalFPs")+" "+o,r.result+=o,r.qualityStep=Math.min(game.settings.get("dsa5","capQSat"),Math.ceil(r.result/3)),r.preData.calculatedSpellModifiers.finalcost=Math.round(r.preData.calculatedSpellModifiers.cost/2),w.next=17;break;case 16:r.successLevel<=-2&&(r.description+=_tables_dsatables_js__WEBPACK_IMPORTED_MODULE_14__.Z.rollCritBotchButton(a?"Liturgy":"Spell",!1,t));case 17:if(!(r.successLevel>0)){w.next=50;break}if(""==t.source.system.effectFormula.value){w.next=50;break}i=t.source.system.effectFormula.value.replace(game.i18n.localize("CHARAbbrev.QS"),r.qualityStep).replace(/[Ww]/g,"d"),c=[],u=_createForOfIteratorHelper(t.situationalModifiers);try{for(u.s();!(l=u.n()).done;)(p=l.value).armorPen&&c.push(p.armorPen)}catch(t){u.e(t)}finally{u.f()}if(/(,|;)/.test(i)&&(i=i.split(/[,;]/)[r.qualityStep-1]),!t.damageRoll){w.next=28;break}w.t0=t.damageRoll,w.next=36;break;case 28:return w.t1=DiceDSA5,w.next=31,new Roll(i).evaluate({async:!0});case 31:return w.t2=w.sent,w.t3=t.extra.options,w.next=35,w.t1.manualRolls.call(w.t1,w.t2,"CHAR.DAMAGE",w.t3);case 35:w.t0=w.sent;case 36:d=w.t0,this._addRollDiceSoNice(t,d,game.dsa5.apps.DiceSoNiceCustomization.getAttributeConfiguration("damage")),r.calculatedEffectFormula=i,h=_createForOfIteratorHelper(d.terms);try{for(h.s();!(m=h.n()).done;)if((y=m.value)instanceof Die||"Die"==y.class){g=_createForOfIteratorHelper(y.results);try{for(g.s();!(v=g.n()).done;)_=v.value,r.characteristics.push({char:"effect",res:_.result,die:"d"+y.faces})}catch(t){g.e(t)}finally{g.f()}}}catch(t){h.e(t)}finally{h.f()}return b=[],w.next=44,DiceDSA5._stringToRoll(t.extra.actor.system[a?"liturgyStats":"spellStats"].damage,t);case 44:0!=(k=w.sent)&&b.push(game.i18n.localize("statuseffects")+" "+k),r.armorPen=c,r.damageRoll=d,r.damage=d.total+k,r.damagedescription=b.join("\n");case 50:return w.next=52,this.calculateEnergyCost(a,r,t);case 52:if(!_advantage_rules_dsa5_js__WEBPACK_IMPORTED_MODULE_4__.Z.hasVantage(t.extra.actor,game.i18n.localize("CONDITION.minorSpirits"))||t.extra.actor.effects.find((function(t){return t.name==game.i18n.localize("CONDITION.minorSpirits")}))){w.next=57;break}return w.next=55,new Roll("1d20").evaluate({async:!0});case 55:w.sent.total<=r.preData.calculatedSpellModifiers.finalcost&&(r.description+=", "+game.i18n.localize("minorghostsappear"),_utility_dsa5_js__WEBPACK_IMPORTED_MODULE_3__.Z.getSpeaker(t.extra.speaker).addCondition("minorSpirits"));case 57:return w.abrupt("return",r);case 58:case"end":return w.stop()}}),_callee22,this)}))),function rollSpell(t){return _rollSpell.apply(this,arguments)})},{key:"_rollThreeD20",value:(_rollThreeD=_asyncToGenerator(_regeneratorRuntime().mark((function _callee23(t){var r,a,o,i,c,u,l,p,d,h,m,y,g,v,_,b,k,w;return _regeneratorRuntime().wrap((function _callee23$(x){for(;;)switch(x.prev=x.next){case 0:if(!t.roll){x.next=4;break}x.t0=Roll.fromData(t.roll),x.next=7;break;case 4:return x.next=6,new Roll("1d20+1d20+1d20").evaluate({async:!0});case 6:x.t0=x.sent;case 7:return r=x.t0,a=[],o=0,this._appendSituationalModifiers(t,game.i18n.localize("Difficulty"),t.testDifficulty),x.next=13,this._situationalModifiers(t);case 13:return i=x.sent,x.t1=t.source.system.talentValue.value+t.advancedModifiers.fws,x.next=17,this._situationalModifiers(t,"FW");case 17:if(x.t2=x.sent,c=x.t1+x.t2,u=this._situationalPartCheckModifiers(t,"TPM"),l=[1,2,3].map((function(r){return t.extra.actor.system.characteristics[t.source.system["characteristic".concat(r)].value].value+i+t.advancedModifiers.chars[r-1]+u[r-1]})),p=[0,1,2].map((function(t){return r.terms[2*t].results[0].result-l[t]})),t.routine)c=Math.round(c/2);else{d=_createForOfIteratorHelper(p);try{for(d.s();!(h=d.n()).done;)(m=h.value)>0&&(c-=m)}catch(t){d.e(t)}finally{d.f()}}if(y=t.extra.actor.system.skillModifiers.crit,g=t.extra.actor.system.skillModifiers.botch,["spell","ritual"].includes(t.source.type)&&_advantage_rules_dsa5_js__WEBPACK_IMPORTED_MODULE_4__.Z.hasVantage(t.extra.actor,game.i18n.localize("LocalizedIDs.wildMagic"))&&(g=19),"skill"!=t.source.type||!_advantage_rules_dsa5_js__WEBPACK_IMPORTED_MODULE_4__.Z.hasVantage(t.extra.actor,"".concat(game.i18n.localize("LocalizedIDs.incompetent")," (").concat(t.source.name,")"))){x.next=37;break}return x.next=29,new Roll("1d20").evaluate({async:!0});case 29:v=x.sent,_=p.reduce((function(t,r,a,o){return r0)){x.next=51;break}return x.t3=c,x.next=45,this._situationalModifiers(t,"FP");case 45:return c=x.t3+=x.sent,x.t4=Math.max(1,(0==c?1:c>0?Math.ceil(c/3):0)+(null!=t.qualityStep?Number(t.qualityStep):0))+(t.advancedModifiers.qls||0),x.next=49,this._situationalModifiers(t,"QL");case 49:x.t5=x.sent,w=x.t4+x.t5;case 51:return(w=Math.min(game.settings.get("dsa5","capQSat"),w))2&&void 0!==arguments[2]?arguments[2]:20,o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1,i=t.terms.filter((function(t){return t.results&&t.results[0].result<=o})).length,c=t.terms.filter((function(t){return t.results&&t.results[0].result>=a})).length;return i>=2?i:c>=2?-1*c:r>=0?1:-1}},{key:"getSuccessDescription",value:function getSuccessDescription(t){return game.i18n.localize(["AstoundingFailure","CriticalFailure","Failure","","Success","CriticalSuccess","AstoundingSuccess"][t+3])}},{key:"rollItem",value:(_rollItem=_asyncToGenerator(_regeneratorRuntime().mark((function _callee25(t){var r,a,o,i,c,u,l,p,d,h,m,y,g,v,_;return _regeneratorRuntime().wrap((function _callee25$(b){for(;;)switch(b.prev=b.next){case 0:if(b.t0=t.roll,b.t0){b.next=5;break}return b.next=4,new Roll("1d20+1d20+1d20").evaluate({async:!0});case 4:b.t0=b.sent;case 5:return r=b.t0,a=[],b.next=9,this._situationalModifiers(t);case 9:o=b.sent,i=Number(t.source.system.step.value),c=[1,2,3].map((function(r){return 10+Number(t.source.system.step.value)+o})),u=[0,1,2].map((function(t){return r.terms[2*t].results[0].result-c[t]})),l=_createForOfIteratorHelper(u);try{for(l.s();!(p=l.n()).done;)(d=p.value)>0&&(i-=d)}catch(t){l.e(t)}finally{l.f()}h=DiceDSA5.get3D20SuccessLevel(r,i,20),a.push(DiceDSA5.getSuccessDescription(h)),a=a.join(", "),m={result:i,characteristics:[0,1,2].map((function(a){return{char:t.source.type,res:r.terms[2*a].results[0].result,suc:u[a]<=0,tar:c[a]}})),qualityStep:Math.min(game.settings.get("dsa5","capQSat"),(0==i?1:i>0?Math.ceil(i/3):0)+(null!=t.qualityStep?Number(t.qualityStep):0)),description:a,preData:t,successLevel:h,modifiers:o,extra:{}},b.t1=t.source.type,b.next="poison"===b.t1?23:"disease"===b.t1?28:33;break;case 23:return y=t.source.system.duration.value.split(" / ").map((function(t){return t.trim()})),g=t.source.system.effect.value.split(" / ").map((function(t){return t.trim()})),m.duration=y.length>1?m.successLevel>0?y[0]:y[1]:y[0],m.effect=g.length>1?m.successLevel>0?g[0]:g[1]:g[0],b.abrupt("break",33);case 28:return v=t.source.system.damage.value.split(" / ").map((function(t){return t.trim()})),_=t.source.system.duration.value.split(" / ").map((function(t){return t.trim()})),m.damageeffect=v.length>1?m.successLevel>0?v[0]:v[1]:v[0],m.duration=_.length>1?m.successLevel>0?_[0]:_[1]:_[0],b.abrupt("break",33);case 33:return b.abrupt("return",m);case 34:case"end":return b.stop()}}),_callee25,this)}))),function rollItem(t){return _rollItem.apply(this,arguments)})},{key:"updateDefenseCount",value:(_updateDefenseCount=_asyncToGenerator(_regeneratorRuntime().mark((function _callee26(t){return _regeneratorRuntime().wrap((function _callee26$(r){for(;;)switch(r.prev=r.next){case 0:if(!game.combat){r.next=3;break}return r.next=3,game.combat.updateDefenseCount(t.extra.speaker);case 3:case"end":return r.stop()}}),_callee26)}))),function updateDefenseCount(t){return _updateDefenseCount.apply(this,arguments)})},{key:"_compareWeaponReach",value:function _compareWeaponReach(t,r){var a=r.situationalModifiers.find((function(t){return t.name==game.i18n.localize("LocalizedIDs.circumvent")})),o=_config_dsa5_js__WEBPACK_IMPORTED_MODULE_1__.Z.meleeRangesArray.indexOf(t.system.reach.value),i=_config_dsa5_js__WEBPACK_IMPORTED_MODULE_1__.Z.meleeRangesArray.indexOf(r.opposingWeaponSize);return a&&i>o&&(a.value=2*Math.min(a.step,i-o)),2*Math.min(0,o-i)}},{key:"showDiceSoNice",value:(_showDiceSoNice=_asyncToGenerator(_regeneratorRuntime().mark((function _callee27(t,r){var a,o,i;return _regeneratorRuntime().wrap((function _callee27$(c){for(;;)switch(c.prev=c.next){case 0:if(!_utility_dsa5_js__WEBPACK_IMPORTED_MODULE_3__.Z.moduleEnabled("dice-so-nice")||!game.dice3d){c.next=17;break}a=null,o=!1,c.t0=r,c.next="blindroll"===c.t0?6:"gmroll"===c.t0?9:"selfroll"===c.t0?11:13;break;case 6:return o=!0,a=game.users.filter((function(t){return t.isGM})).map((function(t){return t.id})),c.abrupt("break",13);case 9:return a=game.users.filter((function(t){return t.isGM})).map((function(t){return t.id})),c.abrupt("break",13);case 11:return a=[],c.abrupt("break",13);case 13:if(i=game.dice3d.showForRoll(t,game.user,!0,a,o),game.settings.get("dice-so-nice","immediatelyDisplayChatMessages")){c.next=17;break}return c.next=17,i;case 17:case"end":return c.stop()}}),_callee27)}))),function showDiceSoNice(t,r){return _showDiceSoNice.apply(this,arguments)})},{key:"addApplyEffectData",value:function addApplyEffectData(t){var r=t.preData.source;if(t.successLevel>0){if(["meleeweapon","rangeweapon"].includes(r.type)||"trait"==r.type&&["rangeAttack","meleeAttack"].includes(r.system.traitType.value)){if(r.effects.some((function(t){return!getProperty(t,"flags.dsa5.applyToOwner")})))return!0}else if(["spell","liturgy","ritual","ceremony","trait"].includes(r.type)&&r.effects.length>0)return!0}else if(["disease","poison"].includes(r.type))return r.effects.length>0;var a=t.preData.situationalModifiers.filter((function(t){return t.specAbId})).map((function(t){return t.specAbId}));if(a.length>0){var o,i=_createForOfIteratorHelper(t.preData.extra.actor.items.filter((function(t){return a.includes(t._id)})));try{for(i.s();!(o=i.n()).done;){if(o.value.effects.length>0)return!0}}catch(t){i.e(t)}finally{i.f()}}return!1}},{key:"renderRollCard",value:function(){var _renderRollCard=_asyncToGenerator(_regeneratorRuntime().mark((function _callee28(chatOptions,testData,rerenderMessage){var applyEffect,immuneTo,preData,hideDamage,hasAreaTemplate,chatData,postFunction,html,actor,rollData,enriched,newMsg;return _regeneratorRuntime().wrap((function _callee28$(_context28){for(;;)switch(_context28.prev=_context28.next){case 0:return applyEffect=this.addApplyEffectData(testData),immuneTo=_creature_type_js__WEBPACK_IMPORTED_MODULE_18__.Z.checkImmunity(testData),preData=deepClone(testData.preData),hideDamage=rerenderMessage?rerenderMessage.flags.data.hideDamage:"attack"==preData.mode,Hooks.call("postProcessDSARoll",chatOptions,testData,rerenderMessage,hideDamage),_context28.next=7,_utility_dsa5_js__WEBPACK_IMPORTED_MODULE_3__.Z.callAsyncHooks("postProcessDSARoll",[testData]);case 7:return delete preData.extra.actor,delete testData.actor,delete testData.preData,hasAreaTemplate=testData.successLevel>0&&preData.source.system.target&&preData.source.system.target.type in game.dsa5.config.areaTargetTypes,_context28.t0=chatOptions.title,_context28.t1=immuneTo,_context28.t2=testData,_context28.t3=game.user.isGM,_context28.t4=preData,_context28.t5=hideDamage,_context28.t6=preData.situationalModifiers.filter((function(t){return 0!=t.value})),_context28.t7=applyEffect,_context28.t8=hasAreaTemplate,_context28.next=22,_equipment_damage_js__WEBPACK_IMPORTED_MODULE_12__.Z.showDamageToGear(preData,testData);case 22:if(_context28.t9=_context28.sent,chatData={title:_context28.t0,immuneTo:_context28.t1,testData:_context28.t2,hideData:_context28.t3,preData:_context28.t4,hideDamage:_context28.t5,modifierList:_context28.t6,applyEffect:_context28.t7,hasAreaTemplate:_context28.t8,showDamageToGear:_context28.t9},preData.advancedModifiers&&(preData.advancedModifiers.chars.some((function(t){return 0!=t}))&&chatData.modifierList.push({name:game.i18n.localize("MODS.partChecks"),value:preData.advancedModifiers.chars}),0!=preData.advancedModifiers.fws&&chatData.modifierList.push({name:game.i18n.localize("MODS.FW"),value:preData.advancedModifiers.fws}),0!=preData.advancedModifiers.qls&&chatData.modifierList.push({name:game.i18n.localize("MODS.QS"),value:preData.advancedModifiers.qls})),["gmroll","blindroll"].includes(chatOptions.rollMode)&&(chatOptions.whisper=game.users.filter((function(t){return t.isGM})).map((function(t){return t.id}))),"blindroll"===chatOptions.rollMode?chatOptions.blind=!0:"selfroll"===chatOptions.rollMode&&(chatOptions.whisper=[game.user.id]),_dsa_soundeffect_js__WEBPACK_IMPORTED_MODULE_11__.Z.playEffect(preData.mode,preData.source,testData.successLevel,chatOptions.whisper,chatOptions.blind),chatOptions["flags.data"]={preData,postData:testData,template:chatOptions.template,rollMode:chatOptions.rollMode,isOpposedTest:chatOptions.isOpposedTest,title:chatOptions.title,hideData:chatData.hideData,hideDamage:chatData.hideDamage,isDSARoll:!0},rerenderMessage){_context28.next=38;break}return _context28.next=32,renderTemplate(chatOptions.template,chatData);case 32:return chatOptions.content=_context28.sent,_context28.next=35,ChatMessage.create(chatOptions,!1);case 35:return _context28.abrupt("return",_context28.sent);case 38:if(postFunction=getProperty(rerenderMessage,"flags.data.preData.extra.options.postFunction"),!postFunction){_context28.next=43;break}return testData.messageId=rerenderMessage.id,_context28.next=43,eval(postFunction.functionName)(postFunction,{result:testData,chatData},preData.source);case 43:return _context28.next=45,renderTemplate(chatOptions.template,chatData);case 45:return html=_context28.sent,actor=ChatMessage.getSpeakerActor(rerenderMessage.speaker)||game.users.get(rerenderMessage.user).character,rollData=actor?actor.getRollData():{},_context28.next=50,TextEditor.enrichHTML(html,{rollData,async:!0});case 50:return enriched=_context28.sent,chatOptions.content=enriched,_context28.next=54,rerenderMessage.update(_defineProperty({content:chatOptions.content},"flags.data",chatOptions["flags.data"]));case 54:return newMsg=_context28.sent,ui.chat.updateMessage(newMsg),_context28.abrupt("return",newMsg);case 57:case"end":return _context28.stop()}}),_callee28,this)})));function renderRollCard(t,r,a){return _renderRollCard.apply(this,arguments)}return renderRollCard}()},{key:"_itemRoll",value:(_itemRoll2=_asyncToGenerator(_regeneratorRuntime().mark((function _callee30(t){var r,a,o,i,c,u,l,p,d,h;return _regeneratorRuntime().wrap((function _callee30$(m){for(;;)switch(m.prev=m.next){case 0:if(r=$(t.currentTarget),a=r.parents(".message").attr("data-message-id"),o=game.messages.get(a),i=o.speaker,c=r.attr("data-type"),u=r.attr("data-name"),!(l=_utility_dsa5_js__WEBPACK_IMPORTED_MODULE_3__.Z.getSpeaker(i))){m.next=15;break}if(!(p=l.items.find((function(t){return t.name==u&&t.type==c})))){m.next=14;break}if(d=new _item_item_dsa5_js__WEBPACK_IMPORTED_MODULE_7__.Z(p.toObject(),{temporary:!0}),!(h=!!r.attr("data-removecharge")&&"true"==r.attr("data-removecharge"))){m.next=11;break}if(!(d.system.quantity.value<1)){m.next=11;break}return ui.notifications.error(game.i18n.localize("DSAError.NotEnoughCharges")),m.abrupt("return");case 11:d.setupEffect().then(function(){var t=_asyncToGenerator(_regeneratorRuntime().mark((function _callee29(t){return _regeneratorRuntime().wrap((function _callee29$(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,d.itemTest(t);case 2:if(!h){r.next=5;break}return r.next=5,p.update({"system.quantity.value":p.system.quantity.value-1});case 5:case"end":return r.stop()}}),_callee29)})));return function(r){return t.apply(this,arguments)}}()),m.next=15;break;case 14:ui.notifications.error(game.i18n.format("DSAError.notFound",{category:c,name:u}));case 15:case"end":return m.stop()}}),_callee30)}))),function _itemRoll(t){return _itemRoll2.apply(this,arguments)})},{key:"_rollEdit",value:(_rollEdit2=_asyncToGenerator(_regeneratorRuntime().mark((function _callee31(t){var r,a,o,i,c,u,l,p,d,h,m;return _regeneratorRuntime().wrap((function _callee31$(y){for(;;)switch(y.prev=y.next){case 0:r=$(t.currentTarget),a=r.parents(".message").attr("data-message-id"),o=game.messages.get(a),i=o.flags.data,(c=i.preData).extra.actor=_utility_dsa5_js__WEBPACK_IMPORTED_MODULE_3__.Z.getSpeaker(c.extra.speaker).toObject(!1),c.extra.options.cheat&&delete c.extra.options.cheat,y.t0=r.attr("data-edit-type"),y.next="roll"===y.t0?8:"mod"===y.t0?12:23;break;case 8:return u=r.attr("data-edit-id"),l=Number(r.val()),c.roll.terms.length>2*u?((p=Roll.fromData(c.roll)).editRollAtIndex([{index:u,val:l}]),c.roll=p):(d=Roll.fromData(i.postData.damageRoll),u-=c.roll.terms.filter((function(t){return t.results})).length,d.editRollAtIndex([{index:u,val:l}]),c.damageRoll=d),y.abrupt("break",23);case 12:return(u=c.situationalModifiers.findIndex((function(t){return t.name==game.i18n.localize("chatEdit")})))>0&&c.situationalModifiers.splice(u,1),y.t1=game.i18n.localize("chatEdit"),y.t2=Number(r.val()),y.next=18,this._situationalModifiers(c);case 18:return y.t3=y.sent,y.t4=y.t2-y.t3,h={name:y.t1,value:y.t4},c.situationalModifiers.push(h),y.abrupt("break",23);case 23:m={template:i.template,rollMode:i.rollMode,title:i.title,speaker:o.speaker,user:o.user.id},["gmroll","blindroll"].includes(m.rollMode)&&(m.whisper=game.users.filter((function(t){return t.isGM})).map((function(t){return t.id}))),"blindroll"===m.rollMode&&(m.blind=!0),["poison","disease"].includes(c.source.type)?new _item_item_dsa5_js__WEBPACK_IMPORTED_MODULE_7__.Z(c.source,{temporary:!0})["".concat(i.postData.postFunction)]({testData:c,cardOptions:m},{rerenderMessage:o}):_utility_dsa5_js__WEBPACK_IMPORTED_MODULE_3__.Z.getSpeaker(o.speaker)["".concat(i.postData.postFunction)]({testData:c,cardOptions:m},{rerenderMessage:o});case 27:case"end":return y.stop()}}),_callee31,this)}))),function _rollEdit(t){return _rollEdit2.apply(this,arguments)})},{key:"gearDamaged",value:(_gearDamaged=_asyncToGenerator(_regeneratorRuntime().mark((function _callee32(t){var r,a;return _regeneratorRuntime().wrap((function _callee32$(o){for(;;)switch(o.prev=o.next){case 0:if(!((r=t.currentTarget.dataset.uuid.split(";")).length>1)){o.next=8;break}return o.next=4,Promise.all(r.map((function(t){return fromUuid(t)})));case 4:a=o.sent,_dialog_dialog_equipmentdamage_js__WEBPACK_IMPORTED_MODULE_13__.Z.showDialog(a),o.next=13;break;case 8:return o.t0=_equipment_damage_js__WEBPACK_IMPORTED_MODULE_12__.Z,o.next=11,fromUuid(r[0]);case 11:o.t1=o.sent,o.t0.breakingTest.call(o.t0,o.t1);case 13:case"end":return o.stop()}}),_callee32)}))),function gearDamaged(t){return _gearDamaged.apply(this,arguments)})},{key:"rollResistPain",value:(_rollResistPain=_asyncToGenerator(_regeneratorRuntime().mark((function _callee33(t){var r,a,o;return _regeneratorRuntime().wrap((function _callee33$(i){for(;;)switch(i.prev=i.next){case 0:r=t.currentTarget.dataset,a={token:r.token,actor:r.actor,scene:canvas.id},(o=_utility_dsa5_js__WEBPACK_IMPORTED_MODULE_3__.Z.getSpeaker(a))&&o.finishResistPainRoll();case 4:case"end":return i.stop()}}),_callee33)}))),function rollResistPain(t){return _rollResistPain.apply(this,arguments)})},{key:"wrapLock",value:(_wrapLock=_asyncToGenerator(_regeneratorRuntime().mark((function _callee34(t,r){var a;return _regeneratorRuntime().wrap((function _callee34$(o){for(;;)switch(o.prev=o.next){case 0:if(!(a=$(t.currentTarget)).hasClass("locked")){o.next=3;break}return o.abrupt("return");case 3:return a.addClass("locked"),a.prepend(''),o.next=7,r(t,a);case 7:setTimeout((function(){a.removeClass("locked"),a.find("i").remove()}),2e3);case 8:case"end":return o.stop()}}),_callee34)}))),function wrapLock(t,r){return _wrapLock.apply(this,arguments)})},{key:"chatListeners",value:(_chatListeners=_asyncToGenerator(_regeneratorRuntime().mark((function _callee41(t){return _regeneratorRuntime().wrap((function _callee41$(r){for(;;)switch(r.prev=r.next){case 0:t.on("click",".expand-mods",(function(t){t.preventDefault();var r=$(t.currentTarget);r.find("i").toggleClass("fa-minus fa-plus"),r.siblings("ul,div").fadeToggle()})),t.on("click",".edit-toggle",(function(t){t.preventDefault(),$(t.currentTarget).parents(".chat-card").find(".display-toggle").toggle()})),t.on("click",".botch-roll",(function(t){return _tables_dsatables_js__WEBPACK_IMPORTED_MODULE_14__.Z.showBotchCard(t.currentTarget.dataset)})),t.on("click",".roll-item",(function(t){return DiceDSA5._itemRoll(t)})),t.on("click",".gearDamaged",function(){var t=_asyncToGenerator(_regeneratorRuntime().mark((function _callee35(t){return _regeneratorRuntime().wrap((function _callee35$(r){for(;;)switch(r.prev=r.next){case 0:return r.abrupt("return",DiceDSA5.gearDamaged(t));case 1:case"end":return r.stop()}}),_callee35)})));return function(r){return t.apply(this,arguments)}}()),t.on("change",".roll-edit",(function(t){return DiceDSA5._rollEdit(t)})),t.on("click",".applyEffect",function(){var t=_asyncToGenerator(_regeneratorRuntime().mark((function _callee37(t){return _regeneratorRuntime().wrap((function _callee37$(r){for(;;)switch(r.prev=r.next){case 0:DiceDSA5.wrapLock(t,function(){var t=_asyncToGenerator(_regeneratorRuntime().mark((function _callee36(t,r){var a,o;return _regeneratorRuntime().wrap((function _callee36$(i){for(;;)switch(i.prev=i.next){case 0:return a=r.parents(".message").attr("data-message-id"),o=t.currentTarget.dataset.target,i.next=4,_status_active_effects_js__WEBPACK_IMPORTED_MODULE_10__.Z.applyEffect(a,o);case 4:case"end":return i.stop()}}),_callee36)})));return function(r,a){return t.apply(this,arguments)}}());case 1:case"end":return r.stop()}}),_callee37)})));return function(r){return t.apply(this,arguments)}}()),t.on("click",".applyTableEffect",function(){var t=_asyncToGenerator(_regeneratorRuntime().mark((function _callee39(t){return _regeneratorRuntime().wrap((function _callee39$(r){for(;;)switch(r.prev=r.next){case 0:DiceDSA5.wrapLock(t,function(){var t=_asyncToGenerator(_regeneratorRuntime().mark((function _callee38(t,r){var a,o;return _regeneratorRuntime().wrap((function _callee38$(i){for(;;)switch(i.prev=i.next){case 0:return a=r.parents(".message").attr("data-message-id"),o=t.currentTarget.dataset.target,i.next=4,_tables_tableEffects_js__WEBPACK_IMPORTED_MODULE_17__.Z.applyEffect(a,o);case 4:case"end":return i.stop()}}),_callee38)})));return function(r,a){return t.apply(this,arguments)}}());case 1:case"end":return r.stop()}}),_callee39)})));return function(r){return t.apply(this,arguments)}}()),t.on("click",".placeTemplate",function(){var t=_asyncToGenerator(_regeneratorRuntime().mark((function _callee40(t){return _regeneratorRuntime().wrap((function _callee40$(r){for(;;)switch(r.prev=r.next){case 0:return r.abrupt("return",_measuretemplate_js__WEBPACK_IMPORTED_MODULE_16__.c.placeTemplateFromChat(t));case 1:case"end":return r.stop()}}),_callee40)})));return function(r){return t.apply(this,arguments)}}()),t.on("click",".message-delete",(function(t){var r=game.messages.get($(t.currentTarget).parents(".message").attr("data-message-id"));if(r.flags.unopposeData){var a=canvas.tokens.get(r.flags.unopposeData.targetSpeaker.token);_opposed_dsa5_js__WEBPACK_IMPORTED_MODULE_9__.Z.clearOpposed(a.actor)}})),t.on("click",".resistEffect",(function(t){return _status_active_effects_js__WEBPACK_IMPORTED_MODULE_10__.Z.resistEffect(t)})),t.on("click",".resistPain",(function(t){return DiceDSA5.rollResistPain(t)})),_request_roll_js__WEBPACK_IMPORTED_MODULE_15__.Z.chatListeners(t);case 13:case"end":return r.stop()}}),_callee41)}))),function chatListeners(t){return _chatListeners.apply(this,arguments)})}]),DiceDSA5}()},803:(t,r,a)=>{function _typeof(t){return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},_typeof(t)}function _createForOfIteratorHelper(t,r){var a="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!a){if(Array.isArray(t)||(a=_unsupportedIterableToArray(t))||r&&t&&"number"==typeof t.length){a&&(t=a);var o=0,i=function F(){};return{s:i,n:function n(){return o>=t.length?{done:!0}:{done:!1,value:t[o++]}},e:function e(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var c,u=!0,l=!1;return{s:function s(){a=a.call(t)},n:function n(){var t=a.next();return u=t.done,t},e:function e(t){l=!0,c=t},f:function f(){try{u||null==a.return||a.return()}finally{if(l)throw c}}}}function _toConsumableArray(t){return function _arrayWithoutHoles(t){if(Array.isArray(t))return _arrayLikeToArray(t)}(t)||function _iterableToArray(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||_unsupportedIterableToArray(t)||function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function _unsupportedIterableToArray(t,r){if(t){if("string"==typeof t)return _arrayLikeToArray(t,r);var a=Object.prototype.toString.call(t).slice(8,-1);return"Object"===a&&t.constructor&&(a=t.constructor.name),"Map"===a||"Set"===a?Array.from(t):"Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a)?_arrayLikeToArray(t,r):void 0}}function _arrayLikeToArray(t,r){(null==r||r>t.length)&&(r=t.length);for(var a=0,o=new Array(r);a=0;--o){var i=this.tryEntries[o],c=i.completion;if("root"===i.tryLoc)return handle("end");if(i.tryLoc<=this.prev){var u=a.call(i,"catchLoc"),l=a.call(i,"finallyLoc");if(u&&l){if(this.prev=0;--o){var i=this.tryEntries[o];if(i.tryLoc<=this.prev&&a.call(i,"finallyLoc")&&this.prev=0;--r){var a=this.tryEntries[r];if(a.finallyLoc===t)return this.complete(a.completion,a.afterLoc),resetTryEntry(a),l}},catch:function _catch(t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc===t){var o=a.completion;if("throw"===o.type){var i=o.arg;resetTryEntry(a)}return i}}throw new Error("illegal catch attempt")},delegateYield:function delegateYield(t,r,a){return this.delegate={iterator:values(t),resultName:r,nextLoc:a},"next"===this.method&&(this.arg=void 0),l}},t}function asyncGeneratorStep(t,r,a,o,i,c,u){try{var l=t[c](u),p=l.value}catch(t){return void a(t)}l.done?r(p):Promise.resolve(p).then(o,i)}function _asyncToGenerator(t){return function(){var r=this,a=arguments;return new Promise((function(o,i){var c=t.apply(r,a);function _next(t){asyncGeneratorStep(c,o,i,_next,_throw,"next",t)}function _throw(t){asyncGeneratorStep(c,o,i,_next,_throw,"throw",t)}_next(void 0)}))}}function _defineProperties(t,r){for(var a=0;ao});var o=function(){function DSA5SoundEffect(){!function _classCallCheck(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}(this,DSA5SoundEffect)}var t,r,a,o,i,c;return function _createClass(t,r,a){return r&&_defineProperties(t.prototype,r),a&&_defineProperties(t,a),Object.defineProperty(t,"prototype",{writable:!1}),t}(DSA5SoundEffect,null,[{key:"prepareSoundEffects",value:function prepareSoundEffects(){DSA5SoundEffect.soundPaths={money:[],armor:[],meleeweapon:[],rangeweapon:[],default:[]},game.modules.get("gAudioBundle-3")&&(DSA5SoundEffect.soundPaths.money.push("modules/gAudioBundle-3/src/Mint Coins And Money/Coin_Slide_Carpet.ogg","modules/gAudioBundle-3/src/Mint Coins And Money/Coins_Drop_Carpet_06.ogg","modules/gAudioBundle-3/src/Mint Coins And Money/Coins_Bottlecaps_Drop.ogg","modules/gAudioBundle-3/src/Mint Coins And Money/Coins_In_Sack_Held_By_Drawstring_06.ogg","modules/gAudioBundle-3/src/Money/Money_Coins_Handle.ogg"),DSA5SoundEffect.soundPaths.meleeweapon.push("modules/gAudioBundle-3/src/Medieval Armor And Impacts/Weapon_Impact_Parry_01.ogg")),game.modules.get("gAudioBundle-2")&&(DSA5SoundEffect.soundPaths.meleeweapon.push("modules/gAudioBundle-2/src/Gore/Melee_Sword_Attack_04.ogg"),DSA5SoundEffect.soundPaths.armor.push("modules/gAudioBundle-2/src/Footsteps/Footstep And Foley Sounds/Foley_Soldier_Gear_Equipment_Metal_Cloth_Heavy_Movement_Light_08.ogg"),DSA5SoundEffect.soundPaths.default.push("modules/gAudioBundle-2/src/Footsteps/Footstep And Foley Sounds/Foley_Sports_Bag_Grab_Pickup_Catch_04.ogg","modules/gAudioBundle-2/src/Footsteps/Footstep And Foley Sounds/Footstep_Ice_Crunchy_Run_01.ogg","modules/gAudioBundle-2/src/Footsteps/Footstep And Foley Sounds/Footstep_Ice_Crunchy_Run_02.ogg")),game.modules.get("gAudioBundle-4")&&DSA5SoundEffect.soundPaths.rangeweapon.push("modules/gAudioBundle-4/src/Super Heroes Sound Design/Hawk's_Arrow_Flies_Bow_And_Arrow_Shoot_2.ogg"),Hooks.call("setDefaultDSASounds",DSA5SoundEffect.soundPaths)}},{key:"playEffect",value:(c=_asyncToGenerator(_regeneratorRuntime().mark((function _callee(t,r,a){var o,i,c,u=arguments;return _regeneratorRuntime().wrap((function _callee$(l){for(;;)switch(l.prev=l.next){case 0:return o=u.length>3&&void 0!==u[3]?u[3]:void 0,i=u.length>4&&void 0!==u[4]&&u[4],l.next=4,this.getSound(t,r,a);case 4:if(c=l.sent)try{o?(game.socket.emit("system.dsa5",{type:"playWhisperSound",payload:{whisper:o,soundPath:c}}),i||AudioHelper.play({src:c,volume:.8,loop:!1},!1)):AudioHelper.play({src:c,volume:.8,loop:!1},!0)}catch(t){console.warn("Could not play item sound effect ".concat(c))}case 6:case"end":return l.stop()}}),_callee,this)}))),function playEffect(t,r,a){return c.apply(this,arguments)})},{key:"loadSoundConfig",value:(i=_asyncToGenerator(_regeneratorRuntime().mark((function _callee2(){var t,r,a;return _regeneratorRuntime().wrap((function _callee2$(o){for(;;)switch(o.prev=o.next){case 0:return o.next=2,game.settings.get("dsa5","soundConfig");case 2:if(!(t=o.sent)){o.next=18;break}return o.prev=4,o.next=7,fetch(t);case 7:return r=o.sent,o.next=10,r.json();case 10:a=o.sent,this.sounds=a,console.log("DSA5 | Sound Config Loaded"),o.next=18;break;case 15:o.prev=15,o.t0=o.catch(4),console.warn(o.t0);case 18:case"end":return o.stop()}}),_callee2,this,[[4,15]])}))),function loadSoundConfig(){return i.apply(this,arguments)})},{key:"successLevelToString",value:function successLevelToString(t){switch(t){case-1:return["fail"];case-2:return["botch","fail"];case 1:return["success"];case 2:return["crit","success"];default:return[]}}},{key:"getSound",value:(o=_asyncToGenerator(_regeneratorRuntime().mark((function _callee3(t,r,a){var o,i,c,u,l,p,d;return _regeneratorRuntime().wrap((function _callee3$(h){for(;;)switch(h.prev=h.next){case 0:if(this.sounds||this.triedInit){h.next=4;break}return h.next=3,this.loadSoundConfig();case 3:this.triedInit=!0;case 4:if(this.sounds){h.next=6;break}return h.abrupt("return",void 0);case 6:i=this.successLevelToString(a),c=[],h.t0=r.type,h.next="meleeweapon"===h.t0||"rangeweapon"===h.t0?11:"skill"===h.t0?13:"liturgy"===h.t0||"spell"===h.t0||"ceremony"===h.t0||"ritual"===h.t0?15:17;break;case 11:return c=[].concat(_toConsumableArray(i.map((function(a){return"".concat(r.type,".manual.").concat(r.name,".").concat(t,"_").concat(a)}))),["".concat(r.type,".manual.").concat(r.name,".").concat(t),"".concat(r.type,".manual.").concat(r.name,".default.").concat(t),"".concat(r.type,".manual.").concat(r.name,".default")],_toConsumableArray(i.map((function(a){return"".concat(r.type,".").concat(r.system.combatskill.value,".").concat(t,"_").concat(a)}))),["".concat(r.type,".").concat(r.system.combatskill.value,".").concat(t)],_toConsumableArray(i.map((function(t){return"".concat(r.type,".").concat(r.system.combatskill.value,".default_").concat(t)}))),["".concat(r.type,".").concat(r.system.combatskill.value,".default")]),h.abrupt("break",17);case 13:case 15:return c=[].concat(_toConsumableArray(i.map((function(a){return"".concat(r.type,".").concat(r.name,".").concat(t,"_").concat(a)}))),["".concat(r.type,".").concat(r.name,".").concat(t)],_toConsumableArray(i.map((function(t){return"".concat(r.type,".").concat(r.name,".default_").concat(t)}))),["".concat(r.type,".").concat(r.name,".default")]),h.abrupt("break",17);case 17:(o=c).push.apply(o,_toConsumableArray(i.map((function(t){return"".concat(r.type,".default_").concat(t)}))).concat(["".concat(r.type,".default")])),l=_createForOfIteratorHelper(c),h.prev=19,l.s();case 21:if((p=l.n()).done){h.next=30;break}if(d=p.value,hasProperty(this.sounds,d)){h.next=25;break}return h.abrupt("continue",28);case 25:if(!(u=getProperty(this.sounds,d))||!("string"==typeof u||u instanceof String)){h.next=28;break}return h.abrupt("break",30);case 28:h.next=21;break;case 30:h.next=35;break;case 32:h.prev=32,h.t1=h.catch(19),l.e(h.t1);case 35:return h.prev=35,l.f(),h.finish(35);case 38:return h.abrupt("return",u);case 39:case"end":return h.stop()}}),_callee3,this,[[19,32,35,38]])}))),function getSound(t,r,a){return o.apply(this,arguments)})},{key:"playMoneySound",value:(a=_asyncToGenerator(_regeneratorRuntime().mark((function _callee4(){var t,r,a,o=arguments;return _regeneratorRuntime().wrap((function _callee4$(i){for(;;)switch(i.prev=i.next){case 0:return t=o.length>0&&void 0!==o[0]&&o[0],r=DSA5SoundEffect.soundPaths.money,a=r[Math.floor(Math.random()*r.length)],i.next=5,this.playSoundPath(a,t);case 5:case"end":return i.stop()}}),_callee4,this)}))),function playMoneySound(){return a.apply(this,arguments)})},{key:"playEquipmentWearStatusChange",value:(r=_asyncToGenerator(_regeneratorRuntime().mark((function _callee5(t){var r,a,o,i=arguments;return _regeneratorRuntime().wrap((function _callee5$(c){for(;;)switch(c.prev=c.next){case 0:if(r=i.length>1&&void 0!==i[1]&&i[1],!((a=DSA5SoundEffect.soundPaths[t.type]||DSA5SoundEffect.soundPaths.default).length>0)){c.next=6;break}return o=a[Math.floor(Math.random()*a.length)],c.next=6,this.playSoundPath(o,r,.5);case 6:case"end":return c.stop()}}),_callee5,this)}))),function playEquipmentWearStatusChange(t){return r.apply(this,arguments)})},{key:"playSoundPath",value:(t=_asyncToGenerator(_regeneratorRuntime().mark((function _callee6(t){var r,a,o=arguments;return _regeneratorRuntime().wrap((function _callee6$(i){for(;;)switch(i.prev=i.next){case 0:if(r=o.length>1&&void 0!==o[1]&&o[1],a=o.length>2&&void 0!==o[2]?o[2]:.8,game.settings.get("dsa5","inventorySound")){i.next=4;break}return i.abrupt("return");case 4:try{AudioHelper.play({src:t,volume:a,loop:!1},r)}catch(r){console.warn("Could not play item sound effect ".concat(t))}case 5:case"end":return i.stop()}}),_callee6)}))),function playSoundPath(r){return t.apply(this,arguments)})}]),DSA5SoundEffect}();_defineProperty(o,"sounds",void 0),_defineProperty(o,"triedInit",!1)},702:(t,r,a)=>{a.d(r,{Z:()=>p});var o=a(5),i=a(577),c=a(472),u=a(562),l=a(491);function _typeof(t){return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},_typeof(t)}function _regeneratorRuntime(){_regeneratorRuntime=function _regeneratorRuntime(){return t};var t={},r=Object.prototype,a=r.hasOwnProperty,o="function"==typeof Symbol?Symbol:{},i=o.iterator||"@@iterator",c=o.asyncIterator||"@@asyncIterator",u=o.toStringTag||"@@toStringTag";function define(t,r,a){return Object.defineProperty(t,r,{value:a,enumerable:!0,configurable:!0,writable:!0}),t[r]}try{define({},"")}catch(t){define=function define(t,r,a){return t[r]=a}}function wrap(t,r,a,o){var i=r&&r.prototype instanceof Generator?r:Generator,c=Object.create(i.prototype),u=new Context(o||[]);return c._invoke=function(t,r,a){var o="suspendedStart";return function(i,c){if("executing"===o)throw new Error("Generator is already running");if("completed"===o){if("throw"===i)throw c;return doneResult()}for(a.method=i,a.arg=c;;){var u=a.delegate;if(u){var p=maybeInvokeDelegate(u,a);if(p){if(p===l)continue;return p}}if("next"===a.method)a.sent=a._sent=a.arg;else if("throw"===a.method){if("suspendedStart"===o)throw o="completed",a.arg;a.dispatchException(a.arg)}else"return"===a.method&&a.abrupt("return",a.arg);o="executing";var d=tryCatch(t,r,a);if("normal"===d.type){if(o=a.done?"completed":"suspendedYield",d.arg===l)continue;return{value:d.arg,done:a.done}}"throw"===d.type&&(o="completed",a.method="throw",a.arg=d.arg)}}}(t,a,u),c}function tryCatch(t,r,a){try{return{type:"normal",arg:t.call(r,a)}}catch(t){return{type:"throw",arg:t}}}t.wrap=wrap;var l={};function Generator(){}function GeneratorFunction(){}function GeneratorFunctionPrototype(){}var p={};define(p,i,(function(){return this}));var d=Object.getPrototypeOf,h=d&&d(d(values([])));h&&h!==r&&a.call(h,i)&&(p=h);var m=GeneratorFunctionPrototype.prototype=Generator.prototype=Object.create(p);function defineIteratorMethods(t){["next","throw","return"].forEach((function(r){define(t,r,(function(t){return this._invoke(r,t)}))}))}function AsyncIterator(t,r){function invoke(o,i,c,u){var l=tryCatch(t[o],t,i);if("throw"!==l.type){var p=l.arg,d=p.value;return d&&"object"==_typeof(d)&&a.call(d,"__await")?r.resolve(d.__await).then((function(t){invoke("next",t,c,u)}),(function(t){invoke("throw",t,c,u)})):r.resolve(d).then((function(t){p.value=t,c(p)}),(function(t){return invoke("throw",t,c,u)}))}u(l.arg)}var o;this._invoke=function(t,a){function callInvokeWithMethodAndArg(){return new r((function(r,o){invoke(t,a,r,o)}))}return o=o?o.then(callInvokeWithMethodAndArg,callInvokeWithMethodAndArg):callInvokeWithMethodAndArg()}}function maybeInvokeDelegate(t,r){var a=t.iterator[r.method];if(void 0===a){if(r.delegate=null,"throw"===r.method){if(t.iterator.return&&(r.method="return",r.arg=void 0,maybeInvokeDelegate(t,r),"throw"===r.method))return l;r.method="throw",r.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var o=tryCatch(a,t.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,l;var i=o.arg;return i?i.done?(r[t.resultName]=i.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=void 0),r.delegate=null,l):i:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,l)}function pushTryEntry(t){var r={tryLoc:t[0]};1 in t&&(r.catchLoc=t[1]),2 in t&&(r.finallyLoc=t[2],r.afterLoc=t[3]),this.tryEntries.push(r)}function resetTryEntry(t){var r=t.completion||{};r.type="normal",delete r.arg,t.completion=r}function Context(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(pushTryEntry,this),this.reset(!0)}function values(t){if(t){var r=t[i];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var o=-1,c=function next(){for(;++o=0;--o){var i=this.tryEntries[o],c=i.completion;if("root"===i.tryLoc)return handle("end");if(i.tryLoc<=this.prev){var u=a.call(i,"catchLoc"),l=a.call(i,"finallyLoc");if(u&&l){if(this.prev=0;--o){var i=this.tryEntries[o];if(i.tryLoc<=this.prev&&a.call(i,"finallyLoc")&&this.prev=0;--r){var a=this.tryEntries[r];if(a.finallyLoc===t)return this.complete(a.completion,a.afterLoc),resetTryEntry(a),l}},catch:function _catch(t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc===t){var o=a.completion;if("throw"===o.type){var i=o.arg;resetTryEntry(a)}return i}}throw new Error("illegal catch attempt")},delegateYield:function delegateYield(t,r,a){return this.delegate={iterator:values(t),resultName:r,nextLoc:a},"next"===this.method&&(this.arg=void 0),l}},t}function asyncGeneratorStep(t,r,a,o,i,c,u){try{var l=t[c](u),p=l.value}catch(t){return void a(t)}l.done?r(p):Promise.resolve(p).then(o,i)}function _asyncToGenerator(t){return function(){var r=this,a=arguments;return new Promise((function(o,i){var c=t.apply(r,a);function _next(t){asyncGeneratorStep(c,o,i,_next,_throw,"next",t)}function _throw(t){asyncGeneratorStep(c,o,i,_next,_throw,"throw",t)}_next(void 0)}))}}function _defineProperties(t,r){for(var a=0;a14||r.successLevel>2)&&game.settings.get("dsa5","armorAndWeaponDamage")}},{key:"armorEncumbranceModifier",value:function armorEncumbranceModifier(t){return game.settings.get("dsa5","armorAndWeaponDamage")&&EquipmentDamage.calculateWear(t)>1?1:0}},{key:"showDamageToGear",value:(p=_asyncToGenerator(_regeneratorRuntime().mark((function _callee(t,r){var a,o,i,c,u;return _regeneratorRuntime().wrap((function _callee$(p){for(;;)switch(p.prev=p.next){case 0:if(!game.settings.get("dsa5","armorAndWeaponDamage")){p.next=11;break}if(a=l.Z.getSpeaker(t.extra.speaker),o=0,(i=getProperty(a,"flags.oppose.messageId"))&&(c=game.messages.get(i))&&(o=getProperty(c,"flags.data.postData.successLevel")||0),!((u=t.source)._id&&u.system.structure&&(r.successLevel<-2||o>2)&&["meleeweapon","rangeweapon","armor"].includes(u.type))){p.next=11;break}return p.next=9,l.Z.getSpeaker(r.speaker);case 9:return a=p.sent,p.abrupt("return",a.items.get(u._id).uuid);case 11:return p.abrupt("return",void 0);case 12:case"end":return p.stop()}}),_callee)}))),function showDamageToGear(t,r){return p.apply(this,arguments)})},{key:"breakingTest",value:function breakingTest(t){if(!t)return ui.notifications.warn(game.i18n.format("DSAError.notfound",{category:"",name:game.i18n.localize("equipment")}));if(t.system.structure.max<=0)return ui.notifications.warn(game.i18n.format("DSAError.noBreakingStructure",{name:t.name}));var r,a=0;if("armor"==t.type?(r=game.i18n.localize("ARMORSUBCATEGORIES.".concat(t.system.subcategory)),a=getProperty(t,"system.structure.breakPointRating")||i.Z.armorSubcategories[t.system.subcategory]):(r=t.system.combatskill.value,a=getProperty(t,"system.structure.breakPointRating")||i.Z.weaponStabilities[game.i18n.localize("LocalizedCTs.".concat(r))]),a){var u="",l=getProperty(t,"effect.attributes")||"";new RegExp("".concat(c.Z.magical),"i").test(l)?u="".concat(game.i18n.format("WEAPON.attributeWarning",{domain:c.Z.clerical}),"
    "):new RegExp("".concat(c.Z.clerical),"i").test(l)&&(u="".concat(game.i18n.format("WEAPON.attributeWarning",{domain:c.Z.magical}),"
    ")),new o.Z({title:game.i18n.localize("DSASETTINGS.armorAndWeaponDamage"),content:"".concat(u,': '),buttons:{Yes:{icon:'',label:game.i18n.localize("Roll"),callback:function callback(a){EquipmentDamage.resolveBreakingTest(t,Number(a.find('[name="threshold"]').val()),r)}},cancel:{icon:'',label:game.i18n.localize("cancel")}},default:"Yes"}).render(!0)}else ui.notifications.error(game.i18n.format("DSAError.noBreakingResistance",{item:t.name}))}},{key:"applyDamageLevelToItem",value:(a=_asyncToGenerator(_regeneratorRuntime().mark((function _callee2(t,r){var a;return _regeneratorRuntime().wrap((function _callee2$(o){for(;;)switch(o.prev=o.next){case 0:return a=Math.ceil(.25*t.system.structure.max)*r,o.next=3,t.update({"system.structure.value":Math.max(0,t.system.structure.value-a)});case 3:case"end":return o.stop()}}),_callee2)}))),function applyDamageLevelToItem(t,r){return a.apply(this,arguments)})},{key:"absoluteDamageLevelToItem",value:(r=_asyncToGenerator(_regeneratorRuntime().mark((function _callee3(t,r){var a;return _regeneratorRuntime().wrap((function _callee3$(o){for(;;)switch(o.prev=o.next){case 0:return a=Math.ceil(.25*t.system.structure.max)*r,o.next=3,t.update({"system.structure.value":Math.min(t.system.structure.value,Math.max(0,t.system.structure.max-a))});case 3:case"end":return o.stop()}}),_callee3)}))),function absoluteDamageLevelToItem(t,a){return r.apply(this,arguments)})},{key:"resolveBreakingTest",value:(t=_asyncToGenerator(_regeneratorRuntime().mark((function _callee4(t,r,a){var o,i,c,p;return _regeneratorRuntime().wrap((function _callee4$(d){for(;;)switch(d.prev=d.next){case 0:return d.t0=u.Z,d.next=3,new Roll("1d20").evaluate({async:!0});case 3:return d.t1=d.sent,d.t2=game.i18n.format("WEAR.check",{category:a}),d.next=7,d.t0.manualRolls.call(d.t0,d.t1,d.t2);case 7:return o=d.sent,d.t3=u.Z,d.t4=o,d.next=12,game.settings.get("core","rollMode");case 12:return d.t5=d.sent,d.next=15,d.t3.showDiceSoNice.call(d.t3,d.t4,d.t5);case 15:return i=o.total>r?1:0,d.next=18,this.applyDamageLevelToItem(t,i);case 18:return c=EquipmentDamage.calculateWear(t.data),d.next=21,renderTemplate("systems/dsa5/templates/system/breakingtest.html",{wear:c,item:t,threshold:r,category:a,roll:o,result:game.i18n.localize("WEAR.".concat(t.type,".").concat(c))});case 21:p=d.sent,ChatMessage.create(l.Z.chatDataSetup(p));case 23:case"end":return d.stop()}}),_callee4,this)}))),function resolveBreakingTest(r,a,o){return t.apply(this,arguments)})},{key:"damageTooltip",value:function damageTooltip(t){if(game.settings.get("dsa5","armorAndWeaponDamage")){var r=this.calculateWear(t);return{msg:game.i18n.localize("WEAR.".concat(t.type,".").concat(r)),css:"gearD damaged".concat(r)}}return{msg:"",css:""}}},{key:"weaponWearModifier",value:function weaponWearModifier(t){if(game.settings.get("dsa5","armorAndWeaponDamage"))switch(EquipmentDamage.calculateWear(t)){case 1:t.attack-=1,t.parry&&(t.parry-=1);break;case 2:t.attack-=2,t.parry&&(t.parry-=2);break;case 3:case 4:t.attack=0,t.parry&&(t.parry=0)}}},{key:"calculateWear",value:function calculateWear(t){return!t.system.structure||Number(t.system.structure.max<=0)?0:Math.floor(4*(1-t.system.structure.value/t.system.structure.max))}}]),EquipmentDamage}()},794:(t,r,a)=>{a.d(r,{Z:()=>c});var o=a(577),i=a(491);function _typeof(t){return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},_typeof(t)}function _regeneratorRuntime(){_regeneratorRuntime=function _regeneratorRuntime(){return t};var t={},r=Object.prototype,a=r.hasOwnProperty,o="function"==typeof Symbol?Symbol:{},i=o.iterator||"@@iterator",c=o.asyncIterator||"@@asyncIterator",u=o.toStringTag||"@@toStringTag";function define(t,r,a){return Object.defineProperty(t,r,{value:a,enumerable:!0,configurable:!0,writable:!0}),t[r]}try{define({},"")}catch(t){define=function define(t,r,a){return t[r]=a}}function wrap(t,r,a,o){var i=r&&r.prototype instanceof Generator?r:Generator,c=Object.create(i.prototype),u=new Context(o||[]);return c._invoke=function(t,r,a){var o="suspendedStart";return function(i,c){if("executing"===o)throw new Error("Generator is already running");if("completed"===o){if("throw"===i)throw c;return doneResult()}for(a.method=i,a.arg=c;;){var u=a.delegate;if(u){var p=maybeInvokeDelegate(u,a);if(p){if(p===l)continue;return p}}if("next"===a.method)a.sent=a._sent=a.arg;else if("throw"===a.method){if("suspendedStart"===o)throw o="completed",a.arg;a.dispatchException(a.arg)}else"return"===a.method&&a.abrupt("return",a.arg);o="executing";var d=tryCatch(t,r,a);if("normal"===d.type){if(o=a.done?"completed":"suspendedYield",d.arg===l)continue;return{value:d.arg,done:a.done}}"throw"===d.type&&(o="completed",a.method="throw",a.arg=d.arg)}}}(t,a,u),c}function tryCatch(t,r,a){try{return{type:"normal",arg:t.call(r,a)}}catch(t){return{type:"throw",arg:t}}}t.wrap=wrap;var l={};function Generator(){}function GeneratorFunction(){}function GeneratorFunctionPrototype(){}var p={};define(p,i,(function(){return this}));var d=Object.getPrototypeOf,h=d&&d(d(values([])));h&&h!==r&&a.call(h,i)&&(p=h);var m=GeneratorFunctionPrototype.prototype=Generator.prototype=Object.create(p);function defineIteratorMethods(t){["next","throw","return"].forEach((function(r){define(t,r,(function(t){return this._invoke(r,t)}))}))}function AsyncIterator(t,r){function invoke(o,i,c,u){var l=tryCatch(t[o],t,i);if("throw"!==l.type){var p=l.arg,d=p.value;return d&&"object"==_typeof(d)&&a.call(d,"__await")?r.resolve(d.__await).then((function(t){invoke("next",t,c,u)}),(function(t){invoke("throw",t,c,u)})):r.resolve(d).then((function(t){p.value=t,c(p)}),(function(t){return invoke("throw",t,c,u)}))}u(l.arg)}var o;this._invoke=function(t,a){function callInvokeWithMethodAndArg(){return new r((function(r,o){invoke(t,a,r,o)}))}return o=o?o.then(callInvokeWithMethodAndArg,callInvokeWithMethodAndArg):callInvokeWithMethodAndArg()}}function maybeInvokeDelegate(t,r){var a=t.iterator[r.method];if(void 0===a){if(r.delegate=null,"throw"===r.method){if(t.iterator.return&&(r.method="return",r.arg=void 0,maybeInvokeDelegate(t,r),"throw"===r.method))return l;r.method="throw",r.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var o=tryCatch(a,t.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,l;var i=o.arg;return i?i.done?(r[t.resultName]=i.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=void 0),r.delegate=null,l):i:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,l)}function pushTryEntry(t){var r={tryLoc:t[0]};1 in t&&(r.catchLoc=t[1]),2 in t&&(r.finallyLoc=t[2],r.afterLoc=t[3]),this.tryEntries.push(r)}function resetTryEntry(t){var r=t.completion||{};r.type="normal",delete r.arg,t.completion=r}function Context(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(pushTryEntry,this),this.reset(!0)}function values(t){if(t){var r=t[i];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var o=-1,c=function next(){for(;++o=0;--o){var i=this.tryEntries[o],c=i.completion;if("root"===i.tryLoc)return handle("end");if(i.tryLoc<=this.prev){var u=a.call(i,"catchLoc"),l=a.call(i,"finallyLoc");if(u&&l){if(this.prev=0;--o){var i=this.tryEntries[o];if(i.tryLoc<=this.prev&&a.call(i,"finallyLoc")&&this.prev=0;--r){var a=this.tryEntries[r];if(a.finallyLoc===t)return this.complete(a.completion,a.afterLoc),resetTryEntry(a),l}},catch:function _catch(t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc===t){var o=a.completion;if("throw"===o.type){var i=o.arg;resetTryEntry(a)}return i}}throw new Error("illegal catch attempt")},delegateYield:function delegateYield(t,r,a){return this.delegate={iterator:values(t),resultName:r,nextLoc:a},"next"===this.method&&(this.arg=void 0),l}},t}function asyncGeneratorStep(t,r,a,o,i,c,u){try{var l=t[c](u),p=l.value}catch(t){return void a(t)}l.done?r(p):Promise.resolve(p).then(o,i)}function _createForOfIteratorHelper(t,r){var a="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!a){if(Array.isArray(t)||(a=function _unsupportedIterableToArray(t,r){if(!t)return;if("string"==typeof t)return _arrayLikeToArray(t,r);var a=Object.prototype.toString.call(t).slice(8,-1);"Object"===a&&t.constructor&&(a=t.constructor.name);if("Map"===a||"Set"===a)return Array.from(t);if("Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a))return _arrayLikeToArray(t,r)}(t))||r&&t&&"number"==typeof t.length){a&&(t=a);var o=0,i=function F(){};return{s:i,n:function n(){return o>=t.length?{done:!0}:{done:!1,value:t[o++]}},e:function e(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var c,u=!0,l=!1;return{s:function s(){a=a.call(t)},n:function n(){var t=a.next();return u=t.done,t},e:function e(t){l=!0,c=t},f:function f(){try{u||null==a.return||a.return()}finally{if(l)throw c}}}}function _arrayLikeToArray(t,r){(null==r||r>t.length)&&(r=t.length);for(var a=0,o=new Array(r);a4&&void 0!==arguments[4]&&arguments[4],u=arguments.length>5&&void 0!==arguments[5]&&arguments[5],l=[],p=c?new RegExp("^".concat(i.Z.escapeRegex("".concat(r," (")))):new RegExp("^".concat(i.Z.escapeRegex(r),"$")),d=t.items.find((function(t){return o.includes(t.type)&&p.test(t.name)}));return d&&l.push({name:d.name,value:Number(d.system.step.value)*a,selected:u,source:d.name}),l}}]),ItemRulesDSA5}();!function _defineProperty(t,r,a){return r in t?Object.defineProperty(t,r,{value:a,enumerable:!0,configurable:!0,writable:!0}):t[r]=a,t}(c,"children",{})},174:(t,r,a)=>{function _typeof(t){return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},_typeof(t)}function _regeneratorRuntime(){_regeneratorRuntime=function _regeneratorRuntime(){return t};var t={},r=Object.prototype,a=r.hasOwnProperty,o="function"==typeof Symbol?Symbol:{},i=o.iterator||"@@iterator",c=o.asyncIterator||"@@asyncIterator",u=o.toStringTag||"@@toStringTag";function define(t,r,a){return Object.defineProperty(t,r,{value:a,enumerable:!0,configurable:!0,writable:!0}),t[r]}try{define({},"")}catch(t){define=function define(t,r,a){return t[r]=a}}function wrap(t,r,a,o){var i=r&&r.prototype instanceof Generator?r:Generator,c=Object.create(i.prototype),u=new Context(o||[]);return c._invoke=function(t,r,a){var o="suspendedStart";return function(i,c){if("executing"===o)throw new Error("Generator is already running");if("completed"===o){if("throw"===i)throw c;return doneResult()}for(a.method=i,a.arg=c;;){var u=a.delegate;if(u){var p=maybeInvokeDelegate(u,a);if(p){if(p===l)continue;return p}}if("next"===a.method)a.sent=a._sent=a.arg;else if("throw"===a.method){if("suspendedStart"===o)throw o="completed",a.arg;a.dispatchException(a.arg)}else"return"===a.method&&a.abrupt("return",a.arg);o="executing";var d=tryCatch(t,r,a);if("normal"===d.type){if(o=a.done?"completed":"suspendedYield",d.arg===l)continue;return{value:d.arg,done:a.done}}"throw"===d.type&&(o="completed",a.method="throw",a.arg=d.arg)}}}(t,a,u),c}function tryCatch(t,r,a){try{return{type:"normal",arg:t.call(r,a)}}catch(t){return{type:"throw",arg:t}}}t.wrap=wrap;var l={};function Generator(){}function GeneratorFunction(){}function GeneratorFunctionPrototype(){}var p={};define(p,i,(function(){return this}));var d=Object.getPrototypeOf,h=d&&d(d(values([])));h&&h!==r&&a.call(h,i)&&(p=h);var m=GeneratorFunctionPrototype.prototype=Generator.prototype=Object.create(p);function defineIteratorMethods(t){["next","throw","return"].forEach((function(r){define(t,r,(function(t){return this._invoke(r,t)}))}))}function AsyncIterator(t,r){function invoke(o,i,c,u){var l=tryCatch(t[o],t,i);if("throw"!==l.type){var p=l.arg,d=p.value;return d&&"object"==_typeof(d)&&a.call(d,"__await")?r.resolve(d.__await).then((function(t){invoke("next",t,c,u)}),(function(t){invoke("throw",t,c,u)})):r.resolve(d).then((function(t){p.value=t,c(p)}),(function(t){return invoke("throw",t,c,u)}))}u(l.arg)}var o;this._invoke=function(t,a){function callInvokeWithMethodAndArg(){return new r((function(r,o){invoke(t,a,r,o)}))}return o=o?o.then(callInvokeWithMethodAndArg,callInvokeWithMethodAndArg):callInvokeWithMethodAndArg()}}function maybeInvokeDelegate(t,r){var a=t.iterator[r.method];if(void 0===a){if(r.delegate=null,"throw"===r.method){if(t.iterator.return&&(r.method="return",r.arg=void 0,maybeInvokeDelegate(t,r),"throw"===r.method))return l;r.method="throw",r.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var o=tryCatch(a,t.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,l;var i=o.arg;return i?i.done?(r[t.resultName]=i.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=void 0),r.delegate=null,l):i:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,l)}function pushTryEntry(t){var r={tryLoc:t[0]};1 in t&&(r.catchLoc=t[1]),2 in t&&(r.finallyLoc=t[2],r.afterLoc=t[3]),this.tryEntries.push(r)}function resetTryEntry(t){var r=t.completion||{};r.type="normal",delete r.arg,t.completion=r}function Context(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(pushTryEntry,this),this.reset(!0)}function values(t){if(t){var r=t[i];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var o=-1,c=function next(){for(;++o=0;--o){var i=this.tryEntries[o],c=i.completion;if("root"===i.tryLoc)return handle("end");if(i.tryLoc<=this.prev){var u=a.call(i,"catchLoc"),l=a.call(i,"finallyLoc");if(u&&l){if(this.prev=0;--o){var i=this.tryEntries[o];if(i.tryLoc<=this.prev&&a.call(i,"finallyLoc")&&this.prev=0;--r){var a=this.tryEntries[r];if(a.finallyLoc===t)return this.complete(a.completion,a.afterLoc),resetTryEntry(a),l}},catch:function _catch(t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc===t){var o=a.completion;if("throw"===o.type){var i=o.arg;resetTryEntry(a)}return i}}throw new Error("illegal catch attempt")},delegateYield:function delegateYield(t,r,a){return this.delegate={iterator:values(t),resultName:r,nextLoc:a},"next"===this.method&&(this.arg=void 0),l}},t}function asyncGeneratorStep(t,r,a,o,i,c,u){try{var l=t[c](u),p=l.value}catch(t){return void a(t)}l.done?r(p):Promise.resolve(p).then(o,i)}function _asyncToGenerator(t){return function(){var r=this,a=arguments;return new Promise((function(o,i){var c=t.apply(r,a);function _next(t){asyncGeneratorStep(c,o,i,_next,_throw,"next",t)}function _throw(t){asyncGeneratorStep(c,o,i,_next,_throw,"throw",t)}_next(void 0)}))}}function _classCallCheck(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}function _defineProperties(t,r){for(var a=0;au});var o=new WeakMap,i=new WeakMap,c=new WeakMap,u=function(t){!function _inherits(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(r&&r.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),r&&_setPrototypeOf(t,r)}(MeasuredTemplateDSA,MeasuredTemplate);var r,a,u,l,p=_createSuper(MeasuredTemplateDSA);function MeasuredTemplateDSA(){var t;_classCallCheck(this,MeasuredTemplateDSA);for(var r=arguments.length,a=new Array(r),u=0;uCONST.GRID_TYPES.SQUARE?30:15,a=t.shiftKey?r:5,o={direction:this.document.direction+a*Math.sign(t.deltaY)};this.document.updateSource(o),this.refresh()}},{key:"_onConfirmPlacement",value:(u=_asyncToGenerator(_regeneratorRuntime().mark((function _callee2(t){var r;return _regeneratorRuntime().wrap((function _callee2$(a){for(;;)switch(a.prev=a.next){case 0:return a.next=2,this._finishPlacement(t);case 2:r=canvas.grid.getSnappedPosition(this.document.x,this.document.y,2),this.document.updateSource(r),_classPrivateFieldGet(this,c).resolve(canvas.scene.createEmbeddedDocuments("MeasuredTemplate",[this.document.toObject()]));case 5:case"end":return a.stop()}}),_callee2,this)}))),function _onConfirmPlacement(t){return u.apply(this,arguments)})},{key:"_onCancelPlacement",value:(a=_asyncToGenerator(_regeneratorRuntime().mark((function _callee3(t){return _regeneratorRuntime().wrap((function _callee3$(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,this._finishPlacement(t);case 2:_classPrivateFieldGet(this,c).reject();case 3:case"end":return r.stop()}}),_callee3,this)}))),function _onCancelPlacement(t){return a.apply(this,arguments)})}],[{key:"placeTemplateFromChat",value:(r=_asyncToGenerator(_regeneratorRuntime().mark((function _callee4(t){var r,a,o,i,c;return _regeneratorRuntime().wrap((function _callee4$(u){for(;;)switch(u.prev=u.next){case 0:r=$(t.currentTarget).parents(".message").attr("data-message-id"),a=game.messages.get(r),o=a.flags.data.preData.source,i=a.flags.data.postData,(c=this.fromItem(o,i.successLevel))&&c.drawPreview();case 6:case"end":return u.stop()}}),_callee4,this)}))),function placeTemplateFromChat(t){return r.apply(this,arguments)})},{key:"fromItem",value:function fromItem(t,r){var a,o=t.system.target||{},i=game.dsa5.config.areaTargetTypes[o.type];if(!i||!o.value)return null;var c=Number(Roll.safeEval("".concat(o.value).replace(/(qs|ql)/gi,r)))||1,u={t:i,user:game.user.id,distance:c,direction:0,x:0,y:0,fillColor:game.user.color,flags:{dsa5:{origin:t.uuid}}};switch(i){case"cone":u.angle=Number(o.angle)||CONFIG.MeasuredTemplate.defaults.angle;break;case"rect":u.distance=Math.hypot(c,c),u.width=c,u.direction=45;break;case"ray":u.width=o.width&&Number(Roll.safeEval("".concat(o.width).replace(/(qs|ql)/gi,r)))||canvas.dimensions.distance}var l=new this(new(0,CONFIG.MeasuredTemplate.documentClass)(u,{parent:canvas.scene}));return l.item=t,l.actorSheet=(null===(a=t.actor)||void 0===a?void 0:a.sheet)||null,l}}]),MeasuredTemplateDSA}()},586:(t,r,a)=>{a.d(r,{Z:()=>migrateWorld,j:()=>showPatchViewer});var o=a(491),i=a(707);function _typeof(t){return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},_typeof(t)}function _createForOfIteratorHelper(t,r){var a="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!a){if(Array.isArray(t)||(a=function _unsupportedIterableToArray(t,r){if(!t)return;if("string"==typeof t)return _arrayLikeToArray(t,r);var a=Object.prototype.toString.call(t).slice(8,-1);"Object"===a&&t.constructor&&(a=t.constructor.name);if("Map"===a||"Set"===a)return Array.from(t);if("Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a))return _arrayLikeToArray(t,r)}(t))||r&&t&&"number"==typeof t.length){a&&(t=a);var o=0,i=function F(){};return{s:i,n:function n(){return o>=t.length?{done:!0}:{done:!1,value:t[o++]}},e:function e(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var c,u=!0,l=!1;return{s:function s(){a=a.call(t)},n:function n(){var t=a.next();return u=t.done,t},e:function e(t){l=!0,c=t},f:function f(){try{u||null==a.return||a.return()}finally{if(l)throw c}}}}function _arrayLikeToArray(t,r){(null==r||r>t.length)&&(r=t.length);for(var a=0,o=new Array(r);a=0;--o){var i=this.tryEntries[o],c=i.completion;if("root"===i.tryLoc)return handle("end");if(i.tryLoc<=this.prev){var u=a.call(i,"catchLoc"),l=a.call(i,"finallyLoc");if(u&&l){if(this.prev=0;--o){var i=this.tryEntries[o];if(i.tryLoc<=this.prev&&a.call(i,"finallyLoc")&&this.prev=0;--r){var a=this.tryEntries[r];if(a.finallyLoc===t)return this.complete(a.completion,a.afterLoc),resetTryEntry(a),l}},catch:function _catch(t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc===t){var o=a.completion;if("throw"===o.type){var i=o.arg;resetTryEntry(a)}return i}}throw new Error("illegal catch attempt")},delegateYield:function delegateYield(t,r,a){return this.delegate={iterator:values(t),resultName:r,nextLoc:a},"next"===this.method&&(this.arg=void 0),l}},t}function asyncGeneratorStep(t,r,a,o,i,c,u){try{var l=t[c](u),p=l.value}catch(t){return void a(t)}l.done?r(p):Promise.resolve(p).then(o,i)}function _asyncToGenerator(t){return function(){var r=this,a=arguments;return new Promise((function(o,i){var c=t.apply(r,a);function _next(t){asyncGeneratorStep(c,o,i,_next,_throw,"next",t)}function _throw(t){asyncGeneratorStep(c,o,i,_next,_throw,"throw",t)}_next(void 0)}))}}function setupDefaulTokenConfig(){return _setupDefaulTokenConfig.apply(this,arguments)}function _setupDefaulTokenConfig(){return(_setupDefaulTokenConfig=_asyncToGenerator(_regeneratorRuntime().mark((function _callee7(){var t;return _regeneratorRuntime().wrap((function _callee7$(r){for(;;)switch(r.prev=r.next){case 0:if(game.settings.get("dsa5","defaultConfigFinished")){r.next=13;break}return console.log("Configuring default token settings"),(t=game.settings.get("core","defaultToken")).displayName=CONST.TOKEN_DISPLAY_MODES.OWNER_HOVER,t.displayBars=CONST.TOKEN_DISPLAY_MODES.OWNER_HOVER,t.disposition=CONST.TOKEN_DISPOSITIONS.NEUTRAL,t.bar1={attribute:"status.wounds"},r.next=9,game.settings.set("core","defaultToken",t);case 9:return r.next=11,game.settings.set("core","leftClickRelease",!0);case 11:return r.next=13,game.settings.set("dsa5","defaultConfigFinished",!0);case 13:case"end":return r.stop()}}),_callee7)})))).apply(this,arguments)}function migrateDSA(t,r){return _migrateDSA.apply(this,arguments)}function _migrateDSA(){return(_migrateDSA=_asyncToGenerator(_regeneratorRuntime().mark((function _callee8(t,r){return _regeneratorRuntime().wrap((function _callee8$(a){for(;;)switch(a.prev=a.next){case 0:return a.next=2,showPatchViewer();case 2:if(!(t<24)){a.next=5;break}return a.next=5,migratTo24();case 5:return a.next=7,game.settings.set("dsa5","migrationVersion",r);case 7:case"end":return a.stop()}}),_callee8)})))).apply(this,arguments)}function migratTo24(){return _migratTo.apply(this,arguments)}function _migratTo(){return(_migratTo=_asyncToGenerator(_regeneratorRuntime().mark((function _callee9(){var t,r,a,o;return _regeneratorRuntime().wrap((function _callee9$(i){for(;;)switch(i.prev=i.next){case 0:t=_createForOfIteratorHelper(game.actors),i.prev=1,t.s();case 3:if((r=t.n()).done){i.next=11;break}if(a=r.value,!(o=a.effects.filter((function(t){return["inpain","encumbered"].includes(t.getFlag("core","statusId"))}))).length){i.next=9;break}return i.next=9,a.deleteEmbeddedDocuments("ActiveEffect",o.map((function(t){return t.id})));case 9:i.next=3;break;case 11:i.next=16;break;case 13:i.prev=13,i.t0=i.catch(1),t.e(i.t0);case 16:return i.prev=16,t.f(),i.finish(16);case 19:case"end":return i.stop()}}),_callee9,null,[[1,13,16,19]])})))).apply(this,arguments)}function showPatchViewer(){return _showPatchViewer.apply(this,arguments)}function _showPatchViewer(){return(_showPatchViewer=_asyncToGenerator(_regeneratorRuntime().mark((function _callee10(){var t,r;return _regeneratorRuntime().wrap((function _callee10$(a){for(;;)switch(a.prev=a.next){case 0:return a.next=2,fetch("systems/dsa5/lazy/updatenotes.json");case 2:return t=a.sent,a.next=5,t.json();case 5:r=a.sent,new c(r).render(!0);case 8:case"end":return a.stop()}}),_callee10)})))).apply(this,arguments)}function migrateWorld(){Hooks.once("ready",_asyncToGenerator(_regeneratorRuntime().mark((function _callee(){var t,r;return _regeneratorRuntime().wrap((function _callee$(a){for(;;)switch(a.prev=a.next){case 0:if(game.user.isGM){a.next=2;break}return a.abrupt("return");case 2:return a.next=4,setupDefaulTokenConfig();case 4:return a.next=6,game.settings.get("dsa5","migrationVersion");case 6:if(t=a.sent,t<(r=25)){a.next=11;break}return a.abrupt("return");case 11:migrateDSA(t,r);case 12:case"end":return a.stop()}}),_callee)}))))}var c=function(t){!function _inherits(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(r&&r.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),r&&_setPrototypeOf(t,r)}(PatchViewer,Application);var r,a,c,u=_createSuper(PatchViewer);function PatchViewer(t,r){var a;return function _classCallCheck(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}(this,PatchViewer),(a=u.call(this,r)).json=t,a.versionIndex=3,a}return function _createClass(t,r,a){return r&&_defineProperties(t.prototype,r),a&&_defineProperties(t,a),Object.defineProperty(t,"prototype",{writable:!1}),t}(PatchViewer,[{key:"activateListeners",value:function activateListeners(t){var r=this;_get(_getPrototypeOf(PatchViewer.prototype),"activateListeners",this).call(this,t),(0,i.Ee)(t),t.find(".showMore").click((function(a){return r.showMore(t)}))}},{key:"showMore",value:(c=_asyncToGenerator(_regeneratorRuntime().mark((function _callee2(t){var r,a;return _regeneratorRuntime().wrap((function _callee2$(o){for(;;)switch(o.prev=o.next){case 0:if("2.3.0"!=(r=[this.json.notes[this.json.notes.length-this.versionIndex]])[0].version){o.next=4;break}return t.find(".showMore").hide(),o.abrupt("return");case 4:return o.next=6,this.fetchVersions(r);case 6:a=o.sent,t.find(".changelogsection").append(a.changelog[0]),t.find(".newssection").append(a.news[0]),this.versionIndex+=1;case 10:case"end":return o.stop()}}),_callee2,this)}))),function showMore(t){return c.apply(this,arguments)})},{key:"fetchVersions",value:(a=_asyncToGenerator(_regeneratorRuntime().mark((function _callee5(t){var r,a,o;return _regeneratorRuntime().wrap((function _callee5$(i){for(;;)switch(i.prev=i.next){case 0:return r=game.i18n.lang,i.next=3,Promise.all(t.map(function(){var t=_asyncToGenerator(_regeneratorRuntime().mark((function _callee3(t){return _regeneratorRuntime().wrap((function _callee3$(a){for(;;)switch(a.prev=a.next){case 0:return a.next=2,renderTemplate("systems/dsa5/lazy/patchhtml/changelog_".concat(r,"_").concat(t.version,".html"));case 2:return a.abrupt("return",a.sent);case 3:case"end":return a.stop()}}),_callee3)})));return function(r){return t.apply(this,arguments)}}()));case 3:return a=i.sent,i.next=6,Promise.all(t.map(function(){var t=_asyncToGenerator(_regeneratorRuntime().mark((function _callee4(t){return _regeneratorRuntime().wrap((function _callee4$(a){for(;;)switch(a.prev=a.next){case 0:return a.next=2,renderTemplate("systems/dsa5/lazy/patchhtml/news_".concat(r,"_").concat(t.version,".html"));case 2:return a.abrupt("return",a.sent);case 3:case"end":return a.stop()}}),_callee4)})));return function(r){return t.apply(this,arguments)}}()));case 6:return o=i.sent,i.abrupt("return",{changelog:a,news:o});case 8:case"end":return i.stop()}}),_callee5)}))),function fetchVersions(t){return a.apply(this,arguments)})},{key:"getData",value:(r=_asyncToGenerator(_regeneratorRuntime().mark((function _callee6(){var t,r,a,i,c,u,l,p;return _regeneratorRuntime().wrap((function _callee6$(d){for(;;)switch(d.prev=d.next){case 0:return t=this.json.notes[this.json.notes.length-1],r=this.json.default.replace(/VERSION/g,t.version),a="

    CHANGELOG

    ".concat(r,".
    Important updates: ").concat(t.text,'

    For details or proposals visit our wiki page at Github or show the Full Changelog in Foundry. Have fun.

    '),d.next=5,ChatMessage.create(o.Z.chatDataSetup(a,"roll"));case 5:return i=game.i18n.lang,d.next=8,this.fetchVersions([t]);case 8:return c=d.sent,u=[this.json.notes[this.json.notes.length-2]],d.next=12,this.fetchVersions(u);case 12:return l=d.sent,d.next=15,renderTemplate("systems/dsa5/lazy/patchhtml/modules_".concat(i,".html"));case 15:return p=d.sent,d.abrupt("return",{patchName:r,changelog:c.changelog[0],news:c.news[0],prevVersions:u,prevChangeLogs:l.changelog,prevNews:l.news,modules:p});case 17:case"end":return d.stop()}}),_callee6,this)}))),function getData(){return r.apply(this,arguments)})}],[{key:"defaultOptions",get:function get(){var t=_get(_getPrototypeOf(PatchViewer),"defaultOptions",this);return t.tabs=[{navSelector:".tabs",contentSelector:".content",initial:"newcontent"}],mergeObject(t,{classes:t.classes.concat(["dsa5","largeDialog","patches"]),width:740,height:740,title:"Changelog"}),t.template="systems/dsa5/templates/system/patchviewer.html",t.resizable=!0,t}}]),PatchViewer}()},604:(t,r,a)=>{a.d(r,{Z:()=>i});var o=a(491);a(122),a(803);function _typeof(t){return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},_typeof(t)}function _regeneratorRuntime(){_regeneratorRuntime=function _regeneratorRuntime(){return t};var t={},r=Object.prototype,a=r.hasOwnProperty,o="function"==typeof Symbol?Symbol:{},i=o.iterator||"@@iterator",c=o.asyncIterator||"@@asyncIterator",u=o.toStringTag||"@@toStringTag";function define(t,r,a){return Object.defineProperty(t,r,{value:a,enumerable:!0,configurable:!0,writable:!0}),t[r]}try{define({},"")}catch(t){define=function define(t,r,a){return t[r]=a}}function wrap(t,r,a,o){var i=r&&r.prototype instanceof Generator?r:Generator,c=Object.create(i.prototype),u=new Context(o||[]);return c._invoke=function(t,r,a){var o="suspendedStart";return function(i,c){if("executing"===o)throw new Error("Generator is already running");if("completed"===o){if("throw"===i)throw c;return doneResult()}for(a.method=i,a.arg=c;;){var u=a.delegate;if(u){var p=maybeInvokeDelegate(u,a);if(p){if(p===l)continue;return p}}if("next"===a.method)a.sent=a._sent=a.arg;else if("throw"===a.method){if("suspendedStart"===o)throw o="completed",a.arg;a.dispatchException(a.arg)}else"return"===a.method&&a.abrupt("return",a.arg);o="executing";var d=tryCatch(t,r,a);if("normal"===d.type){if(o=a.done?"completed":"suspendedYield",d.arg===l)continue;return{value:d.arg,done:a.done}}"throw"===d.type&&(o="completed",a.method="throw",a.arg=d.arg)}}}(t,a,u),c}function tryCatch(t,r,a){try{return{type:"normal",arg:t.call(r,a)}}catch(t){return{type:"throw",arg:t}}}t.wrap=wrap;var l={};function Generator(){}function GeneratorFunction(){}function GeneratorFunctionPrototype(){}var p={};define(p,i,(function(){return this}));var d=Object.getPrototypeOf,h=d&&d(d(values([])));h&&h!==r&&a.call(h,i)&&(p=h);var m=GeneratorFunctionPrototype.prototype=Generator.prototype=Object.create(p);function defineIteratorMethods(t){["next","throw","return"].forEach((function(r){define(t,r,(function(t){return this._invoke(r,t)}))}))}function AsyncIterator(t,r){function invoke(o,i,c,u){var l=tryCatch(t[o],t,i);if("throw"!==l.type){var p=l.arg,d=p.value;return d&&"object"==_typeof(d)&&a.call(d,"__await")?r.resolve(d.__await).then((function(t){invoke("next",t,c,u)}),(function(t){invoke("throw",t,c,u)})):r.resolve(d).then((function(t){p.value=t,c(p)}),(function(t){return invoke("throw",t,c,u)}))}u(l.arg)}var o;this._invoke=function(t,a){function callInvokeWithMethodAndArg(){return new r((function(r,o){invoke(t,a,r,o)}))}return o=o?o.then(callInvokeWithMethodAndArg,callInvokeWithMethodAndArg):callInvokeWithMethodAndArg()}}function maybeInvokeDelegate(t,r){var a=t.iterator[r.method];if(void 0===a){if(r.delegate=null,"throw"===r.method){if(t.iterator.return&&(r.method="return",r.arg=void 0,maybeInvokeDelegate(t,r),"throw"===r.method))return l;r.method="throw",r.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var o=tryCatch(a,t.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,l;var i=o.arg;return i?i.done?(r[t.resultName]=i.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=void 0),r.delegate=null,l):i:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,l)}function pushTryEntry(t){var r={tryLoc:t[0]};1 in t&&(r.catchLoc=t[1]),2 in t&&(r.finallyLoc=t[2],r.afterLoc=t[3]),this.tryEntries.push(r)}function resetTryEntry(t){var r=t.completion||{};r.type="normal",delete r.arg,t.completion=r}function Context(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(pushTryEntry,this),this.reset(!0)}function values(t){if(t){var r=t[i];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var o=-1,c=function next(){for(;++o=0;--o){var i=this.tryEntries[o],c=i.completion;if("root"===i.tryLoc)return handle("end");if(i.tryLoc<=this.prev){var u=a.call(i,"catchLoc"),l=a.call(i,"finallyLoc");if(u&&l){if(this.prev=0;--o){var i=this.tryEntries[o];if(i.tryLoc<=this.prev&&a.call(i,"finallyLoc")&&this.prev=0;--r){var a=this.tryEntries[r];if(a.finallyLoc===t)return this.complete(a.completion,a.afterLoc),resetTryEntry(a),l}},catch:function _catch(t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc===t){var o=a.completion;if("throw"===o.type){var i=o.arg;resetTryEntry(a)}return i}}throw new Error("illegal catch attempt")},delegateYield:function delegateYield(t,r,a){return this.delegate={iterator:values(t),resultName:r,nextLoc:a},"next"===this.method&&(this.arg=void 0),l}},t}function _createForOfIteratorHelper(t,r){var a="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!a){if(Array.isArray(t)||(a=function _unsupportedIterableToArray(t,r){if(!t)return;if("string"==typeof t)return _arrayLikeToArray(t,r);var a=Object.prototype.toString.call(t).slice(8,-1);"Object"===a&&t.constructor&&(a=t.constructor.name);if("Map"===a||"Set"===a)return Array.from(t);if("Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a))return _arrayLikeToArray(t,r)}(t))||r&&t&&"number"==typeof t.length){a&&(t=a);var o=0,i=function F(){};return{s:i,n:function n(){return o>=t.length?{done:!0}:{done:!1,value:t[o++]}},e:function e(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var c,u=!0,l=!1;return{s:function s(){a=a.call(t)},n:function n(){var t=a.next();return u=t.done,t},e:function e(t){l=!0,c=t},f:function f(){try{u||null==a.return||a.return()}finally{if(l)throw c}}}}function _arrayLikeToArray(t,r){(null==r||r>t.length)&&(r=t.length);for(var a=0,o=new Array(r);a2&&void 0!==m[2]?m[2]:{},o=game.packs.get(t),y.next=4,o.getDocuments({name:r});case 4:if((i=y.sent).length){y.next=26;break}c=_createForOfIteratorHelper(game.packs.filter((function(t){return"Macro"==t.documentName&&/\(internal\)/.test(t.metadata.label)}))),y.prev=7,c.s();case 9:if((u=c.n()).done){y.next=18;break}return l=u.value,y.next=13,l.getDocuments({name:r});case 13:if(!(i=y.sent).length){y.next=16;break}return y.abrupt("break",18);case 16:y.next=9;break;case 18:y.next=23;break;case 20:y.prev=20,y.t0=y.catch(7),c.e(y.t0);case 23:return y.prev=23,c.f(),y.finish(23);case 26:if(p={},!i.length){y.next=43;break}return d="(async () => {".concat(i[0].command,"})()"),h=Function("args","actor","item",d),y.prev=30,a.result=p,y.next=34,h.call(this,a,this.item.actor,this.item);case 34:y.next=41;break;case 36:y.prev=36,y.t1=y.catch(30),ui.notifications.error("There was an error in your macro syntax. See the console (F12) for details"),console.error(y.t1),p.error=!0;case 41:y.next=44;break;case 43:ui.notifications.error(game.i18n.format("DSAError.macroNotFound",{name:r}));case 44:return y.abrupt("return",p);case 45:case"end":return y.stop()}}),_callee,this,[[7,20,23,26],[30,36]])}))),function callMacro(t,r){return p.apply(this,arguments)})},{key:"executeOnUseEffect",value:(l=_asyncToGenerator(_regeneratorRuntime().mark((function _callee2(){var t,r,a;return _regeneratorRuntime().wrap((function _callee2$(o){for(;;)switch(o.prev=o.next){case 0:if(game.user.can("MACRO_SCRIPT")){o.next=2;break}return o.abrupt("return",ui.notifications.warn("You are not allowed to use JavaScript macros."));case 2:if(this.item.actor){o.next=4;break}return o.abrupt("return");case 4:return t=OnUseEffect.getOnUseEffect(this.item),r="(async () => {".concat(t,"})()"),a=Function("item","actor",r),o.prev=7,o.next=10,a.call(this,this.item,this.item.actor);case 10:o.next=17;break;case 12:o.prev=12,o.t0=o.catch(7),ui.notifications.error("There was an error in your macro syntax. See the console (F12) for details"),console.error(o.t0),console.warn(o.t0.stack);case 17:case"end":return o.stop()}}),_callee2,this,[[7,12]])}))),function executeOnUseEffect(){return l.apply(this,arguments)})},{key:"automatedAnimation",value:(u=_asyncToGenerator(_regeneratorRuntime().mark((function _callee3(t){var r=arguments;return _regeneratorRuntime().wrap((function _callee3$(t){for(;;)switch(t.prev=t.next){case 0:r.length>1&&void 0!==r[1]&&r[1],o.Z.moduleEnabled("autoanimations")&&console.warn("Animations for on use effects not enabled yet");case 2:case"end":return t.stop()}}),_callee3)}))),function automatedAnimation(t){return u.apply(this,arguments)})},{key:"effectDummy",value:function effectDummy(t,r,a){return{name:t,icon:"icons/svg/aura.svg",changes:r,duration:a,flags:{dsa5:{value:null,editable:!0,customizable:!0,description:t,custom:!0}}}}},{key:"socketedConditionAddActor",value:(c=_asyncToGenerator(_regeneratorRuntime().mark((function _callee4(t,r){var a,o,i,c,u,l;return _regeneratorRuntime().wrap((function _callee4$(p){for(;;)switch(p.prev=p.next){case 0:if(!game.user.isGM){p.next=31;break}(a="string"==typeof r)&&((r=duplicate(CONFIG.statusEffects.find((function(t){return t.id==r})))).name=game.i18n.localize(r.name)),o=[],i=_createForOfIteratorHelper(t),p.prev=5,i.s();case 7:if((c=i.n()).done){p.next=19;break}if(u=c.value,!a){p.next=14;break}return p.next=12,u.addCondition(r,1,!1,!1);case 12:p.next=16;break;case 14:return p.next=16,u.addCondition(r);case 16:o.push(u.name);case 17:p.next=7;break;case 19:p.next=24;break;case 21:p.prev=21,p.t0=p.catch(5),i.e(p.t0);case 24:return p.prev=24,i.f(),p.finish(24);case 27:return p.next=29,this.createInfoMessage(r,o);case 29:p.next=33;break;case 31:l={id:this.item.uuid,data:r,actors:t.map((function(t){return t.id}))},game.socket.emit("system.dsa5",{type:"socketedConditionAddActor",payload:l});case 33:case"end":return p.stop()}}),_callee4,this,[[5,21,24,27]])}))),function socketedConditionAddActor(t,r){return c.apply(this,arguments)})},{key:"createInfoMessage",value:(i=_asyncToGenerator(_regeneratorRuntime().mark((function _callee5(t,r){var a,i,c,u=arguments;return _regeneratorRuntime().wrap((function _callee5$(l){for(;;)switch(l.prev=l.next){case 0:if(a=!(u.length>2&&void 0!==u[2])||u[2],!r.length){l.next=6;break}return i=a?"ActiveEffects.appliedEffect":"ActiveEffects.removedEffect",c=game.i18n.format(i,{source:t.name,target:r.join(", ")}),l.next=6,ChatMessage.create(o.Z.chatDataSetup(c));case 6:case"end":return l.stop()}}),_callee5)}))),function createInfoMessage(t,r){return i.apply(this,arguments)})},{key:"socketedRemoveCondition",value:(a=_asyncToGenerator(_regeneratorRuntime().mark((function _callee6(t,r){var a,o,i,c,u,l,p,d,h=arguments;return _regeneratorRuntime().wrap((function _callee6$(m){for(;;)switch(m.prev=m.next){case 0:if(a=h.length>2&&void 0!==h[2]?h[2]:1,!game.user.isGM){m.next=29;break}o=[],i=_createForOfIteratorHelper(t),m.prev=4,i.s();case 6:if((c=i.n()).done){m.next=15;break}if(u=c.value,!(l=canvas.tokens.get(u)).actor){m.next=13;break}return m.next=12,l.actor.removeCondition(r,a,!1);case 12:o.push(l.name);case 13:m.next=6;break;case 15:m.next=20;break;case 17:m.prev=17,m.t0=m.catch(4),i.e(m.t0);case 20:return m.prev=20,i.f(),m.finish(20);case 23:return(p=CONFIG.statusEffects.find((function(t){return t.id==r}))).name=game.i18n.localize(p.name),m.next=27,this.createInfoMessage(p,o,!1);case 27:m.next=31;break;case 29:d={id:this.item.uuid,coreId:r,targets:t},game.socket.emit("system.dsa5",{type:"socketedRemoveCondition",payload:d});case 31:case"end":return m.stop()}}),_callee6,this,[[4,17,20,23]])}))),function socketedRemoveCondition(t,r){return a.apply(this,arguments)})},{key:"socketedActorTransformation",value:(r=_asyncToGenerator(_regeneratorRuntime().mark((function _callee7(t,r){var a,o,i,c,u;return _regeneratorRuntime().wrap((function _callee7$(l){for(;;)switch(l.prev=l.next){case 0:if(!game.user.isGM){l.next=22;break}a=_createForOfIteratorHelper(t),l.prev=2,a.s();case 4:if((o=a.n()).done){l.next=12;break}if(i=o.value,!(c=canvas.tokens.get(i)).actor){l.next=10;break}return l.next=10,c.actor.update(r);case 10:l.next=4;break;case 12:l.next=17;break;case 14:l.prev=14,l.t0=l.catch(2),a.e(l.t0);case 17:return l.prev=17,a.f(),l.finish(17);case 20:l.next=24;break;case 22:u={id:this.item.uuid,targets:t,update:r},game.socket.emit("system.dsa5",{type:"socketedActorTransformation",payload:u});case 24:case"end":return l.stop()}}),_callee7,this,[[2,14,17,20]])}))),function socketedActorTransformation(t,a){return r.apply(this,arguments)})},{key:"socketedConditionAdd",value:(t=_asyncToGenerator(_regeneratorRuntime().mark((function _callee8(t,r){var a,o,i,c,u,l,p;return _regeneratorRuntime().wrap((function _callee8$(d){for(;;)switch(d.prev=d.next){case 0:if(!game.user.isGM){d.next=33;break}(a="string"==typeof r)&&((r=duplicate(CONFIG.statusEffects.find((function(t){return t.id==r})))).name=game.i18n.localize(r.name)),o=[],i=_createForOfIteratorHelper(t),d.prev=5,i.s();case 7:if((c=i.n()).done){d.next=21;break}if(u=c.value,!(l=canvas.tokens.get(u)).actor){d.next=19;break}if(!a){d.next=16;break}return d.next=14,l.actor.addCondition(r,1,!1,!1);case 14:d.next=18;break;case 16:return d.next=18,l.actor.addCondition(r);case 18:o.push(l.name);case 19:d.next=7;break;case 21:d.next=26;break;case 23:d.prev=23,d.t0=d.catch(5),i.e(d.t0);case 26:return d.prev=26,i.f(),d.finish(26);case 29:return d.next=31,this.createInfoMessage(r,o);case 31:d.next=35;break;case 33:p={id:this.item.uuid,data:r,targets:t},game.socket.emit("system.dsa5",{type:"socketedConditionAdd",payload:p});case 35:case"end":return d.stop()}}),_callee8,this,[[5,23,26,29]])}))),function socketedConditionAdd(r,a){return t.apply(this,arguments)})}],[{key:"getOnUseEffect",value:function getOnUseEffect(t){return t.getFlag("dsa5","onUseEffect")}}]),OnUseEffect}()},600:(t,r,a)=>{a.d(r,{Z:()=>h});var o=a(491),i=a(562),c=a(118),u=a(369),l=a(702),p=a(61),d=a(839);function _typeof(t){return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},_typeof(t)}function _createForOfIteratorHelper(t,r){var a="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!a){if(Array.isArray(t)||(a=_unsupportedIterableToArray(t))||r&&t&&"number"==typeof t.length){a&&(t=a);var o=0,i=function F(){};return{s:i,n:function n(){return o>=t.length?{done:!0}:{done:!1,value:t[o++]}},e:function e(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var c,u=!0,l=!1;return{s:function s(){a=a.call(t)},n:function n(){var t=a.next();return u=t.done,t},e:function e(t){l=!0,c=t},f:function f(){try{u||null==a.return||a.return()}finally{if(l)throw c}}}}function _defineProperty(t,r,a){return r in t?Object.defineProperty(t,r,{value:a,enumerable:!0,configurable:!0,writable:!0}):t[r]=a,t}function _toConsumableArray(t){return function _arrayWithoutHoles(t){if(Array.isArray(t))return _arrayLikeToArray(t)}(t)||function _iterableToArray(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||_unsupportedIterableToArray(t)||function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function _unsupportedIterableToArray(t,r){if(t){if("string"==typeof t)return _arrayLikeToArray(t,r);var a=Object.prototype.toString.call(t).slice(8,-1);return"Object"===a&&t.constructor&&(a=t.constructor.name),"Map"===a||"Set"===a?Array.from(t):"Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a)?_arrayLikeToArray(t,r):void 0}}function _arrayLikeToArray(t,r){(null==r||r>t.length)&&(r=t.length);for(var a=0,o=new Array(r);a=0;--o){var i=this.tryEntries[o],c=i.completion;if("root"===i.tryLoc)return handle("end");if(i.tryLoc<=this.prev){var u=a.call(i,"catchLoc"),l=a.call(i,"finallyLoc");if(u&&l){if(this.prev=0;--o){var i=this.tryEntries[o];if(i.tryLoc<=this.prev&&a.call(i,"finallyLoc")&&this.prev=0;--r){var a=this.tryEntries[r];if(a.finallyLoc===t)return this.complete(a.completion,a.afterLoc),resetTryEntry(a),l}},catch:function _catch(t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc===t){var o=a.completion;if("throw"===o.type){var i=o.arg;resetTryEntry(a)}return i}}throw new Error("illegal catch attempt")},delegateYield:function delegateYield(t,r,a){return this.delegate={iterator:values(t),resultName:r,nextLoc:a},"next"===this.method&&(this.arg=void 0),l}},t}function asyncGeneratorStep(t,r,a,o,i,c,u){try{var l=t[c](u),p=l.value}catch(t){return void a(t)}l.done?r(p):Promise.resolve(p).then(o,i)}function _asyncToGenerator(t){return function(){var r=this,a=arguments;return new Promise((function(o,i){var c=t.apply(r,a);function _next(t){asyncGeneratorStep(c,o,i,_next,_throw,"next",t)}function _throw(t){asyncGeneratorStep(c,o,i,_next,_throw,"throw",t)}_next(void 0)}))}}function _defineProperties(t,r){for(var a=0;a'):'')}},{key:"createOpposedTest",value:(S=_asyncToGenerator(_regeneratorRuntime().mark((function _callee6(t,r,a,o){var i,c,u,l;return _regeneratorRuntime().wrap((function _callee6$(o){for(;;)switch(o.prev=o.next){case 0:i=r.speaker.token?canvas.tokens.get(r.speaker.token).document:t.prototypeToken,a.successLevel>0?(c=r.flags.data.preData.attackOfOpportunity,u=c?"":'
    "),l=[],game.user.targets.forEach(function(){var t=_asyncToGenerator(_regeneratorRuntime().mark((function _callee4(t){var a,o,p,d,h;return _regeneratorRuntime().wrap((function _callee4$(m){for(;;)switch(m.prev=m.next){case 0:if(!t.actor){m.next=17;break}return a="".concat(OpposedDsa5.opposeMessage(i,t,!1)," ").concat(u),m.next=4,ChatMessage.create(_defineProperty({user:game.user.id,content:a,speaker:r.speaker},"flags.unopposeData",{attackMessageId:r.id,targetSpeaker:{scene:t.scene.id,token:t.id,alias:t.document.name}}));case 4:if(o=m.sent,p={speaker:r.speaker,messageId:r.id,startMessageId:o.id},game.user.isGM){m.next=10;break}game.socket.emit("system.dsa5",{type:"target",payload:{target:t.id,scene:(null===(d=t.scene)||void 0===d?void 0:d.id)||(null===(h=canvas.scene)||void 0===h?void 0:h.id),opposeFlag:p}}),m.next=12;break;case 10:return m.next=12,t.actor.update({"flags.oppose":p});case 12:if(l.push(o.id),!c){m.next=16;break}return m.next=16,OpposedDsa5.resolveUndefended(o,game.i18n.localize("OPPOSED.attackOfOpportunity"));case 16:Hooks.call("DSAOpposedRollStart",t);case 17:case"end":return m.stop()}}),_callee4)})));return function(r){return t.apply(this,arguments)}}()),r.flags.data.startMessagesList=l):game.user.targets.forEach(function(){var t=_asyncToGenerator(_regeneratorRuntime().mark((function _callee5(t){return _regeneratorRuntime().wrap((function _callee5$(a){for(;;)switch(a.prev=a.next){case 0:if(!t.actor){a.next=3;break}return a.next=3,ChatMessage.create({user:game.user.id,content:OpposedDsa5.opposeMessage(i,t,!0),speaker:r.speaker});case 3:case"end":return a.stop()}}),_callee5)})));return function(r){return t.apply(this,arguments)}}());case 2:case"end":return o.stop()}}),_callee6)}))),function createOpposedTest(t,r,a,o){return S.apply(this,arguments)})},{key:"opposeMessage",value:function opposeMessage(t,r,a){return'
    \n '.concat(t.name," ").concat(game.i18n.localize("ROLL.Targeting")," ").concat(r.document.name," ").concat(a?game.i18n.localize("ROLL.failed"):"",'\n
    \n
    \n
    ').concat(OpposedDsa5.videoOrImgTag(t.texture.src),'
    \n
    ').concat(OpposedDsa5.videoOrImgTag(r.document.texture.src),"
    \n
    \n ")}},{key:"changeStartMessage",value:(x=_asyncToGenerator(_regeneratorRuntime().mark((function _callee7(t){var r,a,o,i,c;return _regeneratorRuntime().wrap((function _callee7$(u){for(;;)switch(u.prev=u.next){case 0:r=_createForOfIteratorHelper(t.flags.data.startMessagesList),u.prev=1,r.s();case 3:if((a=r.n()).done){u.next=12;break}return o=a.value,i=game.messages.get(o),c=i.flags.unopposeData,game.socket.emit("system.dsa5",{type:"target",payload:{target:c.targetSpeaker.token,scene:canvas.scene.id,opposeFlag:{speaker:t.speaker,messageId:t.id,startMessageId:i.id}}}),u.next=10,i.update({"flags.unopposeData.attackMessageId":t.id});case 10:u.next=3;break;case 12:u.next=17;break;case 14:u.prev=14,u.t0=u.catch(1),r.e(u.t0);case 17:return u.prev=17,r.f(),u.finish(17);case 20:case"end":return u.stop()}}),_callee7,null,[[1,14,17,20]])}))),function changeStartMessage(t){return x.apply(this,arguments)})},{key:"resolveFinalMessage",value:function resolveFinalMessage(t){var r,a;if(t.flags.data.defenderMessage){var o,i=_createForOfIteratorHelper(t.flags.data.defenderMessage);try{for(i.s();!(o=i.n()).done;){var c=o.value;r=OpposedDsa5.getMessageDude(t);var u=game.messages.get(c);a=OpposedDsa5.getMessageDude(u),this.completeOpposedProcess(r,a,{blind:t.blind,whisper:t.whisper})}}catch(t){i.e(t)}finally{i.f()}}else{a=OpposedDsa5.getMessageDude(t);var l=game.messages.get(t.flags.data.attackerMessage);r=OpposedDsa5.getMessageDude(l),this.completeOpposedProcess(r,a,{blind:t.blind,whisper:t.whisper})}}},{key:"getMessageDude",value:function getMessageDude(t){var r,a={speaker:t.speaker,testResult:mergeObject(t.flags.data.postData,{source:t.flags.data.preData.source}),img:o.Z.getSpeaker(t.speaker).img,messageId:t.id};return a.testResult.ammo&&(r=a.testResult.source.effects).push.apply(r,_toConsumableArray(a.testResult.ammo.effects)),a}},{key:"showDamage",value:(w=_asyncToGenerator(_regeneratorRuntime().mark((function _callee8(t){var r,a=arguments;return _regeneratorRuntime().wrap((function _callee8$(o){for(;;)switch(o.prev=o.next){case 0:if(r=a.length>1&&void 0!==a[1]&&a[1],!game.user.isGM){o.next=8;break}if(r&&t.flags.data.hideDamage||!t.flags.data.postData.damageRoll){o.next=6;break}return o.next=5,t.update({content:t.content.replace('data-hide-damage="'.concat(!r,'"'),'data-hide-damage="'.concat(r,'"')),"flags.data.hideDamage":r});case 5:r||i.Z._addRollDiceSoNice(t.flags.data.preData,Roll.fromData(t.flags.data.postData.damageRoll),game.dsa5.apps.DiceSoNiceCustomization.getAttributeConfiguration("damage"));case 6:o.next=9;break;case 8:game.socket.emit("system.dsa5",{type:"showDamage",payload:{id:t.id,hide:r}});case 9:case"end":return o.stop()}}),_callee8)}))),function showDamage(t){return w.apply(this,arguments)})},{key:"playAutomatedJBA2",value:(k=_asyncToGenerator(_regeneratorRuntime().mark((function _callee9(t,r,a){var i,c,u,l,p,h,m,y,g,v,_,b,k,w,x,S,T,A;return _regeneratorRuntime().wrap((function _callee9$(O){for(;;)switch(O.prev=O.next){case 0:if(!o.Z.moduleEnabled("autoanimations")){O.next=34;break}if(i=o.Z.getSpeaker(t.speaker).getActiveTokens()[0],c=o.Z.getSpeaker(r.speaker).getActiveTokens()[0],i&&i.actor&&c&&c.actor){O.next=5;break}return O.abrupt("return");case 5:if((u=i.actor.items.get(t.testResult.source._id))||(u=new d.Z(t.testResult.source,{temporary:!0})),u){O.next=9;break}return O.abrupt("return");case 9:for(u=u.toObject(),l=[c],p="attacker"==a.winner,h=p?l:[],m=t.testResult.successLevel>1&&p,y=t.testResult.successLevel<1&&!p,g=r.testResult.successLevel>1&&!p,v=r.testResult.successLevel<1&&p,_=[],b=[],m?b.push(game.i18n.localize("CriticalSuccess")):y?b.push(game.i18n.localize("CriticalFailure")):g?b.push("".concat(game.i18n.localize("CHAR.PARRY")," ").concat(game.i18n.localize("CriticalSuccess"))):v&&b.push("".concat(game.i18n.localize("CHAR.PARRY")," ").concat(game.i18n.localize("CriticalFailure"))),p||b.push(game.i18n.localize("CHAR.PARRY")),k=0,w=b;k0)){u.next=13;break}if((a=o.Z.getSpeaker(r.postData.speaker).getActiveTokens()[0])&&a.actor){u.next=9;break}return u.abrupt("return");case 9:i=Array.from(game.user.targets),c=a.actor.items.get(r.preData.source._id),i.length||(i=[a]),AutomatedAnimations.playAnimation(a,c,{targets:i});case 13:case"end":return u.stop()}}),_callee10)}))),function showSpellWithoutTarget(t){return b.apply(this,arguments)})},{key:"clearOpposed",value:(_=_asyncToGenerator(_regeneratorRuntime().mark((function _callee11(t){return _regeneratorRuntime().wrap((function _callee11$(r){for(;;)switch(r.prev=r.next){case 0:if(!game.user.isGM){r.next=5;break}return r.next=3,t.update(_defineProperty({},"flags.-=oppose",null));case 3:r.next=6;break;case 5:game.socket.emit("system.dsa5",{type:"clearOpposed",payload:{actorId:t.id}});case 6:case"end":return r.stop()}}),_callee11)}))),function clearOpposed(t){return _.apply(this,arguments)})},{key:"_handleReaction",value:(v=_asyncToGenerator(_regeneratorRuntime().mark((function _callee12(t){var r,a,o,i;return _regeneratorRuntime().wrap((function _callee12$(u){for(;;)switch(u.prev=u.next){case 0:r=$(t.currentTarget).parents(".message").attr("data-message-id"),a=game.messages.get(r),o=game.messages.get(a.flags.unopposeData.attackMessageId),i=o.flags.data.preData.source,u.t0=i.type,u.next="skill"===u.t0?7:9;break;case 7:return c.$G.showDialog(a),u.abrupt("break",10);case 9:c.MN.showDialog(a);case 10:case"end":return u.stop()}}),_callee12)}))),function _handleReaction(t){return v.apply(this,arguments)})},{key:"chatListeners",value:(g=_asyncToGenerator(_regeneratorRuntime().mark((function _callee13(t){var r=this;return _regeneratorRuntime().wrap((function _callee13$(a){for(;;)switch(a.prev=a.next){case 0:t.on("click",".unopposed-button",(function(t){t.preventDefault(),r._handleReaction(t)}));case 1:case"end":return a.stop()}}),_callee13)}))),function chatListeners(t){return g.apply(this,arguments)})},{key:"hideReactionButton",value:(y=_asyncToGenerator(_regeneratorRuntime().mark((function _callee14(t){var r,a;return _regeneratorRuntime().wrap((function _callee14$(o){for(;;)switch(o.prev=o.next){case 0:if(!t){o.next=11;break}if(!game.user.isGM){o.next=10;break}return r=game.messages.get(t),(a=$(r.content)).find("button.unopposed-button").remove(),a=$("
    ").append(a),o.next=8,r.update({content:a.html()});case 8:o.next=11;break;case 10:game.socket.emit("system.dsa5",{type:"hideQueryButton",payload:{id:t}});case 11:case"end":return o.stop()}}),_callee14)}))),function hideReactionButton(t){return y.apply(this,arguments)})},{key:"completeOpposedProcess",value:(m=_asyncToGenerator(_regeneratorRuntime().mark((function _callee15(t,r,a){var o;return _regeneratorRuntime().wrap((function _callee15$(i){for(;;)switch(i.prev=i.next){case 0:return i.next=2,this.evaluateOpposedTest(t.testResult,r.testResult,a);case 2:return o=i.sent,this.formatOpposedResult(o,t.speaker,r.speaker),this.rerenderMessagesWithModifiers(o,t,r),Hooks.call("finishOpposedTest",t,r,o,a),i.next=8,this.finishOpposedTestHookAsync(t,r,o,a);case 8:return this.playAutomatedJBA2(t,r,o),i.next=11,this.renderOpposedResult(o,a);case 11:return i.next=13,this.hideReactionButton(a.startMessageId);case 13:return i.abrupt("return",o);case 14:case"end":return i.stop()}}),_callee15,this)}))),function completeOpposedProcess(t,r,a){return m.apply(this,arguments)})},{key:"finishOpposedTestHookAsync",value:(h=_asyncToGenerator(_regeneratorRuntime().mark((function _callee16(t,r,a,o){return _regeneratorRuntime().wrap((function _callee16$(t){for(;;)switch(t.prev=t.next){case 0:case"end":return t.stop()}}),_callee16)}))),function finishOpposedTestHookAsync(t,r,a,o){return h.apply(this,arguments)})},{key:"evaluateOpposedTest",value:(a=_asyncToGenerator(_regeneratorRuntime().mark((function _callee17(t,r){var a,o,i=arguments;return _regeneratorRuntime().wrap((function _callee17$(c){for(;;)switch(c.prev=c.next){case 0:if(a=i.length>2&&void 0!==i[2]?i[2]:{},(o={}).other=[],a.additionalInfo&&o.other.push(a.additionalInfo),o.winner="attacker",["weapon","spell","liturgy","ceremony","ritual","combatskill"].includes(t.rollType)&&null==r.successLevel&&(r.successLevel=-5),null==r.successLevel){c.next=16;break}c.t0=t.rollType,c.next="combatskill"===c.t0||"talent"===c.t0?10:"ceremony"===c.t0||"ritual"===c.t0||"spell"===c.t0||"liturgy"===c.t0||"weapon"===c.t0?12:14;break;case 10:return this._evaluateTalentOpposedRoll(t,r,o,a),c.abrupt("break",16);case 12:return this._evaluateWeaponOpposedRoll(t,r,o,a),c.abrupt("break",16);case 14:ui.notifications.error("Can not oppose "+t.rollType),console.warn("Can not oppose "+t.rollType);case 16:return c.abrupt("return",o);case 17:case"end":return c.stop()}}),_callee17,this)}))),function evaluateOpposedTest(t,r){return a.apply(this,arguments)})},{key:"_evaluateWeaponOpposedRoll",value:function _evaluateWeaponOpposedRoll(t,r,a){var o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};if(t.successLevel>0&&r.successLevel<0){var i=this._calculateOpposedDamage(t,r,o);if(i.armorDamaged.damaged&&i.armorDamaged.ids.length){var c=i.armorDamaged.ids.join(";");a.other.push('
    "))}r.counterAttack&&(i.damage+=2,i.sum=i.damage-i.armor,i.tooltip=game.i18n.localize("LocalizedIDs.counterAttack")+" 2"),i.messages.length&&(i.tooltip||(i.tooltip=""),i.tooltip+=" ".concat(i.messages.join("
    "))),a.winner="attacker";var u=[0!=i.armorMod?"".concat(i.armorMod+" "+game.i18n.localize("Modifier")):"",1!=i.armorMultiplier?"*"+i.armorMultiplier+" "+game.i18n.localize("Modifier"):"",0!=i.spellArmor?"".concat(i.spellArmor," ").concat(game.i18n.localize("spellArmor")):"",0!=i.liturgyArmor?"".concat(i.liturgyArmor," ").concat(game.i18n.localize("liturgyArmor")):""].join(""),l="".concat(game.i18n.localize("damage"),": ").concat(i.damage,' - ').concat(i.armor,' = ').concat(i.sum);a.damage={description:l,value:i.sum,sp:i.damage}}else a.winner="defender"}},{key:"_calculateOpposedDamage",value:function _calculateOpposedDamage(t,r){var a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i=o.Z.getSpeaker(r.speaker),c=[],d=t.damage,h=game.i18n.localize("LocalizedIDs.immuneToCrit");t.doubleDamage&&i.items.find((function(t){return t.name==h&&"trait"==t.type}))&&(d=Math.floor(d/t.doubleDamage),c.push(h)),a.origin=t.source,a.damage=d;var m,y=p.Z.applyRollTransformation(i,a,5).options.damage,g=u.Z.armorValue(i,a),v=g.wornArmor,_=g.armor,b=[],k=0,w=t.armorPen||[],x=_createForOfIteratorHelper(w);try{for(x.s();!(m=x.n()).done;){var S=m.value;/^\*/.test(S)?b.push(Number(S.replace("*",""))):k+=Number(S)}}catch(t){x.e(t)}finally{x.f()}var T=0,A=0;["spell","ritual"].includes(t.source.type)?T+=i.system.spellArmor||0:["liturgy","ceremony"].includes(t.source.type)&&(T+=i.system.liturgyArmor||0),_+=k;var O=b.reduce((function(t,r){return t*r}),1);_=Math.max(Math.round(_*O),0),_+=T+A;var P=l.Z.armorGetsDamage(y,t),E=v.map((function(t){return t.uuid}));return{damage:y,armor:_,armorDamaged:{damaged:P,ids:E},armorMod:k,spellArmor:T,liturgyArmor:A,armorMultiplier:O,messages:c,sum:y-_}}},{key:"_evaluateTalentOpposedRoll",value:function _evaluateTalentOpposedRoll(t,r,a){t.successLevel>0&&t.successLevel>r.successLevel?a.winner="attacker":t.qualityStep>r.qualityStep||t.result>=0&&r.result<0?(a.winner="attacker",a.differenceSL=t.qualityStep-r.qualityStep):(a.winner="defender",a.differenceSL=r.qualityStep-t.qualityStep)}},{key:"formatOpposedResult",value:function formatOpposedResult(t,r,a){var o=t.differenceSL?"winsFP":"wins";return"attacker"==t.winner?(t.result=game.i18n.format("OPPOSED."+o,{winner:r.alias,loser:a.alias,SL:t.differenceSL}),t.img=r.img):"defender"==t.winner&&(t.result=game.i18n.format("OPPOSED."+o,{winner:a.alias,loser:r.alias,SL:t.differenceSL}),t.img=a.img),t.speakerAttack=r,t.speakerDefend=a,t}},{key:"rerenderMessagesWithModifiers",value:function rerenderMessagesWithModifiers(t,r,a){var o=game.messages.get(r.messageId);this.showDamage(o,"attacker"!=t.winner)}},{key:"renderOpposedResult",value:(r=_asyncToGenerator(_regeneratorRuntime().mark((function _callee18(t){var r,a,o,i=arguments;return _regeneratorRuntime().wrap((function _callee18$(c){for(;;)switch(c.prev=c.next){case 0:return r=i.length>1&&void 0!==i[1]?i[1]:{},c.next=3,game.settings.get("dsa5","hideOpposedDamage");case 3:return t.hideData=c.sent,c.next=6,renderTemplate("systems/dsa5/templates/chat/roll/opposed-result.html",t);case 6:return a=c.sent,o={user:game.user.id,content:a,"flags.opposeData":t,"flags.hideData":t.hideData,whisper:r.whisper,blind:r.blind},r.target&&(o["flags.startMessageId"]=r.startMessageId),c.next=11,ChatMessage.create(o);case 11:case"end":return c.stop()}}),_callee18)}))),function renderOpposedResult(t){return r.apply(this,arguments)})},{key:"resolveUndefended",value:(t=_asyncToGenerator(_regeneratorRuntime().mark((function _callee19(t){var r,a,o,i,c,u,l,p=arguments;return _regeneratorRuntime().wrap((function _callee19$(d){for(;;)switch(d.prev=d.next){case 0:return a=p.length>1&&void 0!==p[1]?p[1]:"",o=t.flags.unopposeData,i=game.messages.get(o.attackMessageId),(c={speaker:i.speaker,testResult:i.flags.data.postData,messageId:o.attackMessageId}).testResult.source=i.flags.data.preData.source,c.testResult.ammo&&(r=c.testResult.source.effects).push.apply(r,_toConsumableArray(c.testResult.ammo.effects)),u=canvas.tokens.get(o.targetSpeaker.token),l={speaker:o.targetSpeaker,testResult:{actor:u.actor,speaker:{token:o.targetSpeaker.token}}},d.next=10,this.clearOpposed(u.actor);case 10:return d.next=12,this.completeOpposedProcess(c,l,{target:!0,startMessageId:t.id,additionalInfo:a});case 12:if(!game.user.isGM){d.next=17;break}return d.next=15,i.update({"flags.data.unopposedStartMessage":t.id});case 15:d.next=19;break;case 17:return d.next=19,game.socket.emit("system.dsa5",{type:"updateAttackMessage",payload:{messageId:i.id,startMessageId:t.id}});case 19:case"end":return d.stop()}}),_callee19,this)}))),function resolveUndefended(r){return t.apply(this,arguments)})}]),OpposedDsa5}()},903:(t,r,a)=>{a.d(r,{Z:()=>u});var o=a(538),i=a(231),c=a(491);function _typeof(t){return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},_typeof(t)}function _createForOfIteratorHelper(t,r){var a="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!a){if(Array.isArray(t)||(a=function _unsupportedIterableToArray(t,r){if(!t)return;if("string"==typeof t)return _arrayLikeToArray(t,r);var a=Object.prototype.toString.call(t).slice(8,-1);"Object"===a&&t.constructor&&(a=t.constructor.name);if("Map"===a||"Set"===a)return Array.from(t);if("Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a))return _arrayLikeToArray(t,r)}(t))||r&&t&&"number"==typeof t.length){a&&(t=a);var o=0,i=function F(){};return{s:i,n:function n(){return o>=t.length?{done:!0}:{done:!1,value:t[o++]}},e:function e(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var c,u=!0,l=!1;return{s:function s(){a=a.call(t)},n:function n(){var t=a.next();return u=t.done,t},e:function e(t){l=!0,c=t},f:function f(){try{u||null==a.return||a.return()}finally{if(l)throw c}}}}function _arrayLikeToArray(t,r){(null==r||r>t.length)&&(r=t.length);for(var a=0,o=new Array(r);a=0;--o){var i=this.tryEntries[o],c=i.completion;if("root"===i.tryLoc)return handle("end");if(i.tryLoc<=this.prev){var u=a.call(i,"catchLoc"),l=a.call(i,"finallyLoc");if(u&&l){if(this.prev=0;--o){var i=this.tryEntries[o];if(i.tryLoc<=this.prev&&a.call(i,"finallyLoc")&&this.prev=0;--r){var a=this.tryEntries[r];if(a.finallyLoc===t)return this.complete(a.completion,a.afterLoc),resetTryEntry(a),l}},catch:function _catch(t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc===t){var o=a.completion;if("throw"===o.type){var i=o.arg;resetTryEntry(a)}return i}}throw new Error("illegal catch attempt")},delegateYield:function delegateYield(t,r,a){return this.delegate={iterator:values(t),resultName:r,nextLoc:a},"next"===this.method&&(this.arg=void 0),l}},t}function asyncGeneratorStep(t,r,a,o,i,c,u){try{var l=t[c](u),p=l.value}catch(t){return void a(t)}l.done?r(p):Promise.resolve(p).then(o,i)}function _asyncToGenerator(t){return function(){var r=this,a=arguments;return new Promise((function(o,i){var c=t.apply(r,a);function _next(t){asyncGeneratorStep(c,o,i,_next,_throw,"next",t)}function _throw(t){asyncGeneratorStep(c,o,i,_next,_throw,"throw",t)}_next(void 0)}))}}function _defineProperties(t,r){for(var a=0;a3&&void 0!==h[3]?h[3]:0,c=i.Z._getActor(),u=c.actor,l=c.tokenId,u){m.next=4;break}return m.abrupt("return");case 4:game.user.updateTokenTargets([]),p={modifier:o,postFunction:{cummulative:a,functionName:"game.dsa5.apps.RequestRoll.autoEditGroupCheckRoll"}},m.t0=t,m.next="attribute"===m.t0?9:10;break;case 9:return m.abrupt("break",12);case 10:d=u.items.find((function(a){return a.name==r&&a.type==t})),u.setupSkill(d,p,l).then(function(){var o=_asyncToGenerator(_regeneratorRuntime().mark((function _callee(o){var i;return _regeneratorRuntime().wrap((function _callee$(c){for(;;)switch(c.prev=c.next){case 0:return c.next=2,u.basicTest(o);case 2:return i=c.sent,c.next=5,RequestRoll.editGroupCheckRoll(a,i,r,t);case 5:case"end":return c.stop()}}),_callee)})));return function(t){return o.apply(this,arguments)}}());case 12:case"end":return m.stop()}}),_callee2)}))),function requestGC(t,r,a){return g.apply(this,arguments)})},{key:"autoEditGroupCheckRoll",value:(y=_asyncToGenerator(_regeneratorRuntime().mark((function _callee3(t,r,a){return _regeneratorRuntime().wrap((function _callee3$(o){for(;;)switch(o.prev=o.next){case 0:return o.next=2,RequestRoll.editGroupCheckRoll(t.cummulative,r,a.name,a.type);case 2:case"end":return o.stop()}}),_callee3)}))),function autoEditGroupCheckRoll(t,r,a){return y.apply(this,arguments)})},{key:"editGroupCheckRoll",value:(m=_asyncToGenerator(_regeneratorRuntime().mark((function _callee4(t,r,a,o){var i,u,l,p,d,h,m;return _regeneratorRuntime().wrap((function _callee4$(y){for(;;)switch(y.prev=y.next){case 0:return y.next=2,game.messages.get(t);case 2:i=y.sent,u=i.flags,l=r.result.successLevel>1,p=l?2:1,u.botched=u.botched||r.result.successLevel<-1,d=c.Z.getSpeaker(r.result.speaker),h={messageId:r.result.messageId,actor:d.name,qs:(r.result.qualityStep||0)*p,success:r.result.successLevel,target:a,type:o},(m=u.results.findIndex((function(t){return t.messageId==h.messageId})))>=0?u.results[m]=h:u.results.push(h),RequestRoll.rerenderGC(i,u);case 12:case"end":return y.stop()}}),_callee4)}))),function editGroupCheckRoll(t,r,a,o){return m.apply(this,arguments)})},{key:"requestRoll",value:(h=_asyncToGenerator(_regeneratorRuntime().mark((function _callee5(t,r){var a,o,c,u,l,p,d,h=arguments;return _regeneratorRuntime().wrap((function _callee5$(m){for(;;)switch(m.prev=m.next){case 0:if(a=h.length>2&&void 0!==h[2]?h[2]:0,o=i.Z._getActor(),c=o.actor,u=o.tokenId,!c){m.next=17;break}game.user.updateTokenTargets([]),l={modifier:a},m.t0=t,m.next="attribute"===m.t0?8:"regeneration"===m.t0?11:"fallingDamage"===m.t0?13:15;break;case 8:return p=Object.keys(game.dsa5.config.characteristics).find((function(t){return game.i18n.localize(game.dsa5.config.characteristics[t])==r})),c.setupCharacteristic(p,l,u).then((function(t){c.basicTest(t)})),m.abrupt("break",17);case 11:return c.setupRegeneration("regenerate",l,u).then((function(t){c.basicTest(t)})),m.abrupt("break",17);case 13:return c.setupFallingDamage(l,u),m.abrupt("break",17);case 15:d=c.items.find((function(a){return a.name==r&&a.type==t})),c.setupSkill(d,l,u).then((function(t){c.basicTest(t)}));case 17:case"end":return m.stop()}}),_callee5)}))),function requestRoll(t,r){return h.apply(this,arguments)})},{key:"rerenderGC",value:(d=_asyncToGenerator(_regeneratorRuntime().mark((function _callee6(t,r){var a,o,i,c,u;return _regeneratorRuntime().wrap((function _callee6$(l){for(;;)switch(l.prev=l.next){case 0:if(!game.user.isGM){l.next=14;break}a=0,r.qs=r.results.reduce((function(t,r){return a+=r.success<0?1:0,r.success>1&&(a=0),t+r.qs}),0),r.failed=a,o=_createForOfIteratorHelper(r.rollOptions);try{for(o.s();!(i=o.n()).done;)(c=i.value).calculatedModifier=c.modifier-a}catch(t){o.e(t)}finally{o.f()}return r.openRolls=r.maxRolls-r.results.length,r.doneRolls=r.results.length,l.next=10,renderTemplate("systems/dsa5/templates/chat/roll/groupcheck.html",r);case 10:u=l.sent,t.update({content:u,flags:r}),l.next=15;break;case 14:game.socket.emit("system.dsa5",{type:"updateGroupCheck",payload:{messageId:t.id,data:r}});case 15:$("#chat-log").find('[data-message-id="'.concat(t.id,'"')).appendTo("#chat-log");case 16:case"end":return l.stop()}}),_callee6)}))),function rerenderGC(t,r){return d.apply(this,arguments)})},{key:"showRQMessage",value:function showRQMessage(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,a=r<0?" ".concat(r):r>0?" +".concat(r):"",o=i.Z.skills.find((function(r){return r.name==t})).type,u=game.i18n.format("CHATNOTIFICATION.requestRoll",{user:game.user.name,item:' ').concat(t).concat(a,"")});ChatMessage.create(c.Z.chatDataSetup(u))}},{key:"showGCMessage",value:(p=_asyncToGenerator(_regeneratorRuntime().mark((function _callee7(t){var r,a,o,u,l,p,d=arguments;return _regeneratorRuntime().wrap((function _callee7$(h){for(;;)switch(h.prev=h.next){case 0:return r=d.length>1&&void 0!==d[1]?d[1]:0,a=d.length>2&&void 0!==d[2]?d[2]:{},o=i.Z.skills.find((function(r){return r.name==t})).type,u={results:[],qs:0,failed:0,modifier:r,name:game.user.name,maxRolls:7,openRolls:7,doneRolls:0,targetQs:10,rollOptions:[{type:o,modifier:r,calculatedModifier:r,target:t}]},mergeObject(u,a),h.next=7,renderTemplate("systems/dsa5/templates/chat/roll/groupcheck.html",u);case 7:l=h.sent,(p=c.Z.chatDataSetup(l)).flags=u,ChatMessage.create(p);case 11:case"end":return h.stop()}}),_callee7)}))),function showGCMessage(t){return p.apply(this,arguments)})},{key:"addSkillToGC",value:(l=_asyncToGenerator(_regeneratorRuntime().mark((function _callee9(t){var r,a,c;return _regeneratorRuntime().wrap((function _callee9$(u){for(;;)switch(u.prev=u.next){case 0:return r=$(t.currentTarget).parents(".message").attr("data-message-id"),u.next=3,renderTemplate("systems/dsa5/templates/dialog/addgroupcheckskill.html",{skills:i.Z.skills.filter((function(t){return"skill"==t.type})).sort((function(t,r){return t.name.localeCompare(r.name)}))});case 3:a=u.sent,c={title:game.i18n.localize("HELP.groupcheck"),content:a,buttons:{ok:{icon:'',label:game.i18n.localize("ok"),callback:function(){var t=_asyncToGenerator(_regeneratorRuntime().mark((function _callee8(t){var a,o;return _regeneratorRuntime().wrap((function _callee8$(i){for(;;)switch(i.prev=i.next){case 0:a=game.messages.get(r),(o=a.flags).rollOptions.push({type:"skill",modifier:t.find('[name="modifier"]').val(),target:t.find('[name="skill"]').val()}),RequestRoll.rerenderGC(a,o);case 4:case"end":return i.stop()}}),_callee8)})));return function callback(r){return t.apply(this,arguments)}}()},cancel:{icon:'',label:game.i18n.localize("cancel")}}},new o.Z(c).render(!0);case 6:case"end":return u.stop()}}),_callee9)}))),function addSkillToGC(t){return l.apply(this,arguments)})},{key:"removeGCEntry",value:(u=_asyncToGenerator(_regeneratorRuntime().mark((function _callee10(t){var r,a,o,i;return _regeneratorRuntime().wrap((function _callee10$(c){for(;;)switch(c.prev=c.next){case 0:r=$(t.currentTarget),a=Number(t.currentTarget.dataset.index),o=game.messages.get(r.parents(".message").attr("data-message-id")),(i=o.flags).results.splice(a,1),RequestRoll.rerenderGC(o,i);case 6:case"end":return c.stop()}}),_callee10)}))),function removeGCEntry(t){return u.apply(this,arguments)})},{key:"removeSkillFromGC",value:function removeSkillFromGC(t){var r=$(t.currentTarget),a=game.messages.get(r.parents(".message").attr("data-message-id")),o=a.flags;o.rollOptions=o.rollOptions.filter((function(r){return!(r.type==t.currentTarget.dataset.type&&r.target==t.currentTarget.dataset.name)})),o.results=o.results.filter((function(r){return!(r.type==t.currentTarget.dataset.type&&r.target==t.currentTarget.dataset.name)})),RequestRoll.rerenderGC(a,o)}},{key:"editGC",value:(a=_asyncToGenerator(_regeneratorRuntime().mark((function _callee11(t){var r,a,o,i;return _regeneratorRuntime().wrap((function _callee11$(c){for(;;)switch(c.prev=c.next){case 0:r=$(t.currentTarget),a=Number(t.currentTarget.dataset.index),o=game.messages.get(r.parents(".message").attr("data-message-id")),i=o.flags,a?i.results[a].qs=Number(r.val()):t.currentTarget.dataset.name?i.rollOptions.find((function(r){return r.target==t.currentTarget.dataset.name&&t.currentTarget.dataset.type==r.type}))[t.currentTarget.dataset.field]=Number(r.val()):i[t.currentTarget.dataset.field]=Number(r.val()),RequestRoll.rerenderGC(o,i);case 6:case"end":return c.stop()}}),_callee11)}))),function editGC(t){return a.apply(this,arguments)})},{key:"updateInformationRoll",value:(r=_asyncToGenerator(_regeneratorRuntime().mark((function _callee12(t,r,a){var o,i,u,l,p,d,h;return _regeneratorRuntime().wrap((function _callee12$(a){for(;;)switch(a.prev=a.next){case 0:if(!((o=r.result.qualityStep||0)>0)){a.next=20;break}return a.next=4,fromUuid(t.uuid);case 4:i=a.sent,u=["

    ".concat(i.name,"

    ")],l=1;case 7:if(!(l<=o)){a.next=17;break}if(p="qs".concat(l),!i.system[p]){a.next=14;break}return a.next=12,TextEditor.enrichHTML(i.system[p],{async:!0});case 12:d=a.sent,u.push("

    ".concat(d,"

    "));case 14:l++,a.next=7;break;case 17:h=c.Z.chatDataSetup(u.join("")),t.recipients.length&&(h.whisper=t.recipients),ChatMessage.create(h);case 20:case"end":return a.stop()}}),_callee12)}))),function updateInformationRoll(t,a,o){return r.apply(this,arguments)})},{key:"informationRequestRoll",value:(t=_asyncToGenerator(_regeneratorRuntime().mark((function _callee14(t){var r,a,o,c,u,l,p,d,h,m=this;return _regeneratorRuntime().wrap((function _callee14$(y){for(;;)switch(y.prev=y.next){case 0:if(r=t.currentTarget.dataset.mod,a=t.currentTarget.dataset.uuid,o=i.Z._getActor(),c=o.actor,u=o.tokenId,c){y.next=5;break}return y.abrupt("return");case 5:l=game.settings.get("dsa5","informationDistribution"),p=[],1==l?(p=game.users.filter((function(t){return t.isGM})).map((function(t){return t.id}))).push(game.user.id):2==l&&(p=game.users.filter((function(t){return t.isGM})).map((function(t){return t.id}))),d={modifier:r,postFunction:{functionName:"game.dsa5.apps.RequestRoll.updateInformationRoll",uuid:a,recipients:p}},h=c.items.find((function(r){return r.name==t.currentTarget.dataset.skill&&"skill"==r.type})),c.setupSkill(h,d,u).then(function(){var t=_asyncToGenerator(_regeneratorRuntime().mark((function _callee13(t){var r;return _regeneratorRuntime().wrap((function _callee13$(a){for(;;)switch(a.prev=a.next){case 0:return t.testData.opposable=!1,a.next=3,c.basicTest(t);case 3:r=a.sent,m.updateInformationRoll(d.postFunction,r);case 5:case"end":return a.stop()}}),_callee13)})));return function(r){return t.apply(this,arguments)}}());case 11:case"end":return y.stop()}}),_callee14)}))),function informationRequestRoll(r){return t.apply(this,arguments)})},{key:"chatListeners",value:function chatListeners(t){t.on("change",".editGC",(function(t){return RequestRoll.editGC(t)})),t.on("click",".request-roll",(function(t){var r=t.currentTarget.dataset;RequestRoll.requestRoll(r.type,r.name,Number(r.modifier)||0)})),t.on("click",".request-gc",(function(t){var r=t.currentTarget.dataset;RequestRoll.requestGC(r.type,r.name,$(t.currentTarget).parents(".message").attr("data-message-id"),Number(r.modifier)||0)})),t.on("click",".removeGC",(function(t){return RequestRoll.removeGCEntry(t)})),t.on("click",".removeSkillFromGC",(function(t){return RequestRoll.removeSkillFromGC(t)})),t.on("click",".addSkillToGC",(function(t){return RequestRoll.addSkillToGC(t)})),t.on("click",".informationRequestRoll",(function(t){return RequestRoll.informationRequestRoll(t)}))}}]),RequestRoll}()},169:(t,r,a)=>{a.d(r,{Z:()=>i});var o=a(491);function _typeof(t){return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},_typeof(t)}function _createForOfIteratorHelper(t,r){var a="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!a){if(Array.isArray(t)||(a=function _unsupportedIterableToArray(t,r){if(!t)return;if("string"==typeof t)return _arrayLikeToArray(t,r);var a=Object.prototype.toString.call(t).slice(8,-1);"Object"===a&&t.constructor&&(a=t.constructor.name);if("Map"===a||"Set"===a)return Array.from(t);if("Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a))return _arrayLikeToArray(t,r)}(t))||r&&t&&"number"==typeof t.length){a&&(t=a);var o=0,i=function F(){};return{s:i,n:function n(){return o>=t.length?{done:!0}:{done:!1,value:t[o++]}},e:function e(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var c,u=!0,l=!1;return{s:function s(){a=a.call(t)},n:function n(){var t=a.next();return u=t.done,t},e:function e(t){l=!0,c=t},f:function f(){try{u||null==a.return||a.return()}finally{if(l)throw c}}}}function _arrayLikeToArray(t,r){(null==r||r>t.length)&&(r=t.length);for(var a=0,o=new Array(r);a=0;--o){var i=this.tryEntries[o],c=i.completion;if("root"===i.tryLoc)return handle("end");if(i.tryLoc<=this.prev){var u=a.call(i,"catchLoc"),l=a.call(i,"finallyLoc");if(u&&l){if(this.prev=0;--o){var i=this.tryEntries[o];if(i.tryLoc<=this.prev&&a.call(i,"finallyLoc")&&this.prev=0;--r){var a=this.tryEntries[r];if(a.finallyLoc===t)return this.complete(a.completion,a.afterLoc),resetTryEntry(a),l}},catch:function _catch(t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc===t){var o=a.completion;if("throw"===o.type){var i=o.arg;resetTryEntry(a)}return i}}throw new Error("illegal catch attempt")},delegateYield:function delegateYield(t,r,a){return this.delegate={iterator:values(t),resultName:r,nextLoc:a},"next"===this.method&&(this.arg=void 0),l}},t}function asyncGeneratorStep(t,r,a,o,i,c,u){try{var l=t[c](u),p=l.value}catch(t){return void a(t)}l.done?r(p):Promise.resolve(p).then(o,i)}function _asyncToGenerator(t){return function(){var r=this,a=arguments;return new Promise((function(o,i){var c=t.apply(r,a);function _next(t){asyncGeneratorStep(c,o,i,_next,_throw,"next",t)}function _throw(t){asyncGeneratorStep(c,o,i,_next,_throw,"throw",t)}_next(void 0)}))}}function _defineProperties(t,r){for(var a=0;a1&&void 0!==arguments[1]?arguments[1]:{},i=this.getHorse(t);if(i){var c=this.getLoyaltyFromHorse(i);if(!c)return ui.notifications.warn(game.i18n.format("DSAError.notFound",{category:o.Z.categoryLocalization("skill"),name:game.i18n.localize("LocalizedIDs.loyalty")}));i.setupSkill(c,a,null===(r=i.token)||void 0===r?void 0:r.id).then((function(t){i.basicTest(t)}))}}},{key:"updateRiderSpeed",value:(d=_asyncToGenerator(_regeneratorRuntime().mark((function _callee2(t,r){var a,o,i,c,u,l;return _regeneratorRuntime().wrap((function _callee2$(p){for(;;)switch(p.prev=p.next){case 0:if(null!==(a=canvas)&&void 0!==a&&null!==(o=a.tokens)&&void 0!==o&&o.documentCollection){p.next=2;break}return p.abrupt("return");case 2:for(i=t.getActiveTokens().map((function(t){return t.id})),c=0,u=Array.from(canvas.tokens.documentCollection);c1&&void 0!==arguments[1]&&arguments[1];return t.system.horse&&!(r=t.system.horse.token&&!t.system.horse.actorLink?o.Z.getSpeaker(t.system.horse.token):game.actors.get(t.system.horse.actorId))&&a&&t.system.horse.isRiding&&(r={name:game.i18n.localize("unknown")}),r}},{key:"unmountHorse",value:(c=_asyncToGenerator(_regeneratorRuntime().mark((function _callee7(t,r){var a,o,i,c,u;return _regeneratorRuntime().wrap((function _callee7$(l){for(;;)switch(l.prev=l.next){case 0:return _defineProperty(o={},"flags.dsa5.-=horseTokenId",null),_defineProperty(o,"elevation",Math.max(0,(null!==(a=r.elevation)&&void 0!==a?a:0)-1)),i=o,(c=r.getFlag("dsa5","horseResized"))&&mergeObject(i,(_defineProperty(u={},"flags.dsa5.-=horseResized",null),_defineProperty(u,"width",c.width),_defineProperty(u,"height",c.height),u)),l.next=5,this.clearMount(t);case 5:return l.next=7,r.update(i);case 7:case"end":return l.stop()}}),_callee7,this)}))),function unmountHorse(t,r){return c.apply(this,arguments)})},{key:"clearMount",value:(i=_asyncToGenerator(_regeneratorRuntime().mark((function _callee8(t){return _regeneratorRuntime().wrap((function _callee8$(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,t.update({system:{horse:{isRiding:!1,actorLink:!1,actorId:"","-=token":null}}});case 2:return r.next=4,this.removeRidingCondition(t);case 4:case"end":return r.stop()}}),_callee8,this)}))),function clearMount(t){return i.apply(this,arguments)})},{key:"ridingCondition",value:function ridingCondition(){return{name:game.i18n.localize("RIDING.riding"),icon:"systems/dsa5/icons/thirdparty/horse-head.svg",changes:[{key:"system.status.dodge.gearmodifier",mode:2,value:-2}],flags:{dsa5:{description:game.i18n.localize("RIDING.ridingDescription")}}}}},{key:"setHorse",value:(a=_asyncToGenerator(_regeneratorRuntime().mark((function _callee9(t,r){var a;return _regeneratorRuntime().wrap((function _callee9$(o){for(;;)switch(o.prev=o.next){case 0:return a={system:{horse:{isRiding:!0,actorLink:r.prototypeToken.actorLink,actorId:r.id}}},!r.prototypeToken.actorLink&&r.token&&mergeObject(a,{system:{horse:{token:{scene:canvas.scene.id,token:r.token.id}}}}),o.next=4,t.update(a);case 4:if(!r.isToken){o.next=7;break}return o.next=7,canvas.scene.updateEmbeddedDocuments("Token",t.getActiveTokens().map((function(t){return{_id:t.id,"flags.dsa5.horseTokenId":r.token.id,x:r.token.x,y:r.token.y}})).concat(_defineProperty({_id:r.token.id},"flags.dsa5.-=horseTokenId",null)),{noHooks:!0});case 7:return o.next=9,this.addRidingCondition(t);case 9:case"end":return o.stop()}}),_callee9,this)}))),function setHorse(t,r){return a.apply(this,arguments)})},{key:"adaptTokenSize",value:function adaptTokenSize(t,r){return t.width>=r.width?{width:.7*r.width,height:.7*r.height,"flags.dsa5.horseResized":{width:t.width,height:t.height}}:{}}},{key:"mountHorse",value:(r=_asyncToGenerator(_regeneratorRuntime().mark((function _callee10(t){var r,a,o,i,c;return _regeneratorRuntime().wrap((function _callee10$(u){for(;;)switch(u.prev=u.next){case 0:return a=canvas.tokens.controlled.find((function(r){return r.document.id!=t.id})),o=t.parent,i={system:{horse:{isRiding:!0,actorLink:a.actorLink,actorId:a.actor.id}}},a.actorLink||mergeObject(i,{system:{horse:{token:{scene:o.id,token:a.id}}}}),c={_id:t.id,"flags.dsa5.horseTokenId":a.id,x:a.x,y:a.y,elevation:(null!==(r=a.document.elevation)&&void 0!==r?r:0)+1},mergeObject(c,this.adaptTokenSize(t.document,a.document)),u.next=8,t.actor.update(i);case 8:return u.next=10,canvas.scene.updateEmbeddedDocuments("Token",[c,_defineProperty({_id:a.id},"flags.dsa5.-=horseTokenId",null)],{noHooks:!0});case 10:return u.next=12,this.addRidingCondition(t.actor);case 12:case"end":return u.stop()}}),_callee10,this)}))),function mountHorse(t){return r.apply(this,arguments)})},{key:"getHorseSpeed",value:function getHorseSpeed(t){var r;return(null===(r=t.effects.find((function(t){return getProperty(t,"flags.dsa5.horseSpeed")})))||void 0===r?void 0:r.flags.dsa5.horseSpeed)||0}},{key:"horseSpeedModifier",value:function horseSpeedModifier(t){var r=this.getHorseSpeed(t);return Object.keys(this.speedKeys).map((function(t){return Number(t)})).indexOf(Number(r))}},{key:"increaseSpeed",value:function increaseSpeed(t){var r=this.getHorseSpeed(t),a=Math.min(3,Object.keys(this.speedKeys).map((function(t){return Number(t)})).indexOf(r)+1);this.setSpeed(t,Object.keys(this.speedKeys).map((function(t){return Number(t)}))[a])}},{key:"decreaseSpeed",value:function decreaseSpeed(t){var r=this.getHorseSpeed(t),a=Math.max(0,Object.keys(this.speedKeys).map((function(t){return Number(t)})).indexOf(r)-1);this.setSpeed(t,Object.keys(this.speedKeys).map((function(t){return Number(t)}))[a])}},{key:"setSpeed",value:(t=_asyncToGenerator(_regeneratorRuntime().mark((function _callee11(t,r){return _regeneratorRuntime().wrap((function _callee11$(a){for(;;)switch(a.prev=a.next){case 0:return a.next=2,t.deleteEmbeddedDocuments("ActiveEffect",t.effects.filter((function(t){return hasProperty(t,"flags.dsa5.horseSpeed")})).map((function(t){return t.id})));case 2:return a.next=4,t.addCondition({name:game.i18n.localize("speed")+": "+game.i18n.localize("RIDING.speeds.".concat(r)),icon:"systems/dsa5/icons/thirdparty/horse-head.svg",changes:[this.speedKeys[r]],flags:{dsa5:{description:game.i18n.localize("RIDING.speed.".concat(r)),horseSpeed:r}}});case 4:case"end":return a.stop()}}),_callee11,this)}))),function setSpeed(r,a){return t.apply(this,arguments)})},{key:"renderTokenHUD",value:function renderTokenHUD(t,r,a){var o=this,i=t.object.actor;if(2==canvas.tokens.controlled.length)r.find(".col.left").prepend(this.preRenderedMountHud),r.find('.control-icon[data-action="ride"]').click((function(){return o.mountHorse(t.object)}));else if(this.isRiding(i)){r.find(".col.left").prepend(this.preRenderedUnmountHud);var c=r.find('.control-icon[data-action="ride"]');c.click((function(){o.unmountHorse(i,t.object.document),c.remove()}));var u=this.getHorse(i);r.find(".col.right").prepend(this.preRenderedSpeedHud),r.find('.control-icon[data-action="rideIncrease"]').click((function(){return o.increaseSpeed(u)})),r.find('.control-icon[data-action="rideDecrease"]').click((function(){return o.decreaseSpeed(u)}))}}}]),Riding}();_defineProperty(i,"preRenderedUnmountHud",'\n
    \n \n
    \n '),_defineProperty(i,"preRenderedMountHud",'
    '),_defineProperty(i,"preRenderedSpeedHud",'\n
    \n
    \n '),_defineProperty(i,"speedKeys",{0:{key:"system.status.speed.multiplier",mode:5,value:0},"-4":{key:"system.status.speed.initial",mode:5,value:4},"-5000":{key:"system.status.speed.multiplier",mode:5,value:.66},"-8":{key:"system.status.speed.multiplier",mode:5,value:1}})},122:(t,r,a)=>{a.d(r,{Z:()=>u});var o=a(973),i=a(173),c=a(491);function _typeof(t){return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},_typeof(t)}function _createForOfIteratorHelper(t,r){var a="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!a){if(Array.isArray(t)||(a=function _unsupportedIterableToArray(t,r){if(!t)return;if("string"==typeof t)return _arrayLikeToArray(t,r);var a=Object.prototype.toString.call(t).slice(8,-1);"Object"===a&&t.constructor&&(a=t.constructor.name);if("Map"===a||"Set"===a)return Array.from(t);if("Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a))return _arrayLikeToArray(t,r)}(t))||r&&t&&"number"==typeof t.length){a&&(t=a);var o=0,i=function F(){};return{s:i,n:function n(){return o>=t.length?{done:!0}:{done:!1,value:t[o++]}},e:function e(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var c,u=!0,l=!1;return{s:function s(){a=a.call(t)},n:function n(){var t=a.next();return u=t.done,t},e:function e(t){l=!0,c=t},f:function f(){try{u||null==a.return||a.return()}finally{if(l)throw c}}}}function _arrayLikeToArray(t,r){(null==r||r>t.length)&&(r=t.length);for(var a=0,o=new Array(r);a=0;--o){var i=this.tryEntries[o],c=i.completion;if("root"===i.tryLoc)return handle("end");if(i.tryLoc<=this.prev){var u=a.call(i,"catchLoc"),l=a.call(i,"finallyLoc");if(u&&l){if(this.prev=0;--o){var i=this.tryEntries[o];if(i.tryLoc<=this.prev&&a.call(i,"finallyLoc")&&this.prev=0;--r){var a=this.tryEntries[r];if(a.finallyLoc===t)return this.complete(a.completion,a.afterLoc),resetTryEntry(a),l}},catch:function _catch(t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc===t){var o=a.completion;if("throw"===o.type){var i=o.arg;resetTryEntry(a)}return i}}throw new Error("illegal catch attempt")},delegateYield:function delegateYield(t,r,a){return this.delegate={iterator:values(t),resultName:r,nextLoc:a},"next"===this.method&&(this.arg=void 0),l}},t}function asyncGeneratorStep(t,r,a,o,i,c,u){try{var l=t[c](u),p=l.value}catch(t){return void a(t)}l.done?r(p):Promise.resolve(p).then(o,i)}function _asyncToGenerator(t){return function(){var r=this,a=arguments;return new Promise((function(o,i){var c=t.apply(r,a);function _next(t){asyncGeneratorStep(c,o,i,_next,_throw,"next",t)}function _throw(t){asyncGeneratorStep(c,o,i,_next,_throw,"throw",t)}_next(void 0)}))}}function _defineProperties(t,r){for(var a=0;ad)){m.next=14;break}return m.next=14,l.update(p);case 14:m.next=22;break;case 16:return h=duplicate(CONFIG.statusEffects.find((function(t){return"bleeding"==t.id}))),mergeObject(h,p),m.next=20,o.Z.addCondition(i,h,1,!1,!0);case 20:return m.next=22,ChatMessage.create(c.Z.chatDataSetup(game.i18n.format("CHATNOTIFICATION.gotBleeding",{actor:i.name})));case 22:case"end":return m.stop()}}),_callee2)})));return function(r){return t.apply(this,arguments)}}());case 5:case"end":return l.stop()}}),_callee3)}))),function calcBleeding(r){return t.apply(this,arguments)})},{key:"increment",value:function increment(t,r,a){var o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:void 0,i=t.ctrlKey?10:1,c=2==t.button?-1:1,u=getProperty(r,a)+i*c;return null!=o&&(u=Math.max(o,u)),setProperty(r,a,u),u}},{key:"magicalImprovement",value:function magicalImprovement(t,r){var a,o=_createForOfIteratorHelper(t.items);try{for(o.s();!(a=o.n()).done;){var i=a.value;["ritual","spell"].includes(i.type)&&(i.system.talentValue.value+=4)}}catch(t){o.e(t)}finally{o.f()}}}]),RuleChaos}();_defineProperty(u,"regex2h",/\(2H/)},173:(t,r,a)=>{a.d(r,{Z:()=>u});var o=a(577),i=a(794),c=a(492);function _typeof(t){return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},_typeof(t)}function _regeneratorRuntime(){_regeneratorRuntime=function _regeneratorRuntime(){return t};var t={},r=Object.prototype,a=r.hasOwnProperty,o="function"==typeof Symbol?Symbol:{},i=o.iterator||"@@iterator",c=o.asyncIterator||"@@asyncIterator",u=o.toStringTag||"@@toStringTag";function define(t,r,a){return Object.defineProperty(t,r,{value:a,enumerable:!0,configurable:!0,writable:!0}),t[r]}try{define({},"")}catch(t){define=function define(t,r,a){return t[r]=a}}function wrap(t,r,a,o){var i=r&&r.prototype instanceof Generator?r:Generator,c=Object.create(i.prototype),u=new Context(o||[]);return c._invoke=function(t,r,a){var o="suspendedStart";return function(i,c){if("executing"===o)throw new Error("Generator is already running");if("completed"===o){if("throw"===i)throw c;return doneResult()}for(a.method=i,a.arg=c;;){var u=a.delegate;if(u){var p=maybeInvokeDelegate(u,a);if(p){if(p===l)continue;return p}}if("next"===a.method)a.sent=a._sent=a.arg;else if("throw"===a.method){if("suspendedStart"===o)throw o="completed",a.arg;a.dispatchException(a.arg)}else"return"===a.method&&a.abrupt("return",a.arg);o="executing";var d=tryCatch(t,r,a);if("normal"===d.type){if(o=a.done?"completed":"suspendedYield",d.arg===l)continue;return{value:d.arg,done:a.done}}"throw"===d.type&&(o="completed",a.method="throw",a.arg=d.arg)}}}(t,a,u),c}function tryCatch(t,r,a){try{return{type:"normal",arg:t.call(r,a)}}catch(t){return{type:"throw",arg:t}}}t.wrap=wrap;var l={};function Generator(){}function GeneratorFunction(){}function GeneratorFunctionPrototype(){}var p={};define(p,i,(function(){return this}));var d=Object.getPrototypeOf,h=d&&d(d(values([])));h&&h!==r&&a.call(h,i)&&(p=h);var m=GeneratorFunctionPrototype.prototype=Generator.prototype=Object.create(p);function defineIteratorMethods(t){["next","throw","return"].forEach((function(r){define(t,r,(function(t){return this._invoke(r,t)}))}))}function AsyncIterator(t,r){function invoke(o,i,c,u){var l=tryCatch(t[o],t,i);if("throw"!==l.type){var p=l.arg,d=p.value;return d&&"object"==_typeof(d)&&a.call(d,"__await")?r.resolve(d.__await).then((function(t){invoke("next",t,c,u)}),(function(t){invoke("throw",t,c,u)})):r.resolve(d).then((function(t){p.value=t,c(p)}),(function(t){return invoke("throw",t,c,u)}))}u(l.arg)}var o;this._invoke=function(t,a){function callInvokeWithMethodAndArg(){return new r((function(r,o){invoke(t,a,r,o)}))}return o=o?o.then(callInvokeWithMethodAndArg,callInvokeWithMethodAndArg):callInvokeWithMethodAndArg()}}function maybeInvokeDelegate(t,r){var a=t.iterator[r.method];if(void 0===a){if(r.delegate=null,"throw"===r.method){if(t.iterator.return&&(r.method="return",r.arg=void 0,maybeInvokeDelegate(t,r),"throw"===r.method))return l;r.method="throw",r.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var o=tryCatch(a,t.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,l;var i=o.arg;return i?i.done?(r[t.resultName]=i.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=void 0),r.delegate=null,l):i:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,l)}function pushTryEntry(t){var r={tryLoc:t[0]};1 in t&&(r.catchLoc=t[1]),2 in t&&(r.finallyLoc=t[2],r.afterLoc=t[3]),this.tryEntries.push(r)}function resetTryEntry(t){var r=t.completion||{};r.type="normal",delete r.arg,t.completion=r}function Context(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(pushTryEntry,this),this.reset(!0)}function values(t){if(t){var r=t[i];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var o=-1,c=function next(){for(;++o=0;--o){var i=this.tryEntries[o],c=i.completion;if("root"===i.tryLoc)return handle("end");if(i.tryLoc<=this.prev){var u=a.call(i,"catchLoc"),l=a.call(i,"finallyLoc");if(u&&l){if(this.prev=0;--o){var i=this.tryEntries[o];if(i.tryLoc<=this.prev&&a.call(i,"finallyLoc")&&this.prev=0;--r){var a=this.tryEntries[r];if(a.finallyLoc===t)return this.complete(a.completion,a.afterLoc),resetTryEntry(a),l}},catch:function _catch(t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc===t){var o=a.completion;if("throw"===o.type){var i=o.arg;resetTryEntry(a)}return i}}throw new Error("illegal catch attempt")},delegateYield:function delegateYield(t,r,a){return this.delegate={iterator:values(t),resultName:r,nextLoc:a},"next"===this.method&&(this.arg=void 0),l}},t}function asyncGeneratorStep(t,r,a,o,i,c,u){try{var l=t[c](u),p=l.value}catch(t){return void a(t)}l.done?r(p):Promise.resolve(p).then(o,i)}function _asyncToGenerator(t){return function(){var r=this,a=arguments;return new Promise((function(o,i){var c=t.apply(r,a);function _next(t){asyncGeneratorStep(c,o,i,_next,_throw,"next",t)}function _throw(t){asyncGeneratorStep(c,o,i,_next,_throw,"throw",t)}_next(void 0)}))}}function _classCallCheck(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}function _defineProperties(t,r){for(var a=0;a2&&void 0!==c[2])||c[2],o.Z.removeAbilityRules[r.name]&&o.Z.removeAbilityRules[r.name](t,r),i=SpecialabilityRulesDSA5.calcAPCostSum(r),u.next=5,SpecialabilityRulesDSA5.refundFreelanguage(r,t,i,a);case 5:return i=u.sent,u.next=8,t._updateAPs(-1*i,{},{render:a});case 8:case"end":return u.stop()}}),_callee2)}))),function abilityRemoved(t,r){return l.apply(this,arguments)})},{key:"_specialabilityReturnFunction",value:(u=_asyncToGenerator(_regeneratorRuntime().mark((function _callee3(t,r,a,i){var c,u,l,p,d,h;return _regeneratorRuntime().wrap((function _callee3$(m){for(;;)switch(m.prev=m.next){case 0:if(null!=r){m.next=2;break}return m.abrupt("return");case 2:if(r=duplicate(r),null!=i&&(/,/.test(r.system.APValue.value)&&(u="".concat(r.name.replace(" ()","")," (").concat(i.name),r.system.APValue.value=r.system.APValue.value.split(",")[t.items.filter((function(t){return t.type==r.type&&t.name.includes(u)})).length].trim()),SpecialabilityRulesDSA5.simpleAdoption(r,i,r.name,o.Z.AbilitiesNeedingAdaption),r.name="".concat(r.name.replace(" ()","")," (").concat(i.name).concat(i.customEntry?", "+i.customEntry:"",")"),i.data&&null!==(c=i.system.StF)&&void 0!==c&&c.value&&/\//.test(r.system.APValue.value)&&(r.system.APValue.value=r.system.APValue.value.split("/")[i.system.StF.value.charCodeAt(0)-65].trim())),!(l=t.items.find((function(t){return t.type==a&&t.name==r.name})))){m.next=25;break}return p=duplicate(l),m.next=9,SpecialabilityRulesDSA5.isFreeLanguage(r,t,/;/.test(p.system.APValue.value)?p.system.APValue.value.split(";").map((function(t){return Number(t.trim())}))[p.system.step.value]:p.system.APValue.value,!1);case 9:if(d=m.sent,m.t0=p.system.step.value+1<=p.system.maxRank.value,!m.t0){m.next=15;break}return m.next=14,t.checkEnoughXP(d);case 14:m.t0=m.sent;case 15:if(!m.t0){m.next=23;break}return p.system.step.value+=1,m.next=19,t._updateAPs(d,{},{render:!1});case 19:return m.next=21,t.updateEmbeddedDocuments("Item",[p]);case 21:return m.next=23,SpecialabilityRulesDSA5.abilityAdded(t,p);case 23:m.next=37;break;case 25:return m.next=27,SpecialabilityRulesDSA5.isFreeLanguage(r,t,r.system.APValue.value.split(";").map((function(t){return t.trim()}))[0],!1);case 27:return h=m.sent,m.next=30,t.checkEnoughXP(h);case 30:if(!m.sent){m.next=37;break}return m.next=33,SpecialabilityRulesDSA5.abilityAdded(t,r);case 33:return m.next=35,t._updateAPs(h,{},{render:!1});case 35:return m.next=37,t.createEmbeddedDocuments("Item",[r]);case 37:case"end":return m.stop()}}),_callee3)}))),function _specialabilityReturnFunction(t,r,a,o){return u.apply(this,arguments)})},{key:"refundFreelanguage",value:(i=_asyncToGenerator(_regeneratorRuntime().mark((function _callee4(t,r,a){var o,i,c,u,l,p=arguments;return _regeneratorRuntime().wrap((function _callee4$(d){for(;;)switch(d.prev=d.next){case 0:if(o=!(p.length>3&&void 0!==p[3])||p[3],"language"!=t.system.category.value||!r.system.freeLanguagePoints){d.next=9;break}return i=Number(r.system.freeLanguagePoints.value),c=r.items.filter((function(t){return"specialability"==t.type&&"language"==t.system.category.value})).reduce((function(t,r){return t+Number(r.system.step.value)*Number(r.system.APValue.value)}),0),u=Math.min(i,c-Number(a)),l=Math.max(0,i-u),d.next=8,r.update({"system.freeLanguagePoints.used":Math.min(i,Number(u))},{render:o});case 8:a=Math.max(0,a-l);case 9:return d.abrupt("return",a);case 10:case"end":return d.stop()}}),_callee4)}))),function refundFreelanguage(t,r,a){return i.apply(this,arguments)})},{key:"isFreeLanguage",value:(a=_asyncToGenerator(_regeneratorRuntime().mark((function _callee5(t,r,a){var o,i,c,u,l,p=arguments;return _regeneratorRuntime().wrap((function _callee5$(d){for(;;)switch(d.prev=d.next){case 0:if(o=!(p.length>3&&void 0!==p[3])||p[3],"language"!=t.system.category.value||!r.system.freeLanguagePoints){d.next=9;break}return i=Number(r.system.freeLanguagePoints.value),c=r.items.filter((function(t){return"specialability"==t.type&&"language"==t.system.category.value})).reduce((function(t,r){return t+Number(r.system.step.value)*Number(r.system.APValue.value)}),0),u=Math.min(i,c),l=Math.max(0,i-u),d.next=8,r.update({"system.freeLanguagePoints.used":Math.min(i,Number(u)+Number(a))},{render:o});case 8:a=Math.max(0,a-l);case 9:return d.abrupt("return",a);case 10:case"end":return d.stop()}}),_callee5)}))),function isFreeLanguage(t,r,o){return a.apply(this,arguments)})},{key:"needsAdoption",value:(r=_asyncToGenerator(_regeneratorRuntime().mark((function _callee6(t,r,a){var i,u,l,p,d;return _regeneratorRuntime().wrap((function _callee6$(h){for(;;)switch(h.prev=h.next){case 0:if(!(i=o.Z.AbilitiesNeedingAdaption[r.name])){h.next=26;break}if("text"!=i.items){h.next=9;break}return h.next=5,renderTemplate("systems/dsa5/templates/dialog/requires-adoption-string-dialog.html",{original:r});case 5:u=h.sent,l=function callback(o){var i={name:o.find('[name="entryselection"]').val()};SpecialabilityRulesDSA5._specialabilityReturnFunction(t,r,a,i)},h.next=22;break;case 9:if("array"!=i.items){h.next=17;break}return p=i.elems.map((function(t){return{name:t}})),h.next=13,renderTemplate("systems/dsa5/templates/dialog/requires-adoption-dialog.html",{items:p,original:r,area:i.area});case 13:u=h.sent,l=function callback(o){var i=p.find((function(t){return t.name==o.find('[name="entryselection"]').val()}));SpecialabilityRulesDSA5._specialabilityReturnFunction(t,r,a,i)},h.next=22;break;case 17:return d=t.items.filter((function(t){return i.items.includes(t.type)})).sort((function(t,r){return t.name.localeCompare(r.name)})),h.next=20,renderTemplate("systems/dsa5/templates/dialog/requires-adoption-dialog.html",{items:d,original:r,area:i.area});case 20:u=h.sent,l=function callback(o){var i=d.find((function(t){return t.name==o.find('[name="entryselection"]').val()}));i.customEntry=o.find('[name="custom"]').val(),SpecialabilityRulesDSA5._specialabilityReturnFunction(t,r,a,i)};case 22:return h.next=24,new c.Z({title:game.i18n.localize("DIALOG.ItemRequiresAdoption"),content:u,buttons:{Yes:{icon:'',label:game.i18n.localize("yes"),callback:l},cancel:{icon:'',label:game.i18n.localize("cancel")}},default:"Yes"}).render(!0);case 24:h.next=27;break;case 26:SpecialabilityRulesDSA5._specialabilityReturnFunction(t,r,a,null);case 27:case"end":return h.stop()}}),_callee6)}))),function needsAdoption(t,a,o){return r.apply(this,arguments)})},{key:"hasAbility",value:function hasAbility(t,r){return _get(_getPrototypeOf(SpecialabilityRulesDSA5),"hasItem",this).call(this,t,r,["specialability"])}},{key:"abilityStep",value:function abilityStep(t,r){return _get(_getPrototypeOf(SpecialabilityRulesDSA5),"itemStep",this).call(this,t,r,["specialability"])}},{key:"abilityAsModifier",value:function abilityAsModifier(t,r){var a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,o=arguments.length>3&&void 0!==arguments[3]&&arguments[3];return _get(_getPrototypeOf(SpecialabilityRulesDSA5),"itemAsModifier",this).call(this,t,r,a,["specialability"],o)}}]),SpecialabilityRulesDSA5}(i.Z);i.Z.children.SpecialabilityRulesDSA5=u},101:(t,r,a)=>{a.d(r,{Z:()=>u});var o=a(577),i=a(794),c=a(491);function _typeof(t){return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},_typeof(t)}function _regeneratorRuntime(){_regeneratorRuntime=function _regeneratorRuntime(){return t};var t={},r=Object.prototype,a=r.hasOwnProperty,o="function"==typeof Symbol?Symbol:{},i=o.iterator||"@@iterator",c=o.asyncIterator||"@@asyncIterator",u=o.toStringTag||"@@toStringTag";function define(t,r,a){return Object.defineProperty(t,r,{value:a,enumerable:!0,configurable:!0,writable:!0}),t[r]}try{define({},"")}catch(t){define=function define(t,r,a){return t[r]=a}}function wrap(t,r,a,o){var i=r&&r.prototype instanceof Generator?r:Generator,c=Object.create(i.prototype),u=new Context(o||[]);return c._invoke=function(t,r,a){var o="suspendedStart";return function(i,c){if("executing"===o)throw new Error("Generator is already running");if("completed"===o){if("throw"===i)throw c;return doneResult()}for(a.method=i,a.arg=c;;){var u=a.delegate;if(u){var p=maybeInvokeDelegate(u,a);if(p){if(p===l)continue;return p}}if("next"===a.method)a.sent=a._sent=a.arg;else if("throw"===a.method){if("suspendedStart"===o)throw o="completed",a.arg;a.dispatchException(a.arg)}else"return"===a.method&&a.abrupt("return",a.arg);o="executing";var d=tryCatch(t,r,a);if("normal"===d.type){if(o=a.done?"completed":"suspendedYield",d.arg===l)continue;return{value:d.arg,done:a.done}}"throw"===d.type&&(o="completed",a.method="throw",a.arg=d.arg)}}}(t,a,u),c}function tryCatch(t,r,a){try{return{type:"normal",arg:t.call(r,a)}}catch(t){return{type:"throw",arg:t}}}t.wrap=wrap;var l={};function Generator(){}function GeneratorFunction(){}function GeneratorFunctionPrototype(){}var p={};define(p,i,(function(){return this}));var d=Object.getPrototypeOf,h=d&&d(d(values([])));h&&h!==r&&a.call(h,i)&&(p=h);var m=GeneratorFunctionPrototype.prototype=Generator.prototype=Object.create(p);function defineIteratorMethods(t){["next","throw","return"].forEach((function(r){define(t,r,(function(t){return this._invoke(r,t)}))}))}function AsyncIterator(t,r){function invoke(o,i,c,u){var l=tryCatch(t[o],t,i);if("throw"!==l.type){var p=l.arg,d=p.value;return d&&"object"==_typeof(d)&&a.call(d,"__await")?r.resolve(d.__await).then((function(t){invoke("next",t,c,u)}),(function(t){invoke("throw",t,c,u)})):r.resolve(d).then((function(t){p.value=t,c(p)}),(function(t){return invoke("throw",t,c,u)}))}u(l.arg)}var o;this._invoke=function(t,a){function callInvokeWithMethodAndArg(){return new r((function(r,o){invoke(t,a,r,o)}))}return o=o?o.then(callInvokeWithMethodAndArg,callInvokeWithMethodAndArg):callInvokeWithMethodAndArg()}}function maybeInvokeDelegate(t,r){var a=t.iterator[r.method];if(void 0===a){if(r.delegate=null,"throw"===r.method){if(t.iterator.return&&(r.method="return",r.arg=void 0,maybeInvokeDelegate(t,r),"throw"===r.method))return l;r.method="throw",r.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var o=tryCatch(a,t.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,l;var i=o.arg;return i?i.done?(r[t.resultName]=i.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=void 0),r.delegate=null,l):i:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,l)}function pushTryEntry(t){var r={tryLoc:t[0]};1 in t&&(r.catchLoc=t[1]),2 in t&&(r.finallyLoc=t[2],r.afterLoc=t[3]),this.tryEntries.push(r)}function resetTryEntry(t){var r=t.completion||{};r.type="normal",delete r.arg,t.completion=r}function Context(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(pushTryEntry,this),this.reset(!0)}function values(t){if(t){var r=t[i];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var o=-1,c=function next(){for(;++o=0;--o){var i=this.tryEntries[o],c=i.completion;if("root"===i.tryLoc)return handle("end");if(i.tryLoc<=this.prev){var u=a.call(i,"catchLoc"),l=a.call(i,"finallyLoc");if(u&&l){if(this.prev=0;--o){var i=this.tryEntries[o];if(i.tryLoc<=this.prev&&a.call(i,"finallyLoc")&&this.prev=0;--r){var a=this.tryEntries[r];if(a.finallyLoc===t)return this.complete(a.completion,a.afterLoc),resetTryEntry(a),l}},catch:function _catch(t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc===t){var o=a.completion;if("throw"===o.type){var i=o.arg;resetTryEntry(a)}return i}}throw new Error("illegal catch attempt")},delegateYield:function delegateYield(t,r,a){return this.delegate={iterator:values(t),resultName:r,nextLoc:a},"next"===this.method&&(this.arg=void 0),l}},t}function asyncGeneratorStep(t,r,a,o,i,c,u){try{var l=t[c](u),p=l.value}catch(t){return void a(t)}l.done?r(p):Promise.resolve(p).then(o,i)}function _asyncToGenerator(t){return function(){var r=this,a=arguments;return new Promise((function(o,i){var c=t.apply(r,a);function _next(t){asyncGeneratorStep(c,o,i,_next,_throw,"next",t)}function _throw(t){asyncGeneratorStep(c,o,i,_next,_throw,"throw",t)}_next(void 0)}))}}function _classCallCheck(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}function _defineProperties(t,r){for(var a=0;a{a.d(r,{Z:()=>u});var o=a(369),i=a(846),c=a(577);function _typeof(t){return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},_typeof(t)}function _toConsumableArray(t){return function _arrayWithoutHoles(t){if(Array.isArray(t))return _arrayLikeToArray(t)}(t)||function _iterableToArray(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||_unsupportedIterableToArray(t)||function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function _createForOfIteratorHelper(t,r){var a="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!a){if(Array.isArray(t)||(a=_unsupportedIterableToArray(t))||r&&t&&"number"==typeof t.length){a&&(t=a);var o=0,i=function F(){};return{s:i,n:function n(){return o>=t.length?{done:!0}:{done:!1,value:t[o++]}},e:function e(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var c,u=!0,l=!1;return{s:function s(){a=a.call(t)},n:function n(){var t=a.next();return u=t.done,t},e:function e(t){l=!0,c=t},f:function f(){try{u||null==a.return||a.return()}finally{if(l)throw c}}}}function _unsupportedIterableToArray(t,r){if(t){if("string"==typeof t)return _arrayLikeToArray(t,r);var a=Object.prototype.toString.call(t).slice(8,-1);return"Object"===a&&t.constructor&&(a=t.constructor.name),"Map"===a||"Set"===a?Array.from(t):"Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a)?_arrayLikeToArray(t,r):void 0}}function _arrayLikeToArray(t,r){(null==r||r>t.length)&&(r=t.length);for(var a=0,o=new Array(r);a=0;--o){var i=this.tryEntries[o],c=i.completion;if("root"===i.tryLoc)return handle("end");if(i.tryLoc<=this.prev){var u=a.call(i,"catchLoc"),l=a.call(i,"finallyLoc");if(u&&l){if(this.prev=0;--o){var i=this.tryEntries[o];if(i.tryLoc<=this.prev&&a.call(i,"finallyLoc")&&this.prev=0;--r){var a=this.tryEntries[r];if(a.finallyLoc===t)return this.complete(a.completion,a.afterLoc),resetTryEntry(a),l}},catch:function _catch(t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc===t){var o=a.completion;if("throw"===o.type){var i=o.arg;resetTryEntry(a)}return i}}throw new Error("illegal catch attempt")},delegateYield:function delegateYield(t,r,a){return this.delegate={iterator:values(t),resultName:r,nextLoc:a},"next"===this.method&&(this.arg=void 0),l}},t}function asyncGeneratorStep(t,r,a,o,i,c,u){try{var l=t[c](u),p=l.value}catch(t){return void a(t)}l.done?r(p):Promise.resolve(p).then(o,i)}function _asyncToGenerator(t){return function(){var r=this,a=arguments;return new Promise((function(o,i){var c=t.apply(r,a);function _next(t){asyncGeneratorStep(c,o,i,_next,_throw,"next",t)}function _throw(t){asyncGeneratorStep(c,o,i,_next,_throw,"throw",t)}_next(void 0)}))}}function _defineProperties(t,r){for(var a=0;ar.system.price.value?-1:1})));case 4:case"end":return r.stop()}}),_callee5,this)}))),function allMoneyItems(){return m.apply(this,arguments)})},{key:"allSkillsList",value:(h=_asyncToGenerator(_regeneratorRuntime().mark((function _callee6(){return _regeneratorRuntime().wrap((function _callee6$(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.allSkills();case 2:if(t.t0=t.sent,t.t0){t.next=5;break}t.t0=[];case 5:return t.abrupt("return",t.t0.map((function(t){return t.name})).sort((function(t,r){return t.localeCompare(r)})));case 6:case"end":return t.stop()}}),_callee6,this)}))),function allSkillsList(){return h.apply(this,arguments)})},{key:"allCombatSkillsList",value:(d=_asyncToGenerator(_regeneratorRuntime().mark((function _callee7(t){return _regeneratorRuntime().wrap((function _callee7$(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,this.allCombatSkills();case 2:if(r.t0=r.sent.filter((function(r){return r.system.weapontype.value==t})),r.t0){r.next=5;break}r.t0=[];case 5:return r.abrupt("return",r.t0.map((function(t){return t.name})).sort((function(t,r){return t.localeCompare(r)})));case 6:case"end":return r.stop()}}),_callee7,this)}))),function allCombatSkillsList(t){return d.apply(this,arguments)})},{key:"callItemTransformationMacro",value:(p=_asyncToGenerator(_regeneratorRuntime().mark((function _callee8(t,r,a){var o,i,c,u,l,p,d,h,m=arguments;return _regeneratorRuntime().wrap((function _callee8$(y){for(;;)switch(y.prev=y.next){case 0:if(o=m.length>3&&void 0!==m[3]?m[3]:{},i=t.split("."),c=game.packs.get("".concat(i[0],".").concat(i[1]))){y.next=6;break}return console.warn("Pack ".concat(c," not found")),y.abrupt("return",{});case 6:return y.next=8,c.getDocuments({name:i[2]});case 8:if(u=y.sent,l={},!u.length){y.next=27;break}return p=u[0],d="(async () => {".concat(p.command,"})()"),h=Function("args","source","effect",d),y.prev=14,o.result=l,y.next=18,h.call(this,o,r,a);case 18:y.next=25;break;case 20:y.prev=20,y.t0=y.catch(14),ui.notifications.error("There was an error in your macro syntax. See the console (F12) for details"),console.error(y.t0),l.error=!0;case 25:y.next=28;break;case 27:ui.notifications.error(game.i18n.format("DSAError.macroNotFound",{name:t}));case 28:return y.abrupt("return",l);case 29:case"end":return y.stop()}}),_callee8,this,[[14,20]])}))),function callItemTransformationMacro(t,r,a){return p.apply(this,arguments)})},{key:"isActiveGM",value:function isActiveGM(){var t;return null===(t=game.users.activeGM)||void 0===t?void 0:t.isSelf}},{key:"parseAbilityString",value:function parseAbilityString(t){return{original:t.replace(/ (FP|SR|FW|SP)?[+-]?\d{1,2}$/,"").trim(),name:t.replace(/\((.+?)\)/g,"()").replace(/ (FP|SR|FW|SP)?[+-]?\d{1,2}$/,"").trim(),step:Number((t.match(/[+-]?\d{1,2}$/)||[1])[0]),special:(t.match(/\(([^()]+)\)/)||["",""])[1],type:t.match(/ (FP|SP)[+-]?\d{1,2}/)?"FP":t.match(/ (FW|SR)[+-]?\d{1,2}/)?"FW":"",bonus:null!=t.match(/[-+]\d{1,2}$/)}}},{key:"categoryLocalization",value:function categoryLocalization(t){return game.i18n.localize("TYPES.Item.".concat(t))}},{key:"attributeLocalization",value:function attributeLocalization(t){return game.i18n.localize("CHAR.".concat(t.toUpperCase()))}},{key:"attributeAbbrLocalization",value:function attributeAbbrLocalization(t){return game.i18n.localize("CHARAbbrev.".concat(t.toUpperCase()))}},{key:"callAsyncHooks",value:(l=_asyncToGenerator(_regeneratorRuntime().mark((function _callee9(t,r){var a,o,i;return _regeneratorRuntime().wrap((function _callee9$(u){for(;;)switch(u.prev=u.next){case 0:a=_createForOfIteratorHelper(c.Z.asyncHooks[t]),u.prev=1,a.s();case 3:if((o=a.n()).done){u.next=9;break}return i=o.value,u.next=7,i.apply(void 0,_toConsumableArray(r));case 7:u.next=3;break;case 9:u.next=14;break;case 11:u.prev=11,u.t0=u.catch(1),a.e(u.t0);case 14:return u.prev=14,a.f(),u.finish(14);case 17:case"end":return u.stop()}}),_callee9,null,[[1,11,14,17]])}))),function callAsyncHooks(t,r){return l.apply(this,arguments)})},{key:"chatDataSetup",value:function chatDataSetup(t,r,a,o){var i={user:game.user.id,rollMode:r||game.settings.get("core","rollMode"),content:t};return["gmroll","blindroll"].includes(i.rollMode)&&(i.whisper=ChatMessage.getWhisperRecipients("GM").map((function(t){return t.id}))),"blindroll"===i.rollMode?i.blind=!0:"selfroll"===i.rollMode&&(i.whisper=[game.user]),a&&(i.speaker=ChatMessage.getSpeaker(),i.whisper=ChatMessage.getWhisperRecipients(a)),o&&(i.speaker=ChatMessage.getSpeaker(),i.whisper=o),i}},{key:"getSpeaker",value:function getSpeaker(t){var r=ChatMessage.getSpeakerActor(t);if(!r&&canvas.tokens){var a=canvas.tokens.get(t.token);a&&(r=a.actor)}if(!r){var o=game.scenes.get(t.scene);try{var i;o&&(r=null===(i=new Token(o.getEmbeddedDocument("Token",t.token)))||void 0===i?void 0:i.actor)}catch(t){}}return r}},{key:"fateAvailable",value:function fateAvailable(t,r){return r?game.settings.get("dsa5","groupschips").split("/").map((function(t){return Number(t)}))[0]>0:t.system.status.fatePoints.value>0}},{key:"_calculateAdvCost",value:function _calculateAdvCost(t,r){var a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1;return c.Z.advancementCosts[r][Number(t)+a]}},{key:"getFolderForType",value:(u=_asyncToGenerator(_regeneratorRuntime().mark((function _callee10(t){var r,a,o,i,c,u,l=arguments;return _regeneratorRuntime().wrap((function _callee10$(p){for(;;)switch(p.prev=p.next){case 0:return r=l.length>1&&void 0!==l[1]?l[1]:null,a=l.length>2&&void 0!==l[2]?l[2]:null,o=l.length>3&&void 0!==l[3]?l[3]:0,i=l.length>4&&void 0!==l[4]?l[4]:"",c=l.length>5&&void 0!==l[5]?l[5]:void 0,p.next=7,game.folders.contents.find((function(o){var i;return o.name==a&&o.type==t&&(null===(i=o.folder)||void 0===i?void 0:i.id)==r}));case 7:if(u=p.sent){p.next=12;break}return p.next=11,Folder.create({name:a,type:t,sorting:c||("JournalEntry"==t?"a":"m"),color:i,sort:o,parent:r});case 11:u=p.sent;case 12:return p.abrupt("return",u);case 13:case"end":return p.stop()}}),_callee10)}))),function getFolderForType(t){return u.apply(this,arguments)})},{key:"toObjectIfPossible",value:function toObjectIfPossible(t){return"function"==typeof t.toObject?t.toObject(!1):duplicate(t)}},{key:"showArtwork",value:(a=_asyncToGenerator(_regeneratorRuntime().mark((function _callee11(t){var r,a,o,i,c,u=arguments;return _regeneratorRuntime().wrap((function _callee11$(l){for(;;)switch(l.prev=l.next){case 0:return r=t.img,a=t.name,o=t.uuid,i=t.isOwner,c=u.length>1&&void 0!==u[1]&&u[1],l.abrupt("return",new ImagePopout(r,{title:c?i?a:"-":a,shareable:!0,uuid:o}).render(!0));case 3:case"end":return l.stop()}}),_callee11)}))),function showArtwork(t){return a.apply(this,arguments)})},{key:"findAnyItem",value:(r=_asyncToGenerator(_regeneratorRuntime().mark((function _callee12(t){var r,a,o,i,c,u,l,p,d,h,m,y,g;return _regeneratorRuntime().wrap((function _callee12$(v){for(;;)switch(v.prev=v.next){case 0:r=[],a=t.map((function(t){return t.name})),o=t.map((function(t){return t.type})),i=_createForOfIteratorHelper(game.items.contents),v.prev=4,i.s();case 6:if((c=i.n()).done){v.next=14;break}if(u=c.value,(l=a.indexOf(u.name))>=0&&o[l]==u.type&&(a.splice(l,1),o.splice(l,1),r.push(u.toObject())),!(a.length<=0)){v.next=12;break}return v.abrupt("break",14);case 12:v.next=6;break;case 14:v.next=19;break;case 16:v.prev=16,v.t0=v.catch(4),i.e(v.t0);case 19:return v.prev=19,i.f(),v.finish(19);case 22:if(!(a.length>0)){v.next=46;break}p=/^dsa5-core/,d=Array.from(game.packs.keys()).sort((function(t,r){return p.test(t)&&p.test(r)&&t.localeCompare(r),p.test(r)?-1:p.test(t)?1:t.localeCompare(r)})),h=_createForOfIteratorHelper(d),v.prev=26,h.s();case 28:if((m=h.n()).done){v.next=38;break}if(y=m.value,"Item"!=(g=game.packs.get(y)).documentName||!game.user.isGM&&g.private){v.next=36;break}return v.next=34,g.getDocuments({name__in:a,type__in:o}).then((function(t){var i,c=_createForOfIteratorHelper(t);try{for(c.s();!(i=c.n()).done;){var u=i.value,l=a.indexOf(u.name);l>=0&&o[l]==u.type&&(a.splice(l,1),o.splice(l,1),r.push(u.toObject()))}}catch(t){c.e(t)}finally{c.f()}}));case 34:if(!(a.length<=0)){v.next=36;break}return v.abrupt("break",38);case 36:v.next=28;break;case 38:v.next=43;break;case 40:v.prev=40,v.t1=v.catch(26),h.e(v.t1);case 43:return v.prev=43,h.f(),v.finish(43);case 46:return v.abrupt("return",r);case 47:case"end":return v.stop()}}),_callee12,null,[[4,16,19,22],[26,40,43,46]])}))),function findAnyItem(t){return r.apply(this,arguments)})},{key:"replaceDies",value:function replaceDies(t){var r=arguments.length>1&&void 0!==arguments[1]&&arguments[1],a=/( |^)(\d{1,2})?[wWdD][0-9]+((\+|-)[0-9]+)?/g,o=r?"":"/r ";return t.replace(a,(function(t){return" [[".concat(o).concat(t.replace(/[DwW]/,"d"),"]]")}))}},{key:"escapeRegex",value:function escapeRegex(t){return("string"==typeof t||t instanceof String?t:"").replace(/[-[/\]{}()*+?.,\\^$|#\s]/g,"\\$&")}},{key:"replaceConditions",value:function replaceConditions(t){return t?t.replace(c.Z.statusRegex.regex,(function(t){return(0,i.q)([t])})):t}},{key:"experienceDescription",value:function experienceDescription(t){for(var r=["EXP.legendary","EXP.brillant","EXP.masterful","EXP.competent","EXP.experienced","EXP.average"],a=0,o=0,i=[2100,1700,1400,1200,1100,1e3];o=Number(c))return r[a];a++}return"EXP.inexperienced"}},{key:"emptyActor",value:(t=_asyncToGenerator(_regeneratorRuntime().mark((function _callee13(){var t,r,a,i=arguments;return _regeneratorRuntime().wrap((function _callee13$(c){for(;;)switch(c.prev=c.next){case 0:return t=i.length>0&&void 0!==i[0]?i[0]:12,r=i.length>1&&void 0!==i[1]?i[1]:"Alrik",Array.isArray(t)||(t=[t,t,t,t,t,t,t,t]),c.next=5,o.Z.create({name:r,type:"npc",items:[],system:{status:{wounds:{value:50},fatePoints:{}},characteristics:{mu:{initial:t[0]},kl:{initial:t[1]},in:{initial:t[2]},ch:{initial:t[3]},ff:{initial:t[4]},ge:{initial:t[5]},ko:{initial:t[6]},kk:{initial:t[7]}}}},{temporary:!0,noHook:!0});case 5:return(a=c.sent).prepareData(),c.abrupt("return",a);case 8:case"end":return c.stop()}}),_callee13)}))),function emptyActor(){return t.apply(this,arguments)})}]),DSA5_Utility}()},707:(t,r,a)=>{function _typeof(t){return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},_typeof(t)}function _regeneratorRuntime(){_regeneratorRuntime=function _regeneratorRuntime(){return t};var t={},r=Object.prototype,a=r.hasOwnProperty,o="function"==typeof Symbol?Symbol:{},i=o.iterator||"@@iterator",c=o.asyncIterator||"@@asyncIterator",u=o.toStringTag||"@@toStringTag";function define(t,r,a){return Object.defineProperty(t,r,{value:a,enumerable:!0,configurable:!0,writable:!0}),t[r]}try{define({},"")}catch(t){define=function define(t,r,a){return t[r]=a}}function wrap(t,r,a,o){var i=r&&r.prototype instanceof Generator?r:Generator,c=Object.create(i.prototype),u=new Context(o||[]);return c._invoke=function(t,r,a){var o="suspendedStart";return function(i,c){if("executing"===o)throw new Error("Generator is already running");if("completed"===o){if("throw"===i)throw c;return doneResult()}for(a.method=i,a.arg=c;;){var u=a.delegate;if(u){var p=maybeInvokeDelegate(u,a);if(p){if(p===l)continue;return p}}if("next"===a.method)a.sent=a._sent=a.arg;else if("throw"===a.method){if("suspendedStart"===o)throw o="completed",a.arg;a.dispatchException(a.arg)}else"return"===a.method&&a.abrupt("return",a.arg);o="executing";var d=tryCatch(t,r,a);if("normal"===d.type){if(o=a.done?"completed":"suspendedYield",d.arg===l)continue;return{value:d.arg,done:a.done}}"throw"===d.type&&(o="completed",a.method="throw",a.arg=d.arg)}}}(t,a,u),c}function tryCatch(t,r,a){try{return{type:"normal",arg:t.call(r,a)}}catch(t){return{type:"throw",arg:t}}}t.wrap=wrap;var l={};function Generator(){}function GeneratorFunction(){}function GeneratorFunctionPrototype(){}var p={};define(p,i,(function(){return this}));var d=Object.getPrototypeOf,h=d&&d(d(values([])));h&&h!==r&&a.call(h,i)&&(p=h);var m=GeneratorFunctionPrototype.prototype=Generator.prototype=Object.create(p);function defineIteratorMethods(t){["next","throw","return"].forEach((function(r){define(t,r,(function(t){return this._invoke(r,t)}))}))}function AsyncIterator(t,r){function invoke(o,i,c,u){var l=tryCatch(t[o],t,i);if("throw"!==l.type){var p=l.arg,d=p.value;return d&&"object"==_typeof(d)&&a.call(d,"__await")?r.resolve(d.__await).then((function(t){invoke("next",t,c,u)}),(function(t){invoke("throw",t,c,u)})):r.resolve(d).then((function(t){p.value=t,c(p)}),(function(t){return invoke("throw",t,c,u)}))}u(l.arg)}var o;this._invoke=function(t,a){function callInvokeWithMethodAndArg(){return new r((function(r,o){invoke(t,a,r,o)}))}return o=o?o.then(callInvokeWithMethodAndArg,callInvokeWithMethodAndArg):callInvokeWithMethodAndArg()}}function maybeInvokeDelegate(t,r){var a=t.iterator[r.method];if(void 0===a){if(r.delegate=null,"throw"===r.method){if(t.iterator.return&&(r.method="return",r.arg=void 0,maybeInvokeDelegate(t,r),"throw"===r.method))return l;r.method="throw",r.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var o=tryCatch(a,t.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,l;var i=o.arg;return i?i.done?(r[t.resultName]=i.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=void 0),r.delegate=null,l):i:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,l)}function pushTryEntry(t){var r={tryLoc:t[0]};1 in t&&(r.catchLoc=t[1]),2 in t&&(r.finallyLoc=t[2],r.afterLoc=t[3]),this.tryEntries.push(r)}function resetTryEntry(t){var r=t.completion||{};r.type="normal",delete r.arg,t.completion=r}function Context(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(pushTryEntry,this),this.reset(!0)}function values(t){if(t){var r=t[i];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var o=-1,c=function next(){for(;++o=0;--o){var i=this.tryEntries[o],c=i.completion;if("root"===i.tryLoc)return handle("end");if(i.tryLoc<=this.prev){var u=a.call(i,"catchLoc"),l=a.call(i,"finallyLoc");if(u&&l){if(this.prev=0;--o){var i=this.tryEntries[o];if(i.tryLoc<=this.prev&&a.call(i,"finallyLoc")&&this.prev=0;--r){var a=this.tryEntries[r];if(a.finallyLoc===t)return this.complete(a.completion,a.afterLoc),resetTryEntry(a),l}},catch:function _catch(t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc===t){var o=a.completion;if("throw"===o.type){var i=o.arg;resetTryEntry(a)}return i}}throw new Error("illegal catch attempt")},delegateYield:function delegateYield(t,r,a){return this.delegate={iterator:values(t),resultName:r,nextLoc:a},"next"===this.method&&(this.arg=void 0),l}},t}function _createForOfIteratorHelper(t,r){var a="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!a){if(Array.isArray(t)||(a=function _unsupportedIterableToArray(t,r){if(!t)return;if("string"==typeof t)return _arrayLikeToArray(t,r);var a=Object.prototype.toString.call(t).slice(8,-1);"Object"===a&&t.constructor&&(a=t.constructor.name);if("Map"===a||"Set"===a)return Array.from(t);if("Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a))return _arrayLikeToArray(t,r)}(t))||r&&t&&"number"==typeof t.length){a&&(t=a);var o=0,i=function F(){};return{s:i,n:function n(){return o>=t.length?{done:!0}:{done:!1,value:t[o++]}},e:function e(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var c,u=!0,l=!1;return{s:function s(){a=a.call(t)},n:function n(){var t=a.next();return u=t.done,t},e:function e(t){l=!0,c=t},f:function f(){try{u||null==a.return||a.return()}finally{if(l)throw c}}}}function _arrayLikeToArray(t,r){(null==r||r>t.length)&&(r=t.length);for(var a=0,o=new Array(r);a1&&void 0!==arguments[1]?arguments[1]:320,a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:40;t.attr({width:.8*r,viewBox:"0 0 ".concat(r," ").concat(a)});var o=t.find("text"),i=o.get(0).getBBox(),c=r/i.width,u=a/i.height,l=c2&&void 0!==p[2])||p[2],"Actor"!=t.type){d.next=8;break}return d.next=4,Actor.implementation.fromDropData(t);case 4:i=d.sent,c=r===i.id,d.next=12;break;case 8:return d.next=10,Item.implementation.fromDropData(t);case 10:i=d.sent,c=r===(null===(u=i.parent)||void 0===u?void 0:u.uuid);case 12:return l=null===(a=i)||void 0===a?void 0:a.type,o&&(i=i.toObject()),t.amount&&(i.system.quantity.value=Number(t.amount)),d.abrupt("return",{item:i,typeClass:l,selfTarget:c});case 16:case"end":return d.stop()}}),_callee2)}))),_itemFromDrop.apply(this,arguments)}function slist(t,r,a){var o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"div";if(r=t.find(r)[0]){r.classList.add("slist");var i,c=r.querySelectorAll(o),u=null,l=_createForOfIteratorHelper(c);try{for(l.s();!(i=l.n()).done;){var p=i.value;p.draggable=!0,p.addEventListener("dragstart",(function(t){u=this})),p.addEventListener("dragover",(function(t){t.preventDefault()})),p.addEventListener("drop",function(){var t=_asyncToGenerator(_regeneratorRuntime().mark((function _callee(t){var o,i,l;return _regeneratorRuntime().wrap((function _callee$(p){for(;;)switch(p.prev=p.next){case 0:if(t.preventDefault(),this==u){p.next=7;break}for(o=0,i=0,l=0;l'),r=$(".tinyNotifications"));var a=$("
  • ".concat(t,"
  • "));r.prepend(a),setTimeout((function(){a.remove()}),1500)}function IconVisibility(t,r,a,o){var i=Math.ceil(r.scrollLeft),c=r.scrollWidth-r.clientWidth;a.style.display=i>0?"block":"none",o.style.display=c>i?"block":"none",function columnLayout(t){var r=t.width(),a=Number(getComputedStyle(document.body).getPropertyValue("--minColumnWidth").replace("px","")),o=Number(getComputedStyle(document.body).getPropertyValue("--minColumnWidth60").replace("px",""));r>=2*a+6?t.removeClass("singleColumnLayout"):t.addClass("singleColumnLayout");r<=o?t.addClass("minimumColumnLayout"):t.removeClass("minimumColumnLayout")}(t)}function clickableAbility(t){return _clickableAbility.apply(this,arguments)}function _clickableAbility(){return(_clickableAbility=_asyncToGenerator(_regeneratorRuntime().mark((function _callee3(t){var r,a,o,i,c,u,l,p,d,h,m,y;return _regeneratorRuntime().wrap((function _callee3$(g){for(;;)switch(g.prev=g.next){case 0:r=$(t.currentTarget).closest(".searchableAbility")[0].dataset.category.split(" "),a=t.currentTarget.text.replace(/\d+$/,"").trim(),o=_createForOfIteratorHelper(r),g.prev=3,o.s();case 5:if((i=o.n()).done){g.next=16;break}return c=i.value,g.next=9,game.dsa5.itemLibrary.findCompendiumItem(a,c);case 9:if(u=g.sent,!(l=u.find((function(t){return t.name==a})))){g.next=14;break}return l.sheet.render(!0),g.abrupt("return");case 14:g.next=5;break;case 16:g.next=21;break;case 18:g.prev=18,g.t0=g.catch(3),o.e(g.t0);case 21:return g.prev=21,o.f(),g.finish(21);case 24:if(!/\(/.test(a)){g.next=48;break}a=a.split("(")[0].trim()+" ()",p=_createForOfIteratorHelper(r),g.prev=27,p.s();case 29:if((d=p.n()).done){g.next=40;break}return h=d.value,g.next=33,game.dsa5.itemLibrary.findCompendiumItem(a,h);case 33:if(m=g.sent,!(y=m.find((function(t){return t.name==a})))){g.next=38;break}return y.sheet.render(!0),g.abrupt("return");case 38:g.next=29;break;case 40:g.next=45;break;case 42:g.prev=42,g.t1=g.catch(27),p.e(g.t1);case 45:return g.prev=45,p.f(),g.finish(45);case 48:case"end":return g.stop()}}),_callee3,null,[[3,18,21,24],[27,42,45,48]])})))).apply(this,arguments)}function tabSlider(t){var r,a=_createForOfIteratorHelper(t.find(".navWrapper"));try{var o=function _loop(){var a=r.value,o=a.querySelector(".left-btn"),i=a.querySelector(".right-btn"),c=a.querySelector(".sheet-tabs"),u=!1;i.addEventListener("click",(function(){c.scrollLeft+=150,setTimeout((function(){return IconVisibility(t,c,o,i)}),500)})),o.addEventListener("click",(function(){c.scrollLeft-=150,setTimeout((function(){return IconVisibility(t,c,o,i)}),500)})),new ResizeObserver((function(){return IconVisibility(t,c,o,i)})).observe(a),c.addEventListener("mousemove",(function(r){u&&(c.scrollLeft-=r.movementX,setTimeout((function(){return IconVisibility(t,c,o,i)}),500))})),c.addEventListener("mousedown",(function(){u=!0,c.classList.add("dragging"),document.addEventListener("mouseup",(function(){u=!1,c.classList.remove("dragging")}),{once:!0})}))};for(a.s();!(r=a.n()).done;)o()}catch(t){a.e(t)}finally{a.f()}}a.d(r,{$8:()=>clickableAbility,Ee:()=>tabSlider,Jp:()=>slist,gw:()=>delay,p0:()=>tinyNotification,x8:()=>itemFromDrop,zJ:()=>svgAutoFit});var o=function appHeight(){document.documentElement.style.setProperty("--app-height","".concat(window.innerHeight,"px"))};window.addEventListener("resize",o),o()},430:(t,r,a)=>{a.d(r,{Z:()=>u});var o=a(577),i=a(604),c=a(491);function _typeof(t){return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},_typeof(t)}function _regeneratorRuntime(){_regeneratorRuntime=function _regeneratorRuntime(){return t};var t={},r=Object.prototype,a=r.hasOwnProperty,o="function"==typeof Symbol?Symbol:{},i=o.iterator||"@@iterator",c=o.asyncIterator||"@@asyncIterator",u=o.toStringTag||"@@toStringTag";function define(t,r,a){return Object.defineProperty(t,r,{value:a,enumerable:!0,configurable:!0,writable:!0}),t[r]}try{define({},"")}catch(t){define=function define(t,r,a){return t[r]=a}}function wrap(t,r,a,o){var i=r&&r.prototype instanceof Generator?r:Generator,c=Object.create(i.prototype),u=new Context(o||[]);return c._invoke=function(t,r,a){var o="suspendedStart";return function(i,c){if("executing"===o)throw new Error("Generator is already running");if("completed"===o){if("throw"===i)throw c;return doneResult()}for(a.method=i,a.arg=c;;){var u=a.delegate;if(u){var p=maybeInvokeDelegate(u,a);if(p){if(p===l)continue;return p}}if("next"===a.method)a.sent=a._sent=a.arg;else if("throw"===a.method){if("suspendedStart"===o)throw o="completed",a.arg;a.dispatchException(a.arg)}else"return"===a.method&&a.abrupt("return",a.arg);o="executing";var d=tryCatch(t,r,a);if("normal"===d.type){if(o=a.done?"completed":"suspendedYield",d.arg===l)continue;return{value:d.arg,done:a.done}}"throw"===d.type&&(o="completed",a.method="throw",a.arg=d.arg)}}}(t,a,u),c}function tryCatch(t,r,a){try{return{type:"normal",arg:t.call(r,a)}}catch(t){return{type:"throw",arg:t}}}t.wrap=wrap;var l={};function Generator(){}function GeneratorFunction(){}function GeneratorFunctionPrototype(){}var p={};define(p,i,(function(){return this}));var d=Object.getPrototypeOf,h=d&&d(d(values([])));h&&h!==r&&a.call(h,i)&&(p=h);var m=GeneratorFunctionPrototype.prototype=Generator.prototype=Object.create(p);function defineIteratorMethods(t){["next","throw","return"].forEach((function(r){define(t,r,(function(t){return this._invoke(r,t)}))}))}function AsyncIterator(t,r){function invoke(o,i,c,u){var l=tryCatch(t[o],t,i);if("throw"!==l.type){var p=l.arg,d=p.value;return d&&"object"==_typeof(d)&&a.call(d,"__await")?r.resolve(d.__await).then((function(t){invoke("next",t,c,u)}),(function(t){invoke("throw",t,c,u)})):r.resolve(d).then((function(t){p.value=t,c(p)}),(function(t){return invoke("throw",t,c,u)}))}u(l.arg)}var o;this._invoke=function(t,a){function callInvokeWithMethodAndArg(){return new r((function(r,o){invoke(t,a,r,o)}))}return o=o?o.then(callInvokeWithMethodAndArg,callInvokeWithMethodAndArg):callInvokeWithMethodAndArg()}}function maybeInvokeDelegate(t,r){var a=t.iterator[r.method];if(void 0===a){if(r.delegate=null,"throw"===r.method){if(t.iterator.return&&(r.method="return",r.arg=void 0,maybeInvokeDelegate(t,r),"throw"===r.method))return l;r.method="throw",r.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var o=tryCatch(a,t.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,l;var i=o.arg;return i?i.done?(r[t.resultName]=i.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=void 0),r.delegate=null,l):i:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,l)}function pushTryEntry(t){var r={tryLoc:t[0]};1 in t&&(r.catchLoc=t[1]),2 in t&&(r.finallyLoc=t[2],r.afterLoc=t[3]),this.tryEntries.push(r)}function resetTryEntry(t){var r=t.completion||{};r.type="normal",delete r.arg,t.completion=r}function Context(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(pushTryEntry,this),this.reset(!0)}function values(t){if(t){var r=t[i];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var o=-1,c=function next(){for(;++o=0;--o){var i=this.tryEntries[o],c=i.completion;if("root"===i.tryLoc)return handle("end");if(i.tryLoc<=this.prev){var u=a.call(i,"catchLoc"),l=a.call(i,"finallyLoc");if(u&&l){if(this.prev=0;--o){var i=this.tryEntries[o];if(i.tryLoc<=this.prev&&a.call(i,"finallyLoc")&&this.prev=0;--r){var a=this.tryEntries[r];if(a.finallyLoc===t)return this.complete(a.completion,a.afterLoc),resetTryEntry(a),l}},catch:function _catch(t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc===t){var o=a.completion;if("throw"===o.type){var i=o.arg;resetTryEntry(a)}return i}}throw new Error("illegal catch attempt")},delegateYield:function delegateYield(t,r,a){return this.delegate={iterator:values(t),resultName:r,nextLoc:a},"next"===this.method&&(this.arg=void 0),l}},t}function _createForOfIteratorHelper(t,r){var a="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!a){if(Array.isArray(t)||(a=function _unsupportedIterableToArray(t,r){if(!t)return;if("string"==typeof t)return _arrayLikeToArray(t,r);var a=Object.prototype.toString.call(t).slice(8,-1);"Object"===a&&t.constructor&&(a=t.constructor.name);if("Map"===a||"Set"===a)return Array.from(t);if("Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a))return _arrayLikeToArray(t,r)}(t))||r&&t&&"number"==typeof t.length){a&&(t=a);var o=0,i=function F(){};return{s:i,n:function n(){return o>=t.length?{done:!0}:{done:!1,value:t[o++]}},e:function e(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var c,u=!0,l=!1;return{s:function s(){a=a.call(t)},n:function n(){var t=a.next();return u=t.done,t},e:function e(t){l=!0,c=t},f:function f(){try{u||null==a.return||a.return()}finally{if(l)throw c}}}}function _arrayLikeToArray(t,r){(null==r||r>t.length)&&(r=t.length);for(var a=0,o=new Array(r);a1&&void 0!==v[1]?v[1]:{}).speaker={token:t.token,actor:t.actor,scene:t.scene},r.source=t.source,a=o.Z.systemTables.find((function(r){return r.name==t.table})),_.next=6,DSATables.getRollTable(a.pack[game.i18n.lang],game.i18n.localize("TABLENAMES.".concat(t.table)),t);case 6:i=_.sent,u=_createForOfIteratorHelper(i),_.prev=8,u.s();case 10:if((l=u.n()).done){_.next=31;break}if(p=l.value,!r.speaker){_.next=18;break}return _.next=15,DSATables.hasEffect(p);case 15:_.t0=_.sent,_.next=19;break;case 18:_.t0=!1;case 19:return d=_.t0,h=c.Z.replaceDies(c.Z.replaceConditions(p.results[0].text)),m="".concat(game.i18n.localize("TABLENAMES."+t.table)),_.next=24,renderTemplate("systems/dsa5/templates/tables/tableCard.html",{result:h,title:m,hasEffect:d});case 24:return y=_.sent,_.next=27,this.buildEffects(p,d);case 27:g=_.sent,ChatMessage.create({user:game.user.id,content:y,whisper:r.whisper,blind:r.blind,flags:{data:{preData:{source:{effects:g},extra:{actor:{id:r.speaker.actor},speaker:r.speaker},situationalModifiers:[]},postData:{}},dsa5:{hasEffect:d,options:r}}});case 29:_.next=10;break;case 31:_.next=36;break;case 33:_.prev=33,_.t1=_.catch(8),u.e(_.t1);case 36:return _.prev=36,u.f(),_.finish(36);case 39:case"end":return _.stop()}}),_callee,this,[[8,33,36,39]])}))),function showBotchCard(t){return p.apply(this,arguments)})},{key:"hasEffect",value:(l=_asyncToGenerator(_regeneratorRuntime().mark((function _callee2(t){return _regeneratorRuntime().wrap((function _callee2$(r){for(;;)switch(r.prev=r.next){case 0:return r.abrupt("return",getProperty(t.results[0],"flags.dsa5")||!1);case 1:case"end":return r.stop()}}),_callee2)}))),function hasEffect(t){return l.apply(this,arguments)})},{key:"buildEffects",value:(u=_asyncToGenerator(_regeneratorRuntime().mark((function _callee3(t,r){var a,o,c,u,l,p;return _regeneratorRuntime().wrap((function _callee3$(t){for(;;)switch(t.prev=t.next){case 0:if(a=[],r&&r.resistEffect){o=Array.isArray(r.resistEffect.fail)?r.resistEffect.fail:[r.resistEffect.fail],c=_createForOfIteratorHelper(o);try{for(c.s();!(u=c.n()).done;)l=u.value,p=(new i.Z).effectDummy(l.description,r.resistEffect.changes||[],r.resistEffect.duration||{}),l.systemEffect?mergeObject(p,{_id:"botchEffect",flags:{dsa5:{hideOnToken:!1,hidePlayers:!1,advancedFunction:2,args3:'await actor.addCondition("'.concat(l.systemEffect,'", ').concat(l.level||1,");")}}}):l.command&&mergeObject(p,{_id:"botchEffect",flags:{dsa5:{hideOnToken:!1,hidePlayers:!1,advancedFunction:2,args3:l.command}}}),a.push(p)}catch(t){c.e(t)}finally{c.f()}}return t.abrupt("return",a);case 3:case"end":return t.stop()}}),_callee3)}))),function buildEffects(t,r){return u.apply(this,arguments)})},{key:"getRollTable",value:(a=_asyncToGenerator(_regeneratorRuntime().mark((function _callee4(t,r){var a,o,i,c,u=arguments;return _regeneratorRuntime().wrap((function _callee4$(l){for(;;)switch(l.prev=l.next){case 0:return a=u.length>2&&void 0!==u[2]?u[2]:{},o=game.packs.get(t),l.next=4,o.getDocuments({name__in:[r]});case 4:return i=l.sent[0],l.next=7,i.draw({displayChat:!1});case 7:if(c=l.sent,!("true"==a.weaponless&&c.roll.total<7)){l.next=13;break}return c.roll.editRollAtIndex([{index:0,val:c.roll.total+5}]),l.next=12,i.draw({displayChat:!1,roll:c.roll});case 12:c=l.sent;case 13:return l.abrupt("return",[c]);case 14:case"end":return l.stop()}}),_callee4)}))),function getRollTable(t,r){return a.apply(this,arguments)})},{key:"tableEnabledFor",value:(r=_asyncToGenerator(_regeneratorRuntime().mark((function _callee5(t){var r;return _regeneratorRuntime().wrap((function _callee5$(a){for(;;)switch(a.prev=a.next){case 0:return r=o.Z.systemTables.find((function(r){return r.name==t})),a.abrupt("return",!!r&&game.settings.get(r.setting.module,r.setting.key));case 2:case"end":return a.stop()}}),_callee5)}))),function tableEnabledFor(t){return r.apply(this,arguments)})},{key:"rollCritBotchButton",value:function rollCritBotchButton(t,r,a){var o=game.i18n.localize("TABLENAMES.".concat(t)),i=a.extra.speaker,c=a.source._id;return', ').concat(o,"")}},{key:"defaultBotch",value:(t=_asyncToGenerator(_regeneratorRuntime().mark((function _callee6(){return _regeneratorRuntime().wrap((function _callee6$(t){for(;;)switch(t.prev=t.next){case 0:return t.t0=", "+game.i18n.localize("selfDamage"),t.next=3,new Roll("1d6+2").evaluate({async:!0});case 3:return t.t1=t.sent.total,t.abrupt("return",t.t0+t.t1);case 5:case"end":return t.stop()}}),_callee6)}))),function defaultBotch(){return t.apply(this,arguments)})},{key:"defaultAttackCrit",value:function defaultAttackCrit(t){var r=", "+game.i18n.localize("halfDefense");return t&&(r+=", "+game.i18n.format("doubleDamage",{x:2})),r}},{key:"defaultParryCrit",value:function defaultParryCrit(){return", "+game.i18n.localize("attackOfOpportunity")}}]),DSATables}()},585:(t,r,a)=>{a.d(r,{Z:()=>d});var o=a(369),i=a(61),c=a(472),u=a(702),l=a(491),p=a(604);function _typeof(t){return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},_typeof(t)}function _createForOfIteratorHelper(t,r){var a="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!a){if(Array.isArray(t)||(a=function _unsupportedIterableToArray(t,r){if(!t)return;if("string"==typeof t)return _arrayLikeToArray(t,r);var a=Object.prototype.toString.call(t).slice(8,-1);"Object"===a&&t.constructor&&(a=t.constructor.name);if("Map"===a||"Set"===a)return Array.from(t);if("Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a))return _arrayLikeToArray(t,r)}(t))||r&&t&&"number"==typeof t.length){a&&(t=a);var o=0,i=function F(){};return{s:i,n:function n(){return o>=t.length?{done:!0}:{done:!1,value:t[o++]}},e:function e(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var c,u=!0,l=!1;return{s:function s(){a=a.call(t)},n:function n(){var t=a.next();return u=t.done,t},e:function e(t){l=!0,c=t},f:function f(){try{u||null==a.return||a.return()}finally{if(l)throw c}}}}function _arrayLikeToArray(t,r){(null==r||r>t.length)&&(r=t.length);for(var a=0,o=new Array(r);a=0;--o){var i=this.tryEntries[o],c=i.completion;if("root"===i.tryLoc)return handle("end");if(i.tryLoc<=this.prev){var u=a.call(i,"catchLoc"),l=a.call(i,"finallyLoc");if(u&&l){if(this.prev=0;--o){var i=this.tryEntries[o];if(i.tryLoc<=this.prev&&a.call(i,"finallyLoc")&&this.prev=0;--r){var a=this.tryEntries[r];if(a.finallyLoc===t)return this.complete(a.completion,a.afterLoc),resetTryEntry(a),l}},catch:function _catch(t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc===t){var o=a.completion;if("throw"===o.type){var i=o.arg;resetTryEntry(a)}return i}}throw new Error("illegal catch attempt")},delegateYield:function delegateYield(t,r,a){return this.delegate={iterator:values(t),resultName:r,nextLoc:a},"next"===this.method&&(this.arg=void 0),l}},t}function asyncGeneratorStep(t,r,a,o,i,c,u){try{var l=t[c](u),p=l.value}catch(t){return void a(t)}l.done?r(p):Promise.resolve(p).then(o,i)}function _asyncToGenerator(t){return function(){var r=this,a=arguments;return new Promise((function(o,i){var c=t.apply(r,a);function _next(t){asyncGeneratorStep(c,o,i,_next,_throw,"next",t)}function _throw(t){asyncGeneratorStep(c,o,i,_next,_throw,"throw",t)}_next(void 0)}))}}function _defineProperties(t,r){for(var a=0;a/,'hideAnchor">'))});case 23:case"end":return _.stop()}}),_callee)}))),function applyEffect(t,r){return _.apply(this,arguments)})},{key:"damageModifier",value:(v=_asyncToGenerator(_regeneratorRuntime().mark((function _callee2(t,r,a,o){return _regeneratorRuntime().wrap((function _callee2$(t){for(;;)switch(t.prev=t.next){case 0:case"end":return t.stop()}}),_callee2)}))),function damageModifier(t,r,a,o){return v.apply(this,arguments)})},{key:"nextAction",value:(g=_asyncToGenerator(_regeneratorRuntime().mark((function _callee3(t,r,a,o){return _regeneratorRuntime().wrap((function _callee3$(t){for(;;)switch(t.prev=t.next){case 0:case"end":return t.stop()}}),_callee3)}))),function nextAction(t,r,a,o){return g.apply(this,arguments)})},{key:"opportunityAttack",value:(y=_asyncToGenerator(_regeneratorRuntime().mark((function _callee4(t,r,a,o){return _regeneratorRuntime().wrap((function _callee4$(t){for(;;)switch(t.prev=t.next){case 0:case"end":return t.stop()}}),_callee4)}))),function opportunityAttack(t,r,a,o){return y.apply(this,arguments)})},{key:"gearDamaged",value:(m=_asyncToGenerator(_regeneratorRuntime().mark((function _callee5(t,r,a,o){var i;return _regeneratorRuntime().wrap((function _callee5$(r){for(;;)switch(r.prev=r.next){case 0:if(!o||!["meleeweapon","rangeweapon"].includes(o.type)){r.next=12;break}if(i=getProperty(o,"system.effect.attributes")||"",!new RegExp("(".concat(c.Z.magical,"|").concat(c.Z.clerical,")"),"i").test(i)){r.next=9;break}return r.next=7,o.update({"system.worn.value":!1});case 7:r.next=11;break;case 9:return r.next=11,u.Z.absoluteDamageLevelToItem(o,t);case 11:return r.abrupt("return",!0);case 12:case"end":return r.stop()}}),_callee5)}))),function gearDamaged(t,r,a,o){return m.apply(this,arguments)})},{key:"gearLost",value:(h=_asyncToGenerator(_regeneratorRuntime().mark((function _callee6(t,r,a,o){var i,c,u;return _regeneratorRuntime().wrap((function _callee6$(r){for(;;)switch(r.prev=r.next){case 0:if(!o||!["meleeweapon","rangeweapon"].includes(o.type)){r.next=13;break}return r.next=3,o.update({"system.worn.value":!1});case 3:if(!t.distance){r.next=12;break}return r.next=6,new Roll(t.distance).evaluate({async:!0});case 6:return i=r.sent,r.next=9,i.render();case 9:c=r.sent,u=game.i18n.format("WEAPON.dropped",{distance:i.total}),ChatMessage.create(l.Z.chatDataSetup("

    ".concat(u,"

    ").concat(c)));case 12:return r.abrupt("return",!0);case 13:case"end":return r.stop()}}),_callee6)}))),function gearLost(t,r,a,o){return h.apply(this,arguments)})},{key:"resistEffect",value:(d=_asyncToGenerator(_regeneratorRuntime().mark((function _callee7(t,r,a,o,c){var u,l,p,d;return _regeneratorRuntime().wrap((function _callee7$(o){for(;;)switch(o.prev=o.next){case 0:u=_createForOfIteratorHelper(a);try{for(u.s();!(l=u.n()).done;)p=l.value,d=[{skill:t.roll,mod:t.modifier||0,effect:{_id:"botchEffect",name:t.fail.description},target:p,token:p.token?p.token.id:void 0}],i.Z.createResistRollMessage(d,c,r)}catch(t){u.e(t)}finally{u.f()}return o.abrupt("return",!0);case 3:case"end":return o.stop()}}),_callee7)}))),function resistEffect(t,r,a,o,i){return d.apply(this,arguments)})},{key:"evaluateTargetArg",value:function evaluateTargetArg(t,r){var a=r,o=!0;if("victim"==t.target){var i=Array.from(game.user.targets).map((function(t){return t.actor}));i.length?a=i:(o=!1,ui.notifications.warn("DSAError.noVictim"))}return{hasTargets:o,finalTargets:a}}},{key:"malus",value:(a=_asyncToGenerator(_regeneratorRuntime().mark((function _callee8(t,r,a,o){var i,c,u,l,d,h,m;return _regeneratorRuntime().wrap((function _callee8$(r){for(;;)switch(r.prev=r.next){case 0:i=this.evaluateTargetArg(t,a),c=i.hasTargets,u=i.finalTargets,l=_createForOfIteratorHelper(t),r.prev=2,h=_regeneratorRuntime().mark((function _loop(){var t,r,a,o,i,l,h,m,y,g,v,_,b,k,w,x,S;return _regeneratorRuntime().wrap((function _loop$(T){for(;;)switch(T.prev=T.next){case 0:if(t=d.value,r=!c&&t.noTarget,a=r?t.noTarget.systemEffect:t.systemEffect,o=r?t.noTarget.level:t.level||1,i=r?t.noTarget.changes:t.changes,l=r?t.noTarget.duration:t.duration,!a){T.next=30;break}h=CONFIG.statusEffects.find((function(t){return t.id==a})),i||(i=duplicate(h.changes),(m=i.find((function(t){return t.key=="system.condition.".concat(a)})))&&(m.value=o)),i?(g=game.i18n.localize("CONDITION.".concat(a))+" - "+game.i18n.localize("botchCritEffect"),(y=(new p.Z).effectDummy(g,i,l||{})).icon=h.icon):y=a,v=_createForOfIteratorHelper(u),T.prev=11,v.s();case 13:if((_=v.n()).done){T.next=19;break}return b=_.value,T.next=17,b.addCondition(y);case 17:T.next=13;break;case 19:T.next=24;break;case 21:T.prev=21,T.t0=T.catch(11),v.e(T.t0);case 24:return T.prev=24,v.f(),T.finish(24);case 27:return T.abrupt("return",{v:!0});case 30:if(!i){T.next=51;break}k=(new p.Z).effectDummy(game.i18n.localize("botchCritEffect"),i||[],l||{}),mergeObject(k,{flags:{dsa5:{hideOnToken:!1,hidePlayers:!1}}}),w=_createForOfIteratorHelper(u),T.prev=34,w.s();case 36:if((x=w.n()).done){T.next=42;break}return S=x.value,T.next=40,S.addCondition(k);case 40:T.next=36;break;case 42:T.next=47;break;case 44:T.prev=44,T.t1=T.catch(34),w.e(T.t1);case 47:return T.prev=47,w.f(),T.finish(47);case 50:return T.abrupt("return",{v:!0});case 51:case"end":return T.stop()}}),_loop,null,[[11,21,24,27],[34,44,47,50]])})),l.s();case 5:if((d=l.n()).done){r.next=12;break}return r.delegateYield(h(),"t0",7);case 7:if("object"!==_typeof(m=r.t0)){r.next=10;break}return r.abrupt("return",m.v);case 10:r.next=5;break;case 12:r.next=17;break;case 14:r.prev=14,r.t1=r.catch(2),l.e(r.t1);case 17:return r.prev=17,l.f(),r.finish(17);case 20:case"end":return r.stop()}}),_callee8,this,[[2,14,17,20]])}))),function malus(t,r,o,i){return a.apply(this,arguments)})},{key:"selfAttack",value:(r=_asyncToGenerator(_regeneratorRuntime().mark((function _callee9(t,r,a,o){var i;return _regeneratorRuntime().wrap((function _callee9$(r){for(;;)switch(r.prev=r.next){case 0:(i=this.evaluateTargetArg(t,a)).hasTargets,i.finalTargets;case 2:case"end":return r.stop()}}),_callee9,this)}))),function selfAttack(t,a,o,i){return r.apply(this,arguments)})},{key:"selfDamage",value:(t=_asyncToGenerator(_regeneratorRuntime().mark((function _callee10(t,r,a,i){var c,u,p,d,h,m,y,g,v,_;return _regeneratorRuntime().wrap((function _callee10$(r){for(;;)switch(r.prev=r.next){case 0:if((c=this.evaluateTargetArg(t,a)).hasTargets,u=c.finalTargets,!i){r.next=22;break}p=l.Z.toObjectIfPossible(i),d=_createForOfIteratorHelper(u),r.prev=4,m=_regeneratorRuntime().mark((function _loop2(){var r,a,c,u,d;return _regeneratorRuntime().wrap((function _loop2$(m){for(;;)switch(m.prev=m.next){case 0:return r=h.value,a=r.items.filter((function(t){return"combatskill"==t.type})).map((function(t){return o.Z._calculateCombatSkillValues(t.toObject(),r.system)})),c=void 0,c=t.damage?{damagedie:t.damage,damageAdd:""}:"rangeweapon"==i.type?o.Z._prepareRangeWeapon(p,[],a,r):"meleeweapon"==i.type?o.Z._prepareMeleeWeapon(p,a,r):"meleeAttack"==i.system.traitType.value?o.Z._prepareRangeTrait(p):o.Z._prepareMeleetrait(p),u=(c.damagedie+c.damageAdd).replace(/wWD/g,"d"),m.next=7,new Roll("(".concat(u,")*").concat(t.multiplier||1).concat(t.modifier||"")).evaluate({async:!0});case 7:return d=m.sent,m.next=10,r.applyDamage(Math.round(d.total));case 10:return m.t0=ChatMessage,m.t1=l.Z,m.next=14,d.render();case 14:m.t2=m.sent,m.t3=m.t1.chatDataSetup.call(m.t1,m.t2),m.t0.create.call(m.t0,m.t3);case 17:case"end":return m.stop()}}),_loop2)})),d.s();case 7:if((h=d.n()).done){r.next=11;break}return r.delegateYield(m(),"t0",9);case 9:r.next=7;break;case 11:r.next=16;break;case 13:r.prev=13,r.t1=r.catch(4),d.e(r.t1);case 16:return r.prev=16,d.f(),r.finish(16);case 19:return r.abrupt("return",!0);case 22:y=_createForOfIteratorHelper(u),r.prev=23,y.s();case 25:if((g=y.n()).done){r.next=41;break}return v=g.value,r.next=29,new Roll("1d6").evaluate({async:!0});case 29:return _=r.sent,r.next=32,v.applyDamage(Math.round(_.total));case 32:return r.t2=ChatMessage,r.t3=l.Z,r.next=36,_.render();case 36:r.t4=r.sent,r.t5=r.t3.chatDataSetup.call(r.t3,r.t4),r.t2.create.call(r.t2,r.t5);case 39:r.next=25;break;case 41:r.next=46;break;case 43:r.prev=43,r.t6=r.catch(23),y.e(r.t6);case 46:return r.prev=46,y.f(),r.finish(46);case 49:return r.abrupt("return",!0);case 50:case"end":return r.stop()}}),_callee10,this,[[4,13,16,19],[23,43,46,49]])}))),function selfDamage(r,a,o,i){return t.apply(this,arguments)})}]),TableEffects}()},93:(__unused_webpack_module,__webpack_exports__,__webpack_require__)=>{__webpack_require__.d(__webpack_exports__,{Z:()=>DSATour});var _system_view_helper_js__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__(707);function _typeof(t){return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},_typeof(t)}function _createForOfIteratorHelper(t,r){var a="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!a){if(Array.isArray(t)||(a=_unsupportedIterableToArray(t))||r&&t&&"number"==typeof t.length){a&&(t=a);var o=0,i=function F(){};return{s:i,n:function n(){return o>=t.length?{done:!0}:{done:!1,value:t[o++]}},e:function e(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var c,u=!0,l=!1;return{s:function s(){a=a.call(t)},n:function n(){var t=a.next();return u=t.done,t},e:function e(t){l=!0,c=t},f:function f(){try{u||null==a.return||a.return()}finally{if(l)throw c}}}}function _unsupportedIterableToArray(t,r){if(t){if("string"==typeof t)return _arrayLikeToArray(t,r);var a=Object.prototype.toString.call(t).slice(8,-1);return"Object"===a&&t.constructor&&(a=t.constructor.name),"Map"===a||"Set"===a?Array.from(t):"Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a)?_arrayLikeToArray(t,r):void 0}}function _arrayLikeToArray(t,r){(null==r||r>t.length)&&(r=t.length);for(var a=0,o=new Array(r);a=0;--o){var i=this.tryEntries[o],c=i.completion;if("root"===i.tryLoc)return handle("end");if(i.tryLoc<=this.prev){var u=a.call(i,"catchLoc"),l=a.call(i,"finallyLoc");if(u&&l){if(this.prev=0;--o){var i=this.tryEntries[o];if(i.tryLoc<=this.prev&&a.call(i,"finallyLoc")&&this.prev=0;--r){var a=this.tryEntries[r];if(a.finallyLoc===t)return this.complete(a.completion,a.afterLoc),resetTryEntry(a),l}},catch:function _catch(t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc===t){var o=a.completion;if("throw"===o.type){var i=o.arg;resetTryEntry(a)}return i}}throw new Error("illegal catch attempt")},delegateYield:function delegateYield(t,r,a){return this.delegate={iterator:values(t),resultName:r,nextLoc:a},"next"===this.method&&(this.arg=void 0),l}},t}function asyncGeneratorStep(t,r,a,o,i,c,u){try{var l=t[c](u),p=l.value}catch(t){return void a(t)}l.done?r(p):Promise.resolve(p).then(o,i)}function _asyncToGenerator(t){return function(){var r=this,a=arguments;return new Promise((function(o,i){var c=t.apply(r,a);function _next(t){asyncGeneratorStep(c,o,i,_next,_throw,"next",t)}function _throw(t){asyncGeneratorStep(c,o,i,_next,_throw,"throw",t)}_next(void 0)}))}}function _classCallCheck(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}function _defineProperties(t,r){for(var a=0;a { ".concat(this.config.preCommand," })"));case 3:return fn=_context2.sent,_context2.next=6,fn();case 6:if(!this.app){_context2.next=14;break}return _context2.next=9,this.app.render(!0,{focus:!0});case 9:if(this.app.rendered){_context2.next=14;break}return _context2.next=12,(0,_system_view_helper_js__WEBPACK_IMPORTED_MODULE_0__.gw)(50);case 12:_context2.next=9;break;case 14:if(!this.app&&!this.config.preCommand){_context2.next=20;break}case 15:if($(this.steps[this.stepIndex+1].selector+":visible").length){_context2.next=20;break}return _context2.next=18,(0,_system_view_helper_js__WEBPACK_IMPORTED_MODULE_0__.gw)(50);case 18:_context2.next=15;break;case 20:return _context2.next=22,_get(_getPrototypeOf(DSATour.prototype),"start",this).call(this);case 22:return res=_context2.sent,$("#tooltip").show(),_context2.abrupt("return",res);case 25:case"end":return _context2.stop()}}),_callee2,this)})));function start(){return _start.apply(this,arguments)}return start}()}],[{key:"travelAgency",value:(_travelAgency=_asyncToGenerator(_regeneratorRuntime().mark((function _callee3(){var t,r,a,o,i,c,u,l,p;return _regeneratorRuntime().wrap((function _callee3$(d){for(;;)switch(d.prev=d.next){case 0:t="de"==game.i18n.lang?"de":"en",console.log("Adding DSA/TDE Tours"),r=_createForOfIteratorHelper(this.tours),d.prev=3,r.s();case 5:if((a=r.n()).done){d.next=13;break}return o=a.value,d.next=9,game.dsa5.apps.DSATour.fromJSON("".concat(o.replace("/lang/","/".concat(t,"/")),".json"));case 9:i=d.sent,game.tours.register(i.config.module,i.id,i);case 11:d.next=5;break;case 13:d.next=18;break;case 15:d.prev=15,d.t0=d.catch(3),r.e(d.t0);case 18:return d.prev=18,r.f(),d.finish(18);case 21:if(game.user.isGM){d.next=23;break}return d.abrupt("return");case 23:c=_createForOfIteratorHelper(this.gmTours),d.prev=24,c.s();case 26:if((u=c.n()).done){d.next=34;break}return l=u.value,d.next=30,game.dsa5.apps.DSATour.fromJSON("".concat(l.replace("/lang/","/".concat(t,"/")),".json"));case 30:p=d.sent,game.tours.register(p.config.module,p.id,p);case 32:d.next=26;break;case 34:d.next=39;break;case 36:d.prev=36,d.t1=d.catch(24),c.e(d.t1);case 39:return d.prev=39,c.f(),d.finish(39);case 42:case"end":return d.stop()}}),_callee3,this,[[3,15,18,21],[24,36,39,42]])}))),function travelAgency(){return _travelAgency.apply(this,arguments)})}]),DSATour}(Tour);_defineProperty(DSATour,"tours",["systems/dsa5/modules/tours/lang/initial","systems/dsa5/modules/tours/lang/library","systems/dsa5/modules/tours/lang/actor"]),_defineProperty(DSATour,"gmTours",["systems/dsa5/modules/tours/lang/mastermenu"])}},__webpack_module_cache__={};function __webpack_require__(t){var r=__webpack_module_cache__[t];if(void 0!==r)return r.exports;var a=__webpack_module_cache__[t]={exports:{}};return __webpack_modules__[t](a,a.exports,__webpack_require__),a.exports}__webpack_require__.d=(t,r)=>{for(var a in r)__webpack_require__.o(r,a)&&!__webpack_require__.o(t,a)&&Object.defineProperty(t,a,{enumerable:!0,get:r[a]})},__webpack_require__.o=(t,r)=>Object.prototype.hasOwnProperty.call(t,r);var __webpack_exports__={};(()=>{var t=__webpack_require__(491),r=__webpack_require__(577),a=__webpack_require__(272),o=__webpack_require__(839),i=__webpack_require__(173),c=__webpack_require__(947),u=__webpack_require__(973);function _typeof(t){return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},_typeof(t)}function _createForOfIteratorHelper(t,r){var a="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!a){if(Array.isArray(t)||(a=_unsupportedIterableToArray(t))||r&&t&&"number"==typeof t.length){a&&(t=a);var o=0,i=function F(){};return{s:i,n:function n(){return o>=t.length?{done:!0}:{done:!1,value:t[o++]}},e:function e(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var c,u=!0,l=!1;return{s:function s(){a=a.call(t)},n:function n(){var t=a.next();return u=t.done,t},e:function e(t){l=!0,c=t},f:function f(){try{u||null==a.return||a.return()}finally{if(l)throw c}}}}function _regeneratorRuntime(){_regeneratorRuntime=function _regeneratorRuntime(){return t};var t={},r=Object.prototype,a=r.hasOwnProperty,o="function"==typeof Symbol?Symbol:{},i=o.iterator||"@@iterator",c=o.asyncIterator||"@@asyncIterator",u=o.toStringTag||"@@toStringTag";function define(t,r,a){return Object.defineProperty(t,r,{value:a,enumerable:!0,configurable:!0,writable:!0}),t[r]}try{define({},"")}catch(t){define=function define(t,r,a){return t[r]=a}}function wrap(t,r,a,o){var i=r&&r.prototype instanceof Generator?r:Generator,c=Object.create(i.prototype),u=new Context(o||[]);return c._invoke=function(t,r,a){var o="suspendedStart";return function(i,c){if("executing"===o)throw new Error("Generator is already running");if("completed"===o){if("throw"===i)throw c;return doneResult()}for(a.method=i,a.arg=c;;){var u=a.delegate;if(u){var p=maybeInvokeDelegate(u,a);if(p){if(p===l)continue;return p}}if("next"===a.method)a.sent=a._sent=a.arg;else if("throw"===a.method){if("suspendedStart"===o)throw o="completed",a.arg;a.dispatchException(a.arg)}else"return"===a.method&&a.abrupt("return",a.arg);o="executing";var d=tryCatch(t,r,a);if("normal"===d.type){if(o=a.done?"completed":"suspendedYield",d.arg===l)continue;return{value:d.arg,done:a.done}}"throw"===d.type&&(o="completed",a.method="throw",a.arg=d.arg)}}}(t,a,u),c}function tryCatch(t,r,a){try{return{type:"normal",arg:t.call(r,a)}}catch(t){return{type:"throw",arg:t}}}t.wrap=wrap;var l={};function Generator(){}function GeneratorFunction(){}function GeneratorFunctionPrototype(){}var p={};define(p,i,(function(){return this}));var d=Object.getPrototypeOf,h=d&&d(d(values([])));h&&h!==r&&a.call(h,i)&&(p=h);var m=GeneratorFunctionPrototype.prototype=Generator.prototype=Object.create(p);function defineIteratorMethods(t){["next","throw","return"].forEach((function(r){define(t,r,(function(t){return this._invoke(r,t)}))}))}function AsyncIterator(t,r){function invoke(o,i,c,u){var l=tryCatch(t[o],t,i);if("throw"!==l.type){var p=l.arg,d=p.value;return d&&"object"==_typeof(d)&&a.call(d,"__await")?r.resolve(d.__await).then((function(t){invoke("next",t,c,u)}),(function(t){invoke("throw",t,c,u)})):r.resolve(d).then((function(t){p.value=t,c(p)}),(function(t){return invoke("throw",t,c,u)}))}u(l.arg)}var o;this._invoke=function(t,a){function callInvokeWithMethodAndArg(){return new r((function(r,o){invoke(t,a,r,o)}))}return o=o?o.then(callInvokeWithMethodAndArg,callInvokeWithMethodAndArg):callInvokeWithMethodAndArg()}}function maybeInvokeDelegate(t,r){var a=t.iterator[r.method];if(void 0===a){if(r.delegate=null,"throw"===r.method){if(t.iterator.return&&(r.method="return",r.arg=void 0,maybeInvokeDelegate(t,r),"throw"===r.method))return l;r.method="throw",r.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var o=tryCatch(a,t.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,l;var i=o.arg;return i?i.done?(r[t.resultName]=i.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=void 0),r.delegate=null,l):i:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,l)}function pushTryEntry(t){var r={tryLoc:t[0]};1 in t&&(r.catchLoc=t[1]),2 in t&&(r.finallyLoc=t[2],r.afterLoc=t[3]),this.tryEntries.push(r)}function resetTryEntry(t){var r=t.completion||{};r.type="normal",delete r.arg,t.completion=r}function Context(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(pushTryEntry,this),this.reset(!0)}function values(t){if(t){var r=t[i];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var o=-1,c=function next(){for(;++o=0;--o){var i=this.tryEntries[o],c=i.completion;if("root"===i.tryLoc)return handle("end");if(i.tryLoc<=this.prev){var u=a.call(i,"catchLoc"),l=a.call(i,"finallyLoc");if(u&&l){if(this.prev=0;--o){var i=this.tryEntries[o];if(i.tryLoc<=this.prev&&a.call(i,"finallyLoc")&&this.prev=0;--r){var a=this.tryEntries[r];if(a.finallyLoc===t)return this.complete(a.completion,a.afterLoc),resetTryEntry(a),l}},catch:function _catch(t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc===t){var o=a.completion;if("throw"===o.type){var i=o.arg;resetTryEntry(a)}return i}}throw new Error("illegal catch attempt")},delegateYield:function delegateYield(t,r,a){return this.delegate={iterator:values(t),resultName:r,nextLoc:a},"next"===this.method&&(this.arg=void 0),l}},t}function _slicedToArray(t,r){return function _arrayWithHoles(t){if(Array.isArray(t))return t}(t)||function _iterableToArrayLimit(t,r){var a=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null==a)return;var o,i,c=[],u=!0,l=!1;try{for(a=a.call(t);!(u=(o=a.next()).done)&&(c.push(o.value),!r||c.length!==r);u=!0);}catch(t){l=!0,i=t}finally{try{u||null==a.return||a.return()}finally{if(l)throw i}}return c}(t,r)||_unsupportedIterableToArray(t,r)||function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function _unsupportedIterableToArray(t,r){if(t){if("string"==typeof t)return _arrayLikeToArray(t,r);var a=Object.prototype.toString.call(t).slice(8,-1);return"Object"===a&&t.constructor&&(a=t.constructor.name),"Map"===a||"Set"===a?Array.from(t):"Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a)?_arrayLikeToArray(t,r):void 0}}function _arrayLikeToArray(t,r){(null==r||r>t.length)&&(r=t.length);for(var a=0,o=new Array(r);a1&&void 0!==c[1]&&c[1],u.next=3,new Promise((function(a,o){var i={Yes:{icon:'',label:game.i18n.localize("update"),callback:function callback(){a([!0])}},cancel:{icon:'',label:game.i18n.localize("cancel"),callback:function callback(){a([!1])}}};r&&(i.migrateAll={icon:'',label:game.i18n.localize("replace"),callback:function callback(){a([2])}}),new Dialog({title:game.i18n.localize("Migrakel.Migration"),content:t,default:"yes",buttons:i,close:function close(){a([!1])}}).render(!0)}));case 3:return a=u.sent,o=_slicedToArray(a,1),i=o[0],u.abrupt("return",i);case 7:case"end":return u.stop()}}),_callee)}))),function showDialog(t){return l.apply(this,arguments)})},{key:"refreshStatusEffects",value:(u=_asyncToGenerator(_regeneratorRuntime().mark((function _callee2(t){var r,a,o,i,c;return _regeneratorRuntime().wrap((function _callee2$(u){for(;;)switch(u.prev=u.next){case 0:r=[],a=_createForOfIteratorHelper(t.effects),u.prev=2,a.s();case 4:if((o=a.n()).done){u.next=19;break}if(!(i=o.value).origin){u.next=17;break}return c=void 0,u.prev=8,u.next=11,fromUuid(i.origin);case 11:c=u.sent,u.next=16;break;case 14:u.prev=14,u.t0=u.catch(8);case 16:c||r.push(i.id);case 17:u.next=4;break;case 19:u.next=24;break;case 21:u.prev=21,u.t1=u.catch(2),a.e(u.t1);case 24:return u.prev=24,a.f(),u.finish(24);case 27:return u.next=29,t.deleteEmbeddedDocuments("ActiveEffect",r);case 29:case"end":return u.stop()}}),_callee2,null,[[2,21,24,27],[8,14]])}))),function refreshStatusEffects(t){return u.apply(this,arguments)})},{key:"updateVals",value:(c=_asyncToGenerator(_regeneratorRuntime().mark((function _callee3(t,r,a){var o,i,c,u,l,p,d,h,m,y,g,v,_,b;return _regeneratorRuntime().wrap((function _callee3$(k){for(;;)switch(k.prev=k.next){case 0:return o=game.dsa5.itemLibrary,i=[],c=[],u=new Map,k.next=6,this.refreshStatusEffects(t);case 6:if(!r({type:"equipment"})){k.next=34;break}l=[],p=[],d=_createForOfIteratorHelper(t.items.filter((function(t){return"equipment"==t.type&&"bags"==t.system.equipmentType.value}))),k.prev=10,m=_regeneratorRuntime().mark((function _loop(){var t,r,i;return _regeneratorRuntime().wrap((function _loop$(c){for(;;)switch(c.prev=c.next){case 0:return t=h.value,c.next=3,o.findCompendiumItem(t.name,t.type);case 3:if(!((r=c.sent).length>0)){c.next=12;break}if(r=r.find((function(r){return r.name==t.name&&r.type==t.type}))){c.next=8;break}return c.abrupt("return","continue");case 8:console.log("MIGRATION - Updated ".concat(t.name)),i=mergeObject(t.toObject(),a(r)),p.push(i),l.push(t.id);case 12:case"end":return c.stop()}}),_loop)})),d.s();case 13:if((h=d.n()).done){k.next=20;break}return k.delegateYield(m(),"t0",15);case 15:if("continue"!==k.t0){k.next=18;break}return k.abrupt("continue",18);case 18:k.next=13;break;case 20:k.next=25;break;case 22:k.prev=22,k.t1=k.catch(10),d.e(k.t1);case 25:return k.prev=25,d.f(),k.finish(25);case 28:return k.next=30,t.createEmbeddedDocuments("Item",p);case 30:for(y=k.sent,g=0;g0)){p.next=13;break}if(r=r.find((function(r){return r.name==t.name&&r.type==t.type}))){p.next=8;break}return p.abrupt("return","continue");case 8:console.log("MIGRATION - Updated ".concat(t.name)),(l=mergeObject(t.toObject(),a(r))).system.parent_id&&u.has(l.system.parent_id)&&(l.system.parent_id=u.get(l.system.parent_id)),c.push(l),i.push(t.id);case 13:case"end":return p.stop()}}),_loop2)})),v.s();case 38:if((_=v.n()).done){k.next=45;break}return k.delegateYield(b(),"t2",40);case 40:if("continue"!==k.t2){k.next=43;break}return k.abrupt("continue",43);case 43:k.next=38;break;case 45:k.next=50;break;case 47:k.prev=47,k.t3=k.catch(35),v.e(k.t3);case 50:return k.prev=50,v.f(),k.finish(50);case 53:return k.next=55,t.createEmbeddedDocuments("Item",c);case 55:return k.next=57,t.deleteEmbeddedDocuments("Item",i);case 57:Migrakel.silent||ui.notifications.notify(game.i18n.localize("Migrakel.migrationDone"));case 58:case"end":return k.stop()}}),_callee3,this,[[10,22,25,28],[35,47,50,53]])}))),function updateVals(t,r,a){return c.apply(this,arguments)})},{key:"updateSpellsAndLiturgies",value:(i=_asyncToGenerator(_regeneratorRuntime().mark((function _callee4(t){var r,a,o,i,c,u=arguments;return _regeneratorRuntime().wrap((function _callee4$(l){for(;;)switch(l.prev=l.next){case 0:if(null==(r=u.length>1&&void 0!==u[1]?u[1]:void 0)){l.next=5;break}l.t0=r,l.next=8;break;case 5:return l.next=7,this.showDialog(game.i18n.localize("Migrakel.spells"),!0);case 7:l.t0=l.sent;case 8:if(a=l.t0,o=function condition(t){return["spell","liturgy","ritual","ceremony","spellextension"].includes(t.type)},2!=a){l.next=16;break}return i=function updator(t){var r=t.toObject();return delete r.system.talentValue,r},l.next=14,this.updateVals(t,o,i);case 14:l.next=20;break;case 16:if(!a){l.next=20;break}return c=function _updator(t){var r={effects:t.effects.toObject()};return"spellextension"!=t.type&&(r.system={effectFormula:{value:t.system.effectFormula.value}}),r},l.next=20,this.updateVals(t,o,c);case 20:return l.abrupt("return",a);case 21:case"end":return l.stop()}}),_callee4,this)}))),function updateSpellsAndLiturgies(t){return i.apply(this,arguments)})},{key:"updateSpecialAbilities",value:(o=_asyncToGenerator(_regeneratorRuntime().mark((function _callee5(t){var r,a,o,i,c=this,u=arguments;return _regeneratorRuntime().wrap((function _callee5$(l){for(;;)switch(l.prev=l.next){case 0:if(null==(r=u.length>1&&void 0!==u[1]?u[1]:void 0)){l.next=5;break}l.t0=r,l.next=8;break;case 5:return l.next=7,this.showDialog(game.i18n.localize("Migrakel.abilities"));case 7:l.t0=l.sent;case 8:if(!(a=l.t0)){l.next=14;break}return o=function updator(t){var r={system:{effect:{value:t.system.effect.value}},effects:t.effects.toObject()};return"specialability"==t.type&&(mergeObject(r,{system:{category:{sub:t.system.category.sub||0},list:{value:t.system.list.value},effect:{value2:getProperty(t,"system.effect.value2")||"",value3:getProperty(t,"system.effect.value3")||""}}}),"staff"==t.system.category.value&&mergeObject(r,{system:{feature:getProperty(t,"system.feature")||"",AsPCost:getProperty(t,"system.AsPCost")||"",volume:Number(getProperty(t,"system.volume"))||0,artifact:getProperty(t,"system.artifact")||""}})),c.updateMacro(r,t),r},i=function condition(t){return["specialability","advantage","disadvantage","trait"].includes(t.type)},l.next=14,this.updateVals(t,i,o);case 14:return l.abrupt("return",a);case 15:case"end":return l.stop()}}),_callee5,this)}))),function updateSpecialAbilities(t){return o.apply(this,arguments)})},{key:"updateCombatskills",value:(a=_asyncToGenerator(_regeneratorRuntime().mark((function _callee6(t){var r,a,o,i,c=arguments;return _regeneratorRuntime().wrap((function _callee6$(u){for(;;)switch(u.prev=u.next){case 0:if(null==(r=c.length>1&&void 0!==c[1]?c[1]:void 0)){u.next=5;break}u.t0=r,u.next=8;break;case 5:return u.next=7,this.showDialog(game.i18n.localize("Migrakel.cskills"));case 7:u.t0=u.sent;case 8:if(!(a=u.t0)){u.next=14;break}return o=function updator(t){return{effects:t.effects.toObject()}},i=function condition(t){return["combatskill"].includes(t.type)},u.next=14,this.updateVals(t,i,o);case 14:return u.abrupt("return",a);case 15:case"end":return u.stop()}}),_callee6,this)}))),function updateCombatskills(t){return a.apply(this,arguments)})},{key:"updateSkills",value:(r=_asyncToGenerator(_regeneratorRuntime().mark((function _callee7(t){var r,a,o,i,c=arguments;return _regeneratorRuntime().wrap((function _callee7$(u){for(;;)switch(u.prev=u.next){case 0:if(null==(r=c.length>1&&void 0!==c[1]?c[1]:void 0)){u.next=5;break}u.t0=r,u.next=8;break;case 5:return u.next=7,this.showDialog(game.i18n.localize("Migrakel.skills"));case 7:u.t0=u.sent;case 8:if(!(a=u.t0)){u.next=14;break}return o=function condition(t){return["skill"].includes(t.type)},i=function updator(t){return{img:t.img}},u.next=14,this.updateVals(t,o,i);case 14:return u.abrupt("return",a);case 15:case"end":return u.stop()}}),_callee7,this)}))),function updateSkills(t){return r.apply(this,arguments)})},{key:"updateMacro",value:function updateMacro(t,r){var a=r.getFlag("dsa5","onUseEffect");a&&mergeObject(t,{flags:{dsa5:{onUseEffect:a}}})}},{key:"updateGear",value:(t=_asyncToGenerator(_regeneratorRuntime().mark((function _callee8(t){var r,a,o,i,c=this,u=arguments;return _regeneratorRuntime().wrap((function _callee8$(l){for(;;)switch(l.prev=l.next){case 0:if(null==(r=u.length>1&&void 0!==u[1]?u[1]:void 0)){l.next=5;break}l.t0=r,l.next=8;break;case 5:return l.next=7,this.showDialog(game.i18n.localize("Migrakel.gear"));case 7:l.t0=l.sent;case 8:if(!(a=l.t0)){l.next=14;break}return o=function condition(t){return["meleeweapon","armor","rangeweapon","equipment","poison","consumable","ammunition"].includes(t.type)},i=function updator(t){var r={img:t.img,effects:t.effects.toObject()};return["poison","consumable"].includes(t.type)||mergeObject(r,{system:{effect:{value:t.system.effect.value}}}),["armor"].includes(t.type)&&mergeObject(r,{system:{subcategory:t.system.subcategory}}),["meleeweapon","rangeweapon","armor"].includes(t.type)&&mergeObject(r,{system:{structure:{max:t.system.structure.max,value:t.system.structure.value}}}),c.updateMacro(r,t),r},l.next=14,this.updateVals(t,o,i);case 14:return l.abrupt("return",a);case 15:case"end":return l.stop()}}),_callee8,this)}))),function updateGear(r){return t.apply(this,arguments)})}]),Migrakel}();function dialog_actorConfig_typeof(t){return dialog_actorConfig_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},dialog_actorConfig_typeof(t)}function dialog_actorConfig_regeneratorRuntime(){dialog_actorConfig_regeneratorRuntime=function _regeneratorRuntime(){return t};var t={},r=Object.prototype,a=r.hasOwnProperty,o="function"==typeof Symbol?Symbol:{},i=o.iterator||"@@iterator",c=o.asyncIterator||"@@asyncIterator",u=o.toStringTag||"@@toStringTag";function define(t,r,a){return Object.defineProperty(t,r,{value:a,enumerable:!0,configurable:!0,writable:!0}),t[r]}try{define({},"")}catch(t){define=function define(t,r,a){return t[r]=a}}function wrap(t,r,a,o){var i=r&&r.prototype instanceof Generator?r:Generator,c=Object.create(i.prototype),u=new Context(o||[]);return c._invoke=function(t,r,a){var o="suspendedStart";return function(i,c){if("executing"===o)throw new Error("Generator is already running");if("completed"===o){if("throw"===i)throw c;return doneResult()}for(a.method=i,a.arg=c;;){var u=a.delegate;if(u){var p=maybeInvokeDelegate(u,a);if(p){if(p===l)continue;return p}}if("next"===a.method)a.sent=a._sent=a.arg;else if("throw"===a.method){if("suspendedStart"===o)throw o="completed",a.arg;a.dispatchException(a.arg)}else"return"===a.method&&a.abrupt("return",a.arg);o="executing";var d=tryCatch(t,r,a);if("normal"===d.type){if(o=a.done?"completed":"suspendedYield",d.arg===l)continue;return{value:d.arg,done:a.done}}"throw"===d.type&&(o="completed",a.method="throw",a.arg=d.arg)}}}(t,a,u),c}function tryCatch(t,r,a){try{return{type:"normal",arg:t.call(r,a)}}catch(t){return{type:"throw",arg:t}}}t.wrap=wrap;var l={};function Generator(){}function GeneratorFunction(){}function GeneratorFunctionPrototype(){}var p={};define(p,i,(function(){return this}));var d=Object.getPrototypeOf,h=d&&d(d(values([])));h&&h!==r&&a.call(h,i)&&(p=h);var m=GeneratorFunctionPrototype.prototype=Generator.prototype=Object.create(p);function defineIteratorMethods(t){["next","throw","return"].forEach((function(r){define(t,r,(function(t){return this._invoke(r,t)}))}))}function AsyncIterator(t,r){function invoke(o,i,c,u){var l=tryCatch(t[o],t,i);if("throw"!==l.type){var p=l.arg,d=p.value;return d&&"object"==dialog_actorConfig_typeof(d)&&a.call(d,"__await")?r.resolve(d.__await).then((function(t){invoke("next",t,c,u)}),(function(t){invoke("throw",t,c,u)})):r.resolve(d).then((function(t){p.value=t,c(p)}),(function(t){return invoke("throw",t,c,u)}))}u(l.arg)}var o;this._invoke=function(t,a){function callInvokeWithMethodAndArg(){return new r((function(r,o){invoke(t,a,r,o)}))}return o=o?o.then(callInvokeWithMethodAndArg,callInvokeWithMethodAndArg):callInvokeWithMethodAndArg()}}function maybeInvokeDelegate(t,r){var a=t.iterator[r.method];if(void 0===a){if(r.delegate=null,"throw"===r.method){if(t.iterator.return&&(r.method="return",r.arg=void 0,maybeInvokeDelegate(t,r),"throw"===r.method))return l;r.method="throw",r.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var o=tryCatch(a,t.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,l;var i=o.arg;return i?i.done?(r[t.resultName]=i.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=void 0),r.delegate=null,l):i:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,l)}function pushTryEntry(t){var r={tryLoc:t[0]};1 in t&&(r.catchLoc=t[1]),2 in t&&(r.finallyLoc=t[2],r.afterLoc=t[3]),this.tryEntries.push(r)}function resetTryEntry(t){var r=t.completion||{};r.type="normal",delete r.arg,t.completion=r}function Context(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(pushTryEntry,this),this.reset(!0)}function values(t){if(t){var r=t[i];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var o=-1,c=function next(){for(;++o=0;--o){var i=this.tryEntries[o],c=i.completion;if("root"===i.tryLoc)return handle("end");if(i.tryLoc<=this.prev){var u=a.call(i,"catchLoc"),l=a.call(i,"finallyLoc");if(u&&l){if(this.prev=0;--o){var i=this.tryEntries[o];if(i.tryLoc<=this.prev&&a.call(i,"finallyLoc")&&this.prev=0;--r){var a=this.tryEntries[r];if(a.finallyLoc===t)return this.complete(a.completion,a.afterLoc),resetTryEntry(a),l}},catch:function _catch(t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc===t){var o=a.completion;if("throw"===o.type){var i=o.arg;resetTryEntry(a)}return i}}throw new Error("illegal catch attempt")},delegateYield:function delegateYield(t,r,a){return this.delegate={iterator:values(t),resultName:r,nextLoc:a},"next"===this.method&&(this.arg=void 0),l}},t}function dialog_actorConfig_asyncGeneratorStep(t,r,a,o,i,c,u){try{var l=t[c](u),p=l.value}catch(t){return void a(t)}l.done?r(p):Promise.resolve(p).then(o,i)}function dialog_actorConfig_asyncToGenerator(t){return function(){var r=this,a=arguments;return new Promise((function(o,i){var c=t.apply(r,a);function _next(t){dialog_actorConfig_asyncGeneratorStep(c,o,i,_next,_throw,"next",t)}function _throw(t){dialog_actorConfig_asyncGeneratorStep(c,o,i,_next,_throw,"throw",t)}_next(void 0)}))}}function dialog_actorConfig_defineProperties(t,r){for(var a=0;a
    '),a.next=4,l[t](o.actor);case 4:$(r.currentTarget).find("i").remove(),o.lock=!1;case 6:case"end":return a.stop()}}),_callee)})));return function upd(){return a.apply(this,arguments)}}(),a();case 4:case"end":return i.stop()}}),_callee2,this)}))),function updateWrapper(t,r){return a.apply(this,arguments)})},{key:"activateListeners",value:function activateListeners(t){var r=this;_get(_getPrototypeOf(DialogActorConfig.prototype),"activateListeners",this).call(this,t),t.find(".updateSpells").click(function(){var t=dialog_actorConfig_asyncToGenerator(dialog_actorConfig_regeneratorRuntime().mark((function _callee3(t){return dialog_actorConfig_regeneratorRuntime().wrap((function _callee3$(a){for(;;)switch(a.prev=a.next){case 0:return a.abrupt("return",r.updateWrapper("updateSpellsAndLiturgies",t));case 1:case"end":return a.stop()}}),_callee3)})));return function(r){return t.apply(this,arguments)}}()),t.find(".updateAbilities").click(function(){var t=dialog_actorConfig_asyncToGenerator(dialog_actorConfig_regeneratorRuntime().mark((function _callee4(t){return dialog_actorConfig_regeneratorRuntime().wrap((function _callee4$(a){for(;;)switch(a.prev=a.next){case 0:return a.abrupt("return",r.updateWrapper("updateSpecialAbilities",t));case 1:case"end":return a.stop()}}),_callee4)})));return function(r){return t.apply(this,arguments)}}()),t.find(".updatecSkills").click(function(){var t=dialog_actorConfig_asyncToGenerator(dialog_actorConfig_regeneratorRuntime().mark((function _callee5(t){return dialog_actorConfig_regeneratorRuntime().wrap((function _callee5$(a){for(;;)switch(a.prev=a.next){case 0:return a.abrupt("return",r.updateWrapper("updateCombatskills",t));case 1:case"end":return a.stop()}}),_callee5)})));return function(r){return t.apply(this,arguments)}}()),t.find(".updateSkills").click(function(){var t=dialog_actorConfig_asyncToGenerator(dialog_actorConfig_regeneratorRuntime().mark((function _callee6(t){return dialog_actorConfig_regeneratorRuntime().wrap((function _callee6$(a){for(;;)switch(a.prev=a.next){case 0:return a.abrupt("return",r.updateWrapper("updateSkills",t));case 1:case"end":return a.stop()}}),_callee6)})));return function(r){return t.apply(this,arguments)}}()),t.find(".updateGear").click(function(){var t=dialog_actorConfig_asyncToGenerator(dialog_actorConfig_regeneratorRuntime().mark((function _callee7(t){return dialog_actorConfig_regeneratorRuntime().wrap((function _callee7$(a){for(;;)switch(a.prev=a.next){case 0:return a.abrupt("return",r.updateWrapper("updateGear",t));case 1:case"end":return a.stop()}}),_callee7)})));return function(r){return t.apply(this,arguments)}}())}}],[{key:"buildDialog",value:(r=dialog_actorConfig_asyncToGenerator(dialog_actorConfig_regeneratorRuntime().mark((function _callee8(t){var r;return dialog_actorConfig_regeneratorRuntime().wrap((function _callee8$(a){for(;;)switch(a.prev=a.next){case 0:return a.next=2,renderTemplate("systems/dsa5/templates/actors/parts/actorConfig.html",{actor:t});case 2:r=a.sent,new DialogActorConfig(t,{title:game.i18n.localize("SHEET.actorConfig"),content:r,default:"Save",buttons:{Save:{icon:'',label:game.i18n.localize("Save"),callback:function callback(r){t.update({"system.config.autoBar":r.find('[name="autoBar"]').is(":checked"),"system.config.autoSize":r.find('[name="autoSize"]').is(":checked")})}},cancel:{icon:'',label:game.i18n.localize("cancel")}}}).render(!0);case 4:case"end":return a.stop()}}),_callee8)}))),function buildDialog(t){return r.apply(this,arguments)})}]),DialogActorConfig}(),d=__webpack_require__(369),h=__webpack_require__(707),m=__webpack_require__(803),y=__webpack_require__(122),g=__webpack_require__(604);function bindImgToCanvasDragStart(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"img";game.user.isGM&&t.find(r).each((function(t,r){r.setAttribute("draggable",!0),r.addEventListener("dragstart",(function(t){return v(t)}))}))}var v=function dragTileImg(t){canvas.tiles.activate();var r=t.currentTarget.src,a=t.currentTarget,o=canvas.dimensions.sceneHeight/a.naturalHeight,i=canvas.dimensions.sceneWidth/a.naturalWidth,c=Math.min(1,i,o),u={type:"Tile",texture:{src:r},tileSize:Math.round(canvas.dimensions.size/c)};t.dataTransfer.setData("text/plain",JSON.stringify(u));var l=a.naturalWidth*c*canvas.stage.scale.x,p=a.naturalHeight*c*canvas.stage.scale.y,d=DragDrop.createDragImage(a,l,p);t.dataTransfer.setDragImage(d,l/2,p/2)},_=__webpack_require__(231),b=__webpack_require__(169);function foreignFieldEditor_typeof(t){return foreignFieldEditor_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},foreignFieldEditor_typeof(t)}function foreignFieldEditor_regeneratorRuntime(){foreignFieldEditor_regeneratorRuntime=function _regeneratorRuntime(){return t};var t={},r=Object.prototype,a=r.hasOwnProperty,o="function"==typeof Symbol?Symbol:{},i=o.iterator||"@@iterator",c=o.asyncIterator||"@@asyncIterator",u=o.toStringTag||"@@toStringTag";function define(t,r,a){return Object.defineProperty(t,r,{value:a,enumerable:!0,configurable:!0,writable:!0}),t[r]}try{define({},"")}catch(t){define=function define(t,r,a){return t[r]=a}}function wrap(t,r,a,o){var i=r&&r.prototype instanceof Generator?r:Generator,c=Object.create(i.prototype),u=new Context(o||[]);return c._invoke=function(t,r,a){var o="suspendedStart";return function(i,c){if("executing"===o)throw new Error("Generator is already running");if("completed"===o){if("throw"===i)throw c;return doneResult()}for(a.method=i,a.arg=c;;){var u=a.delegate;if(u){var p=maybeInvokeDelegate(u,a);if(p){if(p===l)continue;return p}}if("next"===a.method)a.sent=a._sent=a.arg;else if("throw"===a.method){if("suspendedStart"===o)throw o="completed",a.arg;a.dispatchException(a.arg)}else"return"===a.method&&a.abrupt("return",a.arg);o="executing";var d=tryCatch(t,r,a);if("normal"===d.type){if(o=a.done?"completed":"suspendedYield",d.arg===l)continue;return{value:d.arg,done:a.done}}"throw"===d.type&&(o="completed",a.method="throw",a.arg=d.arg)}}}(t,a,u),c}function tryCatch(t,r,a){try{return{type:"normal",arg:t.call(r,a)}}catch(t){return{type:"throw",arg:t}}}t.wrap=wrap;var l={};function Generator(){}function GeneratorFunction(){}function GeneratorFunctionPrototype(){}var p={};define(p,i,(function(){return this}));var d=Object.getPrototypeOf,h=d&&d(d(values([])));h&&h!==r&&a.call(h,i)&&(p=h);var m=GeneratorFunctionPrototype.prototype=Generator.prototype=Object.create(p);function defineIteratorMethods(t){["next","throw","return"].forEach((function(r){define(t,r,(function(t){return this._invoke(r,t)}))}))}function AsyncIterator(t,r){function invoke(o,i,c,u){var l=tryCatch(t[o],t,i);if("throw"!==l.type){var p=l.arg,d=p.value;return d&&"object"==foreignFieldEditor_typeof(d)&&a.call(d,"__await")?r.resolve(d.__await).then((function(t){invoke("next",t,c,u)}),(function(t){invoke("throw",t,c,u)})):r.resolve(d).then((function(t){p.value=t,c(p)}),(function(t){return invoke("throw",t,c,u)}))}u(l.arg)}var o;this._invoke=function(t,a){function callInvokeWithMethodAndArg(){return new r((function(r,o){invoke(t,a,r,o)}))}return o=o?o.then(callInvokeWithMethodAndArg,callInvokeWithMethodAndArg):callInvokeWithMethodAndArg()}}function maybeInvokeDelegate(t,r){var a=t.iterator[r.method];if(void 0===a){if(r.delegate=null,"throw"===r.method){if(t.iterator.return&&(r.method="return",r.arg=void 0,maybeInvokeDelegate(t,r),"throw"===r.method))return l;r.method="throw",r.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var o=tryCatch(a,t.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,l;var i=o.arg;return i?i.done?(r[t.resultName]=i.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=void 0),r.delegate=null,l):i:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,l)}function pushTryEntry(t){var r={tryLoc:t[0]};1 in t&&(r.catchLoc=t[1]),2 in t&&(r.finallyLoc=t[2],r.afterLoc=t[3]),this.tryEntries.push(r)}function resetTryEntry(t){var r=t.completion||{};r.type="normal",delete r.arg,t.completion=r}function Context(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(pushTryEntry,this),this.reset(!0)}function values(t){if(t){var r=t[i];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var o=-1,c=function next(){for(;++o=0;--o){var i=this.tryEntries[o],c=i.completion;if("root"===i.tryLoc)return handle("end");if(i.tryLoc<=this.prev){var u=a.call(i,"catchLoc"),l=a.call(i,"finallyLoc");if(u&&l){if(this.prev=0;--o){var i=this.tryEntries[o];if(i.tryLoc<=this.prev&&a.call(i,"finallyLoc")&&this.prev=0;--r){var a=this.tryEntries[r];if(a.finallyLoc===t)return this.complete(a.completion,a.afterLoc),resetTryEntry(a),l}},catch:function _catch(t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc===t){var o=a.completion;if("throw"===o.type){var i=o.arg;resetTryEntry(a)}return i}}throw new Error("illegal catch attempt")},delegateYield:function delegateYield(t,r,a){return this.delegate={iterator:values(t),resultName:r,nextLoc:a},"next"===this.method&&(this.arg=void 0),l}},t}function foreignFieldEditor_asyncGeneratorStep(t,r,a,o,i,c,u){try{var l=t[c](u),p=l.value}catch(t){return void a(t)}l.done?r(p):Promise.resolve(p).then(o,i)}function foreignFieldEditor_asyncToGenerator(t){return function(){var r=this,a=arguments;return new Promise((function(o,i){var c=t.apply(r,a);function _next(t){foreignFieldEditor_asyncGeneratorStep(c,o,i,_next,_throw,"next",t)}function _throw(t){foreignFieldEditor_asyncGeneratorStep(c,o,i,_next,_throw,"throw",t)}_next(void 0)}))}}function foreignFieldEditor_defineProperties(t,r){for(var a=0;a=t.length?{done:!0}:{done:!1,value:t[o++]}},e:function e(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var c,u=!0,l=!1;return{s:function s(){a=a.call(t)},n:function n(){var t=a.next();return u=t.done,t},e:function e(t){l=!0,c=t},f:function f(){try{u||null==a.return||a.return()}finally{if(l)throw c}}}}function payment_unsupportedIterableToArray(t,r){if(t){if("string"==typeof t)return payment_arrayLikeToArray(t,r);var a=Object.prototype.toString.call(t).slice(8,-1);return"Object"===a&&t.constructor&&(a=t.constructor.name),"Map"===a||"Set"===a?Array.from(t):"Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a)?payment_arrayLikeToArray(t,r):void 0}}function payment_arrayLikeToArray(t,r){(null==r||r>t.length)&&(r=t.length);for(var a=0,o=new Array(r);a=0;--o){var i=this.tryEntries[o],c=i.completion;if("root"===i.tryLoc)return handle("end");if(i.tryLoc<=this.prev){var u=a.call(i,"catchLoc"),l=a.call(i,"finallyLoc");if(u&&l){if(this.prev=0;--o){var i=this.tryEntries[o];if(i.tryLoc<=this.prev&&a.call(i,"finallyLoc")&&this.prev=0;--r){var a=this.tryEntries[r];if(a.finallyLoc===t)return this.complete(a.completion,a.afterLoc),resetTryEntry(a),l}},catch:function _catch(t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc===t){var o=a.completion;if("throw"===o.type){var i=o.arg;resetTryEntry(a)}return i}}throw new Error("illegal catch attempt")},delegateYield:function delegateYield(t,r,a){return this.delegate={iterator:values(t),resultName:r,nextLoc:a},"next"===this.method&&(this.arg=void 0),l}},t}function payment_asyncGeneratorStep(t,r,a,o,i,c,u){try{var l=t[c](u),p=l.value}catch(t){return void a(t)}l.done?r(p):Promise.resolve(p).then(o,i)}function payment_asyncToGenerator(t){return function(){var r=this,a=arguments;return new Promise((function(o,i){var c=t.apply(r,a);function _next(t){payment_asyncGeneratorStep(c,o,i,_next,_throw,"next",t)}function _throw(t){payment_asyncGeneratorStep(c,o,i,_next,_throw,"throw",t)}_next(void 0)}))}}function payment_defineProperties(t,r){for(var a=0;a2&&void 0!==u[2]&&u[2],i=!(u.length>3&&void 0!==u[3])||u[3],!(c=DSA5Payment.canPay(r,a,o)).success){l.next=6;break}return l.next=6,DSA5Payment._updateMoney(r,c.actorsMoney.money,c.actorsMoney.sum-c.money,i);case 6:return o||""==c.msg||ChatMessage.create(t.Z.chatDataSetup("

    ".concat(c.msg,"

    "),"roll")),l.abrupt("return",c.success);case 8:case"end":return l.stop()}}),_callee)}))),function payMoney(t,r){return c.apply(this,arguments)})},{key:"canPay",value:function canPay(t,r,a){var o=this._getPaymoney(r),i={success:!1,msg:"",money:o};return o&&(i.actorsMoney=this._actorsMoney(t),i.actorsMoney.sum>=o?(i.msg=game.i18n.format("PAYMENT.pay",{actor:t.name,amount:DSA5Payment._moneyToString(o)}),i.success=!0):(i.msg=game.i18n.format("PAYMENT.cannotpay",{actor:t.name,amount:DSA5Payment._moneyToString(o)}),a&&ui.notifications.notify(i.msg))),i}},{key:"getMoney",value:(i=payment_asyncToGenerator(payment_regeneratorRuntime().mark((function _callee2(r,a){var o,i,c,u,l,p=arguments;return payment_regeneratorRuntime().wrap((function _callee2$(d){for(;;)switch(d.prev=d.next){case 0:if(o=p.length>2&&void 0!==p[2]&&p[2],i=!(p.length>3&&void 0!==p[3])||p[3],!(c=this._getPaidmoney(a))){d.next=10;break}return u=this._actorsMoney(r),d.next=7,DSA5Payment._updateMoney(r,u.money,u.sum+c,i);case 7:return l="

    ".concat(game.i18n.format("PAYMENT.getPaid",{actor:r.name,amount:DSA5Payment._moneyToString(c)}),"

    "),o||ChatMessage.create(t.Z.chatDataSetup(l,"roll")),d.abrupt("return",!0);case 10:case"end":return d.stop()}}),_callee2,this)}))),function getMoney(t,r){return i.apply(this,arguments)})},{key:"_updateMoney",value:(o=payment_asyncToGenerator(payment_regeneratorRuntime().mark((function _callee3(t,r,a){var o,i,c,u,l,p=arguments;return payment_regeneratorRuntime().wrap((function _callee3$(d){for(;;)switch(d.prev=d.next){case 0:o=!(p.length>3&&void 0!==p[3])||p[3],i=DSA5Payment._moneyToCoins(a),c=payment_createForOfIteratorHelper(r),d.prev=3,c.s();case 5:if((u=c.n()).done){d.next=20;break}l=u.value,d.t0=l.name,d.next="Money-D"===d.t0?10:"Money-S"===d.t0?12:"Money-H"===d.t0?14:"Money-K"===d.t0?16:18;break;case 10:return l.system.quantity.value=i.D,d.abrupt("break",18);case 12:return l.system.quantity.value=i.S,d.abrupt("break",18);case 14:return l.system.quantity.value=i.H,d.abrupt("break",18);case 16:return l.system.quantity.value=i.K,d.abrupt("break",18);case 18:d.next=5;break;case 20:d.next=25;break;case 22:d.prev=22,d.t1=d.catch(3),c.e(d.t1);case 25:return d.prev=25,c.f(),d.finish(25);case 28:return d.next=30,t.updateEmbeddedDocuments("Item",r,{render:o});case 30:case"end":return d.stop()}}),_callee3,null,[[3,22,25,28]])}))),function _updateMoney(t,r,a){return o.apply(this,arguments)})},{key:"createGetPaidChatMessage",value:function createGetPaidChatMessage(r){var a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:void 0,o=this._getPaidmoney(r);if(o){var i=a?" (".concat(a,")"):"",c="

    ".concat(game.i18n.localize("PAYMENT.wage"),"

    ").concat(game.i18n.format("PAYMENT.getPaidSum",{amount:DSA5Payment._moneyToString(o)})).concat(i,'

    ");ChatMessage.create(t.Z.chatDataSetup(c,"roll"))}}},{key:"createPayChatMessage",value:function createPayChatMessage(r){var a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:void 0,o=this._getPaymoney(r);if(o){var i=a?" (".concat(a,")"):"",c="

    ".concat(game.i18n.localize("PAYMENT.bill"),"

    ").concat(game.i18n.format("PAYMENT.paySum",{amount:DSA5Payment._moneyToString(o)})).concat(i,'

    ");ChatMessage.create(t.Z.chatDataSetup(c,"roll"))}}},{key:"_getPaidmoney",value:function _getPaidmoney(r){var a=this._parseMoneyString(r);if(!a){var o="

    ".concat(game.i18n.localize("PAYMENT.error"),"

    ").concat(game.i18n.localize("PAYMENT.getPaidexample"),"

    ");return ChatMessage.create(t.Z.chatDataSetup(o,"roll")),!1}return a}},{key:"_getPaymoney",value:function _getPaymoney(r){var a=this._parseMoneyString(r);if(!a){var o="

    ".concat(game.i18n.localize("PAYMENT.error"),"

    ").concat(game.i18n.localize("PAYMENT.payexample"),"

    ");return ChatMessage.create(t.Z.chatDataSetup(o,"roll")),!1}return a}},{key:"_parseMoneyString",value:function _parseMoneyString(t){var r=t.replace(",",".").match(/\d{1,}(\.\d{1,3}|,\d{1,3})?/);return!!r&&Number(r[0])}},{key:"_actorsMoney",value:function _actorsMoney(t){var r=duplicate(t.items.filter((function(t){return"money"==t.type})));return{money:r,sum:r.reduce((function(t,r){return t+Number(r.system.quantity.value)*Number(r.system.price.value)}),0)}}},{key:"handlePayAction",value:(a=payment_asyncToGenerator(payment_regeneratorRuntime().mark((function _callee4(t,r,a){var o,i,c=arguments;return payment_regeneratorRuntime().wrap((function _callee4$(u){for(;;)switch(u.prev=u.next){case 0:if(o=c.length>3&&void 0!==c[3]?c[3]:void 0,!game.user.isGM||o){u.next=4;break}return ui.notifications.notify(game.i18n.localize("PAYMENT.onlyActors")),u.abrupt("return");case 4:if(o?m.Z.playMoneySound(!0):o=game.user.character,i=!1,!o||!r){u.next=12;break}return u.next=9,DSA5Payment.payMoney(o,a);case 9:i=u.sent,u.next=19;break;case 12:if(!o||r){u.next=18;break}return u.next=15,DSA5Payment.getMoney(o,a);case 15:i=u.sent,u.next=19;break;case 18:ui.notifications.notify(game.i18n.localize("PAYMENT.onlyActors"));case 19:i&&t&&(t.fadeOut(),game.socket.emit("system.dsa5",{type:"updateMsg",payload:{id:t.closest(".message").attr("data-message-id"),updateData:_defineProperty({},"flags.dsa5.userHidden.".concat(game.user.id),!0)}}));case 20:case"end":return u.stop()}}),_callee4)}))),function handlePayAction(t,r,o){return a.apply(this,arguments)})},{key:"_moneyToCoins",value:function _moneyToCoins(t){var r=Math.round(100*t),a=Math.floor(r/1e3),o=Math.floor((r-1e3*a)/100),i=Math.floor((r-1e3*a-100*o)/10);return{D:a,S:o,H:i,K:Math.round(r-1e3*a-100*o-10*i)}}},{key:"_moneyToString",value:function _moneyToString(t){for(var r=DSA5Payment._moneyToCoins(t),a=[],o=0,i=Object.entries(r);o0&&a.push(''.concat(l,' '))}return a.join(", ")}},{key:"chatListeners",value:(r=payment_asyncToGenerator(payment_regeneratorRuntime().mark((function _callee5(t){return payment_regeneratorRuntime().wrap((function _callee5$(r){for(;;)switch(r.prev=r.next){case 0:t.on("click",".payButton",(function(t){var r=$(t.currentTarget);DSA5Payment.handlePayAction(r,1!=Number(r.attr("data-pay")),r.attr("data-amount")),m.Z.playMoneySound()}));case 1:case"end":return r.stop()}}),_callee5)}))),function chatListeners(t){return r.apply(this,arguments)})}]),DSA5Payment}();function tokenHotbar2_typeof(t){return tokenHotbar2_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},tokenHotbar2_typeof(t)}function tokenHotbar2_createForOfIteratorHelper(t,r){var a="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!a){if(Array.isArray(t)||(a=tokenHotbar2_unsupportedIterableToArray(t))||r&&t&&"number"==typeof t.length){a&&(t=a);var o=0,i=function F(){};return{s:i,n:function n(){return o>=t.length?{done:!0}:{done:!1,value:t[o++]}},e:function e(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var c,u=!0,l=!1;return{s:function s(){a=a.call(t)},n:function n(){var t=a.next();return u=t.done,t},e:function e(t){l=!0,c=t},f:function f(){try{u||null==a.return||a.return()}finally{if(l)throw c}}}}function _toConsumableArray(t){return function _arrayWithoutHoles(t){if(Array.isArray(t))return tokenHotbar2_arrayLikeToArray(t)}(t)||function _iterableToArray(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||tokenHotbar2_unsupportedIterableToArray(t)||function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function tokenHotbar2_unsupportedIterableToArray(t,r){if(t){if("string"==typeof t)return tokenHotbar2_arrayLikeToArray(t,r);var a=Object.prototype.toString.call(t).slice(8,-1);return"Object"===a&&t.constructor&&(a=t.constructor.name),"Map"===a||"Set"===a?Array.from(t):"Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a)?tokenHotbar2_arrayLikeToArray(t,r):void 0}}function tokenHotbar2_arrayLikeToArray(t,r){(null==r||r>t.length)&&(r=t.length);for(var a=0,o=new Array(r);a=0;--o){var i=this.tryEntries[o],c=i.completion;if("root"===i.tryLoc)return handle("end");if(i.tryLoc<=this.prev){var u=a.call(i,"catchLoc"),l=a.call(i,"finallyLoc");if(u&&l){if(this.prev=0;--o){var i=this.tryEntries[o];if(i.tryLoc<=this.prev&&a.call(i,"finallyLoc")&&this.prev=0;--r){var a=this.tryEntries[r];if(a.finallyLoc===t)return this.complete(a.completion,a.afterLoc),resetTryEntry(a),l}},catch:function _catch(t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc===t){var o=a.completion;if("throw"===o.type){var i=o.arg;resetTryEntry(a)}return i}}throw new Error("illegal catch attempt")},delegateYield:function delegateYield(t,r,a){return this.delegate={iterator:values(t),resultName:r,nextLoc:a},"next"===this.method&&(this.arg=void 0),l}},t}function tokenHotbar2_asyncGeneratorStep(t,r,a,o,i,c,u){try{var l=t[c](u),p=l.value}catch(t){return void a(t)}l.done?r(p):Promise.resolve(p).then(o,i)}function tokenHotbar2_asyncToGenerator(t){return function(){var r=this,a=arguments;return new Promise((function(o,i){var c=t.apply(r,a);function _next(t){tokenHotbar2_asyncGeneratorStep(c,o,i,_next,_throw,"next",t)}function _throw(t){tokenHotbar2_asyncGeneratorStep(c,o,i,_next,_throw,"throw",t)}_next(void 0)}))}}function tokenHotbar2_classCallCheck(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}function tokenHotbar2_defineProperties(t,r){for(var a=0;a0?Math.min(100,r+5):Math.max(15,r-5),a.next=4,game.settings.set("dsa5","tokenhotbarSize",r);case 4:return a.next=6,this.render(!0);case 6:case"end":return a.stop()}}),_callee2,this)}))),function _onWheelResize(t){return x.apply(this,arguments)})},{key:"_cycleLayout",value:(k=tokenHotbar2_asyncToGenerator(tokenHotbar2_regeneratorRuntime().mark((function _callee3(t){var r;return tokenHotbar2_regeneratorRuntime().wrap((function _callee3$(a){for(;;)switch(a.prev=a.next){case 0:if(2!=t.button){a.next=7;break}return 4==(r=game.settings.get("dsa5","tokenhotbarLayout")+1)&&(r=0),a.next=5,game.settings.set("dsa5","tokenhotbarLayout",r);case 5:return a.next=7,this.render(!0);case 7:case"end":return a.stop()}}),_callee3,this)}))),function _cycleLayout(t){return k.apply(this,arguments)})},{key:"changeDarkness",value:function changeDarkness(t){var r=Number(t.currentTarget.value);canvas.scene&&canvas.scene.update({darkness:r},{animateDarkness:3e3}),(0,h.p0)(r)}},{key:"activateListeners",value:function activateListeners(t){var r=this;tokenHotbar2_get(tokenHotbar2_getPrototypeOf(TokenHotbar2.prototype),"activateListeners",this).call(this,t);var a=t.find(".dragHandler");new Draggable(this,t,a[0],this.options.resizable),a.on("wheel",function(){var t=tokenHotbar2_asyncToGenerator(tokenHotbar2_regeneratorRuntime().mark((function _callee4(t){return tokenHotbar2_regeneratorRuntime().wrap((function _callee4$(a){for(;;)switch(a.prev=a.next){case 0:return t.stopPropagation(),t.preventDefault(),a.next=4,r._onWheelResize(t);case 4:return a.abrupt("return",!1);case 5:case"end":return a.stop()}}),_callee4)})));return function(r){return t.apply(this,arguments)}}()),a.on("mousedown",function(){var t=tokenHotbar2_asyncToGenerator(tokenHotbar2_regeneratorRuntime().mark((function _callee5(t){return tokenHotbar2_regeneratorRuntime().wrap((function _callee5$(a){for(;;)switch(a.prev=a.next){case 0:return a.next=2,r._cycleLayout(t);case 2:case"end":return a.stop()}}),_callee5)})));return function(r){return t.apply(this,arguments)}}()),t.find(".itdarkness input").change((function(t){return r.changeDarkness(t)}));var o=this,i=function fn(t){return o.filterButtons(t),!1};t.find(".filterable").hover((function(){$(document).keydown(i)}),(function(){$(document).unbind("keydown",i)})),t.find(".quantity-click").mousedown((function(t){return y.Z.quantityClick(t)})),t.on("mousedown","li",function(){var t=tokenHotbar2_asyncToGenerator(tokenHotbar2_regeneratorRuntime().mark((function _callee6(t){return tokenHotbar2_regeneratorRuntime().wrap((function _callee6$(a){for(;;)switch(a.prev=a.next){case 0:return t.stopPropagation(),a.next=3,r.executeQuickButton(t);case 3:return a.abrupt("return",!1);case 4:case"end":return a.stop()}}),_callee6)})));return function(r){return t.apply(this,arguments)}}()),t.on("mouseenter","li.primary",(function(a){var o=a.currentTarget.dataset.category;r.category=o,setTimeout((function(){t.find(".secondary").removeClass("shown"),o==r.category&&t.find('.secondary[data-category="'.concat(o,'"]')).addClass("shown")}),700)})),t.on("mouseleave","li.primary",(function(a){var i=a.currentTarget.dataset.category;r.category=void 0,setTimeout((function(){i!=r.category&&(o.searching="",$(a.currentTarget).find(".secondary").removeClass("dsahidden"),t.find('.secondary[data-category="'.concat(i,'"]')).removeClass("shown"))}),50)}))}},{key:"handleEffect",value:(_=tokenHotbar2_asyncToGenerator(tokenHotbar2_regeneratorRuntime().mark((function _callee7(t,r,a,o){var i,c;return tokenHotbar2_regeneratorRuntime().wrap((function _callee7$(o){for(;;)switch(o.prev=o.next){case 0:if(i=r.effects.get(a),c=_toConsumableArray(i.statuses)[0],0!=t.button){o.next=11;break}if(!c){o.next=8;break}return o.next=6,r.addCondition(c,1,!1,!1);case 6:o.next=9;break;case 8:i.sheet.render(!0);case 9:o.next=19;break;case 11:if(2!=t.button){o.next=19;break}if(!c){o.next=17;break}return o.next=15,r.removeCondition(c,1,!1);case 15:o.next=19;break;case 17:return o.next=19,r.sheet._deleteActiveEffect(a);case 19:return o.next=21,this.render(!0);case 21:case"end":return o.stop()}}),_callee7,this)}))),function handleEffect(t,r,a,o){return _.apply(this,arguments)})},{key:"handleGMRoll",value:(v=tokenHotbar2_asyncToGenerator(tokenHotbar2_regeneratorRuntime().mark((function _callee8(t){var r,a;return tokenHotbar2_regeneratorRuntime().wrap((function _callee8$(o){for(;;)switch(o.prev=o.next){case 0:r=t.currentTarget.dataset.id,a=Math.round($(t.currentTarget).closest(".tokenHotbarInner").find(".modifierVal").val()),t.ctrlKey?game.dsa5.apps.DSA5ChatListeners.check3D20(void 0,r,{modifier:a}):2==t.button?game.dsa5.macro.requestGC(r,a,{maxRolls:7}):game.dsa5.macro.requestRoll(r,a);case 3:case"end":return o.stop()}}),_callee8)}))),function handleGMRoll(t){return v.apply(this,arguments)})},{key:"handleSkillRoll",value:(m=tokenHotbar2_asyncToGenerator(tokenHotbar2_regeneratorRuntime().mark((function _callee10(t,r,a,o){var i,c,u=this;return tokenHotbar2_regeneratorRuntime().wrap((function _callee10$(l){for(;;)switch(l.prev=l.next){case 0:if(i={},2==t.button&&(i.rollMode="blindroll"),"rideLoyaltyID"!=a){l.next=6;break}b.Z.rollLoyalty(r,i),l.next=25;break;case 6:if("attackWeaponless"!=a){l.next=10;break}r.setupWeaponless("attack",i,o).then((function(t){r.basicTest(t)})),l.next=25;break;case 10:if(!(c=r.items.get(a))){l.next=25;break}if(!t.originalEvent.ctrlKey){l.next=14;break}return l.abrupt("return",c.sheet.render(!0));case 14:l.t0=c.type,l.next="meleeweapon"===l.t0||"rangeweapon"===l.t0||"trait"===l.t0?17:"liturgy"===l.t0||"spell"===l.t0?19:"skill"===l.t0?21:"consumable"===l.t0?23:25;break;case 17:return r.setupWeapon(c,"attack",i,o).then((function(t){r.basicTest(t)})),l.abrupt("break",25);case 19:return r.setupSpell(c,i,o).then((function(t){r.basicTest(t)})),l.abrupt("break",25);case 21:return r.setupSkill(c,i,o).then((function(t){r.basicTest(t)})),l.abrupt("break",25);case 23:return new Dialog({title:game.i18n.localize("SHEET.ConsumeItem")+": "+c.name,content:game.i18n.localize("SHEET.ConsumeItem")+": "+c.name,default:"yes",buttons:{Yes:{icon:'',label:game.i18n.localize("yes"),callback:function(){var t=tokenHotbar2_asyncToGenerator(tokenHotbar2_regeneratorRuntime().mark((function _callee9(){return tokenHotbar2_regeneratorRuntime().wrap((function _callee9$(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,c.setupEffect(null,{},o);case 2:return t.next=4,u.updateDSA5Hotbar();case 4:case"end":return t.stop()}}),_callee9)})));return function callback(){return t.apply(this,arguments)}}()},cancel:{icon:'',label:game.i18n.localize("cancel")}}}).render(!0),l.abrupt("break",25);case 25:case"end":return l.stop()}}),_callee10)}))),function handleSkillRoll(t,r,a,o){return m.apply(this,arguments)})},{key:"handleOnUse",value:(p=tokenHotbar2_asyncToGenerator(tokenHotbar2_regeneratorRuntime().mark((function _callee11(t,r,a,o){var i;return tokenHotbar2_regeneratorRuntime().wrap((function _callee11$(t){for(;;)switch(t.prev=t.next){case 0:i=r.items.get(a),new g.Z(i).executeOnUseEffect();case 3:case"end":return t.stop()}}),_callee11)}))),function handleOnUse(t,r,a,o){return p.apply(this,arguments)})},{key:"handleGM",value:(l=tokenHotbar2_asyncToGenerator(tokenHotbar2_regeneratorRuntime().mark((function _callee12(r,a,o,i){return tokenHotbar2_regeneratorRuntime().wrap((function _callee12$(c){for(;;)switch(c.prev=c.next){case 0:c.t0=o,c.next="masterMenu"===c.t0?3:"payMoney"===c.t0?5:"randomVictim"===c.t0?7:9;break;case 3:return t.Z.renderToggle(game.dsa5.apps.gameMasterMenu),c.abrupt("break",10);case 5:return this.payMoney(r),c.abrupt("break",10);case 7:return this.handleGMRandomVictim(r),c.abrupt("break",10);case 9:o in this.callbackFunctions&&this.callbackFunctions[o](r,a,o,i);case 10:case"end":return c.stop()}}),_callee12,this)}))),function handleGM(t,r,a,o){return l.apply(this,arguments)})},{key:"payMoney",value:function payMoney(t){var r="".concat($(t.currentTarget).closest(".tokenHotbarInner").find(".modifierVal").val());2==t.button?w.createGetPaidChatMessage(r):w.createPayChatMessage(r)}},{key:"handleGMRandomVictim",value:(u=tokenHotbar2_asyncToGenerator(tokenHotbar2_regeneratorRuntime().mark((function _callee13(r){var a,o,i;return tokenHotbar2_regeneratorRuntime().wrap((function _callee13$(c){for(;;)switch(c.prev=c.next){case 0:return c.next=2,game.dsa5.apps.gameMasterMenu.rollRandomPlayer(2==r.button);case 2:if(a=c.sent,!(o=game.actors.get(a))){c.next=9;break}return c.next=7,t.Z.showArtwork(o);case 7:i=c.sent,r.originalEvent.ctrlKey||setTimeout((function(){i.close()}),2e3);case 9:case"end":return c.stop()}}),_callee13)}))),function handleGMRandomVictim(t){return u.apply(this,arguments)})},{key:"executeQuickButton",value:(c=tokenHotbar2_asyncToGenerator(tokenHotbar2_regeneratorRuntime().mark((function _callee14(t){var r,a,o,i,c,u;return tokenHotbar2_regeneratorRuntime().wrap((function _callee14$(l){for(;;)switch(l.prev=l.next){case 0:o=null===(r=canvas.tokens.controlled[0])||void 0===r?void 0:r.actor,i=null===(a=canvas.tokens.controlled[0])||void 0===a?void 0:a.id,c=t.currentTarget.dataset.id,u=t.currentTarget.dataset.subfunction,l.t0=u,l.next="addEffect"===l.t0?7:"effect"===l.t0?9:"onUse"===l.t0?11:"gm"===l.t0?13:"none"===l.t0||"darkness"===l.t0?15:"skillgm"===l.t0?16:18;break;case 7:return S.showDialog(),l.abrupt("break",19);case 9:return this.handleEffect(t,o,c,i),l.abrupt("break",19);case 11:return this.handleOnUse(t,o,c,i),l.abrupt("break",19);case 13:return this.handleGM(t,o,c,i),l.abrupt("break",19);case 15:return l.abrupt("break",19);case 16:return this.handleGMRoll(t),l.abrupt("break",19);case 18:this.handleSkillRoll(t,o,c,i);case 19:case"end":return l.stop()}}),_callee14,this)}))),function executeQuickButton(t){return c.apply(this,arguments)})},{key:"subWidth",value:function subWidth(t,r){var a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:7;return'style="width:'.concat(200*Math.ceil(t.length/a),'px"')}},{key:"getData",value:(i=tokenHotbar2_asyncToGenerator(tokenHotbar2_regeneratorRuntime().mark((function _callee15(){var t,r,a,o,i,c,u,l,p,h,m,y,g,v,_,k,w,x,S,T,A,O,P,E,C,D,I,R,L,G,M,j,z,N,H,$,Z,W=this;return tokenHotbar2_regeneratorRuntime().wrap((function _callee15$(B){for(;;)switch(B.prev=B.next){case 0:return B.next=2,tokenHotbar2_get(tokenHotbar2_getPrototypeOf(TokenHotbar2.prototype),"getData",this).call(this);case 2:if(r=B.sent,a=this.actor,o={attacks:[],spells:[],default:[],skills:[],gm:[]},u=[],l=[],p=[],h=game.settings.get("dsa5","tokenhotbarLayout"),m=h%2,y=TokenHotbar2.defaultOptions.itemWidth,g=["liturgy","spell"],v=!1,!a){B.next=30;break}return _=[],k=[],w=b.Z.isRiding(a),x=game.i18n.localize("LocalizedIDs.riding"),B.next=20,a.actorEffects();case 20:if(p=B.sent.map((function(t){return{name:t.name,id:t.id,icon:t.icon,cssClass:"effect",abbrev:"".concat(t.name[0]," ").concat(t.getFlag("dsa5","value")||""),subfunction:"effect"}})),game.combat){S=a.items.filter((function(t){return"combatskill"==t.type})).map((function(t){return d.Z._calculateCombatSkillValues(t.toObject(),a.system)})),T=S.find((function(t){return t.name==game.i18n.localize("LocalizedIDs.wrestle")})),T&&o.attacks.push({name:game.i18n.localize("attackWeaponless"),id:"attackWeaponless",icon:"systems/dsa5/icons/categories/attack_weaponless.webp",attack:T.system.attack.value,damage:"1d6"}),A=["meleeweapon","rangeweapon"],O=["meleeAttack","rangeAttack"],P=tokenHotbar2_createForOfIteratorHelper(a.items);try{for(C=function _loop(){var t=E.value;if(["skill"].includes(t.type)&&(W.combatSkills.some((function(r){return t.name.startsWith(r)}))||w&&x==t.name)&&o.default.push({name:"".concat(t.name," (").concat(t.system.talentValue.value,")"),id:t.id,icon:t.img,cssClass:"skill filterable",abbrev:t.name[0]}),"trait"==t.type&&O.includes(t.system.traitType.value)){var r=d.Z._parseDmg(t.toObject());o.attacks.push({name:t.name,id:t.id,icon:t.img,cssClass:"weapon ".concat(t.id),abbrev:t.name[0],attack:t.system.at.value,damage:r.damagedie,dadd:r.damageAdd})}else if(A.includes(t.type)&&1==t.system.worn.value){var i="meleeweapon"==t.type?d.Z._prepareMeleeWeapon(t.toObject(),S,a):d.Z._prepareRangeWeapon(t.toObject(),[],S,a);o.attacks.push({name:t.name,id:t.id,icon:t.img,cssClass:"weapon ".concat(t.id),abbrev:t.name[0],attack:i.attack,damage:i.damagedie,dadd:i.damageAdd})}else if(g.includes(t.type))t.system.effectFormula.value?o.spells.push({name:t.name,id:t.id,icon:t.img,cssClass:"spell",abbrev:t.name[0]}):k.push({name:t.name,id:t.id,icon:t.img,cssClass:"spell",abbrev:t.name[0]});else if(["skill"].includes(t.type)){var c={name:"".concat(t.name," (").concat(t.system.talentValue.value,")"),id:t.id,icon:t.img,cssClass:"skill",addClass:t.system.group.value,abbrev:t.name[0],tw:t.system.talentValue.value};_.push(c)}else"consumable"==t.type&&u.push({name:t.name,id:t.id,icon:t.img,cssClass:"consumable",abbrev:t.system.quantity.value});t.getFlag("dsa5","onUseEffect")&&l.push({name:t.name,id:t.id,icon:t.img,cssClass:"onUse",abbrev:t.name[0],subfunction:"onUse"})},P.s();!(E=P.n()).done;)C()}catch(t){P.e(t)}finally{P.f()}i=u.pop(),w&&(D=b.Z.getHorse(a))&&(I=b.Z.getLoyaltyFromHorse(D))&&o.default.push({name:"".concat(I.name," (").concat(I.system.talentValue.value,")"),id:"rideLoyaltyID",icon:I.img,cssClass:"skill",abbrev:I.name[0]})}else{L=[],G=tokenHotbar2_createForOfIteratorHelper(a.items);try{for(G.s();!(M=G.n()).done;)j=M.value,["skill"].includes(j.type)&&(this.defaultSkills.includes(j.name)||w&&x==j.name)&&o.default.push({name:"".concat(j.name," (").concat(j.system.talentValue.value,")"),id:j.id,icon:j.img,cssClass:"skill filterable",abbrev:j.name[0]}),["skill"].includes(j.type)?(z={name:"".concat(j.name," (").concat(j.system.talentValue.value,")"),id:j.id,icon:j.img,cssClass:"skill",addClass:j.system.group.value,abbrev:j.name[0],tw:j.system.talentValue.value},j.system.talentValue.value>0&&(z.cssClass+=" filterable",L.push(z)),_.push(z)):g.includes(j.type)&&(j.system.effectFormula.value?o.spells.push({name:j.name,id:j.id,icon:j.img,cssClass:"spell",abbrev:j.name[0]}):k.push({name:j.name,id:j.id,icon:j.img,cssClass:"spell",abbrev:j.name[0]})),j.getFlag("dsa5","onUseEffect")&&l.push({name:j.name,id:j.id,icon:j.img,cssClass:"onUse",abbrev:j.name[0],subfunction:"onUse"})}catch(t){G.e(t)}finally{G.f()}(R=o.skills).push.apply(R,_toConsumableArray(L.sort((function(t,r){return r.tw-t.tw})).slice(0,5)))}c=l.pop(),0==o.spells.length&&k.length>0&&o.spells.push(k.pop()),o.spells.length>0&&k.length>0&&(o.spells[0].more=k.sort((function(t,r){return t.name.localeCompare(r.name)})),o.spells[0].subwidth=this.subWidth(k,y)),o.default.length>0&&_.length>0&&(o.default[0].more=_.sort((function(t,r){return t.addClass.localeCompare(r.addClass)||t.name.localeCompare(r.name)})),o.default[0].subwidth=this.subWidth(_,y,20)),i&&(u.length>0&&(i.more=u,i.subwidth=this.subWidth(u,y)),o.consumables=[i]),c&&(l.length>0&&(c.more=l,c.subwidth=this.subWidth(l,y)),o.onUsages=[c]),B.next=39;break;case 30:if(!game.user.isGM||game.settings.get("dsa5","disableTokenhotbarMaster")){B.next=39;break}if(v=!0,B.t0=this.skills,B.t0){B.next=37;break}return B.next=36,this.prepareSkills();case 36:B.t0=B.sent;case 37:N=B.t0,o.gm=this.gmItems.filter((function(t){return!t.disabled})).concat([{name:"TT.tokenhotbarSkill",id:"skillgm",icon:"systems/dsa5/icons/categories/Skill.webp",cssClass:"skillgm filterable",abbrev:"",subfunction:"none",more:N,subwidth:this.subWidth(N,y,20)}]);case 39:return this.showEffects&&(H=game.i18n.localize("CONDITION.add"),$={name:"CONDITION.add",id:"",icon:"icons/svg/aura.svg",cssClass:"effect",abbrev:H[0],subfunction:"addEffect"},p.length>0&&($.more=p,$.subwidth=this.subWidth(p,y)),o.effects=[$]),Z=Object.keys(o).reduce((function(t,r){return t+o[r].length}),0)+(v?3:0),m?(this.position.width=y,this.position.height=y*Z+14):(this.position.width=y*Z+14,this.position.height=y),mergeObject(r,{items:o,itemWidth:y,direction:h,count:Z,gmMode:v,darkness:(null===(t=canvas.scene)||void 0===t?void 0:t.darkness)||0,opacity:game.settings.get("dsa5","tokenhotbaropacity")}),B.abrupt("return",r);case 44:case"end":return B.stop()}}),_callee15,this)}))),function getData(){return i.apply(this,arguments)})},{key:"filterButtons",value:function filterButtons(t){switch(t.which){case 17:return;case 8:this.searching=this.searching.slice(0,-1);break;default:this.searching+=String.fromCharCode(t.which)}t.preventDefault(),t.stopPropagation();var r=this.searching.toLowerCase();(0,h.p0)(r);var a=$(t.currentTarget).find(".subbuttons li");a.find(".dsahidden").removeClass("dsahidden"),a.filter((function(){return-1==$(this).find("label").text().toLowerCase().trim().indexOf(r)})).addClass("dsahidden")}},{key:"render",value:(o=tokenHotbar2_asyncToGenerator(tokenHotbar2_regeneratorRuntime().mark((function _callee16(t){var r,a,o=arguments;return tokenHotbar2_regeneratorRuntime().wrap((function _callee16$(i){for(;;)switch(i.prev=i.next){case 0:return r=o.length>1&&void 0!==o[1]?o[1]:{},i.next=3,tokenHotbar2_get(tokenHotbar2_getPrototypeOf(TokenHotbar2.prototype),"render",this).call(this,t,r);case 3:return a=i.sent,this._element&&this._element.css({zIndex:61}),i.abrupt("return",a);case 6:case"end":return i.stop()}}),_callee16,this)}))),function render(t){return o.apply(this,arguments)})},{key:"setPosition",value:function setPosition(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=t.left,a=t.top,o=t.width,i=t.height,c=t.scale,u=tokenHotbar2_get(tokenHotbar2_getPrototypeOf(TokenHotbar2.prototype),"setPosition",this).call(this,{left:r,top:a,width:o,height:i,scale:c}),l=this.element[0];if(!l.style.width||o){var p=o||l.offsetWidth,d=l.style.maxWidth||window.innerWidth;u.width=o=Math.clamped(p,0,d),l.style.width=o+"px",o+u.left>window.innerWidth&&(r=u.left)}return game.settings.set("dsa5","tokenhotbarPosition",{left:u.left,top:u.top}),u}},{key:"updateDSA5Hotbar",value:(a=tokenHotbar2_asyncToGenerator(tokenHotbar2_regeneratorRuntime().mark((function _callee17(){var t,r;return tokenHotbar2_regeneratorRuntime().wrap((function _callee17$(a){for(;;)switch(a.prev=a.next){case 0:return t=canvas.tokens.controlled,this.actor=void 0,this.showEffects=!1,1===t.length&&(r=t[0].actor)&&r.isOwner&&(this.actor=r),t.length>=1&&(this.showEffects=!0),a.next=7,this.render(!0,{focus:!1});case 7:case"end":return a.stop()}}),_callee17,this)}))),function updateDSA5Hotbar(){return a.apply(this,arguments)})}],[{key:"registerTokenHotbar",value:function registerTokenHotbar(){game.dsa5.apps.tokenHotbar||(game.dsa5.apps.tokenHotbar=new TokenHotbar2,game.dsa5.apps.tokenHotbar.render(!0),Hooks.call("dsa5TokenHotbarReady",game.dsa5.apps.tokenHotbar))}},{key:"unregisterTokenHotbar",value:function unregisterTokenHotbar(){game.dsa5.apps.tokenHotbar&&(game.dsa5.apps.tokenHotbar.close(),game.dsa5.apps.tokenHotbar=void 0)}},{key:"hookUpdate",value:function hookUpdate(t){game.dsa5.apps.tokenHotbar&&t==getProperty(game.dsa5.apps.tokenHotbar,"actor.id")&&game.dsa5.apps.tokenHotbar.updateDSA5Hotbar()}},{key:"defaultOptions",get:function get(){var t=tokenHotbar2_get(tokenHotbar2_getPrototypeOf(TokenHotbar2),"defaultOptions",this),r=$("#hotbar").first().position(),a=game.settings.get("dsa5","tokenhotbarSize"),o=game.settings.get("dsa5","tokenhotbarPosition");return mergeObject(t,{classes:t.classes.concat(["dsa5","tokenQuickHot"]),itemWidth:a,resizable:!1,height:a+45,zIndex:61,left:r.left+8,top:r.top-a-25,template:"systems/dsa5/templates/status/tokenHotbar.html",title:"TokenHotbar"}),mergeObject(t,o),t}}]),TokenHotbar2}(),S=function(t){tokenHotbar2_inherits(AddEffectDialog,Dialog);var r,a,o,i,c=tokenHotbar2_createSuper(AddEffectDialog);function AddEffectDialog(){return tokenHotbar2_classCallCheck(this,AddEffectDialog),c.apply(this,arguments)}return tokenHotbar2_createClass(AddEffectDialog,[{key:"activateListeners",value:function activateListeners(t){var r=this;tokenHotbar2_get(tokenHotbar2_getPrototypeOf(AddEffectDialog.prototype),"activateListeners",this).call(this,t),t.find(".reactClick").mouseenter((function(t){if(0==t.currentTarget.getElementsByClassName("hovermenu").length){var a=document.createElement("div");a.classList.add("hovermenu"),a.style.cssText="font-size: var(--font-size-20);";var o=document.createElement("i");o.classList.add("fas","fa-cogs"),o.title=game.i18n.localize("ActiveEffects.custom"),o.addEventListener("click",function(){var t=tokenHotbar2_asyncToGenerator(tokenHotbar2_regeneratorRuntime().mark((function _callee18(t){return tokenHotbar2_regeneratorRuntime().wrap((function _callee18$(a){for(;;)switch(a.prev=a.next){case 0:return a.abrupt("return",r.configureEffect(t));case 1:case"end":return a.stop()}}),_callee18)})));return function(r){return t.apply(this,arguments)}}(),!1),a.appendChild(o),t.currentTarget.appendChild(a)}})),t.find(".reactClick").mouseleave((function(t){var a=t.toElement||t.relatedTarget;a.parentNode!=r&&a!=r&&t.currentTarget.querySelectorAll(".hovermenu").forEach((function(t){return t.remove()}))})),t.find(".quantity-click").mousedown((function(t){return y.Z.quantityClick(t)})),t.find(".reactClick").click((function(t){return r.addEffect(t.currentTarget.dataset.value)}));var a=t.find(".conditionSearch");a.keyup((function(a){return r._filterConditions($(a.currentTarget),t)})),a[0]&&a[0].addEventListener("search",(function filterConditions(a){return r._filterConditions($(a.currentTarget),t)}),!1)}},{key:"_filterConditions",value:function _filterConditions(t,r){if(null!=t.val()){var a=t.val().toLowerCase().trim(),o=r.find(".filterable");r.find(".filterHide").removeClass("filterHide"),o.filter((function(){return-1==$(this).find("span").text().toLowerCase().trim().indexOf(a)})).addClass("filterHide")}}},{key:"configureEffect",value:(i=tokenHotbar2_asyncToGenerator(tokenHotbar2_regeneratorRuntime().mark((function _callee20(t){var r,a,o=this;return tokenHotbar2_regeneratorRuntime().wrap((function _callee20$(i){for(;;)switch(i.prev=i.next){case 0:t.stopPropagation(),r=$(t.currentTarget).closest(".reactClick"),a=r.attr("data-value"),this.close(),AddEffectDialog.modifyEffectDialog(a,function(){var t=tokenHotbar2_asyncToGenerator(tokenHotbar2_regeneratorRuntime().mark((function _callee19(t,r){return tokenHotbar2_regeneratorRuntime().wrap((function _callee19$(a){for(;;)switch(a.prev=a.next){case 0:return a.abrupt("return",o.addEffect(t,r));case 1:case"end":return a.stop()}}),_callee19)})));return function(r,a){return t.apply(this,arguments)}}());case 5:case"end":return i.stop()}}),_callee20,this)}))),function configureEffect(t){return i.apply(this,arguments)})},{key:"addEffect",value:(o=tokenHotbar2_asyncToGenerator(tokenHotbar2_regeneratorRuntime().mark((function _callee21(t){var r,a,o,i,c,u=arguments;return tokenHotbar2_regeneratorRuntime().wrap((function _callee21$(l){for(;;)switch(l.prev=l.next){case 0:a=u.length>1&&void 0!==u[1]?u[1]:{},o=tokenHotbar2_createForOfIteratorHelper(canvas.tokens.controlled),l.prev=2,o.s();case 4:if((i=o.n()).done){l.next=10;break}return c=i.value,l.next=8,c.actor.addTimedCondition(t,1,!1,!1,a);case 8:l.next=4;break;case 10:l.next=15;break;case 12:l.prev=12,l.t0=l.catch(2),o.e(l.t0);case 15:return l.prev=15,o.f(),l.finish(15);case 18:null===(r=game.dsa5.apps.tokenHotbar)||void 0===r||r.render(!0),this.close();case 20:case"end":return l.stop()}}),_callee21,this,[[2,12,15,18]])}))),function addEffect(t){return o.apply(this,arguments)})}],[{key:"showDialog",value:(a=tokenHotbar2_asyncToGenerator(tokenHotbar2_regeneratorRuntime().mark((function _callee22(){var t,r;return tokenHotbar2_regeneratorRuntime().wrap((function _callee22$(a){for(;;)switch(a.prev=a.next){case 0:return t=duplicate(CONFIG.statusEffects).map((function(t){return{name:game.i18n.localize(t.name),icon:t.icon,description:game.i18n.localize(t.description),id:t.id}})).sort((function(t,r){return t.name.localeCompare(r.name)})),a.t0=AddEffectDialog,a.t1=game.i18n.localize("CONDITION.add"),a.next=5,renderTemplate("systems/dsa5/templates/dialog/addstatusdialog.html",{effects:t});case 5:a.t2=a.sent,a.t3={},a.t4={title:a.t1,content:a.t2,buttons:a.t3},(r=new a.t0(a.t4)).position.height=36*Math.ceil(t.length/3)+170,r.render(!0);case 11:case"end":return a.stop()}}),_callee22)}))),function showDialog(){return a.apply(this,arguments)})},{key:"modifyEffectDialog",value:(r=tokenHotbar2_asyncToGenerator(tokenHotbar2_regeneratorRuntime().mark((function _callee24(t,r){return tokenHotbar2_regeneratorRuntime().wrap((function _callee24$(a){for(;;)switch(a.prev=a.next){case 0:return a.t0=AddEffectDialog,a.t1=game.i18n.localize("CONDITION."+t),a.next=4,renderTemplate("systems/dsa5/templates/dialog/configurestatusdialog.html");case 4:a.t2=a.sent,a.t3={add:{icon:'',label:game.i18n.localize("CONDITION.add"),callback:function(){var a=tokenHotbar2_asyncToGenerator(tokenHotbar2_regeneratorRuntime().mark((function _callee23(a){var o,i,c;return tokenHotbar2_regeneratorRuntime().wrap((function _callee23$(u){for(;;)switch(u.prev=u.next){case 0:return o={},i="seconds"==a.find("[name=unit]:checked").val()?Math.round(a.find(".duration").val()/5):a.find(".duration").val(),c=a.find(".effectname").val(),i>0&&mergeObject(o,y.Z._buildDuration(i)),c&&(o.name=c),u.next=7,r(t,o);case 7:case"end":return u.stop()}}),_callee23)})));return function callback(t){return a.apply(this,arguments)}}()}},a.t4={title:a.t1,content:a.t2,default:"add",buttons:a.t3},new a.t0(a.t4).render(!0,{width:400,resizable:!1,classes:["dsa5","dialog"]});case 8:case"end":return a.stop()}}),_callee24)}))),function modifyEffectDialog(t,a){return r.apply(this,arguments)})},{key:"defaultOptions",get:function get(){var t=tokenHotbar2_get(tokenHotbar2_getPrototypeOf(AddEffectDialog),"defaultOptions",this);return mergeObject(t,{classes:["dsa5","tokenStatusEffects"],width:700,resizable:!0}),t}}]),AddEffectDialog}();function actor_sheet_typeof(t){return actor_sheet_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},actor_sheet_typeof(t)}function actor_sheet_toConsumableArray(t){return function actor_sheet_arrayWithoutHoles(t){if(Array.isArray(t))return actor_sheet_arrayLikeToArray(t)}(t)||function actor_sheet_iterableToArray(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||actor_sheet_unsupportedIterableToArray(t)||function actor_sheet_nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function actor_sheet_defineProperty(t,r,a){return r in t?Object.defineProperty(t,r,{value:a,enumerable:!0,configurable:!0,writable:!0}):t[r]=a,t}function actor_sheet_createForOfIteratorHelper(t,r){var a="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!a){if(Array.isArray(t)||(a=actor_sheet_unsupportedIterableToArray(t))||r&&t&&"number"==typeof t.length){a&&(t=a);var o=0,i=function F(){};return{s:i,n:function n(){return o>=t.length?{done:!0}:{done:!1,value:t[o++]}},e:function e(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var c,u=!0,l=!1;return{s:function s(){a=a.call(t)},n:function n(){var t=a.next();return u=t.done,t},e:function e(t){l=!0,c=t},f:function f(){try{u||null==a.return||a.return()}finally{if(l)throw c}}}}function actor_sheet_unsupportedIterableToArray(t,r){if(t){if("string"==typeof t)return actor_sheet_arrayLikeToArray(t,r);var a=Object.prototype.toString.call(t).slice(8,-1);return"Object"===a&&t.constructor&&(a=t.constructor.name),"Map"===a||"Set"===a?Array.from(t):"Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a)?actor_sheet_arrayLikeToArray(t,r):void 0}}function actor_sheet_arrayLikeToArray(t,r){(null==r||r>t.length)&&(r=t.length);for(var a=0,o=new Array(r);a=0;--o){var i=this.tryEntries[o],c=i.completion;if("root"===i.tryLoc)return handle("end");if(i.tryLoc<=this.prev){var u=a.call(i,"catchLoc"),l=a.call(i,"finallyLoc");if(u&&l){if(this.prev=0;--o){var i=this.tryEntries[o];if(i.tryLoc<=this.prev&&a.call(i,"finallyLoc")&&this.prev=0;--r){var a=this.tryEntries[r];if(a.finallyLoc===t)return this.complete(a.completion,a.afterLoc),resetTryEntry(a),l}},catch:function _catch(t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc===t){var o=a.completion;if("throw"===o.type){var i=o.arg;resetTryEntry(a)}return i}}throw new Error("illegal catch attempt")},delegateYield:function delegateYield(t,r,a){return this.delegate={iterator:values(t),resultName:r,nextLoc:a},"next"===this.method&&(this.arg=void 0),l}},t}function actor_sheet_asyncGeneratorStep(t,r,a,o,i,c,u){try{var l=t[c](u),p=l.value}catch(t){return void a(t)}l.done?r(p):Promise.resolve(p).then(o,i)}function actor_sheet_asyncToGenerator(t){return function(){var r=this,a=arguments;return new Promise((function(o,i){var c=t.apply(r,a);function _next(t){actor_sheet_asyncGeneratorStep(c,o,i,_next,_throw,"next",t)}function _throw(t){actor_sheet_asyncGeneratorStep(c,o,i,_next,_throw,"throw",t)}_next(void 0)}))}}function actor_sheet_classCallCheck(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}function actor_sheet_defineProperties(t,r){for(var a=0;a0&&void 0!==l[0]&&l[0],r=l.length>1&&void 0!==l[1]?l[1]:{},this._saveSearchFields(),this._saveCollapsed(),p.next=6,actor_sheet_get(actor_sheet_getPrototypeOf(ActorSheetDsa5.prototype),"_render",this).call(this,t,r);case 6:for(this._setCollapsed(),this._restoreSeachFields(),a=$(this._element),o={".close":"SHEET.Close",".configure-sheet":"SHEET.Configure",".configure-token":"SHEET.Token",".import":"SHEET.Import",".locksheet":"SHEET.Lock",".library":"SHEET.Library",".playerview":"SHEET.switchLimited",".actorConfig":"SHEET.actorConfig"},i=0,c=Object.keys(o);i'.concat(game.i18n.localize("TYPES.Item.aggregatedTest"),"");i.system.usedTestCount.value>=i.system.allowedTestCount.value?(l+="".concat(game.i18n.localize("Aggregated.noMoreAllowed")),ChatMessage.create(t.Z.chatDataSetup(l))):this.actor.setupSkill(u,{moreModifiers:[{name:game.i18n.localize("failedTests"),value:-1*i.system.previousFailedTests.value,selected:!0},{name:game.i18n.localize("Modifier"),value:i.system.baseModifier,selected:!0}]},this.getTokenId()).then((function(t){a.actor.basicTest(t).then((function(t){t.result.successLevel>0?(i.system.cummulatedQS.value=t.result.qualityStep+i.system.cummulatedQS.value,i.system.cummulatedQS.value=Math.min(10,i.system.cummulatedQS.value)):i.system.previousFailedTests.value+=1,i.system.usedTestCount.value+=1,a.actor.updateEmbeddedDocuments("Item",[i]).then((function(){var t=a.actor.items.get(o);t.postItem(),i.system.cummulatedQS.value>=10&&t.sheet.postFinishedItem()}))}))}))}},{key:"consumeItem",value:(de=actor_sheet_asyncToGenerator(actor_sheet_regeneratorRuntime().mark((function _callee3(t){var r=this;return actor_sheet_regeneratorRuntime().wrap((function _callee3$(a){for(;;)switch(a.prev=a.next){case 0:new Dialog({title:game.i18n.localize("SHEET.ConsumeItem")+": "+t.name,content:game.i18n.localize("SHEET.ConsumeItem")+": "+t.name,default:"yes",buttons:{Yes:{icon:'',label:game.i18n.localize("yes"),callback:function callback(){t.setupEffect(null,{},r.getTokenId())}},cancel:{icon:'',label:game.i18n.localize("cancel")}}}).render(!0);case 1:case"end":return a.stop()}}),_callee3)}))),function consumeItem(t){return de.apply(this,arguments)})},{key:"_advanceAttribute",value:(pe=actor_sheet_asyncToGenerator(actor_sheet_regeneratorRuntime().mark((function _callee4(r){var a,o;return actor_sheet_regeneratorRuntime().wrap((function _callee4$(i){for(;;)switch(i.prev=i.next){case 0:return a=Number(this.actor.system.characteristics[r].advances)+Number(this.actor.system.characteristics[r].initial),o=t.Z._calculateAdvCost(a,"E"),i.next=4,this._checkEnoughXP(o);case 4:if(!i.sent){i.next=7;break}return i.next=7,this._updateAPs(o,actor_sheet_defineProperty({},"system.characteristics.".concat(r,".advances"),Number(this.actor.system.characteristics[r].advances)+1));case 7:case"end":return i.stop()}}),_callee4,this)}))),function _advanceAttribute(t){return pe.apply(this,arguments)})},{key:"_refundAttributeAdvance",value:(fe=actor_sheet_asyncToGenerator(actor_sheet_regeneratorRuntime().mark((function _callee5(r){var a,o;return actor_sheet_regeneratorRuntime().wrap((function _callee5$(i){for(;;)switch(i.prev=i.next){case 0:if(a=Number(this.actor.system.characteristics[r].advances)+Number(this.actor.system.characteristics[r].initial),!(Number(this.actor.system.characteristics[r].advances)>0)){i.next=5;break}return o=-1*t.Z._calculateAdvCost(a,"E",0),i.next=5,this._updateAPs(o,actor_sheet_defineProperty({},"system.characteristics.".concat(r,".advances"),Number(this.actor.system.characteristics[r].advances)-1));case 5:case"end":return i.stop()}}),_callee5,this)}))),function _refundAttributeAdvance(t){return fe.apply(this,arguments)})},{key:"_rebuyPC",value:(le=actor_sheet_asyncToGenerator(actor_sheet_regeneratorRuntime().mark((function _callee6(t){return actor_sheet_regeneratorRuntime().wrap((function _callee6$(r){for(;;)switch(r.prev=r.next){case 0:if(!(this.actor.system.status[t].permanentLossSum>0)){r.next=6;break}return r.next=3,this._checkEnoughXP(2);case 3:if(!r.sent){r.next=6;break}return r.next=6,this._updateAPs(2,actor_sheet_defineProperty({},"system.status.".concat(t,".rebuy"),Number(this.actor.system.status[t].rebuy)+1));case 6:case"end":return r.stop()}}),_callee6,this)}))),function _rebuyPC(t){return le.apply(this,arguments)})},{key:"_refundPC",value:(ue=actor_sheet_asyncToGenerator(actor_sheet_regeneratorRuntime().mark((function _callee7(t){return actor_sheet_regeneratorRuntime().wrap((function _callee7$(r){for(;;)switch(r.prev=r.next){case 0:if(!(this.actor.system.status[t].rebuy>0)){r.next=3;break}return r.next=3,this._updateAPs(-2,actor_sheet_defineProperty({},"system.status.".concat(t,".rebuy"),Number(this.actor.system.status[t].rebuy)-1));case 3:case"end":return r.stop()}}),_callee7,this)}))),function _refundPC(t){return ue.apply(this,arguments)})},{key:"_advancePoints",value:(se=actor_sheet_asyncToGenerator(actor_sheet_regeneratorRuntime().mark((function _callee8(r){var a,o;return actor_sheet_regeneratorRuntime().wrap((function _callee8$(i){for(;;)switch(i.prev=i.next){case 0:return a=Number(this.actor.system.status[r].advances),o=t.Z._calculateAdvCost(a,"D"),i.next=4,this._checkEnoughXP(o);case 4:if(i.t0=i.sent,!i.t0){i.next=7;break}i.t0=this._checkMaximumPointAdvancement(r,a+1);case 7:if(!i.t0){i.next=10;break}return i.next=10,this._updateAPs(o,actor_sheet_defineProperty({},"system.status.".concat(r,".advances"),Number(this.actor.system.status[r].advances)+1));case 10:case"end":return i.stop()}}),_callee8,this)}))),function _advancePoints(t){return se.apply(this,arguments)})},{key:"_refundPointsAdvance",value:(ce=actor_sheet_asyncToGenerator(actor_sheet_regeneratorRuntime().mark((function _callee9(r){var a,o;return actor_sheet_regeneratorRuntime().wrap((function _callee9$(i){for(;;)switch(i.prev=i.next){case 0:if(!((a=Number(this.actor.system.status[r].advances))>0)){i.next=5;break}return o=-1*t.Z._calculateAdvCost(a,"D",0),i.next=5,this._updateAPs(o,actor_sheet_defineProperty({},"system.status.".concat(r,".advances"),Number(this.actor.system.status[r].advances)-1));case 5:case"end":return i.stop()}}),_callee9,this)}))),function _refundPointsAdvance(t){return ce.apply(this,arguments)})},{key:"_advanceItem",value:(ie=actor_sheet_asyncToGenerator(actor_sheet_regeneratorRuntime().mark((function _callee10(r){var a,o,i;return actor_sheet_regeneratorRuntime().wrap((function _callee10$(c){for(;;)switch(c.prev=c.next){case 0:return o=this.actor.items.get(r).toObject(),i=t.Z._calculateAdvCost(Number(o.system.talentValue.value),o.system.StF.value),c.next=4,this._checkEnoughXP(i);case 4:if(c.t0=c.sent,!c.t0){c.next=7;break}c.t0=null!==(a=this.actor._checkMaximumItemAdvancement(o,Number(o.system.talentValue.value)+1))&&void 0!==a&&a.result;case 7:if(!c.t0){c.next=12;break}return c.next=10,this.actor.updateEmbeddedDocuments("Item",[{_id:r,"system.talentValue.value":o.system.talentValue.value+1}]);case 10:return c.next=12,this._updateAPs(i);case 12:case"end":return c.stop()}}),_callee10,this)}))),function _advanceItem(t){return ie.apply(this,arguments)})},{key:"_refundItemAdvance",value:(oe=actor_sheet_asyncToGenerator(actor_sheet_regeneratorRuntime().mark((function _callee11(r){var a,o,i;return actor_sheet_regeneratorRuntime().wrap((function _callee11$(c){for(;;)switch(c.prev=c.next){case 0:if(a=this.actor.items.get(r).toObject(),o="combatskill"==a.type?6:0,!(a.system.talentValue.value>o)){c.next=8;break}return i=-1*t.Z._calculateAdvCost(Number(a.system.talentValue.value),a.system.StF.value,0),c.next=6,this.actor.updateEmbeddedDocuments("Item",[{_id:r,"system.talentValue.value":a.system.talentValue.value-1}]);case 6:return c.next=8,this._updateAPs(i);case 8:case"end":return c.stop()}}),_callee11,this)}))),function _refundItemAdvance(t){return oe.apply(this,arguments)})},{key:"_checkMaximumPointAdvancement",value:function _checkMaximumPointAdvancement(t,r){var a=!1;switch(t){case"wounds":a=r<=this.actor.system.characteristics.ko.value;break;case"astralenergy":a=r<=(null==this.actor.system.characteristics[this.actor.system.guidevalue.magical]?0:this.actor.system.characteristics[this.actor.system.guidevalue.magical].value*this.actor.system.energyfactor.magical);break;case"karmaenergy":a=r<=(null==this.actor.system.characteristics[this.actor.system.guidevalue.clerical]?0:this.actor.system.characteristics[this.actor.system.guidevalue.clerical].value*this.actor.system.energyfactor.clerical)}return a||ui.notifications.error(game.i18n.localize("DSAError.AdvanceMaximumReached")),a}},{key:"_openLibrary",value:(ae=actor_sheet_asyncToGenerator(actor_sheet_regeneratorRuntime().mark((function _callee12(){return actor_sheet_regeneratorRuntime().wrap((function _callee12$(t){for(;;)switch(t.prev=t.next){case 0:game.dsa5.itemLibrary.render(!0);case 1:case"end":return t.stop()}}),_callee12)}))),function _openLibrary(){return ae.apply(this,arguments)})},{key:"_configActor",value:(ne=actor_sheet_asyncToGenerator(actor_sheet_regeneratorRuntime().mark((function _callee13(){return actor_sheet_regeneratorRuntime().wrap((function _callee13$(t){for(;;)switch(t.prev=t.next){case 0:p.buildDialog(this.actor);case 1:case"end":return t.stop()}}),_callee13,this)}))),function _configActor(){return ne.apply(this,arguments)})},{key:"_getHeaderButtons",value:function _getHeaderButtons(){var t,r,a,o,i=this,c=actor_sheet_get(actor_sheet_getPrototypeOf(ActorSheetDsa5.prototype),"_getHeaderButtons",this).call(this);return c.unshift({class:"library",icon:"fas fa-university",onclick:(t=actor_sheet_asyncToGenerator(actor_sheet_regeneratorRuntime().mark((function _callee14(){return actor_sheet_regeneratorRuntime().wrap((function _callee14$(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",i._openLibrary());case 1:case"end":return t.stop()}}),_callee14)}))),function onclick(){return t.apply(this,arguments)})}),this.actor.isOwner&&(c.unshift({class:"actorConfig",icon:"fas fa-link",onclick:(a=actor_sheet_asyncToGenerator(actor_sheet_regeneratorRuntime().mark((function _callee15(){return actor_sheet_regeneratorRuntime().wrap((function _callee15$(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",i._configActor());case 1:case"end":return t.stop()}}),_callee15)}))),function onclick(){return a.apply(this,arguments)})}),c.unshift({class:"playerview",icon:"fas fa-toggle-on",onclick:(r=actor_sheet_asyncToGenerator(actor_sheet_regeneratorRuntime().mark((function _callee16(t){return actor_sheet_regeneratorRuntime().wrap((function _callee16$(r){for(;;)switch(r.prev=r.next){case 0:return r.abrupt("return",i._togglePlayerview(t));case 1:case"end":return r.stop()}}),_callee16)}))),function onclick(t){return r.apply(this,arguments)})})),this.actor.system.canAdvance&&c.unshift({class:"locksheet",icon:"fas fa-".concat(this.actor.system.sheetLocked.value?"":"un","lock"),onclick:(o=actor_sheet_asyncToGenerator(actor_sheet_regeneratorRuntime().mark((function _callee17(t){return actor_sheet_regeneratorRuntime().wrap((function _callee17$(r){for(;;)switch(r.prev=r.next){case 0:return r.abrupt("return",i._changeAdvanceLock(t));case 1:case"end":return r.stop()}}),_callee17)}))),function onclick(t){return o.apply(this,arguments)})}),c}},{key:"_changeAdvanceLock",value:(re=actor_sheet_asyncToGenerator(actor_sheet_regeneratorRuntime().mark((function _callee18(t){return actor_sheet_regeneratorRuntime().wrap((function _callee18$(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,this.actor.update({"system.sheetLocked.value":!this.actor.system.sheetLocked.value});case 2:$(t.currentTarget).find("i").toggleClass("fa-unlock fa-lock");case 3:case"end":return r.stop()}}),_callee18,this)}))),function _changeAdvanceLock(t){return re.apply(this,arguments)})},{key:"_checkEnoughXP",value:(te=actor_sheet_asyncToGenerator(actor_sheet_regeneratorRuntime().mark((function _callee19(t){return actor_sheet_regeneratorRuntime().wrap((function _callee19$(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,this.actor.checkEnoughXP(t);case 2:return r.abrupt("return",r.sent);case 3:case"end":return r.stop()}}),_callee19,this)}))),function _checkEnoughXP(t){return te.apply(this,arguments)})},{key:"advanceWrapper",value:(ee=actor_sheet_asyncToGenerator(actor_sheet_regeneratorRuntime().mark((function _callee20(t,r,a){var o,i;return actor_sheet_regeneratorRuntime().wrap((function _callee20$(c){for(;;)switch(c.prev=c.next){case 0:if(o=$(t.currentTarget),(i=o.find("i")).hasClass("fa-spin")){c.next=7;break}return i.addClass("fa-spin fa-spinner"),c.next=6,this[r](a);case 6:i.removeClass("fa-spin fa-spinner");case 7:case"end":return c.stop()}}),_callee20,this)}))),function advanceWrapper(t,r,a){return ee.apply(this,arguments)})},{key:"playerViewEnabled",value:function playerViewEnabled(){return getProperty(this.actor.system,"playerView")}},{key:"_togglePlayerview",value:function _togglePlayerview(t){this.actor.update({"system.playerView":!getProperty(this.actor.system,"playerView")})}},{key:"showLimited",value:function showLimited(){return!game.user.isGM&&this.actor.limited||this.playerViewEnabled()}},{key:"getTokenId",value:function getTokenId(){var t;return null===(t=this.token)||void 0===t?void 0:t.id}},{key:"rollDisease",value:function rollDisease(t){var r=this,a=this.actor.items.get(t),o=-1*this.actor.system.status.soulpower.max,i=-1*this.actor.system.status.toughness.max;a.setupEffect(void 0,{rollMode:"gmroll",manualResistance:{SKModifier:o,ZKModifier:i}}).then(function(){var t=actor_sheet_asyncToGenerator(actor_sheet_regeneratorRuntime().mark((function _callee21(t){var o;return actor_sheet_regeneratorRuntime().wrap((function _callee21$(i){for(;;)switch(i.prev=i.next){case 0:return i.next=2,a.itemTest(t);case 2:return o=i.sent,i.next=5,r.actor.updateEmbeddedDocuments("Item",[{_id:a.id,"system.duration.resolved":o.result.duration}]);case 5:case"end":return i.stop()}}),_callee21)})));return function(r){return t.apply(this,arguments)}}())}},{key:"swapWeaponHand",value:(X=actor_sheet_asyncToGenerator(actor_sheet_regeneratorRuntime().mark((function _callee22(t){var r,a;return actor_sheet_regeneratorRuntime().wrap((function _callee22$(o){for(;;)switch(o.prev=o.next){case 0:if(r=this._getItemId(t),a=this.actor.items.get(r),["Daggers","Fencing Weapons"].includes(game.i18n.localize("LocalizedCTs.".concat(a.system.combatskill.value)))){o.next=5;break}return o.next=5,this.actor.updateEmbeddedDocuments("Item",[{_id:r,"system.worn.wrongGrip":!a.system.worn.wrongGrip}]);case 5:case"end":return o.stop()}}),_callee22,this)}))),function swapWeaponHand(t){return X.apply(this,arguments)})},{key:"activateListeners",value:function activateListeners(r){var a=this;actor_sheet_get(actor_sheet_getPrototypeOf(ActorSheetDsa5.prototype),"activateListeners",this).call(this,r);var o=function posthand(t){a.actor.items.get(a._getItemId(t)).postItem()};r.find(".roll-disease").click((function(t){return a.rollDisease(a._getItemId(t))})),(0,h.Ee)(r),r.find(".condition-edit").click((function(t){a.actor.effects.get(t.currentTarget.dataset.id).sheet.render(!0)})),r.find(".ch-collapse").click((function(t){$(t.currentTarget).find("i").toggleClass("fa-angle-up fa-angle-down"),$(t.currentTarget).closest(".groupbox").find(".row-section:nth-child(2)").fadeToggle()})),r.find(".status-create").click((function(t){var r=$(t.currentTarget).closest(".statusEffectMenu").find("ul");r.fadeIn("fast",(function(){r.find("input").focus()}))})),r.find(".statusEffectMenu ul").mouseleave((function(t){return $(t.currentTarget).fadeOut()})),r.find(".roll-aggregated").mousedown((function(t){return a._handleAggregatedProbe(t)})),r.find(".skill-select").mousedown((function(t){var r=a._getItemId(t),o=a.actor.items.get(r);0==t.button?a.actor.setupSkill(o,{},a.getTokenId()).then((function(t){a.actor.basicTest(t)})):2==t.button&&o.sheet.render(!0)})),r.find(".spell-select").mousedown((function(t){var r=a._getItemId(t),o=a.actor.items.get(r);0==t.button?a.actor.setupSpell(o,{},a.getTokenId()).then((function(t){return a.actor.basicTest(t)})):2==t.button&&o.sheet.render(!0)})),r.find(".item-post").click((function(t){return o(t)})),r.find(".item-dropdown").click((function(t){t.preventDefault(),$(t.currentTarget).closest(".item").find(".expandDetails:first").toggleClass("shown")})),r.find(".condition-show").mousedown((function(t){t.preventDefault();var r=t.currentTarget.dataset.id,o=$(t.currentTarget).parents(".statusEffect").attr("data-descriptor");if(0==t.button){var i=$(t.currentTarget).parents(".statusEffect").attr("data-origin");if(i)fromUuid(i).then((function(t){return t.sheet.render(!0)}));else{var c,u;o?(c=CONFIG.statusEffects.find((function(t){return t.id==o})),u=$('
    ').concat(game.i18n.localize(c.name),": ").concat(game.i18n.localize(c.description),"
    "))):(c=a.actor.effects.find((function(t){return t.id==r})))&&(u=$('
    ').concat(game.i18n.localize(c.name),": ").concat(game.i18n.localize(c.flags.dsa5.description),"
    ")));var l=$(t.currentTarget).closest(".groupbox").find(".effectDescription");l.fadeOut("fast",(function(){l.html(u).fadeIn("fast")}))}}else 2!=t.button||t.currentTarget.dataset.locked||a._deleteActiveEffect(r)})),r.on("click",".chat-condition",(function(t){return c.Z.postStatus(t.currentTarget.dataset.id)})),r.find(".money-change, .skill-advances").focusin((function(t){a.currentFocus=$(t.currentTarget).closest("[data-item-id]").attr("data-item-id")})),r.find(".item-edit").click((function(t){t.preventDefault();var r=a._getItemId(t);a.actor.items.get(r).sheet.render(!0)})),r.find(".showApplication").mousedown((function(t){if(t.preventDefault(),2==t.button)a._deleteItem(t);else{var r=a._getItemId(t);a.actor.items.get(r).sheet.render(!0)}})),r.find(".ch-value").click((function(t){t.preventDefault();var r=t.currentTarget.attributes["data-char"].value;a.actor.setupCharacteristic(r,{},a.getTokenId()).then((function(t){return a.actor.basicTest(t)}))})),r.find(".ch-status").click((function(t){t.preventDefault(),a.actor.setupDodge({},a.getTokenId()).then((function(t){a.actor.basicTest(t)}))})),r.find(".ch-regenerate").click((function(t){t.preventDefault(),a.actor.setupRegeneration("regenerate",{},a.getTokenId()).then((function(t){return a.actor.basicTest(t)}))})),r.find(".ch-weaponless").click((function(t){t.preventDefault();var r=t.currentTarget.attributes["data-char"].value;a.actor.setupWeaponless(r,{},a.getTokenId()).then((function(t){return a.actor.basicTest(t)}))})),r.find(".ch-fallingDamage").click((function(t){t.preventDefault(),a.actor.setupFallingDamage({},a.getTokenId())})),r.find(".ch-rollCombat").click((function(t){t.preventDefault();var r=a._getItemId(t),o=t.currentTarget.dataset.mode,i=a.actor.items.get(r);a.actor.setupWeapon(i,o,{},a.getTokenId()).then((function(t){return a.actor.basicTest(t)}))}));var i=function deletehand(t){return a._deleteItem(t)};r.find(".cards .item").mouseenter((function(t){if(0==t.currentTarget.getElementsByClassName("hovermenu").length){var r=document.createElement("div");r.classList.add("hovermenu");var a=document.createElement("i");a.classList.add("fas","fa-times"),a.title=game.i18n.localize("SHEET.DeleteItem"),a.addEventListener("click",i,!1);var c=document.createElement("i");c.classList.add("fas","fa-comment"),c.title=game.i18n.localize("SHEET.PostItem"),c.addEventListener("click",o,!1),r.appendChild(c),r.appendChild(a),t.currentTarget.appendChild(r)}})),r.find(".cards .item").mouseleave((function(t){var r=t.toElement||t.relatedTarget;r&&r.parentNode!=a&&r!=a&&t.currentTarget.querySelectorAll(".hovermenu").forEach((function(t){return t.remove()}))}));var l=this.actor.uuid;r.find(".actorDrag").each((function(t,r){r.setAttribute("draggable",!0),r.addEventListener("dragstart",(function(t){var r={type:"Actor",uuid:l};t.dataTransfer.setData("text/plain",JSON.stringify(r))}))})),r.find(".filterTalents").click((function(t){$(t.currentTarget).closest(".content").find(".allTalents").toggleClass("showAll"),$(t.currentTarget).toggleClass("filtered")})),r.find(".charimg").mousedown((function(r){2==r.button&&t.Z.showArtwork(a.actor,!0)})),_.Z.bindRollCommands(r);var p=r.find(".talentSearch");p.keyup((function(t){return a._filterTalents($(t.currentTarget))})),p[0]&&p[0].addEventListener("search",(function filterTalents(t){return a._filterTalents($(t.currentTarget))}),!1);var g=r.find(".conditionSearch");g.keyup((function(t){return a._filterConditions($(t.currentTarget))})),g[0]&&g[0].addEventListener("search",(function filterConditions(t){return a._filterConditions($(t.currentTarget))}),!1);var v=r.find(".gearSearch");v.keyup((function(t){return a._filterGear($(t.currentTarget))})),v[0]&&v[0].addEventListener("search",(function filterGear(t){return a._filterGear($(t.currentTarget))}),!1),bindImgToCanvasDragStart(r,"img.charimg"),b.Z.activateListeners(r,this.actor),this._bindKeepFieldsEnabled(r),this.isEditable&&(r.find(".startCharacterBuilder").click((function(){return a.actor.setFlag("core","sheetClass","dsa5.DSACharBuilder")})),r.find(".schipUpdate").click((function(t){t.preventDefault();var r=Number(t.currentTarget.getAttribute("data-val"));1==r&&1==$(a.form).find(".fullSchip").length&&(r=0),a.actor.update({"system.status.fatePoints.value":r})})),r.find(".swapWeaponHand").click((function(t){return a.swapWeaponHand(t)})),r.find(".defenseToggle").click((function(){return a.actor.update({"system.config.defense":!a.actor.system.config.defense})})),r.find(".loadWeapon").mousedown(function(){var t=actor_sheet_asyncToGenerator(actor_sheet_regeneratorRuntime().mark((function _callee23(t){var r,o,i,c;return actor_sheet_regeneratorRuntime().wrap((function _callee23$(u){for(;;)switch(u.prev=u.next){case 0:if(r=a._getItemId(t),o=a.actor.items.get(r).toObject(),""!==getProperty(o,"system.currentAmmo.value")){u.next=4;break}return u.abrupt("return");case 4:return i={_id:r},0==t.button?(c="trait"==o.type?o.system.reloadTime.value:d.Z.calcLZ(o,a.actor),i["system.reloadTime.progress"]=Math.min(o.system.reloadTime.progress+1,c)):2==t.button&&(i["system.reloadTime.progress"]=0),u.next=8,a.actor.updateEmbeddedDocuments("Item",[i]);case 8:case"end":return u.stop()}}),_callee23)})));return function(r){return t.apply(this,arguments)}}()),r.find(".chargeSpell").mousedown(function(){var t=actor_sheet_asyncToGenerator(actor_sheet_regeneratorRuntime().mark((function _callee24(t){var r,o,i;return actor_sheet_regeneratorRuntime().wrap((function _callee24$(c){for(;;)switch(c.prev=c.next){case 0:return r=a._getItemId(t),o=a.actor.items.get(r).toObject(),i=Number(o.system.castingTime.modified),0==t.button?o.system.castingTime.progress=Math.min(o.system.castingTime.progress+1,i):2==t.button&&(o.system.castingTime.progress=0,o.system.castingTime.modified=0),c.next=6,a.actor.updateEmbeddedDocuments("Item",[o]);case 6:case"end":return c.stop()}}),_callee24)})));return function(r){return t.apply(this,arguments)}}()),r.find(".item-swapMag").click(function(){var t=actor_sheet_asyncToGenerator(actor_sheet_regeneratorRuntime().mark((function _callee25(t){return actor_sheet_regeneratorRuntime().wrap((function _callee25$(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,a.actor.swapMag(a._getItemId(t));case 2:case"end":return r.stop()}}),_callee25)})));return function(r){return t.apply(this,arguments)}}()),r.find(".ammo-selector").change(function(){var t=actor_sheet_asyncToGenerator(actor_sheet_regeneratorRuntime().mark((function _callee26(t){var r;return actor_sheet_regeneratorRuntime().wrap((function _callee26$(o){for(;;)switch(o.prev=o.next){case 0:return t.preventDefault(),r=a._getItemId(t),o.next=4,a.actor.updateEmbeddedDocuments("Item",[{_id:r,"system.currentAmmo.value":$(t.currentTarget).val()}]);case 4:case"end":return o.stop()}}),_callee26)})));return function(r){return t.apply(this,arguments)}}()),r.find(".item-toggle").click((function(t){var r=a._getItemId(t),o=a.actor.items.get(r).toObject();switch(o.type){case"armor":case"rangeweapon":case"meleeweapon":case"equipment":a.actor.updateEmbeddedDocuments("Item",[{_id:r,"system.worn.value":!o.system.worn.value}]),m.Z.playEquipmentWearStatusChange(o)}})),r.find(".quantity-click").mousedown((function(t){var r=a._getItemId(t),o=a.actor.items.get(r).toObject();y.Z.increment(t,o,"system.quantity.value",0),a.actor.updateEmbeddedDocuments("Item",[o])})),r.find(".status-add").mousedown(function(){var t=actor_sheet_asyncToGenerator(actor_sheet_regeneratorRuntime().mark((function _callee28(t){var r;return actor_sheet_regeneratorRuntime().wrap((function _callee28$(o){for(;;)switch(o.prev=o.next){case 0:if("custom"!=(r=t.currentTarget.dataset.id)){o.next=5;break}u.Z.createCustomEffect(a.actor),o.next=11;break;case 5:if(0!=t.button){o.next=10;break}return o.next=8,a.actor.addCondition(r,1,!1,!1);case 8:o.next=11;break;case 10:2==t.button&&S.modifyEffectDialog(r,function(){var t=actor_sheet_asyncToGenerator(actor_sheet_regeneratorRuntime().mark((function _callee27(t,r){return actor_sheet_regeneratorRuntime().wrap((function _callee27$(o){for(;;)switch(o.prev=o.next){case 0:return o.abrupt("return",a.actor.addTimedCondition(t,1,!1,!1,r));case 1:case"end":return o.stop()}}),_callee27)})));return function(r,a){return t.apply(this,arguments)}}());case 11:case"end":return o.stop()}}),_callee28)})));return function(r){return t.apply(this,arguments)}}()),r.find(".money-change").change(function(){var t=actor_sheet_asyncToGenerator(actor_sheet_regeneratorRuntime().mark((function _callee29(t){var r;return actor_sheet_regeneratorRuntime().wrap((function _callee29$(o){for(;;)switch(o.prev=o.next){case 0:return r=a._getItemId(t),o.next=3,a.actor.updateEmbeddedDocuments("Item",[{_id:r,"system.quantity.value":Number(t.target.value)}]);case 3:case"end":return o.stop()}}),_callee29)})));return function(r){return t.apply(this,arguments)}}()),r.find(".skill-advances").change(function(){var t=actor_sheet_asyncToGenerator(actor_sheet_regeneratorRuntime().mark((function _callee30(t){var r;return actor_sheet_regeneratorRuntime().wrap((function _callee30$(o){for(;;)switch(o.prev=o.next){case 0:return r=a._getItemId(t),o.next=3,a.actor.updateEmbeddedDocuments("Item",[{_id:r,"system.talentValue.value":Number(t.target.value)}]);case 3:case"end":return o.stop()}}),_callee30)})));return function(r){return t.apply(this,arguments)}}()),r.find(".advance-attribute").mousedown((function(t){return a.advanceWrapper(t,"_advanceAttribute",t.currentTarget.dataset.attr)})),r.find(".refund-attribute").mousedown((function(t){return a.advanceWrapper(t,"_refundAttributeAdvance",t.currentTarget.dataset.attr)})),r.find(".advance-item").mousedown((function(t){return a.advanceWrapper(t,"_advanceItem",a._getItemId(t))})),r.find(".refund-item").mousedown((function(t){return a.advanceWrapper(t,"_refundItemAdvance",a._getItemId(t))})),r.find(".advance-points").mousedown((function(t){return a.advanceWrapper(t,"_advancePoints",t.currentTarget.dataset.attr)})),r.find(".refund-points").mousedown((function(t){return a.advanceWrapper(t,"_refundPointsAdvance",t.currentTarget.dataset.attr)})),r.find(".rebuy-pc").mousedown((function(t){return a.advanceWrapper(t,"_rebuyPC",t.currentTarget.dataset.attr)})),r.find(".refund-pc").mousedown((function(t){return a.advanceWrapper(t,"_refundPC",t.currentTarget.dataset.attr)})),r.find(".onUseItem").mousedown((function(t){return a._onMacroUseItem(t)})),r.find(".traditionPayCost").mousedown((function(t){return a._payAeSpecialAbilityCost(t)})),r.find(".item-create").click((function(t){return a._onItemCreate(t)})),r.find(".condition-toggle").mousedown(function(){var t=actor_sheet_asyncToGenerator(actor_sheet_regeneratorRuntime().mark((function _callee31(t){var r,o;return actor_sheet_regeneratorRuntime().wrap((function _callee31$(i){for(;;)switch(i.prev=i.next){case 0:return r=$(t.currentTarget).parents(".statusEffect").attr("data-id"),o=a.actor.effects.get(r),i.next=4,o.update({disabled:!o.disabled});case 4:case"end":return i.stop()}}),_callee31)})));return function(r){return t.apply(this,arguments)}}()),r.find(".condition-value").mousedown(function(){var t=actor_sheet_asyncToGenerator(actor_sheet_regeneratorRuntime().mark((function _callee32(t){var r;return actor_sheet_regeneratorRuntime().wrap((function _callee32$(o){for(;;)switch(o.prev=o.next){case 0:if(r=$(t.currentTarget).parents(".statusEffect").attr("data-descriptor"),0!=t.button){o.next=6;break}return o.next=4,a.actor.addCondition(r,1,!1,!1);case 4:o.next=9;break;case 6:if(2!=t.button){o.next=9;break}return o.next=9,a.actor.removeCondition(r,1,!1);case 9:case"end":return o.stop()}}),_callee32)})));return function(r){return t.apply(this,arguments)}}()),r.find(".item-delete").click((function(t){return a._deleteItem(t)})),r.find(".tradition-delete").click((function(t){return a._deleteTraditionArtifact(t)})),r.find(".selectTraditionartifact").click((function(){return a.selectTraditionartifact()})),r.find(".consume-item").mousedown((function(t){if(2==t.button){var r=a._getItemId(t),o=a.actor.items.get(r);a.consumeItem(o)}})),r.find(".disableRegeneration").click((function(t){var r=t.currentTarget.dataset.type,o="system.repeatingEffects.disabled.".concat(r);a.actor.update(actor_sheet_defineProperty({},o,!getProperty(a.actor,o)))})))}},{key:"_bindKeepFieldsEnabled",value:function _bindKeepFieldsEnabled(t){var r=this;if(!this.isEditable){var a,o=actor_sheet_createForOfIteratorHelper(t.find(".keepFieldsEnabled"));try{for(o.s();!(a=o.n()).done;){var i=a.value,c=i.dataset.attr,u=i.dataset.name;$(i).find(".editor").append('')),$(i).find(".editor-edit").click((function(t){return r._openKeepFieldEditpage(t)}))}}catch(t){o.e(t)}finally{o.f()}}}},{key:"_openKeepFieldEditpage",value:function _openKeepFieldEditpage(t){var r=t.currentTarget.dataset.attr,a=t.currentTarget.dataset.name;new k(this.actor.id,r,a).render(!0)}},{key:"_onMacroUseItem",value:(Q=actor_sheet_asyncToGenerator(actor_sheet_regeneratorRuntime().mark((function _callee33(t){var r,a;return actor_sheet_regeneratorRuntime().wrap((function _callee33$(o){for(;;)switch(o.prev=o.next){case 0:return r=this.actor.items.get(this._getItemId(t)),a=new g.Z(r),o.next=4,a.executeOnUseEffect();case 4:case"end":return o.stop()}}),_callee33,this)}))),function _onMacroUseItem(t){return Q.apply(this,arguments)})},{key:"_payAeSpecialAbilityCost",value:(J=actor_sheet_asyncToGenerator(actor_sheet_regeneratorRuntime().mark((function _callee34(r){var a,o,i;return actor_sheet_regeneratorRuntime().wrap((function _callee34$(c){for(;;)switch(c.prev=c.next){case 0:if(a=this.actor.items.get(this._getItemId(r)),o=Number(getProperty(a,"system.AsPCost")),this.actor.applyMana(o,"AsP")){c.next=5;break}return c.abrupt("return");case 5:i=game.i18n.format("CHATNOTIFICATION.paysTraditionAbility",{name:this.actor.name,ability:a.name,cost:o}),2==r.button?ChatMessage.create(t.Z.chatDataSetup(i,"gmroll")):ChatMessage.create(t.Z.chatDataSetup(i));case 7:case"end":return c.stop()}}),_callee34,this)}))),function _payAeSpecialAbilityCost(t){return J.apply(this,arguments)})},{key:"_filterGear",value:function _filterGear(t){if(null!=t.val()){var r=t.val().toLowerCase().trim(),a=$(this.element).find(".inventory .item");a.removeClass("filterHide"),a.filter((function(){return-1==$(this).find("a.item-edit").text().toLowerCase().trim().indexOf(r)})).addClass("filterHide")}}},{key:"selectTraditionartifact",value:(K=actor_sheet_asyncToGenerator(actor_sheet_regeneratorRuntime().mark((function _callee35(){return actor_sheet_regeneratorRuntime().wrap((function _callee35$(t){for(;;)switch(t.prev=t.next){case 0:if(this.isEditable){t.next=2;break}return t.abrupt("return");case 2:new A(this.actor).render(!0);case 3:case"end":return t.stop()}}),_callee35,this)}))),function selectTraditionartifact(){return K.apply(this,arguments)})},{key:"_deleteTraditionArtifact",value:function _deleteTraditionArtifact(t){this.isEditable&&this.actor.items.get(this._getItemId(t)).update({"system.isArtifact":!1})}},{key:"_filterTalents",value:function _filterTalents(t){if(null!=t.val()){var r=t.val().toLowerCase().trim(),a=$(this.form).parent().find(".allTalents");a.find(".item, .table-header, .table-title").removeClass("filterHide"),a.addClass("showAll").find(".item").filter((function(){return-1==$(this).find(".talentName").text().toLowerCase().trim().indexOf(r)})).addClass("filterHide"),r.length>0?(a.find(".table-header, .table-title:not(:eq(0))").addClass("filterHide"),a.addClass("filterfull")):a.removeClass("filterfull")}}},{key:"_filterConditions",value:function _filterConditions(t){if(null!=t.val()){var r=t.val().toLowerCase().trim(),a=$(this.form).find(".statusEffectMenu li:not(.search)");a.removeClass("filterHide"),a.filter((function(){return-1==game.i18n.localize($(this).find("a").attr("data-tooltip")).toLowerCase().trim().indexOf(r)})).addClass("filterHide")}}},{key:"_deleteActiveEffect",value:(V=actor_sheet_asyncToGenerator(actor_sheet_regeneratorRuntime().mark((function _callee36(t){var r;return actor_sheet_regeneratorRuntime().wrap((function _callee36$(a){for(;;)switch(a.prev=a.next){case 0:if(this.isEditable){a.next=2;break}return a.abrupt("return");case 2:if(!(r=this.actor.effects.find((function(r){return r.id==t})))){a.next=8;break}if(!(this.token?this.token.actor:this.actor)){a.next=8;break}return a.next=8,this.actor.deleteEmbeddedDocuments("ActiveEffect",[r.id]);case 8:case"end":return a.stop()}}),_callee36,this)}))),function _deleteActiveEffect(t){return V.apply(this,arguments)})},{key:"_deleteItem",value:(Y=actor_sheet_asyncToGenerator(actor_sheet_regeneratorRuntime().mark((function _callee38(t){var r,a,o,i,c=this;return actor_sheet_regeneratorRuntime().wrap((function _callee38$(u){for(;;)switch(u.prev=u.next){case 0:if(this.isEditable){u.next=2;break}return u.abrupt("return");case 2:return r=this._getItemId(t),a=this.actor.items.get(r),o=game.i18n.format("DIALOG.DeleteItemDetail",{item:a.name}),u.next=7,renderTemplate("systems/dsa5/templates/dialog/delete-item-dialog.html",{message:o});case 7:return i=u.sent,u.next=10,new Promise((function(t,a){var o;new Dialog({title:game.i18n.localize("DIALOG.deleteConfirmation"),content:i,buttons:{Yes:{icon:'',label:game.i18n.localize("yes"),callback:(o=actor_sheet_asyncToGenerator(actor_sheet_regeneratorRuntime().mark((function _callee37(){return actor_sheet_regeneratorRuntime().wrap((function _callee37$(a){for(;;)switch(a.prev=a.next){case 0:return a.next=2,c._cleverDeleteItem(r);case 2:t(!0);case 3:case"end":return a.stop()}}),_callee37)}))),function callback(){return o.apply(this,arguments)})},cancel:{icon:'',label:game.i18n.localize("cancel")}},default:"Yes"}).render(!0)}));case 10:case"end":return u.stop()}}),_callee38,this)}))),function _deleteItem(t){return Y.apply(this,arguments)})},{key:"_cleverDeleteItem",value:(U=actor_sheet_asyncToGenerator(actor_sheet_regeneratorRuntime().mark((function _callee39(r){var o,c,u,l,p;return actor_sheet_regeneratorRuntime().wrap((function _callee39$(d){for(;;)switch(d.prev=d.next){case 0:o=this.actor.items.get(r),c=[r],d.t0=o.type,d.next="advantage"===d.t0||"disadvantage"===d.t0?5:"specialability"===d.t0?8:"blessing"===d.t0||"magictrick"===d.t0?11:"ritual"===d.t0||"ceremony"===d.t0||"liturgy"===d.t0||"spell"===d.t0?14:21;break;case 5:return d.next=7,a.Z.vantageRemoved(this.actor,o,!1);case 7:case 10:case 13:case 20:return d.abrupt("break",21);case 8:return d.next=10,i.Z.abilityRemoved(this.actor,o,!1);case 11:return d.next=13,this._updateAPs(-1,{},{render:!1});case 14:for(u=0,l=0;l<=o.system.talentValue.value;l++)u+=t.Z._calculateAdvCost(l,o.system.StF.value,0);return p=this.actor.items.filter((function(t){return"spellextension"==t.type&&o.type==t.system.category&&o.name==t.system.source})),p&&(u+=p.reduce((function(t,r){return t+(Number(r.system.APValue.value)||0)}),0),c.push.apply(c,actor_sheet_toConsumableArray(p.map((function(t){return t.id}))))),d.next=20,this._updateAPs(-1*u,{},{render:!1});case 21:return d.next=23,this.actor.deleteEmbeddedDocuments("Item",c);case 23:case"end":return d.stop()}}),_callee39,this)}))),function _cleverDeleteItem(t){return U.apply(this,arguments)})},{key:"_getItemId",value:function _getItemId(t){return $(t.currentTarget).closest(".item").attr("data-item-id")}},{key:"_addMoney",value:(q=actor_sheet_asyncToGenerator(actor_sheet_regeneratorRuntime().mark((function _callee40(t){var r,a;return actor_sheet_regeneratorRuntime().wrap((function _callee40$(o){for(;;)switch(o.prev=o.next){case 0:if(r=duplicate(this.actor.items.filter((function(t){return"money"==t.type}))),!(a=r.find((function(r){return r.name==t.name})))){o.next=8;break}return a.system.quantity.value+=t.system.quantity.value,o.next=6,this.actor.updateEmbeddedDocuments("Item",[a]);case 6:o.next=10;break;case 8:return o.next=10,this.actor.createEmbeddedDocuments("Item",[t]);case 10:case"end":return o.stop()}}),_callee40,this)}))),function _addMoney(t){return q.apply(this,arguments)})},{key:"_updateAPs",value:(B=actor_sheet_asyncToGenerator(actor_sheet_regeneratorRuntime().mark((function _callee41(t){var r,a,o=arguments;return actor_sheet_regeneratorRuntime().wrap((function _callee41$(i){for(;;)switch(i.prev=i.next){case 0:return r=o.length>1&&void 0!==o[1]?o[1]:{},a=o.length>2&&void 0!==o[2]?o[2]:{},i.next=4,this.actor._updateAPs(t,r,a);case 4:case"end":return i.stop()}}),_callee41,this)}))),function _updateAPs(t){return B.apply(this,arguments)})},{key:"_addVantage",value:(W=actor_sheet_asyncToGenerator(actor_sheet_regeneratorRuntime().mark((function _callee42(t,r){return actor_sheet_regeneratorRuntime().wrap((function _callee42$(o){for(;;)switch(o.prev=o.next){case 0:a.Z.needsAdoption(this.actor,t,r);case 1:case"end":return o.stop()}}),_callee42,this)}))),function _addVantage(t,r){return W.apply(this,arguments)})},{key:"_addSpecialAbility",value:(Z=actor_sheet_asyncToGenerator(actor_sheet_regeneratorRuntime().mark((function _callee43(t,r){return actor_sheet_regeneratorRuntime().wrap((function _callee43$(a){for(;;)switch(a.prev=a.next){case 0:i.Z.needsAdoption(this.actor,t,r);case 1:case"end":return a.stop()}}),_callee43,this)}))),function _addSpecialAbility(t,r){return Z.apply(this,arguments)})},{key:"_onDragStart",value:function _onDragStart(t){var r=t.currentTarget;if(!t.target.classList.contains("content-link")){var a;if(r.dataset.itemId)a=this.actor.items.get(r.dataset.itemId).toDragData(),r.dataset.mod&&(a.mod=r.dataset.mod);if(r.dataset.id)a=this.actor.effects.get(r.dataset.id).toDragData();a&&t.dataTransfer.setData("text/plain",JSON.stringify(a))}}},{key:"_handleSpellExtension",value:(H=actor_sheet_asyncToGenerator(actor_sheet_regeneratorRuntime().mark((function _callee44(r){var a,o;return actor_sheet_regeneratorRuntime().wrap((function _callee44$(i){for(;;)switch(i.prev=i.next){case 0:if(this.actor.items.find((function(t){return t.type==r.type&&t.name==r.name}))){i.next=19;break}if(r=duplicate(r),a=this.actor.items.find((function(t){return t.type==r.system.category&&t.name==r.system.source}))){i.next=8;break}ui.notifications.error(game.i18n.format("DSAError.noSpellForExtension",{name:r.system.source,category:t.Z.categoryLocalization(r.system.category),extension:r.name})),i.next=19;break;case 8:if(!(a.system.talentValue.value
    ',label:game.i18n.localize("CONDITION.shapeshift"),callback:function callback(){var a=game.dsa5.config.hooks.shapeshift;a.setShapeshift(r.actor,t),a.render(!0)}},horse:{icon:'',label:game.i18n.localize("RIDING.horse"),callback:function callback(){b.Z.setHorse(r.actor,t)}}}}).render(!0):b.Z.setHorse(this.actor,t);case 1:case"end":return a.stop()}}),_callee52,this)}))),function creatureDrop(t){return I.apply(this,arguments)})},{key:"_manageDragItems",value:(D=actor_sheet_asyncToGenerator(actor_sheet_regeneratorRuntime().mark((function _callee53(t,r){return actor_sheet_regeneratorRuntime().wrap((function _callee53$(a){for(;;)switch(a.prev=a.next){case 0:a.t0=r,a.next="disease"===a.t0?3:"meleeweapon"===a.t0||"rangeweapon"===a.t0||"equipment"===a.t0||"ammunition"===a.t0||"armor"===a.t0||"poison"===a.t0||"consumable"===a.t0||"plant"===a.t0?6:"disadvantage"===a.t0||"advantage"===a.t0?9:"specialability"===a.t0?12:"money"===a.t0?15:"ritual"===a.t0||"ceremony"===a.t0||"blessing"===a.t0||"magictrick"===a.t0||"liturgy"===a.t0||"spell"===a.t0||"magicalsign"===a.t0?18:"effectwrapper"===a.t0?21:"application"===a.t0?24:"spellextension"===a.t0?27:"creature"===a.t0?30:"skill"===a.t0||"imprint"===a.t0||"essence"===a.t0||"information"===a.t0?32:"patron"===a.t0||"demonmark"===a.t0?35:38;break;case 3:return a.next=5,this._addDisease(t);case 5:return a.abrupt("break",39);case 6:return a.next=8,this._addLoot(t);case 8:return a.abrupt("return",a.sent);case 9:return a.next=11,this._addVantage(t,r);case 11:return a.abrupt("break",39);case 12:return a.next=14,this._addSpecialAbility(t,r);case 14:return a.abrupt("break",39);case 15:return a.next=17,this._addMoney(t);case 17:return a.abrupt("break",39);case 18:return a.next=20,this._addSpellOrLiturgy(t);case 20:return a.abrupt("break",39);case 21:return a.next=23,this._handleEffectWrapper(t);case 23:return a.abrupt("break",39);case 24:return a.next=26,this._handleApplication(t);case 26:return a.abrupt("break",39);case 27:return a.next=29,this._handleSpellExtension(t);case 29:return a.abrupt("break",39);case 30:return this.creatureDrop(t),a.abrupt("break",39);case 32:return a.next=34,this._addUniqueItem(t);case 34:return a.abrupt("break",39);case 35:return a.next=37,this._addDemonMarkOrPatron(t);case 37:return a.abrupt("break",39);case 38:ui.notifications.error(game.i18n.format("DSAError.canNotBeAdded",{item:t.name,category:game.i18n.localize(t.type)}));case 39:case"end":return a.stop()}}),_callee53,this)}))),function _manageDragItems(t,r){return D.apply(this,arguments)})},{key:"_handleEffectWrapper",value:(C=actor_sheet_asyncToGenerator(actor_sheet_regeneratorRuntime().mark((function _callee54(t){return actor_sheet_regeneratorRuntime().wrap((function _callee54$(r){for(;;)switch(r.prev=r.next){case 0:this.actor.createEmbeddedDocuments("ActiveEffect",t.effects.map((function(t){return t.origin=null,t})));case 1:case"end":return r.stop()}}),_callee54,this)}))),function _handleEffectWrapper(t){return C.apply(this,arguments)})},{key:"_handleLookup",value:(E=actor_sheet_asyncToGenerator(actor_sheet_regeneratorRuntime().mark((function _callee55(r){var a,o,i,c;return actor_sheet_regeneratorRuntime().wrap((function _callee55$(u){for(;;)switch(u.prev=u.next){case 0:return u.next=2,t.Z.findAnyItem(r.items);case 2:if(!(a=u.sent)){u.next=10;break}o=actor_sheet_createForOfIteratorHelper(r.items);try{for(c=function _loop(){var t=i.value;if(t.count){var r=a.find((function(r){return r.name==t.name&&r.type==t.type}));r?(r.system.quantity.value=t.count,t.qs&&"consumable"==t.type&&(r.system.QL=t.qs)):ui.notifications.warn(game.i18n.format("DSAError.notFound",{category:t.type,name:t.name}))}},o.s();!(i=o.n()).done;)c()}catch(t){o.e(t)}finally{o.f()}return u.next=8,this.actor.createEmbeddedDocuments("Item",a);case 8:u.next=11;break;case 10:ui.notifications.error(game.i18n.format("DSAError.notFound",{category:thing.type,name:thing.name}));case 11:case"end":return u.stop()}}),_callee55,this)}))),function _handleLookup(t){return E.apply(this,arguments)})},{key:"_handleApplication",value:(P=actor_sheet_asyncToGenerator(actor_sheet_regeneratorRuntime().mark((function _callee56(t){return actor_sheet_regeneratorRuntime().wrap((function _callee56$(r){for(;;)switch(r.prev=r.next){case 0:if(t=duplicate(t),this.actor.items.find((function(r){return r.type==t.type&&r.name==t.name}))){r.next=5;break}return r.next=5,this.actor.createEmbeddedDocuments("Item",[t]);case 5:case"end":return r.stop()}}),_callee56,this)}))),function _handleApplication(t){return P.apply(this,arguments)})},{key:"_handleRemoveSourceOnDrop",value:(O=actor_sheet_asyncToGenerator(actor_sheet_regeneratorRuntime().mark((function _callee57(t){var r;return actor_sheet_regeneratorRuntime().wrap((function _callee57$(a){for(;;)switch(a.prev=a.next){case 0:if(!(r=t.parent)||!r.isOwner){a.next=4;break}return a.next=4,r.deleteEmbeddedDocuments("Item",[t._id]);case 4:case"end":return a.stop()}}),_callee57)}))),function _handleRemoveSourceOnDrop(t){return O.apply(this,arguments)})},{key:"_onDropItemCreate",value:(T=actor_sheet_asyncToGenerator(actor_sheet_regeneratorRuntime().mark((function _callee58(t){return actor_sheet_regeneratorRuntime().wrap((function _callee58$(r){for(;;)switch(r.prev=r.next){case 0:if(!(t instanceof Array)){r.next=2;break}return r.abrupt("return",this.actor.createEmbeddedDocuments("Item",t));case 2:return r.next=4,this._manageDragItems(t,t.type);case 4:return r.abrupt("return",r.sent);case 5:case"end":return r.stop()}}),_callee58,this)}))),function _onDropItemCreate(t){return T.apply(this,arguments)})},{key:"_onDropActor",value:(x=actor_sheet_asyncToGenerator(actor_sheet_regeneratorRuntime().mark((function _callee59(t,r){var a,o,i;return actor_sheet_regeneratorRuntime().wrap((function _callee59$(t){for(;;)switch(t.prev=t.next){case 0:if(this.actor.isOwner){t.next=2;break}return t.abrupt("return",!1);case 2:return t.next=4,(0,h.x8)(r,this.id,!1);case 4:if(a=t.sent,o=a.item,i=a.typeClass,!a.selfTarget){t.next=10;break}return t.abrupt("return");case 10:return t.next=12,this._manageDragItems(o,i);case 12:return t.abrupt("return",t.sent);case 13:case"end":return t.stop()}}),_callee59,this)}))),function _onDropActor(t,r){return x.apply(this,arguments)})},{key:"_onDropActiveEffect",value:(w=actor_sheet_asyncToGenerator(actor_sheet_regeneratorRuntime().mark((function _callee60(t,r){var a,o,i;return actor_sheet_regeneratorRuntime().wrap((function _callee60$(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,ActiveEffect.implementation.fromDropData(r);case 2:if(o=t.sent,this.actor.isOwner&&o){t.next=5;break}return t.abrupt("return",!1);case 5:if(this.actor.uuid!==(null===(a=o.parent)||void 0===a?void 0:a.uuid)){t.next=7;break}return t.abrupt("return",!1);case 7:return(i=o.toObject()).origin=this.actor.uuid,t.abrupt("return",ActiveEffect.create(i,{parent:this.actor}));case 10:case"end":return t.stop()}}),_callee60,this)}))),function _onDropActiveEffect(t,r){return w.apply(this,arguments)})},{key:"_onDropItem",value:(v=actor_sheet_asyncToGenerator(actor_sheet_regeneratorRuntime().mark((function _callee61(t,a){var o,i,c,u,l,p,d;return actor_sheet_regeneratorRuntime().wrap((function _callee61$(h){for(;;)switch(h.prev=h.next){case 0:if(this.actor.isOwner){h.next=2;break}return h.abrupt("return",!1);case 2:return h.next=4,Item.implementation.fromDropData(a);case 4:if(i=h.sent,c=i.toObject(),y.Z.obfuscateDropData(c,a.tabsinvisible),(l=$(t.target).parents(".item"))&&"bags"==l.attr("data-category")&&r.Z.equipmentCategories.includes(i.type)&&l.attr("data-item-id")!=i.id&&(u=l.attr("data-item-id")),!(p=this.actor.uuid===(null===(o=i.parent)||void 0===o?void 0:o.uuid))){h.next=28;break}if(!t.ctrlKey){h.next=16;break}return h.next=14,this.handleItemCopy(c,i.type);case 14:case 21:h.next=26;break;case 16:if(!u){h.next=23;break}return d={_id:i.id,"system.parent_id":u},i.system.worn&&i.system.worn.value&&(d["system.worn.value"]=!1),h.next=21,this.actor.updateEmbeddedDocuments("Item",[d]);case 23:if(!r.Z.equipmentCategories.includes(i.type)){h.next=26;break}return h.next=26,this.actor.updateEmbeddedDocuments("Item",[{_id:i.id,system:{parent_id:0}}]);case 26:h.next=30;break;case 28:return h.next=30,this._onDropItemCreate(c);case 30:if(!t.altKey||p||!r.Z.equipmentCategories.includes(i.type)){h.next=33;break}return h.next=33,this._handleRemoveSourceOnDrop(i);case 33:case"end":return h.stop()}}),_callee61,this)}))),function _onDropItem(t,r){return v.apply(this,arguments)})}],[{key:"defaultOptions",get:function get(){var t=actor_sheet_get(actor_sheet_getPrototypeOf(ActorSheetDsa5),"defaultOptions",this);return t.tabs=[{navSelector:".tabs",contentSelector:".content",initial:"skills"}],mergeObject(t,{width:770,height:740,scrollY:[".save-scroll"],dragDrop:[{dragSelector:".content .item",dropSelector:null},{dragSelector:".mainEffects .statusEffect",dropSelector:null}]}),t}}]),ActorSheetDsa5}(),A=function(t){actor_sheet_inherits(TraditionArtifactpicker,Application);var r,a=actor_sheet_createSuper(TraditionArtifactpicker);function TraditionArtifactpicker(t){var r,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return actor_sheet_classCallCheck(this,TraditionArtifactpicker),(r=a.call(this,o)).actor=t,r}return actor_sheet_createClass(TraditionArtifactpicker,[{key:"template",get:function get(){return"systems/dsa5/templates/actors/traditionPicker.html"}},{key:"getData",value:(r=actor_sheet_asyncToGenerator(actor_sheet_regeneratorRuntime().mark((function _callee62(t){var r,a;return actor_sheet_regeneratorRuntime().wrap((function _callee62$(o){for(;;)switch(o.prev=o.next){case 0:return o.next=2,actor_sheet_get(actor_sheet_getPrototypeOf(TraditionArtifactpicker.prototype),"getData",this).call(this,t);case 2:return r=o.sent,a=this.actor.items.filter((function(t){return["equipment","armor","rangeweapon","meleeweapon"].includes(t.type)})),mergeObject(r,{items:a}),o.abrupt("return",r);case 6:case"end":return o.stop()}}),_callee62,this)}))),function getData(t){return r.apply(this,arguments)})},{key:"activateListeners",value:function activateListeners(t){var r=this;actor_sheet_get(actor_sheet_getPrototypeOf(TraditionArtifactpicker.prototype),"activateListeners",this).call(this,t),t.find(".slot").click(function(){var t=actor_sheet_asyncToGenerator(actor_sheet_regeneratorRuntime().mark((function _callee63(t){var a;return actor_sheet_regeneratorRuntime().wrap((function _callee63$(o){for(;;)switch(o.prev=o.next){case 0:return a=r.actor.items.get(t.currentTarget.dataset.itemId),o.next=3,a.update({"system.isArtifact":!a.system.isArtifact});case 3:case"end":return o.stop()}}),_callee63)})));return function(r){return t.apply(this,arguments)}}())}}],[{key:"defaultOptions",get:function get(){var t=actor_sheet_get(actor_sheet_getPrototypeOf(TraditionArtifactpicker),"defaultOptions",this);return mergeObject(t,{width:440,resizable:!0}),t}}]),TraditionArtifactpicker}(),O=__webpack_require__(794);function dsa5_wizard_regeneratorRuntime(){dsa5_wizard_regeneratorRuntime=function _regeneratorRuntime(){return t};var t={},r=Object.prototype,a=r.hasOwnProperty,o="function"==typeof Symbol?Symbol:{},i=o.iterator||"@@iterator",c=o.asyncIterator||"@@asyncIterator",u=o.toStringTag||"@@toStringTag";function define(t,r,a){return Object.defineProperty(t,r,{value:a,enumerable:!0,configurable:!0,writable:!0}),t[r]}try{define({},"")}catch(t){define=function define(t,r,a){return t[r]=a}}function wrap(t,r,a,o){var i=r&&r.prototype instanceof Generator?r:Generator,c=Object.create(i.prototype),u=new Context(o||[]);return c._invoke=function(t,r,a){var o="suspendedStart";return function(i,c){if("executing"===o)throw new Error("Generator is already running");if("completed"===o){if("throw"===i)throw c;return doneResult()}for(a.method=i,a.arg=c;;){var u=a.delegate;if(u){var p=maybeInvokeDelegate(u,a);if(p){if(p===l)continue;return p}}if("next"===a.method)a.sent=a._sent=a.arg;else if("throw"===a.method){if("suspendedStart"===o)throw o="completed",a.arg;a.dispatchException(a.arg)}else"return"===a.method&&a.abrupt("return",a.arg);o="executing";var d=tryCatch(t,r,a);if("normal"===d.type){if(o=a.done?"completed":"suspendedYield",d.arg===l)continue;return{value:d.arg,done:a.done}}"throw"===d.type&&(o="completed",a.method="throw",a.arg=d.arg)}}}(t,a,u),c}function tryCatch(t,r,a){try{return{type:"normal",arg:t.call(r,a)}}catch(t){return{type:"throw",arg:t}}}t.wrap=wrap;var l={};function Generator(){}function GeneratorFunction(){}function GeneratorFunctionPrototype(){}var p={};define(p,i,(function(){return this}));var d=Object.getPrototypeOf,h=d&&d(d(values([])));h&&h!==r&&a.call(h,i)&&(p=h);var m=GeneratorFunctionPrototype.prototype=Generator.prototype=Object.create(p);function defineIteratorMethods(t){["next","throw","return"].forEach((function(r){define(t,r,(function(t){return this._invoke(r,t)}))}))}function AsyncIterator(t,r){function invoke(o,i,c,u){var l=tryCatch(t[o],t,i);if("throw"!==l.type){var p=l.arg,d=p.value;return d&&"object"==dsa5_wizard_typeof(d)&&a.call(d,"__await")?r.resolve(d.__await).then((function(t){invoke("next",t,c,u)}),(function(t){invoke("throw",t,c,u)})):r.resolve(d).then((function(t){p.value=t,c(p)}),(function(t){return invoke("throw",t,c,u)}))}u(l.arg)}var o;this._invoke=function(t,a){function callInvokeWithMethodAndArg(){return new r((function(r,o){invoke(t,a,r,o)}))}return o=o?o.then(callInvokeWithMethodAndArg,callInvokeWithMethodAndArg):callInvokeWithMethodAndArg()}}function maybeInvokeDelegate(t,r){var a=t.iterator[r.method];if(void 0===a){if(r.delegate=null,"throw"===r.method){if(t.iterator.return&&(r.method="return",r.arg=void 0,maybeInvokeDelegate(t,r),"throw"===r.method))return l;r.method="throw",r.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var o=tryCatch(a,t.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,l;var i=o.arg;return i?i.done?(r[t.resultName]=i.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=void 0),r.delegate=null,l):i:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,l)}function pushTryEntry(t){var r={tryLoc:t[0]};1 in t&&(r.catchLoc=t[1]),2 in t&&(r.finallyLoc=t[2],r.afterLoc=t[3]),this.tryEntries.push(r)}function resetTryEntry(t){var r=t.completion||{};r.type="normal",delete r.arg,t.completion=r}function Context(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(pushTryEntry,this),this.reset(!0)}function values(t){if(t){var r=t[i];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var o=-1,c=function next(){for(;++o=0;--o){var i=this.tryEntries[o],c=i.completion;if("root"===i.tryLoc)return handle("end");if(i.tryLoc<=this.prev){var u=a.call(i,"catchLoc"),l=a.call(i,"finallyLoc");if(u&&l){if(this.prev=0;--o){var i=this.tryEntries[o];if(i.tryLoc<=this.prev&&a.call(i,"finallyLoc")&&this.prev=0;--r){var a=this.tryEntries[r];if(a.finallyLoc===t)return this.complete(a.completion,a.afterLoc),resetTryEntry(a),l}},catch:function _catch(t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc===t){var o=a.completion;if("throw"===o.type){var i=o.arg;resetTryEntry(a)}return i}}throw new Error("illegal catch attempt")},delegateYield:function delegateYield(t,r,a){return this.delegate={iterator:values(t),resultName:r,nextLoc:a},"next"===this.method&&(this.arg=void 0),l}},t}function dsa5_wizard_typeof(t){return dsa5_wizard_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},dsa5_wizard_typeof(t)}function dsa5_wizard_createForOfIteratorHelper(t,r){var a="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!a){if(Array.isArray(t)||(a=function dsa5_wizard_unsupportedIterableToArray(t,r){if(!t)return;if("string"==typeof t)return dsa5_wizard_arrayLikeToArray(t,r);var a=Object.prototype.toString.call(t).slice(8,-1);"Object"===a&&t.constructor&&(a=t.constructor.name);if("Map"===a||"Set"===a)return Array.from(t);if("Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a))return dsa5_wizard_arrayLikeToArray(t,r)}(t))||r&&t&&"number"==typeof t.length){a&&(t=a);var o=0,i=function F(){};return{s:i,n:function n(){return o>=t.length?{done:!0}:{done:!1,value:t[o++]}},e:function e(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var c,u=!0,l=!1;return{s:function s(){a=a.call(t)},n:function n(){var t=a.next();return u=t.done,t},e:function e(t){l=!0,c=t},f:function f(){try{u||null==a.return||a.return()}finally{if(l)throw c}}}}function dsa5_wizard_arrayLikeToArray(t,r){(null==r||r>t.length)&&(r=t.length);for(var a=0,o=new Array(r);a1&&void 0!==arguments[1]?arguments[1]:",",o=[],i=game.i18n.localize("combatskillcountdivider")+":",c=dsa5_wizard_createForOfIteratorHelper(t.split(a));try{for(c.s();!(r=c.n()).done;){var u=r.value;if(u.includes(i)){var l=u.split(":");o.push({choices:l[1].split("/").map((function(t){return t.trim()})),allowedCount:Number(l[0].match(/\d/g))})}}}catch(t){c.e(t)}finally{c.f()}return o}},{key:"parseToItem",value:(m=dsa5_wizard_asyncToGenerator(dsa5_wizard_regeneratorRuntime().mark((function _callee3(a,o){var i=this;return dsa5_wizard_regeneratorRuntime().wrap((function _callee3$(c){for(;;)switch(c.prev=c.next){case 0:if(""!=a.trim()){c.next=2;break}return c.abrupt("return",[]);case 2:return c.next=4,Promise.all(a.split(", ").map(function(){var a=dsa5_wizard_asyncToGenerator(dsa5_wizard_regeneratorRuntime().mark((function _callee2(a){var c,u,l,p,d,h,m;return dsa5_wizard_regeneratorRuntime().wrap((function _callee2$(y){for(;;)switch(y.prev=y.next){case 0:return c=t.Z.parseAbilityString(a.trim()),y.next=3,i.findCompendiumItem(c.original,o);case 3:if(u=y.sent){y.next=8;break}return y.next=7,i.findCompendiumItem(c.name,o);case 7:u=y.sent;case 8:if(u)h=u.uuid,(u=duplicate(u)).uuid=h,u.tooltip=game.i18n.localize("Details"),(u=O.Z.reverseAdoptionCalculation(i.actor,c,u)).system.APValue&&(u.APunparseable=isNaN(u.system.APValue.value),u.apCost=u.APunparseable?u.system.APValue.value:c.step*Number(u.system.APValue.value));else if(i.attributes.includes(c.name)){for(l=0,p=i.actor.system.characteristics[game.dsa5.config.knownShortcuts[c.name.toLowerCase()][1]].value+1;p")),d=o.map((function(r){return t.Z.categoryLocalization(r)})).join("/"),i.errors.push("".concat(d,": ").concat(a)),u={name:a.trim(),notFound:!0,tooltip:game.i18n.localize("DSAError.itemNotFound"),apCost:"?"};return u.replaceName=c.original,u.step=c.step,m=null!=i.actor.items.find((function(t){return o.includes(t.type)&&t.name==c.original})),u.disabled=m||u.notFound||u.APunparseable,m&&(u.tooltip=game.i18n.localize("YouAlreadyHaveit")),y.abrupt("return",u);case 15:case"end":return y.stop()}}),_callee2)})));return function(t){return a.apply(this,arguments)}}()));case 4:return c.abrupt("return",c.sent);case 5:case"end":return c.stop()}}),_callee3)}))),function parseToItem(t,r){return m.apply(this,arguments)})},{key:"mergeLevels",value:function mergeLevels(t,r,a){var o=!1,i=t.find((function(t){return t.name==r.name&&t.type==r.type}));if(i){o=!0;var c=Number(getProperty(r,"system.step.value"));c&&(i.system.step.value=Math.min(i.system.step.value+=c,i.system[a].value))}else t.push(r);return o}},{key:"addSelections",value:(d=dsa5_wizard_asyncToGenerator(dsa5_wizard_regeneratorRuntime().mark((function _callee4(r){var o,c,u,l,p,d,h,m=arguments;return dsa5_wizard_regeneratorRuntime().wrap((function _callee4$(y){for(;;)switch(y.prev=y.next){case 0:o=!(m.length>1&&void 0!==m[1])||m[1],c=[],u=dsa5_wizard_createForOfIteratorHelper(r),y.prev=3,u.s();case 5:if((l=u.n()).done){y.next=31;break}if(p=l.value,""!=$(p).val()){y.next=10;break}return y.abrupt("continue",29);case 10:return y.next=12,fromUuid($(p).val());case 12:d=y.sent.toObject(),h=t.Z.parseAbilityString(d.name),d.name=$(p).attr("name"),y.t0=d.type,y.next="advantage"===y.t0||"disadvantage"===y.t0?18:"specialability"===y.t0?22:"magictrick"===y.t0?27:29;break;case 18:return d.system.step.value=Number(p.dataset.step),d=O.Z.reverseAdoptionCalculation(this.actor,h,d),this.mergeLevels(c,d,"max")||a.Z.vantageAdded(this.actor,d),y.abrupt("break",29);case 22:return d.system.step.value=Number(p.dataset.step),"true"==p.dataset.free&&(d.system.APValue.value=0),d=O.Z.reverseAdoptionCalculation(this.actor,h,d),this.mergeLevels(c,d,"maxRank")||i.Z.abilityAdded(this.actor,d),y.abrupt("break",29);case 27:return this.mergeLevels(c,d),y.abrupt("break",29);case 29:y.next=5;break;case 31:y.next=36;break;case 33:y.prev=33,y.t1=y.catch(3),u.e(y.t1);case 36:return y.prev=36,u.f(),y.finish(36);case 39:return y.next=41,this.actor.createEmbeddedDocuments("Item",c,{render:o});case 41:case"end":return y.stop()}}),_callee4,this,[[3,33,36,39]])}))),function addSelections(t){return d.apply(this,arguments)})},{key:"fixPreviousCosts",value:(p=dsa5_wizard_asyncToGenerator(dsa5_wizard_regeneratorRuntime().mark((function _callee5(t,r){var a,o,i;return dsa5_wizard_regeneratorRuntime().wrap((function _callee5$(c){for(;;)switch(c.prev=c.next){case 0:a=dsa5_wizard_createForOfIteratorHelper(r);try{for(i=function _loop2(){var r=o.value,a=t.find((function(t){return t.type==r.type&&t.name==r.name}));a&&(r.apCost-=a.apCost)},a.s();!(o=a.n()).done;)i()}catch(t){a.e(t)}finally{a.f()}case 2:case"end":return c.stop()}}),_callee5)}))),function fixPreviousCosts(t,r){return p.apply(this,arguments)})},{key:"alreadyAdded",value:(l=dsa5_wizard_asyncToGenerator(dsa5_wizard_regeneratorRuntime().mark((function _callee6(r,a){var o;return dsa5_wizard_regeneratorRuntime().wrap((function _callee6$(i){for(;;)switch(i.prev=i.next){case 0:if(""!=r){i.next=2;break}return i.abrupt("return",!1);case 2:return o=!1,i.next=5,new Promise((function(r,o){new Dialog({title:game.i18n.localize("DIALOG.warning"),content:game.i18n.format("DIALOG.alreadyAddedCharacterpart",{category:t.Z.categoryLocalization(a)}),default:"ok",buttons:{ok:{icon:'',label:game.i18n.localize("Ok"),default:!0,callback:function callback(){r(!1)}},cancel:{icon:'',label:game.i18n.localize("Cancel"),default:!0,callback:function callback(){r(!0)}}}}).render(!0)}));case 5:return o=i.sent,i.abrupt("return",o);case 7:case"end":return i.stop()}}),_callee6)}))),function alreadyAdded(t,r){return l.apply(this,arguments)})},{key:"updateSkill",value:(u=dsa5_wizard_asyncToGenerator(dsa5_wizard_regeneratorRuntime().mark((function _callee7(r,a){var o,i,c,u,l,p,d=this,h=arguments;return dsa5_wizard_regeneratorRuntime().wrap((function _callee7$(m){for(;;)switch(m.prev=m.next){case 0:o=h.length>2&&void 0!==h[2]?h[2]:1,i=!(h.length>3&&void 0!==h[3])||h[3],c=[],u=dsa5_wizard_createForOfIteratorHelper(r);try{for(p=function _loop3(){var r=l.value,u=t.Z.parseAbilityString(r.trim()),p=d.actor.items.find((function(t){return t.type==a&&t.name==u.name}));p?c.push({_id:p.id,"system.talentValue.value":Math.max(0,o*u.step+(i?Number(p.system.talentValue.value):0))}):(console.warn("Could not find ".concat(a," ").concat(r)),d.errors.push("".concat(t.Z.categoryLocalization(a),": ").concat(r)))},u.s();!(l=u.n()).done;)p()}catch(t){u.e(t)}finally{u.f()}return m.next=7,this.actor.updateEmbeddedDocuments("Item",c,{render:!1});case 7:case"end":return m.stop()}}),_callee7,this)}))),function updateSkill(t,r){return u.apply(this,arguments)})},{key:"getData",value:(c=dsa5_wizard_asyncToGenerator(dsa5_wizard_regeneratorRuntime().mark((function _callee8(t){var r;return dsa5_wizard_regeneratorRuntime().wrap((function _callee8$(a){for(;;)switch(a.prev=a.next){case 0:return a.next=2,dsa5_wizard_get(dsa5_wizard_getPrototypeOf(WizardDSA5.prototype),"getData",this).call(this,t);case 2:return r=a.sent,a.next=5,game.dsa5.itemLibrary.buildEquipmentIndex();case 5:return a.abrupt("return",r);case 6:case"end":return a.stop()}}),_callee8,this)}))),function getData(t){return c.apply(this,arguments)})},{key:"_validateInput",value:function _validateInput(t){var r,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this,o=/^exclusive_/,i=dsa5_wizard_createForOfIteratorHelper(t.find(".tab"));try{for(i.s();!(r=i.n()).done;){var c,u=r.value,l=$(u),p=new Set,d=dsa5_wizard_createForOfIteratorHelper(l.find(".exclusive"));try{for(d.s();!(c=d.n()).done;){var h=c.value;p.add(h.className.split(/\s+/).filter((function(t){return o.test(t)}))[0])}}catch(t){d.e(t)}finally{d.f()}var m,y=dsa5_wizard_createForOfIteratorHelper(p);try{for(y.s();!(m=y.n()).done;){var g=m.value,v=l.find(".allowedCount_"+g.split("_")[1]),_=Number(v.attr("data-count"));if(l.find(".".concat(g,":checked")).length!=_)return this._showInputValidation(v,l,a),!1}}catch(t){y.e(t)}finally{y.f()}}}catch(t){i.e(t)}finally{i.f()}return!0}},{key:"_showInputValidation",value:function _showInputValidation(t,r,a){ui.notifications.error(game.i18n.localize("DSAError.MissingChoices"));var o=t.closest(".tab").attr("data-tab");a.activateTab(o),WizardDSA5.flashElem(r.find(".tabs a[data-tab='".concat(o,"']"))),WizardDSA5.flashElem(t.closest("div"))}},{key:"activateListeners",value:function activateListeners(t){var r=this;dsa5_wizard_get(dsa5_wizard_getPrototypeOf(WizardDSA5.prototype),"activateListeners",this).call(this,t),(0,h.Ee)(t),t.find("button.ok").click((function(){r.updating||(r.updating=!0,r.updateCharacter($(r._element)).then((function(){return r.updating=!1})))})),t.find("button.cancel").click((function(){r.close()})),t.find(".show-item").click(function(){var t=dsa5_wizard_asyncToGenerator(dsa5_wizard_regeneratorRuntime().mark((function _callee9(t){var r;return dsa5_wizard_regeneratorRuntime().wrap((function _callee9$(a){for(;;)switch(a.prev=a.next){case 0:return r=t.currentTarget.dataset.uuid,a.next=3,fromUuid(r);case 3:a.sent.sheet.render(!0);case 5:case"end":return a.stop()}}),_callee9)})));return function(r){return t.apply(this,arguments)}}()),t.on("click",".searchableAbility a",(function(t){return(0,h.$8)(t)})),t.find(".exclusive").change((function(t){var r=$(t.currentTarget).closest(".tab"),a=$(t.currentTarget).attr("data-sel"),o=r.find(".allowedCount_".concat(a)),i=Number(o.attr("data-count"));if(r.find(".exclusive_".concat(a,":checked")).length>i)return t.currentTarget.checked=!1,void WizardDSA5.flashElem(o)}))}},{key:"finalizeUpdate",value:function finalizeUpdate(){0==this.errors.length?this.close():$(this._element).find(".dialog-buttons").html('

    '.concat(game.i18n.localize("DSAError.notUnderstood"),"

    • ").concat(this.errors.join("
    • "),"
    "))}}],[{key:"defaultOptions",get:function get(){var t=dsa5_wizard_get(dsa5_wizard_getPrototypeOf(WizardDSA5),"defaultOptions",this);return t.tabs=[{navSelector:".tabs",contentSelector:".content",initial:"description"}],mergeObject(t,{classes:t.classes.concat(["dsa5","largeDialog","generationWizard"]),width:770,height:740}),t.resizable=!0,t}},{key:"flashElem",value:function flashElem(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"emphasize";t.addClass(r),setTimeout((function(){t.removeClass(r)}),600)}}]),WizardDSA5}();function culture_wizard_typeof(t){return culture_wizard_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},culture_wizard_typeof(t)}function culture_wizard_regeneratorRuntime(){culture_wizard_regeneratorRuntime=function _regeneratorRuntime(){return t};var t={},r=Object.prototype,a=r.hasOwnProperty,o="function"==typeof Symbol?Symbol:{},i=o.iterator||"@@iterator",c=o.asyncIterator||"@@asyncIterator",u=o.toStringTag||"@@toStringTag";function define(t,r,a){return Object.defineProperty(t,r,{value:a,enumerable:!0,configurable:!0,writable:!0}),t[r]}try{define({},"")}catch(t){define=function define(t,r,a){return t[r]=a}}function wrap(t,r,a,o){var i=r&&r.prototype instanceof Generator?r:Generator,c=Object.create(i.prototype),u=new Context(o||[]);return c._invoke=function(t,r,a){var o="suspendedStart";return function(i,c){if("executing"===o)throw new Error("Generator is already running");if("completed"===o){if("throw"===i)throw c;return doneResult()}for(a.method=i,a.arg=c;;){var u=a.delegate;if(u){var p=maybeInvokeDelegate(u,a);if(p){if(p===l)continue;return p}}if("next"===a.method)a.sent=a._sent=a.arg;else if("throw"===a.method){if("suspendedStart"===o)throw o="completed",a.arg;a.dispatchException(a.arg)}else"return"===a.method&&a.abrupt("return",a.arg);o="executing";var d=tryCatch(t,r,a);if("normal"===d.type){if(o=a.done?"completed":"suspendedYield",d.arg===l)continue;return{value:d.arg,done:a.done}}"throw"===d.type&&(o="completed",a.method="throw",a.arg=d.arg)}}}(t,a,u),c}function tryCatch(t,r,a){try{return{type:"normal",arg:t.call(r,a)}}catch(t){return{type:"throw",arg:t}}}t.wrap=wrap;var l={};function Generator(){}function GeneratorFunction(){}function GeneratorFunctionPrototype(){}var p={};define(p,i,(function(){return this}));var d=Object.getPrototypeOf,h=d&&d(d(values([])));h&&h!==r&&a.call(h,i)&&(p=h);var m=GeneratorFunctionPrototype.prototype=Generator.prototype=Object.create(p);function defineIteratorMethods(t){["next","throw","return"].forEach((function(r){define(t,r,(function(t){return this._invoke(r,t)}))}))}function AsyncIterator(t,r){function invoke(o,i,c,u){var l=tryCatch(t[o],t,i);if("throw"!==l.type){var p=l.arg,d=p.value;return d&&"object"==culture_wizard_typeof(d)&&a.call(d,"__await")?r.resolve(d.__await).then((function(t){invoke("next",t,c,u)}),(function(t){invoke("throw",t,c,u)})):r.resolve(d).then((function(t){p.value=t,c(p)}),(function(t){return invoke("throw",t,c,u)}))}u(l.arg)}var o;this._invoke=function(t,a){function callInvokeWithMethodAndArg(){return new r((function(r,o){invoke(t,a,r,o)}))}return o=o?o.then(callInvokeWithMethodAndArg,callInvokeWithMethodAndArg):callInvokeWithMethodAndArg()}}function maybeInvokeDelegate(t,r){var a=t.iterator[r.method];if(void 0===a){if(r.delegate=null,"throw"===r.method){if(t.iterator.return&&(r.method="return",r.arg=void 0,maybeInvokeDelegate(t,r),"throw"===r.method))return l;r.method="throw",r.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var o=tryCatch(a,t.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,l;var i=o.arg;return i?i.done?(r[t.resultName]=i.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=void 0),r.delegate=null,l):i:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,l)}function pushTryEntry(t){var r={tryLoc:t[0]};1 in t&&(r.catchLoc=t[1]),2 in t&&(r.finallyLoc=t[2],r.afterLoc=t[3]),this.tryEntries.push(r)}function resetTryEntry(t){var r=t.completion||{};r.type="normal",delete r.arg,t.completion=r}function Context(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(pushTryEntry,this),this.reset(!0)}function values(t){if(t){var r=t[i];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var o=-1,c=function next(){for(;++o=0;--o){var i=this.tryEntries[o],c=i.completion;if("root"===i.tryLoc)return handle("end");if(i.tryLoc<=this.prev){var u=a.call(i,"catchLoc"),l=a.call(i,"finallyLoc");if(u&&l){if(this.prev=0;--o){var i=this.tryEntries[o];if(i.tryLoc<=this.prev&&a.call(i,"finallyLoc")&&this.prev=0;--r){var a=this.tryEntries[r];if(a.finallyLoc===t)return this.complete(a.completion,a.afterLoc),resetTryEntry(a),l}},catch:function _catch(t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc===t){var o=a.completion;if("throw"===o.type){var i=o.arg;resetTryEntry(a)}return i}}throw new Error("illegal catch attempt")},delegateYield:function delegateYield(t,r,a){return this.delegate={iterator:values(t),resultName:r,nextLoc:a},"next"===this.method&&(this.arg=void 0),l}},t}function culture_wizard_asyncGeneratorStep(t,r,a,o,i,c,u){try{var l=t[c](u),p=l.value}catch(t){return void a(t)}l.done?r(p):Promise.resolve(p).then(o,i)}function culture_wizard_asyncToGenerator(t){return function(){var r=this,a=arguments;return new Promise((function(o,i){var c=t.apply(r,a);function _next(t){culture_wizard_asyncGeneratorStep(c,o,i,_next,_throw,"next",t)}function _throw(t){culture_wizard_asyncGeneratorStep(c,o,i,_next,_throw,"throw",t)}_next(void 0)}))}}function culture_wizard_classCallCheck(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}function culture_wizard_defineProperties(t,r){for(var a=0;a0,l.t12=o.length>0,l.t13=i.length>0,l.t14=c.length>0,l.t15=c.length>1,l.t16=a.length>0||o.length>0,l.t17=i.length>0||c.length>0,l.next=44,TextEditor.enrichHTML(getProperty(this.culture.system,"clothing.value"),{secrets:!1,async:!0});case 44:return l.t18=l.sent,l.next=47,TextEditor.enrichHTML(getProperty(this.culture.system,"description.value"),{secrets:!1,async:!0});case 47:return l.t19=l.sent,l.t20={title:l.t4,culture:l.t5,description:l.t6,advantages:l.t7,disadvantages:l.t8,writings:l.t9,languages:l.t10,advantagesToChose:l.t11,disadvantagesToChose:l.t12,writingsToChose:l.t13,languagesToChose:l.t14,languagesToSelect:l.t15,vantagesToChose:l.t16,generalToChose:l.t17,enrichedClothing:l.t18,enrichedDescription:l.t19},(0,l.t2)(l.t3,l.t20),l.abrupt("return",r);case 51:case"end":return l.stop()}}),_callee,this)}))),function getData(t){return o.apply(this,arguments)})},{key:"addCulture",value:(a=culture_wizard_asyncToGenerator(culture_wizard_regeneratorRuntime().mark((function _callee2(t,r){return culture_wizard_regeneratorRuntime().wrap((function _callee2$(a){for(;;)switch(a.prev=a.next){case 0:this.actor=t,this.culture=duplicate(r);case 2:case"end":return a.stop()}}),_callee2,this)}))),function addCulture(t,r){return a.apply(this,arguments)})},{key:"_validateInput",value:function _validateInput(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this,a=t.find(".localKnowledge");if(""==a.val())return this._showInputValidation(a,t,r),!1;var o=t.find(".selectOnlyOne");if(o.length){var i=o.find(".optional:checked");if(1!=i.length)return this._showInputValidation(o,t,r),!1}return culture_wizard_get(culture_wizard_getPrototypeOf(CultureWizard.prototype),"_validateInput",this).call(this,t,r)}},{key:"updateCharacter",value:(r=culture_wizard_asyncToGenerator(culture_wizard_regeneratorRuntime().mark((function _callee3(t){var r,a,o,i,c=arguments;return culture_wizard_regeneratorRuntime().wrap((function _callee3$(u){for(;;)switch(u.prev=u.next){case 0:if(r=c.length>1&&void 0!==c[1]?c[1]:this,t.find("button.ok i").toggleClass("fa-check fa-spinner fa-spin"),a=Number(t.find(".apCost").text()),u.t1=!this._validateInput(t,r),u.t1){u.next=8;break}return u.next=7,this.actor.checkEnoughXP(a);case 7:u.t1=!u.sent;case 8:if(u.t0=u.t1,u.t0){u.next=13;break}return u.next=12,this.alreadyAdded(this.actor.system.details.culture.value,"culture");case 12:u.t0=u.sent;case 13:if(!u.t0){u.next=16;break}return t.find("button.ok i").toggleClass("fa-check fa-spinner fa-spin"),u.abrupt("return");case 16:return o={"system.details.culture.value":this.culture.name},u.next=19,this.findCompendiumItem("".concat(game.i18n.localize("LocalizedIDs.localKnowledge")," ()"),["specialability"]);case 19:if(!(i=u.sent)){u.next=26;break}return(i=duplicate(i)).name="".concat(game.i18n.localize("LocalizedIDs.localKnowledge")," (").concat(t.find(".localKnowledge").val(),")"),i.system.APValue.value=0,u.next=26,this.actor.createEmbeddedDocuments("Item",[i],{render:!1});case 26:return u.next=28,this.addSelections(t.find(".optional:checked"),!1);case 28:return u.next=30,this.actor._updateAPs(a,{},{render:!1});case 30:return u.next=32,this.updateSkill(this.culture.system.skills.value.split(","),"skill");case 32:return u.next=34,this.actor.update(o);case 34:this.finalizeUpdate();case 35:case"end":return u.stop()}}),_callee3,this)}))),function updateCharacter(t){return r.apply(this,arguments)})}],[{key:"defaultOptions",get:function get(){var t=culture_wizard_get(culture_wizard_getPrototypeOf(CultureWizard),"defaultOptions",this);return t.title=game.i18n.format("WIZARD.addItem",{item:"".concat(game.i18n.localize("TYPES.Item.culture"))}),t.template="systems/dsa5/templates/wizard/add-culture-wizard.html",t}}]),CultureWizard}(P);function career_wizard_typeof(t){return career_wizard_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},career_wizard_typeof(t)}function career_wizard_createForOfIteratorHelper(t,r){var a="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!a){if(Array.isArray(t)||(a=function career_wizard_unsupportedIterableToArray(t,r){if(!t)return;if("string"==typeof t)return career_wizard_arrayLikeToArray(t,r);var a=Object.prototype.toString.call(t).slice(8,-1);"Object"===a&&t.constructor&&(a=t.constructor.name);if("Map"===a||"Set"===a)return Array.from(t);if("Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a))return career_wizard_arrayLikeToArray(t,r)}(t))||r&&t&&"number"==typeof t.length){a&&(t=a);var o=0,i=function F(){};return{s:i,n:function n(){return o>=t.length?{done:!0}:{done:!1,value:t[o++]}},e:function e(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var c,u=!0,l=!1;return{s:function s(){a=a.call(t)},n:function n(){var t=a.next();return u=t.done,t},e:function e(t){l=!0,c=t},f:function f(){try{u||null==a.return||a.return()}finally{if(l)throw c}}}}function career_wizard_arrayLikeToArray(t,r){(null==r||r>t.length)&&(r=t.length);for(var a=0,o=new Array(r);a=0;--o){var i=this.tryEntries[o],c=i.completion;if("root"===i.tryLoc)return handle("end");if(i.tryLoc<=this.prev){var u=a.call(i,"catchLoc"),l=a.call(i,"finallyLoc");if(u&&l){if(this.prev=0;--o){var i=this.tryEntries[o];if(i.tryLoc<=this.prev&&a.call(i,"finallyLoc")&&this.prev=0;--r){var a=this.tryEntries[r];if(a.finallyLoc===t)return this.complete(a.completion,a.afterLoc),resetTryEntry(a),l}},catch:function _catch(t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc===t){var o=a.completion;if("throw"===o.type){var i=o.arg;resetTryEntry(a)}return i}}throw new Error("illegal catch attempt")},delegateYield:function delegateYield(t,r,a){return this.delegate={iterator:values(t),resultName:r,nextLoc:a},"next"===this.method&&(this.arg=void 0),l}},t}function career_wizard_asyncGeneratorStep(t,r,a,o,i,c,u){try{var l=t[c](u),p=l.value}catch(t){return void a(t)}l.done?r(p):Promise.resolve(p).then(o,i)}function career_wizard_asyncToGenerator(t){return function(){var r=this,a=arguments;return new Promise((function(o,i){var c=t.apply(r,a);function _next(t){career_wizard_asyncGeneratorStep(c,o,i,_next,_throw,"next",t)}function _throw(t){career_wizard_asyncGeneratorStep(c,o,i,_next,_throw,"throw",t)}_next(void 0)}))}}function career_wizard_defineProperties(t,r){for(var a=0;aa)return t.currentTarget.checked=!1,void P.flashElem(r.find(".maxTricks"))}var o=Number(r.attr("data-cost"));r.find(".optional:checked").each((function(){o+=Number($(this).attr("data-cost"))})),r.find(".attributes:checked").each((function(){o+=Number($(this).attr("data-cost"))}));var i=r.find(".apCost");i.text(o),P.flashElem(i,"emphasize2")}))}},{key:"_validateInput",value:function _validateInput(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this,a=t.find(".maxTricks"),o=Number(a.attr("data-spelltricklimit"))||0;return t.find(".exclusiveTricks:checked").length!=o?(this._showInputValidation(a,t,r),!1):career_wizard_get(career_wizard_getPrototypeOf(CareerWizard.prototype),"_validateInput",this).call(this,t,r)}},{key:"getData",value:(l=career_wizard_asyncToGenerator(career_wizard_regeneratorRuntime().mark((function _callee(t){var r,a,o,i,c,u,l,p,d,h,m,y,g;return career_wizard_regeneratorRuntime().wrap((function _callee$(v){for(;;)switch(v.prev=v.next){case 0:return v.next=2,career_wizard_get(career_wizard_getPrototypeOf(CareerWizard.prototype),"getData",this).call(this,t);case 2:return r=v.sent,v.next=5,this.parseToItem(this.career.system.requirements.value,["disadvantage","advantage","specialability"]);case 5:return a=v.sent,o=a.filter((function(t){return["advantage","disadvantage"].includes(t.type)&&!t.disabled})),v.next=9,this.parseToItem(this.career.system.recommendedAdvantages.value,["advantage"]);case 9:return i=v.sent,this.fixPreviousCosts(a,i),v.next=13,this.parseToItem(this.career.system.recommendedDisadvantages.value,["disadvantage"]);case 13:return c=v.sent,this.fixPreviousCosts(a,c),u=a.filter((function(t){return t.attributeRequirement})),l=this._parseAttributes(this.career.system.combatSkills.value,/,|;/),p=this._parseAttributes(this.career.system.specialAbilities.value),d=this._parseAttributes(this.career.system.spells.value),h=this._parseAttributes(this.career.system.liturgies.value),m=Number(this.career.system.APValue.value),y=a.reduce((function(t,r){return t+(r.disabled?0:Number(r.system.APValue.value)||0)}),0),g=a.filter((function(t){return"specialability"==t.type&&!t.disabled})),v.t0=mergeObject,v.t1=r,v.t2=game.i18n.format("WIZARD.addItem",{item:"".concat(game.i18n.localize("career")," ").concat(this.career.name)}),v.t3=this.career,v.t4=game.i18n.format("WIZARD.careerdescr",{career:this.career.name,cost:m+y}),v.t5=m,v.t6=i,v.t7=c,v.t8=o,v.t9=p,v.t10=d,v.t11=h,v.t12=g,v.t13=l,v.next=39,this.parseToItem(this.career.system.spelltricks.value,["magictrick"]);case 39:return v.t14=v.sent,v.t15=u,v.t16=i.length,v.t17=c.length,v.t18=i.length||c.length||o.length,v.t19=o.length,v.t20=g.length,v.t21=l.length,v.t22=this.career.system.spelltrickCount.value||d.length,v.t23=h.length,v.t24=u.length,v.t25=g.length||u.length||p.length,v.next=53,TextEditor.enrichHTML(getProperty(this.career.system,"clothing.value"),{secrets:!1,async:!0});case 53:return v.t26=v.sent,v.next=56,TextEditor.enrichHTML(getProperty(this.career.system,"description.value"),{secrets:!1,async:!0});case 56:return v.t27=v.sent,v.t28={title:v.t2,career:v.t3,description:v.t4,baseCost:v.t5,advantages:v.t6,disadvantages:v.t7,missingVantages:v.t8,specAbChoices:v.t9,spellChoices:v.t10,liturgyChoices:v.t11,missingSpecialabilities:v.t12,combatskillchoices:v.t13,spelltricks:v.t14,attributeRequirements:v.t15,advantagesToChose:v.t16,disadvantagesToChose:v.t17,vantagesToChose:v.t18,missingVantagesToChose:v.t19,missingSpecialabiltiesToChose:v.t20,combatToChose:v.t21,magicToChose:v.t22,religionToChose:v.t23,anyAttributeRequirements:v.t24,generalToChose:v.t25,enrichedClothing:v.t26,enrichedDescription:v.t27},(0,v.t0)(v.t1,v.t28),v.abrupt("return",r);case 60:case"end":return v.stop()}}),_callee,this)}))),function getData(t){return l.apply(this,arguments)})},{key:"addCareer",value:(u=career_wizard_asyncToGenerator(career_wizard_regeneratorRuntime().mark((function _callee2(t,r){return career_wizard_regeneratorRuntime().wrap((function _callee2$(a){for(;;)switch(a.prev=a.next){case 0:this.actor=t,this.career=duplicate(r);case 2:case"end":return a.stop()}}),_callee2,this)}))),function addCareer(t,r){return u.apply(this,arguments)})},{key:"setAbility",value:(c=career_wizard_asyncToGenerator(career_wizard_regeneratorRuntime().mark((function _callee3(r,a){var o,i,c,u,l,p,d,h=this,m=arguments;return career_wizard_regeneratorRuntime().wrap((function _callee3$(y){for(;;)switch(y.prev=y.next){case 0:if(o=m.length>2&&void 0!==m[2]?m[2]:[],""!=r.trim()){y.next=3;break}return y.abrupt("return");case 3:i=[],c=[],u=game.i18n.localize("combatskillcountdivider")+":",l=career_wizard_createForOfIteratorHelper(r.split(",").concat(o)),y.prev=7,d=career_wizard_regeneratorRuntime().mark((function _loop(){var r,o,l,d;return career_wizard_regeneratorRuntime().wrap((function _loop$(m){for(;;)switch(m.prev=m.next){case 0:if(!(r=p.value).includes(u)&&""!=r){m.next=3;break}return m.abrupt("return","continue");case 3:if(o=t.Z.parseAbilityString(r.trim()),!(l=h.actor.items.find((function(t){return a.includes(t.type)&&t.name==o.original})))){m.next=12;break}(l=duplicate(l)).system.talentValue?l.system.talentValue.value=o.step:l.system.step&&(l.system.step.value=o.step),l=O.Z.reverseAdoptionCalculation(h.actor,o,l),c.push(l),m.next=20;break;case 12:return m.next=14,h.findCompendiumItem(o.original,a);case 14:if(l=m.sent){m.next=19;break}return m.next=18,h.findCompendiumItem(o.name,a);case 18:l=m.sent;case 19:l?((l=duplicate(l)).name=o.original,l.system.talentValue?l.system.talentValue.value=o.step:l.system.step&&(l.system.step.value=o.step),l=O.Z.reverseAdoptionCalculation(h.actor,o,l),i.push(l)):(d=a.map((function(r){return t.Z.categoryLocalization(r)})).join("/"),h.errors.push("".concat(d,": ").concat(r)),ui.notifications.error(game.i18n.format("DSAError.notFound",{category:d,name:r})));case 20:case"end":return m.stop()}}),_loop)})),l.s();case 10:if((p=l.n()).done){y.next=17;break}return y.delegateYield(d(),"t0",12);case 12:if("continue"!==y.t0){y.next=15;break}return y.abrupt("continue",15);case 15:y.next=10;break;case 17:y.next=22;break;case 19:y.prev=19,y.t1=y.catch(7),l.e(y.t1);case 22:return y.prev=22,l.f(),y.finish(22);case 25:return y.next=27,this.actor.updateEmbeddedDocuments("Item",c,{render:!1});case 27:return y.next=29,this.actor.createEmbeddedDocuments("Item",i,{render:!1});case 29:case"end":return y.stop()}}),_callee3,this,[[7,19,22,25]])}))),function setAbility(t,r){return c.apply(this,arguments)})},{key:"addBlessing",value:(i=career_wizard_asyncToGenerator(career_wizard_regeneratorRuntime().mark((function _callee4(r,a){var o,i,c,u,l=this;return career_wizard_regeneratorRuntime().wrap((function _callee4$(p){for(;;)switch(p.prev=p.next){case 0:o=[],i=career_wizard_createForOfIteratorHelper(r),p.prev=2,u=career_wizard_regeneratorRuntime().mark((function _loop2(){var r,i,u;return career_wizard_regeneratorRuntime().wrap((function _loop2$(p){for(;;)switch(p.prev=p.next){case 0:if(r=c.value,""!=(i=r.trim())){p.next=4;break}return p.abrupt("return","continue");case 4:if(u=l.actor.items.find((function(t){return a==t.type&&t.name==i}))){p.next=10;break}return p.next=8,l.findCompendiumItem(i,[a]);case 8:(u=p.sent)?(u=duplicate(u),o.push(u)):(l.errors.push("".concat(t.Z.categoryLocalization(a),": ").concat(r)),ui.notifications.error(game.i18n.format("DSAError.notFound",{category:game.i18n.localize(a),name:i})));case 10:case"end":return p.stop()}}),_loop2)})),i.s();case 5:if((c=i.n()).done){p.next=12;break}return p.delegateYield(u(),"t0",7);case 7:if("continue"!==p.t0){p.next=10;break}return p.abrupt("continue",10);case 10:p.next=5;break;case 12:p.next=17;break;case 14:p.prev=14,p.t1=p.catch(2),i.e(p.t1);case 17:return p.prev=17,i.f(),p.finish(17);case 20:return p.next=22,this.actor.createEmbeddedDocuments("Item",o,{render:!1});case 22:case"end":return p.stop()}}),_callee4,this,[[2,14,17,20]])}))),function addBlessing(t,r){return i.apply(this,arguments)})},{key:"getExclusiveChoices",value:function getExclusiveChoices(t,r){var a,o=[],i=career_wizard_createForOfIteratorHelper(t.find("".concat(r,".exclusive:checked")));try{for(i.s();!(a=i.n()).done;){var c=a.value;o.push($(c).val())}}catch(t){i.e(t)}finally{i.f()}return o}},{key:"updateCharacter",value:(o=career_wizard_asyncToGenerator(career_wizard_regeneratorRuntime().mark((function _callee5(t){var r,a,o,i,c,u,l,p,d=arguments;return career_wizard_regeneratorRuntime().wrap((function _callee5$(h){for(;;)switch(h.prev=h.next){case 0:if(r=d.length>1&&void 0!==d[1]?d[1]:this,t.find("button.ok i").toggleClass("fa-check fa-spinner fa-spin"),a=Number(t.find(".apCost").text()),h.t1=!this._validateInput(t,r),h.t1){h.next=8;break}return h.next=7,this.actor.checkEnoughXP(a);case 7:h.t1=!h.sent;case 8:if(h.t0=h.t1,h.t0){h.next=13;break}return h.next=12,this.alreadyAdded(this.actor.system.details.career.value,"career");case 12:h.t0=h.sent;case 13:if(!h.t0){h.next=16;break}return t.find("button.ok i").toggleClass("fa-check fa-spinner fa-spin"),h.abrupt("return");case 16:o={"system.details.career.value":this.career.name,"system.freeLanguagePoints.value":this.career.system.languagePoints.value},i=career_wizard_createForOfIteratorHelper(t.find(".attributes"));try{for(i.s();!(c=i.n()).done;)u=c.value,l=$(u).attr("data-attribute").toLowerCase(),l=game.dsa5.config.knownShortcuts[l.toLowerCase()][1],Number(this.actor.system.characteristics[l].initial)+Number(this.actor.system.characteristics[l].advances)=t.length?{done:!0}:{done:!1,value:t[o++]}},e:function e(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var c,u=!0,l=!1;return{s:function s(){a=a.call(t)},n:function n(){var t=a.next();return u=t.done,t},e:function e(t){l=!0,c=t},f:function f(){try{u||null==a.return||a.return()}finally{if(l)throw c}}}}function species_wizard_arrayLikeToArray(t,r){(null==r||r>t.length)&&(r=t.length);for(var a=0,o=new Array(r);a=0;--o){var i=this.tryEntries[o],c=i.completion;if("root"===i.tryLoc)return handle("end");if(i.tryLoc<=this.prev){var u=a.call(i,"catchLoc"),l=a.call(i,"finallyLoc");if(u&&l){if(this.prev=0;--o){var i=this.tryEntries[o];if(i.tryLoc<=this.prev&&a.call(i,"finallyLoc")&&this.prev=0;--r){var a=this.tryEntries[r];if(a.finallyLoc===t)return this.complete(a.completion,a.afterLoc),resetTryEntry(a),l}},catch:function _catch(t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc===t){var o=a.completion;if("throw"===o.type){var i=o.arg;resetTryEntry(a)}return i}}throw new Error("illegal catch attempt")},delegateYield:function delegateYield(t,r,a){return this.delegate={iterator:values(t),resultName:r,nextLoc:a},"next"===this.method&&(this.arg=void 0),l}},t}function species_wizard_asyncGeneratorStep(t,r,a,o,i,c,u){try{var l=t[c](u),p=l.value}catch(t){return void a(t)}l.done?r(p):Promise.resolve(p).then(o,i)}function species_wizard_asyncToGenerator(t){return function(){var r=this,a=arguments;return new Promise((function(o,i){var c=t.apply(r,a);function _next(t){species_wizard_asyncGeneratorStep(c,o,i,_next,_throw,"next",t)}function _throw(t){species_wizard_asyncGeneratorStep(c,o,i,_next,_throw,"throw",t)}_next(void 0)}))}}function species_wizard_classCallCheck(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}function species_wizard_defineProperties(t,r){for(var a=0;a1)){u.next=9;break}return u.t0=o[0].trim(),u.next=5,i.parseToItem(o[1].trim(),r);case 5:u.t1=u.sent,c={name:u.t0,res:u.t1},u.next=13;break;case 9:return u.next=11,i.parseToItem(t,r);case 11:u.t2=u.sent,c={name:"",res:u.t2};case 13:return i.fixPreviousCosts(a,c.res),u.abrupt("return",c);case 15:case"end":return u.stop()}}),_callee)})));return function(r){return t.apply(this,arguments)}}()));case 2:return o=c.sent,c.abrupt("return",o);case 4:case"end":return c.stop()}}),_callee2)}))),function _toGroups(t,r,a){return c.apply(this,arguments)})},{key:"getData",value:(i=species_wizard_asyncToGenerator(species_wizard_regeneratorRuntime().mark((function _callee3(t){var r,a,o,i,c,u,l,p;return species_wizard_regeneratorRuntime().wrap((function _callee3$(d){for(;;)switch(d.prev=d.next){case 0:return d.next=2,species_wizard_get(species_wizard_getPrototypeOf(SpeciesWizard.prototype),"getData",this).call(this,t);case 2:return r=d.sent,d.next=5,this.parseToItem(this.species.system.requirements.value,["disadvantage","advantage"]);case 5:return a=d.sent,o=a.filter((function(t){return["advantage","disadvantage"].includes(t.type)&&!t.disabled})),d.next=9,this._toGroups(this.species.system.recommendedAdvantages.value,["advantage"],a);case 9:return i=d.sent,d.next=12,this._toGroups(this.species.system.recommendedDisadvantages.value,["disadvantage"],a);case 12:return c=d.sent,u=this._parseAttributes(this.species.system.attributeChange.value),l=Number(this.species.system.APValue.value),p=a.reduce((function(t,r){return t+(r.disabled?0:Number(r.system.APValue.value)||0)}),0),mergeObject(r,{title:game.i18n.format("WIZARD.addItem",{item:"".concat(game.i18n.localize("TYPES.Item.species")," ").concat(this.species.name)}),species:this.species,description:game.i18n.format("WIZARD.speciesdescr",{species:this.species.name,cost:l+p}),advantagegroups:i,baseCost:l,disadvantagegroups:c,missingVantages:o,attributeRequirements:u,hasLocalization:game.i18n.has("Racedescr.".concat(this.species.name)),anyAttributeRequirements:u.length>0,advantagesToChose:i.length>0,missingVantagesToChose:o.length>0,disadvantagesToChose:c.length>0,vantagesToChose:i.length>0||c.length>0||o.length>0,generalToChose:u.length>0}),d.abrupt("return",r);case 18:case"end":return d.stop()}}),_callee3,this)}))),function getData(t){return i.apply(this,arguments)})},{key:"addSpecies",value:(o=species_wizard_asyncToGenerator(species_wizard_regeneratorRuntime().mark((function _callee4(t,r){return species_wizard_regeneratorRuntime().wrap((function _callee4$(a){for(;;)switch(a.prev=a.next){case 0:this.actor=t,this.species=duplicate(r);case 2:case"end":return a.stop()}}),_callee4,this)}))),function addSpecies(t,r){return o.apply(this,arguments)})},{key:"updateCharacter",value:(a=species_wizard_asyncToGenerator(species_wizard_regeneratorRuntime().mark((function _callee5(t){var a,o,i,c,u,l,p,d,h,m,y,g,v=arguments;return species_wizard_regeneratorRuntime().wrap((function _callee5$(_){for(;;)switch(_.prev=_.next){case 0:if(a=v.length>1&&void 0!==v[1]?v[1]:this,t.find("button.ok i").toggleClass("fa-check fa-spinner fa-spin"),o=Number(t.find(".apCost").text()),_.t1=!this._validateInput(t,a),_.t1){_.next=8;break}return _.next=7,this.actor.checkEnoughXP(o);case 7:_.t1=!_.sent;case 8:if(_.t0=_.t1,_.t0){_.next=13;break}return _.next=12,this.alreadyAdded(this.actor.system.details.species.value,"species");case 12:_.t0=_.sent;case 13:if(!_.t0){_.next=16;break}return t.find("button.ok i").toggleClass("fa-check fa-spinner fa-spin"),_.abrupt("return");case 16:i={"system.details.species.value":this.species.name,"system.status.speed.initial":this.species.system.baseValues.speed.value,"system.status.soulpower.initial":this.species.system.baseValues.soulpower.value,"system.status.toughness.initial":this.species.system.baseValues.toughness.value,"system.status.wounds.initial":this.species.system.baseValues.wounds.value,"system.status.wounds.value":this.species.system.baseValues.wounds.value+2*this.actor.system.characteristics.ko.value},c=[],u=species_wizard_createForOfIteratorHelper(t.find(".exclusive:checked"));try{for(u.s();!(l=u.n()).done;)p=l.value,c.push($(p).val())}catch(t){u.e(t)}finally{u.f()}Object.keys(r.Z.characteristics).forEach((function(t){i["system.characteristics.".concat(t,".species")]=0})),d=species_wizard_createForOfIteratorHelper(this.species.system.attributeChange.value.split(",").concat(c)),_.prev=22,d.s();case 24:if((h=d.n()).done){_.next=34;break}if(!(m=h.value).includes(game.i18n.localize("combatskillcountdivider")+":")&&""!=m){_.next=28;break}return _.abrupt("continue",32);case 28:y=m.trim().split(" "),(g=game.dsa5.config.knownShortcuts[y[0].toLowerCase().trim()].slice(0))[g.length-1]="species",i["system.".concat(g.join("."))]=Number(y[1]);case 32:_.next=24;break;case 34:_.next=39;break;case 36:_.prev=36,_.t2=_.catch(22),d.e(_.t2);case 39:return _.prev=39,d.f(),_.finish(39);case 42:return _.next=44,this.actor._updateAPs(o,{},{render:!1});case 44:return _.next=46,this.addSelections(t.find(".optional:checked"),!1);case 46:return _.next=48,this.actor.update(i);case 48:return _.next=50,this.actor.removeCondition("incapacitated");case 50:this.finalizeUpdate();case 51:case"end":return _.stop()}}),_callee5,this,[[22,36,39,42]])}))),function updateCharacter(t){return a.apply(this,arguments)})}],[{key:"defaultOptions",get:function get(){var t=species_wizard_get(species_wizard_getPrototypeOf(SpeciesWizard),"defaultOptions",this);return t.title=game.i18n.format("WIZARD.addItem",{item:"".concat(game.i18n.localize("TYPES.Item.species"))}),t.template="systems/dsa5/templates/wizard/add-species-wizard.html",t}}]),SpeciesWizard}(P);function character_sheet_typeof(t){return character_sheet_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},character_sheet_typeof(t)}function character_sheet_regeneratorRuntime(){character_sheet_regeneratorRuntime=function _regeneratorRuntime(){return t};var t={},r=Object.prototype,a=r.hasOwnProperty,o="function"==typeof Symbol?Symbol:{},i=o.iterator||"@@iterator",c=o.asyncIterator||"@@asyncIterator",u=o.toStringTag||"@@toStringTag";function define(t,r,a){return Object.defineProperty(t,r,{value:a,enumerable:!0,configurable:!0,writable:!0}),t[r]}try{define({},"")}catch(t){define=function define(t,r,a){return t[r]=a}}function wrap(t,r,a,o){var i=r&&r.prototype instanceof Generator?r:Generator,c=Object.create(i.prototype),u=new Context(o||[]);return c._invoke=function(t,r,a){var o="suspendedStart";return function(i,c){if("executing"===o)throw new Error("Generator is already running");if("completed"===o){if("throw"===i)throw c;return doneResult()}for(a.method=i,a.arg=c;;){var u=a.delegate;if(u){var p=maybeInvokeDelegate(u,a);if(p){if(p===l)continue;return p}}if("next"===a.method)a.sent=a._sent=a.arg;else if("throw"===a.method){if("suspendedStart"===o)throw o="completed",a.arg;a.dispatchException(a.arg)}else"return"===a.method&&a.abrupt("return",a.arg);o="executing";var d=tryCatch(t,r,a);if("normal"===d.type){if(o=a.done?"completed":"suspendedYield",d.arg===l)continue;return{value:d.arg,done:a.done}}"throw"===d.type&&(o="completed",a.method="throw",a.arg=d.arg)}}}(t,a,u),c}function tryCatch(t,r,a){try{return{type:"normal",arg:t.call(r,a)}}catch(t){return{type:"throw",arg:t}}}t.wrap=wrap;var l={};function Generator(){}function GeneratorFunction(){}function GeneratorFunctionPrototype(){}var p={};define(p,i,(function(){return this}));var d=Object.getPrototypeOf,h=d&&d(d(values([])));h&&h!==r&&a.call(h,i)&&(p=h);var m=GeneratorFunctionPrototype.prototype=Generator.prototype=Object.create(p);function defineIteratorMethods(t){["next","throw","return"].forEach((function(r){define(t,r,(function(t){return this._invoke(r,t)}))}))}function AsyncIterator(t,r){function invoke(o,i,c,u){var l=tryCatch(t[o],t,i);if("throw"!==l.type){var p=l.arg,d=p.value;return d&&"object"==character_sheet_typeof(d)&&a.call(d,"__await")?r.resolve(d.__await).then((function(t){invoke("next",t,c,u)}),(function(t){invoke("throw",t,c,u)})):r.resolve(d).then((function(t){p.value=t,c(p)}),(function(t){return invoke("throw",t,c,u)}))}u(l.arg)}var o;this._invoke=function(t,a){function callInvokeWithMethodAndArg(){return new r((function(r,o){invoke(t,a,r,o)}))}return o=o?o.then(callInvokeWithMethodAndArg,callInvokeWithMethodAndArg):callInvokeWithMethodAndArg()}}function maybeInvokeDelegate(t,r){var a=t.iterator[r.method];if(void 0===a){if(r.delegate=null,"throw"===r.method){if(t.iterator.return&&(r.method="return",r.arg=void 0,maybeInvokeDelegate(t,r),"throw"===r.method))return l;r.method="throw",r.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var o=tryCatch(a,t.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,l;var i=o.arg;return i?i.done?(r[t.resultName]=i.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=void 0),r.delegate=null,l):i:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,l)}function pushTryEntry(t){var r={tryLoc:t[0]};1 in t&&(r.catchLoc=t[1]),2 in t&&(r.finallyLoc=t[2],r.afterLoc=t[3]),this.tryEntries.push(r)}function resetTryEntry(t){var r=t.completion||{};r.type="normal",delete r.arg,t.completion=r}function Context(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(pushTryEntry,this),this.reset(!0)}function values(t){if(t){var r=t[i];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var o=-1,c=function next(){for(;++o=0;--o){var i=this.tryEntries[o],c=i.completion;if("root"===i.tryLoc)return handle("end");if(i.tryLoc<=this.prev){var u=a.call(i,"catchLoc"),l=a.call(i,"finallyLoc");if(u&&l){if(this.prev=0;--o){var i=this.tryEntries[o];if(i.tryLoc<=this.prev&&a.call(i,"finallyLoc")&&this.prev=0;--r){var a=this.tryEntries[r];if(a.finallyLoc===t)return this.complete(a.completion,a.afterLoc),resetTryEntry(a),l}},catch:function _catch(t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc===t){var o=a.completion;if("throw"===o.type){var i=o.arg;resetTryEntry(a)}return i}}throw new Error("illegal catch attempt")},delegateYield:function delegateYield(t,r,a){return this.delegate={iterator:values(t),resultName:r,nextLoc:a},"next"===this.method&&(this.arg=void 0),l}},t}function character_sheet_asyncGeneratorStep(t,r,a,o,i,c,u){try{var l=t[c](u),p=l.value}catch(t){return void a(t)}l.done?r(p):Promise.resolve(p).then(o,i)}function character_sheet_classCallCheck(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}function character_sheet_defineProperties(t,r){for(var a=0;a=0;--o){var i=this.tryEntries[o],c=i.completion;if("root"===i.tryLoc)return handle("end");if(i.tryLoc<=this.prev){var u=a.call(i,"catchLoc"),l=a.call(i,"finallyLoc");if(u&&l){if(this.prev=0;--o){var i=this.tryEntries[o];if(i.tryLoc<=this.prev&&a.call(i,"finallyLoc")&&this.prev=0;--r){var a=this.tryEntries[r];if(a.finallyLoc===t)return this.complete(a.completion,a.afterLoc),resetTryEntry(a),l}},catch:function _catch(t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc===t){var o=a.completion;if("throw"===o.type){var i=o.arg;resetTryEntry(a)}return i}}throw new Error("illegal catch attempt")},delegateYield:function delegateYield(t,r,a){return this.delegate={iterator:values(t),resultName:r,nextLoc:a},"next"===this.method&&(this.arg=void 0),l}},t}function creature_sheet_asyncGeneratorStep(t,r,a,o,i,c,u){try{var l=t[c](u),p=l.value}catch(t){return void a(t)}l.done?r(p):Promise.resolve(p).then(o,i)}function creature_sheet_asyncToGenerator(t){return function(){var r=this,a=arguments;return new Promise((function(o,i){var c=t.apply(r,a);function _next(t){creature_sheet_asyncGeneratorStep(c,o,i,_next,_throw,"next",t)}function _throw(t){creature_sheet_asyncGeneratorStep(c,o,i,_next,_throw,"throw",t)}_next(void 0)}))}}function creature_sheet_classCallCheck(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}function creature_sheet_defineProperties(t,r){for(var a=0;a=0;--o){var i=this.tryEntries[o],c=i.completion;if("root"===i.tryLoc)return handle("end");if(i.tryLoc<=this.prev){var u=a.call(i,"catchLoc"),l=a.call(i,"finallyLoc");if(u&&l){if(this.prev=0;--o){var i=this.tryEntries[o];if(i.tryLoc<=this.prev&&a.call(i,"finallyLoc")&&this.prev=0;--r){var a=this.tryEntries[r];if(a.finallyLoc===t)return this.complete(a.completion,a.afterLoc),resetTryEntry(a),l}},catch:function _catch(t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc===t){var o=a.completion;if("throw"===o.type){var i=o.arg;resetTryEntry(a)}return i}}throw new Error("illegal catch attempt")},delegateYield:function delegateYield(t,r,a){return this.delegate={iterator:values(t),resultName:r,nextLoc:a},"next"===this.method&&(this.arg=void 0),l}},t}function obfuscatemixin_asyncGeneratorStep(t,r,a,o,i,c,u){try{var l=t[c](u),p=l.value}catch(t){return void a(t)}l.done?r(p):Promise.resolve(p).then(o,i)}function obfuscatemixin_asyncToGenerator(t){return function(){var r=this,a=arguments;return new Promise((function(o,i){var c=t.apply(r,a);function _next(t){obfuscatemixin_asyncGeneratorStep(c,o,i,_next,_throw,"next",t)}function _throw(t){obfuscatemixin_asyncGeneratorStep(c,o,i,_next,_throw,"throw",t)}_next(void 0)}))}}function obfuscatemixin_classCallCheck(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}function obfuscatemixin_defineProperties(t,r){for(var a=0;a0&&void 0!==v[0]&&v[0],r=v.length>1&&void 0!==v[1]?v[1]:{},_.next=4,obfuscatemixin_get(obfuscatemixin_getPrototypeOf(_class.prototype),"_render",this).call(this,t,r);case 4:a=!1,o=0,i=["details","effects","description","enchantment"];case 7:if(!(o'),h.length?h.replaceWith(m):u.append(" ".concat(m))):l&&(u.hasClass("active")&&(a=!0),u.remove(),"details"==c&&$(this._element).find('[name="system.price.value"],[name="system.price.raw"]').replaceWith(""));case 15:o++,_.next=7;break;case 18:if(!a){_.next=28;break}if(!(y=$(this._element).find("nav .item:first-child")).length){_.next=24;break}this.activateTab(y.attr("data-tab")),_.next=28;break;case 24:return _.next=26,renderTemplate("systems/dsa5/templates/items/obfuscatedItem.html",{item:this.item});case 26:g=_.sent,$(this._element).find(".content").html(g);case 28:case"end":return _.stop()}}),_callee2,this)}))),function _render(){return r.apply(this,arguments)})}]),_class}(t)},N=__webpack_require__(600);function item_sheet_typeof(t){return item_sheet_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},item_sheet_typeof(t)}function item_sheet_defineProperty(t,r,a){return r in t?Object.defineProperty(t,r,{value:a,enumerable:!0,configurable:!0,writable:!0}):t[r]=a,t}function item_sheet_createForOfIteratorHelper(t,r){var a="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!a){if(Array.isArray(t)||(a=function item_sheet_unsupportedIterableToArray(t,r){if(!t)return;if("string"==typeof t)return item_sheet_arrayLikeToArray(t,r);var a=Object.prototype.toString.call(t).slice(8,-1);"Object"===a&&t.constructor&&(a=t.constructor.name);if("Map"===a||"Set"===a)return Array.from(t);if("Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a))return item_sheet_arrayLikeToArray(t,r)}(t))||r&&t&&"number"==typeof t.length){a&&(t=a);var o=0,i=function F(){};return{s:i,n:function n(){return o>=t.length?{done:!0}:{done:!1,value:t[o++]}},e:function e(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var c,u=!0,l=!1;return{s:function s(){a=a.call(t)},n:function n(){var t=a.next();return u=t.done,t},e:function e(t){l=!0,c=t},f:function f(){try{u||null==a.return||a.return()}finally{if(l)throw c}}}}function item_sheet_arrayLikeToArray(t,r){(null==r||r>t.length)&&(r=t.length);for(var a=0,o=new Array(r);a=0;--o){var i=this.tryEntries[o],c=i.completion;if("root"===i.tryLoc)return handle("end");if(i.tryLoc<=this.prev){var u=a.call(i,"catchLoc"),l=a.call(i,"finallyLoc");if(u&&l){if(this.prev=0;--o){var i=this.tryEntries[o];if(i.tryLoc<=this.prev&&a.call(i,"finallyLoc")&&this.prev=0;--r){var a=this.tryEntries[r];if(a.finallyLoc===t)return this.complete(a.completion,a.afterLoc),resetTryEntry(a),l}},catch:function _catch(t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc===t){var o=a.completion;if("throw"===o.type){var i=o.arg;resetTryEntry(a)}return i}}throw new Error("illegal catch attempt")},delegateYield:function delegateYield(t,r,a){return this.delegate={iterator:values(t),resultName:r,nextLoc:a},"next"===this.method&&(this.arg=void 0),l}},t}function item_sheet_asyncGeneratorStep(t,r,a,o,i,c,u){try{var l=t[c](u),p=l.value}catch(t){return void a(t)}l.done?r(p):Promise.resolve(p).then(o,i)}function item_sheet_asyncToGenerator(t){return function(){var r=this,a=arguments;return new Promise((function(o,i){var c=t.apply(r,a);function _next(t){item_sheet_asyncGeneratorStep(c,o,i,_next,_throw,"next",t)}function _throw(t){item_sheet_asyncGeneratorStep(c,o,i,_next,_throw,"throw",t)}_next(void 0)}))}}function item_sheet_classCallCheck(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}function item_sheet_defineProperties(t,r){for(var a=0;a0&&void 0!==arguments[0]?arguments[0]:{},r=item_sheet_get(item_sheet_getPrototypeOf(ItemSheetdsa5.prototype),"_getSubmitData",this).call(this,t),a=foundry.utils.flattenObject(this.item.overrides||{});return Object.keys(a).forEach((function(t){return delete r[t]})),r}},{key:"_render",value:(c=item_sheet_asyncToGenerator(item_sheet_regeneratorRuntime().mark((function _callee(){var t,r,a=arguments;return item_sheet_regeneratorRuntime().wrap((function _callee$(o){for(;;)switch(o.prev=o.next){case 0:return t=a.length>0&&void 0!==a[0]&&a[0],r=a.length>1&&void 0!==a[1]?a[1]:{},o.next=4,item_sheet_get(item_sheet_getPrototypeOf(ItemSheetdsa5.prototype),"_render",this).call(this,t,r);case 4:$(this._element).find(".close").attr("data-tooltip","SHEET.Close"),$(this._element).find(".configure-sheet").attr("data-tooltip","SHEET.Configure"),$(this._element).find(".import").attr("data-tooltip","SHEET.Import"),$(this._element).find(".rolleffect").attr("data-tooltip","SHEET.RollEffect"),$(this._element).find(".showItemHead").attr("data-tooltip","SHEET.PostItem"),$(this._element).find(".consumeItem").attr("data-tooltip","SHEET.ConsumeItem"),$(this._element).find(".rollDamaged").attr("data-tooltip","DSASETTINGS.armorAndWeaponDamage"),$(this._element).find(".onUseEffect").attr("data-tooltip","SHEET.onUseEffect");case 12:case"end":return o.stop()}}),_callee,this)}))),function _render(){return c.apply(this,arguments)})},{key:"_getHeaderButtons",value:function _getHeaderButtons(){var t,r,a=this,o=item_sheet_get(item_sheet_getPrototypeOf(ItemSheetdsa5.prototype),"_getHeaderButtons",this).call(this);return o.unshift({class:"showItemHead",icon:"fas fa-comment",onclick:(t=item_sheet_asyncToGenerator(item_sheet_regeneratorRuntime().mark((function _callee2(){return item_sheet_regeneratorRuntime().wrap((function _callee2$(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",a.item.postItem());case 1:case"end":return t.stop()}}),_callee2)}))),function onclick(){return t.apply(this,arguments)})}),this.item.actor&&g.Z.getOnUseEffect(this.item)&&o.unshift({class:"onUseEffect",icon:"fas fa-dice-six",onclick:(r=item_sheet_asyncToGenerator(item_sheet_regeneratorRuntime().mark((function _callee3(){return item_sheet_regeneratorRuntime().wrap((function _callee3$(t){for(;;)switch(t.prev=t.next){case 0:new g.Z(a.item).executeOnUseEffect();case 2:case"end":return t.stop()}}),_callee3)}))),function onclick(){return r.apply(this,arguments)})}),o}},{key:"setupEffect",value:function setupEffect(t){var r=this;this.item.setupEffect().then((function(t){return r.item.itemTest(t)}))}},{key:"template",get:function get(){return"systems/dsa5/templates/items/item-".concat(this.item.type,"-sheet.html")}},{key:"_getItemId",value:function _getItemId(t){return $(t.currentTarget).parents(".item").attr("data-item-id")}},{key:"_advanceStep",value:function _advanceStep(){}},{key:"_refundStep",value:function _refundStep(){}},{key:"advanceWrapper",value:(i=item_sheet_asyncToGenerator(item_sheet_regeneratorRuntime().mark((function _callee4(t,r){var a,o;return item_sheet_regeneratorRuntime().wrap((function _callee4$(i){for(;;)switch(i.prev=i.next){case 0:if(a=$(t.currentTarget),(o=a.find("i")).hasClass("fa-spin")){i.next=7;break}return o.addClass("fa-spin fa-spinner"),i.next=6,this[r]();case 6:o.removeClass("fa-spin fa-spinner");case 7:case"end":return i.stop()}}),_callee4,this)}))),function advanceWrapper(t,r){return i.apply(this,arguments)})},{key:"activateListeners",value:function activateListeners(r){var a=this;item_sheet_get(item_sheet_getPrototypeOf(ItemSheetdsa5.prototype),"activateListeners",this).call(this,r),(0,h.Ee)(r),r.find(".advance-step").mousedown((function(t){return a.advanceWrapper(t,"_advanceStep")})),r.find(".refund-step").mousedown((function(t){return a.advanceWrapper(t,"_refundStep")})),r.find(".domainsPretty").click((function(t){$(t.currentTarget).hide(),$(t.currentTarget).next(".domainToggle").show()})),r.find('[data-edit="img"]').mousedown((function(r){2==r.button&&t.Z.showArtwork(a.item)})),r.find(".status-add").click((function(){u.Z.createCustomEffect(a.item,"",a.item.name)})),r.find(".condition-show").mousedown((function(t){t.preventDefault();var r=t.currentTarget.dataset.id;0==t.button?a.item.effects.get(r).sheet.render(!0):2==t.button&&a.item.deleteEmbeddedDocuments("ActiveEffect",[r])})),r.find(".select2").select2(),r.find(".condition-toggle").mousedown((function(t){var r=$(t.currentTarget).parents(".statusEffect").attr("data-id"),o=a.item.effects.get(r);o.update({disabled:!o.disabled})})),r.find(".condition-edit").click((function(t){a.item.effects.get(t.currentTarget.dataset.id).sheet.render(!0)})),_.Z.bindRollCommands(r),u.Z.bindButtons(r);var o=r.find(".item-header");if(o.length){var i=o.find("svg");if(i){new ResizeObserver((function(t){var r=t[0];(0,h.zJ)(i,r.contentRect.width)})).observe(o.get(0));var c=o.find("input");c.get(0).disabled||(i.click((function(){i.hide(),c.show(),c.focus()})),c.blur((function(){i.show(),c.hide()})))}}}},{key:"getData",value:(o=item_sheet_asyncToGenerator(item_sheet_regeneratorRuntime().mark((function _callee5(a){var o,i;return item_sheet_regeneratorRuntime().wrap((function _callee5$(c){for(;;)switch(c.prev=c.next){case 0:o=item_sheet_get(item_sheet_getPrototypeOf(ItemSheetdsa5.prototype),"getData",this).call(this,a).data,c.t0=this.item.type,c.next="skill"===c.t0?4:"application"===c.t0?10:"combatskill"===c.t0?16:"trait"===c.t0?21:24;break;case 4:return o.characteristics=r.Z.characteristics,o.skillGroups=r.Z.skillGroups,o.skillBurdens=r.Z.skillBurdens,o.hasLocalization=game.i18n.has("SKILLdescr.".concat(this.item.name)),o.StFs=r.Z.StFs,c.abrupt("break",24);case 10:return o.hasLocalization=game.i18n.has("APPLICATION.".concat(this.item.system.skill," - ").concat(this.item.name)),o.localization=game.i18n.localize("APPLICATION.".concat(this.item.system.skill," - ").concat(this.item.name)),c.next=14,t.Z.allSkillsList();case 14:return o.allSkills=c.sent,c.abrupt("break",24);case 16:return o.weapontypes=r.Z.weapontypes,o.guidevalues=r.Z.combatskillsGuidevalues,o.hasLocalization=game.i18n.has("Combatskilldescr.".concat(this.item.name)),o.StFs=r.Z.StFs,c.abrupt("break",24);case 21:return o.traitCategories=r.Z.traitCategories,o.ranges=r.Z.meleeRanges,c.abrupt("break",24);case 24:return o.isOwned=this.item.actor,o.editable=this.isEditable,o.isOwned&&(o.canAdvance=this.item.actor.canAdvance&&this._advancable(),i=getProperty(this.item,"flags.dsa5.customPriceTag"),!this.isEditable&&i&&(o.customPrice=i)),u.Z.prepareActiveEffects(this.item,o),o.item=this.item,o.armorAndWeaponDamage=game.settings.get("dsa5","armorAndWeaponDamage"),o.isGM=game.user.isGM,c.next=33,TextEditor.enrichHTML(getProperty(this.item.system,"description.value"),{secrets:this.object.isOwner,async:!0});case 33:return o.enrichedDescription=c.sent,c.next=36,TextEditor.enrichHTML(getProperty(this.item.system,"gmdescription.value"),{secrets:this.object.isOwner,async:!0});case 36:return o.enrichedGmdescription=c.sent,c.abrupt("return",o);case 38:case"end":return c.stop()}}),_callee5,this)}))),function getData(t){return o.apply(this,arguments)})},{key:"_advancable",value:function _advancable(){return!1}}],[{key:"defaultOptions",get:function get(){var t=item_sheet_get(item_sheet_getPrototypeOf(ItemSheetdsa5),"defaultOptions",this);return mergeObject(t,{tabs:[{navSelector:".tabs",contentSelector:".content"}],classes:t.classes.concat(["dsa5","item"]),width:471,height:500}),t}},{key:"setupSheets",value:function setupSheets(){Items.unregisterSheet("core",ItemSheet),Items.registerSheet("dsa5",ItemSheetdsa5,{makeDefault:!0}),Items.registerSheet("dsa5",se,{makeDefault:!0,types:["species"]}),Items.registerSheet("dsa5",ee,{makeDefault:!0,types:["career"]}),Items.registerSheet("dsa5",re,{makeDefault:!0,types:["culture"]}),Items.registerSheet("dsa5",fe,{makeDefault:!0,types:["advantage","disadvantage"]}),Items.registerSheet("dsa5",ue,{makeDefault:!0,types:["ritual","ceremony","liturgy","spell"]}),Items.registerSheet("dsa5",ce,{makeDefault:!0,types:["specialability"]}),Items.registerSheet("dsa5",oe,{makeDefault:!0,types:["meleeweapon"]}),Items.registerSheet("dsa5",ie,{makeDefault:!0,types:["poison"]}),Items.registerSheet("dsa5",ne,{makeDefault:!0,types:["disease"]}),Items.registerSheet("dsa5",te,{makeDefault:!0,types:["consumable"]}),Items.registerSheet("dsa5",le,{makeDefault:!0,types:["spellextension"]}),Items.registerSheet("dsa5",ae,{makeDefault:!0,types:["magictrick"]}),Items.registerSheet("dsa5",X,{makeDefault:!0,types:["blessing"]}),Items.registerSheet("dsa5",Q,{makeDefault:!0,types:["rangeweapon"]}),Items.registerSheet("dsa5",U,{makeDefault:!0,types:["equipment"]}),Items.registerSheet("dsa5",Y,{makeDefault:!0,types:["armor"]}),Items.registerSheet("dsa5",q,{makeDefault:!0,types:["ammunition"]}),Items.registerSheet("dsa5",V,{makeDefault:!0,types:["plant"]}),Items.registerSheet("dsa5",J,{makeDefault:!0,types:["magicalsign"]}),Items.registerSheet("dsa5",K,{makeDefault:!0,types:["patron"]}),Items.registerSheet("dsa5",B,{makeDefault:!0,types:["information"]}),Items.registerSheet("dsa5",Z,{makeDefault:!0,types:["aggregatedTest"]}),Items.unregisterSheet("dsa5",ItemSheetdsa5,{types:["armor","equipment","rangeweapon","blessing","magictrick","spellextension","consumable","aggregatedTest","species","career","culture","advantage","specialability","disadvantage","ritual","information","ceremony","liturgy","spell","disease","poison","meleeweapon","ammunition","plant","magicalsign","patron"]})}}]),ItemSheetdsa5}(),Z=function(r){item_sheet_inherits(AggregatedTestSheet,r);var a,o,i=item_sheet_createSuper(AggregatedTestSheet);function AggregatedTestSheet(){return item_sheet_classCallCheck(this,AggregatedTestSheet),i.apply(this,arguments)}return item_sheet_createClass(AggregatedTestSheet,[{key:"getData",value:(o=item_sheet_asyncToGenerator(item_sheet_regeneratorRuntime().mark((function _callee6(r){var a,o,i;return item_sheet_regeneratorRuntime().wrap((function _callee6$(c){for(;;)switch(c.prev=c.next){case 0:return c.next=2,item_sheet_get(item_sheet_getPrototypeOf(AggregatedTestSheet.prototype),"getData",this).call(this,r);case 2:if(a=c.sent,!(o=this.item.getFlag("dsa5","embeddedItem"))){c.next=8;break}return c.next=7,renderTemplate("systems/dsa5/templates/items/browse/".concat(o.type,".html"),{document:o});case 7:i=c.sent;case 8:return c.t0=mergeObject,c.t1=a,c.next=12,t.Z.allSkillsList();case 12:return c.t2=c.sent,c.t3=o,c.t4=i,c.t5={allSkills:c.t2,embeddedItem:c.t3,renderedItem:c.t4},(0,c.t0)(c.t1,c.t5),c.abrupt("return",a);case 18:case"end":return c.stop()}}),_callee6,this)}))),function getData(t){return o.apply(this,arguments)})},{key:"activateListeners",value:function activateListeners(t){var r=this;item_sheet_get(item_sheet_getPrototypeOf(AggregatedTestSheet.prototype),"activateListeners",this).call(this,t),t.find(".buildItem").click(item_sheet_asyncToGenerator(item_sheet_regeneratorRuntime().mark((function _callee7(){return item_sheet_regeneratorRuntime().wrap((function _callee7$(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",r.postFinishedItem());case 1:case"end":return t.stop()}}),_callee7)}))))}},{key:"postFinishedItem",value:(a=item_sheet_asyncToGenerator(item_sheet_regeneratorRuntime().mark((function _callee8(){var r,a,o;return item_sheet_regeneratorRuntime().wrap((function _callee8$(i){for(;;)switch(i.prev=i.next){case 0:if(this.item.actor){i.next=2;break}return i.abrupt("return");case 2:if(r=this.item.getFlag("dsa5","embeddedItem")){i.next=5;break}return i.abrupt("return");case 5:return i.next=7,renderTemplate("systems/dsa5/templates/chat/production-result.html",{actor:this.item.actor,item:r,actorImg:N.Z.videoOrImgTag(this.item.actor.img)});case 7:return a=i.sent,(o=t.Z.chatDataSetup(a)).flags={dsa5:{embeddedItem:r}},i.next=12,ChatMessage.create(o);case 12:case"end":return i.stop()}}),_callee8,this)}))),function postFinishedItem(){return a.apply(this,arguments)})}]),AggregatedTestSheet}(H),W=function(a){item_sheet_inherits(Enchantable,a);var o,i,c,u,l,p,d=item_sheet_createSuper(Enchantable);function Enchantable(){return item_sheet_classCallCheck(this,Enchantable),d.apply(this,arguments)}return item_sheet_createClass(Enchantable,[{key:"_onDrop",value:(p=item_sheet_asyncToGenerator(item_sheet_regeneratorRuntime().mark((function _callee9(t){return item_sheet_regeneratorRuntime().wrap((function _callee9$(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,this.enchant(t);case 2:if(!this.isPoisonable){r.next=5;break}return r.next=5,this.poison(t);case 5:case"end":return r.stop()}}),_callee9,this)}))),function _onDrop(t){return p.apply(this,arguments)})},{key:"enchant",value:(l=item_sheet_asyncToGenerator(item_sheet_regeneratorRuntime().mark((function _callee10(t){var r;return item_sheet_regeneratorRuntime().wrap((function _callee10$(a){for(;;)switch(a.prev=a.next){case 0:return r=JSON.parse(t.dataTransfer.getData("text/plain")),a.next=3,this._enchant([r]);case 3:case"end":return a.stop()}}),_callee10,this)}))),function enchant(t){return l.apply(this,arguments)})},{key:"_enchant",value:(u=item_sheet_asyncToGenerator(item_sheet_regeneratorRuntime().mark((function _callee11(t){var r,a,o,i,c,u,l,p,d;return item_sheet_regeneratorRuntime().wrap((function _callee11$(m){for(;;)switch(m.prev=m.next){case 0:if(!((r=this.item.getFlag("dsa5","enchantments")||[]).length+t.length>7)){m.next=3;break}return m.abrupt("return",ui.notifications.error(game.i18n.localize("DSAError.tooManyEnchants")));case 3:a=item_sheet_createForOfIteratorHelper(t),m.prev=4,a.s();case 6:if((o=a.n()).done){m.next=21;break}return i=o.value,m.next=10,(0,h.x8)(i,void 0,!1);case 10:if(c=m.sent,u=c.item,l=c.typeClass,c.selfTarget,!["spell","liturgy","ceremony","ritual"].includes(l)){m.next=19;break}if(u.pack){m.next=17;break}return m.abrupt("return",ui.notifications.error(game.i18n.localize("DSAError.onlyCompendiumSpells")));case 17:p={name:u.name,pack:u.pack,id:r.length,itemId:u.id,permanent:["liturgy","ceremony"].includes(l)||i.permanent,actorId:i.actorId,charged:!0,talisman:["liturgy","ceremony"].includes(l),fw:["liturgy","ceremony"].includes(l)?18:i.fw||0},r.push(p);case 19:m.next=6;break;case 21:m.next=26;break;case 23:m.prev=23,m.t0=m.catch(4),a.e(m.t0);case 26:return m.prev=26,a.f(),m.finish(26);case 29:if(!r.length){m.next=33;break}return d={flags:{dsa5:{enchantments:r}}},m.next=33,this.item.update(d);case 33:case"end":return m.stop()}}),_callee11,this,[[4,23,26,29]])}))),function _enchant(t){return u.apply(this,arguments)})},{key:"poison",value:(c=item_sheet_asyncToGenerator(item_sheet_regeneratorRuntime().mark((function _callee12(t){var r,a,o,i,c,u;return item_sheet_regeneratorRuntime().wrap((function _callee12$(l){for(;;)switch(l.prev=l.next){case 0:return r=JSON.parse(t.dataTransfer.getData("text/plain")),l.next=3,(0,h.x8)(r,void 0,!1);case 3:if(a=l.sent,o=a.item,i=a.typeClass,a.selfTarget,"poison"!=i){l.next=12;break}return c={name:o.name,pack:o.pack,itemId:o._id,permanent:!1,actorId:r.actorId},u={flags:{dsa5:{poison:c}}},l.next=12,this.item.update(u);case 12:case"end":return l.stop()}}),_callee12,this)}))),function poison(t){return c.apply(this,arguments)})},{key:"toggleChargedState",value:function toggleChargedState(t,r){var a,o=item_sheet_createForOfIteratorHelper(r);try{for(o.s();!(a=o.n()).done;){var i=a.value;if(i.id==t){i.charged=!(!i.talisman||!i.permanent)||!i.charged;break}}}catch(t){o.e(t)}finally{o.f()}this.item.update({flags:{dsa5:{enchantments:r}}})}},{key:"activateListeners",value:function activateListeners(r){var a=this;item_sheet_get(item_sheet_getPrototypeOf(Enchantable.prototype),"activateListeners",this).call(this,r),r.find(".ench-toggle-permanent").click((function(t){var r,o=a.enchantMentId(t),i=o.id,c=o.enchantments,u=item_sheet_createForOfIteratorHelper(c);try{for(u.s();!(r=u.n()).done;){var l=r.value;if(l.id==i){l.permanent=!l.permanent;break}}}catch(t){u.e(t)}finally{u.f()}a.item.update({flags:{dsa5:{enchantments:c}}})})),r.find(".ench-toggle-charge").click((function(t){var r=a.enchantMentId(t),o=r.id,i=r.enchantments;a.toggleChargedState(o,i)})),r.find(".ench-roll").click(function(){var r=item_sheet_asyncToGenerator(item_sheet_regeneratorRuntime().mark((function _callee14(r){var o,i,c,u,l,p;return item_sheet_regeneratorRuntime().wrap((function _callee14$(d){for(;;)switch(d.prev=d.next){case 0:if(o=a.enchantMentId(r),i=o.id,c=o.enchantments,(u=c.find((function(t){return t.id==i}))).charged){d.next=4;break}return d.abrupt("return",ui.notifications.error(game.i18n.localize("DSAError.NotEnoughCharges")));case 4:return d.next=6,a.getSpell(u);case 6:if(!(l=d.sent)){d.next=14;break}return(l=l.toObject()).system.talentValue.value=u.fw,d.next=12,t.Z.emptyActor(14,a.item.name);case 12:(p=d.sent).setupSpell(l,{},"emptyActor").then(function(){var r=item_sheet_asyncToGenerator(item_sheet_regeneratorRuntime().mark((function _callee13(r){var o;return item_sheet_regeneratorRuntime().wrap((function _callee13$(d){for(;;)switch(d.prev=d.next){case 0:return o=game.i18n.format("CHATNOTIFICATION.enchantmentUsed",{item:a.item.name,spell:l.name}),d.next=3,ChatMessage.create(t.Z.chatDataSetup(o));case 3:return d.next=5,p.basicTest(r);case 5:u.permanent?a.toggleChargedState(i,c):a.deleteEnchantment(i,c);case 6:case"end":return d.stop()}}),_callee13)})));return function(t){return r.apply(this,arguments)}}());case 14:case"end":return d.stop()}}),_callee14)})));return function(t){return r.apply(this,arguments)}}()),r.find(".ench-fw").change((function(t){var r=a.enchantMentId(t),o=r.id,i=r.enchantments,c=Number($(t.currentTarget).val());if(c){var u,l=item_sheet_createForOfIteratorHelper(i);try{for(l.s();!(u=l.n()).done;){var p=u.value;if(p.id==o){p.fw=c;break}}}catch(t){l.e(t)}finally{l.f()}a.item.update({flags:{dsa5:{enchantments:i}}})}})),r.find(".ench-delete").click((function(t){var r=a.enchantMentId(t),o=r.id,i=r.enchantments;a.deleteEnchantment(o,i)})),r.find(".ench-show").click(function(){var t=item_sheet_asyncToGenerator(item_sheet_regeneratorRuntime().mark((function _callee15(t){var r,o,i,c,u;return item_sheet_regeneratorRuntime().wrap((function _callee15$(l){for(;;)switch(l.prev=l.next){case 0:return r=a.enchantMentId(t),o=r.id,i=r.enchantments,c=i.find((function(t){return t.id==o})),l.next=4,a.getSpell(c);case 4:(u=l.sent)&&u.sheet.render(!0);case 6:case"end":return l.stop()}}),_callee15)})));return function(r){return t.apply(this,arguments)}}()),r.find(".poison-toggle-permanent").click((function(t){a.item.update({flags:{dsa5:{poison:{permanent:!a.item.flags.dsa5.poison.permanent}}}})})),r.find(".poison-delete").click((function(t){a.deletePoison()})),r.find(".poison-show").click(item_sheet_asyncToGenerator(item_sheet_regeneratorRuntime().mark((function _callee16(){var t;return item_sheet_regeneratorRuntime().wrap((function _callee16$(r){for(;;)switch(r.prev=r.next){case 0:if(a.item.actor&&(t=a.item.actor.items.find((function(t){return"poison"==t.type&&t.name==a.item.flags.dsa5.poison.name}))),t){r.next=5;break}return r.next=4,a.getSpell(a.item.flags.dsa5.poison);case 4:t=r.sent;case 5:t&&t.sheet.render(!0);case 6:case"end":return r.stop()}}),_callee16)}))))}},{key:"deletePoison",value:function deletePoison(){this.item.update(item_sheet_defineProperty({},"flags.dsa5.-=poison",null))}},{key:"deleteEnchantment",value:function deleteEnchantment(t,r){var a=r.findIndex((function(r){return r.id==t}));r.splice(a,1),this.item.update({flags:{dsa5:{enchantments:r}}})}},{key:"getSpell",value:(i=item_sheet_asyncToGenerator(item_sheet_regeneratorRuntime().mark((function _callee17(t){var r,a,o;return item_sheet_regeneratorRuntime().wrap((function _callee17$(i){for(;;)switch(i.prev=i.next){case 0:return i.next=2,game.packs.get(t.pack);case 2:if(r=i.sent){i.next=6;break}return ui.notifications.error(game.i18n.localize("DSAError.enchantmentNotFound")),i.abrupt("return");case 6:return i.next=8,r.getDocument(t.itemId);case 8:if(a=i.sent){i.next=17;break}return i.next=12,r.index.getName(t.name);case 12:if(!(o=i.sent)){i.next=17;break}return i.next=16,r.getDocument(o._id);case 16:a=i.sent;case 17:return a||ui.notifications.error(game.i18n.localize("DSAError.enchantmentNotFound")),i.abrupt("return",a);case 19:case"end":return i.stop()}}),_callee17)}))),function getSpell(t){return i.apply(this,arguments)})},{key:"enchantMentId",value:function enchantMentId(t){return{id:$(t.currentTarget).parents(".statusEffect").attr("data-id"),enchantments:this.item.getFlag("dsa5","enchantments")}}},{key:"prepareDomains",value:function prepareDomains(){var t=getProperty(this.item.system,"effect.attributes");if(t){var r=new RegExp(game.i18n.localize("WEAPON.magical"),"i"),a=new RegExp(game.i18n.localize("WEAPON.clerical"),"i");t=t.split(",").map((function(t){var o="";return r.test(t)?o="magical":a.test(t)&&(o="blessed"),'
  • ').concat(t,"
  • ")})).join("")}return t}},{key:"_canDragDrop",value:function _canDragDrop(t){return this.isEditable}},{key:"getData",value:(o=item_sheet_asyncToGenerator(item_sheet_regeneratorRuntime().mark((function _callee18(t){var a,o;return item_sheet_regeneratorRuntime().wrap((function _callee18$(i){for(;;)switch(i.prev=i.next){case 0:return i.next=2,item_sheet_get(item_sheet_getPrototypeOf(Enchantable.prototype),"getData",this).call(this,t);case 2:return(a=i.sent).enchantments=this.item.getFlag("dsa5","enchantments"),o=[],a.poison=this.item.getFlag("dsa5","poison"),a.poison&&o.push("poison"),a.enchantments&&a.enchantments.some((function(t){return!t.talisman}))&&o.push("enchantment"),a.enchantments&&a.enchantments.some((function(t){return t.talisman}))&&o.push("talisman"),a.enchantmentLabel=o.map((function(t){return game.i18n.localize(t)})).join("/"),a.traditionArtifacts=r.Z.traditionArtifacts,a.hasEnchantments=a.poison||a.enchantments&&a.enchantments.length>0,i.abrupt("return",a);case 13:case"end":return i.stop()}}),_callee18,this)}))),function getData(t){return o.apply(this,arguments)})}],[{key:"defaultOptions",get:function get(){var t=item_sheet_get(item_sheet_getPrototypeOf(Enchantable),"defaultOptions",this);return mergeObject(t,{dragDrop:[{dragSelector:".item-list .item",dropSelector:".content"}]}),t}}]),Enchantable}(H),B=function(r){item_sheet_inherits(InformationSheet,r);var a,o=item_sheet_createSuper(InformationSheet);function InformationSheet(){return item_sheet_classCallCheck(this,InformationSheet),o.apply(this,arguments)}return item_sheet_createClass(InformationSheet,[{key:"getData",value:(a=item_sheet_asyncToGenerator(item_sheet_regeneratorRuntime().mark((function _callee19(r){var a;return item_sheet_regeneratorRuntime().wrap((function _callee19$(o){for(;;)switch(o.prev=o.next){case 0:return o.next=2,item_sheet_get(item_sheet_getPrototypeOf(InformationSheet.prototype),"getData",this).call(this,r);case 2:return a=o.sent,o.t0=mergeObject,o.t1=a,o.next=7,t.Z.allSkillsList();case 7:return o.t2=o.sent,o.next=10,TextEditor.enrichHTML(this.item.system.qs1,{async:!0});case 10:return o.t3=o.sent,o.next=13,TextEditor.enrichHTML(this.item.system.qs2,{async:!0});case 13:return o.t4=o.sent,o.next=16,TextEditor.enrichHTML(this.item.system.qs3,{async:!0});case 16:return o.t5=o.sent,o.next=19,TextEditor.enrichHTML(this.item.system.qs4,{async:!0});case 19:return o.t6=o.sent,o.next=22,TextEditor.enrichHTML(this.item.system.qs5,{async:!0});case 22:return o.t7=o.sent,o.next=25,TextEditor.enrichHTML(this.item.system.qs6,{async:!0});case 25:return o.t8=o.sent,o.t9={allSkills:o.t2,enrichedqs1:o.t3,enrichedqs2:o.t4,enrichedqs3:o.t5,enrichedqs4:o.t6,enrichedqs5:o.t7,enrichedqs6:o.t8},(0,o.t0)(o.t1,o.t9),o.abrupt("return",a);case 29:case"end":return o.stop()}}),_callee19,this)}))),function getData(t){return a.apply(this,arguments)})}]),InformationSheet}(H),q=function(t){item_sheet_inherits(AmmunitionSheet,t);var a,o=item_sheet_createSuper(AmmunitionSheet);function AmmunitionSheet(t,r){var a;return item_sheet_classCallCheck(this,AmmunitionSheet),(a=o.call(this,t,r)).isPoisonable=!0,a}return item_sheet_createClass(AmmunitionSheet,[{key:"getData",value:(a=item_sheet_asyncToGenerator(item_sheet_regeneratorRuntime().mark((function _callee20(t){var a;return item_sheet_regeneratorRuntime().wrap((function _callee20$(o){for(;;)switch(o.prev=o.next){case 0:return o.next=2,item_sheet_get(item_sheet_getPrototypeOf(AmmunitionSheet.prototype),"getData",this).call(this,t);case 2:return(a=o.sent).ammunitiongroups=r.Z.ammunitiongroups,a.domains=this.prepareDomains(),o.abrupt("return",a);case 6:case"end":return o.stop()}}),_callee20,this)}))),function getData(t){return a.apply(this,arguments)})}]),AmmunitionSheet}(W),U=function(t){item_sheet_inherits(EquipmentSheet,t);var a,o,i,c=item_sheet_createSuper(EquipmentSheet);function EquipmentSheet(){return item_sheet_classCallCheck(this,EquipmentSheet),c.apply(this,arguments)}return item_sheet_createClass(EquipmentSheet,[{key:"getData",value:(i=item_sheet_asyncToGenerator(item_sheet_regeneratorRuntime().mark((function _callee21(t){var a,o,i=this;return item_sheet_regeneratorRuntime().wrap((function _callee21$(c){for(;;)switch(c.prev=c.next){case 0:return c.next=2,item_sheet_get(item_sheet_getPrototypeOf(EquipmentSheet.prototype),"getData",this).call(this,t);case 2:if(a=c.sent,c.t0=mergeObject,c.t1=a,c.t2=r.Z.equipmentTypes,c.t3=this.prepareDomains(),c.t4=game.user.isGM,c.t4){c.next=12;break}return c.next=11,game.settings.get("dsa5","playerCanEditSpellMacro");case 11:c.t4=c.sent;case 12:return c.t5=c.t4,c.t6={equipmentTypes:c.t2,domains:c.t3,canOnUseEffect:c.t5},(0,c.t0)(c.t1,c.t6),this.isBagWithContents()&&(o=0,mergeObject(a,{containerContent:this.item.actor.items.filter((function(t){return r.Z.equipmentCategories.includes(t.type)&&t.system.parent_id==i.item.id})).map((function(t){t.system.preparedWeight=parseFloat((t.system.weight.value*t.system.quantity.value).toFixed(3)),o+=Number(t.system.preparedWeight);var r=getProperty(t,"flags.dsa5.enchantments");return r&&r.length>0?t.enchantClass="rar":(t.system.effect&&""!=t.system.effect.value||t.effects.length>0)&&(t.enchantClass="common"),t})),weightSum:parseFloat(o.toFixed(3)),weightWidth:'style="width: '.concat(Math.min(this.item.system.capacity?o/this.item.system.capacity*100:0,100),'%"'),weightExceeded:o>Number(this.item.system.capacity)?"exceeded":""})),c.abrupt("return",a);case 17:case"end":return c.stop()}}),_callee21,this)}))),function getData(t){return i.apply(this,arguments)})},{key:"breakOverflow",value:(o=item_sheet_asyncToGenerator(item_sheet_regeneratorRuntime().mark((function _callee22(t,r){var a,o,i;return item_sheet_regeneratorRuntime().wrap((function _callee22$(c){for(;;)switch(c.prev=c.next){case 0:return c.t0=$,c.next=3,renderTemplate("systems/dsa5/templates/items/baghover.html",t);case 3:return c.t1=c.sent,a=(0,c.t0)(c.t1),o=r.offset().top+52,i=r.offset().left-75,a.appendTo($("body")),a.css({position:"absolute",left:i+"px",top:o+"px",bottom:"auto",right:"auto","z-index":1e4}),c.abrupt("return",a);case 10:case"end":return c.stop()}}),_callee22)}))),function breakOverflow(t,r){return o.apply(this,arguments)})},{key:"activateListeners",value:function activateListeners(t){var r=this;item_sheet_get(item_sheet_getPrototypeOf(EquipmentSheet.prototype),"activateListeners",this).call(this,t);var a=t.find(".slot");a.mouseenter(function(){var t=item_sheet_asyncToGenerator(item_sheet_regeneratorRuntime().mark((function _callee23(t){var a,o;return item_sheet_regeneratorRuntime().wrap((function _callee23$(i){for(;;)switch(i.prev=i.next){case 0:return a=$(t.currentTarget),i.next=3,r.breakOverflow({name:a.attr("data-name"),weight:a.attr("data-weight"),quantity:a.attr("data-quantity")},a);case 3:(o=i.sent).fadeIn(),a.mouseleave((function(){o.remove(),a.off("mouseleave")}));case 6:case"end":return i.stop()}}),_callee23)})));return function(r){return t.apply(this,arguments)}}()),a.mousedown(function(){var t=item_sheet_asyncToGenerator(item_sheet_regeneratorRuntime().mark((function _callee24(t){var a,o;return item_sheet_regeneratorRuntime().wrap((function _callee24$(i){for(;;)switch(i.prev=i.next){case 0:if(a=t.currentTarget.dataset.itemId,o=r.actor.items.get(a),0!=t.button){i.next=6;break}o.sheet.render(!0),i.next=11;break;case 6:if(2!=t.button){i.next=11;break}return $(".itemInfo").remove(),i.next=10,o.update({"system.parent_id":0});case 10:r.render(!0);case 11:case"end":return i.stop()}}),_callee24)})));return function(r){return t.apply(this,arguments)}}())}},{key:"isBagWithContents",value:function isBagWithContents(){return this.item.actor&&"bags"==getProperty(this.item,"system.equipmentType.value")}},{key:"_onDrop",value:(a=item_sheet_asyncToGenerator(item_sheet_regeneratorRuntime().mark((function _callee25(t){var a,o,i,c,u,l;return item_sheet_regeneratorRuntime().wrap((function _callee25$(p){for(;;)switch(p.prev=p.next){case 0:if(!this.isBagWithContents()){p.next=22;break}return a=JSON.parse(t.dataTransfer.getData("text/plain")),p.next=4,(0,h.x8)(a,void 0);case 4:if(o=p.sent,i=o.item,c=o.typeClass,o.selfTarget,u=this.item.id==i.id,l=this.item.parent.id==a.actorId,!r.Z.equipmentCategories.includes(c)||u){p.next=22;break}if(i.system.parent_id=this.item.id,i.system.worn&&i.system.worn.value&&(i.system.worn.value=!1),!l){p.next=18;break}return p.next=16,this.item.actor.updateEmbeddedDocuments("Item",[i]);case 16:p.next=20;break;case 18:return p.next=20,this.item.actor.sheet._addLoot(i);case 20:return this.render(!0),p.abrupt("return");case 22:return p.next=24,item_sheet_get(item_sheet_getPrototypeOf(EquipmentSheet.prototype),"_onDrop",this).call(this,t);case 24:case"end":return p.stop()}}),_callee25,this)}))),function _onDrop(t){return a.apply(this,arguments)})}]),EquipmentSheet}(z(W)),Y=function(t){item_sheet_inherits(ArmorSheet,t);var a,o=item_sheet_createSuper(ArmorSheet);function ArmorSheet(){return item_sheet_classCallCheck(this,ArmorSheet),o.apply(this,arguments)}return item_sheet_createClass(ArmorSheet,[{key:"getData",value:(a=item_sheet_asyncToGenerator(item_sheet_regeneratorRuntime().mark((function _callee26(t){var a;return item_sheet_regeneratorRuntime().wrap((function _callee26$(o){for(;;)switch(o.prev=o.next){case 0:return o.next=2,item_sheet_get(item_sheet_getPrototypeOf(ArmorSheet.prototype),"getData",this).call(this,t);case 2:if(a=o.sent,mergeObject(a,{domains:this.prepareDomains(),armorSubcategories:Object.keys(r.Z.armorSubcategories),breakPointRating:r.Z.armorSubcategories[this.item.system.subcategory]}),o.t0=game.user.isGM,o.t0){o.next=9;break}return o.next=8,game.settings.get("dsa5","playerCanEditSpellMacro");case 8:o.t0=o.sent;case 9:return a.canOnUseEffect=o.t0,o.abrupt("return",a);case 11:case"end":return o.stop()}}),_callee26,this)}))),function getData(t){return a.apply(this,arguments)})},{key:"_getHeaderButtons",value:function _getHeaderButtons(){var t,r=this,a=item_sheet_get(item_sheet_getPrototypeOf(ArmorSheet.prototype),"_getHeaderButtons",this).call(this);return this.item.isOwned&&game.settings.get("dsa5","armorAndWeaponDamage")&&this.item.system.structure.max>0&&a.unshift({class:"rollDamaged",icon:"fas fa-dice-d20",onclick:(t=item_sheet_asyncToGenerator(item_sheet_regeneratorRuntime().mark((function _callee27(){return item_sheet_regeneratorRuntime().wrap((function _callee27$(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",M.Z.breakingTest(r.item));case 1:case"end":return t.stop()}}),_callee27)}))),function onclick(){return t.apply(this,arguments)})}),a}}]),ArmorSheet}(z(W)),V=function(t){item_sheet_inherits(PlantSheet,t);var r,a=item_sheet_createSuper(PlantSheet);function PlantSheet(){return item_sheet_classCallCheck(this,PlantSheet),a.apply(this,arguments)}return item_sheet_createClass(PlantSheet,[{key:"getData",value:(r=item_sheet_asyncToGenerator(item_sheet_regeneratorRuntime().mark((function _callee28(t){var r;return item_sheet_regeneratorRuntime().wrap((function _callee28$(a){for(;;)switch(a.prev=a.next){case 0:return a.next=2,item_sheet_get(item_sheet_getPrototypeOf(PlantSheet.prototype),"getData",this).call(this,t);case 2:return(r=a.sent).attributes=Object.keys(r.system.planttype).map((function(t){return{name:t,checked:r.system.planttype[t]}})),a.next=6,TextEditor.enrichHTML(getProperty(this.item.system,"effect"),{secrets:this.object.isOwner,async:!0});case 6:return r.enrichedEffect=a.sent,a.next=9,TextEditor.enrichHTML(getProperty(this.item.system,"recipes"),{secrets:this.object.isOwner,async:!0});case 9:return r.enrichedRecipes=a.sent,a.next=12,TextEditor.enrichHTML(getProperty(this.item.system,"infos"),{secrets:this.object.isOwner,async:!0});case 12:return r.enrichedInformation=a.sent,a.abrupt("return",r);case 14:case"end":return a.stop()}}),_callee28,this)}))),function getData(t){return r.apply(this,arguments)})}]),PlantSheet}(z(H)),K=function(t){item_sheet_inherits(PatronSheet,t);var r,a=item_sheet_createSuper(PatronSheet);function PatronSheet(){return item_sheet_classCallCheck(this,PatronSheet),a.apply(this,arguments)}return item_sheet_createClass(PatronSheet,[{key:"getData",value:(r=item_sheet_asyncToGenerator(item_sheet_regeneratorRuntime().mark((function _callee29(t){var r;return item_sheet_regeneratorRuntime().wrap((function _callee29$(a){for(;;)switch(a.prev=a.next){case 0:return a.next=2,item_sheet_get(item_sheet_getPrototypeOf(PatronSheet.prototype),"getData",this).call(this,t);case 2:return(r=a.sent).patronCategories=[0,1,2,3].map((function(t){return{name:game.i18n.localize("PATRON.".concat(t)),val:t}})),r.priorities={0:game.i18n.localize("PATRON.primary"),1:game.i18n.localize("PATRON.secondary")},a.abrupt("return",r);case 6:case"end":return a.stop()}}),_callee29,this)}))),function getData(t){return r.apply(this,arguments)})}]),PatronSheet}(H),J=function(t){item_sheet_inherits(MagicalSignSheet,t);var r,a,o=item_sheet_createSuper(MagicalSignSheet);function MagicalSignSheet(){return item_sheet_classCallCheck(this,MagicalSignSheet),o.apply(this,arguments)}return item_sheet_createClass(MagicalSignSheet,[{key:"getData",value:(a=item_sheet_asyncToGenerator(item_sheet_regeneratorRuntime().mark((function _callee30(t){var r;return item_sheet_regeneratorRuntime().wrap((function _callee30$(a){for(;;)switch(a.prev=a.next){case 0:return a.next=2,item_sheet_get(item_sheet_getPrototypeOf(MagicalSignSheet.prototype),"getData",this).call(this,t);case 2:if((r=a.sent).categories={1:game.i18n.localize("TYPES.Item.magicalsign"),2:game.i18n.localize("additionalsign")},a.t0=game.user.isGM,a.t0){a.next=9;break}return a.next=8,game.settings.get("dsa5","playerCanEditSpellMacro");case 8:a.t0=a.sent;case 9:return r.canOnUseEffect=a.t0,a.abrupt("return",r);case 11:case"end":return a.stop()}}),_callee30,this)}))),function getData(t){return a.apply(this,arguments)})},{key:"_getHeaderButtons",value:function _getHeaderButtons(){var t,r=this,a=item_sheet_get(item_sheet_getPrototypeOf(MagicalSignSheet.prototype),"_getHeaderButtons",this).call(this);return this.item.isOwned&&a.unshift({class:"rolleffect",icon:"fas fa-dice-d20",onclick:(t=item_sheet_asyncToGenerator(item_sheet_regeneratorRuntime().mark((function _callee31(t){return item_sheet_regeneratorRuntime().wrap((function _callee31$(a){for(;;)switch(a.prev=a.next){case 0:return a.abrupt("return",r.setupEffect(t));case 1:case"end":return a.stop()}}),_callee31)}))),function onclick(r){return t.apply(this,arguments)})}),a}},{key:"setupEffect",value:(r=item_sheet_asyncToGenerator(item_sheet_regeneratorRuntime().mark((function _callee33(t){var r,a,o,i,c;return item_sheet_regeneratorRuntime().wrap((function _callee33$(t){for(;;)switch(t.prev=t.next){case 0:if(r=Number(this.item.system.asp)||0,!(this.item.actor.system.status.astralenergy.value

    ".concat(this.item.name,"

    ").concat(this.item.system.description.value,"

    ").concat(o.chatData(this.item.system,"").join("
    "),'

    '),a.setupSkill(i,{other:[c],subtitle:" (".concat(game.i18n.localize("TYPES.Item.magicalsign"),")")},void 0).then(function(){var t=item_sheet_asyncToGenerator(item_sheet_regeneratorRuntime().mark((function _callee32(t){var o;return item_sheet_regeneratorRuntime().wrap((function _callee32$(i){for(;;)switch(i.prev=i.next){case 0:return i.next=2,a.basicTest(t,{suppressMessage:!0});case 2:return(o=i.sent).result.preData.calculatedSpellModifiers={finalcost:r,costsMana:!0},i.next=6,j.Z.renderRollCard(o.cardOptions,o.result,o.options.rerenderMessage);case 6:case"end":return i.stop()}}),_callee32)})));return function(r){return t.apply(this,arguments)}}());case 8:case"end":return t.stop()}}),_callee33,this)}))),function setupEffect(t){return r.apply(this,arguments)})}]),MagicalSignSheet}(H),Q=function(a){item_sheet_inherits(RangeweaponSheet,a);var o,i=item_sheet_createSuper(RangeweaponSheet);function RangeweaponSheet(){return item_sheet_classCallCheck(this,RangeweaponSheet),i.apply(this,arguments)}return item_sheet_createClass(RangeweaponSheet,[{key:"_getHeaderButtons",value:function _getHeaderButtons(){var t,r=this,a=item_sheet_get(item_sheet_getPrototypeOf(RangeweaponSheet.prototype),"_getHeaderButtons",this).call(this);return this.item.isOwned&&game.settings.get("dsa5","armorAndWeaponDamage")&&this.item.system.structure.max>0&&a.unshift({class:"rollDamaged",icon:"fas fa-dice-d20",onclick:(t=item_sheet_asyncToGenerator(item_sheet_regeneratorRuntime().mark((function _callee34(){return item_sheet_regeneratorRuntime().wrap((function _callee34$(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",M.Z.breakingTest(r.item));case 1:case"end":return t.stop()}}),_callee34)}))),function onclick(){return t.apply(this,arguments)})}),a}},{key:"getData",value:(o=item_sheet_asyncToGenerator(item_sheet_regeneratorRuntime().mark((function _callee35(a){var o;return item_sheet_regeneratorRuntime().wrap((function _callee35$(i){for(;;)switch(i.prev=i.next){case 0:return i.next=2,item_sheet_get(item_sheet_getPrototypeOf(RangeweaponSheet.prototype),"getData",this).call(this,a);case 2:if(o=i.sent,i.t0=mergeObject,i.t1=o,i.t2=game.user.isGM,i.t2){i.next=10;break}return i.next=9,game.settings.get("dsa5","playerCanEditSpellMacro");case 9:i.t2=i.sent;case 10:return i.t3=i.t2,i.t4=r.Z.ammunitiongroups,i.next=14,t.Z.allCombatSkillsList("range");case 14:return i.t5=i.sent,i.t6=this.prepareDomains(),i.t7=r.Z.weaponStabilities[game.i18n.localize("LocalizedCTs.".concat(this.item.system.combatskill.value))],i.t8={canOnUseEffect:i.t3,ammunitiongroups:i.t4,combatskills:i.t5,domains:i.t6,breakPointRating:i.t7},(0,i.t0)(i.t1,i.t8),i.abrupt("return",o);case 20:case"end":return i.stop()}}),_callee35,this)}))),function getData(t){return o.apply(this,arguments)})}]),RangeweaponSheet}(z(W)),X=function(r){item_sheet_inherits(BlessingSheetDSA5,r);var a,o,i=item_sheet_createSuper(BlessingSheetDSA5);function BlessingSheetDSA5(){return item_sheet_classCallCheck(this,BlessingSheetDSA5),i.apply(this,arguments)}return item_sheet_createClass(BlessingSheetDSA5,[{key:"_getHeaderButtons",value:function _getHeaderButtons(){var t,r=this,a=item_sheet_get(item_sheet_getPrototypeOf(BlessingSheetDSA5.prototype),"_getHeaderButtons",this).call(this);return this.item.isOwned&&a.unshift({class:"rolleffect",icon:"fas fa-dice-d20",onclick:(t=item_sheet_asyncToGenerator(item_sheet_regeneratorRuntime().mark((function _callee36(t){return item_sheet_regeneratorRuntime().wrap((function _callee36$(a){for(;;)switch(a.prev=a.next){case 0:return a.abrupt("return",r.setupEffect(t));case 1:case"end":return a.stop()}}),_callee36)}))),function onclick(r){return t.apply(this,arguments)})}),a}},{key:"getData",value:(o=item_sheet_asyncToGenerator(item_sheet_regeneratorRuntime().mark((function _callee37(t){var r;return item_sheet_regeneratorRuntime().wrap((function _callee37$(a){for(;;)switch(a.prev=a.next){case 0:return a.next=2,item_sheet_get(item_sheet_getPrototypeOf(BlessingSheetDSA5.prototype),"getData",this).call(this,t);case 2:if(r=a.sent,a.t0=game.user.isGM,a.t0){a.next=8;break}return a.next=7,game.settings.get("dsa5","playerCanEditSpellMacro");case 7:a.t0=a.sent;case 8:return r.canOnUseEffect=a.t0,a.abrupt("return",r);case 10:case"end":return a.stop()}}),_callee37,this)}))),function getData(t){return o.apply(this,arguments)})},{key:"setupEffect",value:(a=item_sheet_asyncToGenerator(item_sheet_regeneratorRuntime().mark((function _callee38(r){var a,o;return item_sheet_regeneratorRuntime().wrap((function _callee38$(r){for(;;)switch(r.prev=r.next){case 0:if(!(this.item.actor.system.status.karmaenergy.value<1)){r.next=2;break}return r.abrupt("return",ui.notifications.error(game.i18n.localize("DSAError.NotEnoughKaP")));case 2:return a=game.dsa5.config.ItemSubclasses.magictrick,r.next=5,this.item.actor.update({"system.status.karmaenergy.value":this.item.actor.system.status.karmaenergy.value-=1});case 5:return o="

    ".concat(this.item.name," - ").concat(game.i18n.localize("blessing")," ").concat(game.i18n.localize("probe"),"

    ").concat(this.item.system.description.value,"

    ").concat(a.chatData(this.item.system,"").join("
    "),"

    "),r.next=8,ChatMessage.create(t.Z.chatDataSetup(o));case 8:case"end":return r.stop()}}),_callee38,this)}))),function setupEffect(t){return a.apply(this,arguments)})}]),BlessingSheetDSA5}(H),ee=function(t){item_sheet_inherits(ItemCareerDSA5,t);var a,o=item_sheet_createSuper(ItemCareerDSA5);function ItemCareerDSA5(){return item_sheet_classCallCheck(this,ItemCareerDSA5),o.apply(this,arguments)}return item_sheet_createClass(ItemCareerDSA5,[{key:"getData",value:(a=item_sheet_asyncToGenerator(item_sheet_regeneratorRuntime().mark((function _callee39(t){var a,o;return item_sheet_regeneratorRuntime().wrap((function _callee39$(i){for(;;)switch(i.prev=i.next){case 0:return i.next=2,item_sheet_get(item_sheet_getPrototypeOf(ItemCareerDSA5.prototype),"getData",this).call(this,t);case 2:return a=i.sent,(o=duplicate(r.Z.characteristics))["-"]="-",a.mageLevels=r.Z.mageLevels,a.guidevalues=o,i.next=9,TextEditor.enrichHTML(getProperty(this.item.system,"clothing.value"),{secrets:this.object.isOwner,async:!0});case 9:return a.enrichedClothing=i.sent,i.abrupt("return",a);case 11:case"end":return i.stop()}}),_callee39,this)}))),function getData(t){return a.apply(this,arguments)})}],[{key:"defaultOptions",get:function get(){var t=item_sheet_get(item_sheet_getPrototypeOf(ItemCareerDSA5),"defaultOptions",this);return mergeObject(t,{width:700,height:700}),t}}]),ItemCareerDSA5}(H),te=function(t){item_sheet_inherits(ConsumableSheetDSA5,t);var a,o=item_sheet_createSuper(ConsumableSheetDSA5);function ConsumableSheetDSA5(){return item_sheet_classCallCheck(this,ConsumableSheetDSA5),o.apply(this,arguments)}return item_sheet_createClass(ConsumableSheetDSA5,[{key:"_getHeaderButtons",value:function _getHeaderButtons(){var t,r=this,a=item_sheet_get(item_sheet_getPrototypeOf(ConsumableSheetDSA5.prototype),"_getHeaderButtons",this).call(this);return this.item.isOwned&&a.unshift({class:"consumeItem",icon:"fas fa-dice-d20",onclick:(t=item_sheet_asyncToGenerator(item_sheet_regeneratorRuntime().mark((function _callee40(t){return item_sheet_regeneratorRuntime().wrap((function _callee40$(a){for(;;)switch(a.prev=a.next){case 0:return a.abrupt("return",r.setupEffect(t));case 1:case"end":return a.stop()}}),_callee40)}))),function onclick(r){return t.apply(this,arguments)})}),a}},{key:"getData",value:(a=item_sheet_asyncToGenerator(item_sheet_regeneratorRuntime().mark((function _callee41(t){var a;return item_sheet_regeneratorRuntime().wrap((function _callee41$(o){for(;;)switch(o.prev=o.next){case 0:return o.next=2,item_sheet_get(item_sheet_getPrototypeOf(ConsumableSheetDSA5.prototype),"getData",this).call(this,t);case 2:return(a=o.sent).calculatedPrice=a.system.price.value*a.system.QL||0,a.availableSteps=a.system.QLList.split("\n").map((function(t,r){return r+1})),a.equipmentTypes=r.Z.equipmentTypes,o.next=8,TextEditor.enrichHTML(getProperty(this.item.system,"ingredients"),{secrets:this.object.isOwner,async:!0});case 8:return a.enrichedIngredients=o.sent,o.abrupt("return",a);case 10:case"end":return o.stop()}}),_callee41,this)}))),function getData(t){return a.apply(this,arguments)})},{key:"setupEffect",value:function setupEffect(t){this.item.setupEffect()}}],[{key:"defaultOptions",get:function get(){var t=item_sheet_get(item_sheet_getPrototypeOf(ConsumableSheetDSA5),"defaultOptions",this);return mergeObject(t,{width:480}),t}}]),ConsumableSheetDSA5}(z(H)),re=function(t){item_sheet_inherits(ItemCultureDSA5,t);var r,a=item_sheet_createSuper(ItemCultureDSA5);function ItemCultureDSA5(){return item_sheet_classCallCheck(this,ItemCultureDSA5),a.apply(this,arguments)}return item_sheet_createClass(ItemCultureDSA5,[{key:"getData",value:(r=item_sheet_asyncToGenerator(item_sheet_regeneratorRuntime().mark((function _callee42(t){var r;return item_sheet_regeneratorRuntime().wrap((function _callee42$(a){for(;;)switch(a.prev=a.next){case 0:return a.next=2,item_sheet_get(item_sheet_getPrototypeOf(ItemCultureDSA5.prototype),"getData",this).call(this,t);case 2:return r=a.sent,a.next=5,TextEditor.enrichHTML(getProperty(this.item.system,"clothing.value"),{secrets:this.object.isOwner,async:!0});case 5:return r.enrichedClothing=a.sent,a.abrupt("return",r);case 7:case"end":return a.stop()}}),_callee42,this)}))),function getData(t){return r.apply(this,arguments)})}],[{key:"defaultOptions",get:function get(){var t=item_sheet_get(item_sheet_getPrototypeOf(ItemCultureDSA5),"defaultOptions",this);return mergeObject(t,{width:700,height:700}),t}}]),ItemCultureDSA5}(H),ne=function(t){item_sheet_inherits(DiseaseSheetDSA5,t);var a,o=item_sheet_createSuper(DiseaseSheetDSA5);function DiseaseSheetDSA5(){return item_sheet_classCallCheck(this,DiseaseSheetDSA5),o.apply(this,arguments)}return item_sheet_createClass(DiseaseSheetDSA5,[{key:"_getHeaderButtons",value:function _getHeaderButtons(){var t,r=this,a=item_sheet_get(item_sheet_getPrototypeOf(DiseaseSheetDSA5.prototype),"_getHeaderButtons",this).call(this);return a.unshift({class:"rolleffect",icon:"fas fa-dice-d20",onclick:(t=item_sheet_asyncToGenerator(item_sheet_regeneratorRuntime().mark((function _callee43(t){return item_sheet_regeneratorRuntime().wrap((function _callee43$(a){for(;;)switch(a.prev=a.next){case 0:return a.abrupt("return",r.setupEffect(t));case 1:case"end":return a.stop()}}),_callee43)}))),function onclick(r){return t.apply(this,arguments)})}),a}},{key:"getData",value:(a=item_sheet_asyncToGenerator(item_sheet_regeneratorRuntime().mark((function _callee44(t){var a;return item_sheet_regeneratorRuntime().wrap((function _callee44$(o){for(;;)switch(o.prev=o.next){case 0:return o.next=2,item_sheet_get(item_sheet_getPrototypeOf(DiseaseSheetDSA5.prototype),"getData",this).call(this,t);case 2:return(a=o.sent).resistances=r.Z.magicResistanceModifiers,o.abrupt("return",a);case 5:case"end":return o.stop()}}),_callee44,this)}))),function getData(t){return a.apply(this,arguments)})}]),DiseaseSheetDSA5}(H),ae=function(r){item_sheet_inherits(MagictrickSheetDSA5,r);var a,o,i=item_sheet_createSuper(MagictrickSheetDSA5);function MagictrickSheetDSA5(){return item_sheet_classCallCheck(this,MagictrickSheetDSA5),i.apply(this,arguments)}return item_sheet_createClass(MagictrickSheetDSA5,[{key:"_getHeaderButtons",value:function _getHeaderButtons(){var t,r=this,a=item_sheet_get(item_sheet_getPrototypeOf(MagictrickSheetDSA5.prototype),"_getHeaderButtons",this).call(this);return this.item.isOwned&&a.unshift({class:"rolleffect",icon:"fas fa-dice-d20",onclick:(t=item_sheet_asyncToGenerator(item_sheet_regeneratorRuntime().mark((function _callee45(t){return item_sheet_regeneratorRuntime().wrap((function _callee45$(a){for(;;)switch(a.prev=a.next){case 0:return a.abrupt("return",r.setupEffect(t));case 1:case"end":return a.stop()}}),_callee45)}))),function onclick(r){return t.apply(this,arguments)})}),a}},{key:"getData",value:(o=item_sheet_asyncToGenerator(item_sheet_regeneratorRuntime().mark((function _callee46(t){var r;return item_sheet_regeneratorRuntime().wrap((function _callee46$(a){for(;;)switch(a.prev=a.next){case 0:return a.next=2,item_sheet_get(item_sheet_getPrototypeOf(MagictrickSheetDSA5.prototype),"getData",this).call(this,t);case 2:if(r=a.sent,a.t0=game.user.isGM,a.t0){a.next=8;break}return a.next=7,game.settings.get("dsa5","playerCanEditSpellMacro");case 7:a.t0=a.sent;case 8:return r.canOnUseEffect=a.t0,a.abrupt("return",r);case 10:case"end":return a.stop()}}),_callee46,this)}))),function getData(t){return o.apply(this,arguments)})},{key:"setupEffect",value:(a=item_sheet_asyncToGenerator(item_sheet_regeneratorRuntime().mark((function _callee47(r){var a,o;return item_sheet_regeneratorRuntime().wrap((function _callee47$(r){for(;;)switch(r.prev=r.next){case 0:if(!(this.item.actor.system.status.astralenergy.value<1)){r.next=2;break}return r.abrupt("return",ui.notifications.error(game.i18n.localize("DSAError.NotEnoughAsP")));case 2:return a=game.dsa5.config.ItemSubclasses.magictrick,r.next=5,this.item.actor.update({"system.status.astralenergy.value":this.item.actor.system.status.astralenergy.value-=1});case 5:return o="

    ".concat(this.item.name," - ").concat(game.i18n.localize("magictrick")," ").concat(game.i18n.localize("probe"),"

    ").concat(this.item.system.description.value,"

    ").concat(a.chatData(this.item.system,"").join("
    "),"

    "),r.next=8,ChatMessage.create(t.Z.chatDataSetup(o));case 8:case"end":return r.stop()}}),_callee47,this)}))),function setupEffect(t){return a.apply(this,arguments)})}]),MagictrickSheetDSA5}(H),oe=function(a){item_sheet_inherits(MeleeweaponSheetDSA5,a);var o,i=item_sheet_createSuper(MeleeweaponSheetDSA5);function MeleeweaponSheetDSA5(t,r){var a;return item_sheet_classCallCheck(this,MeleeweaponSheetDSA5),(a=i.call(this,t,r)).isPoisonable=!0,a}return item_sheet_createClass(MeleeweaponSheetDSA5,[{key:"getData",value:(o=item_sheet_asyncToGenerator(item_sheet_regeneratorRuntime().mark((function _callee48(a){var o,i,c,u,l,p,d,h=this;return item_sheet_regeneratorRuntime().wrap((function _callee48$(m){for(;;)switch(m.prev=m.next){case 0:return m.next=2,item_sheet_get(item_sheet_getPrototypeOf(MeleeweaponSheetDSA5.prototype),"getData",this).call(this,a);case 2:if(o=m.sent,i=mergeObject(duplicate(r.Z.characteristics),item_sheet_defineProperty({"ge/kk":game.i18n.localize("CHAR.GEKK")},"-","-")),c=y.Z.regex2h.test(this.item.name),u="",c){m.next=10;break}u="wrongGrip.yieldTwo",m.next=18;break;case 10:l=game.i18n.localize("LocalizedCTs.".concat(this.item.system.combatskill.value)),m.t0=l,m.next="Two-Handed Impact Weapons"===m.t0||"Two-Handed Swords"===m.t0?14:17;break;case 14:return p=new RegExp(game.i18n.localize("wrongGrip.wrongGripBastardRegex")),u=p.test(this.item.name)?"wrongGrip.yieldOneBastard":"wrongGrip.yieldOneSwordBlunt",m.abrupt("break",18);case 17:u="wrongGrip.yieldOnePolearms";case 18:return m.t1=mergeObject,m.t2=o,m.t3=i,m.t4=c,m.t5=c?"wrongGrip.oneHanded":"wrongGrip.twoHanded",m.t6=u,m.next=26,t.Z.allCombatSkillsList("melee");case 26:if(m.t7=m.sent,m.t8=r.Z.meleeRanges,m.t9=r.Z.shieldSizes,m.t10=y.Z.isShield(this.item),m.t11=this.prepareDomains(),m.t12=r.Z.weaponStabilities[game.i18n.localize("LocalizedCTs.".concat(this.item.system.combatskill.value))],m.t13={characteristics:m.t3,twoHanded:m.t4,wrongGripLabel:m.t5,wrongGripHint:m.t6,combatskills:m.t7,ranges:m.t8,shieldSizes:m.t9,isShield:m.t10,domains:m.t11,breakPointRating:m.t12},(0,m.t1)(m.t2,m.t13),this.item.actor&&(d=this.item.actor.items.find((function(t){return"combatskill"==t.type&&t.name==h.item.system.combatskill.value})),o.canBeOffHand=d&&!d.system.weapontype.twoHanded&&this.item.system.worn.value,o.canBeWrongGrip=!["Daggers","Fencing Weapons"].includes(game.i18n.localize("LocalizedCTs.".concat(this.item.system.combatskill.value)))),m.t14=game.user.isGM,m.t14){m.next=40;break}return m.next=39,game.settings.get("dsa5","playerCanEditSpellMacro");case 39:m.t14=m.sent;case 40:return o.canOnUseEffect=m.t14,m.abrupt("return",o);case 42:case"end":return m.stop()}}),_callee48,this)}))),function getData(t){return o.apply(this,arguments)})},{key:"_getHeaderButtons",value:function _getHeaderButtons(){var t,r=this,a=item_sheet_get(item_sheet_getPrototypeOf(MeleeweaponSheetDSA5.prototype),"_getHeaderButtons",this).call(this);return this.item.isOwned&&game.settings.get("dsa5","armorAndWeaponDamage")&&this.item.system.structure.max>0&&a.unshift({class:"rollDamaged",icon:"fas fa-dice-d20",onclick:(t=item_sheet_asyncToGenerator(item_sheet_regeneratorRuntime().mark((function _callee49(){return item_sheet_regeneratorRuntime().wrap((function _callee49$(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",M.Z.breakingTest(r.item));case 1:case"end":return t.stop()}}),_callee49)}))),function onclick(){return t.apply(this,arguments)})}),a}}]),MeleeweaponSheetDSA5}(z(W)),ie=function(t){item_sheet_inherits(PoisonSheetDSA5,t);var a,o=item_sheet_createSuper(PoisonSheetDSA5);function PoisonSheetDSA5(){return item_sheet_classCallCheck(this,PoisonSheetDSA5),o.apply(this,arguments)}return item_sheet_createClass(PoisonSheetDSA5,[{key:"_getHeaderButtons",value:function _getHeaderButtons(){var t,r=this,a=item_sheet_get(item_sheet_getPrototypeOf(PoisonSheetDSA5.prototype),"_getHeaderButtons",this).call(this);return a.unshift({class:"rolleffect",icon:"fas fa-dice-d20",onclick:(t=item_sheet_asyncToGenerator(item_sheet_regeneratorRuntime().mark((function _callee50(t){return item_sheet_regeneratorRuntime().wrap((function _callee50$(a){for(;;)switch(a.prev=a.next){case 0:return a.abrupt("return",r.setupEffect(t));case 1:case"end":return a.stop()}}),_callee50)}))),function onclick(r){return t.apply(this,arguments)})}),a}},{key:"getData",value:(a=item_sheet_asyncToGenerator(item_sheet_regeneratorRuntime().mark((function _callee51(t){var a;return item_sheet_regeneratorRuntime().wrap((function _callee51$(o){for(;;)switch(o.prev=o.next){case 0:return o.next=2,item_sheet_get(item_sheet_getPrototypeOf(PoisonSheetDSA5.prototype),"getData",this).call(this,t);case 2:return(a=o.sent).resistances=r.Z.magicResistanceModifiers,o.abrupt("return",a);case 5:case"end":return o.stop()}}),_callee51,this)}))),function getData(t){return a.apply(this,arguments)})}]),PoisonSheetDSA5}(z(H)),ce=function(t){item_sheet_inherits(SpecialAbilitySheetDSA5,t);var a,o,c,u=item_sheet_createSuper(SpecialAbilitySheetDSA5);function SpecialAbilitySheetDSA5(){return item_sheet_classCallCheck(this,SpecialAbilitySheetDSA5),u.apply(this,arguments)}return item_sheet_createClass(SpecialAbilitySheetDSA5,[{key:"_refundStep",value:(c=item_sheet_asyncToGenerator(item_sheet_regeneratorRuntime().mark((function _callee52(){var t;return item_sheet_regeneratorRuntime().wrap((function _callee52$(r){for(;;)switch(r.prev=r.next){case 0:if(!(this.item.system.step.value>1)){r.next=11;break}return r.next=3,i.Z.stepXPCost(this.item,this.item.system.step.value-1);case 3:return t=r.sent,r.next=6,i.Z.refundFreelanguage(this.item,this.item.actor,t,!1);case 6:return t=r.sent,r.next=9,this.item.actor._updateAPs(-1*t,{},{render:!1});case 9:return r.next=11,this.item.update({"system.step.value":this.item.system.step.value-1});case 11:case"end":return r.stop()}}),_callee52,this)}))),function _refundStep(){return c.apply(this,arguments)})},{key:"_advanceStep",value:(o=item_sheet_asyncToGenerator(item_sheet_regeneratorRuntime().mark((function _callee53(){var t;return item_sheet_regeneratorRuntime().wrap((function _callee53$(r){for(;;)switch(r.prev=r.next){case 0:if(!(this.item.system.step.value0}},{key:"getData",value:(a=item_sheet_asyncToGenerator(item_sheet_regeneratorRuntime().mark((function _callee54(t){var a;return item_sheet_regeneratorRuntime().wrap((function _callee54$(o){for(;;)switch(o.prev=o.next){case 0:return o.next=2,item_sheet_get(item_sheet_getPrototypeOf(SpecialAbilitySheetDSA5.prototype),"getData",this).call(this,t);case 2:if(a=o.sent,o.t0=mergeObject,o.t1=a,o.t2=r.Z.specialAbilityCategories,o.t3=r.Z.combatSkillSubCategories,o.t4=r.Z.traditionArtifacts,o.t5=game.user.isGM,o.t5){o.next=13;break}return o.next=12,game.settings.get("dsa5","playerCanEditSpellMacro");case 12:o.t5=o.sent;case 13:return o.t6=o.t5,o.t7={categories:o.t2,subCategories:o.t3,traditionArtifacts:o.t4,canOnUseEffect:o.t6},(0,o.t0)(o.t1,o.t7),o.abrupt("return",a);case 17:case"end":return o.stop()}}),_callee54,this)}))),function getData(t){return a.apply(this,arguments)})}]),SpecialAbilitySheetDSA5}(H),se=function(t){item_sheet_inherits(ItemSpeciesDSA5,t);var r,a=item_sheet_createSuper(ItemSpeciesDSA5);function ItemSpeciesDSA5(){return item_sheet_classCallCheck(this,ItemSpeciesDSA5),a.apply(this,arguments)}return item_sheet_createClass(ItemSpeciesDSA5,[{key:"getData",value:(r=item_sheet_asyncToGenerator(item_sheet_regeneratorRuntime().mark((function _callee55(t){var r;return item_sheet_regeneratorRuntime().wrap((function _callee55$(a){for(;;)switch(a.prev=a.next){case 0:return a.next=2,item_sheet_get(item_sheet_getPrototypeOf(ItemSpeciesDSA5.prototype),"getData",this).call(this,t);case 2:return r=a.sent,mergeObject(r,{hasLocalization:game.i18n.has("Racedescr.".concat(this.item.name))}),a.abrupt("return",r);case 5:case"end":return a.stop()}}),_callee55,this)}))),function getData(t){return r.apply(this,arguments)})}],[{key:"defaultOptions",get:function get(){var t=item_sheet_get(item_sheet_getPrototypeOf(ItemSpeciesDSA5),"defaultOptions",this);return mergeObject(t,{width:530,height:570}),t}}]),ItemSpeciesDSA5}(H),ue=function(t){item_sheet_inherits(SpellSheetDSA5,t);var a,o,i=item_sheet_createSuper(SpellSheetDSA5);function SpellSheetDSA5(){return item_sheet_classCallCheck(this,SpellSheetDSA5),i.apply(this,arguments)}return item_sheet_createClass(SpellSheetDSA5,[{key:"getData",value:(o=item_sheet_asyncToGenerator(item_sheet_regeneratorRuntime().mark((function _callee56(t){var a,o=this;return item_sheet_regeneratorRuntime().wrap((function _callee56$(i){for(;;)switch(i.prev=i.next){case 0:return i.next=2,item_sheet_get(item_sheet_getPrototypeOf(SpellSheetDSA5.prototype),"getData",this).call(this,t);case 2:return(a=i.sent).characteristics=r.Z.characteristics,a.StFs=r.Z.StFs,a.resistances=r.Z.magicResistanceModifiers,a.targetTypes=r.Z.areaTargetTypes,a.isOwned&&(a.extensions=this.item.actor.items.filter((function(t){return"spellextension"==t.type&&t.system.source==o.item.name&&o.item.type==t.system.category}))),i.abrupt("return",a);case 9:case"end":return i.stop()}}),_callee56,this)}))),function getData(t){return o.apply(this,arguments)})},{key:"activateListeners",value:function activateListeners(t){var r=this;item_sheet_get(item_sheet_getPrototypeOf(SpellSheetDSA5.prototype),"activateListeners",this).call(this,t),t.find(".item-edit").click((function(t){t.preventDefault();var a=r._getItemId(t);r.item.actor.items.get(a).sheet.render(!0)})),t.find(".item-delete").click((function(t){r._deleteItem(t)}))}},{key:"_deleteItem",value:function _deleteItem(t){var r=this,a=this._getItemId(t),o=this.actor.items.find((function(t){return t.id==a})),i=game.i18n.format("DIALOG.DeleteItemDetail",{item:o.name});renderTemplate("systems/dsa5/templates/dialog/delete-item-dialog.html",{message:i}).then((function(o){new Dialog({title:game.i18n.localize("DIALOG.deleteConfirmation"),content:o,buttons:{Yes:{icon:'',label:game.i18n.localize("yes"),callback:function callback(){r._cleverDeleteItem(a),$(t.currentTarget).closest(".item").remove()}},cancel:{icon:'',label:game.i18n.localize("cancel")}},default:"Yes"}).render(!0)}))}},{key:"_cleverDeleteItem",value:(a=item_sheet_asyncToGenerator(item_sheet_regeneratorRuntime().mark((function _callee57(t){var r;return item_sheet_regeneratorRuntime().wrap((function _callee57$(a){for(;;)switch(a.prev=a.next){case 0:return r=this.item.actor.items.find((function(r){return r.id==t})),a.next=3,this.item.actor._updateAPs(-1*r.system.APValue.value,{},{render:!1});case 3:return a.next=5,this.item.actor.deleteEmbeddedDocuments("Item",[t]);case 5:case"end":return a.stop()}}),_callee57,this)}))),function _cleverDeleteItem(t){return a.apply(this,arguments)})}]),SpellSheetDSA5}(H),le=function(t){item_sheet_inherits(SpellExtensionSheetDSA5,t);var r,a=item_sheet_createSuper(SpellExtensionSheetDSA5);function SpellExtensionSheetDSA5(){return item_sheet_classCallCheck(this,SpellExtensionSheetDSA5),a.apply(this,arguments)}return item_sheet_createClass(SpellExtensionSheetDSA5,[{key:"getData",value:(r=item_sheet_asyncToGenerator(item_sheet_regeneratorRuntime().mark((function _callee58(t){var r;return item_sheet_regeneratorRuntime().wrap((function _callee58$(a){for(;;)switch(a.prev=a.next){case 0:return a.next=2,item_sheet_get(item_sheet_getPrototypeOf(SpellExtensionSheetDSA5.prototype),"getData",this).call(this,t);case 2:return r=a.sent,mergeObject(r,{categories:{spell:"spell",liturgy:"liturgy",ritual:"ritual",ceremony:"ceremony"}}),a.abrupt("return",r);case 5:case"end":return a.stop()}}),_callee58,this)}))),function getData(t){return r.apply(this,arguments)})}]),SpellExtensionSheetDSA5}(H),fe=function(t){item_sheet_inherits(VantageSheetDSA5,t);var r,o,i,c=item_sheet_createSuper(VantageSheetDSA5);function VantageSheetDSA5(){return item_sheet_classCallCheck(this,VantageSheetDSA5),c.apply(this,arguments)}return item_sheet_createClass(VantageSheetDSA5,[{key:"_advancable",value:function _advancable(){return this.item.system.max.value>0}},{key:"getData",value:(i=item_sheet_asyncToGenerator(item_sheet_regeneratorRuntime().mark((function _callee59(t){var r;return item_sheet_regeneratorRuntime().wrap((function _callee59$(a){for(;;)switch(a.prev=a.next){case 0:return a.next=2,item_sheet_get(item_sheet_getPrototypeOf(VantageSheetDSA5.prototype),"getData",this).call(this,t);case 2:if(r=a.sent,a.t0=game.user.isGM,a.t0){a.next=8;break}return a.next=7,game.settings.get("dsa5","playerCanEditSpellMacro");case 7:a.t0=a.sent;case 8:return r.canOnUseEffect=a.t0,a.abrupt("return",r);case 10:case"end":return a.stop()}}),_callee59,this)}))),function getData(t){return i.apply(this,arguments)})},{key:"_refundStep",value:(o=item_sheet_asyncToGenerator(item_sheet_regeneratorRuntime().mark((function _callee60(){var t;return item_sheet_regeneratorRuntime().wrap((function _callee60$(r){for(;;)switch(r.prev=r.next){case 0:if(!(this.item.system.step.value>1)){r.next=11;break}return r.next=3,a.Z.stepXPCost(this.item,this.item.system.step.value-1);case 3:return t=r.sent,r.next=6,a.Z.reduceSingularVantages(this.item.actor,this.item,t);case 6:return t=r.sent,r.next=9,this.item.actor._updateAPs(-1*t,{},{render:!1});case 9:return r.next=11,this.item.update({"system.step.value":this.item.system.step.value-1});case 11:case"end":return r.stop()}}),_callee60,this)}))),function _refundStep(){return o.apply(this,arguments)})},{key:"_advanceStep",value:(r=item_sheet_asyncToGenerator(item_sheet_regeneratorRuntime().mark((function _callee61(){var t,r;return item_sheet_regeneratorRuntime().wrap((function _callee61$(o){for(;;)switch(o.prev=o.next){case 0:if(!(this.item.system.step.value=0;--o){var i=this.tryEntries[o],c=i.completion;if("root"===i.tryLoc)return handle("end");if(i.tryLoc<=this.prev){var u=a.call(i,"catchLoc"),l=a.call(i,"finallyLoc");if(u&&l){if(this.prev=0;--o){var i=this.tryEntries[o];if(i.tryLoc<=this.prev&&a.call(i,"finallyLoc")&&this.prev=0;--r){var a=this.tryEntries[r];if(a.finallyLoc===t)return this.complete(a.completion,a.afterLoc),resetTryEntry(a),l}},catch:function _catch(t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc===t){var o=a.completion;if("throw"===o.type){var i=o.arg;resetTryEntry(a)}return i}}throw new Error("illegal catch attempt")},delegateYield:function delegateYield(t,r,a){return this.delegate={iterator:values(t),resultName:r,nextLoc:a},"next"===this.method&&(this.arg=void 0),l}},t}function dicesonice_asyncGeneratorStep(t,r,a,o,i,c,u){try{var l=t[c](u),p=l.value}catch(t){return void a(t)}l.done?r(p):Promise.resolve(p).then(o,i)}function dicesonice_asyncToGenerator(t){return function(){var r=this,a=arguments;return new Promise((function(o,i){var c=t.apply(r,a);function _next(t){dicesonice_asyncGeneratorStep(c,o,i,_next,_throw,"next",t)}function _throw(t){dicesonice_asyncGeneratorStep(c,o,i,_next,_throw,"throw",t)}_next(void 0)}))}}function dicesonice_createForOfIteratorHelper(t,r){var a="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!a){if(Array.isArray(t)||(a=dicesonice_unsupportedIterableToArray(t))||r&&t&&"number"==typeof t.length){a&&(t=a);var o=0,i=function F(){};return{s:i,n:function n(){return o>=t.length?{done:!0}:{done:!1,value:t[o++]}},e:function e(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var c,u=!0,l=!1;return{s:function s(){a=a.call(t)},n:function n(){var t=a.next();return u=t.done,t},e:function e(t){l=!0,c=t},f:function f(){try{u||null==a.return||a.return()}finally{if(l)throw c}}}}function dicesonice_slicedToArray(t,r){return function dicesonice_arrayWithHoles(t){if(Array.isArray(t))return t}(t)||function dicesonice_iterableToArrayLimit(t,r){var a=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null==a)return;var o,i,c=[],u=!0,l=!1;try{for(a=a.call(t);!(u=(o=a.next()).done)&&(c.push(o.value),!r||c.length!==r);u=!0);}catch(t){l=!0,i=t}finally{try{u||null==a.return||a.return()}finally{if(l)throw i}}return c}(t,r)||dicesonice_unsupportedIterableToArray(t,r)||function dicesonice_nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function dicesonice_unsupportedIterableToArray(t,r){if(t){if("string"==typeof t)return dicesonice_arrayLikeToArray(t,r);var a=Object.prototype.toString.call(t).slice(8,-1);return"Object"===a&&t.constructor&&(a=t.constructor.name),"Map"===a||"Set"===a?Array.from(t):"Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a)?dicesonice_arrayLikeToArray(t,r):void 0}}function dicesonice_arrayLikeToArray(t,r){(null==r||r>t.length)&&(r=t.length);for(var a=0,o=new Array(r);a0&&void 0!==arguments[0])||arguments[0],a=new Set,o=dicesonice_createForOfIteratorHelper(DiceSoNiceCustomization.attrs);try{for(o.s();!(t=o.n()).done;){var i=t.value;a.add(game.settings.get("dsa5","dice3d_system_".concat(i)))}}catch(t){o.e(t)}finally{o.f()}a=Array.from(a),r&&this.preloadDiceAssets(a),game.socket.emit("system.dsa5",{type:"preloadDice3d",payload:a})}},{key:"requestDicePreloads",value:function requestDicePreloads(){this.collectPreloads(!1)}},{key:"preloadDiceAssets",value:(a=dicesonice_asyncToGenerator(dicesonice_regeneratorRuntime().mark((function _callee4(t){var r,a,o,i,c,u,l,p,d,h=this,m=arguments;return dicesonice_regeneratorRuntime().wrap((function _callee4$(y){for(;;)switch(y.prev=y.next){case 0:r=m.length>1&&void 0!==m[1]?m[1]:[],console.warn("loading",t),a=dicesonice_createForOfIteratorHelper(t),y.prev=3,a.s();case 5:if((o=a.n()).done){y.next=42;break}if(i=o.value,c=game.dice3d.DiceFactory.systems[i]){y.next=11;break}return this.unloadedModels.push(i),y.abrupt("continue",40);case 11:u=c.dice.filter((function(t){return 0==r.length||r.includes(t.type)})),l=dicesonice_createForOfIteratorHelper(u),y.prev=13,l.s();case 15:if((p=l.n()).done){y.next=32;break}if(d=p.value,y.prev=17,!d.modelFile){y.next=23;break}return y.next=21,d.loadModel(game.dice3d.DiceFactory.loaderGLTF);case 21:y.next=25;break;case 23:return y.next=25,d.loadTextures();case 25:y.next=30;break;case 27:y.prev=27,y.t0=y.catch(17),console.warn("Unable to load dice model",i,d);case 30:y.next=15;break;case 32:y.next=37;break;case 34:y.prev=34,y.t1=y.catch(13),l.e(y.t1);case 37:return y.prev=37,l.f(),y.finish(37);case 40:y.next=5;break;case 42:y.next=47;break;case 44:y.prev=44,y.t2=y.catch(3),a.e(y.t2);case 47:return y.prev=47,a.f(),y.finish(47);case 50:this.unloadedModels.length&&this.retries<6&&!this.retrying&&(this.retrying=!0,setTimeout((function(){h.retries+=1;var t=new Set(h.unloadedModels);h.unloadedModels=[],h.retrying=!1,h.preloadDiceAssets(t)}),1e4));case 51:case"end":return y.stop()}}),_callee4,this,[[3,44,47,50],[13,34,37,40],[17,27]])}))),function preloadDiceAssets(t){return a.apply(this,arguments)})},{key:"defaultOptions",get:function get(){var t=dicesonice_get(dicesonice_getPrototypeOf(DiceSoNiceCustomization),"defaultOptions",this);return mergeObject(t,{template:"systems/dsa5/templates/wizard/dicesonice-configuration.html",title:game.i18n.localize("DSASETTINGS.dicesonicesettings"),width:600}),t}}]),DiceSoNiceCustomization}();dicesonice_defineProperty(de,"unloadedModels",[]),dicesonice_defineProperty(de,"retries",0),dicesonice_defineProperty(de,"retrying",!1),dicesonice_defineProperty(de,"attrs",["mu","kl","in","ch","ff","ge","ko","kk","attack","dodge","parry","damage"]);var he=function(t){dicesonice_inherits(DiceSoNiceForm,FormApplication);var r=dicesonice_createSuper(DiceSoNiceForm);function DiceSoNiceForm(){return dicesonice_classCallCheck(this,DiceSoNiceForm),r.apply(this,arguments)}return dicesonice_createClass(DiceSoNiceForm,[{key:"render",value:function render(){game.dsa5.apps.DiceSoNiceCustomization.render(!0)}}]),DiceSoNiceForm}(),me=__webpack_require__(61);function actor_typeof(t){return actor_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},actor_typeof(t)}function actor_setPrototypeOf(t,r){return actor_setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function _setPrototypeOf(t,r){return t.__proto__=r,t},actor_setPrototypeOf(t,r)}function actor_createSuper(t){var r=function actor_isNativeReflectConstruct(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function _createSuperInternal(){var a,o=actor_getPrototypeOf(t);if(r){var i=actor_getPrototypeOf(this).constructor;a=Reflect.construct(o,arguments,i)}else a=o.apply(this,arguments);return actor_possibleConstructorReturn(this,a)}}function actor_possibleConstructorReturn(t,r){if(r&&("object"===actor_typeof(r)||"function"==typeof r))return r;if(void 0!==r)throw new TypeError("Derived constructors may only return object or undefined");return function actor_assertThisInitialized(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}function actor_getPrototypeOf(t){return actor_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function _getPrototypeOf(t){return t.__proto__||Object.getPrototypeOf(t)},actor_getPrototypeOf(t)}function actor_classCallCheck(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}function actor_defineProperties(t,r){for(var a=0;a=t.length?{done:!0}:{done:!1,value:t[o++]}},e:function e(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var c,u=!0,l=!1;return{s:function s(){a=a.call(t)},n:function n(){var t=a.next();return u=t.done,t},e:function e(t){l=!0,c=t},f:function f(){try{u||null==a.return||a.return()}finally{if(l)throw c}}}}function actor_unsupportedIterableToArray(t,r){if(t){if("string"==typeof t)return actor_arrayLikeToArray(t,r);var a=Object.prototype.toString.call(t).slice(8,-1);return"Object"===a&&t.constructor&&(a=t.constructor.name),"Map"===a||"Set"===a?Array.from(t):"Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a)?actor_arrayLikeToArray(t,r):void 0}}function actor_arrayLikeToArray(t,r){(null==r||r>t.length)&&(r=t.length);for(var a=0,o=new Array(r);a=0;--o){var i=this.tryEntries[o],c=i.completion;if("root"===i.tryLoc)return handle("end");if(i.tryLoc<=this.prev){var u=a.call(i,"catchLoc"),l=a.call(i,"finallyLoc");if(u&&l){if(this.prev=0;--o){var i=this.tryEntries[o];if(i.tryLoc<=this.prev&&a.call(i,"finallyLoc")&&this.prev=0;--r){var a=this.tryEntries[r];if(a.finallyLoc===t)return this.complete(a.completion,a.afterLoc),resetTryEntry(a),l}},catch:function _catch(t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc===t){var o=a.completion;if("throw"===o.type){var i=o.arg;resetTryEntry(a)}return i}}throw new Error("illegal catch attempt")},delegateYield:function delegateYield(t,r,a){return this.delegate={iterator:values(t),resultName:r,nextLoc:a},"next"===this.method&&(this.arg=void 0),l}},t}function actor_asyncGeneratorStep(t,r,a,o,i,c,u){try{var l=t[c](u),p=l.value}catch(t){return void a(t)}l.done?r(p):Promise.resolve(p).then(o,i)}function actor_asyncToGenerator(t){return function(){var r=this,a=arguments;return new Promise((function(o,i){var c=t.apply(r,a);function _next(t){actor_asyncGeneratorStep(c,o,i,_next,_throw,"next",t)}function _throw(t){actor_asyncGeneratorStep(c,o,i,_next,_throw,"throw",t)}_next(void 0)}))}}var ye=function(){function TokenHoverHud(){actor_classCallCheck(this,TokenHoverHud)}return actor_createClass(TokenHoverHud,null,[{key:"show",value:function show(t){var r,a;if(game.combat&&(null===(r=canvas.hud)||void 0===r||null===(a=r.token)||void 0===a||!a.rendered)){var o=t.actor.items.filter((function(t){return("meleeweapon"==t.type||"rangeweapon"==t.type)&&t.system.worn.value}));if(o.length){var i=o.map((function(t){return'')})).join(" "),c=$('
    ').concat(i,"
    "));$("#hud").append(c),this.position(c,t,o.length)}}}},{key:"position",value:function position(t,r,a){var o=r.document,i=canvas.dimensions.size/100,c=43*a,position={width:c,height:42,left:r.center.x-c/2*i,top:r.y+o.height*canvas.dimensions.size+32};1!==i&&(position.transform="scale(".concat(i,")")),t.css(position)}},{key:"hide",value:function hide(t){$("#hoverhud_".concat(t.id)).remove()}}]),TokenHoverHud}(),ge=function(t){!function actor_inherits(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(r&&r.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),r&&actor_setPrototypeOf(t,r)}(AskForNameDialog,Dialog);var r,a=actor_createSuper(AskForNameDialog);function AskForNameDialog(){return actor_classCallCheck(this,AskForNameDialog),a.apply(this,arguments)}return actor_createClass(AskForNameDialog,null,[{key:"getDialog",value:(r=actor_asyncToGenerator(actor_regeneratorRuntime().mark((function _callee9(t,r){return actor_regeneratorRuntime().wrap((function _callee9$(a){for(;;)switch(a.prev=a.next){case 0:new Dialog({title:game.i18n.localize("DSASETTINGS.obfuscateTokenNames"),content:' '),default:"Yes",buttons:{Yes:{icon:'',label:game.i18n.localize("yes"),callback:function(){var a=actor_asyncToGenerator(actor_regeneratorRuntime().mark((function _callee7(a){var o,i,c,u,l,p,d,h,m;return actor_regeneratorRuntime().wrap((function _callee7$(y){for(;;)switch(y.prev=y.next){case 0:if(o=t.id||t._id,i=a.find('[name="name"]').val(),2==r&&(c=canvas.scene.tokens.filter((function(t){return t.name===i})),c.length>0)){u=c.length,l=actor_createForOfIteratorHelper(c);try{for(l.s();!(p=l.n()).done;)d=p.value,(h=d.name.match(/\d+$/))&&Number(h[0])>u&&(u=Number(h[0]))}catch(t){l.e(t)}finally{l.f()}i="".concat(c[0].name.replace(/ \d{1,}$/,"")," ").concat(u+1)}return m=canvas.scene.tokens.get(o),y.next=6,m.update({name:i});case 6:case"end":return y.stop()}}),_callee7)})));return function callback(t){return a.apply(this,arguments)}}()},unknown:{icon:'',label:game.i18n.localize("unknown"),callback:function(){var r=actor_asyncToGenerator(actor_regeneratorRuntime().mark((function _callee8(){var r,a;return actor_regeneratorRuntime().wrap((function _callee8$(o){for(;;)switch(o.prev=o.next){case 0:return r=t.id||t._id,a=canvas.scene.tokens.get(r),o.next=4,a.update({name:game.i18n.localize("unknown")});case 4:case"end":return o.stop()}}),_callee8)})));return function callback(){return r.apply(this,arguments)}}()},cancel:{icon:'',label:game.i18n.localize("cancel")}}}).render(!0);case 1:case"end":return a.stop()}}),_callee9)}))),function getDialog(t,a){return r.apply(this,arguments)})}]),AskForNameDialog}();function createHotBarMacro(t,r,a,o){var i=game.macros.contents.find((function(a){return a.name===r&&a.command===t}));return i?game.user.assignHotbarMacro(i,o):Macro.create({name:r,type:"script",img:a,command:t},{displaySheet:!1}).then((function(t){return game.user.assignHotbarMacro(t,o)})),!1}var ve=__webpack_require__(118);function chatlog_createForOfIteratorHelper(t,r){var a="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!a){if(Array.isArray(t)||(a=function chatlog_unsupportedIterableToArray(t,r){if(!t)return;if("string"==typeof t)return chatlog_arrayLikeToArray(t,r);var a=Object.prototype.toString.call(t).slice(8,-1);"Object"===a&&t.constructor&&(a=t.constructor.name);if("Map"===a||"Set"===a)return Array.from(t);if("Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a))return chatlog_arrayLikeToArray(t,r)}(t))||r&&t&&"number"==typeof t.length){a&&(t=a);var o=0,i=function F(){};return{s:i,n:function n(){return o>=t.length?{done:!0}:{done:!1,value:t[o++]}},e:function e(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var c,u=!0,l=!1;return{s:function s(){a=a.call(t)},n:function n(){var t=a.next();return u=t.done,t},e:function e(t){l=!0,c=t},f:function f(){try{u||null==a.return||a.return()}finally{if(l)throw c}}}}function chatlog_arrayLikeToArray(t,r){(null==r||r>t.length)&&(r=t.length);for(var a=0,o=new Array(r);a').concat(h.results[m].result,""))}}catch(t){d.e(t)}finally{d.f()}var y={content:'
    \n
    \n '.concat(game.i18n.localize("Roll"),": ").concat(p.join(""),'\n
    \n
    \n ').concat(game.i18n.localize("initiative"),": ").concat(Math.floor(100*t.rolls[0]._total)/100,"\n
    \n
    "),flavor:void 0};t.updateSource(y)}}))}function tutorial_typeof(t){return tutorial_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},tutorial_typeof(t)}function tutorial_regeneratorRuntime(){tutorial_regeneratorRuntime=function _regeneratorRuntime(){return t};var t={},r=Object.prototype,a=r.hasOwnProperty,o="function"==typeof Symbol?Symbol:{},i=o.iterator||"@@iterator",c=o.asyncIterator||"@@asyncIterator",u=o.toStringTag||"@@toStringTag";function define(t,r,a){return Object.defineProperty(t,r,{value:a,enumerable:!0,configurable:!0,writable:!0}),t[r]}try{define({},"")}catch(t){define=function define(t,r,a){return t[r]=a}}function wrap(t,r,a,o){var i=r&&r.prototype instanceof Generator?r:Generator,c=Object.create(i.prototype),u=new Context(o||[]);return c._invoke=function(t,r,a){var o="suspendedStart";return function(i,c){if("executing"===o)throw new Error("Generator is already running");if("completed"===o){if("throw"===i)throw c;return doneResult()}for(a.method=i,a.arg=c;;){var u=a.delegate;if(u){var p=maybeInvokeDelegate(u,a);if(p){if(p===l)continue;return p}}if("next"===a.method)a.sent=a._sent=a.arg;else if("throw"===a.method){if("suspendedStart"===o)throw o="completed",a.arg;a.dispatchException(a.arg)}else"return"===a.method&&a.abrupt("return",a.arg);o="executing";var d=tryCatch(t,r,a);if("normal"===d.type){if(o=a.done?"completed":"suspendedYield",d.arg===l)continue;return{value:d.arg,done:a.done}}"throw"===d.type&&(o="completed",a.method="throw",a.arg=d.arg)}}}(t,a,u),c}function tryCatch(t,r,a){try{return{type:"normal",arg:t.call(r,a)}}catch(t){return{type:"throw",arg:t}}}t.wrap=wrap;var l={};function Generator(){}function GeneratorFunction(){}function GeneratorFunctionPrototype(){}var p={};define(p,i,(function(){return this}));var d=Object.getPrototypeOf,h=d&&d(d(values([])));h&&h!==r&&a.call(h,i)&&(p=h);var m=GeneratorFunctionPrototype.prototype=Generator.prototype=Object.create(p);function defineIteratorMethods(t){["next","throw","return"].forEach((function(r){define(t,r,(function(t){return this._invoke(r,t)}))}))}function AsyncIterator(t,r){function invoke(o,i,c,u){var l=tryCatch(t[o],t,i);if("throw"!==l.type){var p=l.arg,d=p.value;return d&&"object"==tutorial_typeof(d)&&a.call(d,"__await")?r.resolve(d.__await).then((function(t){invoke("next",t,c,u)}),(function(t){invoke("throw",t,c,u)})):r.resolve(d).then((function(t){p.value=t,c(p)}),(function(t){return invoke("throw",t,c,u)}))}u(l.arg)}var o;this._invoke=function(t,a){function callInvokeWithMethodAndArg(){return new r((function(r,o){invoke(t,a,r,o)}))}return o=o?o.then(callInvokeWithMethodAndArg,callInvokeWithMethodAndArg):callInvokeWithMethodAndArg()}}function maybeInvokeDelegate(t,r){var a=t.iterator[r.method];if(void 0===a){if(r.delegate=null,"throw"===r.method){if(t.iterator.return&&(r.method="return",r.arg=void 0,maybeInvokeDelegate(t,r),"throw"===r.method))return l;r.method="throw",r.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var o=tryCatch(a,t.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,l;var i=o.arg;return i?i.done?(r[t.resultName]=i.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=void 0),r.delegate=null,l):i:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,l)}function pushTryEntry(t){var r={tryLoc:t[0]};1 in t&&(r.catchLoc=t[1]),2 in t&&(r.finallyLoc=t[2],r.afterLoc=t[3]),this.tryEntries.push(r)}function resetTryEntry(t){var r=t.completion||{};r.type="normal",delete r.arg,t.completion=r}function Context(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(pushTryEntry,this),this.reset(!0)}function values(t){if(t){var r=t[i];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var o=-1,c=function next(){for(;++o=0;--o){var i=this.tryEntries[o],c=i.completion;if("root"===i.tryLoc)return handle("end");if(i.tryLoc<=this.prev){var u=a.call(i,"catchLoc"),l=a.call(i,"finallyLoc");if(u&&l){if(this.prev=0;--o){var i=this.tryEntries[o];if(i.tryLoc<=this.prev&&a.call(i,"finallyLoc")&&this.prev=0;--r){var a=this.tryEntries[r];if(a.finallyLoc===t)return this.complete(a.completion,a.afterLoc),resetTryEntry(a),l}},catch:function _catch(t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc===t){var o=a.completion;if("throw"===o.type){var i=o.arg;resetTryEntry(a)}return i}}throw new Error("illegal catch attempt")},delegateYield:function delegateYield(t,r,a){return this.delegate={iterator:values(t),resultName:r,nextLoc:a},"next"===this.method&&(this.arg=void 0),l}},t}function tutorial_asyncGeneratorStep(t,r,a,o,i,c,u){try{var l=t[c](u),p=l.value}catch(t){return void a(t)}l.done?r(p):Promise.resolve(p).then(o,i)}function tutorial_asyncToGenerator(t){return function(){var r=this,a=arguments;return new Promise((function(o,i){var c=t.apply(r,a);function _next(t){tutorial_asyncGeneratorStep(c,o,i,_next,_throw,"next",t)}function _throw(t){tutorial_asyncGeneratorStep(c,o,i,_next,_throw,"throw",t)}_next(void 0)}))}}function tutorial_defineProperties(t,r){for(var a=0;a=0;--o){var i=this.tryEntries[o],c=i.completion;if("root"===i.tryLoc)return handle("end");if(i.tryLoc<=this.prev){var u=a.call(i,"catchLoc"),l=a.call(i,"finallyLoc");if(u&&l){if(this.prev=0;--o){var i=this.tryEntries[o];if(i.tryLoc<=this.prev&&a.call(i,"finallyLoc")&&this.prev=0;--r){var a=this.tryEntries[r];if(a.finallyLoc===t)return this.complete(a.completion,a.afterLoc),resetTryEntry(a),l}},catch:function _catch(t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc===t){var o=a.completion;if("throw"===o.type){var i=o.arg;resetTryEntry(a)}return i}}throw new Error("illegal catch attempt")},delegateYield:function delegateYield(t,r,a){return this.delegate={iterator:values(t),resultName:r,nextLoc:a},"next"===this.method&&(this.arg=void 0),l}},t}function merchantmixin_createForOfIteratorHelper(t,r){var a="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!a){if(Array.isArray(t)||(a=merchantmixin_unsupportedIterableToArray(t))||r&&t&&"number"==typeof t.length){a&&(t=a);var o=0,i=function F(){};return{s:i,n:function n(){return o>=t.length?{done:!0}:{done:!1,value:t[o++]}},e:function e(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var c,u=!0,l=!1;return{s:function s(){a=a.call(t)},n:function n(){var t=a.next();return u=t.done,t},e:function e(t){l=!0,c=t},f:function f(){try{u||null==a.return||a.return()}finally{if(l)throw c}}}}function merchantmixin_unsupportedIterableToArray(t,r){if(t){if("string"==typeof t)return merchantmixin_arrayLikeToArray(t,r);var a=Object.prototype.toString.call(t).slice(8,-1);return"Object"===a&&t.constructor&&(a=t.constructor.name),"Map"===a||"Set"===a?Array.from(t):"Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a)?merchantmixin_arrayLikeToArray(t,r):void 0}}function merchantmixin_arrayLikeToArray(t,r){(null==r||r>t.length)&&(r=t.length);for(var a=0,o=new Array(r);a3&&void 0!==l[3])||l[3],i=this._getItemId(a),c=a.currentTarget.dataset.price,u=a.ctrlKey?10:1,!game.user.isGM){p.next=9;break}return p.next=7,this.constructor.finishTransaction(t,r,c,i,o,u);case 7:p.next=10;break;case 9:(this.constructor.noNeedToPay(r,t,c)||w.canPay(r,c,!0))&&game.socket.emit("system.dsa5",{type:"trade",payload:{target:this.constructor.transferTokenData(r),source:this.constructor.transferTokenData(t),price:c,itemId:i,buy:o,amount:u}});case 10:case"end":return p.stop()}}),_callee12,this)}))),function transferItem(t,r,a){return A.apply(this,arguments)})},{key:"getTradeFriend",value:function getTradeFriend(){return this.otherTradeFriend||game.user.character}},{key:"_manageDragItems",value:(T=merchantmixin_asyncToGenerator(merchantmixin_regeneratorRuntime().mark((function _callee13(t,r){return merchantmixin_regeneratorRuntime().wrap((function _callee13$(a){for(;;)switch(a.prev=a.next){case 0:a.t0=r,a.next="creature"===a.t0||"npc"===a.t0||"character"===a.t0?3:5;break;case 3:return this.setTradeFriend(t),a.abrupt("break",6);case 5:return a.abrupt("return",merchantmixin_get(merchantmixin_getPrototypeOf(_class.prototype),"_manageDragItems",this).call(this,t,r));case 6:case"end":return a.stop()}}),_callee13,this)}))),function _manageDragItems(t,r){return T.apply(this,arguments)})},{key:"_onDropActor",value:(S=merchantmixin_asyncToGenerator(merchantmixin_regeneratorRuntime().mark((function _callee14(t,r){var a,o,i,c,u;return merchantmixin_regeneratorRuntime().wrap((function _callee14$(t){for(;;)switch(t.prev=t.next){case 0:if(a=this.actor.limited,o=this.actor.isOwner,a||o){t.next=4;break}return t.abrupt("return",!1);case 4:return t.next=6,(0,h.x8)(r,this.id,!1);case 6:if(i=t.sent,c=i.item,u=i.typeClass,!i.selfTarget){t.next=12;break}return t.abrupt("return");case 12:if(!(o||a&&"Actor"==c.documentName)){t.next=16;break}return t.next=15,this._manageDragItems(c,u);case 15:return t.abrupt("return",t.sent);case 16:case"end":return t.stop()}}),_callee14,this)}))),function _onDropActor(t,r){return S.apply(this,arguments)})},{key:"setTradeFriend",value:function setTradeFriend(t){var r=game.actors.get(t._id);r.isOwner&&(this.otherTradeFriend=r,this.render(!0))}},{key:"_render",value:(x=merchantmixin_asyncToGenerator(merchantmixin_regeneratorRuntime().mark((function _callee15(){var t,r,a=arguments;return merchantmixin_regeneratorRuntime().wrap((function _callee15$(o){for(;;)switch(o.prev=o.next){case 0:if(t=a.length>0&&void 0!==a[0]&&a[0],r=a.length>1&&void 0!==a[1]?a[1]:{},game.user.isGM||"loot"!=getProperty(this.actor.system,"merchant.merchantType")||!getProperty(this.actor.system,"merchant.locked")){o.next=5;break}return AudioHelper.play({src:"sounds/lock.wav",loop:!1},!1),o.abrupt("return");case 5:return o.next=7,merchantmixin_get(merchantmixin_getPrototypeOf(_class.prototype),"_render",this).call(this,t,r);case 7:case"end":return o.stop()}}),_callee15,this)}))),function _render(){return x.apply(this,arguments)})},{key:"_togglePlayerview",value:function _togglePlayerview(t){this.actor.update({"system.merchant.playerView":!getProperty(this.actor.system,"merchant.playerView")})}},{key:"playerViewEnabled",value:function playerViewEnabled(){return getProperty(this.actor.system,"merchant.playerView")}},{key:"randomGoods",value:(k=merchantmixin_asyncToGenerator(merchantmixin_regeneratorRuntime().mark((function _callee16(t){var a,o=this;return merchantmixin_regeneratorRuntime().wrap((function _callee16$(i){for(;;)switch(i.prev=i.next){case 0:return i.next=2,renderTemplate("systems/dsa5/templates/dialog/randomGoods-dialog.html",{categories:r.Z.equipmentCategories});case 2:a=i.sent,new Dialog({title:game.i18n.localize("MERCHANT.randomGoods"),content:a,default:"yes",buttons:{Yes:{icon:'',label:game.i18n.localize("yes"),callback:function callback(r){return o.addRandomGoods(o.actor,r,t)}},cancel:{icon:'',label:game.i18n.localize("cancel")}}}).render(!0);case 4:case"end":return i.stop()}}),_callee16)}))),function randomGoods(t){return k.apply(this,arguments)})},{key:"clearInventory",value:(b=merchantmixin_asyncToGenerator(merchantmixin_regeneratorRuntime().mark((function _callee17(t){var r=this;return merchantmixin_regeneratorRuntime().wrap((function _callee17$(a){for(;;)switch(a.prev=a.next){case 0:new Dialog({title:game.i18n.localize("MERCHANT.clearInventory"),content:game.i18n.localize("MERCHANT.deleteAllGoods"),default:"yes",buttons:{Yes:{icon:'',label:game.i18n.localize("yes"),callback:function callback(){r.removeAllGoods(r.actor,t)}},cancel:{icon:'',label:game.i18n.localize("cancel")}}}).render(!0);case 1:case"end":return a.stop()}}),_callee17)}))),function clearInventory(t){return b.apply(this,arguments)})},{key:"addRandomGoods",value:(_=merchantmixin_asyncToGenerator(merchantmixin_regeneratorRuntime().mark((function _callee18(t,r,a){var o,i,c,u,l,p,d,h;return merchantmixin_regeneratorRuntime().wrap((function _callee18$(m){for(;;)switch(m.prev=m.next){case 0:if(o=$(a.currentTarget).text(),$(a.currentTarget).html(' '),i=[],r.find('input[type="checkbox"]:checked').each((function(){var t=$(this).val();i.push({name:t,count:Number(r.find('input[name="each_'.concat(t,'"]')).val()),number:Number(r.find('input[name="number_'.concat(t,'"]')).val())})})),(c=game.dsa5.itemLibrary).equipmentBuild){m.next=8;break}return m.next=8,c.buildEquipmentIndex();case 8:u=[],l=merchantmixin_regeneratorRuntime().mark((function _loop(){var t,r,a;return merchantmixin_regeneratorRuntime().wrap((function _loop$(o){for(;;)switch(o.prev=o.next){case 0:return r=d[p],o.next=3,c.getRandomItems(r.name,r.number);case 3:a=o.sent.map((function(t){var a=t.toObject();return a.system.quantity.value=r.count,a})),(t=u).push.apply(t,merchantmixin_toConsumableArray(a));case 5:case"end":return o.stop()}}),_loop)})),p=0,d=i;case 11:if(!(p1e4)return!1;var i="".concat(r.type,"_").concat(r.name);return!h.hasOwnProperty(i)&&(h[i]=!0)&&0==t.items.filter((function(t){return t.type==r.type&&t.name==r.name})).length})),m.next=20,t.createEmbeddedDocuments("Item",u);case 20:$(a.currentTarget).text(o);case 21:case"end":return m.stop()}}),_callee18)}))),function addRandomGoods(t,r,a){return _.apply(this,arguments)})},{key:"removeAllGoods",value:(v=merchantmixin_asyncToGenerator(merchantmixin_regeneratorRuntime().mark((function _callee19(t,a){var o,i;return merchantmixin_regeneratorRuntime().wrap((function _callee19$(c){for(;;)switch(c.prev=c.next){case 0:return o=$(a.currentTarget).text(),$(a.currentTarget).html(' '),i=t.items.filter((function(t){return r.Z.equipmentCategories.includes(t.type)&&!getProperty(t,"worn.value")})).map((function(t){return t.id})),c.next=5,t.deleteEmbeddedDocuments("Item",i);case 5:$(a.currentTarget).text(o);case 6:case"end":return c.stop()}}),_callee19)}))),function removeAllGoods(t,r){return v.apply(this,arguments)})},{key:"getData",value:(g=merchantmixin_asyncToGenerator(merchantmixin_regeneratorRuntime().mark((function _callee20(t){var r,a=this;return merchantmixin_regeneratorRuntime().wrap((function _callee20$(o){for(;;)switch(o.prev=o.next){case 0:return o.next=2,merchantmixin_get(merchantmixin_getPrototypeOf(_class.prototype),"getData",this).call(this,t);case 2:return(r=o.sent).merchantType=getProperty(this.actor.system,"merchant.merchantType")||"none",r.merchantTypes={none:game.i18n.localize("MERCHANT.typeNone"),merchant:game.i18n.localize("MERCHANT.typeMerchant"),loot:game.i18n.localize("MERCHANT.typeLoot"),epic:game.i18n.localize("MERCHANT.typeEpic")},r.invName=r.merchantTypes[r.merchantType],r.players=game.users.filter((function(t){return!t.isGM})).map((function(t){return t.allowedMerchant=a.actor.testUserPermission(t,"LIMITED",!1),t.buyingFactor=getProperty(a.actor.system,"merchant.factors.buyingFactor.".concat(t.id)),t.sellingFactor=getProperty(a.actor.system,"merchant.factors.sellingFactor.".concat(t.id)),t})),"epic"!=r.merchantType?(this.prepareStorage(r),this.merchantSheetActivated()&&(this.filterWornEquipment(r),this.prepareTradeFriend(r),0==r.prepare.inventory.misc.items.length&&(r.prepare.inventory.misc.show=!1))):(this.prepareStorage(r),r.garadanOptions={1:game.i18n.localize("GARADAN.1"),2:game.i18n.localize("GARADAN.2"),3:game.i18n.localize("GARADAN.3"),4:game.i18n.localize("GARADAN.4"),6:game.i18n.localize("GARADAN.6")}),r.hasOtherTradeFriend=!!this.otherTradeFriend,o.abrupt("return",r);case 10:case"end":return o.stop()}}),_callee20,this)}))),function getData(t){return g.apply(this,arguments)})},{key:"filterWornEquipment",value:function filterWornEquipment(t){for(var r=0,a=Object.entries(t.prepare.inventory);r0)){p.next=29;break}if(l=this.noNeedToPay(r,t,a),p.t0=l,p.t0){p.next=9;break}return p.next=8,w.payMoney(r,a,!0);case 8:p.t0=p.sent;case 9:if(!p.t0){p.next=29;break}if(getProperty(u,"system.worn.value")&&(u.system.worn.value=!1),!i){p.next=23;break}return p.next=15,this.updateTargetTransaction(r,u,c,t,a);case 15:return p.next=17,this.updateSourceTransaction(t,r,u,a,o,c);case 17:return p.next=19,this.transferNotification(u,r,t,i,a,c,l);case 19:return p.next=21,this.selfDestruction(t);case 21:p.next=29;break;case 23:return p.next=25,this.updateSourceTransaction(t,r,u,a,o,c);case 25:return p.next=27,this.updateTargetTransaction(r,u,c,t,a);case 27:return p.next=29,this.transferNotification(u,t,r,i,a,c,l);case 29:case"end":return p.stop()}}),_callee21,this)}))),function finishTransaction(t,r,a,o,i,c){return d.apply(this,arguments)})},{key:"isTemporaryToken",value:function isTemporaryToken(t){return"loot"==getProperty(t.system,"merchant.merchantType")&&getProperty(t.system,"merchant.temporary")}},{key:"selfDestruction",value:(p=merchantmixin_asyncToGenerator(merchantmixin_regeneratorRuntime().mark((function _callee22(t){var a;return merchantmixin_regeneratorRuntime().wrap((function _callee22$(o){for(;;)switch(o.prev=o.next){case 0:if(!this.isTemporaryToken(t)){o.next=10;break}if(t.items.some((function(t){return r.Z.equipmentCategories.includes(t.type)||"money"==t.type&&t.system.quantity.value>0}))){o.next=10;break}return game.socket.emit("system.dsa5",{type:"hideDeletedSheet",payload:{target:this.transferTokenData(t)}}),a=t.getActiveTokens().map((function(t){return t.id})),o.next=7,canvas.scene.deleteEmbeddedDocuments("Token",a);case 7:return o.next=9,game.actors.get(t.id).delete();case 9:this.hideDeletedSheet(t);case 10:case"end":return o.stop()}}),_callee22,this)}))),function selfDestruction(t){return p.apply(this,arguments)})},{key:"hideDeletedSheet",value:(l=merchantmixin_asyncToGenerator(merchantmixin_regeneratorRuntime().mark((function _callee23(t){return merchantmixin_regeneratorRuntime().wrap((function _callee23$(r){for(;;)switch(r.prev=r.next){case 0:t.sheet.close(!0);case 1:case"end":return r.stop()}}),_callee23)}))),function hideDeletedSheet(t){return l.apply(this,arguments)})},{key:"transferNotification",value:(u=merchantmixin_asyncToGenerator(merchantmixin_regeneratorRuntime().mark((function _callee24(r,a,o,i,c,u,l){var p,d,h,m;return merchantmixin_regeneratorRuntime().wrap((function _callee24$(y){for(;;)switch(y.prev=y.next){case 0:if(0!=(p=game.settings.get("dsa5","merchantNotification"))&&"service"!=getProperty(r,"system.equipmentType.value")){y.next=3;break}return y.abrupt("return");case 3:return d="MERCHANT."+(i?"buy":"sell")+(l?"Loot":"")+"Notification",h=game.i18n.format(d,{item:r.name,source:a.name,target:o.name,amount:u,price:c,buy:i}),m=t.Z.chatDataSetup(h),2==p&&(m.whisper=ChatMessage.getWhisperRecipients("GM").map((function(t){return t.id}))),y.next=9,ChatMessage.create(m);case 9:case"end":return y.stop()}}),_callee24)}))),function transferNotification(t,r,a,o,i,c,l){return u.apply(this,arguments)})},{key:"noNeedToPay",value:function noNeedToPay(t,r,a){return 0==a||"loot"==getProperty(t.system,"merchant.merchantType")||"loot"==getProperty(r.system,"merchant.merchantType")}},{key:"updateSourceTransaction",value:(c=merchantmixin_asyncToGenerator(merchantmixin_regeneratorRuntime().mark((function _callee25(t,r,a,o,i,c){var u;return merchantmixin_regeneratorRuntime().wrap((function _callee25$(l){for(;;)switch(l.prev=l.next){case 0:if(u=duplicate(a),!(Number(u.system.quantity.value)>c||"money"==u.type)){l.next=7;break}return u.system.quantity.value=Number(u.system.quantity.value)-c,l.next=5,t.updateEmbeddedDocuments("Item",[u]);case 5:l.next=9;break;case 7:return l.next=9,t.deleteEmbeddedDocuments("Item",[i]);case 9:if(this.noNeedToPay(t,r,o)){l.next=12;break}return l.next=12,w.getMoney(t,o,!0);case 12:case"end":return l.stop()}}),_callee25,this)}))),function updateSourceTransaction(t,r,a,o,i,u){return c.apply(this,arguments)})},{key:"updateTargetTransaction",value:(i=merchantmixin_asyncToGenerator(merchantmixin_regeneratorRuntime().mark((function _callee26(r,a,i,c,u){var l,p,d;return merchantmixin_regeneratorRuntime().wrap((function _callee26$(h){for(;;)switch(h.prev=h.next){case 0:if(l=duplicate(a),"service"!=getProperty(l,"system.equipmentType.value")){h.next=7;break}p=game.i18n.format("MERCHANT.buyNotification",{item:l.name,amount:i,source:r.name,target:c.name,price:u}),ChatMessage.create(t.Z.chatDataSetup(p)),h.next=16;break;case 7:if(d=r.items.find((function(t){return o.Z.areEquals(l,t)})),l.system.quantity.value=i,d){h.next=14;break}return h.next=12,r.createEmbeddedDocuments("Item",[l]);case 12:h.next=16;break;case 14:return h.next=16,o.Z.stackItems(d,l,r);case 16:case"end":return h.stop()}}),_callee26)}))),function updateTargetTransaction(t,r,a,o,c){return i.apply(this,arguments)})}]),_class}(a)},ke=function(t){merchantmixin_inherits(SelectTradefriendDialog,Dialog);var r,a=merchantmixin_createSuper(SelectTradefriendDialog);function SelectTradefriendDialog(){return merchantmixin_classCallCheck(this,SelectTradefriendDialog),a.apply(this,arguments)}return merchantmixin_createClass(SelectTradefriendDialog,[{key:"activateListeners",value:function activateListeners(t){var r=this;merchantmixin_get(merchantmixin_getPrototypeOf(SelectTradefriendDialog.prototype),"activateListeners",this).call(this,t),t.find(".combatant").click((function(t){return r.setTargetToUser(t)}))}},{key:"setTargetToUser",value:function setTargetToUser(t){this.actor.setTradeFriend({_id:t.currentTarget.dataset.id}),this.close()}}],[{key:"defaultOptions",get:function get(){var t=merchantmixin_get(merchantmixin_getPrototypeOf(SelectTradefriendDialog),"defaultOptions",this);return mergeObject(t,{}),t}},{key:"getDialog",value:(r=merchantmixin_asyncToGenerator(merchantmixin_regeneratorRuntime().mark((function _callee27(t){var r,a;return merchantmixin_regeneratorRuntime().wrap((function _callee27$(o){for(;;)switch(o.prev=o.next){case 0:if(!game.user.isGM){o.next=6;break}return o.next=3,game.dsa5.apps.gameMasterMenu.getTrackedHeros();case 3:o.t0=o.sent,o.next=7;break;case 6:o.t0=game.actors.filter((function(t){return t.isOwner}));case 7:return r=o.t0,o.t1=SelectTradefriendDialog,o.t2=game.i18n.localize("DIALOG.setTargetToUser"),o.next=12,renderTemplate("systems/dsa5/templates/dialog/selectTradeFriend.html",{users:r});case 12:return o.t3=o.sent,o.t4={},o.t5={title:o.t2,content:o.t3,default:"yes",buttons:o.t4},(a=new o.t1(o.t5)).actor=t,o.abrupt("return",a);case 18:case"end":return o.stop()}}),_callee27)}))),function getDialog(t){return r.apply(this,arguments)})}]),SelectTradefriendDialog}();function merchant_sheet_typeof(t){return merchant_sheet_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},merchant_sheet_typeof(t)}function merchant_sheet_defineProperties(t,r){for(var a=0;a=0;--o){var i=this.tryEntries[o],c=i.completion;if("root"===i.tryLoc)return handle("end");if(i.tryLoc<=this.prev){var u=a.call(i,"catchLoc"),l=a.call(i,"finallyLoc");if(u&&l){if(this.prev=0;--o){var i=this.tryEntries[o];if(i.tryLoc<=this.prev&&a.call(i,"finallyLoc")&&this.prev=0;--r){var a=this.tryEntries[r];if(a.finallyLoc===t)return this.complete(a.completion,a.afterLoc),resetTryEntry(a),l}},catch:function _catch(t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc===t){var o=a.completion;if("throw"===o.type){var i=o.arg;resetTryEntry(a)}return i}}throw new Error("illegal catch attempt")},delegateYield:function delegateYield(t,r,a){return this.delegate={iterator:values(t),resultName:r,nextLoc:a},"next"===this.method&&(this.arg=void 0),l}},t}function player_menu_subapps_asyncGeneratorStep(t,r,a,o,i,c,u){try{var l=t[c](u),p=l.value}catch(t){return void a(t)}l.done?r(p):Promise.resolve(p).then(o,i)}function player_menu_subapps_asyncToGenerator(t){return function(){var r=this,a=arguments;return new Promise((function(o,i){var c=t.apply(r,a);function _next(t){player_menu_subapps_asyncGeneratorStep(c,o,i,_next,_throw,"next",t)}function _throw(t){player_menu_subapps_asyncGeneratorStep(c,o,i,_next,_throw,"throw",t)}_next(void 0)}))}}function player_menu_subapps_defineProperties(t,r){for(var a=0;a=0;--o){var i=this.tryEntries[o],c=i.completion;if("root"===i.tryLoc)return handle("end");if(i.tryLoc<=this.prev){var u=a.call(i,"catchLoc"),l=a.call(i,"finallyLoc");if(u&&l){if(this.prev=0;--o){var i=this.tryEntries[o];if(i.tryLoc<=this.prev&&a.call(i,"finallyLoc")&&this.prev=0;--r){var a=this.tryEntries[r];if(a.finallyLoc===t)return this.complete(a.completion,a.afterLoc),resetTryEntry(a),l}},catch:function _catch(t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc===t){var o=a.completion;if("throw"===o.type){var i=o.arg;resetTryEntry(a)}return i}}throw new Error("illegal catch attempt")},delegateYield:function delegateYield(t,r,a){return this.delegate={iterator:values(t),resultName:r,nextLoc:a},"next"===this.method&&(this.arg=void 0),l}},t}function player_menu_createForOfIteratorHelper(t,r){var a="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!a){if(Array.isArray(t)||(a=player_menu_unsupportedIterableToArray(t))||r&&t&&"number"==typeof t.length){a&&(t=a);var o=0,i=function F(){};return{s:i,n:function n(){return o>=t.length?{done:!0}:{done:!1,value:t[o++]}},e:function e(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var c,u=!0,l=!1;return{s:function s(){a=a.call(t)},n:function n(){var t=a.next();return u=t.done,t},e:function e(t){l=!0,c=t},f:function f(){try{u||null==a.return||a.return()}finally{if(l)throw c}}}}function player_menu_unsupportedIterableToArray(t,r){if(t){if("string"==typeof t)return player_menu_arrayLikeToArray(t,r);var a=Object.prototype.toString.call(t).slice(8,-1);return"Object"===a&&t.constructor&&(a=t.constructor.name),"Map"===a||"Set"===a?Array.from(t):"Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a)?player_menu_arrayLikeToArray(t,r):void 0}}function player_menu_arrayLikeToArray(t,r){(null==r||r>t.length)&&(r=t.length);for(var a=0,o=new Array(r);a
    '),a.next=3,game.dsa5.itemLibrary.buildEquipmentIndex();case 3:r.render();case 4:case"end":return a.stop()}}),_callee3)})));return function(r){return t.apply(this,arguments)}}()),t.find(".item-edit").click((function(t){var a=$(t.currentTarget).closest(".item").attr("data-item-id");r.actor.items.get(a).sheet.render(!0)})),t.find(".selectableRow").click((function(t){return r.selectImprovement(t)})),t.find(".finalizeConjuration").click((function(){return r.finalizeConjuration()})),t.find(".ruleLink").click((function(t){return r.openRules(t)})),t.find(".openChar").click((function(){var t;null===(t=r.actor)||void 0===t||t.sheet.render(!0)})),t.find(".showEntity").click((function(t){t.stopPropagation();var r=function(){var r=player_menu_asyncToGenerator(player_menu_regeneratorRuntime().mark((function _callee4(){return player_menu_regeneratorRuntime().wrap((function _callee4$(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,fromUuid(t.currentTarget.dataset.uuid);case 2:r.sent.sheet.render(!0);case 3:case"end":return r.stop()}}),_callee4)})));return function fun(){return r.apply(this,arguments)}}();r()})),t.find(".moreModifiers").change((function(t){r.conjurationData.moreModifiers[r.conjurationData.conjurationType].find((function(r){return r.name==t.currentTarget.dataset.name})).selected=$(t.currentTarget).val()}));var a,o=player_menu_createForOfIteratorHelper(this.subApps);try{for(o.s();!(a=o.n()).done;){a.value.activateListeners(t)}}catch(t){o.e(t)}finally{o.f()}}},{key:"openRules",value:(c=player_menu_asyncToGenerator(player_menu_regeneratorRuntime().mark((function _callee6(t){var r,a,o;return player_menu_regeneratorRuntime().wrap((function _callee6$(i){for(;;)switch(i.prev=i.next){case 0:r=t.currentTarget.dataset.subapp,a=(r?this.subApps.find((function(t){return t.constructor.name==r})).constructor.rulePath:this.conjurationData.rules[this.conjurationData.conjurationType])[game.i18n.lang],o=function(){var t=player_menu_asyncToGenerator(player_menu_regeneratorRuntime().mark((function _callee5(){var t,r,o,i;return player_menu_regeneratorRuntime().wrap((function _callee5$(c){for(;;)switch(c.prev=c.next){case 0:return t=game.packs.get(a.pack),c.next=3,t.getDocuments({name:a.name});case 3:r=c.sent,o=player_menu_createForOfIteratorHelper(r);try{for(o.s();!(i=o.n()).done;)i.value.sheet.render(!0)}catch(t){o.e(t)}finally{o.f()}case 6:case"end":return c.stop()}}),_callee5)})));return function fun(){return t.apply(this,arguments)}}(),o();case 4:case"end":return i.stop()}}),_callee6,this)}))),function openRules(t){return c.apply(this,arguments)})},{key:"finalizeConjuration",value:function finalizeConjuration(){var t=this;if(this.conjurationData){if(!this.conjuration)return ui.notifications.warn(game.i18n.localize("DSAError.noConjurationActive"));var r,a=[],o=player_menu_createForOfIteratorHelper(this.conjurationData.selectedIds);try{var i=function _loop(){var o=r.value;a.push(t.conjurationData.modifiers[t.conjurationData.conjurationType].find((function(t){return t.id==o})))};for(o.s();!(r=o.n()).done;)i()}catch(t){o.e(t)}finally{o.f()}var c={source:this.conjuration.toObject(),creationData:{type:this.conjurationData.conjurationType,typeName:this.conjurationData.conjurationTypes[this.conjurationData.conjurationType],qs:this.conjurationData.qs,consumedQS:this.conjurationData.consumedQS,modifiers:a,entityIds:this.conjurationData.selectedEntityIds,packageIds:this.conjurationData.selectedPackageIds},summoner:{name:this.actor.name,img:this.actor.img}};game.user.isGM?PlayerMenu.createConjuration(c):(game.socket.emit("system.dsa5",{type:"summonCreature",payload:c}),ui.notifications.notify(game.i18n.localize("CONJURATION.requestSend")))}}},{key:"selectImprovement",value:function selectImprovement(t){var r=Number(t.currentTarget.dataset.max)||1,a=Number(t.currentTarget.dataset.selected)||0;a>=r?$(t.currentTarget).removeClass("selected"):($(t.currentTarget).addClass("selected"),t.currentTarget.dataset.selected=a+1);var o=[],i=[],c=[],u=0,l=0;$(this._element).find(".selectableRow.selected").each((function(t,r){for(var a=0;a0)){d.next=37;break}if(this.conjuration=a,this.conjurationData.selectedIds=[],this.conjurationData.selectedEntityIds=[],this.conjurationData.selectedPackageIds=[],"creature"!=a.type){d.next=35;break}o=0,i=Object.keys(this.conjurationData.conjurationTypes);case 27:if(!(o1&&(r.system.step={value:l[t.uuid]}),r})),S.next=18,Promise.all(this.creationData.packageIds.map((function(t){return fromUuid(t)})));case 18:if(h=S.sent.map((function(t){return t.toObject(!1)})),this.conjuration.effects.push({changes:[],duration:{},icon:"icons/svg/aura.svg",id:"services",name:game.i18n.localize("PLAYER.services"),flags:{dsa5:{value:o,editable:!0,max:500,description:"".concat(game.i18n.localize("PLAYER.conjuration")," ").concat(game.i18n.localize("PLAYER.services")),manual:o,auto:0,hideOnToken:!0,hidePlayers:!1}}}),!game.dsa5.apps.playerMenu.conjurationData.postFunction[this.creationData.type]){S.next=23;break}return S.next=23,game.dsa5.apps.playerMenu.conjurationData.postFunction[this.creationData.type](this.conjuration,this.creationData.qs-this.creationData.consumedQS,this.creationData.type);case 23:return"creature"!=this.conjuration.type||this.conjuration.system.creatureClass.value.includes(this.creationData.typeName)||(this.conjuration.system.creatureClass.value+=", ".concat(this.creationData.typeName)),S.next=26,d.Z.create(this.conjuration);case 26:return this.actor=S.sent,m=[].concat(player_menu_toConsumableArray(p),player_menu_toConsumableArray(h)).filter((function(t){return!x.conjuration.items.find((function(r){return r.type==t.type&&t.name==r.name}))})),S.next=30,this.actor.createEmbeddedDocuments("Item",m);case 30:y=player_menu_createForOfIteratorHelper(h),S.prev=31,y.s();case 33:if((g=y.n()).done){S.next=39;break}return v=g.value,S.next=37,R.Z.traitAdded(this.actor,v);case 37:S.next=33;break;case 39:S.next=44;break;case 41:S.prev=41,S.t0=S.catch(31),y.e(S.t0);case 44:return S.prev=44,y.f(),S.finish(44);case 47:_=player_menu_createForOfIteratorHelper(p),S.prev=48,_.s();case 50:if((b=_.n()).done){S.next=56;break}return k=b.value,S.next=54,R.Z.traitAdded(this.actor,k);case 54:S.next=50;break;case 56:S.next=61;break;case 58:S.prev=58,S.t1=S.catch(48),_.e(S.t1);case 61:return S.prev=61,_.f(),S.finish(61);case 64:return S.next=66,this.actor.update({"system.status.wounds.value":this.actor.system.status.wounds.max});case 66:return S.next=68,renderTemplate("systems/dsa5/templates/system/conjuration/chat.html",{actor:this.actor,modifiers:this.creationData.modifiers,summoner:this.summoner,summonerImg:N.Z.videoOrImgTag(this.summoner.img),conjureImg:N.Z.videoOrImgTag(this.actor.img),services:o});case 68:return w=S.sent,S.next=71,ChatMessage.create(t.Z.chatDataSetup(w));case 71:this.render();case 72:case"end":return S.stop()}}),_callee13,this,[[31,41,44,47],[48,58,61,64]])}))),function createActor(){return a.apply(this,arguments)})},{key:"activateListeners",value:function activateListeners(t){var r=this;player_menu_get(player_menu_getPrototypeOf(ConjurationRequest.prototype),"activateListeners",this).call(this,t),t.find(".createActor").click((function(){r.createActor()})),t.on("mousedown",".newNPC",function(){var t=player_menu_asyncToGenerator(player_menu_regeneratorRuntime().mark((function _callee14(t){var r;return player_menu_regeneratorRuntime().wrap((function _callee14$(a){for(;;)switch(a.prev=a.next){case 0:r=t.currentTarget.dataset.id,2==t.button&&(game.actors.get(r).delete(),$(t.currentTarget).remove());case 2:case"end":return a.stop()}}),_callee14)})));return function(r){return t.apply(this,arguments)}}()),t.on("click",".newNPC",function(){var t=player_menu_asyncToGenerator(player_menu_regeneratorRuntime().mark((function _callee15(t){var r;return player_menu_regeneratorRuntime().wrap((function _callee15$(a){for(;;)switch(a.prev=a.next){case 0:r=t.currentTarget.dataset.id,game.actors.get(r).sheet.render(!0);case 2:case"end":return a.stop()}}),_callee15)})));return function(r){return t.apply(this,arguments)}}()),t.on("dragstart",".newNPC",(function(t){t.stopPropagation();var r={type:"Actor",uuid:t.currentTarget.dataset.uuid};t.originalEvent.dataTransfer.setData("text/plain",JSON.stringify(r))})),t.find(".showEntity").click((function(t){t.stopPropagation();var r=function(){var r=player_menu_asyncToGenerator(player_menu_regeneratorRuntime().mark((function _callee16(){return player_menu_regeneratorRuntime().wrap((function _callee16$(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,fromUuid(t.currentTarget.dataset.uuid);case 2:r.sent.sheet.render(!0);case 3:case"end":return r.stop()}}),_callee16)})));return function fun(){return r.apply(this,arguments)}}();r()}))}}],[{key:"defaultOptions",get:function get(){var t=player_menu_get(player_menu_getPrototypeOf(ConjurationRequest),"defaultOptions",this);return t.tabs=[{navSelector:".tabs",contentSelector:".content",initial:"main"}],mergeObject(t,{classes:t.classes.concat(["dsa5","largeDialog"]),width:470}),t.template="systems/dsa5/templates/system/conjuration/request.html",t}}]),ConjurationRequest}(xe.Z),Oe=__webpack_require__(903);function itemDrop_typeof(t){return itemDrop_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},itemDrop_typeof(t)}function itemDrop_classCallCheck(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}function itemDrop_defineProperties(t,r){for(var a=0;a=t.length?{done:!0}:{done:!1,value:t[o++]}},e:function e(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var c,u=!0,l=!1;return{s:function s(){a=a.call(t)},n:function n(){var t=a.next();return u=t.done,t},e:function e(t){l=!0,c=t},f:function f(){try{u||null==a.return||a.return()}finally{if(l)throw c}}}}function itemDrop_regeneratorRuntime(){itemDrop_regeneratorRuntime=function _regeneratorRuntime(){return t};var t={},r=Object.prototype,a=r.hasOwnProperty,o="function"==typeof Symbol?Symbol:{},i=o.iterator||"@@iterator",c=o.asyncIterator||"@@asyncIterator",u=o.toStringTag||"@@toStringTag";function define(t,r,a){return Object.defineProperty(t,r,{value:a,enumerable:!0,configurable:!0,writable:!0}),t[r]}try{define({},"")}catch(t){define=function define(t,r,a){return t[r]=a}}function wrap(t,r,a,o){var i=r&&r.prototype instanceof Generator?r:Generator,c=Object.create(i.prototype),u=new Context(o||[]);return c._invoke=function(t,r,a){var o="suspendedStart";return function(i,c){if("executing"===o)throw new Error("Generator is already running");if("completed"===o){if("throw"===i)throw c;return doneResult()}for(a.method=i,a.arg=c;;){var u=a.delegate;if(u){var p=maybeInvokeDelegate(u,a);if(p){if(p===l)continue;return p}}if("next"===a.method)a.sent=a._sent=a.arg;else if("throw"===a.method){if("suspendedStart"===o)throw o="completed",a.arg;a.dispatchException(a.arg)}else"return"===a.method&&a.abrupt("return",a.arg);o="executing";var d=tryCatch(t,r,a);if("normal"===d.type){if(o=a.done?"completed":"suspendedYield",d.arg===l)continue;return{value:d.arg,done:a.done}}"throw"===d.type&&(o="completed",a.method="throw",a.arg=d.arg)}}}(t,a,u),c}function tryCatch(t,r,a){try{return{type:"normal",arg:t.call(r,a)}}catch(t){return{type:"throw",arg:t}}}t.wrap=wrap;var l={};function Generator(){}function GeneratorFunction(){}function GeneratorFunctionPrototype(){}var p={};define(p,i,(function(){return this}));var d=Object.getPrototypeOf,h=d&&d(d(values([])));h&&h!==r&&a.call(h,i)&&(p=h);var m=GeneratorFunctionPrototype.prototype=Generator.prototype=Object.create(p);function defineIteratorMethods(t){["next","throw","return"].forEach((function(r){define(t,r,(function(t){return this._invoke(r,t)}))}))}function AsyncIterator(t,r){function invoke(o,i,c,u){var l=tryCatch(t[o],t,i);if("throw"!==l.type){var p=l.arg,d=p.value;return d&&"object"==itemDrop_typeof(d)&&a.call(d,"__await")?r.resolve(d.__await).then((function(t){invoke("next",t,c,u)}),(function(t){invoke("throw",t,c,u)})):r.resolve(d).then((function(t){p.value=t,c(p)}),(function(t){return invoke("throw",t,c,u)}))}u(l.arg)}var o;this._invoke=function(t,a){function callInvokeWithMethodAndArg(){return new r((function(r,o){invoke(t,a,r,o)}))}return o=o?o.then(callInvokeWithMethodAndArg,callInvokeWithMethodAndArg):callInvokeWithMethodAndArg()}}function maybeInvokeDelegate(t,r){var a=t.iterator[r.method];if(void 0===a){if(r.delegate=null,"throw"===r.method){if(t.iterator.return&&(r.method="return",r.arg=void 0,maybeInvokeDelegate(t,r),"throw"===r.method))return l;r.method="throw",r.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var o=tryCatch(a,t.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,l;var i=o.arg;return i?i.done?(r[t.resultName]=i.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=void 0),r.delegate=null,l):i:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,l)}function pushTryEntry(t){var r={tryLoc:t[0]};1 in t&&(r.catchLoc=t[1]),2 in t&&(r.finallyLoc=t[2],r.afterLoc=t[3]),this.tryEntries.push(r)}function resetTryEntry(t){var r=t.completion||{};r.type="normal",delete r.arg,t.completion=r}function Context(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(pushTryEntry,this),this.reset(!0)}function values(t){if(t){var r=t[i];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var o=-1,c=function next(){for(;++o=0;--o){var i=this.tryEntries[o],c=i.completion;if("root"===i.tryLoc)return handle("end");if(i.tryLoc<=this.prev){var u=a.call(i,"catchLoc"),l=a.call(i,"finallyLoc");if(u&&l){if(this.prev=0;--o){var i=this.tryEntries[o];if(i.tryLoc<=this.prev&&a.call(i,"finallyLoc")&&this.prev=0;--r){var a=this.tryEntries[r];if(a.finallyLoc===t)return this.complete(a.completion,a.afterLoc),resetTryEntry(a),l}},catch:function _catch(t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc===t){var o=a.completion;if("throw"===o.type){var i=o.arg;resetTryEntry(a)}return i}}throw new Error("illegal catch attempt")},delegateYield:function delegateYield(t,r,a){return this.delegate={iterator:values(t),resultName:r,nextLoc:a},"next"===this.method&&(this.arg=void 0),l}},t}function itemDrop_toConsumableArray(t){return function itemDrop_arrayWithoutHoles(t){if(Array.isArray(t))return itemDrop_arrayLikeToArray(t)}(t)||function itemDrop_iterableToArray(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||itemDrop_unsupportedIterableToArray(t)||function itemDrop_nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function itemDrop_unsupportedIterableToArray(t,r){if(t){if("string"==typeof t)return itemDrop_arrayLikeToArray(t,r);var a=Object.prototype.toString.call(t).slice(8,-1);return"Object"===a&&t.constructor&&(a=t.constructor.name),"Map"===a||"Set"===a?Array.from(t):"Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a)?itemDrop_arrayLikeToArray(t,r):void 0}}function itemDrop_arrayLikeToArray(t,r){(null==r||r>t.length)&&(r=t.length);for(var a=0,o=new Array(r);a
    ',label:game.i18n.localize("yes"),callback:function(){var t=itemDrop_asyncToGenerator(itemDrop_regeneratorRuntime().mark((function _callee2(t){return itemDrop_regeneratorRuntime().wrap((function _callee2$(r){for(;;)switch(r.prev=r.next){case 0:return r.abrupt("return",Pe(i,o,a,Number(t.find('[name="count"]').val())));case 1:case"end":return r.stop()}}),_callee2)})));return function callback(r){return t.apply(this,arguments)}}()},cancel:{icon:'',label:game.i18n.localize("cancel")}}}).render(!0);case 10:case"end":return t.stop()}}),_callee3)})));return function handleItemDrop(r,a){return t.apply(this,arguments)}}(),Ce=function(){var t=itemDrop_asyncToGenerator(itemDrop_regeneratorRuntime().mark((function _callee4(t,r){var a,o,i,c,u,l,p,d,h,m;return itemDrop_regeneratorRuntime().wrap((function _callee4$(y){for(;;)switch(y.prev=y.next){case 0:a=r.x,o=r.y,i=0,c=t.grid.size,u=Math.ceil(Math.sqrt(r.ids.length)),l=itemDrop_createForOfIteratorHelper(r.ids),y.prev=6,l.s();case 8:if((p=l.n()).done){y.next=21;break}if(d=p.value,h=game.actors.get(d)){y.next=13;break}return y.abrupt("continue",19);case 13:return y.next=15,h.getTokenDocument({x:a,y:o,hidden:!1});case 15:(m=y.sent).constructor.create(m,{parent:t.scene}),u%i==0&&i>0?(o+=c,a=r.x):a+=c,i++;case 19:y.next=8;break;case 21:y.next=26;break;case 23:y.prev=23,y.t0=y.catch(6),l.e(y.t0);case 26:return y.prev=26,l.f(),y.finish(26);case 29:case"end":return y.stop()}}),_callee4,null,[[6,23,26,29]])})));return function handleGroupDrop(r,a){return t.apply(this,arguments)}}(),De=function connectHook(){Hooks.on("dropCanvasData",function(){var t=itemDrop_asyncToGenerator(itemDrop_regeneratorRuntime().mark((function _callee5(t,r){return itemDrop_regeneratorRuntime().wrap((function _callee5$(a){for(;;)switch(a.prev=a.next){case 0:if(game.settings.get("dsa5","enableItemDropToCanvas")||game.user.isGM||r.tokenId){a.next=2;break}return a.abrupt("return");case 2:if("Item"!=r.type){a.next=7;break}return Ee(t,r),a.abrupt("return",!1);case 7:if("GroupDrop"!=r.type){a.next=10;break}return Ce(t,r),a.abrupt("return",!1);case 10:case"end":return a.stop()}}),_callee5)})));return function(r,a){return t.apply(this,arguments)}}())},Ie=function(t){!function itemDrop_inherits(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(r&&r.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),r&&itemDrop_setPrototypeOf(t,r)}(DropToGroundDialog,Dialog);var r=itemDrop_createSuper(DropToGroundDialog);function DropToGroundDialog(){return itemDrop_classCallCheck(this,DropToGroundDialog),r.apply(this,arguments)}return function itemDrop_createClass(t,r,a){return r&&itemDrop_defineProperties(t.prototype,r),a&&itemDrop_defineProperties(t,a),Object.defineProperty(t,"prototype",{writable:!1}),t}(DropToGroundDialog,[{key:"activateListeners",value:function activateListeners(t){itemDrop_get(itemDrop_getPrototypeOf(DropToGroundDialog.prototype),"activateListeners",this).call(this,t),t.find('input[type="range"]').change((function(t){$(t.currentTarget).closest(".row-section").find(".range-value").html($(t.currentTarget).val())}))}}]),DropToGroundDialog}(),Re=__webpack_require__(846);function didyouknow_typeof(t){return didyouknow_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},didyouknow_typeof(t)}function didyouknow_regeneratorRuntime(){didyouknow_regeneratorRuntime=function _regeneratorRuntime(){return t};var t={},r=Object.prototype,a=r.hasOwnProperty,o="function"==typeof Symbol?Symbol:{},i=o.iterator||"@@iterator",c=o.asyncIterator||"@@asyncIterator",u=o.toStringTag||"@@toStringTag";function define(t,r,a){return Object.defineProperty(t,r,{value:a,enumerable:!0,configurable:!0,writable:!0}),t[r]}try{define({},"")}catch(t){define=function define(t,r,a){return t[r]=a}}function wrap(t,r,a,o){var i=r&&r.prototype instanceof Generator?r:Generator,c=Object.create(i.prototype),u=new Context(o||[]);return c._invoke=function(t,r,a){var o="suspendedStart";return function(i,c){if("executing"===o)throw new Error("Generator is already running");if("completed"===o){if("throw"===i)throw c;return doneResult()}for(a.method=i,a.arg=c;;){var u=a.delegate;if(u){var p=maybeInvokeDelegate(u,a);if(p){if(p===l)continue;return p}}if("next"===a.method)a.sent=a._sent=a.arg;else if("throw"===a.method){if("suspendedStart"===o)throw o="completed",a.arg;a.dispatchException(a.arg)}else"return"===a.method&&a.abrupt("return",a.arg);o="executing";var d=tryCatch(t,r,a);if("normal"===d.type){if(o=a.done?"completed":"suspendedYield",d.arg===l)continue;return{value:d.arg,done:a.done}}"throw"===d.type&&(o="completed",a.method="throw",a.arg=d.arg)}}}(t,a,u),c}function tryCatch(t,r,a){try{return{type:"normal",arg:t.call(r,a)}}catch(t){return{type:"throw",arg:t}}}t.wrap=wrap;var l={};function Generator(){}function GeneratorFunction(){}function GeneratorFunctionPrototype(){}var p={};define(p,i,(function(){return this}));var d=Object.getPrototypeOf,h=d&&d(d(values([])));h&&h!==r&&a.call(h,i)&&(p=h);var m=GeneratorFunctionPrototype.prototype=Generator.prototype=Object.create(p);function defineIteratorMethods(t){["next","throw","return"].forEach((function(r){define(t,r,(function(t){return this._invoke(r,t)}))}))}function AsyncIterator(t,r){function invoke(o,i,c,u){var l=tryCatch(t[o],t,i);if("throw"!==l.type){var p=l.arg,d=p.value;return d&&"object"==didyouknow_typeof(d)&&a.call(d,"__await")?r.resolve(d.__await).then((function(t){invoke("next",t,c,u)}),(function(t){invoke("throw",t,c,u)})):r.resolve(d).then((function(t){p.value=t,c(p)}),(function(t){return invoke("throw",t,c,u)}))}u(l.arg)}var o;this._invoke=function(t,a){function callInvokeWithMethodAndArg(){return new r((function(r,o){invoke(t,a,r,o)}))}return o=o?o.then(callInvokeWithMethodAndArg,callInvokeWithMethodAndArg):callInvokeWithMethodAndArg()}}function maybeInvokeDelegate(t,r){var a=t.iterator[r.method];if(void 0===a){if(r.delegate=null,"throw"===r.method){if(t.iterator.return&&(r.method="return",r.arg=void 0,maybeInvokeDelegate(t,r),"throw"===r.method))return l;r.method="throw",r.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var o=tryCatch(a,t.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,l;var i=o.arg;return i?i.done?(r[t.resultName]=i.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=void 0),r.delegate=null,l):i:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,l)}function pushTryEntry(t){var r={tryLoc:t[0]};1 in t&&(r.catchLoc=t[1]),2 in t&&(r.finallyLoc=t[2],r.afterLoc=t[3]),this.tryEntries.push(r)}function resetTryEntry(t){var r=t.completion||{};r.type="normal",delete r.arg,t.completion=r}function Context(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(pushTryEntry,this),this.reset(!0)}function values(t){if(t){var r=t[i];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var o=-1,c=function next(){for(;++o=0;--o){var i=this.tryEntries[o],c=i.completion;if("root"===i.tryLoc)return handle("end");if(i.tryLoc<=this.prev){var u=a.call(i,"catchLoc"),l=a.call(i,"finallyLoc");if(u&&l){if(this.prev=0;--o){var i=this.tryEntries[o];if(i.tryLoc<=this.prev&&a.call(i,"finallyLoc")&&this.prev=0;--r){var a=this.tryEntries[r];if(a.finallyLoc===t)return this.complete(a.completion,a.afterLoc),resetTryEntry(a),l}},catch:function _catch(t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc===t){var o=a.completion;if("throw"===o.type){var i=o.arg;resetTryEntry(a)}return i}}throw new Error("illegal catch attempt")},delegateYield:function delegateYield(t,r,a){return this.delegate={iterator:values(t),resultName:r,nextLoc:a},"next"===this.method&&(this.arg=void 0),l}},t}function didyouknow_asyncGeneratorStep(t,r,a,o,i,c,u){try{var l=t[c](u),p=l.value}catch(t){return void a(t)}l.done?r(p):Promise.resolve(p).then(o,i)}function didyouknow_asyncToGenerator(t){return function(){var r=this,a=arguments;return new Promise((function(o,i){var c=t.apply(r,a);function _next(t){didyouknow_asyncGeneratorStep(c,o,i,_next,_throw,"next",t)}function _throw(t){didyouknow_asyncGeneratorStep(c,o,i,_next,_throw,"throw",t)}_next(void 0)}))}}function didyouknow_defineProperties(t,r){for(var a=0;a0&&void 0!==a[0]?a[0]:8e3,!game.settings.get("dsa5","disableDidYouKnow")){o.next=3;break}return o.abrupt("return");case 3:fetch("systems/dsa5/lazy/didyouknow/".concat(game.i18n.lang,".json")).then(function(){var t=didyouknow_asyncToGenerator(didyouknow_regeneratorRuntime().mark((function _callee5(t){return didyouknow_regeneratorRuntime().wrap((function _callee5$(r){for(;;)switch(r.prev=r.next){case 0:return r.abrupt("return",t.json());case 1:case"end":return r.stop()}}),_callee5)})));return function(r){return t.apply(this,arguments)}}()).then(function(){var a=didyouknow_asyncToGenerator(didyouknow_regeneratorRuntime().mark((function _callee6(a){var o,i;return didyouknow_regeneratorRuntime().wrap((function _callee6$(c){for(;;)switch(c.prev=c.next){case 0:return o=a.data[Math.floor(Math.random()*a.data.length)],c.next=3,renderTemplate("systems/dsa5/templates/system/didyouknow.html",{msg:o,fadeOut:DidYouKnow.fadeOut});case 3:i=c.sent,$("body").append(i),r.activateListeners(),setTimeout((function(){DidYouKnow.fadeOut&&$(".didYouKnow").fadeOut(1e3,(function(){return $(".didYouKnow").remove()}))}),t);case 7:case"end":return c.stop()}}),_callee6)})));return function(t){return a.apply(this,arguments)}}());case 4:case"end":return o.stop()}}),_callee7)}))),function showOneMessage(){return t.apply(this,arguments)})}]),DidYouKnow}();function combat_tracker_typeof(t){return combat_tracker_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},combat_tracker_typeof(t)}function combat_tracker_toConsumableArray(t){return function combat_tracker_arrayWithoutHoles(t){if(Array.isArray(t))return combat_tracker_arrayLikeToArray(t)}(t)||function combat_tracker_iterableToArray(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||combat_tracker_unsupportedIterableToArray(t)||function combat_tracker_nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function combat_tracker_regeneratorRuntime(){combat_tracker_regeneratorRuntime=function _regeneratorRuntime(){return t};var t={},r=Object.prototype,a=r.hasOwnProperty,o="function"==typeof Symbol?Symbol:{},i=o.iterator||"@@iterator",c=o.asyncIterator||"@@asyncIterator",u=o.toStringTag||"@@toStringTag";function define(t,r,a){return Object.defineProperty(t,r,{value:a,enumerable:!0,configurable:!0,writable:!0}),t[r]}try{define({},"")}catch(t){define=function define(t,r,a){return t[r]=a}}function wrap(t,r,a,o){var i=r&&r.prototype instanceof Generator?r:Generator,c=Object.create(i.prototype),u=new Context(o||[]);return c._invoke=function(t,r,a){var o="suspendedStart";return function(i,c){if("executing"===o)throw new Error("Generator is already running");if("completed"===o){if("throw"===i)throw c;return doneResult()}for(a.method=i,a.arg=c;;){var u=a.delegate;if(u){var p=maybeInvokeDelegate(u,a);if(p){if(p===l)continue;return p}}if("next"===a.method)a.sent=a._sent=a.arg;else if("throw"===a.method){if("suspendedStart"===o)throw o="completed",a.arg;a.dispatchException(a.arg)}else"return"===a.method&&a.abrupt("return",a.arg);o="executing";var d=tryCatch(t,r,a);if("normal"===d.type){if(o=a.done?"completed":"suspendedYield",d.arg===l)continue;return{value:d.arg,done:a.done}}"throw"===d.type&&(o="completed",a.method="throw",a.arg=d.arg)}}}(t,a,u),c}function tryCatch(t,r,a){try{return{type:"normal",arg:t.call(r,a)}}catch(t){return{type:"throw",arg:t}}}t.wrap=wrap;var l={};function Generator(){}function GeneratorFunction(){}function GeneratorFunctionPrototype(){}var p={};define(p,i,(function(){return this}));var d=Object.getPrototypeOf,h=d&&d(d(values([])));h&&h!==r&&a.call(h,i)&&(p=h);var m=GeneratorFunctionPrototype.prototype=Generator.prototype=Object.create(p);function defineIteratorMethods(t){["next","throw","return"].forEach((function(r){define(t,r,(function(t){return this._invoke(r,t)}))}))}function AsyncIterator(t,r){function invoke(o,i,c,u){var l=tryCatch(t[o],t,i);if("throw"!==l.type){var p=l.arg,d=p.value;return d&&"object"==combat_tracker_typeof(d)&&a.call(d,"__await")?r.resolve(d.__await).then((function(t){invoke("next",t,c,u)}),(function(t){invoke("throw",t,c,u)})):r.resolve(d).then((function(t){p.value=t,c(p)}),(function(t){return invoke("throw",t,c,u)}))}u(l.arg)}var o;this._invoke=function(t,a){function callInvokeWithMethodAndArg(){return new r((function(r,o){invoke(t,a,r,o)}))}return o=o?o.then(callInvokeWithMethodAndArg,callInvokeWithMethodAndArg):callInvokeWithMethodAndArg()}}function maybeInvokeDelegate(t,r){var a=t.iterator[r.method];if(void 0===a){if(r.delegate=null,"throw"===r.method){if(t.iterator.return&&(r.method="return",r.arg=void 0,maybeInvokeDelegate(t,r),"throw"===r.method))return l;r.method="throw",r.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var o=tryCatch(a,t.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,l;var i=o.arg;return i?i.done?(r[t.resultName]=i.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=void 0),r.delegate=null,l):i:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,l)}function pushTryEntry(t){var r={tryLoc:t[0]};1 in t&&(r.catchLoc=t[1]),2 in t&&(r.finallyLoc=t[2],r.afterLoc=t[3]),this.tryEntries.push(r)}function resetTryEntry(t){var r=t.completion||{};r.type="normal",delete r.arg,t.completion=r}function Context(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(pushTryEntry,this),this.reset(!0)}function values(t){if(t){var r=t[i];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var o=-1,c=function next(){for(;++o=0;--o){var i=this.tryEntries[o],c=i.completion;if("root"===i.tryLoc)return handle("end");if(i.tryLoc<=this.prev){var u=a.call(i,"catchLoc"),l=a.call(i,"finallyLoc");if(u&&l){if(this.prev=0;--o){var i=this.tryEntries[o];if(i.tryLoc<=this.prev&&a.call(i,"finallyLoc")&&this.prev=0;--r){var a=this.tryEntries[r];if(a.finallyLoc===t)return this.complete(a.completion,a.afterLoc),resetTryEntry(a),l}},catch:function _catch(t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc===t){var o=a.completion;if("throw"===o.type){var i=o.arg;resetTryEntry(a)}return i}}throw new Error("illegal catch attempt")},delegateYield:function delegateYield(t,r,a){return this.delegate={iterator:values(t),resultName:r,nextLoc:a},"next"===this.method&&(this.arg=void 0),l}},t}function combat_tracker_createForOfIteratorHelper(t,r){var a="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!a){if(Array.isArray(t)||(a=combat_tracker_unsupportedIterableToArray(t))||r&&t&&"number"==typeof t.length){a&&(t=a);var o=0,i=function F(){};return{s:i,n:function n(){return o>=t.length?{done:!0}:{done:!1,value:t[o++]}},e:function e(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var c,u=!0,l=!1;return{s:function s(){a=a.call(t)},n:function n(){var t=a.next();return u=t.done,t},e:function e(t){l=!0,c=t},f:function f(){try{u||null==a.return||a.return()}finally{if(l)throw c}}}}function combat_tracker_unsupportedIterableToArray(t,r){if(t){if("string"==typeof t)return combat_tracker_arrayLikeToArray(t,r);var a=Object.prototype.toString.call(t).slice(8,-1);return"Object"===a&&t.constructor&&(a=t.constructor.name),"Map"===a||"Set"===a?Array.from(t):"Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a)?combat_tracker_arrayLikeToArray(t,r):void 0}}function combat_tracker_arrayLikeToArray(t,r){(null==r||r>t.length)&&(r=t.length);for(var a=0,o=new Array(r);a0){var h={name:p.name,remaining:d.Z.calcLZ(p,a.actor)-p.system.reloadTime.progress};h.remaining>0&&c.push(h)}else if(["spell","liturgy"].includes(p.type)&&p.system.castingTime.modified>0){var m={name:p.name,remaining:p.system.castingTime.modified-p.system.castingTime.progress};m.remaining>0&&c.push(m)}}}catch(t){l.e(t)}finally{l.f()}}(c=c.sort((function(t,r){return t.remaining-r.remaining}))).length>0&&(t.ongoings="".concat(game.i18n.localize("COMBATTRACKER.ongoing"),"
    ").concat(c.map((function(t){return"".concat(t.name," - ").concat(t.remaining)})).join("
    ")),t.ongoing=c[0].remaining),t.effects=new Set,a.token&&(a.token.effects.forEach((function(r){return t.effects.add(r)})),a.token.overlayEffect&&t.effects.add(a.token.overlayEffect)),a.actor&&a.actor.temporaryEffects.forEach((function(r){r.statuses.has(CONFIG.Combat.defeatedStatusId)?t.defeated=!0:!r.icon||!i||r.notApplicable||!game.user.isGM&&r.getFlag("dsa5","hidePlayers")||r.getFlag("dsa5","hideOnToken")||t.effects.add(r.icon)}))},a.s();!(o=a.n()).done;)i()}catch(t){a.e(t)}finally{a.f()}return c.abrupt("return",r);case 6:case"end":return c.stop()}}),_callee,this)}))),function getData(t){return r.apply(this,arguments)})}],[{key:"defaultOptions",get:function get(){return foundry.utils.mergeObject(combat_tracker_get(combat_tracker_getPrototypeOf(DSA5CombatTracker),"defaultOptions",this),{template:"/systems/dsa5/templates/system/combattracker.html"})}},{key:"runActAttackDialog",value:function runActAttackDialog(){if(game.combat){var t=game.combat.combatant;(game.user.isGM||t.isOwner)&&ve.HS.showDialog(t.actor,t.tokenId)}}}]),DSA5CombatTracker}(),Me=function(t){combat_tracker_inherits(DSA5Combat,Combat);var r,a,o,i,c=combat_tracker_createSuper(DSA5Combat);function DSA5Combat(t,r){return combat_tracker_classCallCheck(this,DSA5Combat),c.call(this,t,r)}return combat_tracker_createClass(DSA5Combat,[{key:"refreshTokenbars",value:(i=combat_tracker_asyncToGenerator(combat_tracker_regeneratorRuntime().mark((function _callee2(){return combat_tracker_regeneratorRuntime().wrap((function _callee2$(t){for(;;)switch(t.prev=t.next){case 0:game.dsa5.apps.tokenHotbar&&game.dsa5.apps.tokenHotbar.updateDSA5Hotbar();case 1:case"end":return t.stop()}}),_callee2)}))),function refreshTokenbars(){return i.apply(this,arguments)})},{key:"_onCreate",value:function _onCreate(t,r,a){combat_tracker_get(combat_tracker_getPrototypeOf(DSA5Combat.prototype),"_onCreate",this).call(this,t,r,a),this.refreshTokenbars()}},{key:"_onDelete",value:function _onDelete(t,r){combat_tracker_get(combat_tracker_getPrototypeOf(DSA5Combat.prototype),"_onDelete",this).call(this,t,r),this.refreshTokenbars()}},{key:"nextRound",value:(o=combat_tracker_asyncToGenerator(combat_tracker_regeneratorRuntime().mark((function _callee3(){var t,r,a;return combat_tracker_regeneratorRuntime().wrap((function _callee3$(o){for(;;)switch(o.prev=o.next){case 0:if(!game.user.isGM){o.next=20;break}t=combat_tracker_createForOfIteratorHelper(this.turns),o.prev=2,t.s();case 4:if((r=t.n()).done){o.next=10;break}return a=r.value,o.next=8,a.setFlag("dsa5","defenseCount",0);case 8:o.next=4;break;case 10:o.next=15;break;case 12:o.prev=12,o.t0=o.catch(2),t.e(o.t0);case 15:return o.prev=15,t.f(),o.finish(15);case 18:o.next=22;break;case 20:return o.next=22,game.socket.emit("system.dsa5",{type:"clearCombat",payload:{}});case 22:return o.next=24,combat_tracker_get(combat_tracker_getPrototypeOf(DSA5Combat.prototype),"nextRound",this).call(this);case 24:return o.abrupt("return",o.sent);case 25:case"end":return o.stop()}}),_callee3,this,[[2,12,15,18]])}))),function nextRound(){return o.apply(this,arguments)})},{key:"getDefenseCount",value:(a=combat_tracker_asyncToGenerator(combat_tracker_regeneratorRuntime().mark((function _callee4(t){var r;return combat_tracker_regeneratorRuntime().wrap((function _callee4$(a){for(;;)switch(a.prev=a.next){case 0:return r=this.getCombatantFromActor(t),a.abrupt("return",r&&r.getFlag("dsa5","defenseCount")||0);case 2:case"end":return a.stop()}}),_callee4,this)}))),function getDefenseCount(t){return a.apply(this,arguments)})},{key:"getCombatantFromActor",value:function getCombatantFromActor(t){var r;return(r=t.token?Array.from(this.combatants).find((function(r){return r.tokenId==t.token})):Array.from(this.combatants).find((function(r){return r.actorId==t.actor})))?this.combatants.get(r.id):void 0}},{key:"updateDefenseCount",value:(r=combat_tracker_asyncToGenerator(combat_tracker_regeneratorRuntime().mark((function _callee5(t){var r;return combat_tracker_regeneratorRuntime().wrap((function _callee5$(a){for(;;)switch(a.prev=a.next){case 0:if(!game.user.isGM){a.next=7;break}if(!(r=this.getCombatantFromActor(t))||getProperty(r.actor,"system.config.defense")){a.next=5;break}return a.next=5,r.setFlag("dsa5","defenseCount",(r.getFlag("dsa5","defenseCount")||0)+1);case 5:a.next=9;break;case 7:return a.next=9,game.socket.emit("system.dsa5",{type:"updateDefenseCount",payload:{speaker:t}});case 9:case"end":return a.stop()}}),_callee5,this)}))),function updateDefenseCount(t){return r.apply(this,arguments)})}]),DSA5Combat}(),je=function(t){combat_tracker_inherits(DSA5Combatant,Combatant);var r,a=combat_tracker_createSuper(DSA5Combatant);function DSA5Combatant(t,r){return combat_tracker_classCallCheck(this,DSA5Combatant),null==t.flags&&(t.flags={}),mergeObject(t.flags,{dsa5:{defenseCount:0}}),a.call(this,t,r)}return combat_tracker_createClass(DSA5Combatant,[{key:"recalcInitiative",value:(r=combat_tracker_asyncToGenerator(combat_tracker_regeneratorRuntime().mark((function _callee6(){var t,r;return combat_tracker_regeneratorRuntime().wrap((function _callee6$(a){for(;;)switch(a.prev=a.next){case 0:if(!this.initiative){a.next=10;break}return a.next=3,this.getFlag("dsa5","baseRoll");case 3:if(a.t0=a.sent,a.t0){a.next=6;break}a.t0=0;case 6:return t=a.t0,r={initiative:t+this.actor.system.status.initiative.value},a.next=10,this.update(r);case 10:case"end":return a.stop()}}),_callee6,this)}))),function recalcInitiative(){return r.apply(this,arguments)})}]),DSA5Combatant}();Hooks.on("preCreateCombatant",(function(r,a,o){var i=t.Z.getSpeaker({actor:r.actorId,scene:r.sceneId,token:r.token_id});if("loot"==getProperty(i.system,"merchant.merchantType"))return!1})),Hooks.on("updateCombatant",(function(t,r,a){if(game.user.isGM)if(r.initiative){if(!t.getFlag("dsa5","baseRoll")){var o="".concat(r.initiative).split("."),i=Number(o[0])-Math.round(t.actor.system.status.initiative.value);t.setFlag("dsa5","baseRoll",i)}}else"initiative"in r&&null==r.initiative&&t.update(function combat_tracker_defineProperty(t,r,a){return r in t?Object.defineProperty(t,r,{value:a,enumerable:!0,configurable:!0,writable:!0}):t[r]=a,t}({},"flags.dsa5.-=baseRoll",null))}));var Fe=function(){function RepeatingEffectsHelper(){combat_tracker_classCallCheck(this,RepeatingEffectsHelper)}var r,a,o,i,c,l;return combat_tracker_createClass(RepeatingEffectsHelper,null,[{key:"updateCombatHook",value:(l=combat_tracker_asyncToGenerator(combat_tracker_regeneratorRuntime().mark((function _callee7(t,r,a,o){return combat_tracker_regeneratorRuntime().wrap((function _callee7$(a){for(;;)switch(a.prev=a.next){case 0:if(r.round||r.turn){a.next=2;break}return a.abrupt("return");case 2:if(0==t.round||!t.turns||!t.active){a.next=6;break}if(!(t.previous.round0?"CHATNOTIFICATION.regenerates":"CHATNOTIFICATION.getsHurt"),d="".concat(t.actor.name," ").concat(p," ").concat(game.i18n.localize(i)," ").concat(l),h.next=19,this.sendEventMessage(d,r,t);case 19:if("wounds"!=i){h.next=24;break}return h.next=22,t.actor.applyDamage(-1*u.total);case 22:h.next=26;break;case 24:return h.next=26,t.actor.applyMana(-1*u.total,"astralenergy"==i?"AsP":"KaP");case 26:a++,h.next=2;break;case 29:case"end":return h.stop()}}),_callee9,this)}))),function startOfRoundEffects(t,r){return i.apply(this,arguments)})},{key:"applyBleeding",value:(o=combat_tracker_asyncToGenerator(combat_tracker_regeneratorRuntime().mark((function _callee10(t,r){var a;return combat_tracker_regeneratorRuntime().wrap((function _callee10$(o){for(;;)switch(o.prev=o.next){case 0:if(!(t.actor.system.status.wounds.value<1)){o.next=2;break}return o.abrupt("return");case 2:return a=game.i18n.format("CHATNOTIFICATION.bleeding",{actor:t.actor.name}),o.next=5,this.sendEventMessage(a,r,t);case 5:return o.next=7,t.actor.applyDamage(1);case 7:case"end":return o.stop()}}),_callee10,this)}))),function applyBleeding(t,r){return o.apply(this,arguments)})},{key:"applyBurning",value:(a=combat_tracker_asyncToGenerator(combat_tracker_regeneratorRuntime().mark((function _callee11(t,r,a){var o,i,c,l,p,d;return combat_tracker_regeneratorRuntime().wrap((function _callee11$(h){for(;;)switch(h.prev=h.next){case 0:if(!(t.actor.system.status.wounds.value<1)){h.next=2;break}return h.abrupt("return");case 2:return o=Number(r.getFlag("dsa5","value")),i=u.Z.resistantToEffect(t.actor,r),c={0:"1",1:"1d3",2:"1d6",3:"2d6"}[o-i]||"1",h.next=7,new Roll(c).evaluate({async:!0});case 7:return l=h.sent,h.next=10,l.render();case 10:return p=h.sent,d=game.i18n.format("CHATNOTIFICATION.burning.".concat(o),{actor:t.actor.name,damage:p}),h.next=14,this.sendEventMessage(d,a,t);case 14:return h.next=16,t.actor.applyDamage(l.total);case 16:case"end":return h.stop()}}),_callee11,this)}))),function applyBurning(t,r,o){return a.apply(this,arguments)})},{key:"sendEventMessage",value:(r=combat_tracker_asyncToGenerator(combat_tracker_regeneratorRuntime().mark((function _callee12(r,a,o){var i;return combat_tracker_regeneratorRuntime().wrap((function _callee12$(c){for(;;)switch(c.prev=c.next){case 0:if(!game.settings.get("dsa5","hideRegenerationToOwner")){c.next=7;break}return(i=a.combatants.get(o.id).players).push.apply(i,combat_tracker_toConsumableArray(game.users.filter((function(t){return t.isGM})).map((function(t){return t.id})))),c.next=5,ChatMessage.create(t.Z.chatDataSetup(r,void 0,void 0,i));case 5:c.next=9;break;case 7:return c.next=9,ChatMessage.create(t.Z.chatDataSetup(r));case 9:case"end":return c.stop()}}),_callee12)}))),function sendEventMessage(t,a,o){return r.apply(this,arguments)})}]),RepeatingEffectsHelper}();function dsa_ini_tracker_typeof(t){return dsa_ini_tracker_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},dsa_ini_tracker_typeof(t)}function dsa_ini_tracker_regeneratorRuntime(){dsa_ini_tracker_regeneratorRuntime=function _regeneratorRuntime(){return t};var t={},r=Object.prototype,a=r.hasOwnProperty,o="function"==typeof Symbol?Symbol:{},i=o.iterator||"@@iterator",c=o.asyncIterator||"@@asyncIterator",u=o.toStringTag||"@@toStringTag";function define(t,r,a){return Object.defineProperty(t,r,{value:a,enumerable:!0,configurable:!0,writable:!0}),t[r]}try{define({},"")}catch(t){define=function define(t,r,a){return t[r]=a}}function wrap(t,r,a,o){var i=r&&r.prototype instanceof Generator?r:Generator,c=Object.create(i.prototype),u=new Context(o||[]);return c._invoke=function(t,r,a){var o="suspendedStart";return function(i,c){if("executing"===o)throw new Error("Generator is already running");if("completed"===o){if("throw"===i)throw c;return doneResult()}for(a.method=i,a.arg=c;;){var u=a.delegate;if(u){var p=maybeInvokeDelegate(u,a);if(p){if(p===l)continue;return p}}if("next"===a.method)a.sent=a._sent=a.arg;else if("throw"===a.method){if("suspendedStart"===o)throw o="completed",a.arg;a.dispatchException(a.arg)}else"return"===a.method&&a.abrupt("return",a.arg);o="executing";var d=tryCatch(t,r,a);if("normal"===d.type){if(o=a.done?"completed":"suspendedYield",d.arg===l)continue;return{value:d.arg,done:a.done}}"throw"===d.type&&(o="completed",a.method="throw",a.arg=d.arg)}}}(t,a,u),c}function tryCatch(t,r,a){try{return{type:"normal",arg:t.call(r,a)}}catch(t){return{type:"throw",arg:t}}}t.wrap=wrap;var l={};function Generator(){}function GeneratorFunction(){}function GeneratorFunctionPrototype(){}var p={};define(p,i,(function(){return this}));var d=Object.getPrototypeOf,h=d&&d(d(values([])));h&&h!==r&&a.call(h,i)&&(p=h);var m=GeneratorFunctionPrototype.prototype=Generator.prototype=Object.create(p);function defineIteratorMethods(t){["next","throw","return"].forEach((function(r){define(t,r,(function(t){return this._invoke(r,t)}))}))}function AsyncIterator(t,r){function invoke(o,i,c,u){var l=tryCatch(t[o],t,i);if("throw"!==l.type){var p=l.arg,d=p.value;return d&&"object"==dsa_ini_tracker_typeof(d)&&a.call(d,"__await")?r.resolve(d.__await).then((function(t){invoke("next",t,c,u)}),(function(t){invoke("throw",t,c,u)})):r.resolve(d).then((function(t){p.value=t,c(p)}),(function(t){return invoke("throw",t,c,u)}))}u(l.arg)}var o;this._invoke=function(t,a){function callInvokeWithMethodAndArg(){return new r((function(r,o){invoke(t,a,r,o)}))}return o=o?o.then(callInvokeWithMethodAndArg,callInvokeWithMethodAndArg):callInvokeWithMethodAndArg()}}function maybeInvokeDelegate(t,r){var a=t.iterator[r.method];if(void 0===a){if(r.delegate=null,"throw"===r.method){if(t.iterator.return&&(r.method="return",r.arg=void 0,maybeInvokeDelegate(t,r),"throw"===r.method))return l;r.method="throw",r.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var o=tryCatch(a,t.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,l;var i=o.arg;return i?i.done?(r[t.resultName]=i.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=void 0),r.delegate=null,l):i:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,l)}function pushTryEntry(t){var r={tryLoc:t[0]};1 in t&&(r.catchLoc=t[1]),2 in t&&(r.finallyLoc=t[2],r.afterLoc=t[3]),this.tryEntries.push(r)}function resetTryEntry(t){var r=t.completion||{};r.type="normal",delete r.arg,t.completion=r}function Context(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(pushTryEntry,this),this.reset(!0)}function values(t){if(t){var r=t[i];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var o=-1,c=function next(){for(;++o=0;--o){var i=this.tryEntries[o],c=i.completion;if("root"===i.tryLoc)return handle("end");if(i.tryLoc<=this.prev){var u=a.call(i,"catchLoc"),l=a.call(i,"finallyLoc");if(u&&l){if(this.prev=0;--o){var i=this.tryEntries[o];if(i.tryLoc<=this.prev&&a.call(i,"finallyLoc")&&this.prev=0;--r){var a=this.tryEntries[r];if(a.finallyLoc===t)return this.complete(a.completion,a.afterLoc),resetTryEntry(a),l}},catch:function _catch(t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc===t){var o=a.completion;if("throw"===o.type){var i=o.arg;resetTryEntry(a)}return i}}throw new Error("illegal catch attempt")},delegateYield:function delegateYield(t,r,a){return this.delegate={iterator:values(t),resultName:r,nextLoc:a},"next"===this.method&&(this.arg=void 0),l}},t}function dsa_ini_tracker_asyncGeneratorStep(t,r,a,o,i,c,u){try{var l=t[c](u),p=l.value}catch(t){return void a(t)}l.done?r(p):Promise.resolve(p).then(o,i)}function dsa_ini_tracker_asyncToGenerator(t){return function(){var r=this,a=arguments;return new Promise((function(o,i){var c=t.apply(r,a);function _next(t){dsa_ini_tracker_asyncGeneratorStep(c,o,i,_next,_throw,"next",t)}function _throw(t){dsa_ini_tracker_asyncGeneratorStep(c,o,i,_next,_throw,"throw",t)}_next(void 0)}))}}function dsa_ini_tracker_classCallCheck(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}function dsa_ini_tracker_defineProperties(t,r){for(var a=0;a0&&void 0!==arguments[0]?arguments[0]:{},r=t.left,a=t.top,o=t.width,i=t.height,c=t.scale,u=dsa_ini_tracker_get(dsa_ini_tracker_getPrototypeOf(DSAIniTracker.prototype),"setPosition",this).call(this,{left:r,top:a,width:o,height:i,scale:c}),l=this.element[0];if(!l.style.width||o){var p=o||l.offsetWidth,d=l.style.maxWidth||window.innerWidth;u.width=o=Math.clamped(p,0,d),l.style.width=o+"px",o+u.left>window.innerWidth&&(r=u.left)}return game.settings.set("dsa5","iniTrackerPosition",{left:u.left,top:u.top}),u}},{key:"updateTracker",value:function updateTracker(t){this.combatData=t,this.render(!0,{focus:!1})}},{key:"getData",value:(i=dsa_ini_tracker_asyncToGenerator(dsa_ini_tracker_regeneratorRuntime().mark((function _callee(t){var r,a,o,i,c,u,l,p,d,h,m,y,g,v,_,b,k,w,x;return dsa_ini_tracker_regeneratorRuntime().wrap((function _callee$(t){for(;;)switch(t.prev=t.next){case 0:if(r=this.combatData,a=DSAIniTracker.defaultOptions.itemWidth,o=DSAIniTracker.defaultOptions.actorCount,i=r.round,c=r.turns,u=[],l=game.settings.get("core",Combat.CONFIG_SETTING).skipDefeated,p=c.some((function(t){return t.active})),d=r.turns.some((function(t){return t.owner&&!t.hasRolled&&(!game.user.isGM||r.combat.combatants.get(t.id).isNPC)})),c.length){for(h=[],m=o,y=!1,g=-1,v=0,_=0;0!=m&&_!=o;)k=duplicate(c[v]),w=r.combat.combatants.get(k.id),y&&v==g&&(k.css=k.css.replace("active","")),!i||k.active&&!y||!p&&!y?(y=!0,g=v):w.getFlag("dsa5","waitInit")!=r.round+_||w.defeated||!game.user.isGM&&w.hidden||u.push(k),!y||l&&w.defeated||!game.user.isGM&&w.hidden||(k.round=r.round+_,k.owner&&null!==(x=w.token)&&void 0!==x&&x.actor&&(k.maxLP=w.token.actor.system.status.wounds.max,k.currentLP=w.token.actor.system.status.wounds.value),b&&b!=k.round&&(k.newRound="newRound"),b=k.round,h.push(k),m--),++v>=c.length&&(v=0,_++);r.turns=h}return this.position.width=a*o+3*o+80,this.position.height=a+10,mergeObject(r,{itemWidth:a,unRolled:d,waitingTurns:u}),this.conditionalPanToCurrentCombatant(r),t.abrupt("return",r);case 15:case"end":return t.stop()}}),_callee,this)}))),function getData(t){return i.apply(this,arguments)})},{key:"hasChangedTurn",value:function hasChangedTurn(t){var r=t.turn!=this.lastTurnUpdate||t.round!=this.lastRoundUpdate;return this.lastTurnUpdate=t.turn,this.lastRoundUpdate=t.round,r}},{key:"conditionalPanToCurrentCombatant",value:(o=dsa_ini_tracker_asyncToGenerator(dsa_ini_tracker_regeneratorRuntime().mark((function _callee2(t){var r,a;return dsa_ini_tracker_regeneratorRuntime().wrap((function _callee2$(o){for(;;)switch(o.prev=o.next){case 0:if(game.settings.get("dsa5","enableCombatPan")){o.next=2;break}return o.abrupt("return");case 2:if(r=t.turns[0]){o.next=5;break}return o.abrupt("return");case 5:if((a=t.combat.combatants.get(r.id))&&this.hasChangedTurn(t)){o.next=8;break}return o.abrupt("return");case 8:setTimeout((function(){var t=a.token;t&&t.object&&t.object.isVisible&&(canvas.animatePan({x:t.x,y:t.y}),a.actor&&a.actor.isOwner&&t.object.control({releaseOthers:!0}))}),300);case 9:case"end":return o.stop()}}),_callee2,this)}))),function conditionalPanToCurrentCombatant(t){return o.apply(this,arguments)})},{key:"_onWheelResize",value:(a=dsa_ini_tracker_asyncToGenerator(dsa_ini_tracker_regeneratorRuntime().mark((function _callee3(t){var r;return dsa_ini_tracker_regeneratorRuntime().wrap((function _callee3$(a){for(;;)switch(a.prev=a.next){case 0:return r=game.settings.get("dsa5","iniTrackerSize"),r=t.originalEvent.deltaY>0?Math.min(140,r+5):Math.max(30,r-5),a.next=4,game.settings.set("dsa5","iniTrackerSize",r);case 4:return a.next=6,this.render(!0);case 6:case"end":return a.stop()}}),_callee3,this)}))),function _onWheelResize(t){return a.apply(this,arguments)})},{key:"activateListeners",value:function activateListeners(t){var r=this;dsa_ini_tracker_get(dsa_ini_tracker_getPrototypeOf(DSAIniTracker.prototype),"activateListeners",this).call(this,t);var a=t.find(".dragHandler");new Draggable(this,t,a[0],this.options.resizable),a.on("wheel",function(){var t=dsa_ini_tracker_asyncToGenerator(dsa_ini_tracker_regeneratorRuntime().mark((function _callee4(t){return dsa_ini_tracker_regeneratorRuntime().wrap((function _callee4$(a){for(;;)switch(a.prev=a.next){case 0:return t.stopPropagation(),t.preventDefault(),a.next=4,r._onWheelResize(t);case 4:return a.abrupt("return",!1);case 5:case"end":return a.stop()}}),_callee4)})));return function(r){return t.apply(this,arguments)}}()),t.find(".toggleTracker").click((function(){var t=ui.combat;t.renderPopout(t)})),t.find(".combat-control").click((function(t){return r._onCombatControl(t)}));var o=t.find(".iniItem");o.hover(this._onCombatantHoverIn.bind(this),this._onCombatantHoverOut.bind(this)),o.click(this._onCombatantMouseDown.bind(this)),t.find(".waitingTackerList .iniItem").mousedown((function(t){return r._onRightClick(t)})),t.find(".combatant-control").click((function(t){return r._onCombatantControl(t)})),t.find(".combatant .aggroButton").click((function(t){t.preventDefault(),t.stopPropagation(),Ge.runActAttackDialog()})),t.find(".rollMine").click((function(t){return r.rollMyChars()})),game.user.isGM&&t.find(".rolledInit").click((function(t){return r.editCombatant(t)}))}},{key:"rollMyChars",value:function rollMyChars(){game.user.isGM?this._getCombatApp().viewed.rollNPC({}):this._getCombatApp().viewed.rollAll({})}},{key:"_onRightClick",value:function _onRightClick(t){if(2==t.button){var r=game.combat.combatants.get(t.currentTarget.dataset.combatantId);r.isOwner&&r.unsetFlag("dsa5","waitInit")}}},{key:"editCombatant",value:function editCombatant(t){this._getCombatApp()._onConfigureCombatant($(t.currentTarget))}},{key:"_onCombatantControl",value:function _onCombatantControl(t){this._getCombatApp()._onCombatantControl(t)}},{key:"_onCombatControl",value:function _onCombatControl(t){"waitInit"==t.currentTarget.dataset.control?this.waitInit(t):this._getCombatApp()._onCombatControl(t)}},{key:"waitInit",value:(r=dsa_ini_tracker_asyncToGenerator(dsa_ini_tracker_regeneratorRuntime().mark((function _callee5(t){var r;return dsa_ini_tracker_regeneratorRuntime().wrap((function _callee5$(a){for(;;)switch(a.prev=a.next){case 0:return r=game.combat.combatants.get(game.combat.current.combatantId),a.next=3,r.setFlag("dsa5","waitInit",game.combat.current.round);case 3:t.currentTarget.dataset.control="nextTurn",this._getCombatApp()._onCombatControl(t);case 5:case"end":return a.stop()}}),_callee5,this)}))),function waitInit(t){return r.apply(this,arguments)})},{key:"_onCombatantHoverOut",value:function _onCombatantHoverOut(t){this._getCombatApp()._onCombatantHoverOut(t)}},{key:"_onCombatantHoverIn",value:function _onCombatantHoverIn(t){this._getCombatApp()._onCombatantHoverIn(t)}},{key:"_onCombatantMouseDown",value:function _onCombatantMouseDown(t){this._getCombatApp()._onCombatantMouseDown(t)}},{key:"_getCombatApp",value:function _getCombatApp(){return game.combats.apps[0]}},{key:"_canDragStart",value:function _canDragStart(t){return!1}},{key:"_canDragDrop",value:function _canDragDrop(t){return!1}},{key:"_onDragStart",value:function _onDragStart(t){var r=$(t.currentTarget).closestData("combatant-id");t.dataTransfer.setData("text/plain",JSON.stringify({type:"IniChange",combatantId:r}))}},{key:"_onDrop",value:function _onDrop(t){JSON.parse(t.dataTransfer.getData("text/plain")).type}}],[{key:"defaultOptions",get:function get(){var t=dsa_ini_tracker_get(dsa_ini_tracker_getPrototypeOf(DSAIniTracker),"defaultOptions",this);return mergeObject(t,{classes:t.classes.concat(["dsa5","initTracker"]),template:"systems/dsa5/templates/system/initracker.html",dragDrop:[{dragSelector:".iniItem",dropSelector:[".iniTrackerList"]}],top:100,left:170,title:"DSAIniTracker",itemWidth:game.settings.get("dsa5","iniTrackerSize"),actorCount:game.settings.get("dsa5","iniTrackerCount"),position:game.settings.get("dsa5","iniTrackerPosition")}),t}},{key:"connectHooks",value:function connectHooks(){Hooks.on("renderDSA5CombatTracker",(function(t,r,a){game.settings.get("dsa5","enableCombatFlow")&&(game.combat?(game.dsa5.apps.initTracker||(game.dsa5.apps.initTracker=new DSAIniTracker),game.dsa5.apps.initTracker.updateTracker(a)):game.dsa5.apps.initTracker&&(game.dsa5.apps.initTracker.close(),game.dsa5.apps.initTracker=void 0))}))}}]),DSAIniTracker}(),Ne=__webpack_require__(93),He=__webpack_require__(147);function ready_typeof(t){return ready_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},ready_typeof(t)}function ready_regeneratorRuntime(){ready_regeneratorRuntime=function _regeneratorRuntime(){return t};var t={},r=Object.prototype,a=r.hasOwnProperty,o="function"==typeof Symbol?Symbol:{},i=o.iterator||"@@iterator",c=o.asyncIterator||"@@asyncIterator",u=o.toStringTag||"@@toStringTag";function define(t,r,a){return Object.defineProperty(t,r,{value:a,enumerable:!0,configurable:!0,writable:!0}),t[r]}try{define({},"")}catch(t){define=function define(t,r,a){return t[r]=a}}function wrap(t,r,a,o){var i=r&&r.prototype instanceof Generator?r:Generator,c=Object.create(i.prototype),u=new Context(o||[]);return c._invoke=function(t,r,a){var o="suspendedStart";return function(i,c){if("executing"===o)throw new Error("Generator is already running");if("completed"===o){if("throw"===i)throw c;return doneResult()}for(a.method=i,a.arg=c;;){var u=a.delegate;if(u){var p=maybeInvokeDelegate(u,a);if(p){if(p===l)continue;return p}}if("next"===a.method)a.sent=a._sent=a.arg;else if("throw"===a.method){if("suspendedStart"===o)throw o="completed",a.arg;a.dispatchException(a.arg)}else"return"===a.method&&a.abrupt("return",a.arg);o="executing";var d=tryCatch(t,r,a);if("normal"===d.type){if(o=a.done?"completed":"suspendedYield",d.arg===l)continue;return{value:d.arg,done:a.done}}"throw"===d.type&&(o="completed",a.method="throw",a.arg=d.arg)}}}(t,a,u),c}function tryCatch(t,r,a){try{return{type:"normal",arg:t.call(r,a)}}catch(t){return{type:"throw",arg:t}}}t.wrap=wrap;var l={};function Generator(){}function GeneratorFunction(){}function GeneratorFunctionPrototype(){}var p={};define(p,i,(function(){return this}));var d=Object.getPrototypeOf,h=d&&d(d(values([])));h&&h!==r&&a.call(h,i)&&(p=h);var m=GeneratorFunctionPrototype.prototype=Generator.prototype=Object.create(p);function defineIteratorMethods(t){["next","throw","return"].forEach((function(r){define(t,r,(function(t){return this._invoke(r,t)}))}))}function AsyncIterator(t,r){function invoke(o,i,c,u){var l=tryCatch(t[o],t,i);if("throw"!==l.type){var p=l.arg,d=p.value;return d&&"object"==ready_typeof(d)&&a.call(d,"__await")?r.resolve(d.__await).then((function(t){invoke("next",t,c,u)}),(function(t){invoke("throw",t,c,u)})):r.resolve(d).then((function(t){p.value=t,c(p)}),(function(t){return invoke("throw",t,c,u)}))}u(l.arg)}var o;this._invoke=function(t,a){function callInvokeWithMethodAndArg(){return new r((function(r,o){invoke(t,a,r,o)}))}return o=o?o.then(callInvokeWithMethodAndArg,callInvokeWithMethodAndArg):callInvokeWithMethodAndArg()}}function maybeInvokeDelegate(t,r){var a=t.iterator[r.method];if(void 0===a){if(r.delegate=null,"throw"===r.method){if(t.iterator.return&&(r.method="return",r.arg=void 0,maybeInvokeDelegate(t,r),"throw"===r.method))return l;r.method="throw",r.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var o=tryCatch(a,t.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,l;var i=o.arg;return i?i.done?(r[t.resultName]=i.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=void 0),r.delegate=null,l):i:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,l)}function pushTryEntry(t){var r={tryLoc:t[0]};1 in t&&(r.catchLoc=t[1]),2 in t&&(r.finallyLoc=t[2],r.afterLoc=t[3]),this.tryEntries.push(r)}function resetTryEntry(t){var r=t.completion||{};r.type="normal",delete r.arg,t.completion=r}function Context(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(pushTryEntry,this),this.reset(!0)}function values(t){if(t){var r=t[i];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var o=-1,c=function next(){for(;++o=0;--o){var i=this.tryEntries[o],c=i.completion;if("root"===i.tryLoc)return handle("end");if(i.tryLoc<=this.prev){var u=a.call(i,"catchLoc"),l=a.call(i,"finallyLoc");if(u&&l){if(this.prev=0;--o){var i=this.tryEntries[o];if(i.tryLoc<=this.prev&&a.call(i,"finallyLoc")&&this.prev=0;--r){var a=this.tryEntries[r];if(a.finallyLoc===t)return this.complete(a.completion,a.afterLoc),resetTryEntry(a),l}},catch:function _catch(t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc===t){var o=a.completion;if("throw"===o.type){var i=o.arg;resetTryEntry(a)}return i}}throw new Error("illegal catch attempt")},delegateYield:function delegateYield(t,r,a){return this.delegate={iterator:values(t),resultName:r,nextLoc:a},"next"===this.method&&(this.arg=void 0),l}},t}function ready_asyncGeneratorStep(t,r,a,o,i,c,u){try{var l=t[c](u),p=l.value}catch(t){return void a(t)}l.done?r(p):Promise.resolve(p).then(o,i)}function ready_asyncToGenerator(t){return function(){var r=this,a=arguments;return new Promise((function(o,i){var c=t.apply(r,a);function _next(t){ready_asyncGeneratorStep(c,o,i,_next,_throw,"next",t)}function _throw(t){ready_asyncGeneratorStep(c,o,i,_next,_throw,"throw",t)}_next(void 0)}))}}function chat_context_typeof(t){return chat_context_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},chat_context_typeof(t)}function chat_context_regeneratorRuntime(){chat_context_regeneratorRuntime=function _regeneratorRuntime(){return t};var t={},r=Object.prototype,a=r.hasOwnProperty,o="function"==typeof Symbol?Symbol:{},i=o.iterator||"@@iterator",c=o.asyncIterator||"@@asyncIterator",u=o.toStringTag||"@@toStringTag";function define(t,r,a){return Object.defineProperty(t,r,{value:a,enumerable:!0,configurable:!0,writable:!0}),t[r]}try{define({},"")}catch(t){define=function define(t,r,a){return t[r]=a}}function wrap(t,r,a,o){var i=r&&r.prototype instanceof Generator?r:Generator,c=Object.create(i.prototype),u=new Context(o||[]);return c._invoke=function(t,r,a){var o="suspendedStart";return function(i,c){if("executing"===o)throw new Error("Generator is already running");if("completed"===o){if("throw"===i)throw c;return doneResult()}for(a.method=i,a.arg=c;;){var u=a.delegate;if(u){var p=maybeInvokeDelegate(u,a);if(p){if(p===l)continue;return p}}if("next"===a.method)a.sent=a._sent=a.arg;else if("throw"===a.method){if("suspendedStart"===o)throw o="completed",a.arg;a.dispatchException(a.arg)}else"return"===a.method&&a.abrupt("return",a.arg);o="executing";var d=tryCatch(t,r,a);if("normal"===d.type){if(o=a.done?"completed":"suspendedYield",d.arg===l)continue;return{value:d.arg,done:a.done}}"throw"===d.type&&(o="completed",a.method="throw",a.arg=d.arg)}}}(t,a,u),c}function tryCatch(t,r,a){try{return{type:"normal",arg:t.call(r,a)}}catch(t){return{type:"throw",arg:t}}}t.wrap=wrap;var l={};function Generator(){}function GeneratorFunction(){}function GeneratorFunctionPrototype(){}var p={};define(p,i,(function(){return this}));var d=Object.getPrototypeOf,h=d&&d(d(values([])));h&&h!==r&&a.call(h,i)&&(p=h);var m=GeneratorFunctionPrototype.prototype=Generator.prototype=Object.create(p);function defineIteratorMethods(t){["next","throw","return"].forEach((function(r){define(t,r,(function(t){return this._invoke(r,t)}))}))}function AsyncIterator(t,r){function invoke(o,i,c,u){var l=tryCatch(t[o],t,i);if("throw"!==l.type){var p=l.arg,d=p.value;return d&&"object"==chat_context_typeof(d)&&a.call(d,"__await")?r.resolve(d.__await).then((function(t){invoke("next",t,c,u)}),(function(t){invoke("throw",t,c,u)})):r.resolve(d).then((function(t){p.value=t,c(p)}),(function(t){return invoke("throw",t,c,u)}))}u(l.arg)}var o;this._invoke=function(t,a){function callInvokeWithMethodAndArg(){return new r((function(r,o){invoke(t,a,r,o)}))}return o=o?o.then(callInvokeWithMethodAndArg,callInvokeWithMethodAndArg):callInvokeWithMethodAndArg()}}function maybeInvokeDelegate(t,r){var a=t.iterator[r.method];if(void 0===a){if(r.delegate=null,"throw"===r.method){if(t.iterator.return&&(r.method="return",r.arg=void 0,maybeInvokeDelegate(t,r),"throw"===r.method))return l;r.method="throw",r.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var o=tryCatch(a,t.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,l;var i=o.arg;return i?i.done?(r[t.resultName]=i.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=void 0),r.delegate=null,l):i:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,l)}function pushTryEntry(t){var r={tryLoc:t[0]};1 in t&&(r.catchLoc=t[1]),2 in t&&(r.finallyLoc=t[2],r.afterLoc=t[3]),this.tryEntries.push(r)}function resetTryEntry(t){var r=t.completion||{};r.type="normal",delete r.arg,t.completion=r}function Context(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(pushTryEntry,this),this.reset(!0)}function values(t){if(t){var r=t[i];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var o=-1,c=function next(){for(;++o=0;--o){var i=this.tryEntries[o],c=i.completion;if("root"===i.tryLoc)return handle("end");if(i.tryLoc<=this.prev){var u=a.call(i,"catchLoc"),l=a.call(i,"finallyLoc");if(u&&l){if(this.prev=0;--o){var i=this.tryEntries[o];if(i.tryLoc<=this.prev&&a.call(i,"finallyLoc")&&this.prev=0;--r){var a=this.tryEntries[r];if(a.finallyLoc===t)return this.complete(a.completion,a.afterLoc),resetTryEntry(a),l}},catch:function _catch(t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc===t){var o=a.completion;if("throw"===o.type){var i=o.arg;resetTryEntry(a)}return i}}throw new Error("illegal catch attempt")},delegateYield:function delegateYield(t,r,a){return this.delegate={iterator:values(t),resultName:r,nextLoc:a},"next"===this.method&&(this.arg=void 0),l}},t}function chat_context_asyncGeneratorStep(t,r,a,o,i,c,u){try{var l=t[c](u),p=l.value}catch(t){return void a(t)}l.done?r(p):Promise.resolve(p).then(o,i)}function chat_context_asyncToGenerator(t){return function(){var r=this,a=arguments;return new Promise((function(o,i){var c=t.apply(r,a);function _next(t){chat_context_asyncGeneratorStep(c,o,i,_next,_throw,"next",t)}function _throw(t){chat_context_asyncGeneratorStep(c,o,i,_next,_throw,"throw",t)}_next(void 0)}))}}var $e=__webpack_require__(565);function statuseffect_typeof(t){return statuseffect_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},statuseffect_typeof(t)}function statuseffect_regeneratorRuntime(){statuseffect_regeneratorRuntime=function _regeneratorRuntime(){return t};var t={},r=Object.prototype,a=r.hasOwnProperty,o="function"==typeof Symbol?Symbol:{},i=o.iterator||"@@iterator",c=o.asyncIterator||"@@asyncIterator",u=o.toStringTag||"@@toStringTag";function define(t,r,a){return Object.defineProperty(t,r,{value:a,enumerable:!0,configurable:!0,writable:!0}),t[r]}try{define({},"")}catch(t){define=function define(t,r,a){return t[r]=a}}function wrap(t,r,a,o){var i=r&&r.prototype instanceof Generator?r:Generator,c=Object.create(i.prototype),u=new Context(o||[]);return c._invoke=function(t,r,a){var o="suspendedStart";return function(i,c){if("executing"===o)throw new Error("Generator is already running");if("completed"===o){if("throw"===i)throw c;return doneResult()}for(a.method=i,a.arg=c;;){var u=a.delegate;if(u){var p=maybeInvokeDelegate(u,a);if(p){if(p===l)continue;return p}}if("next"===a.method)a.sent=a._sent=a.arg;else if("throw"===a.method){if("suspendedStart"===o)throw o="completed",a.arg;a.dispatchException(a.arg)}else"return"===a.method&&a.abrupt("return",a.arg);o="executing";var d=tryCatch(t,r,a);if("normal"===d.type){if(o=a.done?"completed":"suspendedYield",d.arg===l)continue;return{value:d.arg,done:a.done}}"throw"===d.type&&(o="completed",a.method="throw",a.arg=d.arg)}}}(t,a,u),c}function tryCatch(t,r,a){try{return{type:"normal",arg:t.call(r,a)}}catch(t){return{type:"throw",arg:t}}}t.wrap=wrap;var l={};function Generator(){}function GeneratorFunction(){}function GeneratorFunctionPrototype(){}var p={};define(p,i,(function(){return this}));var d=Object.getPrototypeOf,h=d&&d(d(values([])));h&&h!==r&&a.call(h,i)&&(p=h);var m=GeneratorFunctionPrototype.prototype=Generator.prototype=Object.create(p);function defineIteratorMethods(t){["next","throw","return"].forEach((function(r){define(t,r,(function(t){return this._invoke(r,t)}))}))}function AsyncIterator(t,r){function invoke(o,i,c,u){var l=tryCatch(t[o],t,i);if("throw"!==l.type){var p=l.arg,d=p.value;return d&&"object"==statuseffect_typeof(d)&&a.call(d,"__await")?r.resolve(d.__await).then((function(t){invoke("next",t,c,u)}),(function(t){invoke("throw",t,c,u)})):r.resolve(d).then((function(t){p.value=t,c(p)}),(function(t){return invoke("throw",t,c,u)}))}u(l.arg)}var o;this._invoke=function(t,a){function callInvokeWithMethodAndArg(){return new r((function(r,o){invoke(t,a,r,o)}))}return o=o?o.then(callInvokeWithMethodAndArg,callInvokeWithMethodAndArg):callInvokeWithMethodAndArg()}}function maybeInvokeDelegate(t,r){var a=t.iterator[r.method];if(void 0===a){if(r.delegate=null,"throw"===r.method){if(t.iterator.return&&(r.method="return",r.arg=void 0,maybeInvokeDelegate(t,r),"throw"===r.method))return l;r.method="throw",r.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var o=tryCatch(a,t.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,l;var i=o.arg;return i?i.done?(r[t.resultName]=i.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=void 0),r.delegate=null,l):i:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,l)}function pushTryEntry(t){var r={tryLoc:t[0]};1 in t&&(r.catchLoc=t[1]),2 in t&&(r.finallyLoc=t[2],r.afterLoc=t[3]),this.tryEntries.push(r)}function resetTryEntry(t){var r=t.completion||{};r.type="normal",delete r.arg,t.completion=r}function Context(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(pushTryEntry,this),this.reset(!0)}function values(t){if(t){var r=t[i];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var o=-1,c=function next(){for(;++o=0;--o){var i=this.tryEntries[o],c=i.completion;if("root"===i.tryLoc)return handle("end");if(i.tryLoc<=this.prev){var u=a.call(i,"catchLoc"),l=a.call(i,"finallyLoc");if(u&&l){if(this.prev=0;--o){var i=this.tryEntries[o];if(i.tryLoc<=this.prev&&a.call(i,"finallyLoc")&&this.prev=0;--r){var a=this.tryEntries[r];if(a.finallyLoc===t)return this.complete(a.completion,a.afterLoc),resetTryEntry(a),l}},catch:function _catch(t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc===t){var o=a.completion;if("throw"===o.type){var i=o.arg;resetTryEntry(a)}return i}}throw new Error("illegal catch attempt")},delegateYield:function delegateYield(t,r,a){return this.delegate={iterator:values(t),resultName:r,nextLoc:a},"next"===this.method&&(this.arg=void 0),l}},t}function statuseffect_createForOfIteratorHelper(t,r){var a="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!a){if(Array.isArray(t)||(a=function statuseffect_unsupportedIterableToArray(t,r){if(!t)return;if("string"==typeof t)return statuseffect_arrayLikeToArray(t,r);var a=Object.prototype.toString.call(t).slice(8,-1);"Object"===a&&t.constructor&&(a=t.constructor.name);if("Map"===a||"Set"===a)return Array.from(t);if("Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a))return statuseffect_arrayLikeToArray(t,r)}(t))||r&&t&&"number"==typeof t.length){a&&(t=a);var o=0,i=function F(){};return{s:i,n:function n(){return o>=t.length?{done:!0}:{done:!1,value:t[o++]}},e:function e(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var c,u=!0,l=!1;return{s:function s(){a=a.call(t)},n:function n(){var t=a.next();return u=t.done,t},e:function e(t){l=!0,c=t},f:function f(){try{u||null==a.return||a.return()}finally{if(l)throw c}}}}function statuseffect_arrayLikeToArray(t,r){(null==r||r>t.length)&&(r=t.length);for(var a=0,o=new Array(r);a1&&!u.counterDrawn){var p=game.dsa5.config.effectTextStyle,d=game.settings.get("dsa5","statusEffectCounterColor");p._fill=/^#[0-9A-F]+$/.test(d)?d:"#000000";var h=this.effects.addChild(new PreciseText(u.counter,p));h.x=u.x,h.y=u.y,h.isCounter=!0,u.counterDrawn=!0}r++}}}catch(t){c.e(t)}finally{c.f()}},Token.prototype._drawEffect=function(){var t=statuseffect_asyncToGenerator(statuseffect_regeneratorRuntime().mark((function _callee2(t,r,a){var o,i;return statuseffect_regeneratorRuntime().wrap((function _callee2$(c){for(;;)switch(c.prev=c.next){case 0:if(t){c.next=2;break}return c.abrupt("return");case 2:return c.next=4,loadTexture(t,{fallback:"icons/svg/hazard.svg"});case 4:return o=c.sent,i=new PIXI.Sprite(o),r&&(i.tint=r),i.counter=a,c.abrupt("return",this.effects.addChild(i));case 9:case"end":return c.stop()}}),_callee2,this)})));return function(r,a,o){return t.apply(this,arguments)}}(),TokenHUD.prototype._onToggleEffect=function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};r.overlay;t.preventDefault();var a=t.currentTarget,o=a.dataset.statusId&&this.object.actor?CONFIG.statusEffects.find((function(t){return t.id===a.dataset.statusId})):a.getAttribute("src");if(o.flags.dsa5.editable)return 0==t.button?this.object.incrementCondition(o):2==t.button?this.object.decrementCondition(o):void 0},Token.prototype.incrementCondition=function(){var t=statuseffect_asyncToGenerator(statuseffect_regeneratorRuntime().mark((function _callee3(t){var r,a,o,i,c=arguments;return statuseffect_regeneratorRuntime().wrap((function _callee3$(u){for(;;)switch(u.prev=u.next){case 0:if(r=c.length>1&&void 0!==c[1]?c[1]:{},a=r.active,o=r.overlay,void 0!==o&&o,(i=this.actor.effects.find((function(r){return r.statuses.has(t.id)})))&&!Number.isNumeric(getProperty(i,"flags.dsa5.value"))){u.next=7;break}return u.next=5,this.actor.addCondition(t.id,1,!1,!1);case 5:u.next=10;break;case 7:if(!i){u.next=10;break}return u.next=10,this.actor.removeCondition(t.id,1,!1);case 10:return this.hasActiveHUD&&canvas.tokens.hud.refreshStatusIcons(),u.abrupt("return",a);case 12:case"end":return u.stop()}}),_callee3,this)})));return function(r){return t.apply(this,arguments)}}(),Token.prototype.decrementCondition=function(){var t=statuseffect_asyncToGenerator(statuseffect_regeneratorRuntime().mark((function _callee4(t){var r,a,o,i=arguments;return statuseffect_regeneratorRuntime().wrap((function _callee4$(c){for(;;)switch(c.prev=c.next){case 0:return r=i.length>1&&void 0!==i[1]?i[1]:{},a=r.active,o=r.overlay,void 0!==o&&o,this.actor.removeCondition(t.id,1,!1),this.hasActiveHUD&&canvas.tokens.hud.refreshStatusIcons(),c.abrupt("return",a);case 4:case"end":return c.stop()}}),_callee4,this)})));return function(r){return t.apply(this,arguments)}}();var t=Token.prototype._onClickLeft2;Token.prototype._onClickLeft2=function(r){var a=game.user.isGM||!$e.Z.isEnabled||!function isMerchant(t){return!!t&&["merchant","loot"].includes(getProperty(t.system,"merchant.merchantType"))}(this.actor)||$e.Z.inDistance(this);if(!a)return ui.notifications.warn(game.i18n.localize("DSAError.notInRangeToLoot"));t.call(this,r)}}function sidebar_createForOfIteratorHelper(t,r){var a="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!a){if(Array.isArray(t)||(a=function sidebar_unsupportedIterableToArray(t,r){if(!t)return;if("string"==typeof t)return sidebar_arrayLikeToArray(t,r);var a=Object.prototype.toString.call(t).slice(8,-1);"Object"===a&&t.constructor&&(a=t.constructor.name);if("Map"===a||"Set"===a)return Array.from(t);if("Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a))return sidebar_arrayLikeToArray(t,r)}(t))||r&&t&&"number"==typeof t.length){a&&(t=a);var o=0,i=function F(){};return{s:i,n:function n(){return o>=t.length?{done:!0}:{done:!1,value:t[o++]}},e:function e(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var c,u=!0,l=!1;return{s:function s(){a=a.call(t)},n:function n(){var t=a.next();return u=t.done,t},e:function e(t){l=!0,c=t},f:function f(){try{u||null==a.return||a.return()}finally{if(l)throw c}}}}function sidebar_arrayLikeToArray(t,r){(null==r||r>t.length)&&(r=t.length);for(var a=0,o=new Array(r);a=t.length?{done:!0}:{done:!1,value:t[o++]}},e:function e(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var c,u=!0,l=!1;return{s:function s(){a=a.call(t)},n:function n(){var t=a.next();return u=t.done,t},e:function e(t){l=!0,c=t},f:function f(){try{u||null==a.return||a.return()}finally{if(l)throw c}}}}function configuration_arrayLikeToArray(t,r){(null==r||r>t.length)&&(r=t.length);for(var a=0,o=new Array(r);a=0;--o){var i=this.tryEntries[o],c=i.completion;if("root"===i.tryLoc)return handle("end");if(i.tryLoc<=this.prev){var u=a.call(i,"catchLoc"),l=a.call(i,"finallyLoc");if(u&&l){if(this.prev=0;--o){var i=this.tryEntries[o];if(i.tryLoc<=this.prev&&a.call(i,"finallyLoc")&&this.prev=0;--r){var a=this.tryEntries[r];if(a.finallyLoc===t)return this.complete(a.completion,a.afterLoc),resetTryEntry(a),l}},catch:function _catch(t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc===t){var o=a.completion;if("throw"===o.type){var i=o.arg;resetTryEntry(a)}return i}}throw new Error("illegal catch attempt")},delegateYield:function delegateYield(t,r,a){return this.delegate={iterator:values(t),resultName:r,nextLoc:a},"next"===this.method&&(this.arg=void 0),l}},t}function configuration_asyncGeneratorStep(t,r,a,o,i,c,u){try{var l=t[c](u),p=l.value}catch(t){return void a(t)}l.done?r(p):Promise.resolve(p).then(o,i)}function configuration_asyncToGenerator(t){return function(){var r=this,a=arguments;return new Promise((function(o,i){var c=t.apply(r,a);function _next(t){configuration_asyncGeneratorStep(c,o,i,_next,_throw,"next",t)}function _throw(t){configuration_asyncGeneratorStep(c,o,i,_next,_throw,"throw",t)}_next(void 0)}))}}var We=function exportSetting(t){var r=Array.from(game.settings.settings);t.find('[name="exportOnlyDSA"]').is(":checked")&&(r=r.filter((function(t){return/^dsa5\./.test(t[0])})));var a,o={},i=/(^dsa5\.(selectedActors|trackedActors|groupschips|tokenhotbarPosition|iniTrackerPosition|migrationVersion)$|^dsa5\.breadcrumbs_)/,c=configuration_createForOfIteratorHelper(r);try{for(c.s();!(a=c.n()).done;){var u=a.value;if(!i.test(u[0])){var l=u[0].split("."),p=l.shift(),d=l.join(".");o[u[0]]=game.settings.get(p,d)}}}catch(t){c.e(t)}finally{c.f()}saveDataToFile(JSON.stringify(o,null,2),"text/json","fvtt-DSA5-Configuration.json")},Be=function(){var t=configuration_asyncToGenerator(configuration_regeneratorRuntime().mark((function _callee8(t){var r,a;return configuration_regeneratorRuntime().wrap((function _callee8$(o){for(;;)switch(o.prev=o.next){case 0:if((a=t.find("form")[0]).data.files.length){o.next=3;break}return o.abrupt("return",null===(r=ui.notifications)||void 0===r?void 0:r.error("You did not upload a data file!"));case 3:readTextFromFile(a.data.files[0]).then(function(){var t=configuration_asyncToGenerator(configuration_regeneratorRuntime().mark((function _callee7(t){var r,a,o,i,c,u,l,p;return configuration_regeneratorRuntime().wrap((function _callee7$(d){for(;;)switch(d.prev=d.next){case 0:r=JSON.parse(t),a=Array.from(game.settings.settings).map((function(t){return t[0]})),o=0,i=Object.keys(r);case 3:if(!(o',label:game.i18n.localize("Export"),callback:function callback(t){return We(t)}},import:{icon:'',label:game.i18n.localize("Import"),callback:function callback(t){return Be(t)}}}}).render(!0);case 4:case"end":return r.stop()}}),_callee9)}))),function render(){return r.apply(this,arguments)})}]),ExportForm}(),Ye=function(t){configuration_inherits(ConfigureTokenHotbar,FormApplication);var r,a,o,i=configuration_createSuper(ConfigureTokenHotbar);function ConfigureTokenHotbar(){return configuration_classCallCheck(this,ConfigureTokenHotbar),i.apply(this,arguments)}return configuration_createClass(ConfigureTokenHotbar,[{key:"template",get:function get(){return"systems/dsa5/templates/dialog/configureTokenhotbar.html"}},{key:"activateListeners",value:function activateListeners(t){var r=this;configuration_get(configuration_getPrototypeOf(ConfigureTokenHotbar.prototype),"activateListeners",this).call(this,t),t.find(".resetTokenhotbar").click((function(t){return r.resetTokenHotbar(t)})),t.find("select, input").change(function(){var t=configuration_asyncToGenerator(configuration_regeneratorRuntime().mark((function _callee10(t){var r,a,o;return configuration_regeneratorRuntime().wrap((function _callee10$(i){for(;;)switch(i.prev=i.next){case 0:return a=t.currentTarget.name.split("."),o="Number"==t.currentTarget.dataset.dtype?Number(t.currentTarget.value):t.currentTarget.value,"checkbox"==t.currentTarget.type&&(o=t.currentTarget.checked),i.next=5,game.settings.set(a[0],a[1],o);case 5:null===(r=game.dsa5.apps.tokenHotbar)||void 0===r||r.render(!0);case 6:case"end":return i.stop()}}),_callee10)})));return function(r){return t.apply(this,arguments)}}()),t.find(".bags .slot").click((function(t){return r._onMasterFunctionClicked(t)}))}},{key:"_onMasterFunctionClicked",value:(o=configuration_asyncToGenerator(configuration_regeneratorRuntime().mark((function _callee11(t){var r,a,o;return configuration_regeneratorRuntime().wrap((function _callee11$(i){for(;;)switch(i.prev=i.next){case 0:return a=t.currentTarget.dataset.id,(o=game.settings.get("dsa5","enableMasterTokenFunctions"))[a]=!o[a],i.next=5,game.settings.set("dsa5","enableMasterTokenFunctions",o);case 5:$(t.currentTarget).toggleClass("deactivated",o[a]),game.dsa5.apps.tokenHotbar.gmItems.find((function(t){return t.id==a})).disabled=o[a],null===(r=game.dsa5.apps.tokenHotbar)||void 0===r||r.render(!0);case 8:case"end":return i.stop()}}),_callee11)}))),function _onMasterFunctionClicked(t){return o.apply(this,arguments)})},{key:"getData",value:(a=configuration_asyncToGenerator(configuration_regeneratorRuntime().mark((function _callee12(t){var r;return configuration_regeneratorRuntime().wrap((function _callee12$(a){for(;;)switch(a.prev=a.next){case 0:return a.next=2,configuration_get(configuration_getPrototypeOf(ConfigureTokenHotbar.prototype),"getData",this).call(this,t);case 2:return r=a.sent,mergeObject(r,{tokenhotbarSize:game.settings.get("dsa5","tokenhotbarSize"),tokenhotbarLayout:game.settings.get("dsa5","tokenhotbarLayout"),disableTokenhotbarMaster:game.settings.get("dsa5","disableTokenhotbarMaster"),disableTokenhotbar:game.settings.get("dsa5","disableTokenhotbar"),isGM:game.user.isGM,gmButtons:game.dsa5.apps.tokenHotbar.gmItems}),a.abrupt("return",r);case 5:case"end":return a.stop()}}),_callee12,this)}))),function getData(t){return a.apply(this,arguments)})},{key:"resetTokenHotbar",value:(r=configuration_asyncToGenerator(configuration_regeneratorRuntime().mark((function _callee13(t){var r,a;return configuration_regeneratorRuntime().wrap((function _callee13$(o){for(;;)switch(o.prev=o.next){case 0:return t.preventDefault(),t.stopPropagation(),o.next=4,game.settings.set("dsa5","tokenhotbarPosition",{});case 4:return o.next=6,game.settings.set("dsa5","tokenhotbarLayout",0);case 6:return o.next=8,game.settings.set("dsa5","tokenhotbarSize",35);case 8:null===(r=game.dsa5.apps.tokenHotbar)||void 0===r||r.resetPosition(),null===(a=game.dsa5.apps.tokenHotbar)||void 0===a||a.render(!0);case 10:case"end":return o.stop()}}),_callee13)}))),function resetTokenHotbar(t){return r.apply(this,arguments)})}],[{key:"defaultOptions",get:function get(){var t=configuration_get(configuration_getPrototypeOf(ConfigureTokenHotbar),"defaultOptions",this);return mergeObject(t,{title:game.i18n.localize("DSASETTINGS.configureTokenbar")}),t}}]),ConfigureTokenHotbar}();function journal_typeof(t){return journal_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},journal_typeof(t)}function journal_regeneratorRuntime(){journal_regeneratorRuntime=function _regeneratorRuntime(){return t};var t={},r=Object.prototype,a=r.hasOwnProperty,o="function"==typeof Symbol?Symbol:{},i=o.iterator||"@@iterator",c=o.asyncIterator||"@@asyncIterator",u=o.toStringTag||"@@toStringTag";function define(t,r,a){return Object.defineProperty(t,r,{value:a,enumerable:!0,configurable:!0,writable:!0}),t[r]}try{define({},"")}catch(t){define=function define(t,r,a){return t[r]=a}}function wrap(t,r,a,o){var i=r&&r.prototype instanceof Generator?r:Generator,c=Object.create(i.prototype),u=new Context(o||[]);return c._invoke=function(t,r,a){var o="suspendedStart";return function(i,c){if("executing"===o)throw new Error("Generator is already running");if("completed"===o){if("throw"===i)throw c;return doneResult()}for(a.method=i,a.arg=c;;){var u=a.delegate;if(u){var p=maybeInvokeDelegate(u,a);if(p){if(p===l)continue;return p}}if("next"===a.method)a.sent=a._sent=a.arg;else if("throw"===a.method){if("suspendedStart"===o)throw o="completed",a.arg;a.dispatchException(a.arg)}else"return"===a.method&&a.abrupt("return",a.arg);o="executing";var d=tryCatch(t,r,a);if("normal"===d.type){if(o=a.done?"completed":"suspendedYield",d.arg===l)continue;return{value:d.arg,done:a.done}}"throw"===d.type&&(o="completed",a.method="throw",a.arg=d.arg)}}}(t,a,u),c}function tryCatch(t,r,a){try{return{type:"normal",arg:t.call(r,a)}}catch(t){return{type:"throw",arg:t}}}t.wrap=wrap;var l={};function Generator(){}function GeneratorFunction(){}function GeneratorFunctionPrototype(){}var p={};define(p,i,(function(){return this}));var d=Object.getPrototypeOf,h=d&&d(d(values([])));h&&h!==r&&a.call(h,i)&&(p=h);var m=GeneratorFunctionPrototype.prototype=Generator.prototype=Object.create(p);function defineIteratorMethods(t){["next","throw","return"].forEach((function(r){define(t,r,(function(t){return this._invoke(r,t)}))}))}function AsyncIterator(t,r){function invoke(o,i,c,u){var l=tryCatch(t[o],t,i);if("throw"!==l.type){var p=l.arg,d=p.value;return d&&"object"==journal_typeof(d)&&a.call(d,"__await")?r.resolve(d.__await).then((function(t){invoke("next",t,c,u)}),(function(t){invoke("throw",t,c,u)})):r.resolve(d).then((function(t){p.value=t,c(p)}),(function(t){return invoke("throw",t,c,u)}))}u(l.arg)}var o;this._invoke=function(t,a){function callInvokeWithMethodAndArg(){return new r((function(r,o){invoke(t,a,r,o)}))}return o=o?o.then(callInvokeWithMethodAndArg,callInvokeWithMethodAndArg):callInvokeWithMethodAndArg()}}function maybeInvokeDelegate(t,r){var a=t.iterator[r.method];if(void 0===a){if(r.delegate=null,"throw"===r.method){if(t.iterator.return&&(r.method="return",r.arg=void 0,maybeInvokeDelegate(t,r),"throw"===r.method))return l;r.method="throw",r.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var o=tryCatch(a,t.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,l;var i=o.arg;return i?i.done?(r[t.resultName]=i.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=void 0),r.delegate=null,l):i:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,l)}function pushTryEntry(t){var r={tryLoc:t[0]};1 in t&&(r.catchLoc=t[1]),2 in t&&(r.finallyLoc=t[2],r.afterLoc=t[3]),this.tryEntries.push(r)}function resetTryEntry(t){var r=t.completion||{};r.type="normal",delete r.arg,t.completion=r}function Context(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(pushTryEntry,this),this.reset(!0)}function values(t){if(t){var r=t[i];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var o=-1,c=function next(){for(;++o=0;--o){var i=this.tryEntries[o],c=i.completion;if("root"===i.tryLoc)return handle("end");if(i.tryLoc<=this.prev){var u=a.call(i,"catchLoc"),l=a.call(i,"finallyLoc");if(u&&l){if(this.prev=0;--o){var i=this.tryEntries[o];if(i.tryLoc<=this.prev&&a.call(i,"finallyLoc")&&this.prev=0;--r){var a=this.tryEntries[r];if(a.finallyLoc===t)return this.complete(a.completion,a.afterLoc),resetTryEntry(a),l}},catch:function _catch(t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc===t){var o=a.completion;if("throw"===o.type){var i=o.arg;resetTryEntry(a)}return i}}throw new Error("illegal catch attempt")},delegateYield:function delegateYield(t,r,a){return this.delegate={iterator:values(t),resultName:r,nextLoc:a},"next"===this.method&&(this.arg=void 0),l}},t}function journal_asyncGeneratorStep(t,r,a,o,i,c,u){try{var l=t[c](u),p=l.value}catch(t){return void a(t)}l.done?r(p):Promise.resolve(p).then(o,i)}function journal_asyncToGenerator(t){return function(){var r=this,a=arguments;return new Promise((function(o,i){var c=t.apply(r,a);function _next(t){journal_asyncGeneratorStep(c,o,i,_next,_throw,"next",t)}function _throw(t){journal_asyncGeneratorStep(c,o,i,_next,_throw,"throw",t)}_next(void 0)}))}}function increaseFontSize(t){return _increaseFontSize.apply(this,arguments)}function _increaseFontSize(){return(_increaseFontSize=journal_asyncToGenerator(journal_regeneratorRuntime().mark((function _callee3(t){var a,o;return journal_regeneratorRuntime().wrap((function _callee3$(i){for(;;)switch(i.prev=i.next){case 0:if(a=game.settings.get("dsa5","journalFontSizeIndex"),(o=a+1)!=r.Z.journalFontSizes.length+1){i.next=10;break}return o=0,i.next=6,game.settings.set("dsa5","journalFontSizeIndex",o);case 6:t.css("fontSize",""),(0,h.p0)(game.i18n.format("CHATNOTIFICATION.fontsize",{size:"Default "})),i.next=13;break;case 10:return i.next=12,game.settings.set("dsa5","journalFontSizeIndex",o);case 12:setOuterFontSize(t);case 13:case"end":return i.stop()}}),_callee3)})))).apply(this,arguments)}function setOuterFontSize(t){var a=game.settings.get("dsa5","journalFontSizeIndex"),o=r.Z.journalFontSizes[a-1]||14;(0,h.p0)(game.i18n.format("CHATNOTIFICATION.fontsize",{size:o})),t.css("fontSize","".concat(o,"px"))}function tokenHUD_typeof(t){return tokenHUD_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},tokenHUD_typeof(t)}function tokenHUD_createForOfIteratorHelper(t,r){var a="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!a){if(Array.isArray(t)||(a=function tokenHUD_unsupportedIterableToArray(t,r){if(!t)return;if("string"==typeof t)return tokenHUD_arrayLikeToArray(t,r);var a=Object.prototype.toString.call(t).slice(8,-1);"Object"===a&&t.constructor&&(a=t.constructor.name);if("Map"===a||"Set"===a)return Array.from(t);if("Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a))return tokenHUD_arrayLikeToArray(t,r)}(t))||r&&t&&"number"==typeof t.length){a&&(t=a);var o=0,i=function F(){};return{s:i,n:function n(){return o>=t.length?{done:!0}:{done:!1,value:t[o++]}},e:function e(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var c,u=!0,l=!1;return{s:function s(){a=a.call(t)},n:function n(){var t=a.next();return u=t.done,t},e:function e(t){l=!0,c=t},f:function f(){try{u||null==a.return||a.return()}finally{if(l)throw c}}}}function tokenHUD_arrayLikeToArray(t,r){(null==r||r>t.length)&&(r=t.length);for(var a=0,o=new Array(r);a=0;--o){var i=this.tryEntries[o],c=i.completion;if("root"===i.tryLoc)return handle("end");if(i.tryLoc<=this.prev){var u=a.call(i,"catchLoc"),l=a.call(i,"finallyLoc");if(u&&l){if(this.prev=0;--o){var i=this.tryEntries[o];if(i.tryLoc<=this.prev&&a.call(i,"finallyLoc")&&this.prev=0;--r){var a=this.tryEntries[r];if(a.finallyLoc===t)return this.complete(a.completion,a.afterLoc),resetTryEntry(a),l}},catch:function _catch(t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc===t){var o=a.completion;if("throw"===o.type){var i=o.arg;resetTryEntry(a)}return i}}throw new Error("illegal catch attempt")},delegateYield:function delegateYield(t,r,a){return this.delegate={iterator:values(t),resultName:r,nextLoc:a},"next"===this.method&&(this.arg=void 0),l}},t}function tokenHUD_defineProperty(t,r,a){return r in t?Object.defineProperty(t,r,{value:a,enumerable:!0,configurable:!0,writable:!0}):t[r]=a,t}function tokenHUD_asyncGeneratorStep(t,r,a,o,i,c,u){try{var l=t[c](u),p=l.value}catch(t){return void a(t)}l.done?r(p):Promise.resolve(p).then(o,i)}function tokenHUD_asyncToGenerator(t){return function(){var r=this,a=arguments;return new Promise((function(o,i){var c=t.apply(r,a);function _next(t){tokenHUD_asyncGeneratorStep(c,o,i,_next,_throw,"next",t)}function _throw(t){tokenHUD_asyncGeneratorStep(c,o,i,_next,_throw,"throw",t)}_next(void 0)}))}}function swarmButtons(t,r,a){if(game.user.isGM){var o=t.object.actor;if(o.isToken)if(canvas.tokens.controlled.length>=2){var i=o._id;if(!canvas.tokens.controlled.every((function(t){var r;return(null===(r=t.actor)||void 0===r?void 0:r._id)==i})))return;r.find(".col.left").prepend(swarmHud("swarm.combine"));var c=r.find('.control-icon[data-action="swarm"]');c.click((function(){!function combineSwarm(t,r){return _combineSwarm.apply(this,arguments)}(o,t.object.document),c.remove()}))}else if(o.isSwarm()){r.find(".col.left").prepend(swarmHud("swarm.split"));var u=r.find('.control-icon[data-action="swarm"]');u.click((function(){!function splitSwarm(t,r){return _splitSwarm.apply(this,arguments)}(o,t.object.document),u.remove()}))}}}var Ve=function(t){!function tokenHUD_inherits(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(r&&r.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),r&&tokenHUD_setPrototypeOf(t,r)}(SwarmDialog,Dialog);var r=tokenHUD_createSuper(SwarmDialog);function SwarmDialog(){return tokenHUD_classCallCheck(this,SwarmDialog),r.apply(this,arguments)}return function tokenHUD_createClass(t,r,a){return r&&tokenHUD_defineProperties(t.prototype,r),a&&tokenHUD_defineProperties(t,a),Object.defineProperty(t,"prototype",{writable:!1}),t}(SwarmDialog,[{key:"activateListeners",value:function activateListeners(t){tokenHUD_get(tokenHUD_getPrototypeOf(SwarmDialog.prototype),"activateListeners",this).call(this,t),t.find('input[type="range"]').change((function(t){$(t.currentTarget).closest(".row-section").find(".range-value").html($(t.currentTarget).val())}))}}]),SwarmDialog}();function swarmHud(t){return'
    ')}function _splitSwarm(){return _splitSwarm=tokenHUD_asyncToGenerator(tokenHUD_regeneratorRuntime().mark((function _callee3(t,r){var a,o;return tokenHUD_regeneratorRuntime().wrap((function _callee3$(i){for(;;)switch(i.prev=i.next){case 0:return a=Number(t.system.swarm.count)-1,i.next=3,renderTemplate("systems/dsa5/templates/dialog/swarm-split-dialog.html",{actor:t,maxSplitsize:a});case 3:o=i.sent,new Ve({title:game.i18n.localize("swarm.split"),content:o,default:"yes",buttons:{Yes:{icon:'',label:game.i18n.localize("ok"),callback:function(){var a=tokenHUD_asyncToGenerator(tokenHUD_regeneratorRuntime().mark((function _callee2(a){var o,i,c,u,l,p;return tokenHUD_regeneratorRuntime().wrap((function _callee2$(d){for(;;)switch(d.prev=d.next){case 0:return o=Number(a.find('input[type="range"]').val()),i=deepClone(r),c=Math.floor(t.system.status.wounds.value/t.system.swarm.count*o),u=t.system.status.wounds.value-c,d.next=6,t.update({"system.swarm.count":t.system.swarm.count-o,"system.status.wounds.value":u},{skipSwarmUpdate:!0});case 6:return d.next=8,canvas.scene.createEmbeddedDocuments("Token",[i]);case 8:return d.next=10,i.actor.update({"system.swarm.count":o,"system.status.wounds.value":c},{skipSwarmUpdate:!0});case 10:return l=["x","y"][Math.floor(2*Math.random())],p=Math.random()>.5?1:-1,d.next=14,canvas.scene.updateEmbeddedDocuments("Token",[tokenHUD_defineProperty({_id:i.id},l,r[l]+canvas.scene.grid.size*p)]);case 14:case"end":return d.stop()}}),_callee2)})));return function callback(t){return a.apply(this,arguments)}}()},delete:{icon:'',label:game.i18n.localize("cancel")}}}).render(!0);case 5:case"end":return i.stop()}}),_callee3)}))),_splitSwarm.apply(this,arguments)}function _combineSwarm(){return(_combineSwarm=tokenHUD_asyncToGenerator(tokenHUD_regeneratorRuntime().mark((function _callee4(t,r){var a,o,i,c,u,l,p;return tokenHUD_regeneratorRuntime().wrap((function _callee4$(t){for(;;)switch(t.prev=t.next){case 0:a=0,o=0,i=tokenHUD_createForOfIteratorHelper(canvas.tokens.controlled);try{for(i.s();!(c=i.n()).done;)l=c.value,a+=Number(null===(u=l.actor.system.swarm)||void 0===u?void 0:u.count)||1,o+=Number(l.actor.system.status.wounds.value)}catch(t){i.e(t)}finally{i.f()}return t.next=6,r.actor.update({"system.swarm.count":a,"system.status.wounds.value":o},{skipSwarmUpdate:!0});case 6:return p=canvas.tokens.controlled.map((function(t){return t.id})).filter((function(t){return t!=r.id})),t.next=9,canvas.scene.updateEmbeddedDocuments("Token",p.map((function(t){return{_id:t,x:r.x,y:r.y}})));case 9:return t.next=11,canvas.scene.deleteEmbeddedDocuments("Token",p);case 11:case"end":return t.stop()}}),_callee4)})))).apply(this,arguments)}function tokenHUD(){Hooks.on("renderTokenHUD",(function(t,r,a){ye.hide(t.object);var o=t.object.actor;o&&(!function addThirdBarToHUD(t,r,a){if(r.system.isPriest&&r.system.isMage){var o=r.system.status.karmaenergy.value,i='
    ');t.find(".col.middle").prepend(i),t.find(".bar3 input").change(function(){var t=tokenHUD_asyncToGenerator(tokenHUD_regeneratorRuntime().mark((function _callee(t){var o,i,c,u,l;return tokenHUD_regeneratorRuntime().wrap((function _callee$(p){for(;;)switch(p.prev=p.next){case 0:return o=t.currentTarget,i=o.value.trim(),c=i.startsWith("+")||i.startsWith("-"),i.startsWith("=")&&(i=i.slice(1)),u=Number(i),l=o.name.split(".").reduce((function(t,r){return t[r]}),r),p.next=8,r.update(tokenHUD_defineProperty({},o.name,c?l+u:u));case 8:a.clear();case 9:case"end":return p.stop()}}),_callee)})));return function(r){return t.apply(this,arguments)}}())}}(r,o,t),game.dsa5.apps.LightDialog&&game.dsa5.apps.LightDialog.lightHud(r,o,a),swarmButtons(t,r)),r.find('.control-icon[data-action="target"]').mousedown((function(t){2==t.button&&(game.user.updateTokenTargets([]),$(t.currentTarget).click(),t.preventDefault())})),r.find(".attribute input").off("change"),b.Z.renderTokenHUD(t,r,a)}))}var Ke=__webpack_require__(416);function keybindings_typeof(t){return keybindings_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},keybindings_typeof(t)}function keybindings_regeneratorRuntime(){keybindings_regeneratorRuntime=function _regeneratorRuntime(){return t};var t={},r=Object.prototype,a=r.hasOwnProperty,o="function"==typeof Symbol?Symbol:{},i=o.iterator||"@@iterator",c=o.asyncIterator||"@@asyncIterator",u=o.toStringTag||"@@toStringTag";function define(t,r,a){return Object.defineProperty(t,r,{value:a,enumerable:!0,configurable:!0,writable:!0}),t[r]}try{define({},"")}catch(t){define=function define(t,r,a){return t[r]=a}}function wrap(t,r,a,o){var i=r&&r.prototype instanceof Generator?r:Generator,c=Object.create(i.prototype),u=new Context(o||[]);return c._invoke=function(t,r,a){var o="suspendedStart";return function(i,c){if("executing"===o)throw new Error("Generator is already running");if("completed"===o){if("throw"===i)throw c;return doneResult()}for(a.method=i,a.arg=c;;){var u=a.delegate;if(u){var p=maybeInvokeDelegate(u,a);if(p){if(p===l)continue;return p}}if("next"===a.method)a.sent=a._sent=a.arg;else if("throw"===a.method){if("suspendedStart"===o)throw o="completed",a.arg;a.dispatchException(a.arg)}else"return"===a.method&&a.abrupt("return",a.arg);o="executing";var d=tryCatch(t,r,a);if("normal"===d.type){if(o=a.done?"completed":"suspendedYield",d.arg===l)continue;return{value:d.arg,done:a.done}}"throw"===d.type&&(o="completed",a.method="throw",a.arg=d.arg)}}}(t,a,u),c}function tryCatch(t,r,a){try{return{type:"normal",arg:t.call(r,a)}}catch(t){return{type:"throw",arg:t}}}t.wrap=wrap;var l={};function Generator(){}function GeneratorFunction(){}function GeneratorFunctionPrototype(){}var p={};define(p,i,(function(){return this}));var d=Object.getPrototypeOf,h=d&&d(d(values([])));h&&h!==r&&a.call(h,i)&&(p=h);var m=GeneratorFunctionPrototype.prototype=Generator.prototype=Object.create(p);function defineIteratorMethods(t){["next","throw","return"].forEach((function(r){define(t,r,(function(t){return this._invoke(r,t)}))}))}function AsyncIterator(t,r){function invoke(o,i,c,u){var l=tryCatch(t[o],t,i);if("throw"!==l.type){var p=l.arg,d=p.value;return d&&"object"==keybindings_typeof(d)&&a.call(d,"__await")?r.resolve(d.__await).then((function(t){invoke("next",t,c,u)}),(function(t){invoke("throw",t,c,u)})):r.resolve(d).then((function(t){p.value=t,c(p)}),(function(t){return invoke("throw",t,c,u)}))}u(l.arg)}var o;this._invoke=function(t,a){function callInvokeWithMethodAndArg(){return new r((function(r,o){invoke(t,a,r,o)}))}return o=o?o.then(callInvokeWithMethodAndArg,callInvokeWithMethodAndArg):callInvokeWithMethodAndArg()}}function maybeInvokeDelegate(t,r){var a=t.iterator[r.method];if(void 0===a){if(r.delegate=null,"throw"===r.method){if(t.iterator.return&&(r.method="return",r.arg=void 0,maybeInvokeDelegate(t,r),"throw"===r.method))return l;r.method="throw",r.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var o=tryCatch(a,t.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,l;var i=o.arg;return i?i.done?(r[t.resultName]=i.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=void 0),r.delegate=null,l):i:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,l)}function pushTryEntry(t){var r={tryLoc:t[0]};1 in t&&(r.catchLoc=t[1]),2 in t&&(r.finallyLoc=t[2],r.afterLoc=t[3]),this.tryEntries.push(r)}function resetTryEntry(t){var r=t.completion||{};r.type="normal",delete r.arg,t.completion=r}function Context(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(pushTryEntry,this),this.reset(!0)}function values(t){if(t){var r=t[i];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var o=-1,c=function next(){for(;++o=0;--o){var i=this.tryEntries[o],c=i.completion;if("root"===i.tryLoc)return handle("end");if(i.tryLoc<=this.prev){var u=a.call(i,"catchLoc"),l=a.call(i,"finallyLoc");if(u&&l){if(this.prev=0;--o){var i=this.tryEntries[o];if(i.tryLoc<=this.prev&&a.call(i,"finallyLoc")&&this.prev=0;--r){var a=this.tryEntries[r];if(a.finallyLoc===t)return this.complete(a.completion,a.afterLoc),resetTryEntry(a),l}},catch:function _catch(t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc===t){var o=a.completion;if("throw"===o.type){var i=o.arg;resetTryEntry(a)}return i}}throw new Error("illegal catch attempt")},delegateYield:function delegateYield(t,r,a){return this.delegate={iterator:values(t),resultName:r,nextLoc:a},"next"===this.method&&(this.arg=void 0),l}},t}function keybindings_asyncGeneratorStep(t,r,a,o,i,c,u){try{var l=t[c](u),p=l.value}catch(t){return void a(t)}l.done?r(p):Promise.resolve(p).then(o,i)}function keybindings(){var r;game.keybindings.register("dsa5","masterMenu",{name:"gmMenu",hint:game.i18n.localize("KEYBINDINGS.masterMenu"),editable:[{key:"KeyM"}],onDown:function onDown(){return t.Z.renderToggle(game.dsa5.apps.gameMasterMenu)},restricted:!0}),game.keybindings.register("dsa5","journalBrowser",{name:"Book.Wizard",hint:game.i18n.localize("KEYBINDINGS.journalBrowser"),editable:[{key:"KeyJ"}],onDown:function onDown(){return t.Z.renderToggle(game.dsa5.apps.journalBrowser)}}),game.keybindings.register("dsa5","library",{name:"ItemLibrary",hint:game.i18n.localize("KEYBINDINGS.library"),editable:[{key:"KeyL"}],onDown:function onDown(){return t.Z.renderToggle(game.dsa5.itemLibrary)}}),game.keybindings.register("dsa5","attacktest",{name:"attacktest",hint:game.i18n.localize("KEYBINDINGS.attack"),editable:[{key:"KeyB"}],onDown:function onDown(){return Ge.runActAttackDialog()}}),game.keybindings.register("dsa5","combatTrackerNext",{name:"COMBAT.TurnNext",hint:game.i18n.localize("COMBAT.TurnNext"),editable:[{key:"KeyN"}],onDown:function onDown(){return Je("nextTurn")}}),game.keybindings.register("dsa5","combatTrackerPrevious",{name:"COMBAT.TurnPrev",hint:game.i18n.localize("COMBAT.TurnPrev"),editable:[{key:"KeyV"}],onDown:function onDown(){return Je("previousTurn")}}),game.keybindings.register("dsa5","setTargetToUser",{name:"DIALOG.setTargetToUser",hint:game.i18n.localize("DIALOG.setTargetToUserHint"),editable:[],onDown:(r=function keybindings_asyncToGenerator(t){return function(){var r=this,a=arguments;return new Promise((function(o,i){var c=t.apply(r,a);function _next(t){keybindings_asyncGeneratorStep(c,o,i,_next,_throw,"next",t)}function _throw(t){keybindings_asyncGeneratorStep(c,o,i,_next,_throw,"throw",t)}_next(void 0)}))}}(keybindings_regeneratorRuntime().mark((function _callee(){return keybindings_regeneratorRuntime().wrap((function _callee$(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,Ke.Z0.getDialog();case 2:return t.abrupt("return",t.sent.render(!0));case 3:case"end":return t.stop()}}),_callee)}))),function onDown(){return r.apply(this,arguments)}),restricted:!0})}var Je=function combatTurn(t){var r,a;(null===(r=game.combat)||void 0===r||null===(a=r.combatant)||void 0===a?void 0:a.isOwner)&&game.combat[t]()};function dsarolls_createForOfIteratorHelper(t,r){var a="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!a){if(Array.isArray(t)||(a=function dsarolls_unsupportedIterableToArray(t,r){if(!t)return;if("string"==typeof t)return dsarolls_arrayLikeToArray(t,r);var a=Object.prototype.toString.call(t).slice(8,-1);"Object"===a&&t.constructor&&(a=t.constructor.name);if("Map"===a||"Set"===a)return Array.from(t);if("Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a))return dsarolls_arrayLikeToArray(t,r)}(t))||r&&t&&"number"==typeof t.length){a&&(t=a);var o=0,i=function F(){};return{s:i,n:function n(){return o>=t.length?{done:!0}:{done:!1,value:t[o++]}},e:function e(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var c,u=!0,l=!1;return{s:function s(){a=a.call(t)},n:function n(){var t=a.next();return u=t.done,t},e:function e(t){l=!0,c=t},f:function f(){try{u||null==a.return||a.return()}finally{if(l)throw c}}}}function dsarolls_arrayLikeToArray(t,r){(null==r||r>t.length)&&(r=t.length);for(var a=0,o=new Array(r);a=t.length?{done:!0}:{done:!1,value:t[o++]}},e:function e(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var c,u=!0,l=!1;return{s:function s(){a=a.call(t)},n:function n(){var t=a.next();return u=t.done,t},e:function e(t){l=!0,c=t},f:function f(){try{u||null==a.return||a.return()}finally{if(l)throw c}}}}function adventure_wizard_unsupportedIterableToArray(t,r){if(t){if("string"==typeof t)return adventure_wizard_arrayLikeToArray(t,r);var a=Object.prototype.toString.call(t).slice(8,-1);return"Object"===a&&t.constructor&&(a=t.constructor.name),"Map"===a||"Set"===a?Array.from(t):"Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a)?adventure_wizard_arrayLikeToArray(t,r):void 0}}function adventure_wizard_arrayLikeToArray(t,r){(null==r||r>t.length)&&(r=t.length);for(var a=0,o=new Array(r);a=0;--o){var i=this.tryEntries[o],c=i.completion;if("root"===i.tryLoc)return handle("end");if(i.tryLoc<=this.prev){var u=a.call(i,"catchLoc"),l=a.call(i,"finallyLoc");if(u&&l){if(this.prev=0;--o){var i=this.tryEntries[o];if(i.tryLoc<=this.prev&&a.call(i,"finallyLoc")&&this.prev=0;--r){var a=this.tryEntries[r];if(a.finallyLoc===t)return this.complete(a.completion,a.afterLoc),resetTryEntry(a),l}},catch:function _catch(t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc===t){var o=a.completion;if("throw"===o.type){var i=o.arg;resetTryEntry(a)}return i}}throw new Error("illegal catch attempt")},delegateYield:function delegateYield(t,r,a){return this.delegate={iterator:values(t),resultName:r,nextLoc:a},"next"===this.method&&(this.arg=void 0),l}},t}function adventure_wizard_asyncGeneratorStep(t,r,a,o,i,c,u){try{var l=t[c](u),p=l.value}catch(t){return void a(t)}l.done?r(p):Promise.resolve(p).then(o,i)}function adventure_wizard_asyncToGenerator(t){return function(){var r=this,a=arguments;return new Promise((function(o,i){var c=t.apply(r,a);function _next(t){adventure_wizard_asyncGeneratorStep(c,o,i,_next,_throw,"next",t)}function _throw(t){adventure_wizard_asyncGeneratorStep(c,o,i,_next,_throw,"throw",t)}_next(void 0)}))}}function adventure_wizard_classCallCheck(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}function adventure_wizard_defineProperties(t,r){for(var a=0;a0&&void 0!==a[0]&&a[0],r=a.length>1&&void 0!==a[1]?a[1]:{},o.next=4,adventure_wizard_get(adventure_wizard_getPrototypeOf(BookWizard.prototype),"_render",this).call(this,t,r);case 4:$(this._element).find(".library").attr("data-tooltip","Book.home"),$(this._element).find(".increaseFontSize").attr("data-tooltip","SHEET.increaseFontSize");case 6:case"end":return o.stop()}}),_callee3,this)}))),function _render(){return O.apply(this,arguments)})},{key:"_showBooks",value:function _showBooks(){this.book=null,this.bookData=null,this.selectedChapter=null,this.selectedType=null,this.journals=null,this.actors=null,this.scenes=null,this.content=void 0,this.journalIndex=null,this.fulltextsearch=!0,this.currentType=void 0,this.selectedSubChapter=void 0,this.loadPage(this._element)}},{key:"toggleBookVisibility",value:(A=adventure_wizard_asyncToGenerator(adventure_wizard_regeneratorRuntime().mark((function _callee4(t,r,a){var o,i,c,u,l,p,d,h,m;return adventure_wizard_regeneratorRuntime().wrap((function _callee4$(y){for(;;)switch(y.prev=y.next){case 0:return(o=game.settings.get("dsa5","expansionPermissions"))[t]=a,y.next=4,game.settings.set("dsa5","expansionPermissions",o);case 4:return i=this[r].find((function(r){return r.id==t})),y.next=7,fetch(i.path);case 7:return y.next=9,y.sent.json();case 9:c=y.sent,u=0,l=["actors","journal","scenes"];case 12:if(!(u').concat(t.name,"")})),$(this._element).find(".tocContent").html("
      ".concat(a.join("\n"),"
    ")),o.next=23;break;case 19:return o.next=21,this.getToc();case 21:r=o.sent,$(this._element).find(".adventureWizard > .row-section > .toc").html(r).find(".filterJournals").focus();case 23:case"end":return o.stop()}}),_callee11,this)}))),function filterToc(t){return w.apply(this,arguments)})},{key:"showJournal",value:(k=adventure_wizard_asyncToGenerator(adventure_wizard_regeneratorRuntime().mark((function _callee12(t){var r,a,o,i,c,u,l,p,d,h,m,y=this;return adventure_wizard_regeneratorRuntime().wrap((function _callee12$(g){for(;;)switch(g.prev=g.next){case 0:r="",a=adventure_wizard_createForOfIteratorHelper(t.pages),g.prev=2,a.s();case 4:if((o=a.n()).done){g.next=18;break}return i=o.value,c=t.sheet.getPageSheet(i.id),g.next=9,c.getData();case 9:return u=g.sent,g.next=12,c._renderInner(u);case 12:l=g.sent.get(),p=$(l[l.length-1]).html(),"video"==i.type&&(p='
    '.concat(p,"
    ")),r+=p;case 16:g.next=4;break;case 18:g.next=23;break;case 20:g.prev=20,g.t0=g.catch(2),a.e(g.t0);case 23:return g.prev=23,a.f(),g.finish(23);case 26:return d=this.findSceneNote(t.getFlag("dsa5","initId")),g.next=29,TextEditor.enrichHTML(r,{secrets:game.user.isGM,async:!0});case 29:h=g.sent,this.content='

    ').concat(t.name,'
    ').concat(d,'

    ').concat(h),(m=$(this._element).find(".chapter")).html(this.content),this.selectedSubChapter=t.id,$(this._element).find(".subChapter").removeClass("selected"),$(this._element).find('[data-jid="'.concat(t.id,'"]')).addClass("selected"),bindImgToCanvasDragStart(m),m.find(".documentName-link, .entity-link, .content-link").click((function(t){var r=$(t.currentTarget);y.bookData&&r.attr("data-pack")==y.bookData.journal&&(t.stopPropagation(),y.loadJournalById(r.attr("data-id")))}));case 38:case"end":return g.stop()}}),_callee12,this,[[2,20,23,26]])}))),function showJournal(t){return k.apply(this,arguments)})},{key:"findSceneNote",value:function findSceneNote(t){if(t){var r=game.journal.find((function(r){return r.getFlag("dsa5","initId")==t}));if(r&&r.sceneNote)return'')}return""}},{key:"importBook",value:(b=adventure_wizard_asyncToGenerator(adventure_wizard_regeneratorRuntime().mark((function _callee13(){return adventure_wizard_regeneratorRuntime().wrap((function _callee13$(t){for(;;)switch(t.prev=t.next){case 0:game.user.isGM&&(new Xe).render(this.bookData.moduleName);case 1:case"end":return t.stop()}}),_callee13,this)}))),function importBook(){return b.apply(this,arguments)})},{key:"loadBook",value:(v=adventure_wizard_asyncToGenerator(adventure_wizard_regeneratorRuntime().mark((function _callee16(t,r,a){var o=this;return adventure_wizard_regeneratorRuntime().wrap((function _callee16$(i){for(;;)switch(i.prev=i.next){case 0:return a||(a=this.currentType),this.currentType=a,this.book=this[a].find((function(r){return r.id==t})),i.next=5,fetch(this.book.path).then(function(){var t=adventure_wizard_asyncToGenerator(adventure_wizard_regeneratorRuntime().mark((function _callee14(t){return adventure_wizard_regeneratorRuntime().wrap((function _callee14$(r){for(;;)switch(r.prev=r.next){case 0:return r.abrupt("return",t.json());case 1:case"end":return r.stop()}}),_callee14)})));return function(r){return t.apply(this,arguments)}}()).then(function(){var t=adventure_wizard_asyncToGenerator(adventure_wizard_regeneratorRuntime().mark((function _callee15(t){var a,i;return adventure_wizard_regeneratorRuntime().wrap((function _callee15$(c){for(;;)switch(c.prev=c.next){case 0:return o.bookData=t,a=game.packs.get(t.journal),c.next=4,a.getIndex();case 4:return c.next=6,a.getDocuments();case 6:if(i=c.sent,o.journals=i,!t.actors){c.next=14;break}return a=game.packs.get(t.actors),c.next=12,a.getIndex();case 12:i=c.sent,o.actors=i;case 14:if(!t.scenes){c.next=20;break}return a=game.packs.get(t.scenes),c.next=18,a.getIndex();case 18:i=c.sent,o.scenes=i;case 20:o.checkChapters(a),o.loadPage(r);case 22:case"end":return c.stop()}}),_callee15)})));return function(r){return t.apply(this,arguments)}}());case 5:case"end":return i.stop()}}),_callee16,this)}))),function loadBook(t,r,a){return v.apply(this,arguments)})},{key:"checkChapters",value:function checkChapters(t){this.bookData.chapters||(this.bookData.isDynamic=!0,this.bookData.chapters=[{name:game.i18n.localize("".concat(this.bookData.moduleName,".name")),content:t.folders.map((function(t){return{name:t.name,id:t.id}}))}])}},{key:"prefillActors",value:(g=adventure_wizard_asyncToGenerator(adventure_wizard_regeneratorRuntime().mark((function _callee17(t){var r,a,o,i,c,u,l=this;return adventure_wizard_regeneratorRuntime().wrap((function _callee17$(p){for(;;)switch(p.prev=p.next){case 0:if(t.actors){p.next=2;break}return p.abrupt("return",[]);case 2:return r=[],p.next=5,game.folders.contents.find((function(t){return t.name==game.i18n.localize("".concat(l.bookData.moduleName,".name"))&&"Actor"==t.type&&null==t.folder}));case 5:if(!(a=p.sent)){p.next=12;break}return p.next=9,game.folders.contents.filter((function(t){var r;return"Actor"==t.type&&(null===(r=t.folder)||void 0===r?void 0:r.id)==a.id})).map((function(t){return t.id}));case 9:p.t0=p.sent,p.next=13;break;case 12:p.t0=void 0;case 13:o=p.t0,i=adventure_wizard_createForOfIteratorHelper(t.actors);try{for(u=function _loop(){var t,a,i,u=c.value,p=null!=o&&o.length?game.actors.contents.find((function(t){var r;return t.name==u&&o.includes(null===(r=t.folder)||void 0===r?void 0:r.id)})):void 0,d=void 0,h=null===(t=p)||void 0===t?void 0:t.id,m=null===(a=p)||void 0===a?void 0:a.uuid;p||(p=l.actors.find((function(t){return t.name==u})),d=l.bookData.actors,h=null===(i=p)||void 0===i?void 0:i._id,m=p?"Compendium.".concat(d,".").concat(h):void 0),r.push({name:u,actor:p,pack:d,id:h,uuid:m})},i.s();!(c=i.n()).done;)u()}catch(t){i.e(t)}finally{i.f()}return p.abrupt("return",r);case 17:case"end":return p.stop()}}),_callee17)}))),function prefillActors(t){return g.apply(this,arguments)})},{key:"popJournal",value:(y=adventure_wizard_asyncToGenerator(adventure_wizard_regeneratorRuntime().mark((function _callee18(t){return adventure_wizard_regeneratorRuntime().wrap((function _callee18$(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,fromUuid(t);case 2:r.sent.sheet.render(!0);case 4:case"end":return r.stop()}}),_callee18)}))),function popJournal(t){return y.apply(this,arguments)})},{key:"showSzene",value:(m=adventure_wizard_asyncToGenerator(adventure_wizard_regeneratorRuntime().mark((function _callee19(t){var r,a,o=arguments;return adventure_wizard_regeneratorRuntime().wrap((function _callee19$(i){for(;;)switch(i.prev=i.next){case 0:if(r=o.length>1&&void 0!==o[1]?o[1]:"activate",a=game.scenes.contents.find((function(r){return r.name==t}))){i.next=4;break}return i.abrupt("return",ui.notifications.error(game.i18n.localize("DSAError.sceneNotInitialized")));case 4:i.t0=r,i.next="activate"===i.t0?7:"view"===i.t0?9:"toggle"===i.t0?11:13;break;case 7:return a.activate(),i.abrupt("break",13);case 9:return a.view(),i.abrupt("break",13);case 11:return a.update({navigation:!a.navigation}),i.abrupt("break",13);case 13:case"end":return i.stop()}}),_callee19)}))),function showSzene(t){return m.apply(this,arguments)})},{key:"getChapter",value:(d=adventure_wizard_asyncToGenerator(adventure_wizard_regeneratorRuntime().mark((function _callee20(){var t,r,a,o,i,c,u,l=this;return adventure_wizard_regeneratorRuntime().wrap((function _callee20$(p){for(;;)switch(p.prev=p.next){case 0:if(!this.book){p.next=42;break}if(!this.content){p.next=3;break}return p.abrupt("return",this.content);case 3:if(!this.selectedChapter){p.next=37;break}if("prep"!=this.selectedChapter){p.next=14;break}t={initDescr:game.i18n.format("".concat(this.bookData.moduleName,".importContent"),{defaultText:game.i18n.localize("importDefault")})},r=this.bookData.modules,a=adventure_wizard_createForOfIteratorHelper(r);try{for(a.s();!(o=a.n()).done;)(i=o.value).enabled=this.moduleEnabled(i.id)}catch(t){a.e(t)}finally{a.f()}return p.next=11,renderTemplate("systems/dsa5/templates/wizard/adventure/adventure_preparation.html",{modules:r,info:t});case 11:case 17:case 30:case 36:case 39:case 44:return p.abrupt("return",p.sent);case 14:if("foundryUsage"!=this.selectedChapter){p.next=18;break}return p.next=17,renderTemplate("systems/dsa5/templates/wizard/adventure/adventure_foundry.html");case 18:if(c=this.bookData.chapters.find((function(t){return t.name==l.selectedType})).content.find((function(t){return t.id==l.selectedChapter})),u=this.getSubChapters(),!c.scenes&&!c.actors&&0!=u.length){p.next=33;break}return p.t0=renderTemplate,p.t1=c,p.t2=this.getSubChapters(),p.next=26,this.prefillActors(c);case 26:return p.t3=p.sent,p.t4={chapter:p.t1,subChapters:p.t2,actors:p.t3},p.next=30,(0,p.t0)("systems/dsa5/templates/wizard/adventure/adventure_chapter.html",p.t4);case 33:return this.selectedSubChapter=u[0].id,p.next=36,this.loadJournalById(u[0].id);case 37:return p.next=39,renderTemplate("systems/dsa5/templates/wizard/adventure/adventure_cover.html",{book:this.book,bookData:this.bookData});case 42:return p.next=44,renderTemplate("systems/dsa5/templates/wizard/adventure/adventure_intro.html",{rshs:this.filterBooks(this.rshs),rules:this.filterBooks(this.books),adventures:this.filterBooks(this.adventures),isGM:game.user.isGM});case 45:case"end":return p.stop()}}),_callee20,this)}))),function getChapter(){return d.apply(this,arguments)})},{key:"filterBooks",value:function filterBooks(t){var r,a=game.settings.get("dsa5","expansionPermissions"),o=adventure_wizard_createForOfIteratorHelper(t);try{for(o.s();!(r=o.n()).done;){var i=r.value;null!=a[i.id]&&(i.visible=a[i.id])}}catch(t){o.e(t)}finally{o.f()}return game.user.isGM?t:t.filter((function(t){return null==t.visible||t.visible})).sort((function(t,r){return t.id.localeCompare(r.id)}))}},{key:"getSubChapters",value:function getSubChapters(){var t=this;return(this.bookData.isDynamic?this.journals.filter((function(r){return r.folder.id==t.selectedChapter})).sort((function(t,r){return t.sort>r.sort?1:-1})):this.journals.filter((function(r){return r.flags.dsa5.parent==t.selectedChapter})).sort((function(t,r){return t.flags.dsa5.sort>r.flags.dsa5.sort?1:-1}))).map((function(r){return{name:r.name,id:r.id,cssClass:r.id==t.selectedSubChapter?"selected":""}}))}},{key:"getToc",value:(p=adventure_wizard_asyncToGenerator(adventure_wizard_regeneratorRuntime().mark((function _callee21(){var t,r,a,o,i,c=this;return adventure_wizard_regeneratorRuntime().wrap((function _callee21$(u){for(;;)switch(u.prev=u.next){case 0:if(t=[],!this.book){u.next=29;break}if(t.push.apply(t,adventure_wizard_toConsumableArray(duplicate(this.bookData.chapters))),!this.selectedChapter){u.next=24;break}a=adventure_wizard_createForOfIteratorHelper(t),u.prev=5,a.s();case 7:if((o=a.n()).done){u.next=14;break}if(i=o.value,!(r=i.content.find((function(t){return t.id==c.selectedChapter})))){u.next=12;break}return u.abrupt("break",14);case 12:u.next=7;break;case 14:u.next=19;break;case 16:u.prev=16,u.t0=u.catch(5),a.e(u.t0);case 19:return u.prev=19,a.f(),u.finish(19);case 22:r.cssClass="selected",r.subChapters=this.getSubChapters();case 24:return u.next=26,renderTemplate("systems/dsa5/templates/wizard/adventure/adventure_toc.html",{chapters:t,book:this.book,fulltextsearch:this.fulltextsearch?"on":""});case 26:return u.abrupt("return",u.sent);case 29:return u.abrupt("return",'
    ');case 30:case"end":return u.stop()}}),_callee21,this,[[5,16,19,22]])}))),function getToc(){return p.apply(this,arguments)})},{key:"loadPage",value:(l=adventure_wizard_asyncToGenerator(adventure_wizard_regeneratorRuntime().mark((function _callee22(t){var r,a;return adventure_wizard_regeneratorRuntime().wrap((function _callee22$(o){for(;;)switch(o.prev=o.next){case 0:return o.next=2,this.getChapter();case 2:return r=o.sent,o.next=5,this.getToc();case 5:a=o.sent,t.find(".toc").html(a),t.find(".chapter").html(r);case 8:case"end":return o.stop()}}),_callee22,this)}))),function loadPage(t){return l.apply(this,arguments)})},{key:"getData",value:(c=adventure_wizard_asyncToGenerator(adventure_wizard_regeneratorRuntime().mark((function _callee23(t){var a,o,i,c,u;return adventure_wizard_regeneratorRuntime().wrap((function _callee23$(l){for(;;)switch(l.prev=l.next){case 0:return l.next=2,adventure_wizard_get(adventure_wizard_getPrototypeOf(BookWizard.prototype),"getData",this).call(this,t);case 2:return a=l.sent,l.next=5,this.getChapter();case 5:return o=l.sent,l.next=8,this.getToc();case 8:return i=l.sent,c=game.settings.get("dsa5","journalFontSizeIndex"),u=r.Z.journalFontSizes[c-1]||14,mergeObject(a,{adventure:this.bookData,currentChapter:o,breadcrumbs:this.renderBreadcrumbs(),toc:i,fontSize:u}),l.abrupt("return",a);case 13:case"end":return l.stop()}}),_callee23,this)}))),function getData(t){return c.apply(this,arguments)})},{key:"pinJournal",value:(i=adventure_wizard_asyncToGenerator(adventure_wizard_regeneratorRuntime().mark((function _callee24(t){var r,a,o,i=arguments;return adventure_wizard_regeneratorRuntime().wrap((function _callee24$(c){for(;;)switch(c.prev=c.next){case 0:if(a=i.length>1&&void 0!==i[1]?i[1]:void 0,o=this.readBreadCrumbs(),a){c.next=18;break}return c.next=5,fromUuid(t);case 5:if(c.t2=r=c.sent,c.t1=null===c.t2,c.t1){c.next=9;break}c.t1=void 0===r;case 9:if(!c.t1){c.next=13;break}c.t3=void 0,c.next=14;break;case 13:c.t3=r.name;case 14:if(c.t0=c.t3,c.t0){c.next=17;break}c.t0="";case 17:a=c.t0;case 18:o[t]=a,game.settings.set("dsa5","breadcrumbs_".concat(game.world.id),JSON.stringify(o)),this.render(!0);case 21:case"end":return c.stop()}}),_callee24,this)}))),function pinJournal(t){return i.apply(this,arguments)})},{key:"unpinJournal",value:function unpinJournal(t){var r=this.readBreadCrumbs();delete r[t],game.settings.set("dsa5","breadcrumbs_".concat(game.world.id),JSON.stringify(r)),this.render(!0)}},{key:"_canDragDrop",value:function _canDragDrop(t){return!0}},{key:"_onDrop",value:(o=adventure_wizard_asyncToGenerator(adventure_wizard_regeneratorRuntime().mark((function _callee25(t){var r;return adventure_wizard_regeneratorRuntime().wrap((function _callee25$(a){for(;;)switch(a.prev=a.next){case 0:a.prev=0,r=JSON.parse(t.dataTransfer.getData("text/plain")),a.next=7;break;case 4:return a.prev=4,a.t0=a.catch(0),a.abrupt("return",!1);case 7:"JournalEntry"==r.type&&this.pinJournal(r.pack?"Compendium.".concat(r.pack,".").concat(r.id):"JournalEntry.".concat(r.id));case 8:case"end":return a.stop()}}),_callee25,this,[[0,4]])}))),function _onDrop(t){return o.apply(this,arguments)})},{key:"readBreadCrumbs",value:function readBreadCrumbs(){var t={};try{t=JSON.parse(game.settings.get("dsa5","breadcrumbs_".concat(game.world.id)))}catch(t){console.log("No Journalbrowser notes found")}return t}},{key:"renderBreadcrumbs",value:function renderBreadcrumbs(){var t=this.readBreadCrumbs(),r=Object.entries(t).map((function(t){return'
    ').concat(t[1],"
    ")}));return r.length>0?'"):""}},{key:"moduleEnabled",value:function moduleEnabled(r){return t.Z.moduleEnabled(r)}}],[{key:"defaultOptions",get:function get(){var t=adventure_wizard_get(adventure_wizard_getPrototypeOf(BookWizard),"defaultOptions",this);return t.tabs=[{navSelector:".tabs",contentSelector:".content",initial:"description"}],mergeObject(t,{classes:t.classes.concat(["dsa5","largeDialog","noscrollWizard","bookWizardsheet"]),width:800,height:880,template:"systems/dsa5/templates/wizard/adventure/adventure_wizard.html",title:game.i18n.localize("Book.Wizard"),resizable:!0,dragDrop:[{dragSelector:".item-list .item",dropSelector:null}]}),t}},{key:"initHook",value:function initHook(){BookWizard.wizard=new BookWizard,game.dsa5.apps.journalBrowser=BookWizard.wizard,Hooks.on("renderJournalDirectory",(function(t,r){var a=$('
    '),o=$('"));o.click((function(){BookWizard.wizard.render(!0)})),a.append(o),r.find(".header-actions:first-child").after(a)}))}}]),BookWizard}();!function adventure_wizard_defineProperty(t,r,a){return r in t?Object.defineProperty(t,r,{value:a,enumerable:!0,configurable:!0,writable:!0}):t[r]=a,t}(Qe,"wizard",void 0);var Xe=function(t){adventure_wizard_inherits(InitializerForm,FormApplication);var r=adventure_wizard_createSuper(InitializerForm);function InitializerForm(){return adventure_wizard_classCallCheck(this,InitializerForm),r.apply(this,arguments)}return adventure_wizard_createClass(InitializerForm,[{key:"render",value:function render(t){new game.dsa5.apps.DSA5Initializer("DSA5 Module Initialization",game.i18n.format("".concat(t,".importContent"),{defaultText:game.i18n.localize("importDefault")}),t,game.i18n.lang).render(!0)}}]),InitializerForm}(),et=function(){function JournalSearch(t){adventure_wizard_classCallCheck(this,JournalSearch);var r=t.pages.find((function(t){return!0})).text.content;this.document={name:t.name,data:$("
    ").html(r).text(),id:t.id}}return adventure_wizard_createClass(JournalSearch,[{key:"name",get:function get(){return this.document.name}},{key:"data",get:function get(){return this.document.data}},{key:"id",get:function get(){return this.document.id}}]),JournalSearch}(),tt=__webpack_require__(5);function masters_menu_typeof(t){return masters_menu_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},masters_menu_typeof(t)}function masters_menu_slicedToArray(t,r){return function masters_menu_arrayWithHoles(t){if(Array.isArray(t))return t}(t)||function masters_menu_iterableToArrayLimit(t,r){var a=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null==a)return;var o,i,c=[],u=!0,l=!1;try{for(a=a.call(t);!(u=(o=a.next()).done)&&(c.push(o.value),!r||c.length!==r);u=!0);}catch(t){l=!0,i=t}finally{try{u||null==a.return||a.return()}finally{if(l)throw i}}return c}(t,r)||masters_menu_unsupportedIterableToArray(t,r)||function masters_menu_nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function masters_menu_createForOfIteratorHelper(t,r){var a="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!a){if(Array.isArray(t)||(a=masters_menu_unsupportedIterableToArray(t))||r&&t&&"number"==typeof t.length){a&&(t=a);var o=0,i=function F(){};return{s:i,n:function n(){return o>=t.length?{done:!0}:{done:!1,value:t[o++]}},e:function e(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var c,u=!0,l=!1;return{s:function s(){a=a.call(t)},n:function n(){var t=a.next();return u=t.done,t},e:function e(t){l=!0,c=t},f:function f(){try{u||null==a.return||a.return()}finally{if(l)throw c}}}}function masters_menu_unsupportedIterableToArray(t,r){if(t){if("string"==typeof t)return masters_menu_arrayLikeToArray(t,r);var a=Object.prototype.toString.call(t).slice(8,-1);return"Object"===a&&t.constructor&&(a=t.constructor.name),"Map"===a||"Set"===a?Array.from(t):"Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a)?masters_menu_arrayLikeToArray(t,r):void 0}}function masters_menu_arrayLikeToArray(t,r){(null==r||r>t.length)&&(r=t.length);for(var a=0,o=new Array(r);a=0;--o){var i=this.tryEntries[o],c=i.completion;if("root"===i.tryLoc)return handle("end");if(i.tryLoc<=this.prev){var u=a.call(i,"catchLoc"),l=a.call(i,"finallyLoc");if(u&&l){if(this.prev=0;--o){var i=this.tryEntries[o];if(i.tryLoc<=this.prev&&a.call(i,"finallyLoc")&&this.prev=0;--r){var a=this.tryEntries[r];if(a.finallyLoc===t)return this.complete(a.completion,a.afterLoc),resetTryEntry(a),l}},catch:function _catch(t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc===t){var o=a.completion;if("throw"===o.type){var i=o.arg;resetTryEntry(a)}return i}}throw new Error("illegal catch attempt")},delegateYield:function delegateYield(t,r,a){return this.delegate={iterator:values(t),resultName:r,nextLoc:a},"next"===this.method&&(this.arg=void 0),l}},t}function masters_menu_asyncGeneratorStep(t,r,a,o,i,c,u){try{var l=t[c](u),p=l.value}catch(t){return void a(t)}l.done?r(p):Promise.resolve(p).then(o,i)}function masters_menu_asyncToGenerator(t){return function(){var r=this,a=arguments;return new Promise((function(o,i){var c=t.apply(r,a);function _next(t){masters_menu_asyncGeneratorStep(c,o,i,_next,_throw,"next",t)}function _throw(t){masters_menu_asyncGeneratorStep(c,o,i,_next,_throw,"throw",t)}_next(void 0)}))}}function masters_menu_get(){return masters_menu_get="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function _get(t,r,a){var o=masters_menu_superPropBase(t,r);if(o){var i=Object.getOwnPropertyDescriptor(o,r);return i.get?i.get.call(arguments.length<3?t:a):i.value}},masters_menu_get.apply(this,arguments)}function masters_menu_superPropBase(t,r){for(;!Object.prototype.hasOwnProperty.call(t,r)&&null!==(t=masters_menu_getPrototypeOf(t)););return t}function masters_menu_inherits(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(r&&r.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),r&&masters_menu_setPrototypeOf(t,r)}function masters_menu_setPrototypeOf(t,r){return masters_menu_setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function _setPrototypeOf(t,r){return t.__proto__=r,t},masters_menu_setPrototypeOf(t,r)}function masters_menu_createSuper(t){var r=function masters_menu_isNativeReflectConstruct(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function _createSuperInternal(){var a,o=masters_menu_getPrototypeOf(t);if(r){var i=masters_menu_getPrototypeOf(this).constructor;a=Reflect.construct(o,arguments,i)}else a=o.apply(this,arguments);return masters_menu_possibleConstructorReturn(this,a)}}function masters_menu_possibleConstructorReturn(t,r){if(r&&("object"===masters_menu_typeof(r)||"function"==typeof r))return r;if(void 0!==r)throw new TypeError("Derived constructors may only return object or undefined");return function masters_menu_assertThisInitialized(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}function masters_menu_getPrototypeOf(t){return masters_menu_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function _getPrototypeOf(t){return t.__proto__||Object.getPrototypeOf(t)},masters_menu_getPrototypeOf(t)}function masters_menu_classCallCheck(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}function masters_menu_defineProperties(t,r){for(var a=0;a0&&void 0!==a[0]&&a[0],r=a.length>1&&void 0!==a[1]?a[1]:{},game.user.isGM){o.next=4;break}return o.abrupt("return",ui.notifications.error("DSAError.onlyGMallowed"));case 4:return o.next=6,masters_menu_get(masters_menu_getPrototypeOf(GameMasterMenu.prototype),"_render",this).call(this,t,r);case 6:case"end":return o.stop()}}),_callee3,this)}))),function _render(){return A.apply(this,arguments)})},{key:"getSelectedActors",value:function getSelectedActors(){for(var t=game.settings.get("dsa5","selectedActors"),r=game.settings.get("dsa5","trackedActors"),a={},o=0,i=Object.keys(t);o-1)){i.next=10;break}return a.splice(o,1),i.next=9,game.settings.set("dsa5","trackedActors",{actors:a});case 9:this.render(!0);case 10:case"end":return i.stop()}}),_callee9,this)}))),function _deleteHero(t){return T.apply(this,arguments)})},{key:"updateHeroOrder",value:(S=masters_menu_asyncToGenerator(masters_menu_regeneratorRuntime().mark((function _callee10(t){var r,a,o,i;return masters_menu_regeneratorRuntime().wrap((function _callee10$(c){for(;;)switch(c.prev=c.next){case 0:r=[],a=masters_menu_createForOfIteratorHelper(t.querySelectorAll(".hero"));try{for(a.s();!(o=a.n()).done;)i=o.value,r.push(i.dataset.id)}catch(t){a.e(t)}finally{a.f()}return c.next=5,game.settings.set("dsa5","trackedActors",{actors:r});case 5:case"end":return c.stop()}}),_callee10)}))),function updateHeroOrder(t){return S.apply(this,arguments)})},{key:"updateDarkness",value:(x=masters_menu_asyncToGenerator(masters_menu_regeneratorRuntime().mark((function _callee11(t){return masters_menu_regeneratorRuntime().wrap((function _callee11$(r){for(;;)switch(r.prev=r.next){case 0:canvas.scene&&canvas.scene.update({darkness:Number(t.currentTarget.value)},{animateDarkness:3e3});case 1:case"end":return r.stop()}}),_callee11)}))),function updateDarkness(t){return x.apply(this,arguments)})},{key:"updateSightThreshold",value:(k=masters_menu_asyncToGenerator(masters_menu_regeneratorRuntime().mark((function _callee12(t){var r,a,o;return masters_menu_regeneratorRuntime().wrap((function _callee12$(i){for(;;)switch(i.prev=i.next){case 0:return r=Number(t.currentTarget.dataset.index),a=Number(t.currentTarget.value),(o=game.settings.get("dsa5","sightOptions").split("|"))[r]=a,i.next=6,game.settings.set("dsa5","sightOptions",o.join("|"));case 6:case"end":return i.stop()}}),_callee12)}))),function updateSightThreshold(t){return k.apply(this,arguments)})},{key:"getGroupSchipSetting",value:function getGroupSchipSetting(){return game.settings.get("dsa5","groupschips").split("/").map((function(t){return Number(t)}))}},{key:"changeGroupSchipCount",value:(b=masters_menu_asyncToGenerator(masters_menu_regeneratorRuntime().mark((function _callee13(t){var r;return masters_menu_regeneratorRuntime().wrap((function _callee13$(a){for(;;)switch(a.prev=a.next){case 0:return(r=this.getGroupSchipSetting())[1]=Math.max(0,r[1]+t),r[0]=Math.min(r[1],r[0]),a.next=5,game.settings.set("dsa5","groupschips",r.join("/"));case 5:case"end":return a.stop()}}),_callee13,this)}))),function changeGroupSchipCount(t){return b.apply(this,arguments)})},{key:"changeGroupSchip",value:(_=masters_menu_asyncToGenerator(masters_menu_regeneratorRuntime().mark((function _callee14(t){var r,a;return masters_menu_regeneratorRuntime().wrap((function _callee14$(o){for(;;)switch(o.prev=o.next){case 0:return 1==(r=Number(t.currentTarget.getAttribute("data-val")))&&1==$(t.currentTarget).closest(".col").find(".fullSchip").length&&(r=0),(a=this.getGroupSchipSetting())[0]=r,o.next=6,game.settings.set("dsa5","groupschips",a.join("/"));case 6:case"end":return o.stop()}}),_callee14,this)}))),function changeGroupSchip(t){return _.apply(this,arguments)})},{key:"_randomPlayer",value:(v=masters_menu_asyncToGenerator(masters_menu_regeneratorRuntime().mark((function _callee15(t,r){var a,o,i=this;return masters_menu_regeneratorRuntime().wrap((function _callee15$(c){for(;;)switch(c.prev=c.next){case 0:return a=t.find(".hero"),c.next=3,this.rollRandomPlayer(2==r.button);case 3:o=c.sent,$(r.currentTarget).find("i").addClass("fa-spin"),a.removeClass("victim"),setTimeout((function(){$(i._element).find('.hero[data-id="'.concat(o,'"]')).addClass("victim"),$(r.currentTarget).find("i").removeClass("fa-spin")}),500);case 7:case"end":return c.stop()}}),_callee15,this)}))),function _randomPlayer(t,r){return v.apply(this,arguments)})},{key:"rollRandomPlayer",value:(g=masters_menu_asyncToGenerator(masters_menu_regeneratorRuntime().mark((function _callee16(t){var r,o,i,c,u,l,p,d,h;return masters_menu_regeneratorRuntime().wrap((function _callee16$(m){for(;;)switch(m.prev=m.next){case 0:if(r={},o=1,i=this.getSelectedActors(),c=0!=Object.values(i).filter((function(t){return t})).length,!this.heros.length){m.next=8;break}m.t0=this.heros,m.next=11;break;case 8:return m.next=10,this.getTrackedHeros();case 10:m.t0=m.sent;case 11:u=m.t0,l=masters_menu_createForOfIteratorHelper(u),m.prev=13,l.s();case 15:if((p=l.n()).done){m.next=25;break}if(d=p.value,i[d.id]||!c){m.next=19;break}return m.abrupt("continue",23);case 19:r[o]=d.id,o++,t&&a.Z.hasVantage(d,game.i18n.localize("LocalizedIDs.misfortune"))&&(r[o]=d.id,o++),t&&d.hasCondition("badluck")&&(r[o]=d.id,o++);case 23:m.next=15;break;case 25:m.next=30;break;case 27:m.prev=27,m.t1=m.catch(13),l.e(m.t1);case 30:return m.prev=30,l.f(),m.finish(30);case 33:return m.next=35,new Roll("1d".concat(o-1)).evaluate({async:!0});case 35:return h=m.sent.total,m.abrupt("return",r[h]);case 37:case"end":return m.stop()}}),_callee16,this,[[13,27,30,33]])}))),function rollRandomPlayer(t){return g.apply(this,arguments)})},{key:"doPayment",value:(m=masters_menu_asyncToGenerator(masters_menu_regeneratorRuntime().mark((function _callee17(t,r){var a,o,i,c;return masters_menu_regeneratorRuntime().wrap((function _callee17$(u){for(;;)switch(u.prev=u.next){case 0:return a=game.actors.filter((function(r){return t.includes(r.id)})),o=this.getNames(a),u.next=4,renderTemplate("systems/dsa5/templates/dialog/master-dialog-award.html",{text:game.i18n.localize(game.i18n.format(r?"MASTER.payText":"MASTER.getPaidText",{heros:o}))});case 4:i=u.sent,c=function callback(t){var o,i=t.find(".input-text").val(),c=masters_menu_createForOfIteratorHelper(a);try{for(c.s();!(o=c.n()).done;){var u=o.value;w.handlePayAction(void 0,r,i,u)}}catch(t){c.e(t)}finally{c.f()}},this.buildDialog(game.i18n.localize(r?"MASTER.payTT":"PAYMENT.payButton"),i,c);case 7:case"end":return u.stop()}}),_callee17,this)}))),function doPayment(t,r){return m.apply(this,arguments)})},{key:"getPaid",value:(d=masters_menu_asyncToGenerator(masters_menu_regeneratorRuntime().mark((function _callee18(t){return masters_menu_regeneratorRuntime().wrap((function _callee18$(r){for(;;)switch(r.prev=r.next){case 0:this.doPayment(t,!1);case 1:case"end":return r.stop()}}),_callee18,this)}))),function getPaid(t){return d.apply(this,arguments)})},{key:"getExp",value:(p=masters_menu_asyncToGenerator(masters_menu_regeneratorRuntime().mark((function _callee20(r){var a,o,i,c=this;return masters_menu_regeneratorRuntime().wrap((function _callee20$(u){for(;;)switch(u.prev=u.next){case 0:return a=game.actors.filter((function(t){return r.includes(t.id)})),u.next=3,renderTemplate("systems/dsa5/templates/dialog/master-dialog-award.html",{text:game.i18n.localize(game.i18n.format("MASTER.awardXPText",{heros:this.getNames(a)}))});case 3:o=u.sent,i=function(){var r=masters_menu_asyncToGenerator(masters_menu_regeneratorRuntime().mark((function _callee19(r){var o,i,u,l,p,d,h,m;return masters_menu_regeneratorRuntime().wrap((function _callee19$(y){for(;;)switch(y.prev=y.next){case 0:if(o=Number(r.find(".input-text").val()),i=Math.max(1,Math.round(.25*o)),u=[],l=[],isNaN(o)){y.next=30;break}p=masters_menu_createForOfIteratorHelper(a),y.prev=6,p.s();case 8:if((d=p.n()).done){y.next=16;break}return h=d.value,m=o,h.system.isFamiliar||h.system.isPet?(m=i,l.push(h)):u.push(h),y.next=14,h.update({"system.details.experience.total":h.system.details.experience.total+m});case 14:y.next=8;break;case 16:y.next=21;break;case 18:y.prev=18,y.t0=y.catch(6),p.e(y.t0);case 21:return y.prev=21,p.f(),y.finish(21);case 24:if(!(u.length>0)){y.next=27;break}return y.next=27,ChatMessage.create(t.Z.chatDataSetup(game.i18n.format("MASTER.xpMessage",{heros:c.getNames(u),number:o})));case 27:if(!(l.length>0)){y.next=30;break}return y.next=30,ChatMessage.create(t.Z.chatDataSetup(game.i18n.format("MASTER.xpMessage",{heros:c.getNames(l),number:o})));case 30:case"end":return y.stop()}}),_callee19,null,[[6,18,21,24]])})));return function callback(t){return r.apply(this,arguments)}}(),this.buildDialog(game.i18n.localize("MASTER.awardXP"),o,i);case 6:case"end":return u.stop()}}),_callee20,this)}))),function getExp(t){return p.apply(this,arguments)})},{key:"getNames",value:function getNames(t){return t.map((function(t){return t.name})).join(", ")}},{key:"buildDialog",value:function buildDialog(t,r,a){new tt.Z({title:t,content:r,default:"yes",buttons:{Yes:{icon:'',label:game.i18n.localize("yes"),callback:function callback(t){a(t)}},cancel:{icon:'',label:game.i18n.localize("cancel")}}}).render(!0)}},{key:"_canDragDrop",value:function _canDragDrop(t){return!0}},{key:"_onDrop",value:(l=masters_menu_asyncToGenerator(masters_menu_regeneratorRuntime().mark((function _callee21(t){var r,a;return masters_menu_regeneratorRuntime().wrap((function _callee21$(o){for(;;)switch(o.prev=o.next){case 0:return o.prev=0,r=JSON.parse(t.dataTransfer.getData("text/plain")),o.next=4,Actor.implementation.fromDropData(r);case 4:r=o.sent,o.next=10;break;case 7:return o.prev=7,o.t0=o.catch(0),o.abrupt("return",!1);case 10:if("Actor"!=r.documentName){o.next=18;break}if(-1!=(a=(a=game.settings.get("dsa5","trackedActors")).actors||[]).indexOf(r.id)||r.pack){o.next=18;break}return a.push(r.id),o.next=17,game.settings.set("dsa5","trackedActors",{actors:a});case 17:this.render(!0);case 18:case"end":return o.stop()}}),_callee21,this,[[0,7]])}))),function _onDrop(t){return l.apply(this,arguments)})},{key:"selectedIDs",value:function selectedIDs(){for(var t=[],r=this.getSelectedActors(),a=0,o=Object.entries(r);a0)){a.next=6;break}r=game.actors.filter((function(r){return t.actors.includes(r.id)})).sort((function(r,a){return t.actors.indexOf(r.id)-t.actors.indexOf(a.id)})),a.next=9;break;case 6:return r=game.actors.filter((function(t){return t.hasPlayerOwner})),a.next=9,game.settings.set("dsa5","trackedActors",{actors:r.map((function(t){return t.id}))});case 9:return a.abrupt("return",r);case 10:case"end":return a.stop()}}),_callee24)}))),function getTrackedHeros(){return i.apply(this,arguments)})},{key:"getData",value:(o=masters_menu_asyncToGenerator(masters_menu_regeneratorRuntime().mark((function _callee25(r){var a,o,i,c,u,l,p,d,h,m,g,v,_,b;return masters_menu_regeneratorRuntime().wrap((function _callee25$(k){for(;;)switch(k.prev=k.next){case 0:return k.next=2,masters_menu_get(masters_menu_getPrototypeOf(GameMasterMenu.prototype),"getData",this).call(this,r);case 2:return o=k.sent,k.next=5,this.getTrackedHeros();case 5:i=k.sent,c=y.Z.getGroupSchips(),u=game.settings.get("dsa5","sightOptions").split("|"),l=/ \[[a-zA-Zäöü\d-]+\]/,p=[1,2,3,4].map((function(t){return{label:game.i18n.localize("VisionDisruption.step".concat(t)).replace(l,""),value:u[t-1]}})),o.sceneConfig={sceneAutomationEnabled:game.settings.get("dsa5","sightAutomationEnabled"),enableDPS:game.settings.get("dsa5","enableDPS"),lightSightCompensationEnabled:game.settings.get("dsa5","lightSightCompensationEnabled"),visions:p,darkness:(null===(a=canvas.scene)||void 0===a?void 0:a.darkness)||0},this.heros=i,d=this.getSelectedActors(),h=[],m=masters_menu_createForOfIteratorHelper(i);try{for(m.s();!(g=m.n()).done;)v=g.value,_=duplicate(v),mergeObject(_,{id:v.id,uuid:v.uuid,selected:d[v.id],schips:v.schipshtml(),purse:v.items.filter((function(t){return"money"==t.type})).sort((function(t,r){return r.system.price.value-t.system.price.value})).map((function(t){return'').concat(t.system.quantity.value,"")})).join(" - "),advantages:v.items.filter((function(t){return"advantage"==t.type})).map((function(t){return{name:t.name,uuid:t.uuid}})),disadvantages:v.items.filter((function(t){return"disadvantage"==t.type})).map((function(t){return{name:t.name,uuid:t.uuid}})),system:{status:{wounds:{max:v.system.status.wounds.max},astralenergy:{max:v.system.status.astralenergy.max},karmaenergy:{max:v.system.status.karmaenergy.max}},isMage:v.system.isMage,isPriest:v.system.isPriest}}),h.push(_)}catch(t){m.e(t)}finally{m.f()}if(this.abilities){k.next=21;break}return k.next=19,t.Z.allSkillsList();case 19:b=k.sent,this.abilities=b.map((function(t){return{name:t,type:"skill"}})).concat(Object.values(game.dsa5.config.characteristics).map((function(t){return{name:game.i18n.localize(t),type:"attribute"}})).concat({name:game.i18n.localize("regenerate"),type:"regeneration"})).sort((function(t,r){return t.name.localeCompare(r.name)}));case 21:if(k.t0=mergeObject,k.t1=o,k.t2=h,k.t3=this.abilities,k.t4=c,k.t5=this.lastSkill,k.t6=this.randomCreation.map((function(t){return t.template})),!game.dsa5.apps.LightDialog){k.next=34;break}return k.next=31,game.dsa5.apps.LightDialog.getButtonHTML();case 31:k.t7=k.sent,k.next=35;break;case 34:k.t7="";case 35:return k.t8=k.t7,k.t9={heros:k.t2,abilities:k.t3,groupschips:k.t4,lastSkill:k.t5,randomCreation:k.t6,lightButton:k.t8},(0,k.t0)(k.t1,k.t9),k.abrupt("return",o);case 39:case"end":return k.stop()}}),_callee25,this)}))),function getData(t){return o.apply(this,arguments)})},{key:"registerRandomCreation",value:function registerRandomCreation(t){this.randomCreation.push(t)}}],[{key:"defaultOptions",get:function get(){var t=masters_menu_get(masters_menu_getPrototypeOf(GameMasterMenu),"defaultOptions",this);return t.tabs=[{navSelector:".tabs",contentSelector:".content",initial:"main"}],mergeObject(t,{classes:t.classes.concat(["dsa5","largeDialog","masterMenu","sheet"]),width:470,height:740,title:game.i18n.localize("gmMenu"),dragDrop:[{dragSelector:null,dropSelector:null}]}),t.template="systems/dsa5/templates/system/mastermenu.html",t.resizable=!0,t}}]),GameMasterMenu}();function creature_merchant_sheet_typeof(t){return creature_merchant_sheet_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},creature_merchant_sheet_typeof(t)}function creature_merchant_sheet_classCallCheck(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}function creature_merchant_sheet_defineProperties(t,r){for(var a=0;a=0;--o){var i=this.tryEntries[o],c=i.completion;if("root"===i.tryLoc)return handle("end");if(i.tryLoc<=this.prev){var u=a.call(i,"catchLoc"),l=a.call(i,"finallyLoc");if(u&&l){if(this.prev=0;--o){var i=this.tryEntries[o];if(i.tryLoc<=this.prev&&a.call(i,"finallyLoc")&&this.prev=0;--r){var a=this.tryEntries[r];if(a.finallyLoc===t)return this.complete(a.completion,a.afterLoc),resetTryEntry(a),l}},catch:function _catch(t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc===t){var o=a.completion;if("throw"===o.type){var i=o.arg;resetTryEntry(a)}return i}}throw new Error("illegal catch attempt")},delegateYield:function delegateYield(t,r,a){return this.delegate={iterator:values(t),resultName:r,nextLoc:a},"next"===this.method&&(this.arg=void 0),l}},t}function init_asyncGeneratorStep(t,r,a,o,i,c,u){try{var l=t[c](u),p=l.value}catch(t){return void a(t)}l.done?r(p):Promise.resolve(p).then(o,i)}function init_asyncToGenerator(t){return function(){var r=this,a=arguments;return new Promise((function(o,i){var c=t.apply(r,a);function _next(t){init_asyncGeneratorStep(c,o,i,_next,_throw,"next",t)}function _throw(t){init_asyncGeneratorStep(c,o,i,_next,_throw,"throw",t)}_next(void 0)}))}}function init_classCallCheck(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}function init_defineProperties(t,r){for(var a=0;a0&&void 0!==r[0]?r[0]:{},["de","en"].includes(game.i18n.lang)){a.next=3;break}return a.abrupt("return");case 3:return a.abrupt("return",init_get(init_getPrototypeOf(ForbiddenLanguageDialog.prototype),"close",this).call(this,t));case 4:case"end":return a.stop()}}),_callee,this)}))),function close(){return r.apply(this,arguments)})}]),ForbiddenLanguageDialog}(),ut=function showForbiddenLanguageDialog(){var t,r,a,o={title:game.i18n.localize("language"),content:"

    Your foundry language is not supported by this system. Due to technical reasons your foundry language setting has to be switched to either english or german.

    ",buttons:{de:{icon:'',label:"en",callback:(a=init_asyncToGenerator(init_regeneratorRuntime().mark((function _callee2(){return init_regeneratorRuntime().wrap((function _callee2$(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,game.settings.set("core","language","de");case 2:foundry.utils.debouncedReload();case 3:case"end":return t.stop()}}),_callee2)}))),function callback(){return a.apply(this,arguments)})},en:{icon:'',label:"de",callback:(r=init_asyncToGenerator(init_regeneratorRuntime().mark((function _callee3(){return init_regeneratorRuntime().wrap((function _callee3$(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,game.settings.set("core","language","en");case 2:foundry.utils.debouncedReload();case 3:case"end":return t.stop()}}),_callee3)}))),function callback(){return r.apply(this,arguments)})},logout:{icon:'',label:game.i18n.localize("SETTINGS.Logout"),callback:(t=init_asyncToGenerator(init_regeneratorRuntime().mark((function _callee4(){return init_regeneratorRuntime().wrap((function _callee4$(t){for(;;)switch(t.prev=t.next){case 0:ui.menu.items.logout.onClick();case 1:case"end":return t.stop()}}),_callee4)}))),function callback(){return t.apply(this,arguments)})}}};new st(o).render(!0)},lt=function showWrongLanguageDialog(t){var r,a={title:game.i18n.localize("DSASETTINGS.forceLanguage"),content:game.i18n.format("DSAError.wrongLanguage",{lang:t}),buttons:{ok:{icon:'',label:game.i18n.localize("ok"),callback:(r=init_asyncToGenerator(init_regeneratorRuntime().mark((function _callee5(){return init_regeneratorRuntime().wrap((function _callee5$(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,game.settings.set("core","language",t);case 2:foundry.utils.debouncedReload();case 3:case"end":return r.stop()}}),_callee5)}))),function callback(){return r.apply(this,arguments)})},cancel:{icon:'',label:game.i18n.localize("cancel")}}};new Dialog(a).render(!0)};var ft=function(t){init_inherits(DaylightIlluminationShader,AdaptiveIlluminationShader);var r=init_createSuper(DaylightIlluminationShader);function DaylightIlluminationShader(){return init_classCallCheck(this,DaylightIlluminationShader),r.apply(this,arguments)}return init_createClass(DaylightIlluminationShader)}();function macroControl_defineProperties(t,r){for(var a=0;a1&&void 0!==arguments[1]?arguments[1]:0;Oe.Z.showRQMessage(t,r)}},{key:"requestGC",value:function requestGC(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};Oe.Z.showGCMessage(t,r,a)}},{key:"rollCh",value:function rollCh(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};c.Z.check3D20(void 0,t,r)}},{key:"itemMacroById",value:function itemMacroById(t,r,a,o){var i=game.actors.get(t),c=i?i.items.find((function(t){return t.name===r&&t.type==a})):null;this.runItem(i,c,r,o)}},{key:"itemMacro",value:function itemMacro(t,r,a){var o,i=ChatMessage.getSpeaker();i.token&&(o=game.actors.tokens[i.token]),o||(o=game.actors.get(i.actor));var c=o?o.items.find((function(a){return a.name===t&&a.type==r})):null;this.runItem(o,c,t,a,i.token)}},{key:"charMacroById",value:function charMacroById(t,r){var a=game.actors.get(r);this.runChar(a,t)}},{key:"charMacro",value:function charMacro(t){var r,a=ChatMessage.getSpeaker();a.token&&(r=game.actors.tokens[a.token]),r||(r=game.actors.get(a.actor)),this.runChar(r,t,a.token)}},{key:"runWeaponless",value:function runWeaponless(t,r,a){if(!t)return ui.notifications.error(game.i18n.format("DSAError.MacroItemMissing",{item:r}));var o=r.split("Weaponless")[0];t.setupWeaponless(o,{},a).then((function(r){t.basicTest(r)}))}},{key:"runChar",value:function runChar(t,r,a){if(!t)return ui.notifications.error(game.i18n.format("DSAError.MacroItemMissing",{item:r}));t.setupDodge({},a).then((function(r){t.basicTest(r)}))}},{key:"runItem",value:function runItem(t,r,a,o,i){if(!t)return ui.notifications.error(game.i18n.format("DSAError.MacroItemMissing",{item:a}));switch(r.type){case"combatskill":case"trait":case"meleeweapon":return t.setupWeapon(r,o.mod,o,i).then((function(r){t.basicTest(r)}));case"rangeweapon":return t.setupWeapon(r,"attack",o,i).then((function(r){t.basicTest(r)}));case"skill":return t.setupSkill(r,o,i).then((function(r){t.basicTest(r)}));case"ceremony":case"ritual":case"spell":case"liturgy":return t.setupSpell(r,o,i).then((function(r){t.basicTest(r)}))}}}]),MacroDSA5}();function ownKeys(t,r){var a=Object.keys(t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);r&&(o=o.filter((function(r){return Object.getOwnPropertyDescriptor(t,r).enumerable}))),a.push.apply(a,o)}return a}function _objectSpread(t){for(var r=1;r=t.length?{done:!0}:{done:!1,value:t[o++]}},e:function e(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var c,u=!0,l=!1;return{s:function s(){a=a.call(t)},n:function n(){var t=a.next();return u=t.done,t},e:function e(t){l=!0,c=t},f:function f(){try{u||null==a.return||a.return()}finally{if(l)throw c}}}}function itemlibrary_unsupportedIterableToArray(t,r){if(t){if("string"==typeof t)return itemlibrary_arrayLikeToArray(t,r);var a=Object.prototype.toString.call(t).slice(8,-1);return"Object"===a&&t.constructor&&(a=t.constructor.name),"Map"===a||"Set"===a?Array.from(t):"Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a)?itemlibrary_arrayLikeToArray(t,r):void 0}}function itemlibrary_arrayLikeToArray(t,r){(null==r||r>t.length)&&(r=t.length);for(var a=0,o=new Array(r);a=0;--o){var i=this.tryEntries[o],c=i.completion;if("root"===i.tryLoc)return handle("end");if(i.tryLoc<=this.prev){var u=a.call(i,"catchLoc"),l=a.call(i,"finallyLoc");if(u&&l){if(this.prev=0;--o){var i=this.tryEntries[o];if(i.tryLoc<=this.prev&&a.call(i,"finallyLoc")&&this.prev=0;--r){var a=this.tryEntries[r];if(a.finallyLoc===t)return this.complete(a.completion,a.afterLoc),resetTryEntry(a),l}},catch:function _catch(t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc===t){var o=a.completion;if("throw"===o.type){var i=o.arg;resetTryEntry(a)}return i}}throw new Error("illegal catch attempt")},delegateYield:function delegateYield(t,r,a){return this.delegate={iterator:values(t),resultName:r,nextLoc:a},"next"===this.method&&(this.arg=void 0),l}},t}function itemlibrary_asyncGeneratorStep(t,r,a,o,i,c,u){try{var l=t[c](u),p=l.value}catch(t){return void a(t)}l.done?r(p):Promise.resolve(p).then(o,i)}function itemlibrary_asyncToGenerator(t){return function(){var r=this,a=arguments;return new Promise((function(o,i){var c=t.apply(r,a);function _next(t){itemlibrary_asyncGeneratorStep(c,o,i,_next,_throw,"next",t)}function _throw(t){itemlibrary_asyncGeneratorStep(c,o,i,_next,_throw,"throw",t)}_next(void 0)}))}}function itemlibrary_classCallCheck(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}function itemlibrary_defineProperties(t,r){for(var a=0;a1&&void 0!==arguments[1]?arguments[1]:{};itemlibrary_classCallCheck(this,SearchDocument);var a=t.documentName||t.type;switch(t.documentName){case"Actor":case"Item":a=t.type}var o="";if(game.settings.get("dsa5","indexDescription"))switch(a){case"creature":case"npc":case"character":o=getProperty(t,"system.description.value");break;case"JournalEntry":o=getProperty(t,"system.content");break;default:o=getProperty(t,"description.value")}this.document={name:t.name,filterType:a,data:$("
    ").html(o).text(),id:t.id||t._id,visible:!t.visible||t.visible,compendium:t.compendium?t.compendium.metadata.packageName:r.packageName||"",pack:t.pack||(r.packageName?r.id:void 0),img:t.img}}var t,r;return itemlibrary_createClass(SearchDocument,[{key:"uuid",get:function get(){if(this.document.compendium)return"Compendium.".concat(this.document.pack,".").concat(this.document.id);switch(this.itemType){case"character":case"creature":case"npc":return"Actor.".concat(this.id);case"JournalEntry":return"JournalEntry.".concat(this.id);default:return"Item.".concat(this.id)}}},{key:"name",get:function get(){return this.document.name}},{key:"data",get:function get(){return this.document.data}},{key:"id",get:function get(){return this.document.id}},{key:"itemType",get:function get(){return this.document.filterType}},{key:"getItem",value:(r=itemlibrary_asyncToGenerator(itemlibrary_regeneratorRuntime().mark((function _callee(){return itemlibrary_regeneratorRuntime().wrap((function _callee$(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,fromUuid(this.uuid);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),_callee,this)}))),function getItem(){return r.apply(this,arguments)})},{key:"hasPermission",value:function hasPermission(){return this.document.visible}},{key:"render",value:(t=itemlibrary_asyncToGenerator(itemlibrary_regeneratorRuntime().mark((function _callee2(){return itemlibrary_regeneratorRuntime().wrap((function _callee2$(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.getItem();case 2:t.sent.sheet.render(!0);case 3:case"end":return t.stop()}}),_callee2,this)}))),function render(){return t.apply(this,arguments)})},{key:"compendium",get:function get(){return this.document.compendium}},{key:"img",get:function get(){return"JournalEntry"==this.itemType?"systems/dsa5/icons/categories/DSA-Auge.webp":this.document.img}}]),SearchDocument}(),yt=function(t){itemlibrary_inherits(AdvancedSearchDocument,t);var r=itemlibrary_createSuper(AdvancedSearchDocument);function AdvancedSearchDocument(t,a){var o;itemlibrary_classCallCheck(this,AdvancedSearchDocument),o=r.call(this,t);var i,c=itemlibrary_createForOfIteratorHelper(ht[a]||[]);try{for(c.s();!(i=c.n()).done;){var u=i.value;o[u.attr]=u.attr.split(".").reduce((function(t,r){return void 0===t[r]?{}:t[r]}),t.system)}}catch(t){c.e(t)}finally{c.f()}return o}return itemlibrary_createClass(AdvancedSearchDocument)}(mt),gt=function(r){itemlibrary_inherits(DSA5ItemLibrary,Application);var a,o,i,c,u,l,p,d,m,y,g,v,_,b,k,w=itemlibrary_createSuper(DSA5ItemLibrary);function DSA5ItemLibrary(t){var r;return itemlibrary_classCallCheck(this,DSA5ItemLibrary),(r=w.call(this,t)).advancedFiltering=!1,r.journalBuild=!1,r.journalWorldBuild=!1,r.equipmentBuild=!1,r.equipmentWorldBuild,r.zooBuild=!1,r.zooWorldBuild=!1,r.currentDetailFilter={equipment:[],character:[],spell:[],journal:[],zoo:[]},r.journalIndex=new FlexSearch({encode:"simple",tokenize:"reverse",cache:!0,doc:{id:"id",field:["name","data"]}}),r.equipmentIndex=new FlexSearch({encode:"simple",tokenize:"reverse",cache:!0,doc:{id:"id",field:["name","data","itemType"]}}),r.zooIndex=new FlexSearch({encode:"simple",tokenize:"reverse",cache:!0,doc:{id:"id",field:["name","data","itemType"]}}),r.detailFilter={},r.pages={equipment:{},character:{},spell:{},journal:{},zoo:{}},r.filters={equipment:{categories:{armor:!1,ammunition:!1,equipment:!1,meleeweapon:!1,rangeweapon:!1,poison:!1,disease:!1,consumable:!1,plant:!1},filterBy:{search:""}},character:{categories:{career:!1,advantage:!1,combatskill:!1,culture:!1,disadvantage:!1,trait:!1,skill:!1,specialability:!1,species:!1,application:!1,demonmark:!1,patron:!1,essence:!1,imprint:!1},filterBy:{search:""}},spell:{categories:{blessing:!1,ceremony:!1,liturgy:!1,magictrick:!1,ritual:!1,spell:!1,spellextension:!1,magicalsign:!1},filterBy:{search:""}},journal:{categories:{},filterBy:{search:""}},zoo:{categories:{npc:!1,character:!1,creature:!1},filterBy:{search:""}}},r}return itemlibrary_createClass(DSA5ItemLibrary,[{key:"getData",value:(k=itemlibrary_asyncToGenerator(itemlibrary_regeneratorRuntime().mark((function _callee3(t){var r;return itemlibrary_regeneratorRuntime().wrap((function _callee3$(a){for(;;)switch(a.prev=a.next){case 0:return a.next=2,itemlibrary_get(itemlibrary_getPrototypeOf(DSA5ItemLibrary.prototype),"getData",this).call(this,t);case 2:if((r=a.sent).categories=this.translateFilters(),r.isGM=game.user.isGM,r.items=this.items,r.advancedMode=this.advancedFiltering?"on":"",r.worldIndexed=game.settings.get("dsa5","indexWorldItems")?"on":"",r.fullTextEnabled=game.settings.get("dsa5","indexDescription")?"on":"",r.filterDuplicateItems=game.settings.get("dsa5","filterDuplicateItems")?"on":"",r.browseEnabled=this.browseEnabled?"on":"",!this.advancedFiltering){a.next=15;break}return a.next=14,this.buildDetailFilter("tbd",this.subcategory);case 14:r.advancedFilter=a.sent;case 15:return a.abrupt("return",r);case 16:case"end":return a.stop()}}),_callee3,this)}))),function getData(t){return k.apply(this,arguments)})},{key:"translateFilters",value:function translateFilters(){return{equipment:this.buildFilter(this.filters.equipment),character:this.buildFilter(this.filters.character),spell:this.buildFilter(this.filters.spell),zoo:this.buildFilter(this.filters.zoo,"Actor"),journal:this.buildFilter(this.filters.journal)}}},{key:"purgeAdvancedFilters",value:function purgeAdvancedFilters(){var t=this;for(var r in this.filters)for(var a in this.filters[r].categories)this.filters[r].categories[a]=!1;$(this._element).find('.filter[type="checkbox"]').prop("checked",!1),this.buildDetailFilter("none","none").then((function(r){$(t._element).find(".advancedSearch .groupbox").html(r)}))}},{key:"buildFilter",value:function buildFilter(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"Item",a=[];return Object.keys(t.categories).forEach((function(o){a.push({label:game.i18n.localize("TYPES.".concat(r,".").concat(o)),selected:t.categories[o],key:o})})),a=a.sort((function(t,r){return t.label.localeCompare(r.label)}))}},{key:"getRandomItems",value:(b=itemlibrary_asyncToGenerator(itemlibrary_regeneratorRuntime().mark((function _callee4(t,r){var a,o;return itemlibrary_regeneratorRuntime().wrap((function _callee4$(i){for(;;)switch(i.prev=i.next){case 0:return a=[],o=this.equipmentIndex,i.t0=a.push,i.t1=a,i.t2=itemlibrary_toConsumableArray,i.next=7,o.search(t,{field:["itemType"]});case 7:return i.t3=i.sent,i.t4=(0,i.t2)(i.t3),i.t0.apply.call(i.t0,i.t1,i.t4),i.next=12,Promise.all(this.shuffle(a.filter((function(t){return t.hasPermission}))).slice(0,r+5).map((function(t){return t.getItem()})));case 12:return i.abrupt("return",i.sent.filter((function(t){var r=t.getFlag("dsa5","enchantments");return!r||!r.find((function(t){return t.talisman}))})).slice(0,r));case 13:case"end":return i.stop()}}),_callee4,this)}))),function getRandomItems(t,r){return b.apply(this,arguments)})},{key:"shuffle",value:function shuffle(t){for(var r,a,o=t.length;0!==o;)a=Math.floor(Math.random()*o),r=t[o-=1],t[o]=t[a],t[a]=r;return t}},{key:"findCompendiumItem",value:(_=itemlibrary_asyncToGenerator(itemlibrary_regeneratorRuntime().mark((function _callee5(t,r){var a,o,i,c=arguments;return itemlibrary_regeneratorRuntime().wrap((function _callee5$(u){for(;;)switch(u.prev=u.next){case 0:if(a=!(c.length>2&&void 0!==c[2])||c[2],this.equipmentBuild){u.next=4;break}return u.next=4,this.buildEquipmentIndex();case 4:return o={field:["name"],where:{itemType:r}},u.next=7,this.equipmentIndex.search(t,o);case 7:return i=u.sent,a&&(i=i.filter((function(t){return""!=t.compendium}))),u.next=11,Promise.all(i.map((function(t){return t.getItem()})));case 11:return u.abrupt("return",u.sent);case 12:case"end":return u.stop()}}),_callee5,this)}))),function findCompendiumItem(t,r){return _.apply(this,arguments)})},{key:"getCategoryItems",value:(v=itemlibrary_asyncToGenerator(itemlibrary_regeneratorRuntime().mark((function _callee6(t){var r,a,o,i=arguments;return itemlibrary_regeneratorRuntime().wrap((function _callee6$(c){for(;;)switch(c.prev=c.next){case 0:return r=i.length>1&&void 0!==i[1]&&i[1],a=i.length>2&&void 0!==i[2]&&i[2],c.next=4,this.buildEquipmentIndex();case 4:if(o=this.equipmentIndex.search(t,{field:["itemType"]}),!r){c.next=11;break}return c.next=8,Promise.all(o.map((function(t){return t.getItem()})));case 8:return c.abrupt("return",c.sent.map((function(t){return t.toObject()})));case 11:if(!a){c.next=15;break}return c.next=14,Promise.all(o.map((function(t){return t.getItem()})));case 14:return c.abrupt("return",c.sent);case 15:return c.abrupt("return",o);case 16:case"end":return c.stop()}}),_callee6,this)}))),function getCategoryItems(t){return v.apply(this,arguments)})},{key:"executeAdvancedFilter",value:(g=itemlibrary_asyncToGenerator(itemlibrary_regeneratorRuntime().mark((function _callee7(t,r,a,o,i){var c,u,l,p,d,h,m,y=arguments;return itemlibrary_regeneratorRuntime().wrap((function _callee7$(g){for(;;)switch(g.prev=g.next){case 0:return c=y.length>5&&void 0!==y[5]?y[5]:[],u=function selFnct(t){var r,o=itemlibrary_createForOfIteratorHelper(a);try{for(o.s();!(r=o.n()).done;){var i=r.value;if(i[2]?t[i[0]]!=i[1]:-1==t[i[0]].indexOf(i[1]))return!1}}catch(t){o.e(t)}finally{o.f()}return!0},l=function txtFnct(t){var r,a=itemlibrary_createForOfIteratorHelper(o);try{for(a.s();!(r=a.n()).done;){var i=r.value;if(-1==t[i[0]].toLowerCase().indexOf(i[1]))return!1}}catch(t){a.e(t)}finally{a.f()}return!0},p=function cbFnct(t){var r,a=itemlibrary_createForOfIteratorHelper(i);try{for(a.s();!(r=a.n()).done;){var o=r.value;if(t[o[0]]!=o[1])return!1}}catch(t){a.e(t)}finally{a.f()}return!0},d=function rangeFct(t){var r,a=itemlibrary_createForOfIteratorHelper(c);try{for(a.s();!(r=a.n()).done;){var o=r.value;if(t[o[0]]o[2])return!1}}catch(t){a.e(t)}finally{a.f()}return!0},h=r.where((function(r){return(""==t||-1!=r.name.toLowerCase().indexOf(t))&&u(r)&&l(r)&&p(r)&&d(r)})),m=(m=h).filter((function(t){return t.hasPermission})).sort((function(t,r){return t.name.toLowerCase()>r.name.toLowerCase()?1:-1})),g.abrupt("return",m);case 9:case"end":return g.stop()}}),_callee7)}))),function executeAdvancedFilter(t,r,a,o,i){return g.apply(this,arguments)})},{key:"advancedFilterStuff",value:(y=itemlibrary_asyncToGenerator(itemlibrary_regeneratorRuntime().mark((function _callee8(t,r){var a,o,i,c,u,l,p,d,h,m,y,g,v,_,b,k,w,x,S,T;return itemlibrary_regeneratorRuntime().wrap((function _callee8$(r){for(;;)switch(r.prev=r.next){case 0:a=$(this._element).find(".detailFilters"),o=a.attr("data-subc"),i=this.filters[t].filterBy.search.toLowerCase(),c=this.detailFilter[o],u=[],l=[],p=[],d=itemlibrary_createForOfIteratorHelper(a.find("select"));try{for(d.s();!(h=d.n()).done;)m=h.value,""!=(y=$(m).val())&&u.push([$(m).attr("name"),y,"true"!=m.dataset.notstrict])}catch(t){d.e(t)}finally{d.f()}g=itemlibrary_createForOfIteratorHelper(a.find('input[type="text"]:not(.manualFilter)'));try{for(g.s();!(v=g.n()).done;)_=v.value,""!=(b=$(_).val())&&l.push([$(_).attr("name"),b.toLowerCase()])}catch(t){g.e(t)}finally{g.f()}k=itemlibrary_createForOfIteratorHelper(a.find('input[type="checkbox"]:checked:not(.manualFilter)'));try{for(k.s();!(w=k.n()).done;)x=w.value,""!=(S=$(x).val())&&p.push([$(x).attr("name"),S.toLowerCase()])}catch(t){k.e(t)}finally{k.f()}return r.next=15,this.executeAdvancedFilter(i,c,u,l,p);case 15:return T=r.sent,this.setBGImage(T,t),T=this.filterDuplications(T),r.abrupt("return",T);case 19:case"end":return r.stop()}}),_callee8,this)}))),function advancedFilterStuff(t,r){return y.apply(this,arguments)})},{key:"filterDuplications",value:function filterDuplications(t){return game.settings.get("dsa5","filterDuplicateItems")&&(t=itemlibrary_toConsumableArray(new Map(t.map((function(t){return["".concat(t.name,"_").concat(t.type),t]}))).values())),t}},{key:"filterStuff",value:(m=itemlibrary_asyncToGenerator(itemlibrary_regeneratorRuntime().mark((function _callee9(t,r,a){var o,i,c,u,l,p,d,h;return itemlibrary_regeneratorRuntime().wrap((function _callee9$(m){for(;;)switch(m.prev=m.next){case 0:for(l in o=this.filters[t].filterBy.search,i={field:["name","data"],limit:60,page:a||!0},c=[],u=!1,this.filters[t].categories)this.filters[t].categories[l]&&(d=void 0,""==o?d=r.search(l,{field:["itemType"],limit:60,page:a||!0}):(h=duplicate(i),mergeObject(h,{where:{itemType:l}}),d=r.search(o,h)),this.pages[t].next=d.next,(p=c).push.apply(p,itemlibrary_toConsumableArray(d.result))),u=this.filters[t].categories[l]||u;return u||(c=r.search(o,i),this.pages[t].next=c.next),c=(c=c.result?c.result:c).filter((function(t){return t.hasPermission})).sort((function(t,r){return t.name.toLowerCase()>r.name.toLowerCase()?1:-1})),this.setBGImage(c,t),c=this.filterDuplications(c),m.abrupt("return",c);case 11:case"end":return m.stop()}}),_callee9,this)}))),function filterStuff(t,r,a){return m.apply(this,arguments)})},{key:"setBGImage",value:function setBGImage(t,r){$(this._element).find(".".concat(r," .libcontainer"))["".concat(t.length>0?"remove":"add","Class")]("libraryImg")}},{key:"getItemTemplate",value:(d=itemlibrary_asyncToGenerator(itemlibrary_regeneratorRuntime().mark((function _callee11(t,r){return itemlibrary_regeneratorRuntime().wrap((function _callee11$(a){for(;;)switch(a.prev=a.next){case 0:if(!this.browseEnabled||"Item"!=r){a.next=6;break}return a.next=3,Promise.all(t.map(function(){var t=itemlibrary_asyncToGenerator(itemlibrary_regeneratorRuntime().mark((function _callee10(t){var r,a,o;return itemlibrary_regeneratorRuntime().wrap((function _callee10$(i){for(;;)switch(i.prev=i.next){case 0:return r="systems/dsa5/templates/items/browse/".concat(t.document.filterType,".html"),i.next=3,fromUuid(t.uuid);case 3:return a=i.sent,i.t0=renderTemplate,i.t1=r,i.t2=itemlibrary_objectSpread,i.t3={document:a,isGM:game.user.isGM},i.next=10,a.sheet.getData();case 10:return i.t4=i.sent,i.t5=(0,i.t2)(i.t3,i.t4),i.next=14,(0,i.t0)(i.t1,i.t5);case 14:return o=i.sent,i.abrupt("return",'
    ').concat(o,"
    "));case 16:case"end":return i.stop()}}),_callee10)})));return function(r){return t.apply(this,arguments)}}()));case 3:return a.abrupt("return",a.sent.join("\n"));case 6:return a.next=9,renderTemplate("systems/dsa5/templates/system/libraryItem.html",{items:t});case 9:return a.abrupt("return",a.sent);case 10:case"end":return a.stop()}}),_callee11,this)}))),function getItemTemplate(t,r){return d.apply(this,arguments)})},{key:"renderResult",value:(p=itemlibrary_asyncToGenerator(itemlibrary_regeneratorRuntime().mark((function _callee12(t,r,a,o){var i,c,u,l;return itemlibrary_regeneratorRuntime().wrap((function _callee12$(p){for(;;)switch(p.prev=p.next){case 0:return i=a.index,c=a.itemType,u=t.find(".searchResult .item-list"),p.next=4,this.getItemTemplate(r,c);case 4:l=p.sent,o||u.empty(),(l=$(l)).each((function(){var t=$(this);t.attr("draggable",!0).on("dragstart",(function(r){var a=i.find($(t).attr("data-item-id"));r.originalEvent.dataTransfer.setData("text/plain",JSON.stringify({type:c,uuid:a.uuid}))}))})),u.append(l);case 9:case"end":return p.stop()}}),_callee12,this)}))),function renderResult(t,r,a,o){return p.apply(this,arguments)})},{key:"filterItems",value:(l=itemlibrary_asyncToGenerator(itemlibrary_regeneratorRuntime().mark((function _callee13(t,r,a){var o,i;return itemlibrary_regeneratorRuntime().wrap((function _callee13$(c){for(;;)switch(c.prev=c.next){case 0:if(o=this.selectIndex(r),!this.advancedFiltering||"journal"==r){c.next=7;break}return c.next=4,this.advancedFilterStuff(r,a);case 4:c.t0=c.sent,c.next=10;break;case 7:return c.next=9,this.filterStuff(r,o.index,a);case 9:c.t0=c.sent;case 10:return i=c.t0,c.next=13,this.renderResult(t,i,o,a);case 13:return c.abrupt("return",i);case 14:case"end":return c.stop()}}),_callee13,this)}))),function filterItems(t,r,a){return l.apply(this,arguments)})},{key:"selectIndex",value:function selectIndex(t){var r="Item",a=this.equipmentIndex;switch(t){case"zoo":r="Actor",a=this.zooIndex;break;case"journal":r="JournalEntry",a=this.journalIndex}return{index:a,itemType:r}}},{key:"_render",value:(u=itemlibrary_asyncToGenerator(itemlibrary_regeneratorRuntime().mark((function _callee14(){var t,r,a=arguments;return itemlibrary_regeneratorRuntime().wrap((function _callee14$(o){for(;;)switch(o.prev=o.next){case 0:return t=a.length>0&&void 0!==a[0]&&a[0],r=a.length>1&&void 0!==a[1]?a[1]:{},o.next=4,itemlibrary_get(itemlibrary_getPrototypeOf(DSA5ItemLibrary.prototype),"_render",this).call(this,t,r);case 4:this.buildEquipmentIndex();case 5:case"end":return o.stop()}}),_callee14,this)}))),function _render(){return u.apply(this,arguments)})},{key:"buildEquipmentIndex",value:(c=itemlibrary_asyncToGenerator(itemlibrary_regeneratorRuntime().mark((function _callee15(){return itemlibrary_regeneratorRuntime().wrap((function _callee15$(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._createIndex("equipment","Item",game.items);case 2:case"end":return t.stop()}}),_callee15,this)}))),function buildEquipmentIndex(){return c.apply(this,arguments)})},{key:"_createIndex",value:(i=itemlibrary_asyncToGenerator(itemlibrary_regeneratorRuntime().mark((function _callee17(t,r,a){var o,i,c,u,l,p,d,h,m=this;return itemlibrary_regeneratorRuntime().wrap((function _callee17$(y){for(;;)switch(y.prev=y.next){case 0:if(!this["".concat(t,"Build")]){y.next=2;break}return y.abrupt("return");case 2:return SceneNavigation.displayProgressBar({label:game.i18n.format("Library.loading",{item:""}),pct:0}),o=$(this._element).find('*[data-tab="'.concat(t,'"]')),this.showLoading(o,t),i=game.packs.filter((function(t){return t.documentName==r&&(game.user.isGM||!t.private)&&!t.metadata.label.startsWith("WZ-")})),c=100/(i.length+1),u=c,l=["name","system.type","system.description.value","img"],p="Actor"==r?function func(t){return t.getIndex({actorFields:l})}:"JournalEntry"==r?function func(t){return t.getDocuments()}:function func(t){return t.getDocuments({type__in:game.system.documentTypes.Item})},d=this.indexWorldItems(a,t),SceneNavigation.displayProgressBar({label:game.i18n.format("Library.loading",{item:"world items"}),pct:Math.round(c)}),h=i.map(function(){var t=itemlibrary_asyncToGenerator(itemlibrary_regeneratorRuntime().mark((function _callee16(t){var r;return itemlibrary_regeneratorRuntime().wrap((function _callee16$(a){for(;;)switch(a.prev=a.next){case 0:return a.next=2,p(t);case 2:r=a.sent,u+=c,SceneNavigation.displayProgressBar({label:game.i18n.format("Library.loading",{item:"".concat(t.metadata.label," (").concat(t.metadata.id,")")}),pct:Math.round(u)}),d.push.apply(d,itemlibrary_toConsumableArray(r.map((function(r){return new mt(r,t.metadata)}))));case 6:case"end":return a.stop()}}),_callee16)})));return function(r){return t.apply(this,arguments)}}()),y.abrupt("return",Promise.all(h).then((function(r){m["".concat(t,"Index")].add(d),m["".concat(t,"Build")]=!0,SceneNavigation.displayProgressBar({label:game.i18n.format("Library.loading",{item:""}),pct:100}),m.hideLoading(o,t)})));case 14:case"end":return y.stop()}}),_callee17,this)}))),function _createIndex(t,r,a){return i.apply(this,arguments)})},{key:"subcategoryFields",value:function subcategoryFields(t){var r,a=["name","itemType"],o=itemlibrary_createForOfIteratorHelper(ht[t]||[]);try{for(o.s();!(r=o.n()).done;){var i=r.value;a.push(i.attr)}}catch(t){o.e(t)}finally{o.f()}return a}},{key:"indexWorldItems",value:function indexWorldItems(t,r){var a=[];return game.settings.get("dsa5","indexWorldItems")&&(a.push.apply(a,itemlibrary_toConsumableArray(t.filter((function(t){return t.visible})).map((function(t){return new mt(t)})))),this["".concat(r,"WorldBuild")]=!0),a}},{key:"createDetailIndex",value:(o=itemlibrary_asyncToGenerator(itemlibrary_regeneratorRuntime().mark((function _callee18(t,r){var a,o,i,c,u,l,p,d,h,m,y,g,v,_,b,k,w,x,S,T;return itemlibrary_regeneratorRuntime().wrap((function _callee18$(A){for(;;)switch(A.prev=A.next){case 0:if(this.detailFilter[r]){A.next=39;break}a=this.subcategoryFields(r),(o=$(this._element).find('*[data-tab="'.concat(t,'"]'))).find(".searchResult ul").html(""),this.showLoading(o,t),this.detailFilter[r]=new FlexSearch({encode:"simple",tokenize:"full",cache:!0,doc:{id:"id",field:a}}),i=this.selectIndex(t),c=i.index,u=i.itemType,l="Item"==u?game.items:game.actors,p=l.filter((function(t){return t.visible&&t.type==r})).map((function(t){return new yt(t,r)})),d=c.search(r,{field:["itemType"]}),h={},m=itemlibrary_createForOfIteratorHelper(d),A.prev=12,m.s();case 14:if((y=m.n()).done){A.next=22;break}if((g=y.value).document.pack){A.next=18;break}return A.abrupt("continue",20);case 18:h[g.document.pack]||(h[g.document.pack]=[]),h[g.document.pack].push(g.document.id);case 20:A.next=14;break;case 22:A.next=27;break;case 24:A.prev=24,A.t0=A.catch(12),m.e(A.t0);case 27:return A.prev=27,m.f(),A.finish(27);case 30:for(v=[],_=0,b=Object.entries(h);_".concat(game.i18n.localize("Library.selectAdvanced"),"

    "));case 12:case"end":return c.stop()}}),_callee19,this)}))),function buildDetailFilter(t,r){return a.apply(this,arguments)})},{key:"checkWorldStuffIndex",value:function checkWorldStuffIndex(){game.settings.get("dsa5","indexWorldItems")&&(!this.journalWorldBuild&&this.journalBuild&&this.journalIndex.add(this.indexWorldItems(game.journal,"journal")),!this.equipmentWorldBuild&&this.equipmentBuild&&this.equipmentIndex.add(this.indexWorldItems(game.items,"equipment")),!this.zooWorldBuild&&this.zooBuild&&this.zooIndex.add(this.indexWorldItems(game.actors,"zoo")))}},{key:"activateListeners",value:function activateListeners(r){var a=this;itemlibrary_get(itemlibrary_getPrototypeOf(DSA5ItemLibrary.prototype),"activateListeners",this).call(this,r),(0,h.Ee)(r),r.on("click",".searchableAbility a",(function(t){return(0,h.$8)(t)})),r.on("click",".toggleAdvancedMode",(function(){a.advancedFiltering=!a.advancedFiltering,a.advancedFiltering?($(a._element).find(".toggleAdvancedMode").addClass("on"),$(a._element).find(".advancedSearch").fadeIn(),a.purgeAdvancedFilters()):($(a._element).find(".toggleAdvancedMode").removeClass("on"),$(a._element).find(".advancedSearch").fadeOut())})),r.on("change",".detailFilters input, .detailFilters select",(function(){var t=$(a._element).find(".tab.active"),r=t.attr("data-tab");a.filterItems(t,r)})),r.on("click",".filter",function(){var t=itemlibrary_asyncToGenerator(itemlibrary_regeneratorRuntime().mark((function _callee20(t){var r,o,i,c;return itemlibrary_regeneratorRuntime().wrap((function _callee20$(u){for(;;)switch(u.prev=u.next){case 0:if(r=$(t.currentTarget).closest(".tab"),o=r.attr("data-tab"),i=t.currentTarget.dataset.category,c=$(t.currentTarget).is(":checked"),!a.advancedFiltering||!c){u.next=13;break}return a.purgeAdvancedFilters(),a.subcategory=i,$(t.currentTarget).prop("checked",c),u.t0=$(a._element).find(".advancedSearch .groupbox"),u.next=11,a.buildDetailFilter(o,i);case 11:u.t1=u.sent,u.t0.html.call(u.t0,u.t1);case 13:a.filters[o].categories[i]=c,a.filterItems(r,o);case 15:case"end":return u.stop()}}),_callee20)})));return function(r){return t.apply(this,arguments)}}()),r.on("click",".item-name",(function(t){a.getItemFromHTML(t).render()})),r.on("mousedown",".item-name",(function(r){2==r.button&&t.Z.showArtwork(a.getItemFromHTML(r))})),r.on("keyup",".filterBy-search",(function(t){var r=$(t.currentTarget).closest(".tab"),o=r.attr("data-tab");a.filters[o].filterBy.search=$(t.currentTarget).val(),a.filterItems(r,o)})),r.on("click",".show-item",function(){var t=itemlibrary_asyncToGenerator(itemlibrary_regeneratorRuntime().mark((function _callee21(t){var r,a;return itemlibrary_regeneratorRuntime().wrap((function _callee21$(o){for(;;)switch(o.prev=o.next){case 0:return r=t.currentTarget.dataset.uuid,o.next=3,fromUuid(r);case 3:(a=o.sent)&&a.sheet.render(!0);case 5:case"end":return o.stop()}}),_callee21)})));return function(r){return t.apply(this,arguments)}}()),r.find('*[data-tab="journal"]').click((function(t){a._createIndex("journal","JournalEntry",game.journal)})),r.find('*[data-tab="zoo"]').click((function(t){a._createIndex("zoo","Actor",game.actors)})),r.find(".showDetails").click((function(t){var a=t.currentTarget.dataset.btn;$(t.currentTarget).find("i").toggleClass("fa-caret-left fa-caret-right"),r.find(".".concat(a," .detailBox")).toggleClass("dsahidden")})),r.find(".toggleWorldIndex").click((function(t){game.settings.set("dsa5","indexWorldItems",!game.settings.get("dsa5","indexWorldItems")),a.checkWorldStuffIndex(),$(t.currentTarget).toggleClass("on")})),r.find(".fulltextsearch").click((function(t){game.settings.set("dsa5","indexDescription",!game.settings.get("dsa5","indexDescription")),$(t.currentTarget).toggleClass("on")})),r.find(".browseEnabled").click((function(t){a.browseEnabled=!a.browseEnabled,$(t.currentTarget).toggleClass("on")})),r.find(".filterDuplicateItems").click((function(t){game.settings.set("dsa5","filterDuplicateItems",!game.settings.get("dsa5","filterDuplicateItems")),$(t.currentTarget).toggleClass("on")}));var o=this;$(this._element).find(".window-content").on("scroll.infinit",debounce((function(t){if(!o.advancedFiltering){var a=$(t.target),i=a.scrollTop()+a.innerHeight()>=a[0].scrollHeight-100,c=r.find(".tabs .item.active").attr("data-tab");if(i&&o.pages[c].next){var u=r.find(".tab.active");o.filterItems.call(o,u,c,o.pages[c].next)}}}),100))}},{key:"getItemFromHTML",value:function getItemFromHTML(t){var r=$(t.currentTarget).parents(".browser-item").attr("data-item-id");switch($(t.currentTarget).closest(".tab").attr("data-tab")){case"zoo":return this.zooIndex.find(r);case"journal":return this.journalIndex.find(r);default:return this.equipmentIndex.find(r)}}},{key:"showLoading",value:function showLoading(t,r){this.setBGImage([1],r),$('
    '.concat(game.i18n.localize("Library.buildingIndex"),"
    ")).appendTo(t.find(".searchResult"))}},{key:"hideLoading",value:function hideLoading(t,r){this.setBGImage([],r),t.find(".loader").remove()}}],[{key:"defaultOptions",get:function get(){var t=itemlibrary_get(itemlibrary_getPrototypeOf(DSA5ItemLibrary),"defaultOptions",this);return t.id="DSA5ItemLibrary",t.classes.push("dsa5","itemlibrary"),t.height=800,t.width=800,t.resizable=!0,t.title=game.i18n.localize("ItemLibrary"),t.template="systems/dsa5/templates/system/itemlibrary.html",t.tabs=[{navSelector:".tabs",contentSelector:".content",initial:"equipment"}],t}}]),DSA5ItemLibrary}();function initializer_typeof(t){return initializer_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},initializer_typeof(t)}function initializer_slicedToArray(t,r){return function initializer_arrayWithHoles(t){if(Array.isArray(t))return t}(t)||function initializer_iterableToArrayLimit(t,r){var a=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null==a)return;var o,i,c=[],u=!0,l=!1;try{for(a=a.call(t);!(u=(o=a.next()).done)&&(c.push(o.value),!r||c.length!==r);u=!0);}catch(t){l=!0,i=t}finally{try{u||null==a.return||a.return()}finally{if(l)throw i}}return c}(t,r)||initializer_unsupportedIterableToArray(t,r)||function initializer_nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function initializer_createForOfIteratorHelper(t,r){var a="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!a){if(Array.isArray(t)||(a=initializer_unsupportedIterableToArray(t))||r&&t&&"number"==typeof t.length){a&&(t=a);var o=0,i=function F(){};return{s:i,n:function n(){return o>=t.length?{done:!0}:{done:!1,value:t[o++]}},e:function e(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var c,u=!0,l=!1;return{s:function s(){a=a.call(t)},n:function n(){var t=a.next();return u=t.done,t},e:function e(t){l=!0,c=t},f:function f(){try{u||null==a.return||a.return()}finally{if(l)throw c}}}}function initializer_unsupportedIterableToArray(t,r){if(t){if("string"==typeof t)return initializer_arrayLikeToArray(t,r);var a=Object.prototype.toString.call(t).slice(8,-1);return"Object"===a&&t.constructor&&(a=t.constructor.name),"Map"===a||"Set"===a?Array.from(t):"Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a)?initializer_arrayLikeToArray(t,r):void 0}}function initializer_arrayLikeToArray(t,r){(null==r||r>t.length)&&(r=t.length);for(var a=0,o=new Array(r);a=0;--o){var i=this.tryEntries[o],c=i.completion;if("root"===i.tryLoc)return handle("end");if(i.tryLoc<=this.prev){var u=a.call(i,"catchLoc"),l=a.call(i,"finallyLoc");if(u&&l){if(this.prev=0;--o){var i=this.tryEntries[o];if(i.tryLoc<=this.prev&&a.call(i,"finallyLoc")&&this.prev=0;--r){var a=this.tryEntries[r];if(a.finallyLoc===t)return this.complete(a.completion,a.afterLoc),resetTryEntry(a),l}},catch:function _catch(t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc===t){var o=a.completion;if("throw"===o.type){var i=o.arg;resetTryEntry(a)}return i}}throw new Error("illegal catch attempt")},delegateYield:function delegateYield(t,r,a){return this.delegate={iterator:values(t),resultName:r,nextLoc:a},"next"===this.method&&(this.arg=void 0),l}},t}function initializer_asyncGeneratorStep(t,r,a,o,i,c,u){try{var l=t[c](u),p=l.value}catch(t){return void a(t)}l.done?r(p):Promise.resolve(p).then(o,i)}function initializer_asyncToGenerator(t){return function(){var r=this,a=arguments;return new Promise((function(o,i){var c=t.apply(r,a);function _next(t){initializer_asyncGeneratorStep(c,o,i,_next,_throw,"next",t)}function _throw(t){initializer_asyncGeneratorStep(c,o,i,_next,_throw,"throw",t)}_next(void 0)}))}}function initializer_classCallCheck(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}function initializer_defineProperties(t,r){for(var a=0;a3&&void 0!==arguments[3]?arguments[3]:"";initializer_classCallCheck(this,DSA5Initializer);var c,u,l={title:t,content:r,buttons:{initialize:{label:game.i18n.localize("initialize"),callback:(u=initializer_asyncToGenerator(initializer_regeneratorRuntime().mark((function _callee(){return initializer_regeneratorRuntime().wrap((function _callee$(t){for(;;)switch(t.prev=t.next){case 0:if(!o.lock){t.next=2;break}return t.abrupt("return");case 2:return t.next=4,o.initialize();case 4:case"end":return t.stop()}}),_callee)}))),function callback(){return u.apply(this,arguments)})},cancel:{label:game.i18n.localize("cancel"),callback:(c=initializer_asyncToGenerator(initializer_regeneratorRuntime().mark((function _callee2(){return initializer_regeneratorRuntime().wrap((function _callee2$(t){for(;;)switch(t.prev=t.next){case 0:if(!o.lock){t.next=2;break}return t.abrupt("return");case 2:return t.next=4,o.dontInitialize();case 4:case"end":return t.stop()}}),_callee2)}))),function callback(){return c.apply(this,arguments)})}}};return(o=p.call(this,l)).module=a,o.lang=i,o.folders={},o.journals={},o.scenes={},o.actors={},o.lock=!1,o}return function initializer_createClass(t,r,a){return r&&initializer_defineProperties(t.prototype,r),a&&initializer_defineProperties(t,a),Object.defineProperty(t,"prototype",{writable:!1}),t}(DSA5Initializer,[{key:"initNotes",value:(l=initializer_asyncToGenerator(initializer_regeneratorRuntime().mark((function _callee3(t,r,a){var o,i,c,u,l=this;return initializer_regeneratorRuntime().wrap((function _callee3$(p){for(;;)switch(p.prev=p.next){case 0:return p.next=2,this.getFolderForType("JournalEntry");case 2:o=p.sent,i=initializer_createForOfIteratorHelper(t.notes),p.prev=4,u=initializer_regeneratorRuntime().mark((function _loop(){var i,u,p,d,h,m;return initializer_regeneratorRuntime().wrap((function _loop$(y){for(;;)switch(y.prev=y.next){case 0:if(i=c.value,y.prev=1,u=r.find((function(t){return t.flags.dsa5.initId==i.entryId})),a.has(u._id)){y.next=26;break}if(p=getProperty(u,"flags.dsa5.parent"),d=o,!l.folders[p]){y.next=10;break}d=l.folders[p],y.next=14;break;case 10:if(!p){y.next=14;break}return y.next=13,l.getFolderForType("JournalEntry",o.id,p,0,getProperty(u,"flags.dsa5.foldercolor")||"");case 13:d=y.sent;case 14:if(u.folder=d.id,!(h=game.journal.find((function(t){var r;return t.name==u.name&&(null===(r=t.folder)||void 0===r?void 0:r.id)==d.id&&t.flags.dsa5.initId==i.entryId})))){y.next=22;break}return y.next=19,h.update(u);case 19:a.set(u._id,h.id),y.next=26;break;case 22:return y.next=24,JournalEntry.create(u);case 24:m=y.sent,a.set(u._id,m.id);case 26:i.entryId=a.get(u._id),y.next=32;break;case 29:y.prev=29,y.t0=y.catch(1),console.warn("Could not initialize Scene Notes for scene :".concat(t.name)+y.t0);case 32:case"end":return y.stop()}}),_loop,null,[[1,29]])})),i.s();case 7:if((c=i.n()).done){p.next=11;break}return p.delegateYield(u(),"t0",9);case 9:p.next=7;break;case 11:p.next=16;break;case 13:p.prev=13,p.t1=p.catch(4),i.e(p.t1);case 16:return p.prev=16,i.f(),p.finish(16);case 19:case"end":return p.stop()}}),_callee3,this,[[4,13,16,19]])}))),function initNotes(t,r,a){return l.apply(this,arguments)})},{key:"initScenes",value:(u=initializer_asyncToGenerator(initializer_regeneratorRuntime().mark((function _callee4(t){var r,a,o,i,c,u,l,p,d,h,m,y,g,v,_,b,k,w,x,S,T,A,O=this;return initializer_regeneratorRuntime().wrap((function _callee4$(P){for(;;)switch(P.prev=P.next){case 0:return P.next=2,this.getFolderForType("Scene");case 2:return r=P.sent,a=game.packs.get(t.scenes),P.next=6,a.getDocuments();case 6:return o=P.sent.map((function(t){return t.toObject()})),i=game.packs.get(t.journal),P.next=10,i.getDocuments();case 10:c=P.sent.map((function(t){return t.toObject()})),u=[],l=[],p=new Map,d=!1,h=initializer_createForOfIteratorHelper(o),P.prev=16,y=initializer_regeneratorRuntime().mark((function _loop2(){var t,a,o,i,h;return initializer_regeneratorRuntime().wrap((function _loop2$(y){for(;;)switch(y.prev=y.next){case 0:if(t=m.value,a=d,o=game.scenes.find((function(a){var o;return a.name==t.name&&(null===(o=a.folder)||void 0===o?void 0:o.id)==r.id})),d||!o){y.next=10;break}return y.next=6,new Promise((function(r,a){new Dialog({title:game.i18n.localize("Book.sceneReset"),content:game.i18n.format("Book.sceneResetDescription",{name:t.name}),default:"Yes",buttons:{Yes:{icon:'',label:game.i18n.localize("yes"),callback:function callback(){r([!0,!1])}},all:{icon:'',label:game.i18n.localize("LocalizedIDs.all"),callback:function callback(){r([!0,!0])}},cancel:{icon:'',label:game.i18n.localize("cancel"),callback:function callback(){r([!1,!1])}}},close:function close(){r([!1,!1])}}).render(!0)}));case 6:i=y.sent,h=initializer_slicedToArray(i,2),a=h[0],d=h[1];case 10:if(!o||a){y.next=13;break}return O.scenes[o.name]=o,y.abrupt("return","continue");case 13:return t.folder=r.id,y.next=16,O.initNotes(t,c,p);case 16:o?(t._id=o.id,l.push(t)):u.push(t);case 17:case"end":return y.stop()}}),_loop2)})),h.s();case 19:if((m=h.n()).done){P.next=26;break}return P.delegateYield(y(),"t0",21);case 21:if("continue"!==P.t0){P.next=24;break}return P.abrupt("continue",24);case 24:P.next=19;break;case 26:P.next=31;break;case 28:P.prev=28,P.t1=P.catch(16),h.e(P.t1);case 31:return P.prev=31,h.f(),P.finish(31);case 34:return P.next=36,Scene.create(u,{dsaInit:!0});case 36:g=P.sent,v=initializer_createForOfIteratorHelper(g),P.prev=38,v.s();case 40:if((_=v.n()).done){P.next=50;break}return b=_.value,this.scenes[b.name]=b,P.next=45,b.createThumbnail();case 45:return k=P.sent,P.next=48,b.update({thumb:k.thumb},{diff:!1});case 48:P.next=40;break;case 50:P.next=55;break;case 52:P.prev=52,P.t2=P.catch(38),v.e(P.t2);case 55:return P.prev=55,v.f(),P.finish(55);case 58:w=0,x=l;case 59:if(!(w
    '),r={},i.prev=4,!game.settings.settings.has("".concat(this.module,".initialized"))){i.next=8;break}return i.next=8,game.settings.set(this.module,"initialized",!0);case 8:i.next=12;break;case 10:i.prev=10,i.t0=i.catch(4);case 12:return i.prev=12,i.next=15,fetch("modules/".concat(this.module,"/adventure").concat(this.lang,".json")).then(function(){var t=initializer_asyncToGenerator(initializer_regeneratorRuntime().mark((function _callee5(t){return initializer_regeneratorRuntime().wrap((function _callee5$(r){for(;;)switch(r.prev=r.next){case 0:return r.abrupt("return",t.json());case 1:case"end":return r.stop()}}),_callee5)})));return function(r){return t.apply(this,arguments)}}()).then(function(){var t=initializer_asyncToGenerator(initializer_regeneratorRuntime().mark((function _callee6(t){return initializer_regeneratorRuntime().wrap((function _callee6$(a){for(;;)switch(a.prev=a.next){case 0:r=t;case 1:case"end":return a.stop()}}),_callee6)})));return function(r){return t.apply(this,arguments)}}());case 15:i.next=27;break;case 17:return i.prev=17,i.t1=i.catch(12),i.prev=19,i.next=22,fetch("modules/".concat(this.module,"/adventure.json")).then(function(){var t=initializer_asyncToGenerator(initializer_regeneratorRuntime().mark((function _callee7(t){return initializer_regeneratorRuntime().wrap((function _callee7$(r){for(;;)switch(r.prev=r.next){case 0:return r.abrupt("return",t.json());case 1:case"end":return r.stop()}}),_callee7)})));return function(r){return t.apply(this,arguments)}}()).then(function(){var t=initializer_asyncToGenerator(initializer_regeneratorRuntime().mark((function _callee8(t){return initializer_regeneratorRuntime().wrap((function _callee8$(a){for(;;)switch(a.prev=a.next){case 0:r=t;case 1:case"end":return a.stop()}}),_callee8)})));return function(r){return t.apply(this,arguments)}}());case 22:i.next=27;break;case 24:i.prev=24,i.t2=i.catch(19),console.warn("Could not find book data for ".concat(this.module," import."));case 27:return i.next=29,fetch("modules/".concat(this.module,"/initialization").concat(this.lang,".json")).then(function(){var t=initializer_asyncToGenerator(initializer_regeneratorRuntime().mark((function _callee9(t){return initializer_regeneratorRuntime().wrap((function _callee9$(r){for(;;)switch(r.prev=r.next){case 0:return r.abrupt("return",t.json());case 1:case"end":return r.stop()}}),_callee9)})));return function(r){return t.apply(this,arguments)}}()).then(function(){var t=initializer_asyncToGenerator(initializer_regeneratorRuntime().mark((function _callee13(t){var i,c,u,l,p,d,h,m,y,g,v;return initializer_regeneratorRuntime().wrap((function _callee13$(_){for(;;)switch(_.prev=_.next){case 0:if(!(i=t.folders)){_.next=17;break}return _.next=4,a.getFolderForType("JournalEntry");case 4:return c=_.sent,u=t.folders[0].name,c&&(a.folders[c.data.name]=c,t.folders.shift()),_.next=9,Folder.create(i);case 9:l=_.sent,Array.isArray(l)||(l=[l]),p=initializer_createForOfIteratorHelper(l);try{for(p.s();!(d=p.n()).done;)h=d.value,a.folders[h.data.name]=h}catch(t){p.e(t)}finally{p.f()}for(y in m=[],a.folders)g=a.folders[y].getFlag("dsa5","parent"),(v=g==u?game.i18n.localize("".concat(a.module,".name")):g)&&m.push({_id:a.folders[y].id,parent:a.folders[v].id});return _.next=17,Folder.updateDocuments(m);case 17:if(!(t.items&&t.items.length>0)){_.next=19;break}return _.delegateYield(initializer_regeneratorRuntime().mark((function _callee10(){var r,i,c,u,l,p;return initializer_regeneratorRuntime().wrap((function _callee10$(d){for(;;)switch(d.prev=d.next){case 0:return d.next=2,a.getFolderForType("Item");case 2:r=d.sent,i=[],c=[],u=initializer_createForOfIteratorHelper(t.items);try{for(p=function _loop3(){var t=l.value;t.folder=r.id;var a=game.items.find((function(a){var o;return a.name==t.name&&(null===(o=a.folder)||void 0===o?void 0:o.id)==r.id}));a?(t._id=a.id,c.push(t)):i.push(t)},u.s();!(l=u.n()).done;)p()}catch(t){u.e(t)}finally{u.f()}return d.next=9,o.Z.create(i);case 9:return d.next=11,o.Z.updateDocuments(c);case 11:case"end":return d.stop()}}),_callee10)}))(),"t0",19);case 19:if(!t.playlists){_.next=21;break}return _.delegateYield(initializer_regeneratorRuntime().mark((function _callee11(){var r,o,i,c,u,l,p,d;return initializer_regeneratorRuntime().wrap((function _callee11$(h){for(;;)switch(h.prev=h.next){case 0:return h.next=2,a.getFolderForType("Playlist");case 2:return r=h.sent,o=[],i=[],c=game.packs.get(t.playlists),h.next=8,c.getDocuments();case 8:u=h.sent.map((function(t){return t.toObject()})),l=initializer_createForOfIteratorHelper(u);try{for(d=function _loop4(){var t=p.value;t.folder=r.id;var a=game.playlists.find((function(a){var o;return a.name==t.name&&(null===(o=a.folder)||void 0===o?void 0:o.id)==r.id}));a?(t._id=a.data._id,i.push(t)):o.push(t)},l.s();!(p=l.n()).done;)d()}catch(t){l.e(t)}finally{l.f()}return h.next=13,Playlist.create(o,{keepId:!0});case 13:return h.next=15,Playlist.updateDocuments(i);case 15:case"end":return h.stop()}}),_callee11)}))(),"t1",21);case 21:if(!t.scenes){_.next=24;break}return _.next=24,a.initScenes(t);case 24:if(!t.actors){_.next=26;break}return _.delegateYield(initializer_regeneratorRuntime().mark((function _callee12(){var o,i,c,u,l,p,d,h,m,y,g,v,_,b,k,w,x,S,T,A,O,P,E,C;return initializer_regeneratorRuntime().wrap((function _callee12$(D){for(;;)switch(D.prev=D.next){case 0:return D.next=2,a.getFolderForType("Actor");case 2:return o=D.sent,i=game.packs.get(t.actors),D.next=6,i.getDocuments();case 6:if(c=D.sent.map((function(t){return t.toObject()})),u=[],l=[],p=new Map,d=0,!getProperty(r,"chapters")){D.next=50;break}h=initializer_createForOfIteratorHelper(r.chapters),D.prev=13,h.s();case 15:if((m=h.n()).done){D.next=42;break}y=m.value,g=initializer_createForOfIteratorHelper(y.content),D.prev=18,g.s();case 20:if((v=g.n()).done){D.next=32;break}if(!(_=v.value).actors){D.next=30;break}b=!1,k=initializer_createForOfIteratorHelper(_.actors);try{for(k.s();!(w=k.n()).done;)x=w.value,p.has(x)||(p.set(x,_.name),b=!0)}catch(t){k.e(t)}finally{k.f()}if(!b){D.next=30;break}return D.next=29,a.getFolderForType("Actor",o.id,_.name,d);case 29:d+=1;case 30:D.next=20;break;case 32:D.next=37;break;case 34:D.prev=34,D.t0=D.catch(18),g.e(D.t0);case 37:return D.prev=37,g.f(),D.finish(37);case 40:D.next=15;break;case 42:D.next=47;break;case 44:D.prev=44,D.t1=D.catch(13),h.e(D.t1);case 47:return D.prev=47,h.f(),D.finish(47);case 50:S=initializer_createForOfIteratorHelper(c),D.prev=51,A=initializer_regeneratorRuntime().mark((function _loop5(){var t,r,i;return initializer_regeneratorRuntime().wrap((function _loop5$(c){for(;;)switch(c.prev=c.next){case 0:if(t=T.value,!p.has(t.name)){c.next=7;break}return c.next=4,a.getFolderForType("Actor",o.id,p.get(t.name));case 4:c.t0=c.sent,c.next=8;break;case 7:c.t0=o;case 8:if(r=c.t0,t.folder=r.id,t._id&&delete t._id,!(i=game.actors.find((function(a){var i;return a.name==t.name&&[o.id,r.id].includes(null===(i=a.folder)||void 0===i?void 0:i.id)})))){c.next=19;break}return t._id=i.id,c.next=16,i.deleteEmbeddedDocuments("Item",i.items.map((function(t){return t.id})));case 16:l.push(t),c.next=20;break;case 19:u.push(t);case 20:case"end":return c.stop()}}),_loop5)})),S.s();case 54:if((T=S.n()).done){D.next=58;break}return D.delegateYield(A(),"t2",56);case 56:D.next=54;break;case 58:D.next=63;break;case 60:D.prev=60,D.t3=D.catch(51),S.e(D.t3);case 63:return D.prev=63,S.f(),D.finish(63);case 66:return D.next=68,Actor.create(u);case 68:return O=D.sent,D.next=71,Actor.updateDocuments(l);case 71:P=initializer_createForOfIteratorHelper(O);try{for(P.s();!(E=P.n()).done;)C=E.value,a.actors[C.name]=C}catch(t){P.e(t)}finally{P.f()}case 73:case"end":return D.stop()}}),_callee12,null,[[13,44,47,50],[18,34,37,40],[51,60,63,66]])}))(),"t2",26);case 26:case"end":return _.stop()}}),_callee13)})));return function(r){return t.apply(this,arguments)}}());case 29:return this.lock=!1,t.find("i").remove(),ui.notifications.notify(game.i18n.localize("initComplete")),i.next=34,this.close();case 34:case"end":return i.stop()}}),_callee14,this,[[4,10],[12,17],[19,24]])}))),function initialize(){return c.apply(this,arguments)})},{key:"dontInitialize",value:(i=initializer_asyncToGenerator(initializer_regeneratorRuntime().mark((function _callee15(){return initializer_regeneratorRuntime().wrap((function _callee15$(t){for(;;)switch(t.prev=t.next){case 0:if(!game.settings.settings.has("".concat(this.module,".initialized"))){t.next=3;break}return t.next=3,game.settings.set(this.module,"initialized",!0);case 3:return ui.notifications.notify(game.i18n.localize("initSkipped")),t.next=6,this.close();case 6:case"end":return t.stop()}}),_callee15,this)}))),function dontInitialize(){return i.apply(this,arguments)})},{key:"submit",value:function submit(t){try{t.callback&&t.callback(this.options.jQuery?this.element:this.element[0])}catch(t){throw ui.notifications.error(t),new Error(t)}}},{key:"getFolderForType",value:(a=initializer_asyncToGenerator(initializer_regeneratorRuntime().mark((function _callee16(r){var a,o,i,c,u=arguments;return initializer_regeneratorRuntime().wrap((function _callee16$(l){for(;;)switch(l.prev=l.next){case 0:return a=u.length>1&&void 0!==u[1]?u[1]:null,o=u.length>2&&void 0!==u[2]?u[2]:null,i=u.length>3&&void 0!==u[3]?u[3]:0,c=u.length>4&&void 0!==u[4]?u[4]:"",o||(o=game.i18n.localize("".concat(this.module,".name"))),l.abrupt("return",t.Z.getFolderForType(r,a,o,i,c));case 6:case"end":return l.stop()}}),_callee16,this)}))),function getFolderForType(t){return a.apply(this,arguments)})}]),DSA5Initializer}();function ChatMessageDSA5_typeof(t){return ChatMessageDSA5_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},ChatMessageDSA5_typeof(t)}function ChatMessageDSA5_classCallCheck(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}function ChatMessageDSA5_defineProperties(t,r){for(var a=0;a=t.length?{done:!0}:{done:!1,value:t[o++]}},e:function e(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var c,u=!0,l=!1;return{s:function s(){a=a.call(t)},n:function n(){var t=a.next();return u=t.done,t},e:function e(t){l=!0,c=t},f:function f(){try{u||null==a.return||a.return()}finally{if(l)throw c}}}}function hotbar_arrayLikeToArray(t,r){(null==r||r>t.length)&&(r=t.length);for(var a=0,o=new Array(r);a=0;--o){var i=this.tryEntries[o],c=i.completion;if("root"===i.tryLoc)return handle("end");if(i.tryLoc<=this.prev){var u=a.call(i,"catchLoc"),l=a.call(i,"finallyLoc");if(u&&l){if(this.prev=0;--o){var i=this.tryEntries[o];if(i.tryLoc<=this.prev&&a.call(i,"finallyLoc")&&this.prev=0;--r){var a=this.tryEntries[r];if(a.finallyLoc===t)return this.complete(a.completion,a.afterLoc),resetTryEntry(a),l}},catch:function _catch(t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc===t){var o=a.completion;if("throw"===o.type){var i=o.arg;resetTryEntry(a)}return i}}throw new Error("illegal catch attempt")},delegateYield:function delegateYield(t,r,a){return this.delegate={iterator:values(t),resultName:r,nextLoc:a},"next"===this.method&&(this.arg=void 0),l}},t}function hotbar_asyncGeneratorStep(t,r,a,o,i,c,u){try{var l=t[c](u),p=l.value}catch(t){return void a(t)}l.done?r(p):Promise.resolve(p).then(o,i)}function hotbar_asyncToGenerator(t){return function(){var r=this,a=arguments;return new Promise((function(o,i){var c=t.apply(r,a);function _next(t){hotbar_asyncGeneratorStep(c,o,i,_next,_throw,"next",t)}function _throw(t){hotbar_asyncGeneratorStep(c,o,i,_next,_throw,"throw",t)}_next(void 0)}))}}function hotbar_classCallCheck(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}function hotbar_defineProperties(t,r){for(var a=0;a0&&void 0!==a[0]&&a[0],r=a.length>1&&void 0!==a[1]?a[1]:{},o.next=4,hotbar_get(hotbar_getPrototypeOf(DSA5Hotbar.prototype),"_render",this).call(this,t,r);case 4:this.addContextColor();case 5:case"end":return o.stop()}}),_callee,this)}))),function _render(){return o.apply(this,arguments)})},{key:"collapse",value:(a=hotbar_asyncToGenerator(hotbar_regeneratorRuntime().mark((function _callee2(){return hotbar_regeneratorRuntime().wrap((function _callee2$(t){for(;;)switch(t.prev=t.next){case 0:if(!this._collapsed){t.next=2;break}return t.abrupt("return",!0);case 2:return $(this.element).addClass("collapsedHotbar"),t.abrupt("return",hotbar_get(hotbar_getPrototypeOf(DSA5Hotbar.prototype),"collapse",this).call(this));case 4:case"end":return t.stop()}}),_callee2,this)}))),function collapse(){return a.apply(this,arguments)})},{key:"expand",value:(r=hotbar_asyncToGenerator(hotbar_regeneratorRuntime().mark((function _callee3(){return hotbar_regeneratorRuntime().wrap((function _callee3$(t){for(;;)switch(t.prev=t.next){case 0:if(this._collapsed){t.next=2;break}return t.abrupt("return",!0);case 2:return $(this.element).removeClass("collapsedHotbar"),t.abrupt("return",hotbar_get(hotbar_getPrototypeOf(DSA5Hotbar.prototype),"expand",this).call(this));case 4:case"end":return t.stop()}}),_callee3,this)}))),function expand(){return r.apply(this,arguments)})},{key:"addContextColor",value:function addContextColor(){var t,r=new RegExp(" ".concat(game.i18n.localize("CHAR.PARRY"),"$")),a=new RegExp(" ".concat(game.i18n.localize("CHAR.ATTACK"),"$")),o=$(this._element).find("#macro-list"),i=hotbar_createForOfIteratorHelper(this.macros);try{for(i.s();!(t=i.n()).done;){var c=t.value;c.macro&&(r.test(c.macro.name)?o.find('[data-macro-id="'.concat(c.macro.id,'"]')).addClass("parry"):a.test(c.macro.name)&&o.find('[data-macro-id="'.concat(c.macro.id,'"]')).addClass("attack"))}}catch(t){i.e(t)}finally{i.f()}}}]),DSA5Hotbar}();function roll_memory_defineProperties(t,r){for(var a=0;a0&&setProperty(this,this.getPath(t,r,a),i)}},{key:"recall",value:function recall(t,r,a){return getProperty(this,this.getPath(t,r,a))}},{key:"formDataSerialize",value:function formDataSerialize(t){var r=t.find("form"),a={};return r.find("select").each((function(){var t=$(this).attr("name");RollMemory.wantedKeys.includes(t)&&(a[t]=$(this).val())})),r.find('input[type="checkbox"]').each((function(){var t=$(this).attr("name");RollMemory.wantedKeys.includes(t)&&(a[t]=this.checked)})),r.find(".specAbs.active").each((function(){a.specAbs||(a.specAbs=[]),a.specAbs.push({id:$(this).attr("data-id"),step:$(this).attr("data-step")})})),t.find('[name="situationalModifiers"] option').each((function(){a.situationalModifiers||(a.situationalModifiers=[]),a.situationalModifiers.push({name:$(this).text().trim(),selected:this.selected})})),a}}],[{key:"wantedKeys",get:function get(){var t=["vision","targetMovement","shooterMovement","quickChange","mountOptions","narrowSpace","advantageousPosition","doubleAttack","reduceCostSpell","forceSpell","increaseCastingTime","decreaseCastingTime","removeGesture","removeFormula"];return $e.Z.isEnabled||t.push("distance"),t}}]),RollMemory}(),xt=__webpack_require__(430);function dsa_active_effects_typeof(t){return dsa_active_effects_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},dsa_active_effects_typeof(t)}function dsa_active_effects_regeneratorRuntime(){dsa_active_effects_regeneratorRuntime=function _regeneratorRuntime(){return t};var t={},r=Object.prototype,a=r.hasOwnProperty,o="function"==typeof Symbol?Symbol:{},i=o.iterator||"@@iterator",c=o.asyncIterator||"@@asyncIterator",u=o.toStringTag||"@@toStringTag";function define(t,r,a){return Object.defineProperty(t,r,{value:a,enumerable:!0,configurable:!0,writable:!0}),t[r]}try{define({},"")}catch(t){define=function define(t,r,a){return t[r]=a}}function wrap(t,r,a,o){var i=r&&r.prototype instanceof Generator?r:Generator,c=Object.create(i.prototype),u=new Context(o||[]);return c._invoke=function(t,r,a){var o="suspendedStart";return function(i,c){if("executing"===o)throw new Error("Generator is already running");if("completed"===o){if("throw"===i)throw c;return doneResult()}for(a.method=i,a.arg=c;;){var u=a.delegate;if(u){var p=maybeInvokeDelegate(u,a);if(p){if(p===l)continue;return p}}if("next"===a.method)a.sent=a._sent=a.arg;else if("throw"===a.method){if("suspendedStart"===o)throw o="completed",a.arg;a.dispatchException(a.arg)}else"return"===a.method&&a.abrupt("return",a.arg);o="executing";var d=tryCatch(t,r,a);if("normal"===d.type){if(o=a.done?"completed":"suspendedYield",d.arg===l)continue;return{value:d.arg,done:a.done}}"throw"===d.type&&(o="completed",a.method="throw",a.arg=d.arg)}}}(t,a,u),c}function tryCatch(t,r,a){try{return{type:"normal",arg:t.call(r,a)}}catch(t){return{type:"throw",arg:t}}}t.wrap=wrap;var l={};function Generator(){}function GeneratorFunction(){}function GeneratorFunctionPrototype(){}var p={};define(p,i,(function(){return this}));var d=Object.getPrototypeOf,h=d&&d(d(values([])));h&&h!==r&&a.call(h,i)&&(p=h);var m=GeneratorFunctionPrototype.prototype=Generator.prototype=Object.create(p);function defineIteratorMethods(t){["next","throw","return"].forEach((function(r){define(t,r,(function(t){return this._invoke(r,t)}))}))}function AsyncIterator(t,r){function invoke(o,i,c,u){var l=tryCatch(t[o],t,i);if("throw"!==l.type){var p=l.arg,d=p.value;return d&&"object"==dsa_active_effects_typeof(d)&&a.call(d,"__await")?r.resolve(d.__await).then((function(t){invoke("next",t,c,u)}),(function(t){invoke("throw",t,c,u)})):r.resolve(d).then((function(t){p.value=t,c(p)}),(function(t){return invoke("throw",t,c,u)}))}u(l.arg)}var o;this._invoke=function(t,a){function callInvokeWithMethodAndArg(){return new r((function(r,o){invoke(t,a,r,o)}))}return o=o?o.then(callInvokeWithMethodAndArg,callInvokeWithMethodAndArg):callInvokeWithMethodAndArg()}}function maybeInvokeDelegate(t,r){var a=t.iterator[r.method];if(void 0===a){if(r.delegate=null,"throw"===r.method){if(t.iterator.return&&(r.method="return",r.arg=void 0,maybeInvokeDelegate(t,r),"throw"===r.method))return l;r.method="throw",r.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var o=tryCatch(a,t.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,l;var i=o.arg;return i?i.done?(r[t.resultName]=i.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=void 0),r.delegate=null,l):i:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,l)}function pushTryEntry(t){var r={tryLoc:t[0]};1 in t&&(r.catchLoc=t[1]),2 in t&&(r.finallyLoc=t[2],r.afterLoc=t[3]),this.tryEntries.push(r)}function resetTryEntry(t){var r=t.completion||{};r.type="normal",delete r.arg,t.completion=r}function Context(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(pushTryEntry,this),this.reset(!0)}function values(t){if(t){var r=t[i];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var o=-1,c=function next(){for(;++o=0;--o){var i=this.tryEntries[o],c=i.completion;if("root"===i.tryLoc)return handle("end");if(i.tryLoc<=this.prev){var u=a.call(i,"catchLoc"),l=a.call(i,"finallyLoc");if(u&&l){if(this.prev=0;--o){var i=this.tryEntries[o];if(i.tryLoc<=this.prev&&a.call(i,"finallyLoc")&&this.prev=0;--r){var a=this.tryEntries[r];if(a.finallyLoc===t)return this.complete(a.completion,a.afterLoc),resetTryEntry(a),l}},catch:function _catch(t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc===t){var o=a.completion;if("throw"===o.type){var i=o.arg;resetTryEntry(a)}return i}}throw new Error("illegal catch attempt")},delegateYield:function delegateYield(t,r,a){return this.delegate={iterator:values(t),resultName:r,nextLoc:a},"next"===this.method&&(this.arg=void 0),l}},t}function dsa_active_effects_asyncGeneratorStep(t,r,a,o,i,c,u){try{var l=t[c](u),p=l.value}catch(t){return void a(t)}l.done?r(p):Promise.resolve(p).then(o,i)}function dsa_active_effects_asyncToGenerator(t){return function(){var r=this,a=arguments;return new Promise((function(o,i){var c=t.apply(r,a);function _next(t){dsa_active_effects_asyncGeneratorStep(c,o,i,_next,_throw,"next",t)}function _throw(t){dsa_active_effects_asyncGeneratorStep(c,o,i,_next,_throw,"throw",t)}_next(void 0)}))}}function dsa_active_effects_ownKeys(t,r){var a=Object.keys(t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);r&&(o=o.filter((function(r){return Object.getOwnPropertyDescriptor(t,r).enumerable}))),a.push.apply(a,o)}return a}function dsa_active_effects_objectSpread(t){for(var r=1;r=t.length?{done:!0}:{done:!1,value:t[o++]}},e:function e(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var c,u=!0,l=!1;return{s:function s(){a=a.call(t)},n:function n(){var t=a.next();return u=t.done,t},e:function e(t){l=!0,c=t},f:function f(){try{u||null==a.return||a.return()}finally{if(l)throw c}}}}function dsa_active_effects_arrayLikeToArray(t,r){(null==r||r>t.length)&&(r=t.length);for(var a=0,o=new Array(r);a')+t.split(",").map((function(t){return"".concat(t,"")})).join(", ")+""}(t,r)},hasLocalization:function hasLocalization(t,r){var a=t.string||t;return game.i18n.has(a)?game.i18n.localize(a):r||""},replaceConditions:t.Z.replaceConditions,floor:function floor(t){return Math.floor(Number(t))},br:function br(t){return t.replace(/\n/g,"
    ")},getAttr:function getAttr(t,r,a){return t.system.characteristics[r][a]},hasElem:function hasElem(t,r){return t.filter((function(t){return r==t})).length},situationalTooltip:function situationalTooltip(t){var r=game.i18n.localize(pe[t.type]||"Modifier"),a="".concat(t.name,"
    ").concat(r,": ").concat(t.value);return t.source&&(a+="
    ".concat(game.i18n.localize("source"),": ").concat(t.source)),a},grouped_each:function grouped_each(t,r,a){var o,i="",c=[];if(r&&r.length>0){for(o=0;o0&&o%t==0&&(i+=a.fn(c),c=[]),c.push(r[o]);i+=a.fn(c)}return i},plantify:function plantify(t){return game.i18n.localize("PLANT.avLevels.".concat(t||0))},oddLength:function oddLength(t){return t.length%2==1}})}(),function dicesonice(){Hooks.once("init",(function(){game.dsa5.apps.DiceSoNiceCustomization=new de})),Hooks.once("diceSoNiceReady",(function(t,r,a,o){t.addColorset({name:"mu",description:"DSA5.mu",category:"DSA5.dies",foreground:"#FFFFFF",background:"#b3241a",edge:"#b3241a",outline:"#FFFFFF",texture:"none"}),t.addColorset({name:"kl",description:"DSA5.kl",category:"DSA5.dies",foreground:"#FFFFFF",background:"#8259a3",edge:"#8259a3",outline:"#FFFFFF",texture:"none"}),t.addColorset({name:"in",description:"DSA5.in",category:"DSA5.dies",foreground:"#FFFFFF",background:"#388834",edge:"#388834",outline:"#FFFFFF",texture:"none"}),t.addColorset({name:"ch",description:"DSA5.ch",category:"DSA5.dies",foreground:"#FFFFFF",background:"#0d0d0d",edge:"#0d0d0d",outline:"#FFFFFF",texture:"none"}),t.addColorset({name:"ff",description:"DSA5.ff",category:"DSA5.dies",foreground:"#000000",background:"#d5b467",edge:"#d5b467",outline:"#FFFFFF",texture:"none"}),t.addColorset({name:"ge",description:"DSA5.ge",category:"DSA5.dies",foreground:"#000000",background:"#688ec4",edge:"#688ec4",outline:"#FFFFFF",texture:"none"}),t.addColorset({name:"ko",description:"DSA5.ko",category:"DSA5.dies",foreground:"#000000",background:"#a3a3a3",edge:"#a3a3a3",outline:"#FFFFFF",texture:"none"}),t.addColorset({name:"kk",description:"DSA5.kk",category:"DSA5.dies",foreground:"#000000",background:"#d6a878",edge:"#d6a878",outline:"#FFFFFF",texture:"none"}),t.addColorset({name:"attack",description:"DSA5.attack",category:"DSA5.dies",foreground:"#FFFFFF",background:"#b3241a",edge:"#b3241a",outline:"#b3241a",texture:"none"}),t.addColorset({name:"dodge",description:"DSA5.dodge",category:"DSA5.dies",foreground:"#FFFFFF",background:"#388834",edge:"#388834",outline:"#FFFFFF",texture:"none"}),t.addColorset({name:"parry",description:"DSA5.parry",category:"DSA5.dies",foreground:"#FFFFFF",background:"#388834",edge:"#388834",outline:"#FFFFFF",texture:"none"}),game.dsa5.apps.DiceSoNiceCustomization.initConfigs(),de.onConnect()}))}(),function actor(){function checkIniChange(t){if(game.combat&&t.changes.some((function(t){return/(system\.status\.initiative|system\.characteristics.mu|system\.characteristics\.ge)/.test(t.key)}))){var r=t.parent.id,a=game.combat.combatants.find((function(t){return t.actor.id==r}));a&&a.recalcInitiative()}}Hooks.on("preDeleteActiveEffect",(function(t,r,a){if(!r.noHook){var o,i=t.parent;if(i&&"Actor"==i.documentName&&getProperty(t,"flags.dsa5.maintain")){var c=[t._id],u=t.name.replace("("+game.i18n.localize("maintainCost")+")","").trim(),l=i.effects.filter((function(r){return r.name.startsWith(u)&&!r.origin&&r.id!=t._id})),p=game.i18n.format("DIALOG.updateMaintainSpell",{actor:i.name});return l&&(p+="

    ".concat(game.i18n.localize("DIALOG.dependentMaintainEffects"),"

    "),p+=l.map((function(t){return'

    ')})).join("")),new Dialog({title:t.name,content:p,default:"yes",buttons:{Yes:{icon:'',label:game.i18n.localize("HELP.pay"),callback:(o=actor_asyncToGenerator(actor_regeneratorRuntime().mark((function _callee(){var r;return actor_regeneratorRuntime().wrap((function _callee$(a){for(;;)switch(a.prev=a.next){case 0:return a.next=2,i.applyMana(Number(getProperty(t,"flags.dsa5.maintain")),getProperty(t,"flags.dsa5.payType"));case 2:a.sent&&(r={startTime:game.time.worldTime},game.combat&&(r.startRound=game.combat.round,r.startTurn=game.combat.turn),i.updateEmbeddedDocuments("ActiveEffect",[{_id:t._id,duration:r}]));case 4:case"end":return a.stop()}}),_callee)}))),function callback(){return o.apply(this,arguments)})},delete:{icon:'',label:game.i18n.localize("delete"),callback:function callback(t){var r,a=actor_createForOfIteratorHelper(t.find(".effectRemoveSelector:checked"));try{for(a.s();!(r=a.n()).done;){var o=r.value;c.push($(o).val())}}catch(t){a.e(t)}finally{a.f()}i.deleteEmbeddedDocuments("ActiveEffect",c,{noHook:!0})}}}}).render(!0),!1}}})),Hooks.on("updateActor",(function(t,r){!game.user.isGM&&t.limited&&hasProperty(r,"system.merchant.hidePlayer")&&ui.sidebar.render(!0)})),Hooks.on("deleteActiveEffect",(function(r,a){if(t.Z.isActiveGM()&&!a.noHook){var o=r.parent;if(o&&"Actor"==o.documentName){var i=actor_toConsumableArray(r.statuses)[0];if("bloodrush"==i)return o.addCondition("stunned",2,!1,!1),!1;if("dead"==i&&game.combat)return o.markDead(!1),!1;if(me.Z.onEffectRemove(o,r),!1===Hooks.call("deleteActorActiveEffect",o,r))return!1}}})),Hooks.on("dropActorSheetData",(function(t,r,a){var o;switch(null===(o=a.data)||void 0===o?void 0:o.type){case"condition":return t.addCondition(a.data.payload.id,1,!1,!1),!1;case"lookup":return r._handleLookup(a.data),!1;case"fullpack":return r._addFullPack(a.data),!1}})),Hooks.on("createActiveEffect",(function(a,o,i){t.Z.isActiveGM()&&(checkIniChange(a),r(a))})),Hooks.on("deleteActiveEffect",(function(r,a,o){t.Z.isActiveGM()&&checkIniChange(r)})),Hooks.on("updateActiveEffect",(function(r,a,i){t.Z.isActiveGM()&&(checkIniChange(r),o(r))}));var r=function(){var t=actor_asyncToGenerator(actor_regeneratorRuntime().mark((function _callee2(t){var r,a;return actor_regeneratorRuntime().wrap((function _callee2$(i){for(;;)switch(i.prev=i.next){case 0:if(r=t.parent){i.next=3;break}return i.abrupt("return");case 3:return i.next=5,o(t,{},r);case 5:if("dead"!=(a=actor_toConsumableArray(t.statuses)[0])||!game.combat){i.next=11;break}return i.next=9,r.markDead(!0);case 9:i.next=14;break;case 11:if("unconscious"!=a){i.next=14;break}return i.next=14,r.addCondition("prone");case 14:case"end":return i.stop()}}),_callee2)})));return function createEffects(r){return t.apply(this,arguments)}}(),o=function(){var r=actor_asyncToGenerator(actor_regeneratorRuntime().mark((function _callee3(r){var o,i,c,u,l,p,d,h,m,y,g=arguments;return actor_regeneratorRuntime().wrap((function _callee3$(v){for(;;)switch(v.prev=v.next){case 0:if(o=g.length>1&&void 0!==g[1]?g[1]:{},(i=g.length>2?g[2]:void 0)||(i=r.parent),i&&"Actor"==i.documentName){v.next=5;break}return v.abrupt("return");case 5:c=/^system\.condition\./,u=actor_createForOfIteratorHelper(r.changes||[]);try{for(u.s();!(l=u.n()).done;)p=l.value,c.test(p.key)&&2==p.mode&&(o[p.key.split(".")[2]]=Number(p.value))}catch(t){u.e(t)}finally{u.f()}d=0,h=Object.keys(o);case 9:if(!(d=4)){v.next=32;break}if("inpain"!=m){v.next=17;break}return v.next=15,i.initResistPainRoll(r);case 15:v.next=32;break;case 17:if(!["encumbered","stunned","feared","confused","trance"].includes(m)){v.next=22;break}return v.next=20,i.addCondition("incapacitated");case 20:v.next=32;break;case 22:if("paralysed"!=m){v.next=27;break}return v.next=25,i.addCondition("rooted");case 25:v.next=32;break;case 27:if(!["drunken","exhaustion"].includes(m)){v.next=32;break}return v.next=30,i.addCondition("stunned");case 30:return v.next=32,i.removeCondition(m);case 32:if(!((Number(o.inpain)||0)>0&&!i.hasCondition("bloodrush")&&i.system.condition.inpain>0&&a.Z.hasVantage(i,game.i18n.localize("LocalizedIDs.frenzy")))){v.next=37;break}return v.next=35,i.addCondition("bloodrush");case 35:y=t.Z.replaceConditions("".concat(game.i18n.format("CHATNOTIFICATION.gainsBloodrush",{character:""+i.name+""}))),ChatMessage.create(t.Z.chatDataSetup(y));case 37:d++,v.next=9;break;case 40:case"end":return v.stop()}}),_callee3)})));return function countableDependentEffects(t){return r.apply(this,arguments)}}(),i=function(){var t=actor_asyncToGenerator(actor_regeneratorRuntime().mark((function _callee4(t,r){return actor_regeneratorRuntime().wrap((function _callee4$(a){for(;;)switch(a.prev=a.next){case 0:(game.dsa5.apps.AskForNameDialog||ge).getDialog(t,r);case 2:case"end":return a.stop()}}),_callee4)})));return function askForName(r,a){return t.apply(this,arguments)}}(),c=function(){var r=actor_asyncToGenerator(actor_regeneratorRuntime().mark((function _callee5(r){var a,o,i,c,u,l,p,d,h,m,g,v,_,b,k,w,x,S,T,A;return actor_regeneratorRuntime().wrap((function _callee5$(O){for(;;)switch(O.prev=O.next){case 0:if(t.Z.isActiveGM()){O.next=2;break}return O.abrupt("return");case 2:if(!game.settings.get("dsa5","randomWeaponSelection")||"character"==r.actor.type){O.next=70;break}a=[],o=[],i=[],c=actor_createForOfIteratorHelper(r.actor.items);try{for(c.s();!(u=c.n()).done;)"meleeweapon"==(l=u.value).type&&l.system.worn.value?y.Z.isShield(l)?o.push(l):a.push(l):"rangeweapon"==l.type&&l.system.worn.value&&i.push(l)}catch(t){c.e(t)}finally{c.f()}if(p=[],!a.length){O.next=49;break}d=a[Math.floor(Math.random()*a.length)],h=d._id,!y.Z.regex2h.test(d.name)&&o.length&&(m=o[Math.floor(Math.random()*o.length)]._id),g=actor_createForOfIteratorHelper(a),O.prev=14,g.s();case 16:if((v=g.n()).done){O.next=23;break}if((_=v.value)._id!=h){O.next=20;break}return O.abrupt("continue",21);case 20:p.push({_id:_._id,system:{worn:{value:!1}}});case 21:O.next=16;break;case 23:O.next=28;break;case 25:O.prev=25,O.t0=O.catch(14),g.e(O.t0);case 28:return O.prev=28,g.f(),O.finish(28);case 31:b=actor_createForOfIteratorHelper(o),O.prev=32,b.s();case 34:if((k=b.n()).done){O.next=41;break}if((w=k.value)._id!=m){O.next=38;break}return O.abrupt("continue",39);case 38:p.push({_id:w._id,system:{worn:{value:!1}}});case 39:O.next=34;break;case 41:O.next=46;break;case 43:O.prev=43,O.t1=O.catch(32),b.e(O.t1);case 46:return O.prev=46,b.f(),O.finish(46);case 49:if(!i.length){O.next=69;break}x=i[Math.floor(Math.random()*i.length)]._id,S=actor_createForOfIteratorHelper(i),O.prev=52,S.s();case 54:if((T=S.n()).done){O.next=61;break}if((A=T.value)._id!=x){O.next=58;break}return O.abrupt("continue",59);case 58:p.push({_id:A._id,system:{worn:{value:!1}}});case 59:O.next=54;break;case 61:O.next=66;break;case 63:O.prev=63,O.t2=O.catch(52),S.e(O.t2);case 66:return O.prev=66,S.f(),O.finish(66);case 69:p.length&&r.actor.updateEmbeddedDocuments("Item",p);case 70:case"end":return O.stop()}}),_callee5,null,[[14,25,28,31],[32,43,46,49],[52,63,66,69]])})));return function randomWeaponSelection(t){return r.apply(this,arguments)}}(),u=function(){var r=actor_asyncToGenerator(actor_regeneratorRuntime().mark((function _callee6(r,a){var o,c,u,l,p,d,h,m,y;return actor_regeneratorRuntime().wrap((function _callee6$(g){for(;;)switch(g.prev=g.next){case 0:if(t.Z.isActiveGM()){g.next=2;break}return g.abrupt("return");case 2:if(!(o=r.actor).hasPlayerOwner){g.next=5;break}return g.abrupt("return");case 5:if(0!=(c=Number(game.settings.get("dsa5","obfuscateTokenNames")))&&"loot"!=getProperty(o,"merchant.merchantType")){g.next=8;break}return g.abrupt("return");case 8:if(u=canvas.scene.tokens.filter((function(t){return t.actor&&t.actor.id===o.id})),l=game.i18n.localize("unknown"),![2,4].includes(c)){g.next=16;break}if(r.id||r._id){g.next=14;break}return g.abrupt("return");case 14:return i(r,c),g.abrupt("return");case 16:if(u.length>0&&c<3){p=u.length,d=actor_createForOfIteratorHelper(u);try{for(d.s();!(h=d.n()).done;)m=h.value,(y=m.name.match(/\d+$/))&&Number(y[0])>p&&(p=Number(y[0]))}catch(t){d.e(t)}finally{d.f()}l="".concat(u[0].name.replace(/ \d{1,}$/,"")," ").concat(p+1)}a.name=l;case 18:case"end":return g.stop()}}),_callee6)})));return function obfuscateName(t,a){return r.apply(this,arguments)}}();Hooks.on("updateToken",(function(t,r,a){b.Z.updateTokenHook(t,r,a)})),Hooks.on("deleteToken",(function(t){b.Z.deleteTokenHook(t),ye.hide(t)})),Hooks.on("preCreateToken",(function(r,a,o,i){var c=r.actor;if(c){var l={};"loot"==getProperty(c,"system.merchant.merchantType")?mergeObject(l,{displayBars:0}):getProperty(c,"system.config.autoBar")&&(mergeObject(l,{bar1:{attribute:"status.wounds"}}),c.system.isMage?mergeObject(l,{bar2:{attribute:"status.astralenergy"}}):c.system.isPriest?mergeObject(l,{bar2:{attribute:"status.karmaenergy"}}):mergeObject(l,{bar2:{attribute:"tbd"}})),getProperty(c,"system.config.autoSize")&&t.Z.calcTokenSize(c,l),u(r,l),r.updateSource(l)}})),Hooks.on("createToken",(function(t,r,a){r.noHook||(u(t,{}),c(t),b.Z.createTokenHook(t,r,a))})),Hooks.on("hoverToken",(function(t,r){game.settings.get("dsa5","showWeaponsOnHover")&&(r?ye.show(t):ye.hide(t))}))}(),function macro_support(){Hooks.on("hotbarDrop",(function(t,r,a){if("dodge"==r.mod){var o={name:game.i18n.localize(r.mod),img:"systems/dsa5/icons/categories/Dodge.webp"};return createHotBarMacro(game.user.isGM||null==r.actorId?'game.dsa5.macro.charMacro("'.concat(r.mod,'")'):'game.dsa5.macro.charMacroById("'.concat(r.mod,'", "').concat(r.actorId,'")'),o.name,o.img,a)}if("attackWeaponless"==r.mod||"parryWeaponless"==r.mod){var i={name:game.i18n.localize(r.mod),img:"systems/dsa5/icons/categories/attack_weaponless.webp"};return createHotBarMacro(game.user.isGM||null==r.actorId?'game.dsa5.macro.weaponLessMacro("'.concat(r.mod,'")'):'game.dsa5.macro.weaponLessMacroId("'.concat(r.mod,'", "').concat(r.actorId,'")'),i.name,i.img,a)}if("Item"==r.type){var c=fromUuidSync(r.uuid);if(!["ritual","ceremony","meleeweapon","rangeweapon","skill","combatskill","spell","liturgy","char","trait"].includes(c.type))return;if(!("meleeweapon"!=c.type&&"combatskill"!=c.type||["attack","parry"].includes(r.mod)))return;if(("rangeweapon"==c.type||"trait"==c.type)&&!["attack"].includes(r.mod))return;var u='{mod: "'.concat(r.mod,'"}');return createHotBarMacro(game.user.isGM||null==r.actorId?'game.dsa5.macro.itemMacro("'.concat(c.name,'", "').concat(c.type,'", ').concat(u,");"):'game.dsa5.macro.itemMacroById("'.concat(r.actorId,'", "').concat(c.name,'", "').concat(c.type,'", ').concat(u,")"),null==r.mod?c.name:"".concat(c.name," - ").concat(game.i18n.localize("CHAR."+r.mod.toUpperCase())),c.img,a)}if("Actor"==r.type||"JournalEntry"==r.type){var l=fromUuidSync(r.uuid);return createHotBarMacro("(await fromUuid('".concat(r.uuid,"')).sheet.render(true)"),l.name,l.img,a)}}))}(),chatlog(),function ready(){Hooks.on("ready",ready_asyncToGenerator(ready_regeneratorRuntime().mark((function _callee(){var a;return ready_regeneratorRuntime().wrap((function _callee$(i){for(;;)switch(i.prev=i.next){case 0:if(game.socket.on("system.dsa5",(function(t){if("hideDeletedSheet"===t.type){var r=t.payload.target.token?game.actors.tokens[t.payload.target.token]:game.actors.get(t.payload.target.actor);we.hideDeletedSheet(r)}})),game.user.isGM&&game.socket.on("system.dsa5",(function(a){var o,i,c;if(t.Z.isActiveGM())switch(a.type){case"updateKeepField":r.Z.allowedforeignfields.includes(a.payload.field)&&game.actors.get(a.payload.actorId).update((o={},i=a.payload.field,c=a.payload.updateData,i in o?Object.defineProperty(o,i,{value:c,enumerable:!0,configurable:!0,writable:!0}):o[i]=c,o));break;case"target":var u=game.scenes.get(a.payload.scene);new Token(u.getEmbeddedDocument("Token",a.payload.target)).actor.update({"flags.oppose":a.payload.opposeFlag});break;case"addEffect":me.Z.applyEffect(a.payload.id,a.payload.mode,a.payload.actors);break;case"updateMsg":game.messages.get(a.payload.id).update(a.payload.updateData);break;case"deleteMsg":game.messages.get(a.payload.id).delete();break;case"showDamage":N.Z.showDamage(game.messages.get(a.payload.id),a.payload.hide);break;case"hideQueryButton":N.Z.hideReactionButton(a.payload.id);break;case"updateGroupCheck":Oe.Z.rerenderGC(game.messages.get(a.payload.messageId),a.payload.data);break;case"updateAttackMessage":game.messages.get(a.payload.messageId).update({"flags.data.unopposedStartMessage":a.payload.startMessageId});break;case"clearCombat":game.combat&&game.combat.nextRound();break;case"clearOpposed":N.Z.clearOpposed(game.actors.get(a.payload.actorId));break;case"updateDefenseCount":game.combat&&game.combat.updateDefenseCount(a.payload.speaker);break;case"trade":var l=a.payload.source.token?game.actors.tokens[a.payload.source.token]:game.actors.get(a.payload.source.actor),p=a.payload.target.token?game.actors.tokens[a.payload.target.token]:game.actors.get(a.payload.target.actor);we.finishTransaction(l,p,a.payload.price,a.payload.itemId,a.payload.buy,a.payload.amount);break;case"playWhisperSound":a.payload.whisper.includes(game.user.id)&&AudioHelper.play({src:a.payload.soundPath,volume:.8,loop:!1},!1);break;case"socketedConditionAddActor":fromUuid(a.payload.id).then((function(t){new g.Z(t).socketedConditionAddActor(a.payload.actors.map((function(t){return game.actors.get(t)})),a.payload.data)}));break;case"socketedConditionAdd":fromUuid(a.payload.id).then((function(t){new g.Z(t).socketedConditionAdd(a.payload.targets,a.payload.data)}));break;case"socketedRemoveCondition":fromUuid(a.payload.id).then((function(t){new g.Z(t).socketedRemoveCondition(a.payload.targets,a.payload.coreId)}));break;case"socketedActorTransformation":fromUuid(a.payload.id).then((function(t){new g.Z(t).socketedActorTransformation(a.payload.targets,a.payload.update)}));break;case"itemDrop":var h=a.payload.sourceActorId?game.actors.get(a.payload.sourceActorId):void 0;fromUuid(a.payload.itemId).then((function(t){Pe(h,t,a.payload.data,a.payload.amount)}));break;case"finalizeFoodContribution":case"hideDeletedSheet":case"finalizeidentification":case"updateHits":case"hideResistButton":break;case"reduceGroupSchip":d.Z.reduceGroupSchip();break;case"summonCreature":Te.createConjuration(a.payload);break;default:console.warn("Unhandled socket data type ".concat(a.type))}})),i.t1=t.Z.moduleEnabled("vtta-tokenizer"),!i.t1){i.next=7;break}return i.next=6,game.settings.get("dsa5","tokenizerSetup");case 6:i.t1=!i.sent;case 7:if(i.t0=i.t1,!i.t0){i.next=10;break}i.t0=game.user.isGM;case 10:if(!i.t0){i.next=19;break}return i.next=13,game.settings.set("vtta-tokenizer","default-frame-pc","[data] systems/dsa5/icons/backgrounds/token_green.webp");case 13:return i.next=15,game.settings.set("vtta-tokenizer","default-frame-npc","[data] systems/dsa5/icons/backgrounds/token_black.webp");case 15:return i.next=17,game.settings.set("vtta-tokenizer","default-frame-neutral","[data] systems/dsa5/icons/backgrounds/token_blue.webp");case 17:return i.next=19,game.settings.set("dsa5","tokenizerSetup",!0);case 19:if(i.t3=t.Z.moduleEnabled("dice-so-nice"),!i.t3){i.next=24;break}return i.next=23,game.settings.get("dsa5","diceSetup");case 23:i.t3=!i.sent;case 24:if(i.t2=i.t3,!i.t2){i.next=27;break}i.t2=game.user.isGM;case 27:if(!i.t2){i.next=32;break}return i.next=30,game.settings.set("dice-so-nice","immediatelyDisplayChatMessages",!0);case 30:return i.next=32,game.settings.set("dsa5","diceSetup",!0);case 32:return i.next=34,_e.firstTimeMessage();case 34:o.Z.setupSubClasses(),Le.showOneMessage(),game.settings.get("dsa5","disableTokenhotbar")||x.registerTokenHotbar(),De(),ze.connectHooks(),a=function hook(t){"settings"==t.tabName&&(Ne.Z.travelAgency(),Hooks.off("changeSidebarTab",hook))},Hooks.on("changeSidebarTab",a),(0,Re.v)(),(0,He.Y)();case 43:case"end":return i.stop()}}),_callee)}))))}(),function chat_context(){var r=function fateAvailable(r,a){return t.Z.fateAvailable(r,a)},a=function canHurt(r){var a,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"damage.value",i=game.messages.get(r.attr("data-message-id")).flags.opposeData,c=!!i&&(null===(a=t.Z.getSpeaker(i.speakerDefend))||void 0===a?void 0:a.isOwner);return((game.user.isGM||c)&&r.find(".opposed-card").length||r.find(".dice-roll").length)&&(getProperty(i,o)||0)>0},o=function canHurtSP(t){return a(t,"damage.sp")},i=function canCostMana(t){var r=game.messages.get(t.attr("data-message-id"));return!(!r.speaker.actor||!r.flags.data||!game.actors.get(r.speaker.actor).isOwner&&!game.user.isGM)&&(["liturgy","ceremony","spell","ritual","magicalsign"].includes(r.flags.data.preData.source.type)||getProperty(r.flags.data.preData,"calculatedSpellModifiers.costsMana"))},c=function canUnhideData(t){if(game.user.isGM&&game.settings.get("dsa5","hideOpposedDamage")){var r=game.messages.get(t.attr("data-message-id"));return"hideData"in r.flags&&r.flags.hideData}return!1},u=function canHideData(t){if(game.user.isGM&&game.settings.get("dsa5","hideOpposedDamage")){var r=game.messages.get(t.attr("data-message-id"));return"hideData"in r.flags&&!r.flags.hideData}return!1},l=function canImproveRoll(t){var a=arguments.length>1&&void 0!==arguments[1]&&arguments[1],o=game.messages.get(t.attr("data-message-id"));if(o.speaker.actor&&o.flags.data&&o.flags.data.postData.successLevel>-2){var i=game.actors.get(o.speaker.actor);if(i.isOwner&&r(i,a)){var c=o.flags.data.preData.source.type,u=o.flags.data.preData.mode||"";["skill","spell","liturgy","ritual","ceremony"].includes(c)&&(c="char");var l=game.i18n.localize("SCHIPSKILLS.".concat(c).concat(u));return!o.flags.data.fateImproved&&i.items.getName(l)}}return!1},p=function canImproveRollGroup(t){return l(t,!0)},h=function canIncreaseQS(t){var a=arguments.length>1&&void 0!==arguments[1]&&arguments[1],o=game.messages.get(t.attr("data-message-id"));if(o.speaker.actor&&o.flags.data){var i=game.actors.get(o.speaker.actor);if(i.isOwner&&r(i,a)&&!o.flags.data.fatePointAddQSUsed)return o.flags.data.postData.successLevel>0&&null!=o.flags.data.postData.qualityStep}return!1},m=function canIncreaseQSGroup(t){return h(t,!0)},y=function isTalented(t){var r=game.messages.get(t.attr("data-message-id"));if(r.speaker.actor&&r.flags.data){var a=game.actors.get(r.speaker.actor);if(a.isOwner)return null!=a.items.find((function(t){return t.name=="".concat(game.i18n.localize("LocalizedIDs.aptitude")," (").concat(r.flags.data.preData.source.name,")")}))&&!r.flags.data.talentedRerollUsed}return!1},g=function canRerollDamage(t){var a=arguments.length>1&&void 0!==arguments[1]&&arguments[1],o=game.messages.get(t.attr("data-message-id"));if(o.speaker.actor&&o.flags.data){var i=game.actors.get(o.speaker.actor);if(i.isOwner&&r(i,a))return null!=o.flags.data.postData.damageRoll&&!o.flags.data.fatePointDamageRerollUsed}return!1},v=function canRerollDamageGroup(t){return g(t,!0)},_=function canReroll(t){var a=arguments.length>1&&void 0!==arguments[1]&&arguments[1],o=game.messages.get(t.attr("data-message-id"));if(o.speaker.actor&&o.flags.data){var i=game.actors.get(o.speaker.actor);if(i.isOwner&&r(i,a))return!(o.flags.data.fatePointRerollUsed||"regenerate"==o.flags.data.postData.rollType)}return!1},b=function canRerollGroup(t){return _(t,!0)},k=function canHeal(t){var r=game.messages.get(t.attr("data-message-id"));return!!(r.speaker.actor&&r.flags.data&&game.actors.get(r.speaker.actor).isOwner&&["LeP","KaP","AsP"].some((function(t){return null!=getProperty(r.flags,"data.postData.".concat(t))})))&&!r.flags.data.healApplied},w=function showHideData(t){if(game.user.isGM){var r=game.messages.get(t.attr("data-message-id"));if("hideData"in r.flags){var a=!r.flags.hideData,o=$(r.content);o.find(".hideAnchor")[a?"addClass":"removeClass"]("hideData"),o=$("
    ").append(o),r.update({content:o.html(),"flags.hideData":a})}}},x=function canApplyDefaultRolls(t){var r=game.messages.get(t.data("messageId"));return!(!r||!canvas.tokens)&&r.isRoll&&r.isContentVisible&&canvas.tokens.controlled.length&&t.find(".dice-roll").length},S=function useFate(t,r){var a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,o=game.messages.get(t.attr("data-message-id"));game.actors.get(o.speaker.actor).useFateOnRoll(o,r,a)},T=function(){var r=chat_context_asyncToGenerator(chat_context_regeneratorRuntime().mark((function _callee(r,a){var o,i,c,u,l,p,d=arguments;return chat_context_regeneratorRuntime().wrap((function _callee$(h){for(;;)switch(h.prev=h.next){case 0:if(o=d.length>2&&void 0!==d[2]?d[2]:1,i=game.messages.get(r.attr("data-message-id")),c=i.flags.opposeData,u=null==c?void 0:c.speakerDefend,(l=t.Z.getSpeaker(u)).isOwner){h.next=7;break}return h.abrupt("return",ui.notifications.error(game.i18n.localize("DSAError.DamagePermission")));case 7:return h.next=9,l.applyDamage(c.damage[a]*o);case 9:if(p={"flags.data.damageApplied":!0,content:i.content.replace(/hideAnchor">/,'hideAnchor">'))},!game.user.isGM){h.next=15;break}return h.next=13,i.update(p);case 13:h.next=16;break;case 15:game.socket.emit("system.dsa5",{type:"updateMsg",payload:{id:r.attr("data-message-id"),updateData:p}});case 16:case"end":return h.stop()}}),_callee)})));return function applyDamage(t,a){return r.apply(this,arguments)}}(),A=function applyChatCardDamage(t,r){var a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,o=game.messages.get(t.data("messageId")).rolls[0];return Promise.all(canvas.tokens.controlled.map((function(t){var i=t.actor,c=Math.round(("sp"!=r?o.total-d.Z.armorValue(i).armor:o.total)*a);return i.applyDamage(Math.max(0,c))})))},O=function(){var r=chat_context_asyncToGenerator(chat_context_regeneratorRuntime().mark((function _callee2(r){var a,o,i,c,u,l,p,d,h,m,y,g,v,_,b;return chat_context_regeneratorRuntime().wrap((function _callee2$(k){for(;;)switch(k.prev=k.next){case 0:if(a=game.messages.get(r.attr("data-message-id")),o=a.flags.data,(i=t.Z.getSpeaker(a.speaker)).isOwner){k.next=5;break}return k.abrupt("return",ui.notifications.error(game.i18n.localize("DSAError.DamagePermission")));case 5:return c=o.preData.calculatedSpellModifiers.maintainCost.trim(),u=["ritual","spell"].includes(o.preData.source.type)||getProperty(o.preData.calculatedSpellModifiers,"costsMana")?"AsP":"KaP",k.next=9,i.applyMana(o.preData.calculatedSpellModifiers.finalcost,u);case 9:if(l=k.sent,!(c&&0!=c&&l&&o.postData.successLevel>0)){k.next=36;break}p=o.preData.source.name,k.prev=12,d=c.match(/^\d{1,3}/)[0],h=(h=c.replace(/^\d{1,3}/,"").match(/\d{1,3}/))&&Number(h[0])||1,m={name:"".concat(p," (").concat(game.i18n.localize("maintainCost"),")"),icon:"icons/svg/daze.svg",flags:{dsa5:{value:null,editable:!0,description:c,maintain:d,payType:u,custom:!0}},changes:[],duration:{}},y=[{regEx:new RegExp(game.i18n.localize("DSAREGEXmaintain.combatRounds"),"gi"),seconds:5},{regEx:new RegExp(game.i18n.localize("DSAREGEXmaintain.minutes"),"gi"),seconds:60},{regEx:new RegExp(game.i18n.localize("DSAREGEXmaintain.hours"),"gi"),seconds:3600},{regEx:new RegExp(game.i18n.localize("DSAREGEXmaintain.days"),"gi"),seconds:86400},{regEx:new RegExp(game.i18n.localize("DSAREGEXmaintain.seconds"),"gi"),seconds:1},{regEx:new RegExp(game.i18n.localize("DSAREGEXmaintain.weeks"),"gi"),seconds:604800},{regEx:new RegExp(game.i18n.localize("DSAREGEXmaintain.months"),"gi"),seconds:2592e3},{regEx:new RegExp(game.i18n.localize("DSAREGEXmaintain.years"),"gi"),seconds:3024e4}],g=0,v=y;case 19:if(!(g/,'')});case 38:case"end":return k.stop()}}),_callee2,null,[[12,33]])})));return function payMana(t){return r.apply(this,arguments)}}();Hooks.on("getChatLogEntryContext",(function(r,d){var P,E;d.push({name:game.i18n.localize("CHATCONTEXT.hideData"),icon:'',condition:u,callback:function callback(t){w(t)}},{name:game.i18n.localize("CHATCONTEXT.showData"),icon:'',condition:c,callback:function callback(t){w(t)}},{name:game.i18n.localize("regenerate"),icon:'',condition:k,callback:(E=chat_context_asyncToGenerator(chat_context_regeneratorRuntime().mark((function _callee3(r){var a,o;return chat_context_regeneratorRuntime().wrap((function _callee3$(i){for(;;)switch(i.prev=i.next){case 0:return i.next=2,game.messages.get(r.attr("data-message-id"));case 2:if(a=i.sent,(o=t.Z.getSpeaker(a.speaker)).isOwner){i.next=6;break}return i.abrupt("return",ui.notifications.error(game.i18n.localize("DSAError.DamagePermission")));case 6:return i.next=8,a.update({"flags.data.healApplied":!0,content:a.content.replace(/<\/div>$/,'
    ')});case 8:return i.next=10,o.applyRegeneration(a.flags.data.postData.LeP,a.flags.data.postData.AsP,a.flags.data.postData.KaP);case 10:case"end":return i.stop()}}),_callee3)}))),function callback(t){return E.apply(this,arguments)})},{name:game.i18n.localize("CHATCONTEXT.ApplyMana"),icon:'',condition:i,callback:(P=chat_context_asyncToGenerator(chat_context_regeneratorRuntime().mark((function _callee4(t){return chat_context_regeneratorRuntime().wrap((function _callee4$(r){for(;;)switch(r.prev=r.next){case 0:O(t);case 1:case"end":return r.stop()}}),_callee4)}))),function callback(t){return P.apply(this,arguments)})},{name:game.i18n.localize("CHATCONTEXT.ApplyDamage"),icon:'',condition:a,callback:function callback(t){T(t,"value")}},{name:game.i18n.localize("CHATCONTEXT.ApplyDamageSP"),icon:'',condition:o,callback:function callback(t){T(t,"sp")}},{name:game.i18n.localize("CHATCONTEXT.ApplyDamage"),icon:'',condition:x,callback:function callback(t){A(t,"value")}},{name:game.i18n.localize("CHATCONTEXT.ApplyDamageSP"),icon:'',condition:x,callback:function callback(t){A(t,"sp")}},{name:game.i18n.localize("CHATCONTEXT.Reroll"),icon:'',condition:_,callback:function callback(t){S(t,"reroll")}},{name:game.i18n.localize("CHATCONTEXT.RerollGroup"),icon:'',condition:b,callback:function callback(t){S(t,"reroll",1)}},{name:game.i18n.localize("CHATCONTEXT.talentedReroll"),icon:'',condition:y,callback:function callback(t){S(t,"isTalented")}},{name:game.i18n.localize("CHATCONTEXT.AddQS"),icon:'',condition:h,callback:function callback(t){S(t,"addQS")}},{name:game.i18n.localize("CHATCONTEXT.AddQSGroup"),icon:'',condition:m,callback:function callback(t){S(t,"addQS",1)}},{name:game.i18n.localize("CHATCONTEXT.rerollDamage"),icon:'',condition:g,callback:function callback(t){S(t,"rerollDamage")}},{name:game.i18n.localize("CHATCONTEXT.rerollDamageGroup"),icon:'',condition:v,callback:function callback(t){S(t,"rerollDamage",1)}},{name:game.i18n.localize("CHATCONTEXT.improveFate"),icon:'',condition:l,callback:function callback(t){S(t,"Improve")}},{name:game.i18n.localize("CHATCONTEXT.improveFateGroup"),icon:'',condition:p,callback:function callback(t){S(t,"Improve",1)}}),game.settings.get("dsa5","doubleDamageOptions")&&d.push({name:game.i18n.localize("CHATCONTEXT.ApplyDamage")+" x2",icon:'',condition:a,callback:function callback(t){T(t,"value",2)}},{name:game.i18n.localize("CHATCONTEXT.ApplyDamageSP")+" x2",icon:'',condition:o,callback:function callback(t){T(t,"sp",2)}},{name:game.i18n.localize("CHATCONTEXT.ApplyDamage")+" x2",icon:'',condition:x,callback:function callback(t){A(t,"value",2)}},{name:game.i18n.localize("CHATCONTEXT.ApplyDamageSP")+" x2",icon:'',condition:x,callback:function callback(t){A(t,"sp",2)}})}))}(),statuseffect(),function sidebar(){Hooks.on("renderSettings",(function(t,r,a){var o=$('"));o.click((function(){window.open("https://github.com/Plushtoast/dsa5-foundryVTT/issues","_blank")})),r.find("#settings-documentation").append(o),(o=$('"))).click((function(){window.open("https://github.com/Plushtoast/dsa5-foundryVTT/wiki","_blank")})),r.find("#settings-documentation").append(o),(o=$('')).click((function(){window.open(game.i18n.localize("fshopLink"),"_blank")})),r.find("#settings-documentation").append(o);var i=game.system.title.split("/")["de"==game.i18n.lang?0:1],c=r.find("#game-details .system .system-info").html();r.find("#game-details .system").html(''.concat(i,'').concat(c,""))})),Hooks.on("renderCompendiumDirectory",(function(t,r,a){var o=$('"));r.find(".header-actions").append(o),o.click((function(){game.dsa5.itemLibrary.render(!0)})),r.find('li[data-pack="dsa5.money"]').remove()})),Hooks.once("renderCompendiumDirectory",(function(t,r,a){var o,i="de"==game.i18n.lang?"en":"de",c=sidebar_createForOfIteratorHelper(game.packs.filter((function(t){return getProperty(t.metadata,"flags.dsalang")==i})));try{var u=function _loop(){var t=o.value,a="".concat(t.metadata.packageName,".").concat(t.metadata.name);game.packs.delete(a),game.data.packs=game.data.packs.filter((function(t){return t.id!=a})),r.find('li[data-pack="'.concat(a,'"]')).remove()};for(c.s();!(o=c.n()).done;)u()}catch(t){c.e(t)}finally{c.f()}})),Hooks.on("renderActorDirectory",(function(t,r,a){if(!game.user.isGM){var o,i=sidebar_createForOfIteratorHelper(t.documents.filter((function(t){return t.isMerchant()&&getProperty(t,"system.merchant.hidePlayer")})));try{for(i.s();!(o=i.n()).done;){var c=o.value;r.find('[data-document-id="'.concat(c.id,'"]')).remove()}}catch(t){i.e(t)}finally{i.f()}}}))}(),function journal(){Hooks.on("renderJournalSheet",(function(t,r,a){r.find(".close").attr("data-tooltip","SHEET.Close"),r.find(".entry-image").attr("data-tooltip","SHEET.imageView"),r.find(".entry-text").attr("data-tooltip","SHEET.textView"),r.find(".share-image").attr("data-tooltip","SHEET.showToPlayers"),r.find(".import").attr("data-tooltip","SHEET.import"),r.find(".panMapNote").attr("data-tooltip","SHEET.panMapNote"),r.find(".increaseFontSize").attr("data-tooltip","SHEET.increaseFontSize")})),Hooks.on("renderJournalPageSheet",(function(t,r,a){_.Z.bindRollCommands(r),u.Z.bindButtons(r),r.find("img").mousedown((function(r){2==r.button&&game.dsa5.apps.DSA5_Utility.showArtwork({name:t.name,uuid:"",img:$(r.currentTarget).attr("src")})})),bindImgToCanvasDragStart(r)})),Hooks.on("getJournalSheetHeaderButtons",(function(t,r){var a,o;r.unshift({class:"increaseFontSize",icon:"fas fa-arrows-up-down",onclick:(a=journal_asyncToGenerator(journal_regeneratorRuntime().mark((function _callee(){return journal_regeneratorRuntime().wrap((function _callee$(r){for(;;)switch(r.prev=r.next){case 0:return r.abrupt("return",increaseFontSize($(t._element).find(".journal-page-content")));case 1:case"end":return r.stop()}}),_callee)}))),function onclick(){return a.apply(this,arguments)})}),(t.document.sceneNote||t.document.pages.some((function(t){return t.sceneNote})))&&r.unshift({class:"panMapNote",icon:"fas fa-map-pin",onclick:(o=journal_asyncToGenerator(journal_regeneratorRuntime().mark((function _callee2(){var r,a;return journal_regeneratorRuntime().wrap((function _callee2$(o){for(;;)switch(o.prev=o.next){case 0:if(r=t._getCurrentPage(),!(a=Array.from(t.document.pages))[r].sceneNote){o.next=6;break}doc=a[r],o.next=13;break;case 6:if(!t.document.sceneNote){o.next=10;break}doc=t.document,o.next=13;break;case 10:if(doc=a.find((function(t){return t.sceneNote})),doc){o.next=13;break}return o.abrupt("return");case 13:canvas.notes.panToNote(doc.sceneNote);case 14:case"end":return o.stop()}}),_callee2)}))),function onclick(){return o.apply(this,arguments)})})}))}(),tokenHUD(),Ze.Z(),function scene(){Hooks.on("preCreateScene",(function(t,r,a,o){var i,c;null!==(i=r.grid)&&void 0!==i&&i.units||t.updateSource({grid:{units:game.i18n.localize("gridUnits")}}),!a.dsaInit&&null!==(c=r.notes)&&void 0!==c&&c.some((function(t){return getProperty(t,"flags.dsa5.initName")}))&&ui.notifications.warn(game.i18n.localize("DSAError.mapsViaJournalbrowser"))})),Hooks.on("preCreateActiveEffect",(function(t,r,a,o){if("Actor"==t.parent.documentName){var i={duration:{}};t.duration.startTime||(i.duration.startTime=game.time.worldTime),game.combat?(i.duration.combat=game.combat.id,i.duration.startRound=game.combat.round,i.duration.startTurn=game.combat.turn,!t.duration.rounds&&t.duration.seconds&&(i.duration.rounds=t.duration.seconds/5),t.updateSource(i)):t.updateSource(i)}}))}(),function dsarolls(){Roll.prototype.editRollAtIndex=function(t){var r,a=[],o=dsarolls_createForOfIteratorHelper(t);try{for(o.s();!(r=o.n()).done;){var i,c=r.value,u=c.index,l=c.val,p=0,d=dsarolls_createForOfIteratorHelper(this.terms);try{for(d.s();!(i=d.n()).done;){var h=i.value,m=h instanceof DiceTerm||"DiceTerm"==h.class||h instanceof Die||"Die"==h.class,y=h instanceof OperatorTerm;if(m||h.faces){if(h.results[u-p]){var g=h.results[u-p].result;h.results[u-p].result=l,a.push(g)}m||(h.total=h.results.reduce((function(t,r){return t+r.result}),0)),p+=h.results.length}else y||"OperatorTerm"!=h.class&&!h.operator||(h.total=h.operator)}}catch(t){d.e(t)}finally{d.f()}a.push(0)}}catch(t){o.e(t)}finally{o.f()}return this._total=this._evaluateTotal(),a}}()}()})()})(); \ No newline at end of file diff --git a/lang/de.json b/lang/de.json index a5340fae..10b7a7c6 100644 --- a/lang/de.json +++ b/lang/de.json @@ -855,7 +855,7 @@ "playerVisibility": "Sichtbarkeit für Spieler" }, "Migrakel": { - "Migration": "Actor Migration", + "Migration": "Akteur Migration", "migrationDone": "Migration abgeschlossen", "spells": "Aktualisiere Effekte und Effektformeln von allen Zaubern, Liturgien, Ritualen und Zeremonien oder Ersetze alle Werte. ALLE MANUELLEN MODIFIKATIONEN WERDEN ÜBERSCHRIEBEN!", "spellsShort": "Zauber migrieren", diff --git a/lazy/patchhtml/news_de_5.1.0.html b/lazy/patchhtml/news_de_5.1.0.html index 0c77b8be..d284d84f 100644 --- a/lazy/patchhtml/news_de_5.1.0.html +++ b/lazy/patchhtml/news_de_5.1.0.html @@ -152,9 +152,31 @@

    Die Schwarze Katze - Einsteigerbox

    - Die Einsteigerbox begleitet euch bei ersten Schritten in der Welt von Die Schwarze Katze. Mit 5 - vorgefertigten Helden, ausführlichem Tutorial, zwei weiteren Abenteuern, Tokens und Kartenmaterial. - Einfach runterladen und losspielen! + Erlebe die nächtliche Welt der Katzen in der "Die Schwarze Katze - Einsteigerbox Die Drachen von + Wolldorf" auf Foundry VTT! Schlüpfe in deine Stiefel, setze deinen Hut auf und stecke deine Nadelklinge + in den Gürtel, denn das Abenteuer ruft. In Wolldorf warten Schätze und Drachen darauf, von + abenteuerlustigen Katzen entdeckt zu werden! +

    +

    + Diese Einsteigerbox ist perfekt für Kinder, Erwachsene, Rollenspielneulinge und erfahrene Spieler + gleichermaßen. Alles, was du brauchst, um in die Welt von "Die Schwarze Katze" einzutauchen, findest du + in diesem Modul: fünf vorgefertigte Helden, ein Tutorial, zwei zusätzliche Abenteuer, vorangelegte + Akteure und wunderschön exklusiv illustrierte Karten. Einfach Foundry öffnen und ohne Vorkenntnisse + losspielen. +

    +

    + Das Modul enthält: +

      +
    • Fünf vorgefertigte Helden
    • + +
    • Karte von Wolldorf
    • + +
    • Vorangelegte Akteure und Tokens
    • +
    + Die Einsteigerbox begleitet euch bei ersten Schritten in der Welt von Die Schwarze Katze. Mit 5 + vorgefertigten Helden, ausführlichem Tutorial, zwei weiteren Abenteuern, Tokens und Kartenmaterial. Einfach + runterladen und losspielen! +

    diff --git a/modules/hooks/configuration.js b/modules/hooks/configuration.js index 6411cccf..19b8adc0 100644 --- a/modules/hooks/configuration.js +++ b/modules/hooks/configuration.js @@ -90,6 +90,7 @@ export function setupConfiguration() { default: 24, type: Number }) + game.settings.register("dsa5", "journalFontSizeIndex", { name: "journalFontSizeIndex", hint: "journalFontSizeIndex", diff --git a/modules/system/itemlibrary.js b/modules/system/itemlibrary.js index 29c04da1..88dec71f 100644 --- a/modules/system/itemlibrary.js +++ b/modules/system/itemlibrary.js @@ -561,7 +561,7 @@ export default class DSA5ItemLibrary extends Application { SceneNavigation.displayProgressBar({label: game.i18n.format('Library.loading', {item: ""}), pct: 0}) const target = $(this._element).find(`*[data-tab="${category}"]`) this.showLoading(target, category) - const packs = game.packs.filter(p => p.documentName == document && (game.user.isGM || !p.private)) + const packs = game.packs.filter(p => p.documentName == document && (game.user.isGM || !p.private) && !p.metadata.label.startsWith("WZ-")) const percentage = 100 / (packs.length + 1) let count = percentage const actorFields = ["name", "system.type", "system.description.value", "img"] diff --git a/modules/system/migrakel.js b/modules/system/migrakel.js index 3d0386f4..183f4e49 100644 --- a/modules/system/migrakel.js +++ b/modules/system/migrakel.js @@ -115,11 +115,13 @@ export default class Migrakel { } await actor.createEmbeddedDocuments("Item", itemsToCreate); await actor.deleteEmbeddedDocuments("Item", itemsToDelete); - ui.notifications.notify(game.i18n.localize("Migrakel.migrationDone")); + + if(!Migrakel.silent) + ui.notifications.notify(game.i18n.localize("Migrakel.migrationDone")); } - static async updateSpellsAndLiturgies(actor) { - const res = await this.showDialog(game.i18n.localize("Migrakel.spells"), true) + static async updateSpellsAndLiturgies(actor, preChoice = undefined) { + const res = preChoice ?? await this.showDialog(game.i18n.localize("Migrakel.spells"), true) const condition = (x) => { return ["spell", "liturgy", "ritual", "ceremony", "spellextension"].includes(x.type); }; @@ -145,10 +147,12 @@ export default class Migrakel { }; await this.updateVals(actor, condition, updator); } + return res } - static async updateSpecialAbilities(actor) { - if (await this.showDialog(game.i18n.localize("Migrakel.abilities"))) { + static async updateSpecialAbilities(actor, preChoice = undefined) { + const res = preChoice ?? await this.showDialog(game.i18n.localize("Migrakel.abilities")) + if (res) { const updator = (find) => { let update = { system: { effect: { value: find.system.effect.value } }, @@ -190,10 +194,12 @@ export default class Migrakel { }; await this.updateVals(actor, condition, updator); } + return res } - static async updateCombatskills(actor) { - if (await this.showDialog(game.i18n.localize("Migrakel.cskills"))) { + static async updateCombatskills(actor, preChoice = undefined) { + const res = preChoice ?? await this.showDialog(game.i18n.localize("Migrakel.cskills")) + if (res) { const updator = (find) => { return { effects: find.effects.toObject(), @@ -204,10 +210,12 @@ export default class Migrakel { }; await this.updateVals(actor, condition, updator); } + return res } - static async updateSkills(actor) { - if (await this.showDialog(game.i18n.localize("Migrakel.skills"))) { + static async updateSkills(actor, preChoice = undefined) { + const res = preChoice ?? await this.showDialog(game.i18n.localize("Migrakel.skills")) + if (res) { const condition = (x) => { return ["skill"].includes(x.type); }; @@ -218,6 +226,7 @@ export default class Migrakel { }; await this.updateVals(actor, condition, updator); } + return res } static updateMacro(update, find) { @@ -229,8 +238,9 @@ export default class Migrakel { } } - static async updateGear(actor) { - if (await this.showDialog(game.i18n.localize("Migrakel.gear"))) { + static async updateGear(actor, preChoice = undefined) { + const choice = preChoice ?? await this.showDialog(game.i18n.localize("Migrakel.gear")) + if (choice) { let condition = (x) => { return [ "meleeweapon", @@ -274,5 +284,6 @@ export default class Migrakel { }; await this.updateVals(actor, condition, updator); } + return choice } } \ No newline at end of file diff --git a/system.json b/system.json index c091d8e1..6b9c6b35 100644 --- a/system.json +++ b/system.json @@ -2,7 +2,7 @@ "id": "dsa5", "title": "Das Schwarze Auge/The Dark Eye (5th Edition)", "description": "The \"Das Schwarze Auge\" system for Foundry VTT. Includes all relevant mechanisms to play in the wonderous world of Aventuria and Das Schwarze Auge/The Dark Eye.", - "version": "5.1.0", + "version": "5.1.1", "authors": [{ "name": "Plushtoast" },{ @@ -78,15 +78,15 @@ "primaryTokenAttribute": "status.wounds", "secondaryTokenAttribute": "status.astralenergy", "compatibility": { - "minimum": "11.296", + "minimum": "11.306", "verified": "11", "maximum": "11" }, "url": "https://github.com/Plushtoast/dsa5-foundryVTT", "manifest": "https://raw.githubusercontent.com/Plushtoast/dsa5-foundryVTT/foundry11/system.json", - "download": "https://github.com/Plushtoast/dsa5-foundryVTT/releases/download/5.1.0/dsa5-foundryVTT-5.1.0.zip", + "download": "https://github.com/Plushtoast/dsa5-foundryVTT/releases/download/5.1.1/dsa5-foundryVTT-5.1.1.zip", "name": "dsa5", - "minimumCoreVersion": "11.296", + "minimumCoreVersion": "11.306", "packFolders": [ { "name": "Item",