narrat 3.9.4 → 3.9.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -171,7 +171,7 @@ This will fail in production.`);s=ep,s._s.has(r)||(i?hx(r,t,o,s):H9(r,o,s),proce
171
171
  *
172
172
  * MIT License
173
173
  */(function(){HowlerGlobal.prototype._pos=[0,0,0],HowlerGlobal.prototype._orientation=[0,0,-1,0,1,0],HowlerGlobal.prototype.stereo=function(n){var r=this;if(!r.ctx||!r.ctx.listener)return r;for(var o=r._howls.length-1;o>=0;o--)r._howls[o].stereo(n);return r},HowlerGlobal.prototype.pos=function(n,r,o){var i=this;if(!i.ctx||!i.ctx.listener)return i;if(r=typeof r!="number"?i._pos[1]:r,o=typeof o!="number"?i._pos[2]:o,typeof n=="number")i._pos=[n,r,o],typeof i.ctx.listener.positionX<"u"?(i.ctx.listener.positionX.setTargetAtTime(i._pos[0],Howler.ctx.currentTime,.1),i.ctx.listener.positionY.setTargetAtTime(i._pos[1],Howler.ctx.currentTime,.1),i.ctx.listener.positionZ.setTargetAtTime(i._pos[2],Howler.ctx.currentTime,.1)):i.ctx.listener.setPosition(i._pos[0],i._pos[1],i._pos[2]);else return i._pos;return i},HowlerGlobal.prototype.orientation=function(n,r,o,i,a,s){var c=this;if(!c.ctx||!c.ctx.listener)return c;var l=c._orientation;if(r=typeof r!="number"?l[1]:r,o=typeof o!="number"?l[2]:o,i=typeof i!="number"?l[3]:i,a=typeof a!="number"?l[4]:a,s=typeof s!="number"?l[5]:s,typeof n=="number")c._orientation=[n,r,o,i,a,s],typeof c.ctx.listener.forwardX<"u"?(c.ctx.listener.forwardX.setTargetAtTime(n,Howler.ctx.currentTime,.1),c.ctx.listener.forwardY.setTargetAtTime(r,Howler.ctx.currentTime,.1),c.ctx.listener.forwardZ.setTargetAtTime(o,Howler.ctx.currentTime,.1),c.ctx.listener.upX.setTargetAtTime(i,Howler.ctx.currentTime,.1),c.ctx.listener.upY.setTargetAtTime(a,Howler.ctx.currentTime,.1),c.ctx.listener.upZ.setTargetAtTime(s,Howler.ctx.currentTime,.1)):c.ctx.listener.setOrientation(n,r,o,i,a,s);else return l;return c},Howl.prototype.init=function(n){return function(r){var o=this;return o._orientation=r.orientation||[1,0,0],o._stereo=r.stereo||null,o._pos=r.pos||null,o._pannerAttr={coneInnerAngle:typeof r.coneInnerAngle<"u"?r.coneInnerAngle:360,coneOuterAngle:typeof r.coneOuterAngle<"u"?r.coneOuterAngle:360,coneOuterGain:typeof r.coneOuterGain<"u"?r.coneOuterGain:0,distanceModel:typeof r.distanceModel<"u"?r.distanceModel:"inverse",maxDistance:typeof r.maxDistance<"u"?r.maxDistance:1e4,panningModel:typeof r.panningModel<"u"?r.panningModel:"HRTF",refDistance:typeof r.refDistance<"u"?r.refDistance:1,rolloffFactor:typeof r.rolloffFactor<"u"?r.rolloffFactor:1},o._onstereo=r.onstereo?[{fn:r.onstereo}]:[],o._onpos=r.onpos?[{fn:r.onpos}]:[],o._onorientation=r.onorientation?[{fn:r.onorientation}]:[],n.call(this,r)}}(Howl.prototype.init),Howl.prototype.stereo=function(n,r){var o=this;if(!o._webAudio)return o;if(o._state!=="loaded")return o._queue.push({event:"stereo",action:function(){o.stereo(n,r)}}),o;var i=typeof Howler.ctx.createStereoPanner>"u"?"spatial":"stereo";if(typeof r>"u")if(typeof n=="number")o._stereo=n,o._pos=[n,0,0];else return o._stereo;for(var a=o._getSoundIds(r),s=0;s<a.length;s++){var c=o._soundById(a[s]);if(c)if(typeof n=="number")c._stereo=n,c._pos=[n,0,0],c._node&&(c._pannerAttr.panningModel="equalpower",(!c._panner||!c._panner.pan)&&t(c,i),i==="spatial"?typeof c._panner.positionX<"u"?(c._panner.positionX.setValueAtTime(n,Howler.ctx.currentTime),c._panner.positionY.setValueAtTime(0,Howler.ctx.currentTime),c._panner.positionZ.setValueAtTime(0,Howler.ctx.currentTime)):c._panner.setPosition(n,0,0):c._panner.pan.setValueAtTime(n,Howler.ctx.currentTime)),o._emit("stereo",c._id);else return c._stereo}return o},Howl.prototype.pos=function(n,r,o,i){var a=this;if(!a._webAudio)return a;if(a._state!=="loaded")return a._queue.push({event:"pos",action:function(){a.pos(n,r,o,i)}}),a;if(r=typeof r!="number"?0:r,o=typeof o!="number"?-.5:o,typeof i>"u")if(typeof n=="number")a._pos=[n,r,o];else return a._pos;for(var s=a._getSoundIds(i),c=0;c<s.length;c++){var l=a._soundById(s[c]);if(l)if(typeof n=="number")l._pos=[n,r,o],l._node&&((!l._panner||l._panner.pan)&&t(l,"spatial"),typeof l._panner.positionX<"u"?(l._panner.positionX.setValueAtTime(n,Howler.ctx.currentTime),l._panner.positionY.setValueAtTime(r,Howler.ctx.currentTime),l._panner.positionZ.setValueAtTime(o,Howler.ctx.currentTime)):l._panner.setPosition(n,r,o)),a._emit("pos",l._id);else return l._pos}return a},Howl.prototype.orientation=function(n,r,o,i){var a=this;if(!a._webAudio)return a;if(a._state!=="loaded")return a._queue.push({event:"orientation",action:function(){a.orientation(n,r,o,i)}}),a;if(r=typeof r!="number"?a._orientation[1]:r,o=typeof o!="number"?a._orientation[2]:o,typeof i>"u")if(typeof n=="number")a._orientation=[n,r,o];else return a._orientation;for(var s=a._getSoundIds(i),c=0;c<s.length;c++){var l=a._soundById(s[c]);if(l)if(typeof n=="number")l._orientation=[n,r,o],l._node&&(l._panner||(l._pos||(l._pos=a._pos||[0,0,-.5]),t(l,"spatial")),typeof l._panner.orientationX<"u"?(l._panner.orientationX.setValueAtTime(n,Howler.ctx.currentTime),l._panner.orientationY.setValueAtTime(r,Howler.ctx.currentTime),l._panner.orientationZ.setValueAtTime(o,Howler.ctx.currentTime)):l._panner.setOrientation(n,r,o)),a._emit("orientation",l._id);else return l._orientation}return a},Howl.prototype.pannerAttr=function(){var n=this,r=arguments,o,i,a;if(!n._webAudio)return n;if(r.length===0)return n._pannerAttr;if(r.length===1)if(typeof r[0]=="object")o=r[0],typeof i>"u"&&(o.pannerAttr||(o.pannerAttr={coneInnerAngle:o.coneInnerAngle,coneOuterAngle:o.coneOuterAngle,coneOuterGain:o.coneOuterGain,distanceModel:o.distanceModel,maxDistance:o.maxDistance,refDistance:o.refDistance,rolloffFactor:o.rolloffFactor,panningModel:o.panningModel}),n._pannerAttr={coneInnerAngle:typeof o.pannerAttr.coneInnerAngle<"u"?o.pannerAttr.coneInnerAngle:n._coneInnerAngle,coneOuterAngle:typeof o.pannerAttr.coneOuterAngle<"u"?o.pannerAttr.coneOuterAngle:n._coneOuterAngle,coneOuterGain:typeof o.pannerAttr.coneOuterGain<"u"?o.pannerAttr.coneOuterGain:n._coneOuterGain,distanceModel:typeof o.pannerAttr.distanceModel<"u"?o.pannerAttr.distanceModel:n._distanceModel,maxDistance:typeof o.pannerAttr.maxDistance<"u"?o.pannerAttr.maxDistance:n._maxDistance,refDistance:typeof o.pannerAttr.refDistance<"u"?o.pannerAttr.refDistance:n._refDistance,rolloffFactor:typeof o.pannerAttr.rolloffFactor<"u"?o.pannerAttr.rolloffFactor:n._rolloffFactor,panningModel:typeof o.pannerAttr.panningModel<"u"?o.pannerAttr.panningModel:n._panningModel});else return a=n._soundById(parseInt(r[0],10)),a?a._pannerAttr:n._pannerAttr;else r.length===2&&(o=r[0],i=parseInt(r[1],10));for(var s=n._getSoundIds(i),c=0;c<s.length;c++)if(a=n._soundById(s[c]),a){var l=a._pannerAttr;l={coneInnerAngle:typeof o.coneInnerAngle<"u"?o.coneInnerAngle:l.coneInnerAngle,coneOuterAngle:typeof o.coneOuterAngle<"u"?o.coneOuterAngle:l.coneOuterAngle,coneOuterGain:typeof o.coneOuterGain<"u"?o.coneOuterGain:l.coneOuterGain,distanceModel:typeof o.distanceModel<"u"?o.distanceModel:l.distanceModel,maxDistance:typeof o.maxDistance<"u"?o.maxDistance:l.maxDistance,refDistance:typeof o.refDistance<"u"?o.refDistance:l.refDistance,rolloffFactor:typeof o.rolloffFactor<"u"?o.rolloffFactor:l.rolloffFactor,panningModel:typeof o.panningModel<"u"?o.panningModel:l.panningModel};var f=a._panner;f||(a._pos||(a._pos=n._pos||[0,0,-.5]),t(a,"spatial"),f=a._panner),f.coneInnerAngle=l.coneInnerAngle,f.coneOuterAngle=l.coneOuterAngle,f.coneOuterGain=l.coneOuterGain,f.distanceModel=l.distanceModel,f.maxDistance=l.maxDistance,f.refDistance=l.refDistance,f.rolloffFactor=l.rolloffFactor,f.panningModel=l.panningModel}return n},Sound.prototype.init=function(n){return function(){var r=this,o=r._parent;r._orientation=o._orientation,r._stereo=o._stereo,r._pos=o._pos,r._pannerAttr=o._pannerAttr,n.call(this),r._stereo?o.stereo(r._stereo):r._pos&&o.pos(r._pos[0],r._pos[1],r._pos[2],r._id)}}(Sound.prototype.init),Sound.prototype.reset=function(n){return function(){var r=this,o=r._parent;return r._orientation=o._orientation,r._stereo=o._stereo,r._pos=o._pos,r._pannerAttr=o._pannerAttr,r._stereo?o.stereo(r._stereo):r._pos?o.pos(r._pos[0],r._pos[1],r._pos[2],r._id):r._panner&&(r._panner.disconnect(0),r._panner=void 0,o._refreshBuffer(r)),n.call(this)}}(Sound.prototype.reset);var t=function(n,r){r=r||"spatial",r==="spatial"?(n._panner=Howler.ctx.createPanner(),n._panner.coneInnerAngle=n._pannerAttr.coneInnerAngle,n._panner.coneOuterAngle=n._pannerAttr.coneOuterAngle,n._panner.coneOuterGain=n._pannerAttr.coneOuterGain,n._panner.distanceModel=n._pannerAttr.distanceModel,n._panner.maxDistance=n._pannerAttr.maxDistance,n._panner.refDistance=n._pannerAttr.refDistance,n._panner.rolloffFactor=n._pannerAttr.rolloffFactor,n._panner.panningModel=n._pannerAttr.panningModel,typeof n._panner.positionX<"u"?(n._panner.positionX.setValueAtTime(n._pos[0],Howler.ctx.currentTime),n._panner.positionY.setValueAtTime(n._pos[1],Howler.ctx.currentTime),n._panner.positionZ.setValueAtTime(n._pos[2],Howler.ctx.currentTime)):n._panner.setPosition(n._pos[0],n._pos[1],n._pos[2]),typeof n._panner.orientationX<"u"?(n._panner.orientationX.setValueAtTime(n._orientation[0],Howler.ctx.currentTime),n._panner.orientationY.setValueAtTime(n._orientation[1],Howler.ctx.currentTime),n._panner.orientationZ.setValueAtTime(n._orientation[2],Howler.ctx.currentTime)):n._panner.setOrientation(n._orientation[0],n._orientation[1],n._orientation[2])):(n._panner=Howler.ctx.createStereoPanner(),n._panner.pan.setValueAtTime(n._stereo,Howler.ctx.currentTime)),n._panner.connect(n._node),n._paused||n._parent.pause(n._id,!0).play(n._id,!0)}})()})(Ts);function ki(e){return new Promise((t,n)=>{setTimeout(t,e)})}const mx=e=>e.reduce((t,n)=>({...t,[n]:n}),{}),vx=e=>e!==null&&typeof e=="object"&&typeof e.then=="function"&&typeof e.catch=="function",G9=["music","ambiant","sound"],J9=mx(G9),Po=eo("audio",{state:()=>{const e=new Map;for(const t in J9)e.set(t,{channels:[],options:{volume:1}});return{modes:e,masterVolume:1}},actions:{stopAll(){this.modes.forEach(e=>{e.channels.forEach((t,n)=>{t&&(this.actuallyStopChannel(t),e.channels[n]=null)})})},async stopChannel(e,t){const n=this.getAudioChannel(e,t);if(!n)return;const{fadeOutTime:r}=F0(n.audio);if(this.setAudioChannel(e,t,null),Fi().options.musicFadeOutTime){const o=Ua(n.audio);o&&o.fade(o.volume(n.howlerId),0,r,n.howlerId),await ki(r)}this.actuallyStopChannel(n)},async pauseChannel(e,t){const n=this.getAudioChannel(e,t);if(!n)return;const r=Ua(n.audio);if(!r){St(`Could not find audio ${n.audio}`);return}r.pause(n.howlerId)},async playChannel(e,t,n){Ts.Howler.ctx.state==="suspended"&&(console.warn("Audio context is suspended :o"),Ts.Howler.ctx.resume());const r=this.getAudioChannel(e,n);if(e==="sound")return this.actuallyPlayChannel(e,n,t);r&&r.audio!==t?await this.changeChannel(e,t,n):r&&r.audio===t?await this.resumeChannel(e,n):await this.actuallyPlayChannel(e,n,t)},async resumeChannel(e,t){const n=this.getAudioChannel(e,t);if(!n)return;const r=Ua(n.audio);if(!r){St(`Could not find audio ${n.audio}`);return}r.play(n.howlerId)},async changeChannel(e,t,n){this.getAudioChannel(e,n)&&e!=="sound"&&await this.stopChannel(e,n),await this.actuallyPlayChannel(e,n,t)},actuallyStopChannel(e){yve(e.audio,e.howlerId)},getAudioChannel(e,t){return this.modes.get(e).channels[t]||null},setAudioChannel(e,t,n){this.modes.get(e).channels[t]=n},async actuallyPlayChannel(e,t,n){const r=Ua(n);if(!r){St(`Could not find audio ${n}`);return}const{fadeInTime:o,fadeInDelay:i}=F0(n),a=this.audioVolume(e,n);if(e!=="sound"){const s=r.play();r.volume(0,s),r.pause(s),this.setAudioChannel(e,t,{audio:n,howlerId:s}),await ki(i);const c=this.getAudioChannel(e,t);c!==null&&c.audio===n&&(r.play(s),r.fade(0,a,o,s))}else if(e==="sound"){const s=r.play();r.volume(a,s),this.setAudioChannel(e,t,{audio:n,howlerId:s})}},reloadAudio(e){for(const t in e.modes){if(t==="sound")continue;const n=t;this.modes.get(n).options=Xn(e.modes[n].options);for(const r in e.modes[n].channels){const o=e.modes[n].channels[r];o&&o.audio&&this.actuallyPlayChannel(n,Number(r),o.audio)}}},stopSound(e){const t=Ua(e);t&&t.stop()},generateSaveData(){const e={};for(const t in J9){const n=this.modes.get(t);e[t]={options:Xn(n.options),channels:Xn(n.channels).map(r=>r?{audio:r.audio}:{audio:null})}}return{modes:e,masterVolume:this.masterVolume}},loadSaveData(e){this.masterVolume=e.masterVolume},reset(){this.stopAll()},setModeVolume(e,t){const n=this.modes.get(e);n.options.volume=t;for(const r in n.channels){const o=n.channels[r];if(o){const i=Ua(o.audio);i&&i.volume(this.modeVolume(e),o.howlerId)}}},setMasterVolume(e){this.masterVolume=e,Ts.Howler.volume(e)},modeVolume(e){return this.masterVolume*this.modes.get(e).options.volume},audioVolume(e,t){var n;return this.modeVolume(e)*(((n=Dz(t))==null?void 0:n.volume)??1)}}}),Q9={};Ts.Howler.volume(.5);let gx={};async function vve(e){qi.log("Loading audio");const t=[];Ts.Howler.volume(e.options.volume);for(const n in e.files){const r=e.files[n];r.src||(r.src=r.path,r.path||console.error(`Audio config for ${n} doesn't have any \`src\` value to find the file`),console.warn("Using `path` for audio and musics is deprecated. Please replace `path` with `src` in your config file!")),t.push(gve(n,e.files[n]))}return e.audioTriggers&&(gx=e.audioTriggers),Promise.all(t)}function uu(e){gx[e]&&Po().playChannel("sound",gx[e],0)}async function gve(e,t){return new Promise((n,r)=>{const o=new Ts.Howl({...t,src:ci(t.src)});o.load(),Q9[e]=o,n()})}function yve(e,t){const n=Ua(e);if(!n){hu(`Could not find music ${e}`);return}n.stop(t)}function Ua(e){return Q9[e]}function bve(e){const t=Ua(e),{fadeInTime:n}=F0(e),r=t.play(),i=Po().audioVolume("music",e);return t.fade(0,i,n,r),r}async function wve(e,t){const n=Ua(e),{fadeOutTime:r}=F0(e);n.fade(n.volume(t),0,r,t),await ki(r),n.stop(t)}function kve(e,t){return e-t*$p().options.extraPointsPerLevel}function Y9(e,t){const{options:n}=$p();let r=e;n.showDifficultyWithoutModifiers||(r=kve(e,t));const o=$p().options;let i=!1,a=0,s=o.difficultyText[0][1];for(;!i;)o.difficultyText.length>a&&r>=o.difficultyText[a][0]?s=o.difficultyText[a][1]:i=!0,a++;let c="";return n.showDifficultyText&&n.showDifficultyNumber?c=`${s} (${r})`:n.showDifficultyText?c=s:n.showDifficultyNumber&&(c=r.toString()),c}function xve({skill:e,skillCheckId:t,value:n}){const r=Jr(),o=r.getSkillCheck(t),i=W0(e),a=r.skills[e].level,s=Y9(n,a);let c=!0,l=`<span class='skill-check'>[<span class='skill-check-name'>${i.name}</span> - `;return o.happened?o.succeeded?l="":(c=!1,l+=` <span class='skill-check-difficulty'>${s}</span> - <span class='skill-check-failed'>FAILED</span>]</span>`):l+=` <span class='skill-check-difficulty'>${s}</span>]</span>`,{difficultyText:l,allowed:c}}function _ve(e,t){const n=Jr(),r=W0(t.skill),o=Y9(t.difficulty,n.skills[t.skill].level);return`<span class='passive-skill-check skill-check'>[<span class='skill-check-name'>${r.name}</span> - <span class='skill-check-difficulty'>${o}</span> - ${e?'<span class="skill-check-success">Success</span>':'<span class="skill-check-failed">Failure</span>'}]</span>`}function Sve(e){const{options:t}=$p(),n=jve(t,e),i=Jr().skills[e].level*t.extraPointsPerLevel;let a=n.reduce((s,c)=>s+c.unmodified,i);return t.finalRollIsHighest?(a=n.reduce((s,c)=>c.modified>s?c.modified:s,0),qi.log(`[SKILL CHECK] Keeping only highest roll: ${a}`)):t.finalRollIsLowest&&(a=n.reduce((s,c)=>c.modified<s?c.modified:s,n[0].modified),qi.log(`[SKILL CHECK] Keeping only lowest roll: ${a}`)),{roll:a,rolls:n}}function jve(e,t){const r=Jr().skills[t],o=r.level*e.extraPointsPerLevel;let{diceRange:i,diceCount:a}=e;e.extraDicePerLevel&&(a+=e.extraDicePerLevel*r.level);const s=[];for(let c=0;c<a;c++){const l=Cve(i),f=l+o;qi.log(`[SKILL CHECK] Roll ${c+1}/${a}: ${f}. (Base roll: ${l}, modifier: ${o} - Skill level: ${r.level})`),s.push({unmodified:l,modified:f})}return s}function Cve(e){return Math.floor(Math.random()*e[1])+e[0]}function $ve(e){const{skills:t}=Ns(),{roll:n,rolls:r}=Sve(e.skill),o=t[e.skill];let i=!1;if(typeof e.winsNeeded=="number"){const a=r.reduce((s,c)=>(X9(c.modified,e.difficulty)&&s++,s),0);a>=e.winsNeeded&&(i=!0),qi.log(`[SKILL CHECK ${o.name}] - Dice pool mode. ${e.winsNeeded} wins needed. Got ${a} successes.
174
- (${e.id} - ${a}/${e.winsNeeded} - rolls: ${JSON.stringify(r.map(s=>s.modified))})`)}else i=X9(n,e.difficulty),qi.log(`[SKILL CHECK ${o.name}]: ${i?"✅":"❌"}`,`(${e.id}) - ${n}/${e.difficulty}`);return uu(i?"onSkillCheckSuccess":"onSkillCheckFailure"),i}function X9(e,t){const{options:n}=$p();let r=e>=t;return n.successOnRollsBelowThreshold&&(r=e<=t),n.failOnRollsEqualToThreshold&&e===t&&(r=!1),r}var P={};(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.Type=e.JsonType=e.JavaScriptTypeBuilder=e.JsonTypeBuilder=e.TypeBuilder=e.TypeBuilderError=e.TransformEncodeBuilder=e.TransformDecodeBuilder=e.TemplateLiteralDslParser=e.TemplateLiteralGenerator=e.TemplateLiteralGeneratorError=e.TemplateLiteralFinite=e.TemplateLiteralFiniteError=e.TemplateLiteralParser=e.TemplateLiteralParserError=e.TemplateLiteralResolver=e.TemplateLiteralPattern=e.TemplateLiteralPatternError=e.UnionResolver=e.KeyArrayResolver=e.KeyArrayResolverError=e.KeyResolver=e.ObjectMap=e.Intrinsic=e.IndexedAccessor=e.TypeClone=e.TypeExtends=e.TypeExtendsResult=e.TypeExtendsError=e.ExtendsUndefined=e.TypeGuard=e.TypeGuardUnknownTypeError=e.ValueGuard=e.FormatRegistry=e.TypeBoxError=e.TypeRegistry=e.PatternStringExact=e.PatternNumberExact=e.PatternBooleanExact=e.PatternString=e.PatternNumber=e.PatternBoolean=e.Kind=e.Hint=e.Optional=e.Readonly=e.Transform=void 0,e.Transform=Symbol.for("TypeBox.Transform"),e.Readonly=Symbol.for("TypeBox.Readonly"),e.Optional=Symbol.for("TypeBox.Optional"),e.Hint=Symbol.for("TypeBox.Hint"),e.Kind=Symbol.for("TypeBox.Kind"),e.PatternBoolean="(true|false)",e.PatternNumber="(0|[1-9][0-9]*)",e.PatternString="(.*)",e.PatternBooleanExact=`^${e.PatternBoolean}$`,e.PatternNumberExact=`^${e.PatternNumber}$`,e.PatternStringExact=`^${e.PatternString}$`;var t;(function(T){const x=new Map;function O(){return new Map(x)}T.Entries=O;function j(){return x.clear()}T.Clear=j;function C(ce){return x.delete(ce)}T.Delete=C;function _(ce){return x.has(ce)}T.Has=_;function F(ce,_e){x.set(ce,_e)}T.Set=F;function ee(ce){return x.get(ce)}T.Get=ee})(t||(e.TypeRegistry=t={}));class n extends Error{constructor(x){super(x)}}e.TypeBoxError=n;var r;(function(T){const x=new Map;function O(){return new Map(x)}T.Entries=O;function j(){return x.clear()}T.Clear=j;function C(ce){return x.delete(ce)}T.Delete=C;function _(ce){return x.has(ce)}T.Has=_;function F(ce,_e){x.set(ce,_e)}T.Set=F;function ee(ce){return x.get(ce)}T.Get=ee})(r||(e.FormatRegistry=r={}));var o;(function(T){function x(se){return Array.isArray(se)}T.IsArray=x;function O(se){return typeof se=="bigint"}T.IsBigInt=O;function j(se){return typeof se=="boolean"}T.IsBoolean=j;function C(se){return se instanceof globalThis.Date}T.IsDate=C;function _(se){return se===null}T.IsNull=_;function F(se){return typeof se=="number"}T.IsNumber=F;function ee(se){return typeof se=="object"&&se!==null}T.IsObject=ee;function ce(se){return typeof se=="string"}T.IsString=ce;function _e(se){return se instanceof globalThis.Uint8Array}T.IsUint8Array=_e;function xe(se){return se===void 0}T.IsUndefined=xe})(o||(e.ValueGuard=o={}));class i extends n{}e.TypeGuardUnknownTypeError=i;var a;(function(T){function x(z){try{return new RegExp(z),!0}catch{return!1}}function O(z){if(!o.IsString(z))return!1;for(let U=0;U<z.length;U++){const Z=z.charCodeAt(U);if(Z>=7&&Z<=13||Z===27||Z===127)return!1}return!0}function j(z){return F(z)||pe(z)}function C(z){return o.IsUndefined(z)||o.IsBigInt(z)}function _(z){return o.IsUndefined(z)||o.IsNumber(z)}function F(z){return o.IsUndefined(z)||o.IsBoolean(z)}function ee(z){return o.IsUndefined(z)||o.IsString(z)}function ce(z){return o.IsUndefined(z)||o.IsString(z)&&O(z)&&x(z)}function _e(z){return o.IsUndefined(z)||o.IsString(z)&&O(z)}function xe(z){return o.IsUndefined(z)||pe(z)}function se(z){return ze(z,"Any")&&ee(z.$id)}T.TAny=se;function Ie(z){return ze(z,"Array")&&z.type==="array"&&ee(z.$id)&&pe(z.items)&&_(z.minItems)&&_(z.maxItems)&&F(z.uniqueItems)&&xe(z.contains)&&_(z.minContains)&&_(z.maxContains)}T.TArray=Ie;function oe(z){return ze(z,"AsyncIterator")&&z.type==="AsyncIterator"&&ee(z.$id)&&pe(z.items)}T.TAsyncIterator=oe;function ye(z){return ze(z,"BigInt")&&z.type==="bigint"&&ee(z.$id)&&C(z.exclusiveMaximum)&&C(z.exclusiveMinimum)&&C(z.maximum)&&C(z.minimum)&&C(z.multipleOf)}T.TBigInt=ye;function de(z){return ze(z,"Boolean")&&z.type==="boolean"&&ee(z.$id)}T.TBoolean=de;function Fe(z){return ze(z,"Constructor")&&z.type==="Constructor"&&ee(z.$id)&&o.IsArray(z.parameters)&&z.parameters.every(U=>pe(U))&&pe(z.returns)}T.TConstructor=Fe;function Y(z){return ze(z,"Date")&&z.type==="Date"&&ee(z.$id)&&_(z.exclusiveMaximumTimestamp)&&_(z.exclusiveMinimumTimestamp)&&_(z.maximumTimestamp)&&_(z.minimumTimestamp)&&_(z.multipleOfTimestamp)}T.TDate=Y;function Q(z){return ze(z,"Function")&&z.type==="Function"&&ee(z.$id)&&o.IsArray(z.parameters)&&z.parameters.every(U=>pe(U))&&pe(z.returns)}T.TFunction=Q;function ve(z){return ze(z,"Integer")&&z.type==="integer"&&ee(z.$id)&&_(z.exclusiveMaximum)&&_(z.exclusiveMinimum)&&_(z.maximum)&&_(z.minimum)&&_(z.multipleOf)}T.TInteger=ve;function Ae(z){return ze(z,"Intersect")&&!(o.IsString(z.type)&&z.type!=="object")&&o.IsArray(z.allOf)&&z.allOf.every(U=>pe(U)&&!wn(U))&&ee(z.type)&&(F(z.unevaluatedProperties)||xe(z.unevaluatedProperties))&&ee(z.$id)}T.TIntersect=Ae;function Pe(z){return ze(z,"Iterator")&&z.type==="Iterator"&&ee(z.$id)&&pe(z.items)}T.TIterator=Pe;function ze(z,U){return ke(z)&&z[e.Kind]===U}T.TKindOf=ze;function ke(z){return o.IsObject(z)&&e.Kind in z&&o.IsString(z[e.Kind])}T.TKind=ke;function Ne(z){return We(z)&&o.IsString(z.const)}T.TLiteralString=Ne;function qe(z){return We(z)&&o.IsNumber(z.const)}T.TLiteralNumber=qe;function tt(z){return We(z)&&o.IsBoolean(z.const)}T.TLiteralBoolean=tt;function We(z){return ze(z,"Literal")&&ee(z.$id)&&(o.IsBoolean(z.const)||o.IsNumber(z.const)||o.IsString(z.const))}T.TLiteral=We;function ut(z){return ze(z,"Never")&&o.IsObject(z.not)&&Object.getOwnPropertyNames(z.not).length===0}T.TNever=ut;function gt(z){return ze(z,"Not")&&pe(z.not)}T.TNot=gt;function Rt(z){return ze(z,"Null")&&z.type==="null"&&ee(z.$id)}T.TNull=Rt;function jt(z){return ze(z,"Number")&&z.type==="number"&&ee(z.$id)&&_(z.exclusiveMaximum)&&_(z.exclusiveMinimum)&&_(z.maximum)&&_(z.minimum)&&_(z.multipleOf)}T.TNumber=jt;function En(z){return ze(z,"Object")&&z.type==="object"&&ee(z.$id)&&o.IsObject(z.properties)&&j(z.additionalProperties)&&_(z.minProperties)&&_(z.maxProperties)&&Object.entries(z.properties).every(([U,Z])=>O(U)&&pe(Z))}T.TObject=En;function Dt(z){return ze(z,"Promise")&&z.type==="Promise"&&ee(z.$id)&&pe(z.item)}T.TPromise=Dt;function Sn(z){return ze(z,"Record")&&z.type==="object"&&ee(z.$id)&&j(z.additionalProperties)&&o.IsObject(z.patternProperties)&&(U=>{const Z=Object.getOwnPropertyNames(U.patternProperties);return Z.length===1&&x(Z[0])&&o.IsObject(U.patternProperties)&&pe(U.patternProperties[Z[0]])})(z)}T.TRecord=Sn;function fn(z){return o.IsObject(z)&&e.Hint in z&&z[e.Hint]==="Recursive"}T.TRecursive=fn;function Kn(z){return ze(z,"Ref")&&ee(z.$id)&&o.IsString(z.$ref)}T.TRef=Kn;function bn(z){return ze(z,"String")&&z.type==="string"&&ee(z.$id)&&_(z.minLength)&&_(z.maxLength)&&ce(z.pattern)&&_e(z.format)}T.TString=bn;function Hn(z){return ze(z,"Symbol")&&z.type==="symbol"&&ee(z.$id)}T.TSymbol=Hn;function Dn(z){return ze(z,"TemplateLiteral")&&z.type==="string"&&o.IsString(z.pattern)&&z.pattern[0]==="^"&&z.pattern[z.pattern.length-1]==="$"}T.TTemplateLiteral=Dn;function jn(z){return ze(z,"This")&&ee(z.$id)&&o.IsString(z.$ref)}T.TThis=jn;function wn(z){return o.IsObject(z)&&e.Transform in z}T.TTransform=wn;function cn(z){return ze(z,"Tuple")&&z.type==="array"&&ee(z.$id)&&o.IsNumber(z.minItems)&&o.IsNumber(z.maxItems)&&z.minItems===z.maxItems&&(o.IsUndefined(z.items)&&o.IsUndefined(z.additionalItems)&&z.minItems===0||o.IsArray(z.items)&&z.items.every(U=>pe(U)))}T.TTuple=cn;function Zn(z){return ze(z,"Undefined")&&z.type==="undefined"&&ee(z.$id)}T.TUndefined=Zn;function Gn(z){return Me(z)&&z.anyOf.every(U=>Ne(U)||qe(U))}T.TUnionLiteral=Gn;function Me(z){return ze(z,"Union")&&ee(z.$id)&&o.IsObject(z)&&o.IsArray(z.anyOf)&&z.anyOf.every(U=>pe(U))}T.TUnion=Me;function dt(z){return ze(z,"Uint8Array")&&z.type==="Uint8Array"&&ee(z.$id)&&_(z.minByteLength)&&_(z.maxByteLength)}T.TUint8Array=dt;function Tt(z){return ze(z,"Unknown")&&ee(z.$id)}T.TUnknown=Tt;function nn(z){return ze(z,"Unsafe")}T.TUnsafe=nn;function Oe(z){return ze(z,"Void")&&z.type==="void"&&ee(z.$id)}T.TVoid=Oe;function ct(z){return o.IsObject(z)&&z[e.Readonly]==="Readonly"}T.TReadonly=ct;function re(z){return o.IsObject(z)&&z[e.Optional]==="Optional"}T.TOptional=re;function pe(z){return o.IsObject(z)&&(se(z)||Ie(z)||de(z)||ye(z)||oe(z)||Fe(z)||Y(z)||Q(z)||ve(z)||Ae(z)||Pe(z)||We(z)||ut(z)||gt(z)||Rt(z)||jt(z)||En(z)||Dt(z)||Sn(z)||Kn(z)||bn(z)||Hn(z)||Dn(z)||jn(z)||cn(z)||Zn(z)||Me(z)||dt(z)||Tt(z)||nn(z)||Oe(z)||ke(z)&&t.Has(z[e.Kind]))}T.TSchema=pe})(a||(e.TypeGuard=a={}));var s;(function(T){function x(O){return O[e.Kind]==="Intersect"?O.allOf.every(j=>x(j)):O[e.Kind]==="Union"?O.anyOf.some(j=>x(j)):O[e.Kind]==="Undefined"?!0:O[e.Kind]==="Not"?!x(O.not):!1}T.Check=x})(s||(e.ExtendsUndefined=s={}));class c extends n{}e.TypeExtendsError=c;var l;(function(T){T[T.Union=0]="Union",T[T.True=1]="True",T[T.False=2]="False"})(l||(e.TypeExtendsResult=l={}));var f;(function(T){function x(M){return M===l.False?M:l.True}function O(M){throw new c(M)}function j(M){return a.TNever(M)||a.TIntersect(M)||a.TUnion(M)||a.TUnknown(M)||a.TAny(M)}function C(M,G){return a.TNever(G)?ze():a.TIntersect(G)?Q(M,G):a.TUnion(G)?Te(M,G):a.TUnknown(G)?ht():a.TAny(G)?_():O("StructuralRight")}function _(M,G){return l.True}function F(M,G){return a.TIntersect(G)?Q(M,G):a.TUnion(G)&&G.anyOf.some(Ve=>a.TAny(Ve)||a.TUnknown(Ve))?l.True:a.TUnion(G)?l.Union:a.TUnknown(G)||a.TAny(G)?l.True:l.Union}function ee(M,G){return a.TUnknown(M)?l.False:a.TAny(M)?l.Union:a.TNever(M)?l.True:l.False}function ce(M,G){return a.TObject(G)&&Dn(G)?l.True:j(G)?C(M,G):a.TArray(G)?x(lt(M.items,G.items)):l.False}function _e(M,G){return j(G)?C(M,G):a.TAsyncIterator(G)?x(lt(M.items,G.items)):l.False}function xe(M,G){return j(G)?C(M,G):a.TObject(G)?cn(M,G):a.TRecord(G)?Tt(M,G):a.TBigInt(G)?l.True:l.False}function se(M,G){return a.TLiteral(M)&&o.IsBoolean(M.const)||a.TBoolean(M)?l.True:l.False}function Ie(M,G){return j(G)?C(M,G):a.TObject(G)?cn(M,G):a.TRecord(G)?Tt(M,G):a.TBoolean(G)?l.True:l.False}function oe(M,G){return j(G)?C(M,G):a.TObject(G)?cn(M,G):a.TConstructor(G)?M.parameters.length>G.parameters.length?l.False:M.parameters.every((Ve,nt)=>x(lt(G.parameters[nt],Ve))===l.True)?x(lt(M.returns,G.returns)):l.False:l.False}function ye(M,G){return j(G)?C(M,G):a.TObject(G)?cn(M,G):a.TRecord(G)?Tt(M,G):a.TDate(G)?l.True:l.False}function de(M,G){return j(G)?C(M,G):a.TObject(G)?cn(M,G):a.TFunction(G)?M.parameters.length>G.parameters.length?l.False:M.parameters.every((Ve,nt)=>x(lt(G.parameters[nt],Ve))===l.True)?x(lt(M.returns,G.returns)):l.False:l.False}function Fe(M,G){return a.TLiteral(M)&&o.IsNumber(M.const)||a.TNumber(M)||a.TInteger(M)?l.True:l.False}function Y(M,G){return a.TInteger(G)||a.TNumber(G)?l.True:j(G)?C(M,G):a.TObject(G)?cn(M,G):a.TRecord(G)?Tt(M,G):l.False}function Q(M,G){return G.allOf.every(Ve=>lt(M,Ve)===l.True)?l.True:l.False}function ve(M,G){return M.allOf.some(Ve=>lt(Ve,G)===l.True)?l.True:l.False}function Ae(M,G){return j(G)?C(M,G):a.TIterator(G)?x(lt(M.items,G.items)):l.False}function Pe(M,G){return a.TLiteral(G)&&G.const===M.const?l.True:j(G)?C(M,G):a.TObject(G)?cn(M,G):a.TRecord(G)?Tt(M,G):a.TString(G)?Oe(M):a.TNumber(G)?We(M):a.TInteger(G)?Fe(M):a.TBoolean(G)?se(M):l.False}function ze(M,G){return l.False}function ke(M,G){return l.True}function Ne(M){let[G,Ve]=[M,0];for(;a.TNot(G);)G=G.not,Ve+=1;return Ve%2===0?G:e.Type.Unknown()}function qe(M,G){return a.TNot(M)?lt(Ne(M),G):a.TNot(G)?lt(M,Ne(G)):O("Invalid fallthrough for Not")}function tt(M,G){return j(G)?C(M,G):a.TObject(G)?cn(M,G):a.TRecord(G)?Tt(M,G):a.TNull(G)?l.True:l.False}function We(M,G){return a.TLiteralNumber(M)||a.TNumber(M)||a.TInteger(M)?l.True:l.False}function ut(M,G){return j(G)?C(M,G):a.TObject(G)?cn(M,G):a.TRecord(G)?Tt(M,G):a.TInteger(G)||a.TNumber(G)?l.True:l.False}function gt(M,G){return Object.getOwnPropertyNames(M.properties).length===G}function Rt(M){return Dn(M)}function jt(M){return gt(M,0)||gt(M,1)&&"description"in M.properties&&a.TUnion(M.properties.description)&&M.properties.description.anyOf.length===2&&(a.TString(M.properties.description.anyOf[0])&&a.TUndefined(M.properties.description.anyOf[1])||a.TString(M.properties.description.anyOf[1])&&a.TUndefined(M.properties.description.anyOf[0]))}function En(M){return gt(M,0)}function Dt(M){return gt(M,0)}function Sn(M){return gt(M,0)}function fn(M){return gt(M,0)}function Kn(M){return Dn(M)}function bn(M){const G=e.Type.Number();return gt(M,0)||gt(M,1)&&"length"in M.properties&&x(lt(M.properties.length,G))===l.True}function Hn(M){return gt(M,0)}function Dn(M){const G=e.Type.Number();return gt(M,0)||gt(M,1)&&"length"in M.properties&&x(lt(M.properties.length,G))===l.True}function jn(M){const G=e.Type.Function([e.Type.Any()],e.Type.Any());return gt(M,0)||gt(M,1)&&"then"in M.properties&&x(lt(M.properties.then,G))===l.True}function wn(M,G){return lt(M,G)===l.False||a.TOptional(M)&&!a.TOptional(G)?l.False:l.True}function cn(M,G){return a.TUnknown(M)?l.False:a.TAny(M)?l.Union:a.TNever(M)||a.TLiteralString(M)&&Rt(G)||a.TLiteralNumber(M)&&En(G)||a.TLiteralBoolean(M)&&Dt(G)||a.TSymbol(M)&&jt(G)||a.TBigInt(M)&&Sn(G)||a.TString(M)&&Rt(G)||a.TSymbol(M)&&jt(G)||a.TNumber(M)&&En(G)||a.TInteger(M)&&En(G)||a.TBoolean(M)&&Dt(G)||a.TUint8Array(M)&&Kn(G)||a.TDate(M)&&fn(G)||a.TConstructor(M)&&Hn(G)||a.TFunction(M)&&bn(G)?l.True:a.TRecord(M)&&a.TString(Me(M))?G[e.Hint]==="Record"?l.True:l.False:a.TRecord(M)&&a.TNumber(Me(M))?gt(G,0)?l.True:l.False:l.False}function Zn(M,G){return j(G)?C(M,G):a.TRecord(G)?Tt(M,G):a.TObject(G)?(()=>{for(const Ve of Object.getOwnPropertyNames(G.properties)){if(!(Ve in M.properties)&&!a.TOptional(G.properties[Ve]))return l.False;if(a.TOptional(G.properties[Ve]))return l.True;if(wn(M.properties[Ve],G.properties[Ve])===l.False)return l.False}return l.True})():l.False}function Gn(M,G){return j(G)?C(M,G):a.TObject(G)&&jn(G)?l.True:a.TPromise(G)?x(lt(M.item,G.item)):l.False}function Me(M){return e.PatternNumberExact in M.patternProperties?e.Type.Number():e.PatternStringExact in M.patternProperties?e.Type.String():O("Unknown record key pattern")}function dt(M){return e.PatternNumberExact in M.patternProperties?M.patternProperties[e.PatternNumberExact]:e.PatternStringExact in M.patternProperties?M.patternProperties[e.PatternStringExact]:O("Unable to get record value schema")}function Tt(M,G){const[Ve,nt]=[Me(G),dt(G)];return a.TLiteralString(M)&&a.TNumber(Ve)&&x(lt(M,nt))===l.True?l.True:a.TUint8Array(M)&&a.TNumber(Ve)||a.TString(M)&&a.TNumber(Ve)||a.TArray(M)&&a.TNumber(Ve)?lt(M,nt):a.TObject(M)?(()=>{for(const at of Object.getOwnPropertyNames(M.properties))if(wn(nt,M.properties[at])===l.False)return l.False;return l.True})():l.False}function nn(M,G){return j(G)?C(M,G):a.TObject(G)?cn(M,G):a.TRecord(G)?lt(dt(M),dt(G)):l.False}function Oe(M,G){return a.TLiteral(M)&&o.IsString(M.const)||a.TString(M)?l.True:l.False}function ct(M,G){return j(G)?C(M,G):a.TObject(G)?cn(M,G):a.TRecord(G)?Tt(M,G):a.TString(G)?l.True:l.False}function re(M,G){return j(G)?C(M,G):a.TObject(G)?cn(M,G):a.TRecord(G)?Tt(M,G):a.TSymbol(G)?l.True:l.False}function pe(M,G){return a.TTemplateLiteral(M)?lt($.Resolve(M),G):a.TTemplateLiteral(G)?lt(M,$.Resolve(G)):O("Invalid fallthrough for TemplateLiteral")}function z(M,G){return a.TArray(G)&&M.items!==void 0&&M.items.every(Ve=>lt(Ve,G.items)===l.True)}function U(M,G){return a.TNever(M)?l.True:a.TUnknown(M)?l.False:a.TAny(M)?l.Union:l.False}function Z(M,G){return j(G)?C(M,G):a.TObject(G)&&Dn(G)||a.TArray(G)&&z(M,G)?l.True:a.TTuple(G)?o.IsUndefined(M.items)&&!o.IsUndefined(G.items)||!o.IsUndefined(M.items)&&o.IsUndefined(G.items)?l.False:o.IsUndefined(M.items)&&!o.IsUndefined(G.items)||M.items.every((Ve,nt)=>lt(Ve,G.items[nt])===l.True)?l.True:l.False:l.False}function he(M,G){return j(G)?C(M,G):a.TObject(G)?cn(M,G):a.TRecord(G)?Tt(M,G):a.TUint8Array(G)?l.True:l.False}function Se(M,G){return j(G)?C(M,G):a.TObject(G)?cn(M,G):a.TRecord(G)?Tt(M,G):a.TVoid(G)?bt(M):a.TUndefined(G)?l.True:l.False}function Te(M,G){return G.anyOf.some(Ve=>lt(M,Ve)===l.True)?l.True:l.False}function it(M,G){return M.anyOf.every(Ve=>lt(Ve,G)===l.True)?l.True:l.False}function ht(M,G){return l.True}function Ot(M,G){return a.TNever(G)?ze():a.TIntersect(G)?Q(M,G):a.TUnion(G)?Te(M,G):a.TAny(G)?_():a.TString(G)?Oe(M):a.TNumber(G)?We(M):a.TInteger(G)?Fe(M):a.TBoolean(G)?se(M):a.TArray(G)?ee(M):a.TTuple(G)?U(M):a.TObject(G)?cn(M,G):a.TUnknown(G)?l.True:l.False}function bt(M,G){return a.TUndefined(M)||a.TUndefined(M)?l.True:l.False}function Ht(M,G){return a.TIntersect(G)?Q(M,G):a.TUnion(G)?Te(M,G):a.TUnknown(G)?ht():a.TAny(G)?_():a.TObject(G)?cn(M,G):a.TVoid(G)?l.True:l.False}function lt(M,G){return a.TTemplateLiteral(M)||a.TTemplateLiteral(G)?pe(M,G):a.TNot(M)||a.TNot(G)?qe(M,G):a.TAny(M)?F(M,G):a.TArray(M)?ce(M,G):a.TBigInt(M)?xe(M,G):a.TBoolean(M)?Ie(M,G):a.TAsyncIterator(M)?_e(M,G):a.TConstructor(M)?oe(M,G):a.TDate(M)?ye(M,G):a.TFunction(M)?de(M,G):a.TInteger(M)?Y(M,G):a.TIntersect(M)?ve(M,G):a.TIterator(M)?Ae(M,G):a.TLiteral(M)?Pe(M,G):a.TNever(M)?ke():a.TNull(M)?tt(M,G):a.TNumber(M)?ut(M,G):a.TObject(M)?Zn(M,G):a.TRecord(M)?nn(M,G):a.TString(M)?ct(M,G):a.TSymbol(M)?re(M,G):a.TTuple(M)?Z(M,G):a.TPromise(M)?Gn(M,G):a.TUint8Array(M)?he(M,G):a.TUndefined(M)?Se(M,G):a.TUnion(M)?it(M,G):a.TUnknown(M)?Ot(M,G):a.TVoid(M)?Ht(M,G):O(`Unknown left type operand '${M[e.Kind]}'`)}function rn(M,G){return lt(M,G)}T.Extends=rn})(f||(e.TypeExtends=f={}));var u;(function(T){function x(ce){return ce.map(_e=>_(_e))}function O(ce){return new Date(ce.getTime())}function j(ce){return new Uint8Array(ce)}function C(ce){const _e=Object.getOwnPropertyNames(ce).reduce((se,Ie)=>({...se,[Ie]:_(ce[Ie])}),{}),xe=Object.getOwnPropertySymbols(ce).reduce((se,Ie)=>({...se,[Ie]:_(ce[Ie])}),{});return{..._e,...xe}}function _(ce){return o.IsArray(ce)?x(ce):o.IsDate(ce)?O(ce):o.IsUint8Array(ce)?j(ce):o.IsObject(ce)?C(ce):ce}function F(ce){return ce.map(_e=>ee(_e))}T.Rest=F;function ee(ce,_e={}){return{..._(ce),..._e}}T.Type=ee})(u||(e.TypeClone=u={}));var d;(function(T){function x(oe){return oe.map(ye=>{const{[e.Optional]:de,...Fe}=u.Type(ye);return Fe})}function O(oe){return oe.every(ye=>a.TOptional(ye))}function j(oe){return oe.some(ye=>a.TOptional(ye))}function C(oe){return O(oe.allOf)?e.Type.Optional(e.Type.Intersect(x(oe.allOf))):oe}function _(oe){return j(oe.anyOf)?e.Type.Optional(e.Type.Union(x(oe.anyOf))):oe}function F(oe){return oe[e.Kind]==="Intersect"?C(oe):oe[e.Kind]==="Union"?_(oe):oe}function ee(oe,ye){const de=oe.allOf.reduce((Fe,Y)=>{const Q=se(Y,ye);return Q[e.Kind]==="Never"?Fe:[...Fe,Q]},[]);return F(e.Type.Intersect(de))}function ce(oe,ye){const de=oe.anyOf.map(Fe=>se(Fe,ye));return F(e.Type.Union(de))}function _e(oe,ye){const de=oe.properties[ye];return o.IsUndefined(de)?e.Type.Never():e.Type.Union([de])}function xe(oe,ye){const de=oe.items;if(o.IsUndefined(de))return e.Type.Never();const Fe=de[ye];return o.IsUndefined(Fe)?e.Type.Never():Fe}function se(oe,ye){return oe[e.Kind]==="Intersect"?ee(oe,ye):oe[e.Kind]==="Union"?ce(oe,ye):oe[e.Kind]==="Object"?_e(oe,ye):oe[e.Kind]==="Tuple"?xe(oe,ye):e.Type.Never()}function Ie(oe,ye,de={}){const Fe=ye.map(Y=>se(oe,Y.toString()));return F(e.Type.Union(Fe,de))}T.Resolve=Ie})(d||(e.IndexedAccessor=d={}));var h;(function(T){function x(xe){const[se,Ie]=[xe.slice(0,1),xe.slice(1)];return`${se.toLowerCase()}${Ie}`}function O(xe){const[se,Ie]=[xe.slice(0,1),xe.slice(1)];return`${se.toUpperCase()}${Ie}`}function j(xe){return xe.toUpperCase()}function C(xe){return xe.toLowerCase()}function _(xe,se){const Ie=E.ParseExact(xe.pattern);if(!D.Check(Ie))return{...xe,pattern:F(xe.pattern,se)};const de=[...I.Generate(Ie)].map(Q=>e.Type.Literal(Q)),Fe=ee(de,se),Y=e.Type.Union(Fe);return e.Type.TemplateLiteral([Y])}function F(xe,se){return typeof xe=="string"?se==="Uncapitalize"?x(xe):se==="Capitalize"?O(xe):se==="Uppercase"?j(xe):se==="Lowercase"?C(xe):xe:xe.toString()}function ee(xe,se){if(xe.length===0)return[];const[Ie,...oe]=xe;return[_e(Ie,se),...ee(oe,se)]}function ce(xe,se){return a.TTemplateLiteral(xe)?_(xe,se):a.TUnion(xe)?e.Type.Union(ee(xe.anyOf,se)):a.TLiteral(xe)?e.Type.Literal(F(xe.const,se)):xe}function _e(xe,se){return ce(xe,se)}T.Map=_e})(h||(e.Intrinsic=h={}));var p;(function(T){function x(F,ee){return e.Type.Intersect(F.allOf.map(ce=>C(ce,ee)),{...F})}function O(F,ee){return e.Type.Union(F.anyOf.map(ce=>C(ce,ee)),{...F})}function j(F,ee){return ee(F)}function C(F,ee){return F[e.Kind]==="Intersect"?x(F,ee):F[e.Kind]==="Union"?O(F,ee):F[e.Kind]==="Object"?j(F,ee):F}function _(F,ee,ce){return{...C(u.Type(F),ee),...ce}}T.Map=_})(p||(e.ObjectMap=p={}));var m;(function(T){function x(_e){return _e[0]==="^"&&_e[_e.length-1]==="$"?_e.slice(1,_e.length-1):_e}function O(_e,xe){return _e.allOf.reduce((se,Ie)=>[...se,...F(Ie,xe)],[])}function j(_e,xe){const se=_e.anyOf.map(Ie=>F(Ie,xe));return[...se.reduce((Ie,oe)=>oe.map(ye=>se.every(de=>de.includes(ye))?Ie.add(ye):Ie)[0],new Set)]}function C(_e,xe){return Object.getOwnPropertyNames(_e.properties)}function _(_e,xe){return xe.includePatterns?Object.getOwnPropertyNames(_e.patternProperties):[]}function F(_e,xe){return a.TIntersect(_e)?O(_e,xe):a.TUnion(_e)?j(_e,xe):a.TObject(_e)?C(_e):a.TRecord(_e)?_(_e,xe):[]}function ee(_e,xe){return[...new Set(F(_e,xe))]}T.ResolveKeys=ee;function ce(_e){return`^(${ee(_e,{includePatterns:!0}).map(Ie=>`(${x(Ie)})`).join("|")})$`}T.ResolvePattern=ce})(m||(e.KeyResolver=m={}));class v extends n{}e.KeyArrayResolverError=v;var g;(function(T){function x(O){return Array.isArray(O)?O:a.TUnionLiteral(O)?O.anyOf.map(j=>j.const.toString()):a.TLiteral(O)?[O.const]:a.TTemplateLiteral(O)?(()=>{const j=E.ParseExact(O.pattern);if(!D.Check(j))throw new v("Cannot resolve keys from infinite template expression");return[...I.Generate(j)]})():[]}T.Resolve=x})(g||(e.KeyArrayResolver=g={}));var y;(function(T){function*x(j){for(const C of j.anyOf)C[e.Kind]==="Union"?yield*x(C):yield C}function O(j){return e.Type.Union([...x(j)],{...j})}T.Resolve=O})(y||(e.UnionResolver=y={}));class w extends n{}e.TemplateLiteralPatternError=w;var k;(function(T){function x(_){throw new w(_)}function O(_){return _.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function j(_,F){return a.TTemplateLiteral(_)?_.pattern.slice(1,_.pattern.length-1):a.TUnion(_)?`(${_.anyOf.map(ee=>j(ee,F)).join("|")})`:a.TNumber(_)?`${F}${e.PatternNumber}`:a.TInteger(_)?`${F}${e.PatternNumber}`:a.TBigInt(_)?`${F}${e.PatternNumber}`:a.TString(_)?`${F}${e.PatternString}`:a.TLiteral(_)?`${F}${O(_.const.toString())}`:a.TBoolean(_)?`${F}${e.PatternBoolean}`:x(`Unexpected Kind '${_[e.Kind]}'`)}function C(_){return`^${_.map(F=>j(F,"")).join("")}$`}T.Create=C})(k||(e.TemplateLiteralPattern=k={}));var $;(function(T){function x(O){const j=E.ParseExact(O.pattern);if(!D.Check(j))return e.Type.String();const C=[...I.Generate(j)].map(_=>e.Type.Literal(_));return e.Type.Union(C)}T.Resolve=x})($||(e.TemplateLiteralResolver=$={}));class S extends n{}e.TemplateLiteralParserError=S;var E;(function(T){function x(oe,ye,de){return oe[ye]===de&&oe.charCodeAt(ye-1)!==92}function O(oe,ye){return x(oe,ye,"(")}function j(oe,ye){return x(oe,ye,")")}function C(oe,ye){return x(oe,ye,"|")}function _(oe){if(!(O(oe,0)&&j(oe,oe.length-1)))return!1;let ye=0;for(let de=0;de<oe.length;de++)if(O(oe,de)&&(ye+=1),j(oe,de)&&(ye-=1),ye===0&&de!==oe.length-1)return!1;return!0}function F(oe){return oe.slice(1,oe.length-1)}function ee(oe){let ye=0;for(let de=0;de<oe.length;de++)if(O(oe,de)&&(ye+=1),j(oe,de)&&(ye-=1),C(oe,de)&&ye===0)return!0;return!1}function ce(oe){for(let ye=0;ye<oe.length;ye++)if(O(oe,ye))return!0;return!1}function _e(oe){let[ye,de]=[0,0];const Fe=[];for(let Q=0;Q<oe.length;Q++)if(O(oe,Q)&&(ye+=1),j(oe,Q)&&(ye-=1),C(oe,Q)&&ye===0){const ve=oe.slice(de,Q);ve.length>0&&Fe.push(se(ve)),de=Q+1}const Y=oe.slice(de);return Y.length>0&&Fe.push(se(Y)),Fe.length===0?{type:"const",const:""}:Fe.length===1?Fe[0]:{type:"or",expr:Fe}}function xe(oe){function ye(Y,Q){if(!O(Y,Q))throw new S("TemplateLiteralParser: Index must point to open parens");let ve=0;for(let Ae=Q;Ae<Y.length;Ae++)if(O(Y,Ae)&&(ve+=1),j(Y,Ae)&&(ve-=1),ve===0)return[Q,Ae];throw new S("TemplateLiteralParser: Unclosed group parens in expression")}function de(Y,Q){for(let ve=Q;ve<Y.length;ve++)if(O(Y,ve))return[Q,ve];return[Q,Y.length]}const Fe=[];for(let Y=0;Y<oe.length;Y++)if(O(oe,Y)){const[Q,ve]=ye(oe,Y),Ae=oe.slice(Q,ve+1);Fe.push(se(Ae)),Y=ve}else{const[Q,ve]=de(oe,Y),Ae=oe.slice(Q,ve);Ae.length>0&&Fe.push(se(Ae)),Y=ve-1}return Fe.length===0?{type:"const",const:""}:Fe.length===1?Fe[0]:{type:"and",expr:Fe}}function se(oe){return _(oe)?se(F(oe)):ee(oe)?_e(oe):ce(oe)?xe(oe):{type:"const",const:oe}}T.Parse=se;function Ie(oe){return se(oe.slice(1,oe.length-1))}T.ParseExact=Ie})(E||(e.TemplateLiteralParser=E={}));class R extends n{}e.TemplateLiteralFiniteError=R;var D;(function(T){function x(F){throw new R(F)}function O(F){return F.type==="or"&&F.expr.length===2&&F.expr[0].type==="const"&&F.expr[0].const==="0"&&F.expr[1].type==="const"&&F.expr[1].const==="[1-9][0-9]*"}function j(F){return F.type==="or"&&F.expr.length===2&&F.expr[0].type==="const"&&F.expr[0].const==="true"&&F.expr[1].type==="const"&&F.expr[1].const==="false"}function C(F){return F.type==="const"&&F.const===".*"}function _(F){return j(F)?!0:O(F)||C(F)?!1:F.type==="and"?F.expr.every(ee=>_(ee)):F.type==="or"?F.expr.every(ee=>_(ee)):F.type==="const"?!0:x("Unknown expression type")}T.Check=_})(D||(e.TemplateLiteralFinite=D={}));class L extends n{}e.TemplateLiteralGeneratorError=L;var I;(function(T){function*x(F){if(F.length===1)return yield*F[0];for(const ee of F[0])for(const ce of x(F.slice(1)))yield`${ee}${ce}`}function*O(F){return yield*x(F.expr.map(ee=>[..._(ee)]))}function*j(F){for(const ee of F.expr)yield*_(ee)}function*C(F){return yield F.const}function*_(F){return F.type==="and"?yield*O(F):F.type==="or"?yield*j(F):F.type==="const"?yield*C(F):(()=>{throw new L("Unknown expression")})()}T.Generate=_})(I||(e.TemplateLiteralGenerator=I={}));var B;(function(T){function*x(_){const F=_.trim().replace(/"|'/g,"");return F==="boolean"?yield e.Type.Boolean():F==="number"?yield e.Type.Number():F==="bigint"?yield e.Type.BigInt():F==="string"?yield e.Type.String():yield(()=>{const ee=F.split("|").map(ce=>e.Type.Literal(ce.trim()));return ee.length===0?e.Type.Never():ee.length===1?ee[0]:e.Type.Union(ee)})()}function*O(_){if(_[1]!=="{"){const F=e.Type.Literal("$"),ee=j(_.slice(1));return yield*[F,...ee]}for(let F=2;F<_.length;F++)if(_[F]==="}"){const ee=x(_.slice(2,F)),ce=j(_.slice(F+1));return yield*[...ee,...ce]}yield e.Type.Literal(_)}function*j(_){for(let F=0;F<_.length;F++)if(_[F]==="$"){const ee=e.Type.Literal(_.slice(0,F)),ce=O(_.slice(F));return yield*[ee,...ce]}yield e.Type.Literal(_)}function C(_){return[...j(_)]}T.Parse=C})(B||(e.TemplateLiteralDslParser=B={}));class q{constructor(x){this.schema=x}Decode(x){return new N(this.schema,x)}}e.TransformDecodeBuilder=q;class N{constructor(x,O){this.schema=x,this.decode=O}Encode(x){const O=u.Type(this.schema);return a.TTransform(O)?(()=>{const _={Encode:F=>O[e.Transform].Encode(x(F)),Decode:F=>this.decode(O[e.Transform].Decode(F))};return{...O,[e.Transform]:_}})():(()=>{const j={Decode:this.decode,Encode:x};return{...O,[e.Transform]:j}})()}}e.TransformEncodeBuilder=N;let W=0;class X extends n{}e.TypeBuilderError=X;class H{Create(x){return x}Throw(x){throw new X(x)}Discard(x,O){return O.reduce((j,C)=>{const{[C]:_,...F}=j;return F},x)}Strict(x){return JSON.parse(JSON.stringify(x))}}e.TypeBuilder=H;class K extends H{ReadonlyOptional(x){return this.Readonly(this.Optional(x))}Readonly(x){return{...u.Type(x),[e.Readonly]:"Readonly"}}Optional(x){return{...u.Type(x),[e.Optional]:"Optional"}}Any(x={}){return this.Create({...x,[e.Kind]:"Any"})}Array(x,O={}){return this.Create({...O,[e.Kind]:"Array",type:"array",items:u.Type(x)})}Boolean(x={}){return this.Create({...x,[e.Kind]:"Boolean",type:"boolean"})}Capitalize(x,O={}){return{...h.Map(u.Type(x),"Capitalize"),...O}}Composite(x,O){const j=e.Type.Intersect(x,{}),_=m.ResolveKeys(j,{includePatterns:!1}).reduce((F,ee)=>({...F,[ee]:e.Type.Index(j,[ee])}),{});return e.Type.Object(_,O)}Enum(x,O={}){if(o.IsUndefined(x))return this.Throw("Enum undefined or empty");const j=Object.getOwnPropertyNames(x).filter(F=>isNaN(F)).map(F=>x[F]),_=[...new Set(j)].map(F=>e.Type.Literal(F));return this.Union(_,{...O,[e.Hint]:"Enum"})}Extends(x,O,j,C,_={}){switch(f.Extends(x,O)){case l.Union:return this.Union([u.Type(j,_),u.Type(C,_)]);case l.True:return u.Type(j,_);case l.False:return u.Type(C,_)}}Exclude(x,O,j={}){return a.TTemplateLiteral(x)?this.Exclude($.Resolve(x),O,j):a.TTemplateLiteral(O)?this.Exclude(x,$.Resolve(O),j):a.TUnion(x)?(()=>{const C=x.anyOf.filter(_=>f.Extends(_,O)===l.False);return C.length===1?u.Type(C[0],j):this.Union(C,j)})():f.Extends(x,O)!==l.False?this.Never(j):u.Type(x,j)}Extract(x,O,j={}){return a.TTemplateLiteral(x)?this.Extract($.Resolve(x),O,j):a.TTemplateLiteral(O)?this.Extract(x,$.Resolve(O),j):a.TUnion(x)?(()=>{const C=x.anyOf.filter(_=>f.Extends(_,O)!==l.False);return C.length===1?u.Type(C[0],j):this.Union(C,j)})():f.Extends(x,O)!==l.False?u.Type(x,j):this.Never(j)}Index(x,O,j={}){return a.TArray(x)&&a.TNumber(O)?u.Type(x.items,j):a.TTuple(x)&&a.TNumber(O)?(()=>{const _=(o.IsUndefined(x.items)?[]:x.items).map(F=>u.Type(F));return this.Union(_,j)})():(()=>{const C=g.Resolve(O),_=u.Type(x);return d.Resolve(_,C,j)})()}Integer(x={}){return this.Create({...x,[e.Kind]:"Integer",type:"integer"})}Intersect(x,O={}){if(x.length===0)return e.Type.Never();if(x.length===1)return u.Type(x[0],O);x.some(F=>a.TTransform(F))&&this.Throw("Cannot intersect transform types");const j=x.every(F=>a.TObject(F)),C=u.Rest(x),_=a.TSchema(O.unevaluatedProperties)?{unevaluatedProperties:u.Type(O.unevaluatedProperties)}:{};return O.unevaluatedProperties===!1||a.TSchema(O.unevaluatedProperties)||j?this.Create({...O,..._,[e.Kind]:"Intersect",type:"object",allOf:C}):this.Create({...O,..._,[e.Kind]:"Intersect",allOf:C})}KeyOf(x,O={}){return a.TRecord(x)?(()=>{const j=Object.getOwnPropertyNames(x.patternProperties)[0];return j===e.PatternNumberExact?this.Number(O):j===e.PatternStringExact?this.String(O):this.Throw("Unable to resolve key type from Record key pattern")})():a.TTuple(x)?(()=>{const C=(o.IsUndefined(x.items)?[]:x.items).map((_,F)=>e.Type.Literal(F.toString()));return this.Union(C,O)})():a.TArray(x)?this.Number(O):(()=>{const j=m.ResolveKeys(x,{includePatterns:!1});if(j.length===0)return this.Never(O);const C=j.map(_=>this.Literal(_));return this.Union(C,O)})()}Literal(x,O={}){return this.Create({...O,[e.Kind]:"Literal",const:x,type:typeof x})}Lowercase(x,O={}){return{...h.Map(u.Type(x),"Lowercase"),...O}}Never(x={}){return this.Create({...x,[e.Kind]:"Never",not:{}})}Not(x,O){return this.Create({...O,[e.Kind]:"Not",not:u.Type(x)})}Null(x={}){return this.Create({...x,[e.Kind]:"Null",type:"null"})}Number(x={}){return this.Create({...x,[e.Kind]:"Number",type:"number"})}Object(x,O={}){const j=Object.getOwnPropertyNames(x),C=j.filter(ce=>a.TOptional(x[ce])),_=j.filter(ce=>!C.includes(ce)),F=a.TSchema(O.additionalProperties)?{additionalProperties:u.Type(O.additionalProperties)}:{},ee=j.reduce((ce,_e)=>({...ce,[_e]:u.Type(x[_e])}),{});return _.length>0?this.Create({...O,...F,[e.Kind]:"Object",type:"object",properties:ee,required:_}):this.Create({...O,...F,[e.Kind]:"Object",type:"object",properties:ee})}Omit(x,O,j={}){const C=g.Resolve(O);return p.Map(this.Discard(u.Type(x),["$id",e.Transform]),_=>{o.IsArray(_.required)&&(_.required=_.required.filter(F=>!C.includes(F)),_.required.length===0&&delete _.required);for(const F of Object.getOwnPropertyNames(_.properties))C.includes(F)&&delete _.properties[F];return this.Create(_)},j)}Partial(x,O={}){return p.Map(this.Discard(u.Type(x),["$id",e.Transform]),j=>{const C=Object.getOwnPropertyNames(j.properties).reduce((_,F)=>({..._,[F]:this.Optional(j.properties[F])}),{});return this.Object(C,this.Discard(j,["required"]))},O)}Pick(x,O,j={}){const C=g.Resolve(O);return p.Map(this.Discard(u.Type(x),["$id",e.Transform]),_=>{o.IsArray(_.required)&&(_.required=_.required.filter(F=>C.includes(F)),_.required.length===0&&delete _.required);for(const F of Object.getOwnPropertyNames(_.properties))C.includes(F)||delete _.properties[F];return this.Create(_)},j)}Record(x,O,j={}){return a.TTemplateLiteral(x)?(()=>{const C=E.ParseExact(x.pattern);return D.Check(C)?this.Object([...I.Generate(C)].reduce((_,F)=>({..._,[F]:u.Type(O)}),{}),j):this.Create({...j,[e.Kind]:"Record",type:"object",patternProperties:{[x.pattern]:u.Type(O)}})})():a.TUnion(x)?(()=>{const C=y.Resolve(x);if(a.TUnionLiteral(C)){const _=C.anyOf.reduce((F,ee)=>({...F,[ee.const]:u.Type(O)}),{});return this.Object(_,{...j,[e.Hint]:"Record"})}else this.Throw("Record key of type union contains non-literal types")})():a.TLiteral(x)?o.IsString(x.const)||o.IsNumber(x.const)?this.Object({[x.const]:u.Type(O)},j):this.Throw("Record key of type literal is not of type string or number"):a.TInteger(x)||a.TNumber(x)?this.Create({...j,[e.Kind]:"Record",type:"object",patternProperties:{[e.PatternNumberExact]:u.Type(O)}}):a.TString(x)?(()=>{const C=o.IsUndefined(x.pattern)?e.PatternStringExact:x.pattern;return this.Create({...j,[e.Kind]:"Record",type:"object",patternProperties:{[C]:u.Type(O)}})})():this.Never()}Recursive(x,O={}){o.IsUndefined(O.$id)&&(O.$id=`T${W++}`);const j=x({[e.Kind]:"This",$ref:`${O.$id}`});return j.$id=O.$id,this.Create({...O,[e.Hint]:"Recursive",...j})}Ref(x,O={}){return o.IsString(x)?this.Create({...O,[e.Kind]:"Ref",$ref:x}):(o.IsUndefined(x.$id)&&this.Throw("Reference target type must specify an $id"),this.Create({...O,[e.Kind]:"Ref",$ref:x.$id}))}Required(x,O={}){return p.Map(this.Discard(u.Type(x),["$id",e.Transform]),j=>{const C=Object.getOwnPropertyNames(j.properties).reduce((_,F)=>({..._,[F]:this.Discard(j.properties[F],[e.Optional])}),{});return this.Object(C,j)},O)}Rest(x){return a.TTuple(x)&&!o.IsUndefined(x.items)?u.Rest(x.items):a.TIntersect(x)?u.Rest(x.allOf):a.TUnion(x)?u.Rest(x.anyOf):[]}String(x={}){return this.Create({...x,[e.Kind]:"String",type:"string"})}TemplateLiteral(x,O={}){const j=o.IsString(x)?k.Create(B.Parse(x)):k.Create(x);return this.Create({...O,[e.Kind]:"TemplateLiteral",type:"string",pattern:j})}Transform(x){return new q(x)}Tuple(x,O={}){const[j,C,_]=[!1,x.length,x.length],F=u.Rest(x),ee=x.length>0?{...O,[e.Kind]:"Tuple",type:"array",items:F,additionalItems:j,minItems:C,maxItems:_}:{...O,[e.Kind]:"Tuple",type:"array",minItems:C,maxItems:_};return this.Create(ee)}Uncapitalize(x,O={}){return{...h.Map(u.Type(x),"Uncapitalize"),...O}}Union(x,O={}){return a.TTemplateLiteral(x)?$.Resolve(x):(()=>{const j=x;if(j.length===0)return this.Never(O);if(j.length===1)return this.Create(u.Type(j[0],O));const C=u.Rest(j);return this.Create({...O,[e.Kind]:"Union",anyOf:C})})()}Unknown(x={}){return this.Create({...x,[e.Kind]:"Unknown"})}Unsafe(x={}){return this.Create({...x,[e.Kind]:x[e.Kind]||"Unsafe"})}Uppercase(x,O={}){return{...h.Map(u.Type(x),"Uppercase"),...O}}}e.JsonTypeBuilder=K;class A extends K{AsyncIterator(x,O={}){return this.Create({...O,[e.Kind]:"AsyncIterator",type:"AsyncIterator",items:u.Type(x)})}Awaited(x,O={}){const j=C=>C.length>0?(()=>{const[_,...F]=C;return[this.Awaited(_),...j(F)]})():C;return a.TIntersect(x)?e.Type.Intersect(j(x.allOf)):a.TUnion(x)?e.Type.Union(j(x.anyOf)):a.TPromise(x)?this.Awaited(x.item):u.Type(x,O)}BigInt(x={}){return this.Create({...x,[e.Kind]:"BigInt",type:"bigint"})}ConstructorParameters(x,O={}){return this.Tuple([...x.parameters],{...O})}Constructor(x,O,j){const[C,_]=[u.Rest(x),u.Type(O)];return this.Create({...j,[e.Kind]:"Constructor",type:"Constructor",parameters:C,returns:_})}Date(x={}){return this.Create({...x,[e.Kind]:"Date",type:"Date"})}Function(x,O,j){const[C,_]=[u.Rest(x),u.Type(O)];return this.Create({...j,[e.Kind]:"Function",type:"Function",parameters:C,returns:_})}InstanceType(x,O={}){return u.Type(x.returns,O)}Iterator(x,O={}){return this.Create({...O,[e.Kind]:"Iterator",type:"Iterator",items:u.Type(x)})}Parameters(x,O={}){return this.Tuple(x.parameters,{...O})}Promise(x,O={}){return this.Create({...O,[e.Kind]:"Promise",type:"Promise",item:u.Type(x)})}RegExp(x,O={}){const j=o.IsString(x)?x:x.source;return this.Create({...O,[e.Kind]:"String",type:"string",pattern:j})}RegEx(x,O={}){return this.RegExp(x,O)}ReturnType(x,O={}){return u.Type(x.returns,O)}Symbol(x){return this.Create({...x,[e.Kind]:"Symbol",type:"symbol"})}Undefined(x={}){return this.Create({...x,[e.Kind]:"Undefined",type:"undefined"})}Uint8Array(x={}){return this.Create({...x,[e.Kind]:"Uint8Array",type:"Uint8Array"})}Void(x={}){return this.Create({...x,[e.Kind]:"Void",type:"void"})}}e.JavaScriptTypeBuilder=A,e.JsonType=new K,e.Type=new A})(P);const Tve=P.Type.Object({prefix:P.Type.Optional(P.Type.String()),suffix:P.Type.Optional(P.Type.String()),volume:P.Type.Optional(P.Type.Number())}),Z9=P.Type.Object({soundOnNewLine:P.Type.Optional(P.Type.String()),soundPerLetter:P.Type.Optional(Tve)}),Ove=P.Type.Object({defaultAudio:P.Type.Optional(Z9),characterAudio:P.Type.Optional(P.Type.Record(P.Type.String(),Z9))}),Eve=P.Type.Object({src:P.Type.String(),path:P.Type.Optional(P.Type.String()),volume:P.Type.Optional(P.Type.Number()),rate:P.Type.Optional(P.Type.Number()),html5:P.Type.Optional(P.Type.Boolean()),fadeInTime:P.Type.Optional(P.Type.Number()),fadeInDelay:P.Type.Optional(P.Type.Number()),fadeOutTime:P.Type.Optional(P.Type.Number()),loop:P.Type.Optional(P.Type.Boolean())}),Ave=P.Type.Record(P.Type.String(),Eve),Pve=P.Type.Object({volume:P.Type.Optional(P.Type.Number()),defaultMusic:P.Type.Optional(P.Type.String()),musicFadeInTime:P.Type.Optional(P.Type.Number()),musicFadeOutTime:P.Type.Optional(P.Type.Number()),musicFadeInDelay:P.Type.Optional(P.Type.Number())}),Mve=P.Type.Record(P.Type.String(),P.Type.String()),eB=P.Type.Object({files:Ave,audioTriggers:Mve,options:Pve,dialogAudio:P.Type.Optional(Ove)}),tB={files:{},audioTriggers:{},options:{volume:1,musicFadeInTime:.5,musicFadeInDelay:.5,musicFadeOutTime:.5}},nB=P.Type.Object({backgrounds:P.Type.Object({width:P.Type.Number(),height:P.Type.Number()}),dialogBottomPadding:P.Type.Union([P.Type.Number(),P.Type.String()]),minTextWidth:P.Type.Optional(P.Type.Number()),verticalLayoutThreshold:P.Type.Number(),defaultFontSize:P.Type.Optional(P.Type.Number()),portraits:P.Type.Object({width:P.Type.Number(),height:P.Type.Number(),offset:P.Type.Optional(P.Type.Object({landscape:P.Type.Optional(P.Type.Object({right:P.Type.Number(),bottom:P.Type.Number()})),portrait:P.Type.Optional(P.Type.Object({right:P.Type.Number(),bottom:P.Type.Number()}))}))})}),Ive={backgrounds:{width:880,height:720},dialogBottomPadding:70,verticalLayoutThreshold:600,defaultFontSize:16,portraits:{width:100,height:100}},r0=P.Type.Object({name:P.Type.String(),description:P.Type.Optional(P.Type.String())}),Nve=P.Type.Intersect([r0,P.Type.Object({type:P.Type.Literal("number"),defaultValue:P.Type.Number(),step:P.Type.Number(),minValue:P.Type.Number(),maxValue:P.Type.Number()})]),Rve=P.Type.Intersect([r0,P.Type.Object({type:P.Type.Literal("integer"),defaultValue:P.Type.Number(),step:P.Type.Number(),minValue:P.Type.Number(),maxValue:P.Type.Number()})]),Dve=P.Type.Intersect([r0,P.Type.Object({type:P.Type.Literal("boolean"),defaultValue:P.Type.Boolean()})]),Lve=P.Type.Intersect([r0,P.Type.Object({type:P.Type.Literal("string"),defaultValue:P.Type.String()})]),Bve=P.Type.Union([Nve,Rve,Dve,Lve]);function Fve(e){return e.type==="number"}function rB(e){return e.type==="integer"}function Vve(e){return e.type==="boolean"}function zve(e){return e.type==="string"}const oB=P.Type.Object({customSettings:P.Type.Optional(P.Type.Record(P.Type.String(),Bve))}),o0="###_--_~=:;_JUMP",yx="###_--_~=:;_RETURN",qve="###_--_~=:;_OK",i0="###_--_~=:;_STOP";function Uve(e){return e===o0||e===yx||e===qve||e===i0}const Hve="3.9.4",Wve=new Date("2024-01-27T14:01:19.800Z"),Kve=400,a0=20,bx="@empty",iB={background:bx},Gve=P.Type.Optional(P.Type.Object({debugMenu:P.Type.Optional(P.Type.String()),jumpMenu:P.Type.Optional(P.Type.String())})),aB=P.Type.Optional(P.Type.Object({animateText:P.Type.Optional(P.Type.Boolean()),textSpeed:P.Type.Optional(P.Type.Number()),timeBetweenLines:P.Type.Optional(P.Type.Number()),overlayMode:P.Type.Optional(P.Type.Boolean()),rightOffset:P.Type.Optional(P.Type.Number()),bottomOffset:P.Type.Optional(P.Type.Number()),width:P.Type.Optional(P.Type.Number()),height:P.Type.Optional(P.Type.Number()),hideDuringTransition:P.Type.Optional(P.Type.Boolean()),showAfterScriptEnd:P.Type.Optional(P.Type.Boolean())})),sB=P.Type.Object({engineSplashScreen:P.Type.Optional(P.Type.Object({skip:P.Type.Optional(P.Type.Boolean()),fadeDuration:P.Type.Optional(P.Type.Number()),timeBeforeFadeout:P.Type.Optional(P.Type.Number()),overrideText:P.Type.Optional(P.Type.String()),overrideLogo:P.Type.Optional(P.Type.String())})),gameSplashScreen:P.Type.Optional(P.Type.Object({startButtonText:P.Type.Optional(P.Type.String())}))}),cB=P.Type.Object({timeOnScreen:P.Type.Number(),alsoPrintInDialogue:P.Type.Optional(P.Type.Boolean())}),Jve=P.Type.Object({name:P.Type.String(),icon:P.Type.String(),startingValue:P.Type.Number(),maxValue:P.Type.Optional(P.Type.Number()),minValue:P.Type.Optional(P.Type.Number()),decimals:P.Type.Optional(P.Type.Number()),prefix:P.Type.Optional(P.Type.String()),suffix:P.Type.Optional(P.Type.String()),hideName:P.Type.Optional(P.Type.Boolean()),formatting:P.Type.Optional(P.Type.Object({style:P.Type.Union([P.Type.Literal("decimal"),P.Type.Literal("currency"),P.Type.Literal("percent"),P.Type.Literal("unit")]),currency:P.Type.Optional(P.Type.String()),unit:P.Type.Optional(P.Type.String())}))}),lB=P.Type.Record(P.Type.String(),Jve),uB=P.Type.Record(P.Type.String(),P.Type.Object({onlyInteractOutsideOfScripts:P.Type.Optional(P.Type.Boolean())})),Qve=P.Type.Object({delay:P.Type.Optional(P.Type.Number()),duration:P.Type.Optional(P.Type.Number())}),fB=P.Type.Record(P.Type.String(),Qve),Yve=P.Type.Object({text:P.Type.String(),cssClass:P.Type.Optional(P.Type.String())}),dB=P.Type.Record(P.Type.String(),Yve),hB=P.Type.Object({showScriptFinishedMessage:P.Type.Optional(P.Type.Boolean())}),pB=P.Type.Object({mode:P.Type.String(),slots:P.Type.Number(),runOnReload:P.Type.Optional(P.Type.String()),disabled:P.Type.Optional(P.Type.Boolean())}),mB=P.Type.Array(P.Type.String()),Xve=[],vB=P.Type.Object({baseAssetsPath:P.Type.Optional(P.Type.String()),baseDataPath:P.Type.Optional(P.Type.String()),gameTitle:P.Type.String(),saveFileName:P.Type.String(),images:P.Type.Optional(P.Type.Record(P.Type.String(),P.Type.String())),layout:nB,settings:P.Type.Optional(oB),gameFlow:P.Type.Optional(P.Type.Object({labelToJumpOnScriptEnd:P.Type.Optional(P.Type.String())})),dialogPanel:P.Type.Optional(aB),splashScreens:P.Type.Optional(sB),notifications:P.Type.Optional(cB),hudStats:lB,interactionTags:P.Type.Optional(uB),transitions:P.Type.Optional(fB),menuButtons:P.Type.Optional(dB),debugging:P.Type.Optional(hB),saves:P.Type.Optional(pB),hotkeys:Gve}),wx={baseAssetsPath:"",baseDataPath:"",gameTitle:"Narrat Game",saveFileName:"narrat save",images:{},layout:Ive,settings:{},gameFlow:{},dialogPanel:{overlayMode:!0,rightOffset:100,bottomOffset:50,width:475,height:680,textSpeed:a0,animateText:!0,timeBetweenLines:100,hideDuringTransition:!1,showAfterScriptEnd:!1},splashScreens:{},notifications:{timeOnScreen:2.5,alsoPrintInDialogue:!1},hudStats:{},interactionTags:{default:{onlyInteractOutsideOfScripts:!0}},transitions:{},menuButtons:{},debugging:{showScriptFinishedMessage:!1},saves:{mode:"manual",slots:10},hotkeys:{}},Zve=P.Type.Object({name:P.Type.String(),description:P.Type.String(),icon:P.Type.String(),onUse:P.Type.Optional(P.Type.Object({action:P.Type.String(),label:P.Type.String()})),tag:P.Type.Optional(P.Type.String()),category:P.Type.Optional(P.Type.String()),showIfEmpty:P.Type.Optional(P.Type.Boolean())}),gB=P.Type.Object({id:P.Type.String(),title:P.Type.String()}),yB=P.Type.Record(P.Type.String(),Zve);P.Type.Object({categories:P.Type.Array(gB),items:yB});const bB=P.Type.Object({categories:P.Type.Optional(P.Type.Array(gB)),items:P.Type.Optional(yB)}),wB={categories:[{id:"default",title:"Items"}],items:{}},ege=P.Type.Object({description:P.Type.String(),succeededDescription:P.Type.Optional(P.Type.String()),failedDescription:P.Type.Optional(P.Type.String()),hidden:P.Type.Optional(P.Type.Boolean())}),tge=P.Type.Object({title:P.Type.String(),description:P.Type.String(),succeededDescription:P.Type.Optional(P.Type.String()),failedDescription:P.Type.Optional(P.Type.String()),endings:P.Type.Optional(P.Type.Record(P.Type.String(),P.Type.Object({success:P.Type.Boolean(),description:P.Type.String()}))),objectives:P.Type.Record(P.Type.String(),ege),category:P.Type.Optional(P.Type.String())}),nge=P.Type.Object({id:P.Type.String(),title:P.Type.String()}),rge=P.Type.Record(P.Type.String(),tge),kB=P.Type.Object({quests:rge,categories:P.Type.Array(nge)}),xB={quests:{},categories:[{id:"default",title:"Quests"}]},_B=P.Type.Object({enabled:P.Type.Boolean(),background:P.Type.Optional(P.Type.String()),text:P.Type.Optional(P.Type.String()),cssClass:P.Type.Optional(P.Type.String()),position:P.Type.Object({left:P.Type.Number(),top:P.Type.Number(),width:P.Type.Optional(P.Type.Number()),height:P.Type.Optional(P.Type.Number())}),anchor:P.Type.Optional(P.Type.Object({x:P.Type.Number(),y:P.Type.Number()})),action:P.Type.Optional(P.Type.String()),actionType:P.Type.Optional(P.Type.String()),scriptClickable:P.Type.Optional(P.Type.Boolean()),tag:P.Type.Optional(P.Type.String())}),oge=P.Type.Record(P.Type.String(),_B),SB=P.Type.Object({buttons:oge,clickableDuringScriptsByDefault:P.Type.Optional(P.Type.Boolean())}),jB={buttons:{},clickableDuringScriptsByDefault:!1},ige=P.Type.Intersect([_B,P.Type.Object({id:P.Type.String()})]),age=P.Type.Object({muted:P.Type.Optional(P.Type.Boolean()),loop:P.Type.Optional(P.Type.Boolean())}),sge=P.Type.Object({background:P.Type.String(),video:P.Type.Optional(age),buttons:P.Type.Optional(P.Type.Array(P.Type.Union([P.Type.String(),ige])))}),CB=P.Type.Record(P.Type.String(),sge);P.Type.Object({screens:CB});const $B=P.Type.Object({screens:P.Type.Optional(CB)}),TB={screens:{}},cge=P.Type.Object({name:P.Type.String(),description:P.Type.String(),startingLevel:P.Type.Number(),hidden:P.Type.Optional(P.Type.Boolean()),icon:P.Type.String()}),OB=P.Type.Record(P.Type.String(),cge),EB=P.Type.Object({xpPerLevel:P.Type.Number(),notifyLevelUp:P.Type.Boolean()});P.Type.Object({skills:OB,skillOptions:EB});const AB=P.Type.Object({skills:P.Type.Optional(OB),skillOptions:P.Type.Optional(EB)}),PB={skills:{},skillOptions:{xpPerLevel:10,notifyLevelUp:!0}},lge=P.Type.Object({portraitCssClass:P.Type.Optional(P.Type.String()),color:P.Type.Optional(P.Type.String()),boxCss:P.Type.Optional(P.Type.Record(P.Type.String(),P.Type.Any())),nameCss:P.Type.Optional(P.Type.Record(P.Type.String(),P.Type.Any())),textCss:P.Type.Optional(P.Type.Record(P.Type.String(),P.Type.Any()))}),uge=P.Type.Object({video:P.Type.String(),autoplay:P.Type.Optional(P.Type.Boolean()),loop:P.Type.Optional(P.Type.Boolean()),muted:P.Type.Optional(P.Type.Boolean()),width:P.Type.Optional(P.Type.Number()),height:P.Type.Optional(P.Type.Number())}),fge=P.Type.Object({image:P.Type.String(),width:P.Type.Optional(P.Type.Number()),height:P.Type.Optional(P.Type.Number())}),dge=P.Type.Union([P.Type.String(),uge,fge]),hge=P.Type.Object({sprites:P.Type.Optional(P.Type.Record(P.Type.String(),dge)),name:P.Type.String(),style:P.Type.Optional(lge)}),MB=P.Type.Object({config:P.Type.Object({imagesPath:P.Type.String(),playerCharacter:P.Type.Optional(P.Type.String()),gameCharacter:P.Type.Optional(P.Type.String())}),characters:P.Type.Record(P.Type.String(),hge)}),IB={config:{imagesPath:"",playerCharacter:"player",gameCharacter:"game"},characters:{}},NB=P.Type.Object({cssClass:P.Type.Optional(P.Type.String()),textCssClass:P.Type.Optional(P.Type.String()),titleCssClass:P.Type.Optional(P.Type.String())}),RB=P.Type.Object({options:P.Type.Object({delay:P.Type.Optional(P.Type.Number()),width:P.Type.Number(),keywordsPrefix:P.Type.String(),screenEdgesMinimumMargin:P.Type.Optional(P.Type.Number()),styling:P.Type.Optional(NB)}),tooltips:P.Type.Array(P.Type.Object({keywords:P.Type.Array(P.Type.String()),title:P.Type.String(),description:P.Type.String(),styling:P.Type.Optional(NB)}))}),DB={options:{delay:0,width:350,keywordsPrefix:"@@"},tooltips:[]},pge=P.Type.Object({name:P.Type.String(),description:P.Type.String(),icon:P.Type.Optional(P.Type.String()),lockedIcon:P.Type.Optional(P.Type.String()),secret:P.Type.Optional(P.Type.Boolean()),category:P.Type.Optional(P.Type.String())}),LB=P.Type.Object({id:P.Type.String(),title:P.Type.String()}),BB=P.Type.Record(P.Type.String(),pge);P.Type.Object({defaultAchievementIcon:P.Type.String(),categories:P.Type.Array(LB),achievements:BB,notifyNewAchievements:P.Type.Boolean(),secretAchievements:P.Type.Optional(P.Type.Object({censorDescription:P.Type.Optional(P.Type.Boolean()),censorName:P.Type.Optional(P.Type.Boolean()),hideUntilObtained:P.Type.Optional(P.Type.Boolean())}))});const FB=P.Type.Object({categories:P.Type.Optional(P.Type.Array(LB)),achievements:P.Type.Optional(BB)}),VB={categories:[{id:"default",title:"Achievements"}],achievements:{},notifyNewAchievements:!0,defaultAchievementIcon:"img/achievements/trophy.png"},mge=P.Type.Object({diceRange:P.Type.Tuple([P.Type.Number(),P.Type.Number()]),diceCount:P.Type.Number(),difficultyText:P.Type.Array(P.Type.Tuple([P.Type.Number(),P.Type.String()])),extraPointsPerLevel:P.Type.Number(),extraDicePerLevel:P.Type.Optional(P.Type.Number()),successOnRollsBelowThreshold:P.Type.Boolean(),showDifficultyText:P.Type.Boolean(),showDifficultyNumber:P.Type.Boolean(),showDifficultyWithoutModifiers:P.Type.Boolean(),finalRollIsHighest:P.Type.Optional(P.Type.Boolean()),finalRollIsLowest:P.Type.Optional(P.Type.Boolean()),failOnRollsEqualToThreshold:P.Type.Optional(P.Type.Boolean())}),vge=P.Type.Object({skill:P.Type.String(),difficulty:P.Type.Number(),winsNeeded:P.Type.Optional(P.Type.Number()),hideAfterRoll:P.Type.Optional(P.Type.Boolean()),repeatable:P.Type.Optional(P.Type.Boolean())}),zB=P.Type.Object({options:mge,skillChecks:P.Type.Record(P.Type.String(),vge)}),qB={options:{diceRange:[1,6],extraPointsPerLevel:1,extraDicePerLevel:0,diceCount:2,successOnRollsBelowThreshold:!1,showDifficultyText:!0,showDifficultyNumber:!1,showDifficultyWithoutModifiers:!1,finalRollIsHighest:!1,finalRollIsLowest:!1,difficultyText:[[2,"Very Easy"],[4,"Easy"],[6,"Medium"],[8,"Hard"],[10,"Very Hard"],[11,"Extremely Hard"],[12,"Near Impossible"]]},skillChecks:{}},gge=P.Type.Object({cssClass:P.Type.Optional(P.Type.String()),textTemplate:P.Type.Optional(P.Type.String())}),UB=P.Type.Record(P.Type.String(),gge);P.Type.Object({choiceTextTemplate:P.Type.String(),choicePrompts:UB});const HB=P.Type.Object({choiceTextTemplate:P.Type.Optional(P.Type.String()),choicePrompts:P.Type.Optional(UB)}),WB={choicePrompts:{},choiceTextTemplate:'<span class="choice-index">%{$index}. </span> <span class="choice-text">%{$choice}</span>'},KB=P.Type.Object({delay:P.Type.Optional(P.Type.Number()),direction:P.Type.Optional(P.Type.String()),duration:P.Type.Optional(P.Type.Number()),easing:P.Type.Optional(P.Type.String()),endDelay:P.Type.Optional(P.Type.Number()),fill:P.Type.Optional(P.Type.String()),iterationStart:P.Type.Optional(P.Type.Number()),iterations:P.Type.Optional(P.Type.Number()),keyframes:P.Type.Optional(P.Type.Any())}),kx=P.Type.Array(P.Type.Any()),yge=P.Type.Object({keyframes:P.Type.Union([P.Type.String(),kx]),options:P.Type.Optional(KB)});P.Type.Object({keyframes:kx,options:P.Type.Optional(KB)});const GB=P.Type.Object({animations:P.Type.Record(P.Type.String(),yge),keyframes:P.Type.Record(P.Type.String(),kx)}),JB={animations:{},keyframes:{}},bge=P.Type.Object({name:P.Type.String(),type:P.Type.String(),optional:P.Type.Optional(P.Type.Boolean())}),wge=P.Type.Object({keyword:P.Type.String(),label:P.Type.String(),options:P.Type.Optional(P.Type.Array(bge))}),QB=P.Type.Object({macros:P.Type.Array(wge)}),YB={macros:[]},xx=P.Type.Object({assets:P.Type.Record(P.Type.String(),P.Type.String())}),XB=P.Type.Object({images:P.Type.Optional(xx),audio:P.Type.Optional(xx),video:P.Type.Optional(xx)}),ZB={images:{assets:{}},audio:{assets:{}},video:{assets:{}}},Kf={common:wx,screens:TB,buttons:jB,skills:PB,skillChecks:qB,scripts:[],audio:tB,tooltips:DB,achievements:VB,items:wB,quests:xB,characters:IB,choices:WB,animations:JB,macros:YB,preload:ZB};var kge=function(t){return xge(t)&&!_ge(t)};function xge(e){return!!e&&typeof e=="object"}function _ge(e){var t=Object.prototype.toString.call(e);return t==="[object RegExp]"||t==="[object Date]"||Cge(e)}var Sge=typeof Symbol=="function"&&Symbol.for,jge=Sge?Symbol.for("react.element"):60103;function Cge(e){return e.$$typeof===jge}function $ge(e){return Array.isArray(e)?[]:{}}function op(e,t){return t.clone!==!1&&t.isMergeableObject(e)?Gf($ge(e),e,t):e}function Tge(e,t,n){return e.concat(t).map(function(r){return op(r,n)})}function Oge(e,t){if(!t.customMerge)return Gf;var n=t.customMerge(e);return typeof n=="function"?n:Gf}function Ege(e){return Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(e).filter(function(t){return Object.propertyIsEnumerable.call(e,t)}):[]}function eF(e){return Object.keys(e).concat(Ege(e))}function tF(e,t){try{return t in e}catch{return!1}}function Age(e,t){return tF(e,t)&&!(Object.hasOwnProperty.call(e,t)&&Object.propertyIsEnumerable.call(e,t))}function Pge(e,t,n){var r={};return n.isMergeableObject(e)&&eF(e).forEach(function(o){r[o]=op(e[o],n)}),eF(t).forEach(function(o){Age(e,o)||(tF(e,o)&&n.isMergeableObject(t[o])?r[o]=Oge(o,n)(e[o],t[o],n):r[o]=op(t[o],n))}),r}function Gf(e,t,n){n=n||{},n.arrayMerge=n.arrayMerge||Tge,n.isMergeableObject=n.isMergeableObject||kge,n.cloneUnlessOtherwiseSpecified=op;var r=Array.isArray(t),o=Array.isArray(e),i=r===o;return i?r?n.arrayMerge(e,t,n):Pge(e,t,n):op(t,n)}Gf.all=function(t,n){if(!Array.isArray(t))throw new Error("first argument should be an array");return t.reduce(function(r,o){return Gf(r,o,n)},{})};var Mge=Gf,Ige=Mge;const fu=ey(Ige),fo=eo("config",{state:()=>({config:Kf,configModules:{}}),actions:{async setConfig(e){this.config=e},extendConfig(e){this.config=fu(this.config,e)},generateSaveData(){return{playerCharacter:this.playerCharacter,gameCharacter:this.gameCharacter}},addConfigModule(e,t){this.configModules[e]=t},findConfigModuleKey(e){const t=Object.keys(this.configModules).find(n=>this.configModules[n].id===e.id);if(t)return t},reloadConfigModule(e,t){this.configModules[e].code=t,this.config[e]=t},loadSaveData(e){this.config.characters.config.playerCharacter=e.playerCharacter,this.config.characters.config.gameCharacter=e.gameCharacter}},getters:{playerCharacter(){return this.config.characters.config.playerCharacter??"player"},gameCharacter(){return this.config.characters.config.gameCharacter??"game"}}});function nF(e){const t=Jr(),n=t.getSkillCheck(e.id);if(n&&n.happened&&(n.succeeded||!e.repeatable))return n;const r=$ve(e);return iF(_ve(r,e)),r?t.passSkillCheck(e.id,e.hideAfterRoll):t.failSkillCheck(e.id,e.hideAfterRoll),t.getSkillCheck(e.id)}function Nge(e,t=[]){const n=e.options,r=e.staticOptions,o=!!n.condition;if(o)return r.success;if(!o){for(const[i,a]of r.elseifs.entries())if(t[i]===!0)return a.branch}if(!o&&r.failure)return r.failure}function rF(e){return typeof e=="object"}function oF(e){return typeof e=="string"&&e.search(/\$/)===0}function iF(e){const t={speaker:fo().gameCharacter,text:e,interactive:!1};cr().addDialog(t)}async function _x(e){cr().addDialog(e)}function Rge(e,t){if(t<e.length)return e[t]}/*! js-yaml 4.1.0 https://github.com/nodeca/js-yaml @license MIT */function aF(e){return typeof e>"u"||e===null}function Dge(e){return typeof e=="object"&&e!==null}function Lge(e){return Array.isArray(e)?e:aF(e)?[]:[e]}function Bge(e,t){var n,r,o,i;if(t)for(i=Object.keys(t),n=0,r=i.length;n<r;n+=1)o=i[n],e[o]=t[o];return e}function Fge(e,t){var n="",r;for(r=0;r<t;r+=1)n+=e;return n}function Vge(e){return e===0&&Number.NEGATIVE_INFINITY===1/e}var zge=aF,qge=Dge,Uge=Lge,Hge=Fge,Wge=Vge,Kge=Bge,ho={isNothing:zge,isObject:qge,toArray:Uge,repeat:Hge,isNegativeZero:Wge,extend:Kge};function sF(e,t){var n="",r=e.reason||"(unknown reason)";return e.mark?(e.mark.name&&(n+='in "'+e.mark.name+'" '),n+="("+(e.mark.line+1)+":"+(e.mark.column+1)+")",!t&&e.mark.snippet&&(n+=`
174
+ (${e.id} - ${a}/${e.winsNeeded} - rolls: ${JSON.stringify(r.map(s=>s.modified))})`)}else i=X9(n,e.difficulty),qi.log(`[SKILL CHECK ${o.name}]: ${i?"✅":"❌"}`,`(${e.id}) - ${n}/${e.difficulty}`);return uu(i?"onSkillCheckSuccess":"onSkillCheckFailure"),i}function X9(e,t){const{options:n}=$p();let r=e>=t;return n.successOnRollsBelowThreshold&&(r=e<=t),n.failOnRollsEqualToThreshold&&e===t&&(r=!1),r}var P={};(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.Type=e.JsonType=e.JavaScriptTypeBuilder=e.JsonTypeBuilder=e.TypeBuilder=e.TypeBuilderError=e.TransformEncodeBuilder=e.TransformDecodeBuilder=e.TemplateLiteralDslParser=e.TemplateLiteralGenerator=e.TemplateLiteralGeneratorError=e.TemplateLiteralFinite=e.TemplateLiteralFiniteError=e.TemplateLiteralParser=e.TemplateLiteralParserError=e.TemplateLiteralResolver=e.TemplateLiteralPattern=e.TemplateLiteralPatternError=e.UnionResolver=e.KeyArrayResolver=e.KeyArrayResolverError=e.KeyResolver=e.ObjectMap=e.Intrinsic=e.IndexedAccessor=e.TypeClone=e.TypeExtends=e.TypeExtendsResult=e.TypeExtendsError=e.ExtendsUndefined=e.TypeGuard=e.TypeGuardUnknownTypeError=e.ValueGuard=e.FormatRegistry=e.TypeBoxError=e.TypeRegistry=e.PatternStringExact=e.PatternNumberExact=e.PatternBooleanExact=e.PatternString=e.PatternNumber=e.PatternBoolean=e.Kind=e.Hint=e.Optional=e.Readonly=e.Transform=void 0,e.Transform=Symbol.for("TypeBox.Transform"),e.Readonly=Symbol.for("TypeBox.Readonly"),e.Optional=Symbol.for("TypeBox.Optional"),e.Hint=Symbol.for("TypeBox.Hint"),e.Kind=Symbol.for("TypeBox.Kind"),e.PatternBoolean="(true|false)",e.PatternNumber="(0|[1-9][0-9]*)",e.PatternString="(.*)",e.PatternBooleanExact=`^${e.PatternBoolean}$`,e.PatternNumberExact=`^${e.PatternNumber}$`,e.PatternStringExact=`^${e.PatternString}$`;var t;(function(T){const x=new Map;function O(){return new Map(x)}T.Entries=O;function j(){return x.clear()}T.Clear=j;function C(ce){return x.delete(ce)}T.Delete=C;function _(ce){return x.has(ce)}T.Has=_;function F(ce,_e){x.set(ce,_e)}T.Set=F;function ee(ce){return x.get(ce)}T.Get=ee})(t||(e.TypeRegistry=t={}));class n extends Error{constructor(x){super(x)}}e.TypeBoxError=n;var r;(function(T){const x=new Map;function O(){return new Map(x)}T.Entries=O;function j(){return x.clear()}T.Clear=j;function C(ce){return x.delete(ce)}T.Delete=C;function _(ce){return x.has(ce)}T.Has=_;function F(ce,_e){x.set(ce,_e)}T.Set=F;function ee(ce){return x.get(ce)}T.Get=ee})(r||(e.FormatRegistry=r={}));var o;(function(T){function x(se){return Array.isArray(se)}T.IsArray=x;function O(se){return typeof se=="bigint"}T.IsBigInt=O;function j(se){return typeof se=="boolean"}T.IsBoolean=j;function C(se){return se instanceof globalThis.Date}T.IsDate=C;function _(se){return se===null}T.IsNull=_;function F(se){return typeof se=="number"}T.IsNumber=F;function ee(se){return typeof se=="object"&&se!==null}T.IsObject=ee;function ce(se){return typeof se=="string"}T.IsString=ce;function _e(se){return se instanceof globalThis.Uint8Array}T.IsUint8Array=_e;function xe(se){return se===void 0}T.IsUndefined=xe})(o||(e.ValueGuard=o={}));class i extends n{}e.TypeGuardUnknownTypeError=i;var a;(function(T){function x(z){try{return new RegExp(z),!0}catch{return!1}}function O(z){if(!o.IsString(z))return!1;for(let U=0;U<z.length;U++){const Z=z.charCodeAt(U);if(Z>=7&&Z<=13||Z===27||Z===127)return!1}return!0}function j(z){return F(z)||pe(z)}function C(z){return o.IsUndefined(z)||o.IsBigInt(z)}function _(z){return o.IsUndefined(z)||o.IsNumber(z)}function F(z){return o.IsUndefined(z)||o.IsBoolean(z)}function ee(z){return o.IsUndefined(z)||o.IsString(z)}function ce(z){return o.IsUndefined(z)||o.IsString(z)&&O(z)&&x(z)}function _e(z){return o.IsUndefined(z)||o.IsString(z)&&O(z)}function xe(z){return o.IsUndefined(z)||pe(z)}function se(z){return ze(z,"Any")&&ee(z.$id)}T.TAny=se;function Ie(z){return ze(z,"Array")&&z.type==="array"&&ee(z.$id)&&pe(z.items)&&_(z.minItems)&&_(z.maxItems)&&F(z.uniqueItems)&&xe(z.contains)&&_(z.minContains)&&_(z.maxContains)}T.TArray=Ie;function oe(z){return ze(z,"AsyncIterator")&&z.type==="AsyncIterator"&&ee(z.$id)&&pe(z.items)}T.TAsyncIterator=oe;function ye(z){return ze(z,"BigInt")&&z.type==="bigint"&&ee(z.$id)&&C(z.exclusiveMaximum)&&C(z.exclusiveMinimum)&&C(z.maximum)&&C(z.minimum)&&C(z.multipleOf)}T.TBigInt=ye;function de(z){return ze(z,"Boolean")&&z.type==="boolean"&&ee(z.$id)}T.TBoolean=de;function Fe(z){return ze(z,"Constructor")&&z.type==="Constructor"&&ee(z.$id)&&o.IsArray(z.parameters)&&z.parameters.every(U=>pe(U))&&pe(z.returns)}T.TConstructor=Fe;function Y(z){return ze(z,"Date")&&z.type==="Date"&&ee(z.$id)&&_(z.exclusiveMaximumTimestamp)&&_(z.exclusiveMinimumTimestamp)&&_(z.maximumTimestamp)&&_(z.minimumTimestamp)&&_(z.multipleOfTimestamp)}T.TDate=Y;function Q(z){return ze(z,"Function")&&z.type==="Function"&&ee(z.$id)&&o.IsArray(z.parameters)&&z.parameters.every(U=>pe(U))&&pe(z.returns)}T.TFunction=Q;function ve(z){return ze(z,"Integer")&&z.type==="integer"&&ee(z.$id)&&_(z.exclusiveMaximum)&&_(z.exclusiveMinimum)&&_(z.maximum)&&_(z.minimum)&&_(z.multipleOf)}T.TInteger=ve;function Ae(z){return ze(z,"Intersect")&&!(o.IsString(z.type)&&z.type!=="object")&&o.IsArray(z.allOf)&&z.allOf.every(U=>pe(U)&&!wn(U))&&ee(z.type)&&(F(z.unevaluatedProperties)||xe(z.unevaluatedProperties))&&ee(z.$id)}T.TIntersect=Ae;function Pe(z){return ze(z,"Iterator")&&z.type==="Iterator"&&ee(z.$id)&&pe(z.items)}T.TIterator=Pe;function ze(z,U){return ke(z)&&z[e.Kind]===U}T.TKindOf=ze;function ke(z){return o.IsObject(z)&&e.Kind in z&&o.IsString(z[e.Kind])}T.TKind=ke;function Ne(z){return We(z)&&o.IsString(z.const)}T.TLiteralString=Ne;function qe(z){return We(z)&&o.IsNumber(z.const)}T.TLiteralNumber=qe;function tt(z){return We(z)&&o.IsBoolean(z.const)}T.TLiteralBoolean=tt;function We(z){return ze(z,"Literal")&&ee(z.$id)&&(o.IsBoolean(z.const)||o.IsNumber(z.const)||o.IsString(z.const))}T.TLiteral=We;function ut(z){return ze(z,"Never")&&o.IsObject(z.not)&&Object.getOwnPropertyNames(z.not).length===0}T.TNever=ut;function gt(z){return ze(z,"Not")&&pe(z.not)}T.TNot=gt;function Rt(z){return ze(z,"Null")&&z.type==="null"&&ee(z.$id)}T.TNull=Rt;function jt(z){return ze(z,"Number")&&z.type==="number"&&ee(z.$id)&&_(z.exclusiveMaximum)&&_(z.exclusiveMinimum)&&_(z.maximum)&&_(z.minimum)&&_(z.multipleOf)}T.TNumber=jt;function En(z){return ze(z,"Object")&&z.type==="object"&&ee(z.$id)&&o.IsObject(z.properties)&&j(z.additionalProperties)&&_(z.minProperties)&&_(z.maxProperties)&&Object.entries(z.properties).every(([U,Z])=>O(U)&&pe(Z))}T.TObject=En;function Dt(z){return ze(z,"Promise")&&z.type==="Promise"&&ee(z.$id)&&pe(z.item)}T.TPromise=Dt;function Sn(z){return ze(z,"Record")&&z.type==="object"&&ee(z.$id)&&j(z.additionalProperties)&&o.IsObject(z.patternProperties)&&(U=>{const Z=Object.getOwnPropertyNames(U.patternProperties);return Z.length===1&&x(Z[0])&&o.IsObject(U.patternProperties)&&pe(U.patternProperties[Z[0]])})(z)}T.TRecord=Sn;function fn(z){return o.IsObject(z)&&e.Hint in z&&z[e.Hint]==="Recursive"}T.TRecursive=fn;function Kn(z){return ze(z,"Ref")&&ee(z.$id)&&o.IsString(z.$ref)}T.TRef=Kn;function bn(z){return ze(z,"String")&&z.type==="string"&&ee(z.$id)&&_(z.minLength)&&_(z.maxLength)&&ce(z.pattern)&&_e(z.format)}T.TString=bn;function Hn(z){return ze(z,"Symbol")&&z.type==="symbol"&&ee(z.$id)}T.TSymbol=Hn;function Dn(z){return ze(z,"TemplateLiteral")&&z.type==="string"&&o.IsString(z.pattern)&&z.pattern[0]==="^"&&z.pattern[z.pattern.length-1]==="$"}T.TTemplateLiteral=Dn;function jn(z){return ze(z,"This")&&ee(z.$id)&&o.IsString(z.$ref)}T.TThis=jn;function wn(z){return o.IsObject(z)&&e.Transform in z}T.TTransform=wn;function cn(z){return ze(z,"Tuple")&&z.type==="array"&&ee(z.$id)&&o.IsNumber(z.minItems)&&o.IsNumber(z.maxItems)&&z.minItems===z.maxItems&&(o.IsUndefined(z.items)&&o.IsUndefined(z.additionalItems)&&z.minItems===0||o.IsArray(z.items)&&z.items.every(U=>pe(U)))}T.TTuple=cn;function Zn(z){return ze(z,"Undefined")&&z.type==="undefined"&&ee(z.$id)}T.TUndefined=Zn;function Gn(z){return Me(z)&&z.anyOf.every(U=>Ne(U)||qe(U))}T.TUnionLiteral=Gn;function Me(z){return ze(z,"Union")&&ee(z.$id)&&o.IsObject(z)&&o.IsArray(z.anyOf)&&z.anyOf.every(U=>pe(U))}T.TUnion=Me;function dt(z){return ze(z,"Uint8Array")&&z.type==="Uint8Array"&&ee(z.$id)&&_(z.minByteLength)&&_(z.maxByteLength)}T.TUint8Array=dt;function Tt(z){return ze(z,"Unknown")&&ee(z.$id)}T.TUnknown=Tt;function nn(z){return ze(z,"Unsafe")}T.TUnsafe=nn;function Oe(z){return ze(z,"Void")&&z.type==="void"&&ee(z.$id)}T.TVoid=Oe;function ct(z){return o.IsObject(z)&&z[e.Readonly]==="Readonly"}T.TReadonly=ct;function re(z){return o.IsObject(z)&&z[e.Optional]==="Optional"}T.TOptional=re;function pe(z){return o.IsObject(z)&&(se(z)||Ie(z)||de(z)||ye(z)||oe(z)||Fe(z)||Y(z)||Q(z)||ve(z)||Ae(z)||Pe(z)||We(z)||ut(z)||gt(z)||Rt(z)||jt(z)||En(z)||Dt(z)||Sn(z)||Kn(z)||bn(z)||Hn(z)||Dn(z)||jn(z)||cn(z)||Zn(z)||Me(z)||dt(z)||Tt(z)||nn(z)||Oe(z)||ke(z)&&t.Has(z[e.Kind]))}T.TSchema=pe})(a||(e.TypeGuard=a={}));var s;(function(T){function x(O){return O[e.Kind]==="Intersect"?O.allOf.every(j=>x(j)):O[e.Kind]==="Union"?O.anyOf.some(j=>x(j)):O[e.Kind]==="Undefined"?!0:O[e.Kind]==="Not"?!x(O.not):!1}T.Check=x})(s||(e.ExtendsUndefined=s={}));class c extends n{}e.TypeExtendsError=c;var l;(function(T){T[T.Union=0]="Union",T[T.True=1]="True",T[T.False=2]="False"})(l||(e.TypeExtendsResult=l={}));var f;(function(T){function x(M){return M===l.False?M:l.True}function O(M){throw new c(M)}function j(M){return a.TNever(M)||a.TIntersect(M)||a.TUnion(M)||a.TUnknown(M)||a.TAny(M)}function C(M,G){return a.TNever(G)?ze():a.TIntersect(G)?Q(M,G):a.TUnion(G)?Te(M,G):a.TUnknown(G)?ht():a.TAny(G)?_():O("StructuralRight")}function _(M,G){return l.True}function F(M,G){return a.TIntersect(G)?Q(M,G):a.TUnion(G)&&G.anyOf.some(Ve=>a.TAny(Ve)||a.TUnknown(Ve))?l.True:a.TUnion(G)?l.Union:a.TUnknown(G)||a.TAny(G)?l.True:l.Union}function ee(M,G){return a.TUnknown(M)?l.False:a.TAny(M)?l.Union:a.TNever(M)?l.True:l.False}function ce(M,G){return a.TObject(G)&&Dn(G)?l.True:j(G)?C(M,G):a.TArray(G)?x(lt(M.items,G.items)):l.False}function _e(M,G){return j(G)?C(M,G):a.TAsyncIterator(G)?x(lt(M.items,G.items)):l.False}function xe(M,G){return j(G)?C(M,G):a.TObject(G)?cn(M,G):a.TRecord(G)?Tt(M,G):a.TBigInt(G)?l.True:l.False}function se(M,G){return a.TLiteral(M)&&o.IsBoolean(M.const)||a.TBoolean(M)?l.True:l.False}function Ie(M,G){return j(G)?C(M,G):a.TObject(G)?cn(M,G):a.TRecord(G)?Tt(M,G):a.TBoolean(G)?l.True:l.False}function oe(M,G){return j(G)?C(M,G):a.TObject(G)?cn(M,G):a.TConstructor(G)?M.parameters.length>G.parameters.length?l.False:M.parameters.every((Ve,nt)=>x(lt(G.parameters[nt],Ve))===l.True)?x(lt(M.returns,G.returns)):l.False:l.False}function ye(M,G){return j(G)?C(M,G):a.TObject(G)?cn(M,G):a.TRecord(G)?Tt(M,G):a.TDate(G)?l.True:l.False}function de(M,G){return j(G)?C(M,G):a.TObject(G)?cn(M,G):a.TFunction(G)?M.parameters.length>G.parameters.length?l.False:M.parameters.every((Ve,nt)=>x(lt(G.parameters[nt],Ve))===l.True)?x(lt(M.returns,G.returns)):l.False:l.False}function Fe(M,G){return a.TLiteral(M)&&o.IsNumber(M.const)||a.TNumber(M)||a.TInteger(M)?l.True:l.False}function Y(M,G){return a.TInteger(G)||a.TNumber(G)?l.True:j(G)?C(M,G):a.TObject(G)?cn(M,G):a.TRecord(G)?Tt(M,G):l.False}function Q(M,G){return G.allOf.every(Ve=>lt(M,Ve)===l.True)?l.True:l.False}function ve(M,G){return M.allOf.some(Ve=>lt(Ve,G)===l.True)?l.True:l.False}function Ae(M,G){return j(G)?C(M,G):a.TIterator(G)?x(lt(M.items,G.items)):l.False}function Pe(M,G){return a.TLiteral(G)&&G.const===M.const?l.True:j(G)?C(M,G):a.TObject(G)?cn(M,G):a.TRecord(G)?Tt(M,G):a.TString(G)?Oe(M):a.TNumber(G)?We(M):a.TInteger(G)?Fe(M):a.TBoolean(G)?se(M):l.False}function ze(M,G){return l.False}function ke(M,G){return l.True}function Ne(M){let[G,Ve]=[M,0];for(;a.TNot(G);)G=G.not,Ve+=1;return Ve%2===0?G:e.Type.Unknown()}function qe(M,G){return a.TNot(M)?lt(Ne(M),G):a.TNot(G)?lt(M,Ne(G)):O("Invalid fallthrough for Not")}function tt(M,G){return j(G)?C(M,G):a.TObject(G)?cn(M,G):a.TRecord(G)?Tt(M,G):a.TNull(G)?l.True:l.False}function We(M,G){return a.TLiteralNumber(M)||a.TNumber(M)||a.TInteger(M)?l.True:l.False}function ut(M,G){return j(G)?C(M,G):a.TObject(G)?cn(M,G):a.TRecord(G)?Tt(M,G):a.TInteger(G)||a.TNumber(G)?l.True:l.False}function gt(M,G){return Object.getOwnPropertyNames(M.properties).length===G}function Rt(M){return Dn(M)}function jt(M){return gt(M,0)||gt(M,1)&&"description"in M.properties&&a.TUnion(M.properties.description)&&M.properties.description.anyOf.length===2&&(a.TString(M.properties.description.anyOf[0])&&a.TUndefined(M.properties.description.anyOf[1])||a.TString(M.properties.description.anyOf[1])&&a.TUndefined(M.properties.description.anyOf[0]))}function En(M){return gt(M,0)}function Dt(M){return gt(M,0)}function Sn(M){return gt(M,0)}function fn(M){return gt(M,0)}function Kn(M){return Dn(M)}function bn(M){const G=e.Type.Number();return gt(M,0)||gt(M,1)&&"length"in M.properties&&x(lt(M.properties.length,G))===l.True}function Hn(M){return gt(M,0)}function Dn(M){const G=e.Type.Number();return gt(M,0)||gt(M,1)&&"length"in M.properties&&x(lt(M.properties.length,G))===l.True}function jn(M){const G=e.Type.Function([e.Type.Any()],e.Type.Any());return gt(M,0)||gt(M,1)&&"then"in M.properties&&x(lt(M.properties.then,G))===l.True}function wn(M,G){return lt(M,G)===l.False||a.TOptional(M)&&!a.TOptional(G)?l.False:l.True}function cn(M,G){return a.TUnknown(M)?l.False:a.TAny(M)?l.Union:a.TNever(M)||a.TLiteralString(M)&&Rt(G)||a.TLiteralNumber(M)&&En(G)||a.TLiteralBoolean(M)&&Dt(G)||a.TSymbol(M)&&jt(G)||a.TBigInt(M)&&Sn(G)||a.TString(M)&&Rt(G)||a.TSymbol(M)&&jt(G)||a.TNumber(M)&&En(G)||a.TInteger(M)&&En(G)||a.TBoolean(M)&&Dt(G)||a.TUint8Array(M)&&Kn(G)||a.TDate(M)&&fn(G)||a.TConstructor(M)&&Hn(G)||a.TFunction(M)&&bn(G)?l.True:a.TRecord(M)&&a.TString(Me(M))?G[e.Hint]==="Record"?l.True:l.False:a.TRecord(M)&&a.TNumber(Me(M))?gt(G,0)?l.True:l.False:l.False}function Zn(M,G){return j(G)?C(M,G):a.TRecord(G)?Tt(M,G):a.TObject(G)?(()=>{for(const Ve of Object.getOwnPropertyNames(G.properties)){if(!(Ve in M.properties)&&!a.TOptional(G.properties[Ve]))return l.False;if(a.TOptional(G.properties[Ve]))return l.True;if(wn(M.properties[Ve],G.properties[Ve])===l.False)return l.False}return l.True})():l.False}function Gn(M,G){return j(G)?C(M,G):a.TObject(G)&&jn(G)?l.True:a.TPromise(G)?x(lt(M.item,G.item)):l.False}function Me(M){return e.PatternNumberExact in M.patternProperties?e.Type.Number():e.PatternStringExact in M.patternProperties?e.Type.String():O("Unknown record key pattern")}function dt(M){return e.PatternNumberExact in M.patternProperties?M.patternProperties[e.PatternNumberExact]:e.PatternStringExact in M.patternProperties?M.patternProperties[e.PatternStringExact]:O("Unable to get record value schema")}function Tt(M,G){const[Ve,nt]=[Me(G),dt(G)];return a.TLiteralString(M)&&a.TNumber(Ve)&&x(lt(M,nt))===l.True?l.True:a.TUint8Array(M)&&a.TNumber(Ve)||a.TString(M)&&a.TNumber(Ve)||a.TArray(M)&&a.TNumber(Ve)?lt(M,nt):a.TObject(M)?(()=>{for(const at of Object.getOwnPropertyNames(M.properties))if(wn(nt,M.properties[at])===l.False)return l.False;return l.True})():l.False}function nn(M,G){return j(G)?C(M,G):a.TObject(G)?cn(M,G):a.TRecord(G)?lt(dt(M),dt(G)):l.False}function Oe(M,G){return a.TLiteral(M)&&o.IsString(M.const)||a.TString(M)?l.True:l.False}function ct(M,G){return j(G)?C(M,G):a.TObject(G)?cn(M,G):a.TRecord(G)?Tt(M,G):a.TString(G)?l.True:l.False}function re(M,G){return j(G)?C(M,G):a.TObject(G)?cn(M,G):a.TRecord(G)?Tt(M,G):a.TSymbol(G)?l.True:l.False}function pe(M,G){return a.TTemplateLiteral(M)?lt($.Resolve(M),G):a.TTemplateLiteral(G)?lt(M,$.Resolve(G)):O("Invalid fallthrough for TemplateLiteral")}function z(M,G){return a.TArray(G)&&M.items!==void 0&&M.items.every(Ve=>lt(Ve,G.items)===l.True)}function U(M,G){return a.TNever(M)?l.True:a.TUnknown(M)?l.False:a.TAny(M)?l.Union:l.False}function Z(M,G){return j(G)?C(M,G):a.TObject(G)&&Dn(G)||a.TArray(G)&&z(M,G)?l.True:a.TTuple(G)?o.IsUndefined(M.items)&&!o.IsUndefined(G.items)||!o.IsUndefined(M.items)&&o.IsUndefined(G.items)?l.False:o.IsUndefined(M.items)&&!o.IsUndefined(G.items)||M.items.every((Ve,nt)=>lt(Ve,G.items[nt])===l.True)?l.True:l.False:l.False}function he(M,G){return j(G)?C(M,G):a.TObject(G)?cn(M,G):a.TRecord(G)?Tt(M,G):a.TUint8Array(G)?l.True:l.False}function Se(M,G){return j(G)?C(M,G):a.TObject(G)?cn(M,G):a.TRecord(G)?Tt(M,G):a.TVoid(G)?bt(M):a.TUndefined(G)?l.True:l.False}function Te(M,G){return G.anyOf.some(Ve=>lt(M,Ve)===l.True)?l.True:l.False}function it(M,G){return M.anyOf.every(Ve=>lt(Ve,G)===l.True)?l.True:l.False}function ht(M,G){return l.True}function Ot(M,G){return a.TNever(G)?ze():a.TIntersect(G)?Q(M,G):a.TUnion(G)?Te(M,G):a.TAny(G)?_():a.TString(G)?Oe(M):a.TNumber(G)?We(M):a.TInteger(G)?Fe(M):a.TBoolean(G)?se(M):a.TArray(G)?ee(M):a.TTuple(G)?U(M):a.TObject(G)?cn(M,G):a.TUnknown(G)?l.True:l.False}function bt(M,G){return a.TUndefined(M)||a.TUndefined(M)?l.True:l.False}function Ht(M,G){return a.TIntersect(G)?Q(M,G):a.TUnion(G)?Te(M,G):a.TUnknown(G)?ht():a.TAny(G)?_():a.TObject(G)?cn(M,G):a.TVoid(G)?l.True:l.False}function lt(M,G){return a.TTemplateLiteral(M)||a.TTemplateLiteral(G)?pe(M,G):a.TNot(M)||a.TNot(G)?qe(M,G):a.TAny(M)?F(M,G):a.TArray(M)?ce(M,G):a.TBigInt(M)?xe(M,G):a.TBoolean(M)?Ie(M,G):a.TAsyncIterator(M)?_e(M,G):a.TConstructor(M)?oe(M,G):a.TDate(M)?ye(M,G):a.TFunction(M)?de(M,G):a.TInteger(M)?Y(M,G):a.TIntersect(M)?ve(M,G):a.TIterator(M)?Ae(M,G):a.TLiteral(M)?Pe(M,G):a.TNever(M)?ke():a.TNull(M)?tt(M,G):a.TNumber(M)?ut(M,G):a.TObject(M)?Zn(M,G):a.TRecord(M)?nn(M,G):a.TString(M)?ct(M,G):a.TSymbol(M)?re(M,G):a.TTuple(M)?Z(M,G):a.TPromise(M)?Gn(M,G):a.TUint8Array(M)?he(M,G):a.TUndefined(M)?Se(M,G):a.TUnion(M)?it(M,G):a.TUnknown(M)?Ot(M,G):a.TVoid(M)?Ht(M,G):O(`Unknown left type operand '${M[e.Kind]}'`)}function rn(M,G){return lt(M,G)}T.Extends=rn})(f||(e.TypeExtends=f={}));var u;(function(T){function x(ce){return ce.map(_e=>_(_e))}function O(ce){return new Date(ce.getTime())}function j(ce){return new Uint8Array(ce)}function C(ce){const _e=Object.getOwnPropertyNames(ce).reduce((se,Ie)=>({...se,[Ie]:_(ce[Ie])}),{}),xe=Object.getOwnPropertySymbols(ce).reduce((se,Ie)=>({...se,[Ie]:_(ce[Ie])}),{});return{..._e,...xe}}function _(ce){return o.IsArray(ce)?x(ce):o.IsDate(ce)?O(ce):o.IsUint8Array(ce)?j(ce):o.IsObject(ce)?C(ce):ce}function F(ce){return ce.map(_e=>ee(_e))}T.Rest=F;function ee(ce,_e={}){return{..._(ce),..._e}}T.Type=ee})(u||(e.TypeClone=u={}));var d;(function(T){function x(oe){return oe.map(ye=>{const{[e.Optional]:de,...Fe}=u.Type(ye);return Fe})}function O(oe){return oe.every(ye=>a.TOptional(ye))}function j(oe){return oe.some(ye=>a.TOptional(ye))}function C(oe){return O(oe.allOf)?e.Type.Optional(e.Type.Intersect(x(oe.allOf))):oe}function _(oe){return j(oe.anyOf)?e.Type.Optional(e.Type.Union(x(oe.anyOf))):oe}function F(oe){return oe[e.Kind]==="Intersect"?C(oe):oe[e.Kind]==="Union"?_(oe):oe}function ee(oe,ye){const de=oe.allOf.reduce((Fe,Y)=>{const Q=se(Y,ye);return Q[e.Kind]==="Never"?Fe:[...Fe,Q]},[]);return F(e.Type.Intersect(de))}function ce(oe,ye){const de=oe.anyOf.map(Fe=>se(Fe,ye));return F(e.Type.Union(de))}function _e(oe,ye){const de=oe.properties[ye];return o.IsUndefined(de)?e.Type.Never():e.Type.Union([de])}function xe(oe,ye){const de=oe.items;if(o.IsUndefined(de))return e.Type.Never();const Fe=de[ye];return o.IsUndefined(Fe)?e.Type.Never():Fe}function se(oe,ye){return oe[e.Kind]==="Intersect"?ee(oe,ye):oe[e.Kind]==="Union"?ce(oe,ye):oe[e.Kind]==="Object"?_e(oe,ye):oe[e.Kind]==="Tuple"?xe(oe,ye):e.Type.Never()}function Ie(oe,ye,de={}){const Fe=ye.map(Y=>se(oe,Y.toString()));return F(e.Type.Union(Fe,de))}T.Resolve=Ie})(d||(e.IndexedAccessor=d={}));var h;(function(T){function x(xe){const[se,Ie]=[xe.slice(0,1),xe.slice(1)];return`${se.toLowerCase()}${Ie}`}function O(xe){const[se,Ie]=[xe.slice(0,1),xe.slice(1)];return`${se.toUpperCase()}${Ie}`}function j(xe){return xe.toUpperCase()}function C(xe){return xe.toLowerCase()}function _(xe,se){const Ie=E.ParseExact(xe.pattern);if(!D.Check(Ie))return{...xe,pattern:F(xe.pattern,se)};const de=[...I.Generate(Ie)].map(Q=>e.Type.Literal(Q)),Fe=ee(de,se),Y=e.Type.Union(Fe);return e.Type.TemplateLiteral([Y])}function F(xe,se){return typeof xe=="string"?se==="Uncapitalize"?x(xe):se==="Capitalize"?O(xe):se==="Uppercase"?j(xe):se==="Lowercase"?C(xe):xe:xe.toString()}function ee(xe,se){if(xe.length===0)return[];const[Ie,...oe]=xe;return[_e(Ie,se),...ee(oe,se)]}function ce(xe,se){return a.TTemplateLiteral(xe)?_(xe,se):a.TUnion(xe)?e.Type.Union(ee(xe.anyOf,se)):a.TLiteral(xe)?e.Type.Literal(F(xe.const,se)):xe}function _e(xe,se){return ce(xe,se)}T.Map=_e})(h||(e.Intrinsic=h={}));var p;(function(T){function x(F,ee){return e.Type.Intersect(F.allOf.map(ce=>C(ce,ee)),{...F})}function O(F,ee){return e.Type.Union(F.anyOf.map(ce=>C(ce,ee)),{...F})}function j(F,ee){return ee(F)}function C(F,ee){return F[e.Kind]==="Intersect"?x(F,ee):F[e.Kind]==="Union"?O(F,ee):F[e.Kind]==="Object"?j(F,ee):F}function _(F,ee,ce){return{...C(u.Type(F),ee),...ce}}T.Map=_})(p||(e.ObjectMap=p={}));var m;(function(T){function x(_e){return _e[0]==="^"&&_e[_e.length-1]==="$"?_e.slice(1,_e.length-1):_e}function O(_e,xe){return _e.allOf.reduce((se,Ie)=>[...se,...F(Ie,xe)],[])}function j(_e,xe){const se=_e.anyOf.map(Ie=>F(Ie,xe));return[...se.reduce((Ie,oe)=>oe.map(ye=>se.every(de=>de.includes(ye))?Ie.add(ye):Ie)[0],new Set)]}function C(_e,xe){return Object.getOwnPropertyNames(_e.properties)}function _(_e,xe){return xe.includePatterns?Object.getOwnPropertyNames(_e.patternProperties):[]}function F(_e,xe){return a.TIntersect(_e)?O(_e,xe):a.TUnion(_e)?j(_e,xe):a.TObject(_e)?C(_e):a.TRecord(_e)?_(_e,xe):[]}function ee(_e,xe){return[...new Set(F(_e,xe))]}T.ResolveKeys=ee;function ce(_e){return`^(${ee(_e,{includePatterns:!0}).map(Ie=>`(${x(Ie)})`).join("|")})$`}T.ResolvePattern=ce})(m||(e.KeyResolver=m={}));class v extends n{}e.KeyArrayResolverError=v;var g;(function(T){function x(O){return Array.isArray(O)?O:a.TUnionLiteral(O)?O.anyOf.map(j=>j.const.toString()):a.TLiteral(O)?[O.const]:a.TTemplateLiteral(O)?(()=>{const j=E.ParseExact(O.pattern);if(!D.Check(j))throw new v("Cannot resolve keys from infinite template expression");return[...I.Generate(j)]})():[]}T.Resolve=x})(g||(e.KeyArrayResolver=g={}));var y;(function(T){function*x(j){for(const C of j.anyOf)C[e.Kind]==="Union"?yield*x(C):yield C}function O(j){return e.Type.Union([...x(j)],{...j})}T.Resolve=O})(y||(e.UnionResolver=y={}));class w extends n{}e.TemplateLiteralPatternError=w;var k;(function(T){function x(_){throw new w(_)}function O(_){return _.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function j(_,F){return a.TTemplateLiteral(_)?_.pattern.slice(1,_.pattern.length-1):a.TUnion(_)?`(${_.anyOf.map(ee=>j(ee,F)).join("|")})`:a.TNumber(_)?`${F}${e.PatternNumber}`:a.TInteger(_)?`${F}${e.PatternNumber}`:a.TBigInt(_)?`${F}${e.PatternNumber}`:a.TString(_)?`${F}${e.PatternString}`:a.TLiteral(_)?`${F}${O(_.const.toString())}`:a.TBoolean(_)?`${F}${e.PatternBoolean}`:x(`Unexpected Kind '${_[e.Kind]}'`)}function C(_){return`^${_.map(F=>j(F,"")).join("")}$`}T.Create=C})(k||(e.TemplateLiteralPattern=k={}));var $;(function(T){function x(O){const j=E.ParseExact(O.pattern);if(!D.Check(j))return e.Type.String();const C=[...I.Generate(j)].map(_=>e.Type.Literal(_));return e.Type.Union(C)}T.Resolve=x})($||(e.TemplateLiteralResolver=$={}));class S extends n{}e.TemplateLiteralParserError=S;var E;(function(T){function x(oe,ye,de){return oe[ye]===de&&oe.charCodeAt(ye-1)!==92}function O(oe,ye){return x(oe,ye,"(")}function j(oe,ye){return x(oe,ye,")")}function C(oe,ye){return x(oe,ye,"|")}function _(oe){if(!(O(oe,0)&&j(oe,oe.length-1)))return!1;let ye=0;for(let de=0;de<oe.length;de++)if(O(oe,de)&&(ye+=1),j(oe,de)&&(ye-=1),ye===0&&de!==oe.length-1)return!1;return!0}function F(oe){return oe.slice(1,oe.length-1)}function ee(oe){let ye=0;for(let de=0;de<oe.length;de++)if(O(oe,de)&&(ye+=1),j(oe,de)&&(ye-=1),C(oe,de)&&ye===0)return!0;return!1}function ce(oe){for(let ye=0;ye<oe.length;ye++)if(O(oe,ye))return!0;return!1}function _e(oe){let[ye,de]=[0,0];const Fe=[];for(let Q=0;Q<oe.length;Q++)if(O(oe,Q)&&(ye+=1),j(oe,Q)&&(ye-=1),C(oe,Q)&&ye===0){const ve=oe.slice(de,Q);ve.length>0&&Fe.push(se(ve)),de=Q+1}const Y=oe.slice(de);return Y.length>0&&Fe.push(se(Y)),Fe.length===0?{type:"const",const:""}:Fe.length===1?Fe[0]:{type:"or",expr:Fe}}function xe(oe){function ye(Y,Q){if(!O(Y,Q))throw new S("TemplateLiteralParser: Index must point to open parens");let ve=0;for(let Ae=Q;Ae<Y.length;Ae++)if(O(Y,Ae)&&(ve+=1),j(Y,Ae)&&(ve-=1),ve===0)return[Q,Ae];throw new S("TemplateLiteralParser: Unclosed group parens in expression")}function de(Y,Q){for(let ve=Q;ve<Y.length;ve++)if(O(Y,ve))return[Q,ve];return[Q,Y.length]}const Fe=[];for(let Y=0;Y<oe.length;Y++)if(O(oe,Y)){const[Q,ve]=ye(oe,Y),Ae=oe.slice(Q,ve+1);Fe.push(se(Ae)),Y=ve}else{const[Q,ve]=de(oe,Y),Ae=oe.slice(Q,ve);Ae.length>0&&Fe.push(se(Ae)),Y=ve-1}return Fe.length===0?{type:"const",const:""}:Fe.length===1?Fe[0]:{type:"and",expr:Fe}}function se(oe){return _(oe)?se(F(oe)):ee(oe)?_e(oe):ce(oe)?xe(oe):{type:"const",const:oe}}T.Parse=se;function Ie(oe){return se(oe.slice(1,oe.length-1))}T.ParseExact=Ie})(E||(e.TemplateLiteralParser=E={}));class R extends n{}e.TemplateLiteralFiniteError=R;var D;(function(T){function x(F){throw new R(F)}function O(F){return F.type==="or"&&F.expr.length===2&&F.expr[0].type==="const"&&F.expr[0].const==="0"&&F.expr[1].type==="const"&&F.expr[1].const==="[1-9][0-9]*"}function j(F){return F.type==="or"&&F.expr.length===2&&F.expr[0].type==="const"&&F.expr[0].const==="true"&&F.expr[1].type==="const"&&F.expr[1].const==="false"}function C(F){return F.type==="const"&&F.const===".*"}function _(F){return j(F)?!0:O(F)||C(F)?!1:F.type==="and"?F.expr.every(ee=>_(ee)):F.type==="or"?F.expr.every(ee=>_(ee)):F.type==="const"?!0:x("Unknown expression type")}T.Check=_})(D||(e.TemplateLiteralFinite=D={}));class L extends n{}e.TemplateLiteralGeneratorError=L;var I;(function(T){function*x(F){if(F.length===1)return yield*F[0];for(const ee of F[0])for(const ce of x(F.slice(1)))yield`${ee}${ce}`}function*O(F){return yield*x(F.expr.map(ee=>[..._(ee)]))}function*j(F){for(const ee of F.expr)yield*_(ee)}function*C(F){return yield F.const}function*_(F){return F.type==="and"?yield*O(F):F.type==="or"?yield*j(F):F.type==="const"?yield*C(F):(()=>{throw new L("Unknown expression")})()}T.Generate=_})(I||(e.TemplateLiteralGenerator=I={}));var B;(function(T){function*x(_){const F=_.trim().replace(/"|'/g,"");return F==="boolean"?yield e.Type.Boolean():F==="number"?yield e.Type.Number():F==="bigint"?yield e.Type.BigInt():F==="string"?yield e.Type.String():yield(()=>{const ee=F.split("|").map(ce=>e.Type.Literal(ce.trim()));return ee.length===0?e.Type.Never():ee.length===1?ee[0]:e.Type.Union(ee)})()}function*O(_){if(_[1]!=="{"){const F=e.Type.Literal("$"),ee=j(_.slice(1));return yield*[F,...ee]}for(let F=2;F<_.length;F++)if(_[F]==="}"){const ee=x(_.slice(2,F)),ce=j(_.slice(F+1));return yield*[...ee,...ce]}yield e.Type.Literal(_)}function*j(_){for(let F=0;F<_.length;F++)if(_[F]==="$"){const ee=e.Type.Literal(_.slice(0,F)),ce=O(_.slice(F));return yield*[ee,...ce]}yield e.Type.Literal(_)}function C(_){return[...j(_)]}T.Parse=C})(B||(e.TemplateLiteralDslParser=B={}));class q{constructor(x){this.schema=x}Decode(x){return new N(this.schema,x)}}e.TransformDecodeBuilder=q;class N{constructor(x,O){this.schema=x,this.decode=O}Encode(x){const O=u.Type(this.schema);return a.TTransform(O)?(()=>{const _={Encode:F=>O[e.Transform].Encode(x(F)),Decode:F=>this.decode(O[e.Transform].Decode(F))};return{...O,[e.Transform]:_}})():(()=>{const j={Decode:this.decode,Encode:x};return{...O,[e.Transform]:j}})()}}e.TransformEncodeBuilder=N;let W=0;class X extends n{}e.TypeBuilderError=X;class H{Create(x){return x}Throw(x){throw new X(x)}Discard(x,O){return O.reduce((j,C)=>{const{[C]:_,...F}=j;return F},x)}Strict(x){return JSON.parse(JSON.stringify(x))}}e.TypeBuilder=H;class K extends H{ReadonlyOptional(x){return this.Readonly(this.Optional(x))}Readonly(x){return{...u.Type(x),[e.Readonly]:"Readonly"}}Optional(x){return{...u.Type(x),[e.Optional]:"Optional"}}Any(x={}){return this.Create({...x,[e.Kind]:"Any"})}Array(x,O={}){return this.Create({...O,[e.Kind]:"Array",type:"array",items:u.Type(x)})}Boolean(x={}){return this.Create({...x,[e.Kind]:"Boolean",type:"boolean"})}Capitalize(x,O={}){return{...h.Map(u.Type(x),"Capitalize"),...O}}Composite(x,O){const j=e.Type.Intersect(x,{}),_=m.ResolveKeys(j,{includePatterns:!1}).reduce((F,ee)=>({...F,[ee]:e.Type.Index(j,[ee])}),{});return e.Type.Object(_,O)}Enum(x,O={}){if(o.IsUndefined(x))return this.Throw("Enum undefined or empty");const j=Object.getOwnPropertyNames(x).filter(F=>isNaN(F)).map(F=>x[F]),_=[...new Set(j)].map(F=>e.Type.Literal(F));return this.Union(_,{...O,[e.Hint]:"Enum"})}Extends(x,O,j,C,_={}){switch(f.Extends(x,O)){case l.Union:return this.Union([u.Type(j,_),u.Type(C,_)]);case l.True:return u.Type(j,_);case l.False:return u.Type(C,_)}}Exclude(x,O,j={}){return a.TTemplateLiteral(x)?this.Exclude($.Resolve(x),O,j):a.TTemplateLiteral(O)?this.Exclude(x,$.Resolve(O),j):a.TUnion(x)?(()=>{const C=x.anyOf.filter(_=>f.Extends(_,O)===l.False);return C.length===1?u.Type(C[0],j):this.Union(C,j)})():f.Extends(x,O)!==l.False?this.Never(j):u.Type(x,j)}Extract(x,O,j={}){return a.TTemplateLiteral(x)?this.Extract($.Resolve(x),O,j):a.TTemplateLiteral(O)?this.Extract(x,$.Resolve(O),j):a.TUnion(x)?(()=>{const C=x.anyOf.filter(_=>f.Extends(_,O)!==l.False);return C.length===1?u.Type(C[0],j):this.Union(C,j)})():f.Extends(x,O)!==l.False?u.Type(x,j):this.Never(j)}Index(x,O,j={}){return a.TArray(x)&&a.TNumber(O)?u.Type(x.items,j):a.TTuple(x)&&a.TNumber(O)?(()=>{const _=(o.IsUndefined(x.items)?[]:x.items).map(F=>u.Type(F));return this.Union(_,j)})():(()=>{const C=g.Resolve(O),_=u.Type(x);return d.Resolve(_,C,j)})()}Integer(x={}){return this.Create({...x,[e.Kind]:"Integer",type:"integer"})}Intersect(x,O={}){if(x.length===0)return e.Type.Never();if(x.length===1)return u.Type(x[0],O);x.some(F=>a.TTransform(F))&&this.Throw("Cannot intersect transform types");const j=x.every(F=>a.TObject(F)),C=u.Rest(x),_=a.TSchema(O.unevaluatedProperties)?{unevaluatedProperties:u.Type(O.unevaluatedProperties)}:{};return O.unevaluatedProperties===!1||a.TSchema(O.unevaluatedProperties)||j?this.Create({...O,..._,[e.Kind]:"Intersect",type:"object",allOf:C}):this.Create({...O,..._,[e.Kind]:"Intersect",allOf:C})}KeyOf(x,O={}){return a.TRecord(x)?(()=>{const j=Object.getOwnPropertyNames(x.patternProperties)[0];return j===e.PatternNumberExact?this.Number(O):j===e.PatternStringExact?this.String(O):this.Throw("Unable to resolve key type from Record key pattern")})():a.TTuple(x)?(()=>{const C=(o.IsUndefined(x.items)?[]:x.items).map((_,F)=>e.Type.Literal(F.toString()));return this.Union(C,O)})():a.TArray(x)?this.Number(O):(()=>{const j=m.ResolveKeys(x,{includePatterns:!1});if(j.length===0)return this.Never(O);const C=j.map(_=>this.Literal(_));return this.Union(C,O)})()}Literal(x,O={}){return this.Create({...O,[e.Kind]:"Literal",const:x,type:typeof x})}Lowercase(x,O={}){return{...h.Map(u.Type(x),"Lowercase"),...O}}Never(x={}){return this.Create({...x,[e.Kind]:"Never",not:{}})}Not(x,O){return this.Create({...O,[e.Kind]:"Not",not:u.Type(x)})}Null(x={}){return this.Create({...x,[e.Kind]:"Null",type:"null"})}Number(x={}){return this.Create({...x,[e.Kind]:"Number",type:"number"})}Object(x,O={}){const j=Object.getOwnPropertyNames(x),C=j.filter(ce=>a.TOptional(x[ce])),_=j.filter(ce=>!C.includes(ce)),F=a.TSchema(O.additionalProperties)?{additionalProperties:u.Type(O.additionalProperties)}:{},ee=j.reduce((ce,_e)=>({...ce,[_e]:u.Type(x[_e])}),{});return _.length>0?this.Create({...O,...F,[e.Kind]:"Object",type:"object",properties:ee,required:_}):this.Create({...O,...F,[e.Kind]:"Object",type:"object",properties:ee})}Omit(x,O,j={}){const C=g.Resolve(O);return p.Map(this.Discard(u.Type(x),["$id",e.Transform]),_=>{o.IsArray(_.required)&&(_.required=_.required.filter(F=>!C.includes(F)),_.required.length===0&&delete _.required);for(const F of Object.getOwnPropertyNames(_.properties))C.includes(F)&&delete _.properties[F];return this.Create(_)},j)}Partial(x,O={}){return p.Map(this.Discard(u.Type(x),["$id",e.Transform]),j=>{const C=Object.getOwnPropertyNames(j.properties).reduce((_,F)=>({..._,[F]:this.Optional(j.properties[F])}),{});return this.Object(C,this.Discard(j,["required"]))},O)}Pick(x,O,j={}){const C=g.Resolve(O);return p.Map(this.Discard(u.Type(x),["$id",e.Transform]),_=>{o.IsArray(_.required)&&(_.required=_.required.filter(F=>C.includes(F)),_.required.length===0&&delete _.required);for(const F of Object.getOwnPropertyNames(_.properties))C.includes(F)||delete _.properties[F];return this.Create(_)},j)}Record(x,O,j={}){return a.TTemplateLiteral(x)?(()=>{const C=E.ParseExact(x.pattern);return D.Check(C)?this.Object([...I.Generate(C)].reduce((_,F)=>({..._,[F]:u.Type(O)}),{}),j):this.Create({...j,[e.Kind]:"Record",type:"object",patternProperties:{[x.pattern]:u.Type(O)}})})():a.TUnion(x)?(()=>{const C=y.Resolve(x);if(a.TUnionLiteral(C)){const _=C.anyOf.reduce((F,ee)=>({...F,[ee.const]:u.Type(O)}),{});return this.Object(_,{...j,[e.Hint]:"Record"})}else this.Throw("Record key of type union contains non-literal types")})():a.TLiteral(x)?o.IsString(x.const)||o.IsNumber(x.const)?this.Object({[x.const]:u.Type(O)},j):this.Throw("Record key of type literal is not of type string or number"):a.TInteger(x)||a.TNumber(x)?this.Create({...j,[e.Kind]:"Record",type:"object",patternProperties:{[e.PatternNumberExact]:u.Type(O)}}):a.TString(x)?(()=>{const C=o.IsUndefined(x.pattern)?e.PatternStringExact:x.pattern;return this.Create({...j,[e.Kind]:"Record",type:"object",patternProperties:{[C]:u.Type(O)}})})():this.Never()}Recursive(x,O={}){o.IsUndefined(O.$id)&&(O.$id=`T${W++}`);const j=x({[e.Kind]:"This",$ref:`${O.$id}`});return j.$id=O.$id,this.Create({...O,[e.Hint]:"Recursive",...j})}Ref(x,O={}){return o.IsString(x)?this.Create({...O,[e.Kind]:"Ref",$ref:x}):(o.IsUndefined(x.$id)&&this.Throw("Reference target type must specify an $id"),this.Create({...O,[e.Kind]:"Ref",$ref:x.$id}))}Required(x,O={}){return p.Map(this.Discard(u.Type(x),["$id",e.Transform]),j=>{const C=Object.getOwnPropertyNames(j.properties).reduce((_,F)=>({..._,[F]:this.Discard(j.properties[F],[e.Optional])}),{});return this.Object(C,j)},O)}Rest(x){return a.TTuple(x)&&!o.IsUndefined(x.items)?u.Rest(x.items):a.TIntersect(x)?u.Rest(x.allOf):a.TUnion(x)?u.Rest(x.anyOf):[]}String(x={}){return this.Create({...x,[e.Kind]:"String",type:"string"})}TemplateLiteral(x,O={}){const j=o.IsString(x)?k.Create(B.Parse(x)):k.Create(x);return this.Create({...O,[e.Kind]:"TemplateLiteral",type:"string",pattern:j})}Transform(x){return new q(x)}Tuple(x,O={}){const[j,C,_]=[!1,x.length,x.length],F=u.Rest(x),ee=x.length>0?{...O,[e.Kind]:"Tuple",type:"array",items:F,additionalItems:j,minItems:C,maxItems:_}:{...O,[e.Kind]:"Tuple",type:"array",minItems:C,maxItems:_};return this.Create(ee)}Uncapitalize(x,O={}){return{...h.Map(u.Type(x),"Uncapitalize"),...O}}Union(x,O={}){return a.TTemplateLiteral(x)?$.Resolve(x):(()=>{const j=x;if(j.length===0)return this.Never(O);if(j.length===1)return this.Create(u.Type(j[0],O));const C=u.Rest(j);return this.Create({...O,[e.Kind]:"Union",anyOf:C})})()}Unknown(x={}){return this.Create({...x,[e.Kind]:"Unknown"})}Unsafe(x={}){return this.Create({...x,[e.Kind]:x[e.Kind]||"Unsafe"})}Uppercase(x,O={}){return{...h.Map(u.Type(x),"Uppercase"),...O}}}e.JsonTypeBuilder=K;class A extends K{AsyncIterator(x,O={}){return this.Create({...O,[e.Kind]:"AsyncIterator",type:"AsyncIterator",items:u.Type(x)})}Awaited(x,O={}){const j=C=>C.length>0?(()=>{const[_,...F]=C;return[this.Awaited(_),...j(F)]})():C;return a.TIntersect(x)?e.Type.Intersect(j(x.allOf)):a.TUnion(x)?e.Type.Union(j(x.anyOf)):a.TPromise(x)?this.Awaited(x.item):u.Type(x,O)}BigInt(x={}){return this.Create({...x,[e.Kind]:"BigInt",type:"bigint"})}ConstructorParameters(x,O={}){return this.Tuple([...x.parameters],{...O})}Constructor(x,O,j){const[C,_]=[u.Rest(x),u.Type(O)];return this.Create({...j,[e.Kind]:"Constructor",type:"Constructor",parameters:C,returns:_})}Date(x={}){return this.Create({...x,[e.Kind]:"Date",type:"Date"})}Function(x,O,j){const[C,_]=[u.Rest(x),u.Type(O)];return this.Create({...j,[e.Kind]:"Function",type:"Function",parameters:C,returns:_})}InstanceType(x,O={}){return u.Type(x.returns,O)}Iterator(x,O={}){return this.Create({...O,[e.Kind]:"Iterator",type:"Iterator",items:u.Type(x)})}Parameters(x,O={}){return this.Tuple(x.parameters,{...O})}Promise(x,O={}){return this.Create({...O,[e.Kind]:"Promise",type:"Promise",item:u.Type(x)})}RegExp(x,O={}){const j=o.IsString(x)?x:x.source;return this.Create({...O,[e.Kind]:"String",type:"string",pattern:j})}RegEx(x,O={}){return this.RegExp(x,O)}ReturnType(x,O={}){return u.Type(x.returns,O)}Symbol(x){return this.Create({...x,[e.Kind]:"Symbol",type:"symbol"})}Undefined(x={}){return this.Create({...x,[e.Kind]:"Undefined",type:"undefined"})}Uint8Array(x={}){return this.Create({...x,[e.Kind]:"Uint8Array",type:"Uint8Array"})}Void(x={}){return this.Create({...x,[e.Kind]:"Void",type:"void"})}}e.JavaScriptTypeBuilder=A,e.JsonType=new K,e.Type=new A})(P);const Tve=P.Type.Object({prefix:P.Type.Optional(P.Type.String()),suffix:P.Type.Optional(P.Type.String()),volume:P.Type.Optional(P.Type.Number())}),Z9=P.Type.Object({soundOnNewLine:P.Type.Optional(P.Type.String()),soundPerLetter:P.Type.Optional(Tve)}),Ove=P.Type.Object({defaultAudio:P.Type.Optional(Z9),characterAudio:P.Type.Optional(P.Type.Record(P.Type.String(),Z9))}),Eve=P.Type.Object({src:P.Type.String(),path:P.Type.Optional(P.Type.String()),volume:P.Type.Optional(P.Type.Number()),rate:P.Type.Optional(P.Type.Number()),html5:P.Type.Optional(P.Type.Boolean()),fadeInTime:P.Type.Optional(P.Type.Number()),fadeInDelay:P.Type.Optional(P.Type.Number()),fadeOutTime:P.Type.Optional(P.Type.Number()),loop:P.Type.Optional(P.Type.Boolean())}),Ave=P.Type.Record(P.Type.String(),Eve),Pve=P.Type.Object({volume:P.Type.Optional(P.Type.Number()),defaultMusic:P.Type.Optional(P.Type.String()),musicFadeInTime:P.Type.Optional(P.Type.Number()),musicFadeOutTime:P.Type.Optional(P.Type.Number()),musicFadeInDelay:P.Type.Optional(P.Type.Number())}),Mve=P.Type.Record(P.Type.String(),P.Type.String()),eB=P.Type.Object({files:Ave,audioTriggers:Mve,options:Pve,dialogAudio:P.Type.Optional(Ove)}),tB={files:{},audioTriggers:{},options:{volume:1,musicFadeInTime:.5,musicFadeInDelay:.5,musicFadeOutTime:.5}},nB=P.Type.Object({backgrounds:P.Type.Object({width:P.Type.Number(),height:P.Type.Number()}),dialogBottomPadding:P.Type.Union([P.Type.Number(),P.Type.String()]),minTextWidth:P.Type.Optional(P.Type.Number()),verticalLayoutThreshold:P.Type.Number(),defaultFontSize:P.Type.Optional(P.Type.Number()),portraits:P.Type.Object({width:P.Type.Number(),height:P.Type.Number(),offset:P.Type.Optional(P.Type.Object({landscape:P.Type.Optional(P.Type.Object({right:P.Type.Number(),bottom:P.Type.Number()})),portrait:P.Type.Optional(P.Type.Object({right:P.Type.Number(),bottom:P.Type.Number()}))}))})}),Ive={backgrounds:{width:880,height:720},dialogBottomPadding:70,verticalLayoutThreshold:600,defaultFontSize:16,portraits:{width:100,height:100}},r0=P.Type.Object({name:P.Type.String(),description:P.Type.Optional(P.Type.String())}),Nve=P.Type.Intersect([r0,P.Type.Object({type:P.Type.Literal("number"),defaultValue:P.Type.Number(),step:P.Type.Number(),minValue:P.Type.Number(),maxValue:P.Type.Number()})]),Rve=P.Type.Intersect([r0,P.Type.Object({type:P.Type.Literal("integer"),defaultValue:P.Type.Number(),step:P.Type.Number(),minValue:P.Type.Number(),maxValue:P.Type.Number()})]),Dve=P.Type.Intersect([r0,P.Type.Object({type:P.Type.Literal("boolean"),defaultValue:P.Type.Boolean()})]),Lve=P.Type.Intersect([r0,P.Type.Object({type:P.Type.Literal("string"),defaultValue:P.Type.String()})]),Bve=P.Type.Union([Nve,Rve,Dve,Lve]);function Fve(e){return e.type==="number"}function rB(e){return e.type==="integer"}function Vve(e){return e.type==="boolean"}function zve(e){return e.type==="string"}const oB=P.Type.Object({customSettings:P.Type.Optional(P.Type.Record(P.Type.String(),Bve))}),o0="###_--_~=:;_JUMP",yx="###_--_~=:;_RETURN",qve="###_--_~=:;_OK",i0="###_--_~=:;_STOP";function Uve(e){return e===o0||e===yx||e===qve||e===i0}const Hve="3.9.5",Wve=new Date("2024-01-29T20:23:34.278Z"),Kve=400,a0=20,bx="@empty",iB={background:bx},Gve=P.Type.Optional(P.Type.Object({debugMenu:P.Type.Optional(P.Type.String()),jumpMenu:P.Type.Optional(P.Type.String())})),aB=P.Type.Optional(P.Type.Object({animateText:P.Type.Optional(P.Type.Boolean()),textSpeed:P.Type.Optional(P.Type.Number()),timeBetweenLines:P.Type.Optional(P.Type.Number()),overlayMode:P.Type.Optional(P.Type.Boolean()),rightOffset:P.Type.Optional(P.Type.Number()),bottomOffset:P.Type.Optional(P.Type.Number()),width:P.Type.Optional(P.Type.Number()),height:P.Type.Optional(P.Type.Number()),hideDuringTransition:P.Type.Optional(P.Type.Boolean()),showAfterScriptEnd:P.Type.Optional(P.Type.Boolean())})),sB=P.Type.Object({engineSplashScreen:P.Type.Optional(P.Type.Object({skip:P.Type.Optional(P.Type.Boolean()),fadeDuration:P.Type.Optional(P.Type.Number()),timeBeforeFadeout:P.Type.Optional(P.Type.Number()),overrideText:P.Type.Optional(P.Type.String()),overrideLogo:P.Type.Optional(P.Type.String())})),gameSplashScreen:P.Type.Optional(P.Type.Object({startButtonText:P.Type.Optional(P.Type.String())}))}),cB=P.Type.Object({timeOnScreen:P.Type.Number(),alsoPrintInDialogue:P.Type.Optional(P.Type.Boolean())}),Jve=P.Type.Object({name:P.Type.String(),icon:P.Type.String(),startingValue:P.Type.Number(),maxValue:P.Type.Optional(P.Type.Number()),minValue:P.Type.Optional(P.Type.Number()),decimals:P.Type.Optional(P.Type.Number()),prefix:P.Type.Optional(P.Type.String()),suffix:P.Type.Optional(P.Type.String()),hideName:P.Type.Optional(P.Type.Boolean()),formatting:P.Type.Optional(P.Type.Object({style:P.Type.Union([P.Type.Literal("decimal"),P.Type.Literal("currency"),P.Type.Literal("percent"),P.Type.Literal("unit")]),currency:P.Type.Optional(P.Type.String()),unit:P.Type.Optional(P.Type.String())}))}),lB=P.Type.Record(P.Type.String(),Jve),uB=P.Type.Record(P.Type.String(),P.Type.Object({onlyInteractOutsideOfScripts:P.Type.Optional(P.Type.Boolean())})),Qve=P.Type.Object({delay:P.Type.Optional(P.Type.Number()),duration:P.Type.Optional(P.Type.Number())}),fB=P.Type.Record(P.Type.String(),Qve),Yve=P.Type.Object({text:P.Type.String(),cssClass:P.Type.Optional(P.Type.String())}),dB=P.Type.Record(P.Type.String(),Yve),hB=P.Type.Object({showScriptFinishedMessage:P.Type.Optional(P.Type.Boolean())}),pB=P.Type.Object({mode:P.Type.String(),slots:P.Type.Number(),runOnReload:P.Type.Optional(P.Type.String()),disabled:P.Type.Optional(P.Type.Boolean())}),mB=P.Type.Array(P.Type.String()),Xve=[],vB=P.Type.Object({baseAssetsPath:P.Type.Optional(P.Type.String()),baseDataPath:P.Type.Optional(P.Type.String()),gameTitle:P.Type.String(),saveFileName:P.Type.String(),images:P.Type.Optional(P.Type.Record(P.Type.String(),P.Type.String())),layout:nB,settings:P.Type.Optional(oB),gameFlow:P.Type.Optional(P.Type.Object({labelToJumpOnScriptEnd:P.Type.Optional(P.Type.String())})),dialogPanel:P.Type.Optional(aB),splashScreens:P.Type.Optional(sB),notifications:P.Type.Optional(cB),hudStats:lB,interactionTags:P.Type.Optional(uB),transitions:P.Type.Optional(fB),menuButtons:P.Type.Optional(dB),debugging:P.Type.Optional(hB),saves:P.Type.Optional(pB),hotkeys:Gve}),wx={baseAssetsPath:"",baseDataPath:"",gameTitle:"Narrat Game",saveFileName:"narrat save",images:{},layout:Ive,settings:{},gameFlow:{},dialogPanel:{overlayMode:!0,rightOffset:100,bottomOffset:50,width:475,height:680,textSpeed:a0,animateText:!0,timeBetweenLines:100,hideDuringTransition:!1,showAfterScriptEnd:!1},splashScreens:{},notifications:{timeOnScreen:2.5,alsoPrintInDialogue:!1},hudStats:{},interactionTags:{default:{onlyInteractOutsideOfScripts:!0}},transitions:{},menuButtons:{},debugging:{showScriptFinishedMessage:!1},saves:{mode:"manual",slots:10},hotkeys:{}},Zve=P.Type.Object({name:P.Type.String(),description:P.Type.String(),icon:P.Type.String(),onUse:P.Type.Optional(P.Type.Object({action:P.Type.String(),label:P.Type.String()})),tag:P.Type.Optional(P.Type.String()),category:P.Type.Optional(P.Type.String()),showIfEmpty:P.Type.Optional(P.Type.Boolean())}),gB=P.Type.Object({id:P.Type.String(),title:P.Type.String()}),yB=P.Type.Record(P.Type.String(),Zve);P.Type.Object({categories:P.Type.Array(gB),items:yB});const bB=P.Type.Object({categories:P.Type.Optional(P.Type.Array(gB)),items:P.Type.Optional(yB)}),wB={categories:[{id:"default",title:"Items"}],items:{}},ege=P.Type.Object({description:P.Type.String(),succeededDescription:P.Type.Optional(P.Type.String()),failedDescription:P.Type.Optional(P.Type.String()),hidden:P.Type.Optional(P.Type.Boolean())}),tge=P.Type.Object({title:P.Type.String(),description:P.Type.String(),succeededDescription:P.Type.Optional(P.Type.String()),failedDescription:P.Type.Optional(P.Type.String()),endings:P.Type.Optional(P.Type.Record(P.Type.String(),P.Type.Object({success:P.Type.Boolean(),description:P.Type.String()}))),objectives:P.Type.Record(P.Type.String(),ege),category:P.Type.Optional(P.Type.String())}),nge=P.Type.Object({id:P.Type.String(),title:P.Type.String()}),rge=P.Type.Record(P.Type.String(),tge),kB=P.Type.Object({quests:rge,categories:P.Type.Array(nge)}),xB={quests:{},categories:[{id:"default",title:"Quests"}]},_B=P.Type.Object({enabled:P.Type.Boolean(),background:P.Type.Optional(P.Type.String()),text:P.Type.Optional(P.Type.String()),cssClass:P.Type.Optional(P.Type.String()),position:P.Type.Object({left:P.Type.Number(),top:P.Type.Number(),width:P.Type.Optional(P.Type.Number()),height:P.Type.Optional(P.Type.Number())}),anchor:P.Type.Optional(P.Type.Object({x:P.Type.Number(),y:P.Type.Number()})),action:P.Type.Optional(P.Type.String()),actionType:P.Type.Optional(P.Type.String()),scriptClickable:P.Type.Optional(P.Type.Boolean()),tag:P.Type.Optional(P.Type.String())}),oge=P.Type.Record(P.Type.String(),_B),SB=P.Type.Object({buttons:oge,clickableDuringScriptsByDefault:P.Type.Optional(P.Type.Boolean())}),jB={buttons:{},clickableDuringScriptsByDefault:!1},ige=P.Type.Intersect([_B,P.Type.Object({id:P.Type.String()})]),age=P.Type.Object({muted:P.Type.Optional(P.Type.Boolean()),loop:P.Type.Optional(P.Type.Boolean())}),sge=P.Type.Object({background:P.Type.String(),video:P.Type.Optional(age),buttons:P.Type.Optional(P.Type.Array(P.Type.Union([P.Type.String(),ige])))}),CB=P.Type.Record(P.Type.String(),sge);P.Type.Object({screens:CB});const $B=P.Type.Object({screens:P.Type.Optional(CB)}),TB={screens:{}},cge=P.Type.Object({name:P.Type.String(),description:P.Type.String(),startingLevel:P.Type.Number(),hidden:P.Type.Optional(P.Type.Boolean()),icon:P.Type.String()}),OB=P.Type.Record(P.Type.String(),cge),EB=P.Type.Object({xpPerLevel:P.Type.Number(),notifyLevelUp:P.Type.Boolean()});P.Type.Object({skills:OB,skillOptions:EB});const AB=P.Type.Object({skills:P.Type.Optional(OB),skillOptions:P.Type.Optional(EB)}),PB={skills:{},skillOptions:{xpPerLevel:10,notifyLevelUp:!0}},lge=P.Type.Object({portraitCssClass:P.Type.Optional(P.Type.String()),color:P.Type.Optional(P.Type.String()),boxCss:P.Type.Optional(P.Type.Record(P.Type.String(),P.Type.Any())),nameCss:P.Type.Optional(P.Type.Record(P.Type.String(),P.Type.Any())),textCss:P.Type.Optional(P.Type.Record(P.Type.String(),P.Type.Any()))}),uge=P.Type.Object({video:P.Type.String(),autoplay:P.Type.Optional(P.Type.Boolean()),loop:P.Type.Optional(P.Type.Boolean()),muted:P.Type.Optional(P.Type.Boolean()),width:P.Type.Optional(P.Type.Number()),height:P.Type.Optional(P.Type.Number())}),fge=P.Type.Object({image:P.Type.String(),width:P.Type.Optional(P.Type.Number()),height:P.Type.Optional(P.Type.Number())}),dge=P.Type.Union([P.Type.String(),uge,fge]),hge=P.Type.Object({sprites:P.Type.Optional(P.Type.Record(P.Type.String(),dge)),name:P.Type.String(),style:P.Type.Optional(lge)}),MB=P.Type.Object({config:P.Type.Object({imagesPath:P.Type.String(),playerCharacter:P.Type.Optional(P.Type.String()),gameCharacter:P.Type.Optional(P.Type.String())}),characters:P.Type.Record(P.Type.String(),hge)}),IB={config:{imagesPath:"",playerCharacter:"player",gameCharacter:"game"},characters:{}},NB=P.Type.Object({cssClass:P.Type.Optional(P.Type.String()),textCssClass:P.Type.Optional(P.Type.String()),titleCssClass:P.Type.Optional(P.Type.String())}),RB=P.Type.Object({options:P.Type.Object({delay:P.Type.Optional(P.Type.Number()),width:P.Type.Number(),keywordsPrefix:P.Type.String(),screenEdgesMinimumMargin:P.Type.Optional(P.Type.Number()),styling:P.Type.Optional(NB)}),tooltips:P.Type.Array(P.Type.Object({keywords:P.Type.Array(P.Type.String()),title:P.Type.String(),description:P.Type.String(),styling:P.Type.Optional(NB)}))}),DB={options:{delay:0,width:350,keywordsPrefix:"@@"},tooltips:[]},pge=P.Type.Object({name:P.Type.String(),description:P.Type.String(),icon:P.Type.Optional(P.Type.String()),lockedIcon:P.Type.Optional(P.Type.String()),secret:P.Type.Optional(P.Type.Boolean()),category:P.Type.Optional(P.Type.String())}),LB=P.Type.Object({id:P.Type.String(),title:P.Type.String()}),BB=P.Type.Record(P.Type.String(),pge);P.Type.Object({defaultAchievementIcon:P.Type.String(),categories:P.Type.Array(LB),achievements:BB,notifyNewAchievements:P.Type.Boolean(),secretAchievements:P.Type.Optional(P.Type.Object({censorDescription:P.Type.Optional(P.Type.Boolean()),censorName:P.Type.Optional(P.Type.Boolean()),hideUntilObtained:P.Type.Optional(P.Type.Boolean())}))});const FB=P.Type.Object({categories:P.Type.Optional(P.Type.Array(LB)),achievements:P.Type.Optional(BB)}),VB={categories:[{id:"default",title:"Achievements"}],achievements:{},notifyNewAchievements:!0,defaultAchievementIcon:"img/achievements/trophy.png"},mge=P.Type.Object({diceRange:P.Type.Tuple([P.Type.Number(),P.Type.Number()]),diceCount:P.Type.Number(),difficultyText:P.Type.Array(P.Type.Tuple([P.Type.Number(),P.Type.String()])),extraPointsPerLevel:P.Type.Number(),extraDicePerLevel:P.Type.Optional(P.Type.Number()),successOnRollsBelowThreshold:P.Type.Boolean(),showDifficultyText:P.Type.Boolean(),showDifficultyNumber:P.Type.Boolean(),showDifficultyWithoutModifiers:P.Type.Boolean(),finalRollIsHighest:P.Type.Optional(P.Type.Boolean()),finalRollIsLowest:P.Type.Optional(P.Type.Boolean()),failOnRollsEqualToThreshold:P.Type.Optional(P.Type.Boolean())}),vge=P.Type.Object({skill:P.Type.String(),difficulty:P.Type.Number(),winsNeeded:P.Type.Optional(P.Type.Number()),hideAfterRoll:P.Type.Optional(P.Type.Boolean()),repeatable:P.Type.Optional(P.Type.Boolean())}),zB=P.Type.Object({options:mge,skillChecks:P.Type.Record(P.Type.String(),vge)}),qB={options:{diceRange:[1,6],extraPointsPerLevel:1,extraDicePerLevel:0,diceCount:2,successOnRollsBelowThreshold:!1,showDifficultyText:!0,showDifficultyNumber:!1,showDifficultyWithoutModifiers:!1,finalRollIsHighest:!1,finalRollIsLowest:!1,difficultyText:[[2,"Very Easy"],[4,"Easy"],[6,"Medium"],[8,"Hard"],[10,"Very Hard"],[11,"Extremely Hard"],[12,"Near Impossible"]]},skillChecks:{}},gge=P.Type.Object({cssClass:P.Type.Optional(P.Type.String()),textTemplate:P.Type.Optional(P.Type.String())}),UB=P.Type.Record(P.Type.String(),gge);P.Type.Object({choiceTextTemplate:P.Type.String(),choicePrompts:UB});const HB=P.Type.Object({choiceTextTemplate:P.Type.Optional(P.Type.String()),choicePrompts:P.Type.Optional(UB)}),WB={choicePrompts:{},choiceTextTemplate:'<span class="choice-index">%{$index}. </span> <span class="choice-text">%{$choice}</span>'},KB=P.Type.Object({delay:P.Type.Optional(P.Type.Number()),direction:P.Type.Optional(P.Type.String()),duration:P.Type.Optional(P.Type.Number()),easing:P.Type.Optional(P.Type.String()),endDelay:P.Type.Optional(P.Type.Number()),fill:P.Type.Optional(P.Type.String()),iterationStart:P.Type.Optional(P.Type.Number()),iterations:P.Type.Optional(P.Type.Number()),keyframes:P.Type.Optional(P.Type.Any())}),kx=P.Type.Array(P.Type.Any()),yge=P.Type.Object({keyframes:P.Type.Union([P.Type.String(),kx]),options:P.Type.Optional(KB)});P.Type.Object({keyframes:kx,options:P.Type.Optional(KB)});const GB=P.Type.Object({animations:P.Type.Record(P.Type.String(),yge),keyframes:P.Type.Record(P.Type.String(),kx)}),JB={animations:{},keyframes:{}},bge=P.Type.Object({name:P.Type.String(),type:P.Type.String(),optional:P.Type.Optional(P.Type.Boolean())}),wge=P.Type.Object({keyword:P.Type.String(),label:P.Type.String(),options:P.Type.Optional(P.Type.Array(bge))}),QB=P.Type.Object({macros:P.Type.Array(wge)}),YB={macros:[]},xx=P.Type.Object({assets:P.Type.Record(P.Type.String(),P.Type.String())}),XB=P.Type.Object({images:P.Type.Optional(xx),audio:P.Type.Optional(xx),video:P.Type.Optional(xx)}),ZB={images:{assets:{}},audio:{assets:{}},video:{assets:{}}},Kf={common:wx,screens:TB,buttons:jB,skills:PB,skillChecks:qB,scripts:[],audio:tB,tooltips:DB,achievements:VB,items:wB,quests:xB,characters:IB,choices:WB,animations:JB,macros:YB,preload:ZB};var kge=function(t){return xge(t)&&!_ge(t)};function xge(e){return!!e&&typeof e=="object"}function _ge(e){var t=Object.prototype.toString.call(e);return t==="[object RegExp]"||t==="[object Date]"||Cge(e)}var Sge=typeof Symbol=="function"&&Symbol.for,jge=Sge?Symbol.for("react.element"):60103;function Cge(e){return e.$$typeof===jge}function $ge(e){return Array.isArray(e)?[]:{}}function op(e,t){return t.clone!==!1&&t.isMergeableObject(e)?Gf($ge(e),e,t):e}function Tge(e,t,n){return e.concat(t).map(function(r){return op(r,n)})}function Oge(e,t){if(!t.customMerge)return Gf;var n=t.customMerge(e);return typeof n=="function"?n:Gf}function Ege(e){return Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(e).filter(function(t){return Object.propertyIsEnumerable.call(e,t)}):[]}function eF(e){return Object.keys(e).concat(Ege(e))}function tF(e,t){try{return t in e}catch{return!1}}function Age(e,t){return tF(e,t)&&!(Object.hasOwnProperty.call(e,t)&&Object.propertyIsEnumerable.call(e,t))}function Pge(e,t,n){var r={};return n.isMergeableObject(e)&&eF(e).forEach(function(o){r[o]=op(e[o],n)}),eF(t).forEach(function(o){Age(e,o)||(tF(e,o)&&n.isMergeableObject(t[o])?r[o]=Oge(o,n)(e[o],t[o],n):r[o]=op(t[o],n))}),r}function Gf(e,t,n){n=n||{},n.arrayMerge=n.arrayMerge||Tge,n.isMergeableObject=n.isMergeableObject||kge,n.cloneUnlessOtherwiseSpecified=op;var r=Array.isArray(t),o=Array.isArray(e),i=r===o;return i?r?n.arrayMerge(e,t,n):Pge(e,t,n):op(t,n)}Gf.all=function(t,n){if(!Array.isArray(t))throw new Error("first argument should be an array");return t.reduce(function(r,o){return Gf(r,o,n)},{})};var Mge=Gf,Ige=Mge;const fu=ey(Ige),fo=eo("config",{state:()=>({config:Kf,configModules:{}}),actions:{async setConfig(e){this.config=e},extendConfig(e){this.config=fu(this.config,e)},generateSaveData(){return{playerCharacter:this.playerCharacter,gameCharacter:this.gameCharacter}},addConfigModule(e,t){this.configModules[e]=t},findConfigModuleKey(e){const t=Object.keys(this.configModules).find(n=>this.configModules[n].id===e.id);if(t)return t},reloadConfigModule(e,t){this.configModules[e].code=t,this.config[e]=t},loadSaveData(e){this.config.characters.config.playerCharacter=e.playerCharacter,this.config.characters.config.gameCharacter=e.gameCharacter}},getters:{playerCharacter(){return this.config.characters.config.playerCharacter??"player"},gameCharacter(){return this.config.characters.config.gameCharacter??"game"}}});function nF(e){const t=Jr(),n=t.getSkillCheck(e.id);if(n&&n.happened&&(n.succeeded||!e.repeatable))return n;const r=$ve(e);return iF(_ve(r,e)),r?t.passSkillCheck(e.id,e.hideAfterRoll):t.failSkillCheck(e.id,e.hideAfterRoll),t.getSkillCheck(e.id)}function Nge(e,t=[]){const n=e.options,r=e.staticOptions,o=!!n.condition;if(o)return r.success;if(!o){for(const[i,a]of r.elseifs.entries())if(t[i]===!0)return a.branch}if(!o&&r.failure)return r.failure}function rF(e){return typeof e=="object"}function oF(e){return typeof e=="string"&&e.search(/\$/)===0}function iF(e){const t={speaker:fo().gameCharacter,text:e,interactive:!1};cr().addDialog(t)}async function _x(e){cr().addDialog(e)}function Rge(e,t){if(t<e.length)return e[t]}/*! js-yaml 4.1.0 https://github.com/nodeca/js-yaml @license MIT */function aF(e){return typeof e>"u"||e===null}function Dge(e){return typeof e=="object"&&e!==null}function Lge(e){return Array.isArray(e)?e:aF(e)?[]:[e]}function Bge(e,t){var n,r,o,i;if(t)for(i=Object.keys(t),n=0,r=i.length;n<r;n+=1)o=i[n],e[o]=t[o];return e}function Fge(e,t){var n="",r;for(r=0;r<t;r+=1)n+=e;return n}function Vge(e){return e===0&&Number.NEGATIVE_INFINITY===1/e}var zge=aF,qge=Dge,Uge=Lge,Hge=Fge,Wge=Vge,Kge=Bge,ho={isNothing:zge,isObject:qge,toArray:Uge,repeat:Hge,isNegativeZero:Wge,extend:Kge};function sF(e,t){var n="",r=e.reason||"(unknown reason)";return e.mark?(e.mark.name&&(n+='in "'+e.mark.name+'" '),n+="("+(e.mark.line+1)+":"+(e.mark.column+1)+")",!t&&e.mark.snippet&&(n+=`
175
175
 
176
176
  `+e.mark.snippet),r+" "+n):r}function ip(e,t){Error.call(this),this.name="YAMLException",this.reason=e,this.mark=t,this.message=sF(this,!1),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack||""}ip.prototype=Object.create(Error.prototype),ip.prototype.constructor=ip,ip.prototype.toString=function(t){return this.name+": "+sF(this,t)};var ai=ip;function Sx(e,t,n,r,o){var i="",a="",s=Math.floor(o/2)-1;return r-t>s&&(i=" ... ",t=r-s+i.length),n-r>s&&(a=" ...",n=r+s-a.length),{str:i+e.slice(t,n).replace(/\t/g,"→")+a,pos:r-t+i.length}}function jx(e,t){return ho.repeat(" ",t-e.length)+e}function Gge(e,t){if(t=Object.create(t||null),!e.buffer)return null;t.maxLength||(t.maxLength=79),typeof t.indent!="number"&&(t.indent=1),typeof t.linesBefore!="number"&&(t.linesBefore=3),typeof t.linesAfter!="number"&&(t.linesAfter=2);for(var n=/\r?\n|\r|\0/g,r=[0],o=[],i,a=-1;i=n.exec(e.buffer);)o.push(i.index),r.push(i.index+i[0].length),e.position<=i.index&&a<0&&(a=r.length-2);a<0&&(a=r.length-1);var s="",c,l,f=Math.min(e.line+t.linesAfter,o.length).toString().length,u=t.maxLength-(t.indent+f+3);for(c=1;c<=t.linesBefore&&!(a-c<0);c++)l=Sx(e.buffer,r[a-c],o[a-c],e.position-(r[a]-r[a-c]),u),s=ho.repeat(" ",t.indent)+jx((e.line-c+1).toString(),f)+" | "+l.str+`
177
177
  `+s;for(l=Sx(e.buffer,r[a],o[a],e.position,u),s+=ho.repeat(" ",t.indent)+jx((e.line+1).toString(),f)+" | "+l.str+`
@@ -202,7 +202,7 @@ This will fail in production.`);s=ep,s._s.has(r)||(i?hx(r,t,o,s):H9(r,o,s),proce
202
202
  `+e.slice(o,i),o=i+1),a=s;return c+=`
203
203
  `,e.length-o>t&&a>o?c+=e.slice(o,a)+`
204
204
  `+e.slice(a+1):c+=e.slice(o),c.slice(1)}function Iye(e){for(var t="",n=0,r,o=0;o<e.length;n>=65536?o+=2:o++)n=lp(e,o),r=Go[n],!r&&cp(n)?(t+=e[o],n>=65536&&(t+=e[o+1])):t+=r||jye(n);return t}function Nye(e,t,n){var r="",o=e.tag,i,a,s;for(i=0,a=n.length;i<a;i+=1)s=n[i],e.replacer&&(s=e.replacer.call(n,String(i),s)),(fc(e,t,s,!1,!1)||typeof s>"u"&&fc(e,t,null,!1,!1))&&(r!==""&&(r+=","+(e.condenseFlow?"":" ")),r+=e.dump);e.tag=o,e.dump="["+r+"]"}function aV(e,t,n,r){var o="",i=e.tag,a,s,c;for(a=0,s=n.length;a<s;a+=1)c=n[a],e.replacer&&(c=e.replacer.call(n,String(a),c)),(fc(e,t+1,c,!0,!0,!1,!0)||typeof c>"u"&&fc(e,t+1,null,!0,!0,!1,!0))&&((!r||o!=="")&&(o+=Ix(e,t)),e.dump&&ap===e.dump.charCodeAt(0)?o+="-":o+="- ",o+=e.dump);e.tag=i,e.dump=o||"[]"}function Rye(e,t,n){var r="",o=e.tag,i=Object.keys(n),a,s,c,l,f;for(a=0,s=i.length;a<s;a+=1)f="",r!==""&&(f+=", "),e.condenseFlow&&(f+='"'),c=i[a],l=n[c],e.replacer&&(l=e.replacer.call(n,c,l)),fc(e,t,c,!1,!1)&&(e.dump.length>1024&&(f+="? "),f+=e.dump+(e.condenseFlow?'"':"")+":"+(e.condenseFlow?"":" "),fc(e,t,l,!1,!1)&&(f+=e.dump,r+=f));e.tag=o,e.dump="{"+r+"}"}function Dye(e,t,n,r){var o="",i=e.tag,a=Object.keys(n),s,c,l,f,u,d;if(e.sortKeys===!0)a.sort();else if(typeof e.sortKeys=="function")a.sort(e.sortKeys);else if(e.sortKeys)throw new ai("sortKeys must be a boolean or a function");for(s=0,c=a.length;s<c;s+=1)d="",(!r||o!=="")&&(d+=Ix(e,t)),l=a[s],f=n[l],e.replacer&&(f=e.replacer.call(n,l,f)),fc(e,t+1,l,!0,!0,!0)&&(u=e.tag!==null&&e.tag!=="?"||e.dump&&e.dump.length>1024,u&&(e.dump&&ap===e.dump.charCodeAt(0)?d+="?":d+="? "),d+=e.dump,u&&(d+=Ix(e,t)),fc(e,t+1,f,!0,u)&&(e.dump&&ap===e.dump.charCodeAt(0)?d+=":":d+=": ",d+=e.dump,o+=d));e.tag=i,e.dump=o||"{}"}function sV(e,t,n){var r,o,i,a,s,c;for(o=n?e.explicitTypes:e.implicitTypes,i=0,a=o.length;i<a;i+=1)if(s=o[i],(s.instanceOf||s.predicate)&&(!s.instanceOf||typeof t=="object"&&t instanceof s.instanceOf)&&(!s.predicate||s.predicate(t))){if(n?s.multi&&s.representName?e.tag=s.representName(t):e.tag=s.tag:e.tag="?",s.represent){if(c=e.styleMap[s.tag]||s.defaultStyle,qF.call(s.represent)==="[object Function]")r=s.represent(t,c);else if(UF.call(s.represent,c))r=s.represent[c](t,c);else throw new ai("!<"+s.tag+'> tag resolver accepts not "'+c+'" style');e.dump=r}return!0}return!1}function fc(e,t,n,r,o,i,a){e.tag=null,e.dump=n,sV(e,n,!1)||sV(e,n,!0);var s=qF.call(e.dump),c=r,l;r&&(r=e.flowLevel<0||e.flowLevel>t);var f=s==="[object Object]"||s==="[object Array]",u,d;if(f&&(u=e.duplicates.indexOf(n),d=u!==-1),(e.tag!==null&&e.tag!=="?"||d||e.indent!==2&&t>0)&&(o=!1),d&&e.usedDuplicates[u])e.dump="*ref_"+u;else{if(f&&d&&!e.usedDuplicates[u]&&(e.usedDuplicates[u]=!0),s==="[object Object]")r&&Object.keys(e.dump).length!==0?(Dye(e,t,e.dump,o),d&&(e.dump="&ref_"+u+e.dump)):(Rye(e,t,e.dump),d&&(e.dump="&ref_"+u+" "+e.dump));else if(s==="[object Array]")r&&e.dump.length!==0?(e.noArrayIndent&&!a&&t>0?aV(e,t-1,e.dump,o):aV(e,t,e.dump,o),d&&(e.dump="&ref_"+u+e.dump)):(Nye(e,t,e.dump),d&&(e.dump="&ref_"+u+" "+e.dump));else if(s==="[object String]")e.tag!=="?"&&Pye(e,e.dump,t,i,c);else{if(s==="[object Undefined]")return!1;if(e.skipInvalid)return!1;throw new ai("unacceptable kind of an object to dump "+s)}e.tag!==null&&e.tag!=="?"&&(l=encodeURI(e.tag[0]==="!"?e.tag.slice(1):e.tag).replace(/!/g,"%21"),e.tag[0]==="!"?l="!"+l:l.slice(0,18)==="tag:yaml.org,2002:"?l="!!"+l.slice(18):l="!<"+l+">",e.dump=l+" "+e.dump)}return!0}function Lye(e,t){var n=[],r=[],o,i;for(Rx(e,n,r),o=0,i=r.length;o<i;o+=1)t.duplicates.push(n[r[o]]);t.usedDuplicates=new Array(i)}function Rx(e,t,n){var r,o,i;if(e!==null&&typeof e=="object")if(o=t.indexOf(e),o!==-1)n.indexOf(o)===-1&&n.push(o);else if(t.push(e),Array.isArray(e))for(o=0,i=e.length;o<i;o+=1)Rx(e[o],t,n);else for(r=Object.keys(e),o=0,i=r.length;o<i;o+=1)Rx(e[r[o]],t,n)}function Bye(e,t){t=t||{};var n=new $ye(t);n.noRefs||Lye(e,n);var r=e;return n.replacer&&(r=n.replacer.call({"":r},"",r)),fc(n,0,r,!0,!0)?n.dump+`
205
- `:""}var Fye=Bye,Vye={dump:Fye};function Dx(e,t){return function(){throw new Error("Function yaml."+e+" is removed in js-yaml 4. Use yaml."+t+" instead, which is now safe by default.")}}var zye=Mo,qye=lF,Uye=hF,Hye=yF,Wye=bF,Kye=Tx,Gye=zF.load,Jye=zF.loadAll,Qye=Vye.dump,Yye=ai,Xye={binary:SF,float:gF,map:dF,null:pF,pairs:CF,set:$F,timestamp:xF,bool:mF,int:vF,merge:_F,omap:jF,seq:fF,str:uF},Zye=Dx("safeLoad","load"),e1e=Dx("safeLoadAll","loadAll"),t1e=Dx("safeDump","dump"),n1e={Type:zye,Schema:qye,FAILSAFE_SCHEMA:Uye,JSON_SCHEMA:Hye,CORE_SCHEMA:Wye,DEFAULT_SCHEMA:Kye,load:Gye,loadAll:Jye,dump:Qye,YAMLException:Yye,types:Xye,safeLoad:Zye,safeLoadAll:e1e,safeDump:t1e};function h0(e){return new Promise((t,n)=>{const r=new XMLHttpRequest;r.onload=function(){r.status>=200&&r.status<300?t(r.responseText):(St(`Failed to load file ${e}`,r.status),n(r.status))},r.open("GET",e),r.send()})}async function up(e){try{const t=await h0(e);let n;if(e.endsWith(".json"))n=JSON.parse(t);else if(e.endsWith(".yaml"))n=n1e.load(t);else{const r=`Unsupported file type for data file ${e} (must be .json or .yaml)`;throw new Error(r)}if(!n)throw new Error(`Data loaded from ${e} is empty`);return n}catch(t){throw console.error(`Failed to load data file ${e}: ${t}`),t}}const r1e=(e,t)=>{const n={};for(const r in e)n[r]=t(e[r]);return n},cV=(e,t)=>{for(const n in e){const r=e[n];t(r,n,e),typeof r=="object"&&r!==null&&cV(r,t)}},ed={};async function o1e(e){return ed[e]?ed[e]:lV(e,e)}async function i1e(e){qi.log("Loading images");const t=[],n=async(o,i)=>await lV(o,i),r=(o,i)=>{t.push(n(o,i))};for(const o in e.common.images){const i=e.common.images[o];r(o,i)}if(e.preload.images)for(const o in e.preload.images.assets){const i=e.preload.images.assets[o];r(o,i)}for(const o in e.screens.screens){const i=e.screens.screens[o];if(i.background&&!e.common.images[i.background]&&!i.video&&r(i.background,i.background),i.buttons)for(const a in i.buttons){const s=i.buttons[a];typeof s=="object"&&s.background&&!e.common.images[s.background]&&r(s.background,s.background)}}return Promise.all(t)}async function lV(e,t){if(ed[e])return ed[e];const n=new Promise((r,o)=>{const i=new Image;i.onload=()=>{ed[e]=i,r(i)},i.onerror=a=>{St(`Failed to load image ${e} at ${t}`,a),o(a)},i.src=ci(t)});return ed[e]=n,n}const p0={};function a1e(e){return p0[e]??{}}function uV(e,t,n){const r=a1e(e.transition),o=e.duration??r.duration??500,i=e.delay??r.delay??0;return{...e,resolve:n,duration:o,delay:i,oldScreen:t}}const Jo=eo("notifications",{state:()=>({notifications:[],enabled:!0}),actions:{async addNotification(e,t,n){if(!this.enabled)return;e=$s(e);const r=`${Date.now()}-${Math.random()*1e4}`;this.notifications.push({id:r,text:e,description:t,icon:n}),Ct().notifications.alsoPrintInDialogue&&iF(`[NOTIFICATION] ${e}`),await ki(Ct().notifications.timeOnScreen*1e3),this.deleteNotification(r)},deleteNotification(e){const t=this.findNotifications(e);t&&this.notifications.splice(this.notifications.indexOf(t),1)},findNotifications(e){return this.notifications.find(t=>t.id===e)},disableNotifications(){this.enabled=!1;for(const e in this.notifications)this.deleteNotification(e)},enableNotifications(){this.enabled=!0}}}),Io=eo("inventory",{state:()=>({items:{},interactionTags:{}}),actions:{generateSaveData(){return{items:Xn(this.items),interactionTags:Xn(this.interactionTags)}},loadSaveData(e){this.items={...this.items,...e.items},this.interactionTags={...e.interactionTags}},updateConfig(e){Object.keys(e.items).forEach(t=>{this.items[t]||(this.items[t]={amount:0,id:t})})},reset(e){this.$reset(),this.updateConfig(e)},hasItem(e,t){var n;return t||(t=1),((n=this.items[e])==null?void 0:n.amount)>=t},getExistingItem(e){return this.items[e]},getItemAmount(e){var t;return((t=this.getExistingItem(e))==null?void 0:t.amount)||0},add(e){const t=this.getExistingItem(e.id);t?t.amount+=e.amount:this.items[e.id]={...e};const n=Ja(e.id).name,r=e.amount>1?`${n} x ${e.amount}`:n;Jo().addNotification(`Received item: ${r}`)},enableInteraction(e){e||(e="default"),this.interactionTags[e]={blockedInteraction:!1}},disableInteraction(e){e||(e="default"),this.interactionTags[e]={blockedInteraction:!0}},onScriptStart(){const e=Ct().interactionTags;Object.keys(e).forEach(t=>{e[t].onlyInteractOutsideOfScripts&&this.disableInteraction(t)})},onScriptEnd(){const e=Ct().interactionTags;Object.keys(e).forEach(t=>{e[t].onlyInteractOutsideOfScripts&&this.enableInteraction(t)})},isInteractionTagBlocked(e){return e||(e="default"),this.interactionTags[e]?this.interactionTags[e].blockedInteraction:!1},remove(e){const t=this.getExistingItem(e.id);t&&(t.amount-=e.amount,Jo().addNotification(`Lost item: ${Ja(e.id).name} x ${e.amount}`),t.amount<=0&&this.deleteItem(e.id))},deleteItem(e){this.getExistingItem(e)&&(this.items[e].amount=0)},canUseItem(e){var n;const t=Ja(e.id);return!!(t&&t.onUse&&!this.isInteractionTagBlocked(t.tag)&&!((n=cr().currentDialog)!=null&&n.choices))},useItem(e){const t=Ja(e.id);if(e&&this.canUseItem(e)&&t){const n=t.onUse;close(),uu("onItemUsed"),n.action==="jump"?un().jumpToLabel(n.label):n.action==="run"?un().runThenGoBackToPreviousDialog(n.label,!0):St(`Unknown action ${n.action}`)}}}}),da=eo("screens",{state:()=>({layers:[{screen:"default"}],buttons:{}}),actions:{setScreen(e,t,n){return new Promise(r=>{const o=this.layers[t||0];let i;const a=(o==null?void 0:o.screen)??null;if(a===e){r();return}n&&(i=uV(n,a,r)),this.layers[t||0]={screen:e,transition:i},i||r()})},finishTransition(e){const t=this.layers[e];if(!t)St(`Tried to finish transition on layer ${e} but it doesn't exist`);else if(t.transition){const n=t.transition.resolve;delete t.transition,n()}},transitionScreen(e,t,n){return this.setScreen(e,n??0,t)},emptyLayer(e,t){return new Promise(n=>{const r=this.layers[e];if(!r){hu(`Tried to empty layer ${e} but it doesn't exist`);return}if(t){const o=r.screen,i=uV(t,o,n);r.transition=i}r.screen="@empty",t||n()})},updateConfig(e){console.log("update config!");const t=pr().buttons.buttons;for(const n in t)this.buttons[n]||(this.buttons[n]={state:t[n].enabled})},reset(e){this.$reset(),this.updateConfig(e)},changeButton(e,t){if(!this.buttons[e]){St(`Tried to change button ${e} but it doesn't exist`);return}this.buttons[e].state=t},generateSaveData(){return{layers:Xn(this.layers).filter(e=>e).map(e=>e.screen??null),buttons:Xn(this.buttons)}},loadSaveData(e){this.layers=e.layers.map(t=>(t!==null&&typeof t!="string"&&(t=null),{screen:t})),this.buttons=fu(this.buttons,e.buttons)},isButtonDisabled(e){const t=this.getButtonState(e);return t==="hidden"||t==="greyed"||t===!1},isButtonInteractible(e){const t=this.getButtonState(e);return t?t===!0:!1},isButtonClickable(e){if(!this.isButtonInteractible(e))return!1;const n=vl(e);return!!m0(n)},getButtonState(e){const t=vl(e),n=this.buttons[e],r=t.tag||"default",o=n.state;return o===!0&&Io().isInteractionTagBlocked(r)?"greyed":o},clickOnButton(e){if(!this.isButtonClickable(e))return;const t=un(),n=vl(e);uu("onButtonClicked");const r=n.action;r&&(n.actionType==="run"?t.runLabelFunction(r):t.jumpToLabel(r))}},getters:{nonEmptyLayers(e){return e.layers.filter(t=>t)},isTransitioning(e){return e.layers.some(t=>t==null?void 0:t.transition)}}});function m0(e){if(!sn().inScript)return!0;const t=q0().clickableDuringScriptsByDefault;if(t)return e.scriptClickable!==!1;if(!t)return e.scriptClickable===!0}const s1e=["screenObject","sprite"];function fV(e){return typeof e=="object"&&e!==null&&s1e.includes(e._entityType)}function c1e(e){return typeof e=="object"&&e!==null&&e._entityType==="sprite"}function l1e(e){if(e.includes(" ")){const t=e.split(" ");return{label:t[0],args:t.slice(1)}}else return{label:e}}const Bi=eo("screenObjects",{state:()=>({tree:[],objectsList:{}}),actions:{addObject(e){e.parent?e.parent.children.push(e):this.tree.push(e),this.objectsList[e.id]=e},createObject(e){const t={_entityType:"screenObject",id:su(),name:"Screen Object",tags:[],x:0,y:0,anchor:{x:0,y:0},width:1,height:1,opacity:1,scale:1,layer:0,children:[],...e};return this.addObject(t),t},destroyObject(e){let t=e;typeof t=="string"&&(t=this.getObject(t));for(let n=t.children.length-1;n>=0;n--)this.destroyObject(t.children[n]);if(t.parent){const n=t.parent,r=n.children.indexOf(t);r!==-1?n.children.splice(r,1):console.warn(`Could not find object ${t.id} in parent's children`)}else{const n=this.tree.indexOf(t);n!==-1?this.tree.splice(n,1):console.warn(`Object to destroy not found in store (${t.id})`)}delete this.objectsList[t.id]},createSprite(e){const t=this.createObject(e);return t._entityType="sprite",o1e(e.image).then(n=>{const r=this.getObject(t.id);r.width===1&&r.height===1&&(r.width=n.width,r.height=n.height)}),t},getObject(e){return this.objectsList[e]},isScreenObjectClickable(e){return m0(e)?!!e.onClick:!1},clickObject(e){if(this.isScreenObjectClickable(e)&&e.onClick){uu("onSpriteClicked");let t;if(typeof e.onClick=="string"){const n=l1e(e.onClick);t={label:n.label,args:n.args}}else t=e.onClick;t.method=t.method??e.clickMethod??"jump",t.args=t.args??[],t.method==="run"?un().runThenGoBackToPreviousDialog(t.label,...t.args):t.method==="jump"?un().jumpToLabel(t.label,...t.args):St(`Unknown sprite click method ${e.clickMethod}`)}},generateSaveData(){return{tree:Xn(this.tree.map(e=>e.id)),objectsList:Xn(r1e(this.objectsList,e=>this.screenObjectToSave(e)))}},loadSaveData(e){this.objectsList=this.loadAllObjects(e.objectsList),this.tree=e.tree.map(t=>this.objectsList[t])},reset(){this.$reset()},screenObjectToSave(e){return{...e,children:e.children.map(t=>t.id),parent:e.parent?e.parent.id:void 0}},loadAllObjects(e){for(const t of Object.values(e)){const n=t;n.parent=n.parent?e[n.parent]:void 0,n.children=n.children.map(r=>e[r])}return e},emptyLayer(e){for(let t=this.tree.length-1;t>=0;t--){const n=this.tree[t];n.layer===e&&this.destroyObject(n)}},emptyAllLayers(){for(let e=this.tree.length-1;e>=0;e--){const t=this.tree[e];this.destroyObject(t)}}}});function dV(e){return"save"in e}function hV(e){return"globalSave"in e}function u1e(e){return"config"in e}const f1e=b.defineComponent({props:{percentage:Number,step:String},methods:{loadingStyle(){return{width:`${this.percentage*60}vw`}}},computed:{}}),d1e={id:"loading-bar"},h1e={id:"loading-text"};function p1e(e,t,n,r,o,i){return b.openBlock(),b.createElementBlock("div",d1e,[b.createElementVNode("div",{id:"inner-loading-bar",style:b.normalizeStyle(e.loadingStyle())},null,4),b.createElementVNode("div",h1e,[b.createElementVNode("h3",null,"Loading "+b.toDisplayString(Math.floor(e.percentage*100))+"% - "+b.toDisplayString(e.step),1)])])}const m1e=Xa(f1e,[["render",p1e]]),v1e="data:image/svg+xml,%3c?xml%20version='1.0'%20encoding='utf-8'?%3e%3c!--%20Generator:%20Adobe%20Illustrator%2019.0.0,%20SVG%20Export%20Plug-In%20.%20SVG%20Version:%206.00%20Build%200)%20--%3e%3csvg%20version='1.1'%20id='Rat'%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20x='0px'%20y='0px'%20viewBox='0%200%20595.3%20595.3'%20style='enable-background:new%200%200%20595.3%20595.3;'%20xml:space='preserve'%3e%3cstyle%20type='text/css'%3e%20.st0{fill:%23E23B33;}%20%3c/style%3e%3cpath%20id='Rat_Shape'%20class='st0'%20d='M556.9,82.5c-10.8-24.3-47-57.1-71.3-65.6c-24.3-8.4-64.1-0.3-88.7,22.3%20c-20,18.4-26,28.2-29.1,37c-2.1,5.9-4.8,13.5-6,20.9v0c-0.5,4.1-4.5,7-8.6,6.1c-10.4-2.3-29.5-6-44.4-6.3%20c-13.7-0.2-30.1,3.2-40.4,5.7c-4.5,1.1-8.8-2.2-8.8-6.8c-0.1-5.3-1.1-12.3-4.8-19.6c-8.5-16.9-19.6-32.6-57.8-47.4%20c-31.9-12.4-75.1-9.7-100.8,1.8c-28.1,12.6-42.4,37.9-54,61.8c-14.4,29.8-14.9,83.6-6.4,104c12.8,30.7,35.8,47.2,52.6,53%20c11.3,3.8,28.2,3.7,38.2,3.3c4.2-0.2,7.7,3.3,7.5,7.5c-0.7,13.6-0.9,41.5,7,61.4c7.7,19.4,29.7,62.3,50.7,101.2%20c0,0.1-14.6,2.9-31.4,6.8c-23.9,5.5-52.6,12.7-54.3,13.7c-3.5,2.1-3,10-2.7,12c0.5,3.4,5.3,8.1,6.9,8.3c3.9,0.3,31.3-7.6,55.7-14.6%20c18.5-5.3,34.9-9.3,35.5-8.2c5.1,9.3,10,18,14.4,25.8c5.2,9.1,10.7,16.4,14.1,23.6c1.1,2.3-16.6,5.8-32.5,14.7%20c-16.4,9.1-29.7,21-32.3,24c-1.8,2.1-3,6-1.2,10.7c1.1,2.9,10,5.7,12.4,5.1c6.8-1.7,16.5-12.5,33.1-21.1%20c16.3-8.5,32.9-14.9,33.8-13.6c9.7,14.3,16.9,21.6,22.6,31.2c9.8,16.5,27.3,45.9,46.6,39.5c6.4-2.1,31.1-33.6,53.3-68.6%20c1.3-2.1,16.1,11.3,30.4,23.2c13.8,11.4,22.7,20.6,27.1,21.4c5.4,1,14.2-7.7,14.1-14.7c-0.1-2.7-14.3-13.8-29.1-26.2%20c-14.5-12.1-30.1-22.8-29.2-24.3c7.6-12,14.5-23.7,20.1-33.9c4.3-7.8,8.9-16,13-24.7c0.6-1.2,15.9,3,31.4,7.1c15.3,4,26.7,10,31,8%20c6.9-3,11.6-13.8,9.4-18.3c-1.1-2.3-17-7.3-33.2-12c-14.2-4.1-28-6.5-27.7-7.3c15.5-34,28.8-64.8,27.6-69.6%20c-1.7-7.1,2.6-11.9,7-36.5c3.2-18.1,4.7-40.9,5.2-51.7c0.2-3.5,2.8-6.3,6.3-6.7c3.1-0.3,6.9-0.9,10.5-1.9c7.8-2,18.6-7.8,36.4-20.6%20c17.9-12.8,38.7-49.6,44.4-67.8S567.6,106.8,556.9,82.5z%20M265.1,336.2c-8.1,4-13,7-26.4,9.6c-6.9,1.4-29.4-0.2-40.7-4.6%20c-10.5-4.1-19.9-7.6-30-15.4s-15.7-13.2-15.7-15.3c0-4.4,6-9.4,11-9.4c5.1,0,14.5,9.2,29.7,16.6c14.3,7,17.9,6.1,25.4,7.3%20c2.9,0.5,7.7,0.6,10.7,0.4c14.1-1.3,21.4-5.9,25.3-8.8c4-3,13.7-12.9,17.2-12.5c8,1,18.9,3.4,18.9,7.1%20C290.4,319,273.2,332.1,265.1,336.2z%20M320.9,521.4c-4.3,3.7-17.7,13.5-23.3,13.5c-2.8,0-7.4-8.2-11.5-16.8%20c-4.1-8.5-9.1-21.1-9.1-31.6c0-4.6,6-7.4,13.4-9.2c7.2-1.7,27.3-1.8,29.9-1.1c6.8,1.7,12.9,2.2,12.7,6.4c-0.4,12.7-7,18.9-8.3,24.3%20C323.4,512.3,323.4,519.2,320.9,521.4z%20M431.1,320.3c-9.2,7.4-10.6,8.1-24.9,13.7c-11.3,4.4-28.6,5.8-41.6,3.6%20c-12.2-2.1-22.3-4.6-29.5-10.1c-9.7-7.3-16.4-15.1-16.4-19.8c0-3.7,6.4-4.3,14.5-4.9c3.5-0.3,9.3,5.9,13.2,9.2%20c8.1,6.8,14.8,8,28.8,9.9c2.9,0.4,7.8,0.4,10.7,0.1c7.5-0.9,12-0.4,25.8-8.2c20-11.2,17.8-14.4,25.1-12.6c2.2,0.6,5.8,1.2,5.6,5.6%20C442.4,309,440.5,312.7,431.1,320.3z'/%3e%3c/svg%3e",g1e={id:"engine-splash-screen",class:"flex justify-center items-center"},y1e={id:"engine-splash-title"},b1e=["src"],Lx=b.defineComponent({__name:"engine-splash",emits:["finished"],setup(e,{emit:t}){const n=t,r=b.ref("hidden"),o=b.computed(()=>({transitionDuration:`${f.value}s`})),i=b.computed(()=>({invisible:r.value!=="appear"})),a=sn(),s=b.computed(()=>{var h;return((h=Ct().splashScreens)==null?void 0:h.engineSplashScreen)??{}}),c=b.computed(()=>typeof s.value.overrideText=="string"?s.value.overrideText:"Made with narrat engine"),l=b.computed(()=>s.value.overrideLogo??v1e),f=b.computed(()=>typeof s.value.fadeDuration=="number"?s.value.fadeDuration:.8),u=b.computed(()=>typeof s.value.timeBeforeFadeout=="number"?s.value.timeBeforeFadeout:1.5);b.onMounted(async()=>{if(await ki(10),r.value="appear",s.value.skip||a.options.debug){d();return}await ki(f.value*1e3),await ki(u.value*1e3),r.value="disappear",await ki(f.value*1e3),d()});function d(){a.loading.loaded?n("finished"):a.listener.once("gameLoaded",()=>{n("finished")})}return(h,p)=>(b.openBlock(),b.createElementBlock("div",g1e,[b.createElementVNode("div",{id:"engine-splash-header",class:b.normalizeClass(["flex justify-center flex-col items-center",i.value]),style:b.normalizeStyle(o.value)},[b.createElementVNode("h1",y1e,b.toDisplayString(c.value),1),b.createElementVNode("img",{src:l.value,alt:"Narrat Logo",id:"engine-splash-logo"},null,8,b1e),b.createVNode(m1e,{percentage:b.unref(a).loading.percentage,step:b.unref(a).loading.step},null,8,["percentage","step"])],6)]))}});class Bx{constructor(){Wn(this,"listeners",{})}on(t,n){return this.listeners[t]||this.addEventToMap(t),this.listeners[t].add(n),n}off(t,n){return this.listeners[t]&&this.listeners[t].delete(n),n}once(t,n){const r=(...o)=>{this.off(t,r),n(...o)};return this.on(t,r)}emit(t,...n){this.listeners[t]&&this.listeners[t].forEach(r=>r(...n))}clear(){Object.keys(this.listeners).forEach(t=>{delete this.listeners[t]})}addEventToMap(t){this.listeners[t]=new Set}}class w1e extends Bx{setup(){const t=()=>{this.emit("preUpdate"),this.emit("update"),this.emit("postUpdate"),requestAnimationFrame(t)};t()}}const fp=new w1e;Qe.Vec2=void 0,(e=>{function t(p,m){return{x:p??0,y:m??0}}e.create=t;function n(p){return Math.sqrt(p.x*p.x+p.y*p.y)}e.magnitude=n;function r(p){const m=n(p);return m===0?t(0,0):{x:p.x/m,y:p.y/m}}e.normalize=r;function o(p,m){return{x:p.x+m.x,y:p.y+m.y}}e.add=o;function i(p,m){return{x:p.x-m.x,y:p.y-m.y}}e.subtract=i;function a(p,m){return{x:p.x*m.x,y:p.y*m.y}}e.multiply=a;function s(p,m){return{x:p.x*m,y:p.y*m}}e.scale=s;function c(p,m){return{x:p.x/m.x,y:p.y/m.y}}e.divide=c;function l(p,m){return n(i(p,m))}e.distance=l;function f(p,m,v){return{x:p.x+(m.x-p.x)*v,y:p.y+(m.y-p.y)*v}}e.lerp=f;function u(p,m){const v=Math.cos(m),g=Math.sin(m);return{x:p.x*v-p.y*g,y:p.x*g+p.y*v}}e.rotate=u;function d(p,m){const v=i(m,p);return e.normalize({x:-v.y,y:v.x})}e.normal=d;function h(p,m){return p.x*m.x+p.y*m.y}e.dot=h})(Qe.Vec2||(Qe.Vec2={}));function Fx(e,t,n,r){const o=e/n,i=t/r;return Math.min(o,i)}const Es=eo("settings",{state:()=>({baseSettings:{textSpeed:30,animateText:!0,fontSize:16},settingsSchema:{textSpeed:{type:"number",defaultValue:30,minValue:1,maxValue:100,step:5,name:"Text Speed",description:"The speed at which text plays."},animateText:{type:"boolean",defaultValue:!0,name:"Animate Text",description:"Whether or not text should animate."},fontSize:{type:"integer",defaultValue:16,minValue:8,maxValue:64,step:1,name:"Font Size",description:"The base font size for the game."}},customSettings:{},customSettingsSchema:{}}),actions:{reset(e){this.$reset(),this.updateConfig(e)},getSetting(e){if(typeof this.baseSettings[e]<"u")return this.baseSettings[e];if(typeof this.customSettings[e]<"u")return this.customSettings[e];St(`Setting ${e} does not exist.`)},getSettingSchema(e){if(typeof this.settingsSchema[e]<"u")return this.settingsSchema[e];if(typeof this.customSettingsSchema[e]<"u")return this.customSettingsSchema[e];St(`Setting ${e} does not exist.`)},getAllSettingSchemas(){return{...this.settingsSchema,...this.customSettingsSchema}},setSetting(e,t){typeof this.baseSettings[e]<"u"?this.baseSettings[e]=t:typeof this.customSettings[e]<"u"?this.customSettings[e]=t:St(`Setting ${e} does not exist.`),e==="fontSize"&&document.documentElement.style.setProperty("font-size",`${t}px`),e==="textSpeed"&&(Ct().dialogPanel.textSpeed=t),e==="animateText"&&(Ct().dialogPanel.animateText=t)},updateConfig(e){var t;if(this.setSetting("textSpeed",e.dialogPanel.textSpeed??a0),this.setSetting("animateText",e.dialogPanel.animateText??!0),this.setSetting("fontSize",e.layout.defaultFontSize??16),(t=e.settings)!=null&&t.customSettings)for(const n in e.settings.customSettings)this.addCustomSetting(n,e.settings.customSettings[n])},addCustomSetting(e,t){this.customSettings[e]=t.defaultValue,this.customSettingsSchema[e]=t},generateSaveData(){return{baseSettings:Xn(this.baseSettings),customSettings:Xn(this.customSettings)}},loadSaveData(e){for(const t in e.baseSettings)this.setSetting(t,e.baseSettings[t]);for(const t in e.customSettings)typeof this.customSettings[t]<"u"&&this.setSetting(t,e.customSettings[t])}}});function dp(e,t=50,n={}){let r;const o=n.isImmediate??!1,i=n.callback??!1,a=n.maxWait;let s=Date.now(),c=[];function l(){if(a!==void 0){const u=Date.now()-s;if(u+t>=a)return a-u}return t}const f=function(...u){const d=this;return new Promise((h,p)=>{const m=function(){if(r=void 0,s=Date.now(),!o){const y=e.apply(d,u);i&&i(y),c.forEach(({resolve:w})=>w(y)),c=[]}},v=o&&r===void 0;r!==void 0&&clearTimeout(r);const g=l();if(r=setTimeout(m,g),v){const y=e.apply(d,u);return i&&i(y),h(y)}c.push({resolve:h,reject:p})})};return f.cancel=function(u){r!==void 0&&clearTimeout(r),c.forEach(({reject:d})=>d(u)),c=[]},f}const Gr=eo("rendering",{state:()=>({screenHeight:window.innerHeight,screenWidth:window.innerWidth,layoutMode:"horizontal",resizeObserver:null,containerElement:null,narratAppElement:null,dialogPanelMode:"auto"}),actions:{generateSaveData(){return{dialogPanelMode:this.dialogPanelMode}},loadSaveData(e){this.dialogPanelMode=e.dialogPanelMode},reset(){this.dialogPanelMode="auto"},updateScreenSize(e,t){this.screenHeight=t,this.screenWidth=e,e<Ct().layout.verticalLayoutThreshold?(this.layoutMode="vertical",document.querySelector("html").style.fontSize=`${Es().baseSettings.fontSize}px`??"40px"):(this.layoutMode="horizontal",document.querySelector("html").style.fontSize=`${Es().baseSettings.fontSize}px`??"16px")},setContainer(e){this.containerElement=e,this.resizeObserver&&this.resizeObserver.disconnect(),this.resizeObserver=new ResizeObserver(dp(()=>{this.refreshScreenSize()},100,{maxWait:200})),this.resizeObserver.observe(e),this.refreshScreenSize()},refreshScreenSize(){const e=this.containerElement;e&&this.updateScreenSize(e.clientWidth,e.clientHeight)}},getters:{gameScaleRatio(e){return Fx(this.screenWidth,this.screenHeight,this.gameWidth,this.gameHeight)},overlayMode(e){return!!(Ct().dialogPanel.overlayMode&&e.layoutMode==="horizontal")},gameWidth(){const e=Ct();return this.layoutMode==="vertical"||this.overlayMode?e.layout.backgrounds.width:e.layout.backgrounds.width+G0()},gameHeight(){const e=Ct();return this.layoutMode==="vertical",e.layout.backgrounds.height},dialogWidth(){return this.layoutMode==="vertical"?this.viewportWidth:G0()},dialogHeight(){return this.layoutMode==="vertical"?this.actualGameHeight-this.gameHeight:Ct().dialogPanel.height??this.gameHeight},actualGameHeight(){let e=this.gameHeight;return this.layoutMode==="vertical"&&(e=this.screenHeight/this.gameScaleRatio),e},viewportRatio(e){if(this.layoutMode==="vertical"){const t=Ct().layout.backgrounds;return e.screenWidth/t.width}return 1},viewportHeight(e){return Ct().layout.backgrounds.height*this.viewportRatio},viewportWidth(e){return Ct().layout.backgrounds.width*this.viewportRatio},showDialog(e){if(this.dialogPanelMode==="on")return!0;if(this.dialogPanelMode==="off")return!1;if(!this.overlayMode||this.layoutMode==="vertical")return!0;const t=sn().inScript;let n=!0;return da().isTransitioning&&Ct().dialogPanel.hideDuringTransition&&(n=!1),!Ct().dialogPanel.showAfterScriptEnd&&!t&&(n=!1),n},container(){return this.containerElement?this.containerElement:document.body},inputsContainer(){return sn().hasCustomContainer?this.container:window},narratApp(){return this.narratAppElement?this.narratAppElement:document.body}}});class k1e extends EventTarget{constructor(){super(...arguments);Wn(this,"gamepadAvailable",!0);Wn(this,"gameActions",{});Wn(this,"keyboardState",{});Wn(this,"actions",{});Wn(this,"lastInputMethodUsed","km");Wn(this,"gamepad",null)}kbEvent(){this.changeLastInput("km")}getGamepads(){return navigator.getGamepads?navigator.getGamepads():(this.gamepadAvailable=!1,[])}gamepadEvent(){this.changeLastInput("gamepad")}mouseEvent(){this.changeLastInput("km")}changeLastInput(n){this.lastInputMethodUsed!==n&&(this.lastInputMethodUsed=n,this.dispatchEvent(new CustomEvent("change-input",{detail:n})))}getGamepad(){const n=this.getGamepads().filter(r=>r!==null);if(n.length>0)return n[0]}startListening(){this.updateGamepad();const n=Gr().inputsContainer;n.addEventListener("mousemove",r=>{this.mouseEvent()}),n.addEventListener("keydown",r=>{this.kbEvent();const o=this.getKeyboardState(r.key).current;this.keyboardState[r.key]={previous:o,current:!0}}),n.addEventListener("keyup",r=>{this.kbEvent();const o=this.getKeyboardState(r.key).current;this.keyboardState[r.key]={previous:o,current:!1}}),fp.on("preUpdate",()=>{this.update()})}updateGamepad(){const n=this.getGamepad();n?this.gamepad?this.updateAllNarratButtons(n,this.gamepad):this.gamepad=this.setupNarratGamepad(n):this.gamepad=null}setupNarratGamepad(n){return{id:n.id,gamepad:n,buttons:n.buttons.map((o,i)=>this.getNarratButtonFromGamepad(o,o,i))}}updateAllNarratButtons(n,r){for(const[o,i]of n.buttons.entries()){const a=r.buttons[o];a.previous=Xn(a.state),a.state=Xn(i),a.previous.pressed!==a.state.pressed&&this.gamepadEvent()}}getNarratButtonFromGamepad(n,r,o){return{index:o,state:Xn(r),previous:Xn(r)}}addAction(n){if(this.gameActions[n.id]=n,n.type==="button"){const r={config:n,active:!1,justPressed:!1,justReleased:!1};this.actions[n.id]={state:r,previous:Xn(r)}}else{const r={config:n,value:Qe.Vec2.create(0,0),fullState:{left:0,right:0,up:0,down:0}};this.actions[n.id]={state:r,previous:Xn(r)}}}getAnalog(n){return this.actions[n]||St(`Action ${n} does not exist`),this.actions[n].state}getButton(n){return this.actions[n]||St(`Action ${n} does not exist`),this.actions[n].state}getKeyboardState(n){return this.keyboardState[n]?this.keyboardState[n]:(this.keyboardState[n]={current:!1,previous:!1},this.keyboardState[n])}getGamepadState(n){return this.gamepad&&this.gamepad.buttons.length>n?{current:this.gamepad.buttons[n].state,previous:this.gamepad.buttons[n].previous}:null}debugGamepad(){if(this.gamepad)for(const[n,r]of this.gamepad.buttons.entries())r.state.pressed,r.previous.pressed}update(){this.updateGamepad(),this.debugGamepad();for(const n of Object.values(this.gameActions))if(n.type==="button"){const r=this.actions[n.id],o=Xn(r.state),i=r.state;r.previous=o,n.action==="press"&&(n.keybinds.some(s=>{let c=!1;if(typeof s.keyboardKey=="string"&&this.getKeyboardState(s.keyboardKey).current===!0&&(c=!0),typeof s.gamepadButton=="number"){const l=this.getGamepadState(s.gamepadButton);l&&l.current.pressed===!0&&(c=!0)}return c})?i.active=!0:i.active=!1,i.active&&!o.active?i.justPressed=!0:i.justPressed=!1,!i.active&&o.active?i.justReleased=!0:i.justReleased=!1)}else if(n.type==="analog"){const r=this.actions[n.id],o=r.state;Xn(r.state),r.previous=Xn(o);let i=Qe.Vec2.create(0,0);n.keybinds.forEach(a=>{this.getKeyboardState(a.left).current&&(o.fullState.left=1,i.x-=1),this.getKeyboardState(a.right).current&&(o.fullState.right=1,i.x+=1),this.getKeyboardState(a.up).current&&(o.fullState.up=1,i.y-=1),this.getKeyboardState(a.down).current&&(o.fullState.down=1,i.y+=1)}),i=Qe.Vec2.normalize(i),o.value=i}}}const ul=new k1e,No=eo("menu",{state:()=>({menus:{},activeMenu:!1}),getters:{showSkills(){return Object.entries(Ns().skills).length>0},showInventory(){return Object.entries(V0().items).length>0},showQuests(){return Object.entries(Tp().quests).length>0},showAchievements(){return Object.entries(Op().achievements).length>0},menuTabsToShow(e){return e.menus.menu.tabs.map(t=>{const n=Ct().menuButtons[t.id]||{};return{...t,...n}}).filter(t=>t.condition?t.condition():!0)},menu(e){return e.activeMenu?e.menus[e.activeMenu]:void 0},tab(){if(this.menu)return this.menu.tabs[this.menu.activeTab]}},actions:{setup(){},addMenu(e,t){this.menus[e]={...t,id:e}},addMenuOption(e,t){this.menus[e]||(this.menus[e]={id:e,label:e,tabs:[],activeTab:0}),this.menus[e].tabs.push(t)},setActiveTab(e){this.menu&&(this.menu.activeTab=e)},openMenu(e){this.activeMenu=e},closeMenu(){this.activeMenu=!1},toggleMenu(){this.activeMenu?this.activeMenu=!1:this.activeMenu="menu"}}}),x1e=[{id:"left",type:"button",action:"press",keybinds:[{keyboardKey:"ArrowLeft",gamepadButton:14}]},{id:"right",type:"button",action:"press",keybinds:[{keyboardKey:"ArrowRight",gamepadButton:15}]},{id:"up",type:"button",action:"press",keybinds:[{keyboardKey:"ArrowUp",gamepadButton:12}]},{id:"down",type:"button",action:"press",keybinds:[{keyboardKey:"ArrowDown",gamepadButton:13}]},{id:"continue",type:"button",action:"press",keybinds:[{keyboardKey:"Enter",gamepadButton:0}]},{id:"cancel",type:"button",action:"press",keybinds:[{keyboardKey:"Escape",gamepadButton:1}]},{id:"system",type:"button",action:"press",keybinds:[{keyboardKey:"n",gamepadButton:9}]},{id:"menu",type:"button",action:"press",keybinds:[{keyboardKey:"m",gamepadButton:8}]},{id:"previousTab",type:"button",action:"press",keybinds:[{keyboardKey:"p",gamepadButton:4}]},{id:"nextTab",type:"button",action:"press",keybinds:[{keyboardKey:"o",gamepadButton:5}]},{id:"subPreviousTab",type:"button",action:"press",keybinds:[{keyboardKey:"i",gamepadButton:6}]},{id:"subNextTab",type:"button",action:"press",keybinds:[{keyboardKey:"u",gamepadButton:7}]},{id:"viewportSelect",type:"button",action:"press",keybinds:[{keyboardKey:"v",gamepadButton:2}]},{id:"autoPlay",type:"button",action:"press",keybinds:[{keyboardKey:"a",gamepadButton:6}]},{id:"skip",type:"button",action:"press",keybinds:[{keyboardKey:"s",gamepadButton:7}]}],xr=eo("inputs",{state:()=>({inputStack:[],baseInputListener:null,inputMode:"mk",inGameInputListener:null}),actions:{setupInputs(){ul.addEventListener("change-input",e=>{this.inputMode=e.detail});for(const e of x1e)ul.addAction(e);this.listenToBaseNarratInputs(),fp.on("preUpdate",()=>{for(const[e,t]of Object.entries(ul.actions))if(t.state.config.type==="button"){const n=t;n.state.justPressed&&this.triggerListeners(e,"press",n),n.state.justReleased&&this.triggerListeners(e,"release",n)}else t.state.config.type})},createInGameInputListener(){this.inGameInputListener||(this.inGameInputListener=this.registerInputListener("in-game",{system:{press:()=>{No().openMenu("system")}},menu:{press:()=>{No().openMenu("menu")}}}))},removeInGameInputListener(){this.inGameInputListener&&(this.unregisterInputListener(this.inGameInputListener),this.inGameInputListener=null)},listenToContainerInputs(){ul.startListening()},listenToBaseNarratInputs(){},triggerListeners(e,t,n){const r=this.inputStack[this.inputStack.length-1];if(r&&r.actions[e]&&r.actions[e][t])if(n.state.config.type==="button"){const o=r.actions[e][t],i=n;o(n.state.config,i.state,i.previous)}else console.warn("Analog events not implemented yet")},getInputs(){return ul},registerInputListener(e,t){const r={id:`${Date.now()}-${Math.floor(Math.random()*1e8)}`,name:e,actions:t??{}};return this.inputStack.push(r),r},unregisterInputListener(e){const t=this.inputStack.findIndex(n=>n.id===e.id);if(t===-1)throw new Error("Input listener not found");this.inputStack.splice(t,1)},registerActions(e,t,n){e.actions[t]=n}}}),_i=eo("scenes-store",{state:()=>({scenes:{},activeScene:"engine-splash",currentOptions:{}}),getters:{isPlaying(e){return e.activeScene!=="engine-splash"&&e.activeScene!=="game-splash"&&e.activeScene!=="start-menu"}},actions:{generateSaveData(){return{activeScene:this.activeScene}},loadSaveData(e){},changeScene(e,t){const n=this.activeScene;if(n&&n!==e){const r=this.scenes[n];r.onLeaving&&r.onLeaving(),this.currentOptions={},this.activeScene=e,this.currentOptions=t||{},this.scenes[e].onStarting&&this.scenes[e].onStarting()}},getSceneConfig(e){return this.scenes[e]},onEngineSplashFinished(){this.changeScene("game-splash")},finishedScene(e){this.scenes[e].onFinished&&this.scenes[e].onFinished()},addNewScene(e){this.scenes[e.id]=e}}}),_1e={id:"game-splash-screen",style:{height:"100%",padding:"20px"},class:"flex justify-center items-center"},S1e={id:"game-splash-screen-header flex justify-center flex-col items-center",class:"flex justify-center flex-col items-center"},j1e={class:"title",id:"game-splash-title"},Vx=b.defineComponent({__name:"game-splash",setup(e){const t=b.ref(null),n=sn(),r=b.computed(()=>{var c;return((c=Ct().splashScreens)==null?void 0:c.gameSplashScreen)??{}}),o=b.computed(()=>typeof r.value.startButtonText=="string"?r.value.startButtonText:"Press to start"),i=b.computed(()=>n.loading.loaded),a=b.computed(()=>Ct().gameTitle||"Narrat Game");function s(){_i().changeScene("start-menu")}return b.onMounted(()=>{t.value=xr().registerInputListener("game-splash",{continue:{press:()=>{s()}},system:{press:()=>{s()}}}),n.options.debug&&s()}),b.onUnmounted(()=>{t.value&&xr().unregisterInputListener(t.value)}),(c,l)=>(b.openBlock(),b.createElementBlock("div",_1e,[b.createElementVNode("div",S1e,[b.createElementVNode("h1",j1e,b.toDisplayString(a.value),1),i.value?(b.openBlock(),b.createElementBlock("button",{key:0,class:"button menu-button main-menu-button large splash-start-button override",onClick:s},b.toDisplayString(o.value),1)):b.createCommentVNode("",!0)])]))}});function dc(e){if(!e.listener)return console.warn("No input listener provided for navigation"),null;const t=b.ref(-1),n=b.computed(()=>e.mode==="grid"?t.value%e.columns:0),r=b.ref([]),o=b.ref(ul.lastInputMethodUsed),i=b.ref(null);function a(){var D,L;return(D=e.container)!=null&&D.value?e.container.value.children:(L=e.elements)!=null&&L.value?e.elements.value.filter(I=>I!==null):[]}function s(){r.value=a()}const c=b.computed(()=>u(t.value));function l(D){return r.value?D>=0&&D<r.value.length:!1}function f(D){const L=t.value;if(l(D)&&(t.value=D,c.value)){o.value==="gamepad"&&c.value.classList.add("selected");const I=u(L);I&&L!==D&&I.classList.remove("selected"),e.onSelected&&e.onSelected(D)}}function u(D){return r.value?r.value[D]:null}function d(){r.value&&(t.value===0?e.loopForbidden||f(r.value.length-1):f(t.value-1))}function h(){r.value&&(t.value===r.value.length-1?e.loopForbidden||f(0):f(t.value+1))}function p(){if(!r.value)return;const D=e,L=t.value;!e.loopForbidden&&L<D.columns?f(r.value.length-1):f(t.value-e.columns)}function m(){if(!r.value)return;const D=e,L=t.value;!e.loopForbidden&&L>=r.value.length-D.columns?f(0):f(t.value+e.columns)}function v(){e.mode==="grid"?p():e.mode==="list"&&d()}function g(){e.mode==="grid"?m():e.mode==="list"&&h()}function y(){(e.mode==="grid"||e.mode==="list")&&d()}function w(){(e.mode==="grid"||e.mode==="list")&&h()}function k(){e.onChosen&&e.onChosen(t.value)}b.onMounted(()=>{R()});function $(){e.listener&&(e.onlyVertical||(delete e.listener.actions.left,delete e.listener.actions.right),e.onlyHorizontal||(delete e.listener.actions.up,delete e.listener.actions.down),e.noChoosing||delete e.listener.actions.continue,i.value&&ul.removeEventListener("change-input",i.value))}function S(){c.value&&c.value.classList.add("selected")}function E(){c.value&&c.value.classList.remove("selected")}function R(){e.listener&&(s(),i.value=D=>{o.value=D.detail,D.detail==="gamepad"?S():E()},ul.addEventListener("change-input",i.value),e.onlyVertical||(e.listener.actions.left={press:y},e.listener.actions.right={press:w}),e.onlyHorizontal||(e.listener.actions.up={press:v},e.listener.actions.down={press:g}),e.noChoosing||(e.listener.actions.continue={press:k}),f(0))}return b.onUnmounted(()=>{$()}),b.watch(()=>{var D;return(D=e.elements)==null?void 0:D.value},D=>{D&&s()}),{selectedIndex:t,selectedElement:c,currentColumn:n,buttonDown:g,buttonUp:v,buttonLeft:y,buttonRight:w,selectUp:p,selectDown:m,selectPrevious:d,selectNext:h,select:f,disable:$,mount:R}}const C1e={class:"used-save-slot flex flex-row justify-between items-center grow"},$1e={class:"flex flex-col save-slot-number-container"},T1e={class:"save-slot-number"},O1e={class:"flex flex-col justify-center save-info"},E1e={key:1,class:"save-name"},A1e={class:"flex flex-col"},P1e={key:0},M1e={key:1},I1e={key:2},N1e=["onClick"],zx=b.defineComponent({__name:"save-slot-ui",props:{saveSlot:{},id:{},actions:{},selected:{type:Boolean},inputListener:{}},emits:["choice","cancel"],setup(e,{expose:t,emit:n}){var k;const r=e,o=b.ref(null),i=b.ref(null),a=b.ref(null);t({slotContainer:a});const s=b.ref(((k=r.saveSlot.saveData)==null?void 0:k.metadata.name)??"Empty Save"),c=b.ref(0),l=b.computed(()=>r.saveSlot.saveData!==null),f=b.computed(()=>r.saveSlot.saveData),u=b.computed(()=>Ct().saves.mode),d=b.computed(()=>{const $=r.saveSlot.saveData;if($&&$.screen.layers[0]){const S=ud($.screen.layers[0]);if(S)return{backgroundImage:`url(${fd(S.background)})`}}return!1}),h=n;function p($){h("choice",$)}function m($){return f.value?ty(f.value.main.playTime/1e3):"00:00:00"}function v(){f.value&&Ime(r.saveSlot.id,s.value)}function g(){const $=Ct().saves.slots;let S="";const E=r.saveSlot.slotNumber;return E===0&&Ct().saves.mode==="manual"?"AUTO":($>=10&&E<10&&(S+="0"),$>=100&&E<100&&(S+="0"),S+E)}function y(){o.value=dc({mode:"list",container:i,listener:r.inputListener,onlyHorizontal:!0,onSelected:$=>{c.value=$},onChosen:$=>{p($)}}),o.value.mount()}function w(){o.value.disable(),o.value=null}return b.watch(()=>r.selected,($,S)=>{$&&!o.value&&y(),!$&&o.value&&w()}),b.onUnmounted(()=>{o.value&&w()}),($,S)=>(b.openBlock(),b.createElementBlock("div",{class:"save-slot flex flex-row",ref_key:"slotContainer",ref:a},[b.createElementVNode("div",C1e,[b.createElementVNode("div",$1e,[b.createElementVNode("h1",T1e,b.toDisplayString(g()),1)]),d.value?(b.openBlock(),b.createElementBlock("div",{key:0,class:"save-slot-screenshot",style:b.normalizeStyle(d.value)},null,4)):b.createCommentVNode("",!0),b.createElementVNode("div",O1e,[l.value?b.withDirectives((b.openBlock(),b.createElementBlock("input",{key:0,type:"text",class:"save-name","onUpdate:modelValue":S[0]||(S[0]=E=>s.value=E),onInput:v},null,544)),[[b.vModelText,s.value]]):(b.openBlock(),b.createElementBlock("h3",E1e,b.toDisplayString(s.value),1)),b.createElementVNode("div",A1e,[f.value?(b.openBlock(),b.createElementBlock("p",P1e,b.toDisplayString(new Date(f.value.metadata.saveDate).toLocaleString()),1)):b.createCommentVNode("",!0),f.value?(b.openBlock(),b.createElementBlock("p",M1e,"Play time: "+b.toDisplayString(m($.saveSlot)),1)):b.createCommentVNode("",!0),u.value==="game-slots"?(b.openBlock(),b.createElementBlock("p",I1e,b.toDisplayString($.saveSlot.slotType==="auto"?"Auto Save":"Manual Save"),1)):b.createCommentVNode("",!0)])]),b.createElementVNode("div",{class:"flex flex-row",ref_key:"actionsContainer",ref:i},[(b.openBlock(!0),b.createElementBlock(b.Fragment,null,b.renderList($.actions,(E,R)=>(b.openBlock(),b.createElementBlock("button",{class:b.normalizeClass(["button",{selected:$.selected&&R===c.value}]),onClick:()=>p(R),key:R},[b.createElementVNode("h3",null,b.toDisplayString(E),1)],10,N1e))),128))],512)])],512))}}),R1e=b.createElementVNode("h3",{class:"title"},"Confirmation",-1),v0=b.defineComponent({__name:"yes-no",props:{prompt:{type:String,required:!0},onConfirm:{type:Function,required:!1},onRefuse:{type:Function,required:!1}},emits:["choice"],setup(e,{emit:t}){const n=b.ref(xr().registerInputListener("yes-no",{cancel:{press:()=>{a(!1)}},continue:{press:()=>{a(!0)}}})),r=b.ref(null);dc({mode:"list",container:r,listener:n.value,onChosen:s=>{a(s===0)}});const o=e,i=t;function a(s){s===!0&&o.onConfirm?o.onConfirm():s===!1&&o.onRefuse&&o.onRefuse(),i("choice",s)}return b.onMounted(()=>{}),b.onUnmounted(()=>{n.value&&xr().unregisterInputListener(n.value)}),(s,c)=>(b.openBlock(),b.createBlock(Bs,{onClose:c[2]||(c[2]=()=>a(!1)),containerCssClass:"yes-no-modal"},{header:b.withCtx(()=>[R1e]),body:b.withCtx(()=>[b.createElementVNode("h3",null,b.toDisplayString(e.prompt),1),b.createElementVNode("div",{class:"flex justify-center",ref_key:"buttonsContainer",ref:r},[b.createElementVNode("button",{class:"button",onClick:c[0]||(c[0]=()=>a(!0))},"Yes"),b.createElementVNode("button",{class:"button",onClick:c[1]||(c[1]=()=>a(!1))},"No")],512)]),_:1}))}}),D1e={class:"title"},L1e={key:0},B1e={class:"saves-section"},F1e=b.createElementVNode("h3",{class:"saves-section-title"},"Auto save",-1),V1e={class:"saves-section"},z1e=b.createElementVNode("h3",{class:"saves-section-title"},"Manual Saves",-1),q1e={key:1,class:"saves-section"},U1e=b.createElementVNode("h3",{class:"saves-section-title"},"Save Slots",-1),H1e={class:"saves-container flex flex-col"},pV=b.defineComponent({__name:"save-slots",props:{mode:{}},emits:["chosen","close"],setup(e,{emit:t}){const n=e,r=b.ref(xr().registerInputListener("save-slots",{cancel:{press:()=>{R()}}})),o=b.ref(0),i=b.reactive([]),a=b.computed(()=>i.slice(0,1)),s=b.computed(()=>i.slice(1)),c=b.ref([]),l=b.ref([]),f=b.ref([]),u=b.ref([]),d=b.ref([]);b.ref({mode:"list",elements:u,listener:r.value,onlyVertical:!0,noChoosing:!0,onSelected:I=>{o.value=I}});const h=dc({mode:"list",elements:u,listener:r.value,onlyVertical:!0,noChoosing:!0,onSelected:I=>{o.value=I}}),p=b.computed(()=>{const I=o.value;return d.value.length<I+1?null:d.value[I].id}),m=b.reactive(n.mode==="load"?["Load","Delete"]:["Choose"]),v=b.computed(()=>Ct().saves.mode),g=b.reactive({prompt:"Are you sure you want to delete this save file?",saveToDelete:null,onConfirm:()=>{E(g.saveToDelete),g.saveToDelete=null},onRefuse:()=>{g.saveToDelete=null}}),y=b.reactive({prompt:"Are you sure you want to overwrite this save file?",saveToOverwrite:null,onConfirm:()=>{$(y.saveToOverwrite),y.saveToOverwrite=null},onRefuse:()=>{y.saveToOverwrite=null}}),w=t;b.onBeforeMount(()=>{lc().slots.forEach((q,N)=>{i[N]=q})});function k(){u.value=v.value==="manual"?[...l.value.map(B=>B.slotContainer),...f.value.map(B=>B.slotContainer)]:c.value.map(B=>B.slotContainer);const I=v.value==="manual"?[...a.value,...s.value]:i;d.value=I.map(B=>({id:B.id}))}b.onMounted(()=>{k()}),b.onUnmounted(()=>{h.value&&(h.value.disable(),h.value=null),r.value&&xr().unregisterInputListener(r.value)});function $(I){w("chosen",{slotId:I})}function S(I){const B=L(I);if(B){if(Ct().saves.mode==="manual"&&B.slotType==="auto"){sn().alert("Sorry","Can't delete the auto save slot!");return}g.saveToDelete=I}}function E(I){Mme(I);const B=i.find(q=>q.id===I);B&&(B.saveData=null),k()}function R(){w("close")}function D(I,B){const q=m[B];q==="Load"?$(I):q==="Delete"?S(I):q==="Choose"&&(y.saveToOverwrite=I)}function L(I){return i.find(B=>B.id===I)}return(I,B)=>(b.openBlock(),b.createBlock(Bs,{onClose:R,containerCssClass:"save-modal",cantClose:!1},{header:b.withCtx(()=>[b.createElementVNode("h3",D1e,b.toDisplayString(I.mode==="load"?"Choose a save to load":"Pick a slot to save the game"),1)]),body:b.withCtx(()=>[v.value==="manual"?(b.openBlock(),b.createElementBlock("div",L1e,[b.createElementVNode("div",B1e,[F1e,b.createVNode(b.TransitionGroup,{name:"list",tag:"div"},{default:b.withCtx(()=>[(b.openBlock(!0),b.createElementBlock(b.Fragment,null,b.renderList(a.value,q=>(b.openBlock(),b.createBlock(zx,{key:q.id,saveSlot:q,id:q.id,actions:m,onChoice:N=>D(q.id,N),inputListener:r.value,selected:p.value===q.id,ref_for:!0,ref_key:"autoSlotsElements",ref:l},null,8,["saveSlot","id","actions","onChoice","inputListener","selected"]))),128))]),_:1})]),b.createElementVNode("div",V1e,[z1e,b.createVNode(b.TransitionGroup,{name:"list",tag:"div"},{default:b.withCtx(()=>[(b.openBlock(!0),b.createElementBlock(b.Fragment,null,b.renderList(s.value,q=>(b.openBlock(),b.createBlock(zx,{key:q.id,saveSlot:q,id:q.id,actions:m,onChoice:N=>D(q.id,N),inputListener:r.value,selected:p.value===q.id,ref_for:!0,ref_key:"manualSlotsElements",ref:f},null,8,["saveSlot","id","actions","onChoice","inputListener","selected"]))),128))]),_:1})])])):(b.openBlock(),b.createElementBlock("div",q1e,[U1e,b.createElementVNode("div",H1e,[b.createVNode(b.TransitionGroup,{name:"list",tag:"div"},{default:b.withCtx(()=>[(b.openBlock(!0),b.createElementBlock(b.Fragment,null,b.renderList(i,q=>(b.openBlock(),b.createBlock(zx,{key:q.id,saveSlot:q,id:q.id,actions:m,onChoice:N=>D(q.id,N),selected:p.value===q.id,inputListener:r.value,ref_for:!0,ref_key:"saveSlotsElements",ref:c},null,8,["saveSlot","id","actions","onChoice","selected","inputListener"]))),128))]),_:1})])])),g.saveToDelete?(b.openBlock(),b.createBlock(v0,{key:2,prompt:g.prompt,onRefuse:g.onRefuse,onConfirm:g.onConfirm},null,8,["prompt","onRefuse","onConfirm"])):b.createCommentVNode("",!0),y.saveToOverwrite?(b.openBlock(),b.createBlock(v0,{key:3,prompt:y.prompt,onRefuse:y.onRefuse,onConfirm:y.onConfirm},null,8,["prompt","onRefuse","onConfirm"])):b.createCommentVNode("",!0)]),_:1}))}}),W1e=b.defineComponent({__name:"start-menu-button",props:{button:{}},emits:["click"],setup(e){return(t,n)=>(b.openBlock(),b.createElementBlock("button",{class:b.normalizeClass(["button menu-button main-menu-button large override",t.button.cssClass]),onClick:n[0]||(n[0]=r=>t.$emit("click"))},b.toDisplayString(t.button.title),3))}});class qx extends Bx{setup(t=!1){const r=t?"keydown":"keyup",o=dp(a=>{ha.emit("debouncedKeydown",a)},10,{isImmediate:!0,maxWait:10}),i=Gr().inputsContainer;i.addEventListener("keydown",a=>{ha.emit("keydown",a)}),i.addEventListener(r,a=>{o(a)})}}const ha=new qx,Ux=eo("startMenu",{state:()=>({buttons:[]}),actions:{addButtonsFromPlugins(){yn.plugins.forEach(t=>{t.startMenuButtons&&t.startMenuButtons.forEach(n=>{const r=window.narrat.app;n.popupComponent&&r.component(n.popupComponent.name,n.popupComponent.component),this.buttons.push(n)})})}}});function K1e(){SV()}function mV(){K1e(),sn().menuReturn()}async function G1e(e){if(Ct().saves.mode==="manual"){const t=ax();t&&(e=t.id)}sn().setSaveSlot(e),jV(lc().globalSave),vV(),un().runGame()}function vV(){Po().stopAll(),uu("onPressStart"),un().start(),sn().prepareToPlay(),yn.callHook("onGameStart")}async function J1e(e,t){if(Ct().saves.mode==="manual"){const n=ax();n&&(t=n.id)}if(sn().setSaveSlot(t),vV(),e.saveData){uwe({gameSave:e.saveData,globalSave:lc().globalSave}),Po().reloadAudio(e.saveData.audio);const n=un(),r=Ct().saves.runOnReload;typeof r=="string"&&await un().runLabelFunction(r),n.jumpToLabel(e.saveData.vm.lastLabel)}}const Q1e={id:"game-menu"},Y1e={id:"game-header",class:"flex flex-col justify-between items-center"},X1e={id:"game-title-container"},Z1e={id:"game-title-text"},ebe={class:"title"},Hx=b.defineComponent({__name:"StartMenu",setup(e){const t=b.ref(xr().registerInputListener("start-menu",{})),n=b.ref([]),r=b.ref(null),o=b.ref(!1),i=b.ref(!1),a=b.ref(null),s=b.ref(null),c=b.ref(!1),l=b.ref(!1),f=b.ref(null),u=Ux(),d=b.ref(!1),h=b.ref(null),p=b.computed(()=>u.buttons),m=dc({mode:"list",container:r,listener:t.value,onChosen:q=>{v(n.value[q])}});function v(q){switch(q.id){case"continue":E();break;case"new-game":g();break;case"load-game":R();break;case"exit":sn().exitGame();break;default:w(q);break}}async function g(){o.value&&Ct().saves.mode==="manual"&&!Ct().saves.disabled?l.value=!0:y()}async function y(){if(s.value===null)if(Ct().saves.mode==="manual"){const q=ax();if(!q){St("No autosave found");return}s.value=q.id}else{const q=Ame();if(!q){St("No free slot found");return}s.value=q}l.value=!1,await G1e(s.value)}function w(q){const N=p.value.findIndex(X=>X.id===q.id),W=p.value[N];W.action&&W.action(),W.popupComponent&&(d.value=W)}function k(){d.value=!1}function $(){l.value=!1}async function S(){if(!s.value)return;const q=Zh(s.value);if(!q){St("No save file found");return}J1e(q,s.value)}function E(){typeof a.value=="string"&&(s.value=a.value,S())}function R(){c.value=!0}function D({slotId:q}){const N=Zh(q);N&&N.saveData?(s.value=q,S()):g()}b.onMounted(()=>{const q=lc();q.slots.some(N=>N.saveData)&&(o.value=!0),(Ct().saves.mode==="manual"||q.slots.some(N=>!N.saveData))&&(i.value=!0),q.lastSaveSlot&&Zh(q.lastSaveSlot)&&(a.value=q.lastSaveSlot),L(),f.value=ha.on("debouncedKeydown",N=>{N.key===" "&&y(),N.key==="c"&&E()}),b.nextTick(()=>{m.select(0)}),Fi().options.defaultMusic&&(h.value=bve(Fi().options.defaultMusic))});function L(){const q=Ct().saves.disabled;a.value&&!q&&n.value.push(I({id:"continue",title:"Continue",cssClass:"continue-button"})),i.value&&n.value.push(I({id:"new-game",title:"New Game",cssClass:"start-button"})),o.value&&!q&&n.value.push(I({id:"load-game",title:"Load Game",cssClass:"continue-button"}));for(const N of p.value)n.value.push({id:N.id,title:N.text,cssClass:`${N.id}-start-menu-button`});n.value.push(I({id:"exit",title:"Exit",cssClass:"exit-button"}))}function I({id:q,title:N,cssClass:W}){const X=Ct().menuButtons[q];if(X){let H=W;return X.cssClass&&(H=`${X.cssClass} ${W}`),{id:q,title:X.text??N,cssClass:H}}return{id:q,title:N,cssClass:W}}b.onUnmounted(()=>{if(t.value&&xr().unregisterInputListener(t.value),f.value&&ha.off("debouncedKeydown",f.value),typeof h.value=="number"){const q=Fi().options.defaultMusic;wve(q,h.value)}});const B=b.computed(()=>Ct().gameTitle);return(q,N)=>(b.openBlock(),b.createElementBlock("div",Q1e,[c.value?(b.openBlock(),b.createBlock(pV,{key:0,mode:"load",onChosen:D,onClose:N[0]||(N[0]=W=>c.value=!1)})):b.createCommentVNode("",!0),l.value?(b.openBlock(),b.createBlock(v0,{key:1,prompt:"This will override your previous autosave, are you sure?",onConfirm:y,onRefuse:$})):b.createCommentVNode("",!0),b.createElementVNode("div",Y1e,[b.createElementVNode("div",X1e,[b.createElementVNode("h1",Z1e,b.toDisplayString(B.value),1)]),b.createElementVNode("div",{class:"flex flex-col start-menu-buttons-container",ref_key:"buttonsContainer",ref:r},[(b.openBlock(!0),b.createElementBlock(b.Fragment,null,b.renderList(n.value,W=>(b.openBlock(),b.createBlock(W1e,{key:W.id,button:W,onClick:X=>v(W)},null,8,["button","onClick"]))),128))],512)]),d.value?(b.openBlock(),b.createBlock(b.Teleport,{key:2,to:"#narrat-app-container"},[b.createVNode(Bs,{onClose:k,class:b.normalizeClass(`start-menu-popup-${d.value.id}`)},{header:b.withCtx(()=>[b.createElementVNode("h3",ebe,b.toDisplayString(d.value.text),1)]),body:b.withCtx(()=>[d.value.popupComponent?(b.openBlock(),b.createBlock(b.resolveDynamicComponent(d.value.popupComponent.component),{key:0,onClose:k},null,32)):b.createCommentVNode("",!0)]),_:1},8,["class"])])):b.createCommentVNode("",!0)]))}});function g0(e){const t=U0().characters[e];return t||St(`Character ${e} not found`),t}function tbe(e,t){const n=g0(e);if(n&&(t||(t="default"),n.sprites)){const r=n.sprites[t];return r==="none"?void 0:typeof r=="string"?{image:r}:r}}function gV(e){return`${U0().config.imagesPath}${e}`}function nbe(e){return typeof e=="object"&&Object.hasOwn(e,"image")}function rbe(e){return typeof e=="object"&&Object.hasOwn(e,"video")}function Wx(e){var t;return e?((t=g0(e))==null?void 0:t.style)||{}:{}}const obe=["src"],ibe=["autoplay","loop","muted"],abe=["src"],sbe=b.defineComponent({__name:"dialog-picture",props:{picture:{},video:{},character:{},pose:{}},setup(e){const t=e,n=b.computed(()=>t.video),r=b.computed(()=>Gr().layoutMode),o=b.computed(()=>{var c;const a={};if(!t.character)return{};t.character&&(a[t.character]=!0);const s=g0(t.character);return(c=s==null?void 0:s.style)!=null&&c.portraitCssClass&&(a[s.style.portraitCssClass]=!0),a}),i=b.computed(()=>{var h,p;const a=Gr(),s=Ct().layout;let c=0,l=0;const f=s.portraits;if(r.value==="vertical"){const m=((h=f.offset)==null?void 0:h.portrait)??{right:0,bottom:0};c=20+m.right,l=a.dialogHeight+m.bottom}else{const m=((p=f.offset)==null?void 0:p.landscape)??{right:0,bottom:0},v=Ct().dialogPanel.rightOffset??wx.dialogPanel.rightOffset;c=G0()-10+m.right+v,l=200+m.bottom}let u=s.portraits.width,d=s.portraits.height;return t.video&&(u=t.video.width??u,d=t.video.height??d),t.picture&&(u=t.picture.width??u,d=t.picture.height??d),{right:`${c}px`,bottom:`${l}px`,width:`${u}px`,height:`${d}px`}});return(a,s)=>{var c;return b.openBlock(),b.createElementBlock("div",{class:b.normalizeClass(["dialog-picture override",o.value]),style:b.normalizeStyle(i.value)},[a.picture?(b.openBlock(),b.createElementBlock("img",{key:0,src:b.unref(ci)(b.unref(gV)((c=a.picture)==null?void 0:c.image)),class:b.normalizeClass(["picture override",o.value])},null,10,obe)):b.createCommentVNode("",!0),n.value?(b.openBlock(),b.createElementBlock("video",{key:1,class:"picture override",autoplay:n.value.autoplay!==!1,loop:n.value.loop!==!1,muted:!!n.value.muted},[b.createElementVNode("source",{src:b.unref(ci)(b.unref(gV)(n.value.video))},null,8,abe)],8,ibe)):b.createCommentVNode("",!0)],6)}}});function cbe(){return Fi().dialogAudio}function yV(e){const t=cbe();if(t){if(t.characterAudio&&t.characterAudio[e])return t.characterAudio[e];if(t.defaultAudio)return t.defaultAudio}}function bV(e,t){if(typeof t!="string")return;const n=yV(e);return n==null?void 0:n.soundPerLetter}function lbe(e,t){if(typeof t!="string")return;const n=bV(e,t);if(!n)return;const r=n;let o="";return r.prefix&&(o+=r.prefix),o+=t,r.suffix&&(o+=r.suffix),o}function ube(e,t){if(typeof t!="string")return;const n=t.toLowerCase(),r=lbe(e,n);if(typeof r!="string")return;const o=Ua(r);if(o){const i=bV(e,n);let a=1;i.volume&&(a=i.volume);const s=Po().audioVolume("sound",r)*a;o.volume(s),o.play()}}function fbe(e){const t=yV(e);if(t!=null&&t.soundOnNewLine){const n=Ua(t.soundOnNewLine);if(n){const r=Po().audioVolume("sound",t.soundOnNewLine);n.volume(r),n.play()}}}const dbe=["innerHTML"],hbe=["innerHTML"],pbe=["innerHTML"],mbe={key:1},vbe=["onClick","innerHTML"],gbe={key:1},ybe={key:2,class:"buttons-container"},bbe=b.defineComponent({__name:"dialog-box",props:{options:{},active:{type:Boolean},inputListener:{}},setup(e,{expose:t}){const n=b.ref(null),r=b.ref(""),o=b.ref(!1),i=b.ref(null),a=b.ref(null),s=b.ref(!1),c=b.ref(null),l=b.ref(null),f=b.ref(null),u=b.ref(null),d=b.ref(null),h=e,p=b.ref(null);h.active&&(p.value=dc({mode:"list",container:n,listener:h.inputListener,onlyVertical:!0,onChosen:oe=>{xe.value&&ee.value?$(ee.value[oe]):y(" ")}})),b.onMounted(()=>{W(),s.value=!0}),b.onUnmounted(()=>{m(),B(),A({unmounted:!0})});function m(){i.value&&(clearTimeout(i.value),i.value=null),v()}function v(){p.value&&(p.value.disable(),p.value=null)}function g(oe){y(oe.key)}function y(oe){if(!xe.value){s.value&&a&&oe===" "&&A({pressedSpace:!0});return}if(xe.value&&h.options.textField&&oe==="Enter"&&L(),xe.value&&!h.options.textField){let ye=-1;switch(oe){case" ":ye=0;break;case"1":ye=0;break;case"2":ye=1;break;case"3":ye=2;break;case"4":ye=3;break;case"5":ye=4;break;case"6":ye=5;break;case"7":ye=6;break;case"8":ye=7;break}ye!==-1&&ee.value&&ye<ee.value.length?$(ee.value[ye]):ye===0&&$(ye)}}function w(){xe.value||s.value&&a&&A({pressedSpace:!0})}function k(){o.value||$(0)}function $(oe){S();let ye;typeof oe=="object"?ye=oe.originalIndex:ye=oe,sn().playerAnswered(ye)}function S(){m(),A({unmounted:!0}),o.value=!0}function E(oe){const ye={};return oe.allowed||(ye.pointerEvents="none",ye.textDecoration="line-through"),ye}function R(oe,ye){const de={index:oe+1,choice:ye.choice};let Fe='<span class="choice-index">%{$index}. </span> <span class="choice-text">%{$choice}</span>';if(aS().choiceTextTemplate&&(Fe=aS().choiceTextTemplate),ye.flag){const Y=Bz(ye.flag);Y!=null&&Y.textTemplate&&(Fe=Y.textTemplate)}return W9(de,Fe)}function D(oe){const ye={};if(oe.allowed||(ye["strike-anim"]=!0),oe.seenBefore&&(ye["seen-before"]=!0),oe.flag){const de=Bz(oe.flag);de!=null&&de.cssClass&&(ye[de.cssClass]=!0)}return ye}function L(){const oe=r.value;B(),sn().playerAnswered(oe)}function I(){h.options.textField&&(i.value=setTimeout(()=>{xe.value&&(d.value=xr().registerInputListener("text-field-input-grabber",{}),u.value&&u.value.focus())},100))}function B(){d.value&&(xr().unregisterInputListener(d.value),d.value=null)}function q(oe,ye){const de=h.options.text.substring(oe,ye);a.value.text+=de;const Fe=de.substring(0,1);return ube(h.options.styleId,Fe),ye}function N(oe){const ye=oe[0];return a.value.text+=ye,a.value.skippedChars+=ye.length,ye.length}function W(){if(!h.options.old)if(cr().playMode==="skip")X();else if(fbe(h.options.styleId),Ct().dialogPanel.animateText){a.value={text:"",index:0,startTime:Date.now(),timer:null,skippedChars:0,tags:mve(h.options.text),finished:!1};const oe=a.value;oe.timer=setInterval(()=>{K()},30)}else O.value&&(c.value=setTimeout(()=>{A()},(Ct().dialogPanel.textSpeed??a0)*h.options.text.length))}function X(){cr().playMode==="skip"&&!h.options.old&&(O.value?l.value=setTimeout(()=>{A()},100):(cr().toggleSkip(),A({unmounted:!0})))}function H(){cr().playMode==="auto"&&!h.options.old&&O.value&&xe&&k()}function K(){const oe=a.value;if(!oe)return;const ye=oe.index,de=Date.now()-oe.startTime;let Fe=!1,Y=Math.round(de/(Ct().dialogPanel.textSpeed??a0))+oe.skippedChars;if(Y>h.options.text.length&&(Fe=!0,oe.finished=!0,Y=h.options.text.length),Y!==oe.index){let Q=ye;for(;oe.tags.length>0&&Y>=oe.tags[0].index;){Q=q(Q,oe.tags[0].index);const ve=N(oe.tags.shift());Q+=ve,Y+=ve}Q=q(Q,Y),oe.index=Q}Fe&&A()}function A({unmounted:oe,pressedSpace:ye}={}){I(),setTimeout(()=>{p.value&&p.value.select(0)},10),a.value&&(a.value.timer&&clearInterval(a.value.timer),a.value=null),c.value&&!ye&&clearTimeout(c.value),l.value&&clearTimeout(l.value),f.value&&clearTimeout(f.value),!oe&&!ye&&cr().playMode!=="normal"&&O&&(f.value=setTimeout(()=>{k()},cr().playMode==="auto"?Ct().dialogPanel.timeBetweenLines??Kf.common.dialogPanel.timeBetweenLines:0))}const T=b.computed(()=>h.options.title?" &nbsp;–&nbsp; ":""),x=b.computed(()=>({...Wx(h.options.styleId).boxCss})),O=b.computed(()=>!ee.value&&!h.options.textField),j=b.computed(()=>{const oe={};return h.options.title&&(oe["dialog-box-followup"]=!0),h.options.old?oe["dialog-box-old"]=!0:oe["dialog-box-new"]=!0,oe}),C=b.computed(()=>{const oe=Wx(h.options.styleId);return{color:oe.color,...oe.nameCss}}),_=b.computed(()=>Wx(h.options.styleId).textCss),F=b.computed(()=>a.value?a.value.text:h.options.text),ee=b.computed(()=>{if(h.options.choices)return h.options.choices}),ce=b.computed(()=>cr().playMode==="skip"),_e=b.computed(()=>cr().playMode==="auto"),xe=b.computed(()=>h.active&&s.value&&!o.value&&!f.value&&!a.value&&h.options.interactive&&!Ie.value),se=sn(),Ie=b.computed(()=>se.paused);return b.watch(()=>h.options,(oe,ye)=>{!ye.old&&oe.old&&a&&A({unmounted:!0})}),b.watch(ce,(oe,ye)=>{oe&&!ye&&X()}),b.watch(_e,(oe,ye)=>{oe&&!ye&&H()}),t({keyboardEvent:g}),(oe,ye)=>{const de=b.resolveDirective("visible");return b.openBlock(),b.createElementBlock("div",{class:b.normalizeClass(["dialog-box w-full override",j.value]),style:b.normalizeStyle(x.value)},[b.createElementVNode("div",{class:"dialog-content",onClick:w},[oe.options.title?(b.openBlock(),b.createElementBlock("span",{key:0,class:"dialog-title override",style:b.normalizeStyle(C.value),innerHTML:oe.options.title},null,12,dbe)):b.createCommentVNode("",!0),b.createElementVNode("span",{class:"dialog-text dialog-separator override",style:b.normalizeStyle(_.value),innerHTML:T.value},null,12,hbe),b.createElementVNode("span",{class:b.normalizeClass(["dialog-text override",oe.options.cssClass]),style:b.normalizeStyle(_.value),innerHTML:F.value},null,14,pbe),oe.options.old?b.createCommentVNode("",!0):b.withDirectives((b.openBlock(),b.createElementBlock("div",mbe,[ee.value?(b.openBlock(),b.createElementBlock("div",{key:0,class:"dialog-choices",ref_key:"choicesDiv",ref:n},[(b.openBlock(!0),b.createElementBlock(b.Fragment,null,b.renderList(ee.value,(Fe,Y)=>(b.openBlock(),b.createElementBlock("p",{key:Y,style:b.normalizeStyle(E(Fe)),class:b.normalizeClass([D(Fe),"dialog-choice override"]),onClick:Q=>$(Fe),innerHTML:R(Y,Fe)},null,14,vbe))),128))],512)):oe.options.textField?(b.openBlock(),b.createElementBlock("div",gbe,[b.withDirectives(b.createElementVNode("input",{autofocus:"",type:"text",class:"label-input input",ref_key:"playerInput",ref:u,id:"player-input-field","onUpdate:modelValue":ye[0]||(ye[0]=Fe=>r.value=Fe)},null,512),[[b.vModelText,r.value]]),b.createElementVNode("button",{onClick:L,class:"button",id:"player-input-submit"}," Submit ")])):(b.openBlock(),b.createElementBlock("div",ybe,[b.createElementVNode("div",{onClick:ye[1]||(ye[1]=Fe=>$(0)),ref:"continue",class:"interact-button button override"}," Continue ",512)]))])),[[de,xe.value]])])],6)}}}),wbe={key:0,class:"auto-play-feedback-container"},kbe=b.defineComponent({__name:"AutoPlayFeedback",setup(e){const t=cr(),n=b.computed(()=>t.playMode==="auto"),r=b.computed(()=>t.playMode==="skip"),o=b.computed(()=>n.value?"auto-play-feedback-auto":r.value?"auto-play-feedback-skip":{}),i=b.computed(()=>n.value?"Auto Play":r.value?"Skip":"");return(a,s)=>i.value?(b.openBlock(),b.createElementBlock("div",wbe,[b.createElementVNode("div",{class:b.normalizeClass(["auto-play-feedback",o.value])},b.toDisplayString(i.value),3)])):b.createCommentVNode("",!0)}}),xbe=b.createElementVNode("div",{class:"anchor"},null,-1),Kx=b.defineComponent({__name:"game-dialog",setup(e){const t=b.computed(()=>Gr().layoutMode),n=b.computed(()=>xr().inGameInputListener),r=b.ref(sn().inScript),o=b.ref(null),i=Gr(),a=un(),s=b.computed(()=>a.stack),c=cr(),l=b.computed(()=>c.dialog),f=b.ref(null),u=b.ref(null),d=b.ref(null),h=b.computed(()=>{let B="0px";const q=Ct().layout.dialogBottomPadding;return typeof q=="number"?B=`${q}px`:typeof q=="string"&&(B=q),{paddingBottom:B}}),p=b.computed(()=>{if(l.value.length>0)return l.value[l.value.length-1]}),m=b.computed(()=>{if(p.value)return p.value.speaker}),v=b.computed(()=>{if(p.value)return p.value.pose}),g=b.computed(()=>{if(p.value){const B=m.value;let q=v.value;return B?(q||(q="idle"),q):void 0}}),y=b.computed(()=>{if(!g.value)return;const B=m.value;return tbe(B,g.value)}),w=b.computed(()=>{const B=y.value;if(nbe(B))return B}),k=b.computed(()=>{const B=y.value;if(rbe(B))return B}),$=b.computed(()=>i.dialogWidth),S=b.computed(()=>sn().inScript);b.watch(S,B=>{B?r.value=!0:cr().playMode!=="normal"?(cr().playMode==="skip"&&(cr().playMode="normal"),o.value=setTimeout(()=>{r.value=!1},500)):r.value=!1}),b.onMounted(()=>{if(n.value){const q=n.value;q.actions.autoPlay={press:()=>{cr().toggleAutoPlay()}},q.actions.skip={press:()=>{cr().toggleSkip()}}}const B=q=>{u.value&&u.value.keyboardEvent&&u.value.keyboardEvent(q)};B.value=ha.on("debouncedKeydown",B)}),b.onUnmounted(()=>{n.value&&(delete n.value.actions.autoPlay,delete n.value.actions.skip),d.value&&ha.off("debouncedKeydown",d.value),o.value&&clearTimeout(o.value)});const E=b.computed(()=>{let B;const q=`${Gr().dialogHeight}px`,N={};if(Gr().overlayMode){N.position="absolute";const W=Ct().dialogPanel.rightOffset??Kf.common.dialogPanel.rightOffset;N.right=`${W}px`;const X=Ct().dialogPanel.bottomOffset??Kf.common.dialogPanel.bottomOffset;N.bottom=`${X}px`}return{...N,width:t.value==="horizontal"?`${$.value}px`:"100%",height:q,transform:B,transformOrigin:"right"}});function R(){cr().toggleAutoPlay()}function D(){cr().toggleSkip()}function L(B,q){const N=g0(B.speaker);let W=(N==null?void 0:N.name)??"Missing Character";return q>=1&&l.value[q-1].speaker===B.speaker&&(W=void 0),B.choices&&B.choices.forEach(X=>{X.choice=$s(X.choice)}),{title:W??"",text:B.text,cssClass:B.cssClass,styleId:B.speaker,choices:B.choices,old:q<l.value.length-1,interactive:B.interactive,textField:B.textField}}function I(B){return B===c.dialog.length-1&&s.value.length>0}return b.watch(l.value,B=>{if(f.value){const q=f.value;q.scrollTop=q.scrollHeight+1e8}}),(B,q)=>(b.openBlock(),b.createElementBlock(b.Fragment,null,[b.createVNode(kbe),b.createVNode(b.Transition,{name:"fade"},{default:b.withCtx(()=>[(w.value||k.value)&&b.unref(i).showDialog?(b.openBlock(),b.createBlock(sbe,{key:0,picture:w.value,video:k.value,character:m.value,pose:v.value},null,8,["picture","video","character","pose"])):b.createCommentVNode("",!0)]),_:1}),b.createVNode(b.Transition,{name:"dialog-transition"},{default:b.withCtx(()=>[b.unref(i).showDialog?(b.openBlock(),b.createElementBlock("div",{key:0,class:"dialog override",ref_key:"dialogRef",ref:f,style:b.normalizeStyle(E.value)},[b.createVNode(b.TransitionGroup,{name:"list",tag:"div",class:"dialog-container w-full override",style:b.normalizeStyle(h.value)},{default:b.withCtx(()=>[(b.openBlock(!0),b.createElementBlock(b.Fragment,null,b.renderList(l.value,(N,W)=>(b.openBlock(),b.createBlock(bbe,{ref_for:!0,ref:X=>u.value=X,key:N.id,options:L(N,W),active:I(W),inputListener:n.value},null,8,["options","active","inputListener"]))),128))]),_:1},8,["style"]),(b.openBlock(),b.createBlock(b.Teleport,{to:"#narrat-app"},[b.createElementVNode("div",{class:"auto-skip-buttons flex"},[b.createElementVNode("div",{class:"button menu-toggle-button auto-button auto",onClick:R}," Auto "),b.createElementVNode("div",{class:"button menu-toggle-button auto-button skip",onClick:D}," Skip ")])])),xbe],4)):b.createCommentVNode("",!0)]),_:1})],64))}}),_be=["id"],Sbe=["src"],jbe={class:"tab-title"},wV=b.defineComponent({__name:"tab-selector",props:{tab:{},active:{type:Boolean}},emits:["click"],setup(e,{emit:t}){const n=e,r=t,o=b.computed(()=>n.active?"tab-active":"tab-inactive");function i(){r("click")}return(a,s)=>(b.openBlock(),b.createElementBlock("div",{class:b.normalizeClass(["tab",o.value]),id:`tab-${a.tab.id}`,onClick:i},[b.createElementVNode("div",{class:b.normalizeClass(["tab-title-container",a.active?"active":""])},[a.tab.icon?(b.openBlock(),b.createElementBlock("img",{key:0,src:a.tab.icon,alt:"tab icon",class:"tab-icon"},null,8,Sbe)):b.createCommentVNode("",!0),b.createElementVNode("span",jbe,b.toDisplayString(a.tab.label),1)],2)],10,_be))}}),Cbe={class:"tabs-controller"},$be={key:0,class:"tabs-controller__tabs"},Tbe={key:1,class:"tab-content"},Obe={key:2},Ebe=[b.createElementVNode("div",{class:"tab-content__empty"},[b.createElementVNode("p",null,"No tab selected")],-1)],Abe=b.defineComponent({__name:"TabsController",props:{tabs:{},defaultTab:{}},emits:["tab-change","close"],setup(e,{emit:t}){const n=b.ref(xr().registerInputListener("tabs-controller",{cancel:{press:()=>{r("close")}},system:{press:()=>{r("close")}},menu:{press:()=>{r("close")}},previousTab:{press:()=>{i.value>0&&a(i.value-1)}},nextTab:{press:()=>{i.value<o.tabs.length-1&&a(i.value+1)}}})),r=t,o=e,i=b.ref(o.defaultTab);function a(c){i.value=c,r("tab-change",c)}const s=b.computed(()=>o.tabs[i.value]);return b.onUnmounted(()=>{n.value&&(xr().unregisterInputListener(n.value),n.value=null)}),(c,l)=>(b.openBlock(),b.createElementBlock("div",Cbe,[c.tabs.length>1?(b.openBlock(),b.createElementBlock("div",$be,[(b.openBlock(!0),b.createElementBlock(b.Fragment,null,b.renderList(c.tabs,(f,u)=>(b.openBlock(),b.createBlock(wV,{key:f.id,tab:f,active:u===i.value,onClick:()=>a(u),inputListener:n.value},null,8,["tab","active","onClick","inputListener"]))),128))])):b.createCommentVNode("",!0),s.value?(b.openBlock(),b.createElementBlock("div",Tbe,[s.value?(b.openBlock(),b.createBlock(b.resolveDynamicComponent(s.value.component),{key:0,inputListener:n.value,onClose:l[0]||(l[0]=f=>c.$emit("close"))},null,40,["inputListener"])):b.createCommentVNode("",!0)])):(b.openBlock(),b.createElementBlock("div",Obe,Ebe))]))}}),Pbe={class:"menu-container menu-toggle"},Mbe=["onClick","id"],Ibe={class:"title"},Gx=b.defineComponent({__name:"menu-buttons",setup(e){const t=No(),n=b.ref(null);b.onMounted(()=>{yn.callHook("onGameMounted")}),b.onUnmounted(()=>{n.value&&ha.off("keydown",n.value),yn.callHook("onGameUnmounted")});function r(f){No().activeMenu=f}const o=b.computed(()=>t.menus),i=b.computed(()=>t.menu),a=b.computed(()=>{var f;return(((f=i.value)==null?void 0:f.tabs)??[]).filter(u=>u.condition?u.condition():!0).map(u=>({id:u.id,label:u.text,component:u.component}))});function s(){t.closeMenu()}function c(f){t.setActiveTab(f)}function l(){return s()}return(f,u)=>(b.openBlock(),b.createElementBlock("div",Pbe,[(b.openBlock(!0),b.createElementBlock(b.Fragment,null,b.renderList(o.value,(d,h)=>(b.openBlock(),b.createElementBlock("button",{key:d.id,onClick:p=>r(d.id),id:d.cssId??`${h}-menu-button`,class:"button menu-toggle-button"},b.toDisplayString(d.label),9,Mbe))),128)),i.value?(b.openBlock(),b.createBlock(b.Teleport,{key:0,to:"#narrat-app-container"},[b.createVNode(Bs,{containerCssClass:{[i.value.cssClass]:!0,"menu-modal":!0},onClose:s},{header:b.withCtx(()=>{var d;return[b.createElementVNode("h3",Ibe,b.toDisplayString(((d=b.unref(t).tab)==null?void 0:d.text)??i.value.label),1)]}),body:b.withCtx(()=>[b.createVNode(Abe,{onTabChange:c,onClose:l,tabs:a.value,defaultTab:i.value.activeTab},null,8,["tabs","defaultTab"])]),_:1},8,["containerCssClass"])])):b.createCommentVNode("",!0)]))}});function kV(e){const t={};return e.selected&&(t.selected=!0),e.clickable&&e.viewportClickable&&!e.transitioning&&(t.interactable=!0),(!e.clickable||!e.viewportClickable)&&(t.disabled=!0),e.transitioning&&(t.transitioning=!0),e.greyed&&(t.greyed=!0),e.hidden&&(t.hidden=!0),e.cssClass&&(t[e.cssClass]=!0),t}function Nbe(e,t,n){return{selected:t,clickable:e.onClick!==void 0,viewportClickable:m0(e),transitioning:n,greyed:!1,hidden:!1,cssClass:e.cssClass}}function Rbe(e,t,n){const r=vl(e),o=da().getButtonState(e);return{selected:t,clickable:da().isButtonInteractible(e),viewportClickable:m0(r),transitioning:n,greyed:o==="greyed",hidden:o==="hidden"||o===!1,cssClass:r.cssClass}}function Dbe(e,t,n){return kV(Rbe(e,t,n))}function Lbe(e,t,n){return kV(Nbe(e,t,n))}const Bbe=["id"],Fbe=["innerHTML"],Vbe=b.defineComponent({__name:"screen-object",props:{screenObject:{},layerSelected:{type:Boolean},transitioning:{type:Boolean},activeInteractive:{}},setup(e){const t=e,n=Bi();function r(s){t.transitioning||t.screenObject.onClick&&n.clickObject(s)}const o=b.computed(()=>{if(!t.layerSelected)return!1;const s=t.activeInteractive;return s.type==="screenObject"&&s.id===t.screenObject.id}),i=b.computed(()=>Lbe(t.screenObject,o.value,t.transitioning)),a=b.computed(()=>{const s={};t.screenObject.opacity!==1&&(s.opacity=t.screenObject.opacity);let c=t.screenObject.x,l=t.screenObject.y,f=t.screenObject.width,u=t.screenObject.height;if(t.screenObject.anchor){const h=t.screenObject.anchor;c=t.screenObject.x-f*h.x,l=t.screenObject.y-u*h.y,s.transformOrigin=`${h.x*100}% ${h.y*100}%`}t.screenObject.scale&&(f=f*t.screenObject.scale,u=u*t.screenObject.scale);const d={...s,left:`${c}px`,top:`${l}px`,width:`${f}px`,height:`${u}px`};return c1e(t.screenObject)&&(d.backgroundImage=`url(${fd(t.screenObject.image)})`),d});return(s,c)=>{const l=b.resolveComponent("ScreenObject",!0);return b.openBlock(),b.createElementBlock("div",{tabindex:"-1",class:b.normalizeClass(["viewport-object",i.value]),id:`viewport-object-${t.screenObject.id}`,onClick:c[0]||(c[0]=f=>r(s.screenObject)),style:b.normalizeStyle(a.value)},[b.createElementVNode("span",{innerHTML:t.screenObject.text?b.unref($s)(t.screenObject.text):void 0},null,8,Fbe),(b.openBlock(!0),b.createElementBlock(b.Fragment,null,b.renderList(t.screenObject.children,f=>(b.openBlock(),b.createBlock(l,{transitioning:s.transitioning,key:f.id,screenObject:f},null,8,["transitioning","screenObject"]))),128))],14,Bbe)}}}),zbe=["id","innerHTML"],qbe=b.defineComponent({__name:"viewport-button",props:{id:{},layerSelected:{type:Boolean},transitioning:{type:Boolean},activeInteractive:{}},setup(e){const t=e,n=da();b.computed(()=>n.getButtonState(t.id));const r=b.computed(()=>vl(t.id)),o=r.value.background?fd(r.value.background):null,i=b.computed(()=>{if(!t.layerSelected)return!1;const f=t.activeInteractive;return f.type==="button"&&f.id===t.id});b.computed(()=>n.isButtonClickable(t.id));const a=b.computed(()=>{const f=r.value.text??"";return $s(f)}),s=b.computed(()=>Dbe(t.id,i.value,t.transitioning)),c=b.computed(()=>{const f={};r.value.position.width&&(f.width=`${r.value.position.width}px`),r.value.position.height&&(f.height=`${r.value.position.height}px`),r.value.background&&(f.backgroundImage=`url(${o})`);let u=r.value.position.left,d=r.value.position.top;return r.value.anchor&&(u=r.value.position.left-r.value.position.width*r.value.anchor.x,d=r.value.position.top-r.value.position.height*r.value.anchor.y),{...f,left:`${u}px`,top:`${d}px`}});function l(){n.clickOnButton(t.id)}return(f,u)=>(b.openBlock(),b.createElementBlock("div",{tabindex:"-1",class:b.normalizeClass(["viewport-button",s.value]),id:`viewport-button-${f.id}`,onClick:u[0]||(u[0]=d=>l()),style:b.normalizeStyle(c.value),innerHTML:a.value},null,14,zbe))}}),Ube=["id"],Hbe=["id","loop","muted"],Wbe=["src"],Kbe=["id"],Jx=b.defineComponent({__name:"screen-layer",props:{layer:{},layerIndex:{},transitioning:{type:Boolean},activeInteractive:{}},setup(e){const t=e,n=sn(),r=Bi(),o=b.computed(()=>!!(t.activeInteractive&&t.activeInteractive.layer===t.layerIndex)),i=b.computed(()=>r.tree.filter(v=>v.layer===t.layerIndex)),a=b.computed(()=>Ct().layout.backgrounds.width),s=b.computed(()=>Ct().layout.backgrounds.height),c=b.computed(()=>t.layer),l=b.computed(()=>{const v=ud(c.value);return v||St(`Screen ${c.value} doesn't have a config`),v}),f=b.computed(()=>n.isInGame),u=b.computed(()=>l.value.buttons||[]),d=b.computed(()=>l.value.video),h=b.computed(()=>({width:`${a.value}px`,height:`${s.value}px`})),p=b.computed(()=>{let v;return l.value.background!==bx&&(v=`url(${fd(l.value.background)})`),{backgroundImage:v,position:"absolute",left:0,top:0,width:`${a.value}px`,height:`${s.value}px`}}),m=b.computed(()=>({position:"absolute",left:0,top:0,width:`${a.value}px`,height:`${s.value}px`}));return(v,g)=>f.value?(b.openBlock(),b.createElementBlock("div",{key:0,class:"viewport-layer",id:`viewport-layer-${c.value}`,style:b.normalizeStyle(h.value)},[d.value?(b.openBlock(),b.createElementBlock("video",{key:0,class:"viewport-layer-background",id:`viewport-layer-background-${c.value}`,style:b.normalizeStyle(m.value),autoplay:"",loop:d.value.loop!==!1,muted:!!d.value.muted},[b.createElementVNode("source",{src:b.unref(ci)(l.value.background)},null,8,Wbe)],12,Hbe)):(b.openBlock(),b.createElementBlock("div",{key:1,class:"viewport-layer-background",id:`viewport-layer-background-${c.value}`,style:b.normalizeStyle(p.value)},null,12,Kbe)),(b.openBlock(!0),b.createElementBlock(b.Fragment,null,b.renderList(u.value,y=>(b.openBlock(),b.createBlock(qbe,{key:y,id:y,layerSelected:o.value,transitioning:v.transitioning,activeInteractive:v.activeInteractive},null,8,["id","layerSelected","transitioning","activeInteractive"]))),128)),(b.openBlock(!0),b.createElementBlock(b.Fragment,null,b.renderList(i.value,y=>(b.openBlock(),b.createBlock(Vbe,{key:y.id,screenObject:y,transitioning:v.transitioning,layerSelected:o.value,activeInteractive:v.activeInteractive},null,8,["screenObject","transitioning","layerSelected","activeInteractive"]))),128))],12,Ube)):b.createCommentVNode("",!0)}}),Gbe=b.defineComponent({__name:"NarratTransition",props:{name:{type:String,required:!0},duration:{type:Number,required:!0},delay:Number},emits:["complete"],setup(e,{emit:t}){b.useSlots();const n=t,r=e,o=b.ref("start"),i=b.reactive({oldSlotClasses:{},oldSlotStyle:{},newSlotClasses:{},newSlotStyle:{}});return b.onMounted(async()=>{const a=`narrat-transition-${r.name}`;i.newSlotClasses={[`${a}-enter-from`]:!0},i.oldSlotClasses={[`${a}-leave-active`]:!0},await ki(30),i.oldSlotStyle={transitionDuration:`${r.duration/1e3}s`},i.newSlotStyle={transitionDuration:`${r.duration/1e3}s`},i.oldSlotClasses[`${a}-leave-to`]=!0,i.newSlotClasses[`${a}-enter-active`]=!0,await ki(r.delay??0),delete i.newSlotClasses[`${a}-enter-from`],await ki(r.duration),o.value="end",n("complete")}),(a,s)=>(b.openBlock(),b.createElementBlock(b.Fragment,null,[o.value!=="end"?(b.openBlock(),b.createElementBlock("div",{key:0,class:b.normalizeClass(["transition-holder",i.oldSlotClasses]),style:b.normalizeStyle(i.oldSlotStyle)},[b.renderSlot(a.$slots,"oldElement")],6)):b.createCommentVNode("",!0),b.createElementVNode("div",{class:b.normalizeClass(["transition-holder",i.newSlotClasses]),style:b.normalizeStyle(i.newSlotStyle)},[b.renderSlot(a.$slots,"newElement")],6)],64))}});function xV(e,t,n){return e<t?t:e>n?n:e}const Qx=b.defineComponent({__name:"screens",setup(e){const t=b.computed(()=>xr().inGameInputListener),n=sn(),r=da(),o=Bi(),i=b.ref(0),a=b.computed(()=>r.nonEmptyLayers),s=b.computed(()=>{const p=[];return a.value.reduce((m,v,g)=>{const w=ud(v.screen).buttons;if(w)for(const $ of w)r.isButtonClickable($)&&m.push({id:$,type:"button",layer:g});const k=o.tree.filter($=>$.layer===g);for(const $ of k)o.isScreenObjectClickable($)&&m.push({id:$.id,type:"screenObject",layer:g});return m},p)}),c=b.computed(()=>{if(s.value.length===0)return null;let p=i.value;return p>s.value.length-1&&(p=s.value.length-1),s.value[p]}),l=b.computed(()=>Ct().layout.backgrounds.width),f=b.computed(()=>Ct().layout.backgrounds.height),u=b.computed(()=>n.isInGame);function d(p){r.finishTransition(p)}const h=b.computed(()=>{const p=l.value;return{height:`${f.value}px`,width:`${p}px`}});return b.onMounted(()=>{b.nextTick(()=>{if(t.value){const p=t.value.actions;p.previousTab={press:()=>{i.value>0?i.value--:i.value=s.value.length-1,i.value=xV(i.value,0,s.value.length-1)}},p.left=p.previousTab,p.nextTab={press:()=>{i.value<s.value.length-1?i.value++:i.value=0,i.value=xV(i.value,0,s.value.length-1)}},p.right=p.nextTab,p.viewportSelect={press:()=>{if(c.value){const m=c.value;m.type==="button"?r.clickOnButton(m.id):m.type==="screenObject"&&o.clickObject(o.getObject(m.id))}}}}})}),b.onUnmounted(()=>{if(t.value){const p=t.value;delete p.actions.previousTab,delete p.actions.left,delete p.actions.nextTab,delete p.actions.right}}),(p,m)=>u.value?(b.openBlock(),b.createElementBlock("div",{key:0,class:"viewport",id:"narrat-viewport",style:b.normalizeStyle(h.value)},[(b.openBlock(!0),b.createElementBlock(b.Fragment,null,b.renderList(a.value,(v,g)=>(b.openBlock(),b.createElementBlock("div",{key:v.screen??"",class:"layer-container"},[v.transition?(b.openBlock(),b.createBlock(Gbe,{key:0,name:v.transition.transition,duration:v.transition.duration,delay:v.transition.delay,onComplete:()=>d(g)},{oldElement:b.withCtx(()=>[v.transition.oldScreen?(b.openBlock(),b.createBlock(Jx,{key:0,layer:v.transition.oldScreen,layerIndex:g,transitioning:!0},null,8,["layer","layerIndex"])):b.createCommentVNode("",!0)]),newElement:b.withCtx(()=>[v.screen?(b.openBlock(),b.createBlock(Jx,{key:0,layer:v.screen,layerIndex:g,transitioning:!0},null,8,["layer","layerIndex"])):b.createCommentVNode("",!0)]),_:2},1032,["name","duration","delay","onComplete"])):v.screen?(b.openBlock(),b.createBlock(Jx,{key:1,layer:v.screen,layerIndex:g,transitioning:!1,activeInteractive:c.value},null,8,["layer","layerIndex","activeInteractive"])):b.createCommentVNode("",!0)]))),128))],4)):b.createCommentVNode("",!0)}}),Si=eo("hud",{state:()=>({hudStats:{},visible:!0}),actions:{updateConfig(e){for(const t in e.hudStats)this.hudStats[t]||(this.hudStats[t]={value:e.hudStats[t].startingValue})},reset(e){this.$reset(),this.updateConfig(e)},setStat(e,t){this.hudStats[e].value=t,this.getStat(e).value<(wu(e).minValue??0)&&(this.hudStats[e].value=wu(e).minValue??0),this.getStat(e).value>(wu(e).maxValue??1/0)&&(this.hudStats[e].value=wu(e).maxValue??1/0)},addStat(e,t){this.setStat(e,this.getStatValue(e)+t)},getStat(e){return this.hudStats[e]},getStatValue(e){return this.hudStats[e].value},generateSaveData(){return{hudStats:Xn(this.hudStats),visible:this.visible}},loadSaveData(e){this.hudStats=fu(this.hudStats,e.hudStats),this.visible=e.visible},setVisibility(e){this.visible=e}}}),Jbe=b.defineComponent({data(){return{}},methods:{getStatImage(e){return ci(this.statsConfig[e].icon)},formatStat(e,t){var s;const n=wu(e),r=n.decimals??2,o=Math.floor(t*10**r)/10**r,i={};(s=n.formatting)!=null&&s.style&&(i.style=n.formatting.style,n.formatting.style==="currency"&&(i.currency=n.formatting.currency??"USD",i.currencyDisplay="narrowSymbol"),n.formatting.style==="unit"&&(i.unit=n.formatting.unit??"day"));let a;try{a=o.toLocaleString(void 0,i)}catch(c){St(`Error formatting HUD stat, probably using an invalid config: ${c}`),console.error(c),a=o.toLocaleString()}return a},statPrefix(e){const t=wu(e);return t.prefix??(t.suffix||t.hideName?"":t.name)},statSuffix(e){return wu(e).suffix??""}},computed:{...rp(Si,["hudStats"]),...rp(Gr,["layoutMode"]),statsConfig(){return Ct().hudStats},stats(){return this.hudStats},hudStyle(){let e="0";return this.layoutMode==="horizontal"&&(e=`${G0()+(Ct().dialogPanel.rightOffset??Kf.common.dialogPanel.rightOffset)}px`),{right:e}},hasHud(){return Si().visible===!1?!1:Object.keys(Si().hudStats).length>0}}}),Qbe=["src"],Ybe=["innerHTML"],Xbe=["innerHTML"];function Zbe(e,t,n,r,o,i){return e.hasHud?(b.openBlock(),b.createElementBlock("div",{key:0,class:"hud",style:b.normalizeStyle(e.hudStyle)},[(b.openBlock(!0),b.createElementBlock(b.Fragment,null,b.renderList(e.stats,(a,s)=>(b.openBlock(),b.createElementBlock("div",{key:s,class:"hud-stat"},[b.createElementVNode("img",{class:"hud-icon",src:e.getStatImage(s)},null,8,Qbe),b.createElementVNode("span",{class:"bold hud-text",innerHTML:e.statPrefix(s)},null,8,Ybe),b.createElementVNode("span",null,b.toDisplayString(e.formatStat(s,a.value)),1),e.statSuffix?(b.openBlock(),b.createElementBlock("span",{key:0,innerHTML:e.statSuffix(s)},null,8,Xbe)):b.createCommentVNode("",!0)]))),128))],4)):b.createCommentVNode("",!0)}const Yx=Xa(Jbe,[["render",Zbe]]),Xx=b.defineComponent({__name:"in-game",setup(e){const t=xr(),n=b.computed(()=>t.inGameInputListener),r=sn(),o=Gr(),i=b.computed(()=>o.layoutMode),a=b.computed(()=>r.saving),s=b.ref(null),c=cr(),l=b.ref(null),f=b.computed(()=>a.value&&!a.value.withPrompt||a.value&&s.value),u=b.computed(()=>{let m="row";return i.value==="vertical"&&(m="column"),{flexDirection:m}});function d(m){if(s.value=null,m===null){e_(m,!1);return}e_(m,!0)}function h(){s.value=!0}function p(){s.value=!1,e_(null,!1),s.value=null}return b.onBeforeMount(()=>{t.createInGameInputListener()}),b.onMounted(()=>{l.value=ha.on("debouncedKeydown",m=>{sn().debugMode||((m.key==="a"||m.key==="A")&&c.toggleAutoPlay(),(m.key==="s"||m.key==="S")&&c.toggleSkip())})}),b.onUnmounted(()=>{n.value&&t.removeInGameInputListener(),l.value&&ha.off("debouncedKeydown",l.value)}),b.computed(()=>Si().visible===!1?!1:Object.keys(Si().hudStats).length>0),(m,v)=>(b.openBlock(),b.createElementBlock("div",{class:"game",style:b.normalizeStyle(u.value)},[b.createVNode(Yx),b.createVNode(Gx),b.createVNode(Qx),b.createVNode(Kx),f.value?(b.openBlock(),b.createBlock(pV,{key:0,mode:"pick",onChosen:d,onClose:v[0]||(v[0]=()=>d(null))})):b.createCommentVNode("",!0),a.value&&a.value.withPrompt&&s.value===null?(b.openBlock(),b.createBlock(v0,{key:1,prompt:"Would you like to save the game?",onConfirm:h,onRefuse:p})):b.createCommentVNode("",!0)],4))}}),ewe={class:"chapter-title-scene"},twe=["innerHTML"],nwe=["innerHTML"],rwe=b.defineComponent({__name:"chapter-title",props:{options:{}},setup(e){const t=e,n=b.ref(null);function r(){n.value=null,_i().changeScene("playing"),un().jumpToLabel(t.options.next_label)}return b.onMounted(()=>{n.value=setTimeout(r,t.options.duration??2e3)}),b.onUnmounted(()=>{n.value&&(clearTimeout(n.value),n.value=null)}),(o,i)=>(b.openBlock(),b.createElementBlock("div",ewe,[b.createElementVNode("h1",{class:"title chapter-title",innerHTML:t.options.title},null,8,twe),t.options.subtitle?(b.openBlock(),b.createElementBlock("h2",{key:0,class:"subtitle chapter-subtitle",innerHTML:t.options.subtitle},null,8,nwe)):b.createCommentVNode("",!0)]))}}),_V={"engine-splash":{id:"engine-splash",component:b.shallowRef(Lx),props:{}},"game-splash":{id:"game-splash",component:b.shallowRef(Vx),props:{}},"start-menu":{id:"start-menu",component:b.shallowRef(Hx),props:{}},playing:{id:"playing",component:b.shallowRef(Xx),props:{}},"chapter-title":{id:"chapter-title",component:b.shallowRef(rwe),props:{}}};let As={};function owe(e){As=e}function iwe(){_V["engine-splash"].onFinished=()=>{_i().onEngineSplashFinished()},_i().scenes=_V}function awe(){return As}function SV(){for(const e in As){const t=As[e],n=t.store();let r;u1e(t)&&(r=pr()[t.config]),n.reset&&n.reset(r)}yn.plugins.forEach(e=>{e.reset&&e.reset()})}function swe(){const e={},t={};for(const n in As){const r=As[n];if(dV(r)){const o=r.store();o.generateSaveData?e[r.save]=o.generateSaveData():St(`Store ${n} has no generateSaveData method. Trying to generate save data for ${r.save}`)}if(hV(r)){const o=r.store();o.generateGlobalSaveData?t[r.globalSave]=o.generateGlobalSaveData():St(`Store ${n} has no generateGlobalSaveData method. Trying to generate save data for ${r.globalSave}`)}}return yn.plugins.forEach(n=>{n.save&&(e.plugins[n.pluginId]=n.save())}),yn.customStores().forEach(([n,r])=>{if(r.save){const o=r.save();o&&(o.customStores[n]=o)}}),{gameSave:e,globalSave:t}}function cwe(e){for(const t in As){const n=As[t];if(dV(n)){const r=n.store();r.loadSaveData?r.loadSaveData(e[n.save]):St(`Store ${t} has no loadSaveData method. Trying to load save data for ${n.save}`)}}yn.plugins.forEach(t=>{t.load&&e.plugins[t.pluginId]&&t.load(e.plugins[t.pluginId])}),yn.customStores().forEach(([t,n])=>{n.load&&n.load(e.customStores[t])})}function jV(e){for(const t in As){const n=As[t];if(hV(n)){const r=n.store();r.loadGlobalSaveData?r.loadGlobalSaveData(e[n.globalSave]):St(`Store ${t} has no loadGlobalSaveData method. Trying to load global save data for ${n.globalSave}`)}}}function lwe(e){cwe(e.gameSave),jV(e.globalSave)}function Zx({slotId:e,name:t}){const n=sn(),r=e??n.saveSlot;n.saveData=Rme({slot:r,name:t,extractedSave:swe()})}function uwe(e){lwe(e)}function CV(){un().globalData={},lc().globalSave.data={},Zx({})}function $V({saveName:e,withPrompt:t}){return new Promise(n=>{un().hasJumped?sn().startManualSave(n,e,t):n()})}function e_(e,t){var r;const n=sn();if(!n.saving){St("No saving in progress!");return}if(!t||!e){n.cancelManualSave();return}n.saveData?(Dme(n.saveData,Su(n.playTime.start,n.playTime.previousPlaytime),e.slotId,(r=n.saving)==null?void 0:r.name),n.alert("Success","Game saved!")):St("There was no data to save!"),n.cancelManualSave()}const un=eo("vm",{state:()=>({stack:[],data:{},globalData:{},lastLabel:"main",script:{},labelStack:["main"],commandsWaitingForPlayerAnswer:[],hasJumped:!1}),actions:{generateSaveData(){return{lastLabel:this.lastLabel,data:lS(this.data,e=>fV(e)?{_entityType:e._entityType,id:e.id}:e)}},generateGlobalSaveData(){return{data:Xn(this.globalData)}},loadSaveData(e){this.lastLabel=e.lastLabel,this.data=e.data,this.findEntitiesInData(this.data)},loadGlobalSaveData(e){this.globalData=e.data},findEntitiesInData(e){cV(this.data,(t,n,r)=>{if(fV(t)){const o=Bi().getObject(t.id);o?r[n]=o:hu(`Trying to reload sprite ${n} (${JSON.stringify(t)} - ${t.id}) but it does not exist.`)}})},setReturnValue(e){this.currentFrame.returnValue=e},waitForPlayerAnswer(e){this.commandsWaitingForPlayerAnswer.push(e)},popAnswerQueue(){return this.commandsWaitingForPlayerAnswer.pop()},addScopedVariable(e,t){this.currentFrame&&(this.currentFrame.scope[e]=t)},async loadScripts(e){this.readGlobalData();const t=await this.loadConfigScriptFiles(e),n=sn().options.scripts;this.addAllScripts([...t,...n])},async loadConfigScriptFiles(e){const t=[];for(const r of e)t.push(h0(K0(r)));return(await Promise.all(t)).map((r,o)=>({fileName:e[o],code:r,id:e[o],type:"script"}))},addAllScripts(e){const t=Date.now();for(const r of e)yn.addNarratScript(r);const n=Date.now();qi.log(`scripts parsed in ${n-t} ms`)},start(){this.setStack({currentIndex:0,branchData:{branch:yn.script.main.branch},label:"main"}),this.setStack({currentIndex:0,branchData:{branch:yn.script.main.branch},label:"main"})},setLastLabel(e){this.lastLabel=e},reset(){this.$reset(),this.stack=[],this.data={},this.hasJumped=!0,this.setStack({currentIndex:0,branchData:{branch:yn.script.main.branch},label:"main"})},readGlobalData(){this.globalData=lc().globalSave.data},setScript(e){yn.script=e},overrideData(e){this.data=e},setStack(e){this.stack=[];const t=this.frameOptionsToFrame(e);this.lastLabel=e.label,this.stack.push(t)},frameOptionsToFrame(e){const t=e.branchData,n={...e,blocks:[],scope:{},returnValue:null};if(this.addBlock(n,{branchData:t,currentIndex:e.currentIndex}),e.scope&&(n.scope=e.scope),e.args&&e.branchData.args)for(const[r,o]of e.branchData.args.entries())e.args.length>r&&(n.scope[o]=e.args[r]);return n},addBlock(e,t){e.blocks.push(t)},async addAndRunBlock(e){const t=this.currentFrame;if(!t)throw new Error("No frame to add block to");return this.addBlock(t,e),await this.runBlock()},setData(e,t){const n=dd();Uz(n,e,t)},addInstruction(e,t){const n=dd();Hz(n,e,t)},addFrame(e){if(!e.label)if(this.currentFrame)e.label=this.currentFrame.label;else throw new Error("Tried to add a new frame but no label was passed and there is no current frame label");const t=this.frameOptionsToFrame(e);this.stack.push(t)},async addAndRunFrame(e){return await this.addFrame(e),await this.runFrame()},async runFrame(){if(!this.currentFrame)throw new Error("Tried to run a frame but there is no current frame");let t;for(;this.currentBlock;){const n=await this.runBlock();if(n===o0||n===i0)return this.cleanFrame(),n;if(n===yx)return this.cleanFrame()}return this.cleanFrame(),t},cleanFrame(){const e=this.currentFrame,{returnValue:t}=e;return this.stack.splice(this.stack.length-1,1),t},async runBlock(){const e=this.currentBlock;if(!e)throw new Error("Tried to run a block but there is no current block");let t;for(;this.currentLine;){if(t=await this.runLineOnly(),Uve(t))return this.cleanBlock(),t;e.currentIndex++}return this.cleanBlock(),t},cleanBlock(){if(!this.currentFrame){St("Tried to clean a block but there is no current frame");return}if(!this.currentFrame.blocks){St("Tried to clean a block but there is no current block");return}this.currentFrame.blocks.splice(this.currentFrame.blocks.length-1,1)},async runGame(){let e=await this.runFrame();for(;e===o0;){const t=this.jumpTarget;if(!t){St("Tried to jump but no target was set");return}this.hasJumped=!0,this.setStack(t),await Zx({}),e=await this.runFrame()}e!==i0&&this.stack.length===0&&this.reachedEndOfScript()},async nextLineOnly(){return this.stack.length===0||this.isBlockFinished()?!1:(this.currentBlock.currentIndex++,!0)},isBlockFinished(){return!this.currentBlock||this.currentBlock&&this.currentBlock.currentIndex>=this.currentBlock.branchData.branch.length},reachedEndOfScript(){if(Ct().gameFlow.labelToJumpOnScriptEnd&&this.lastLabel!==Ct().gameFlow.labelToJumpOnScriptEnd){this.jumpToLabel(Ct().gameFlow.labelToJumpOnScriptEnd);return}sn().endingScript(),sn().options.debug&&Ct().debugging.showScriptFinishedMessage},async runLineOnly(){const e=this.currentLine;if(!e){St("There is no line of script to run.");return}return sn().startingScript(),await MV(e)},async runLabelFunction(e,...t){const n=yn.script[e];if(!n){St(`Tried to run a label that doesn't exist: ${e}`);return}const r={currentIndex:0,branchData:n,label:e,args:t};return this.addAndRunFrame(r)},runCustomFrame(e){this.addAndRunFrame(e)},async jumpToLabel(e,...t){const n=yn.script[e];if(!n){St(`Label ${e} doesn't exist. Is the file with this label added in the list of script files to load in the config?`);return}e!==this.lastLabel&&(this.hasJumped=!0),this.setLastLabel(e),this.setStack({currentIndex:0,branchData:n,args:t,label:e}),this.runGame()},async runThenGoBackToPreviousDialog(e,...t){const n=cr(),r=n.dialog[n.dialog.length-1],o=sn().inScript,i=await this.runLabelFunction(e,...t);return o?n.dialog.push(r):sn().endingScript(),i}},getters:{currentFrame(e){return e.stack[e.stack.length-1]},scope(){var e;return((e=this.currentFrame)==null?void 0:e.scope)??{}},currentBlock(){const e=this.currentFrame;return e?e.blocks[e.blocks.length-1]:void 0},currentLine(){const e=this.currentBlock;if(e&&e.branchData.branch.length>e.currentIndex)return e.branchData.branch[e.currentIndex]},commandWaitingForAnswer(){if(this.commandsWaitingForPlayerAnswer.length>0)return this.commandsWaitingForPlayerAnswer[0]}}}),TV=new Ap;TV.setupDebugger(!1);const pa=TV.logger;function fwe(e){return dwe((t,n,r)=>$we(t,n,r),e.code,e.fileName)}function dwe(e,t,n){const r={fileName:n,currentLine:0,error:(a,s)=>e(r,a,s),processCommandsFunction:t_,indentSize:0};r.indentSize=kwe(r,t);const o=ywe(r,t);r.currentLine=0,pa.log(o);const i={};for(const a of o){a.code.search(":")===-1&&r.error(a.line,"First indentation level should only be used to specify labels");const c=a.code.replace(":","").split(/ +/g),l=c[0],f=c.slice(1);a.branch||r.error(a.line,"This line should have a branch but doesn't"),i[l]={branch:t_(r,a.branch,void 0),args:f}}return i}function t_(e,t,n){const r=e.currentLine;if(!t){let a=0;return n&&(a=n.line),e.error(a,"Processing of command failed because the current branch has no lines inside"),[]}const o={processCommandsFunction:t_,parserContext:e,lines:t,currentLine:0,line:t[0]},i=[];for(;o.currentLine<t.length;){const a=t[o.currentLine];o.line=a;const s=n_(e,a,a.expression),c=yn.commands[s.command.operator];let l=c==null?void 0:c.parser;l||(l=yn.commands.text.parser),pa.log(yn.commands.text);const{newLine:f}=l(o,s);o.currentLine=f,e.currentLine=r+f,i.push(s)}return i}function n_(e,t,n){pa.log(n),typeof n[0]!="string"&&e.error(t.line,"Expression operator should be a string");const r={code:t.code,fileName:e.fileName,line:t.line,command:{staticOptions:{},commandType:n[0],operator:n[0],args:n.slice(1).map(a=>hwe(e,t,a)),options:{}}},o=n[0];if(!yn.commands[o]){const a=["else","success","failure"];!pve(o)&&!a.includes(o)&&e.error(t.line,`Unknown command ${o}`)}return r}function hwe(e,t,n){return Array.isArray(n)?n_(e,t,n):n}function pwe(e){return e==="true"?!0:e==="false"?!1:e==="undefined"?void 0:e===null?null:isNaN(Number(e))?e:Number(e)}function mwe(e,t){t.charAt(t.length-1)===":"&&(t=t.substr(0,t.length-1));const n=vwe(t),[r]=EV(e,n);return r}function vwe(e){const t=/(["'])(?:\\\1|.)*?\1/g,n=[];let r;for(;(r=t.exec(e))!=null;)n.push(r);let o=0,i=[];for(const a of n){const s=a.index;if(s>o){const l=e.substr(o,s-o),f=OV(l);i=[...i,...f]}const c=a[0].replace(/\\/g,"");i.push(`$$"${c.substring(1,c.length-1)}`),o=s+a[0].length}return i=[...i,...OV(e.substr(o))],i.push(")"),i}function OV(e){e=e.replace(/: *$/g,"");let t=e.split(" ").filter(n=>n);return t=t.reduce((n,r)=>[...n,...r.split(/(\(|\))/g)].filter(o=>o&&o),[]),t.map(n=>pwe(n))}function EV(e,t){pa.log("===============");let n=[],r=0,o=AV(t)+r,i=r_(t)+r;for(pa.log(`Parsing expression: ${t}`),pa.log(`Parenthesis start index: ${o} - end: ${i}`);o!==-1&&i>o;){n=[...n,...t.slice(r,o)];const c=t.slice(o+1);pa.log(`Found a sub expression. Before: ${n} - After: ${c}`),r=o;const[l,f]=EV(e,c),u=r+f;n.push(l),r=u+1;const d=t.slice(r);pa.log(`Sub expression came back: ${l} - rest of string: ${d}`),o=AV(d),o!==-1&&(o+=r),i=r_(d),i!==-1&&(i+=r)}i!==-1&&pa.log("Found parenthesis end before new opening parenthesis, close this expression");const a=r_(t.slice(r))+r;if(a===-1)return e.error(e.currentLine,'Expression is not closed (missing ")" closing parenthesis)'),[n,a];const s=t.slice(r,a);return pa.log(`End of expression: ${a} - ${s}`),pa.log("==================="),n=[...n,...s],gwe(e,n),[n,a+1]}function gwe(e,t){t.length<1&&e.error(e.currentLine,"Expression is empty")}function AV(e){return e.findIndex(t=>t==="(")}function r_(e){return e.findIndex(t=>t===")")}function ywe(e,t){const n=t.split(/\r?\n|$/).map(o=>{const i=o.search(/ *\/\//g);return i!==-1?o.substr(0,i):o});return PV(e,n,0,0).lines}function PV(e,t,n,r){let o=!0,i=n;const a=[];for(;o&&!(i>=t.length);){let s=t[i];if(s.search(/^\s*$/)!==-1)i++;else{const c=wwe(e,s);if(s=s.substring(c*e.indentSize),bwe(e,c,i),c<r)o=!1;else if(c>r){(a.length===0||c-r!==1)&&e.error(i,"Wrong double indentation");const l=PV(e,t,i,c);a[a.length-1].branch=l.lines,i=l.endLine}else{const l=mwe(e,s),f={code:s,indentation:c,line:i,expression:l};a.push(f),i++,e.currentLine=i}}}return{lines:a,endLine:i}}function bwe(e,t,n){t%1!==0&&e.error(n,`Indentation level of ${t} incorrect. Expected indentation of ${e.indentSize} spaces for this file.`)}function wwe(e,t){return t.search(/[^ ]/)/e.indentSize}function kwe(e,t){const n=/\n( *)/,r=t.match(n);return!r||r.length<2?(e.error(0,"Can't detect indentation level. Make sure you indent with at least 2 spaces and consistently"),0):(pa.log(r),r[1].length)}class xwe{constructor(){Wn(this,"plugins",[]);Wn(this,"pinia");Wn(this,"script",{});Wn(this,"scripts",[]);Wn(this,"commands",{})}addCommand(t){this.commands[t.keyword]=t}addPlugin(t){if(this.plugins.push(t),t.customCommands)for(const n of t.customCommands)this.addCommand(n)}callHook(t,...n){for(const r of this.plugins)typeof r[t]=="function"&&r[t](...n)}addNarratScript(t){const n=fwe(t);this.script={...this.script,...n},this.scripts.push(t)}customStores(){const t=[];for(const n of this.plugins)if(n.customStores)for(const r in n.customStores)t.push([r,n.customStores[r](this.pinia)]);return t}addCustomSettings(){for(const t of this.plugins)if(t.customSettings)for(const n in t.customSettings)Es().addCustomSetting(n,t.customSettings[n])}}const yn=new xwe;async function MV(e,t){var r;const n=un();try{return await y0(e,t)}catch(o){console.error(o),console.error(e),St(`Narrat script runtime error at <span class="error-filename">${e.fileName}:${e.line+1}</span>
205
+ `:""}var Fye=Bye,Vye={dump:Fye};function Dx(e,t){return function(){throw new Error("Function yaml."+e+" is removed in js-yaml 4. Use yaml."+t+" instead, which is now safe by default.")}}var zye=Mo,qye=lF,Uye=hF,Hye=yF,Wye=bF,Kye=Tx,Gye=zF.load,Jye=zF.loadAll,Qye=Vye.dump,Yye=ai,Xye={binary:SF,float:gF,map:dF,null:pF,pairs:CF,set:$F,timestamp:xF,bool:mF,int:vF,merge:_F,omap:jF,seq:fF,str:uF},Zye=Dx("safeLoad","load"),e1e=Dx("safeLoadAll","loadAll"),t1e=Dx("safeDump","dump"),n1e={Type:zye,Schema:qye,FAILSAFE_SCHEMA:Uye,JSON_SCHEMA:Hye,CORE_SCHEMA:Wye,DEFAULT_SCHEMA:Kye,load:Gye,loadAll:Jye,dump:Qye,YAMLException:Yye,types:Xye,safeLoad:Zye,safeLoadAll:e1e,safeDump:t1e};function h0(e){return new Promise((t,n)=>{const r=new XMLHttpRequest;r.onload=function(){r.status>=200&&r.status<300?t(r.responseText):(St(`Failed to load file ${e}`,r.status),n(r.status))},r.open("GET",e),r.send()})}async function up(e){try{const t=await h0(e);let n;if(e.endsWith(".json"))n=JSON.parse(t);else if(e.endsWith(".yaml"))n=n1e.load(t);else{const r=`Unsupported file type for data file ${e} (must be .json or .yaml)`;throw new Error(r)}if(!n)throw new Error(`Data loaded from ${e} is empty`);return n}catch(t){throw console.error(`Failed to load data file ${e}: ${t}`),t}}const r1e=(e,t)=>{const n={};for(const r in e)n[r]=t(e[r]);return n},cV=(e,t)=>{for(const n in e){const r=e[n];t(r,n,e),typeof r=="object"&&r!==null&&cV(r,t)}},ed={};async function o1e(e){return ed[e]?ed[e]:lV(e,e)}async function i1e(e){qi.log("Loading images");const t=[],n=async(o,i)=>await lV(o,i),r=(o,i)=>{t.push(n(o,i))};for(const o in e.common.images){const i=e.common.images[o];r(o,i)}if(e.preload.images)for(const o in e.preload.images.assets){const i=e.preload.images.assets[o];r(o,i)}for(const o in e.screens.screens){const i=e.screens.screens[o];if(i.background&&!e.common.images[i.background]&&!i.video&&r(i.background,i.background),i.buttons)for(const a in i.buttons){const s=i.buttons[a];typeof s=="object"&&s.background&&!e.common.images[s.background]&&r(s.background,s.background)}}return Promise.all(t)}async function lV(e,t){if(ed[e])return ed[e];const n=new Promise((r,o)=>{const i=new Image;i.onload=()=>{ed[e]=i,r(i)},i.onerror=a=>{St(`Failed to load image ${e} at ${t}`,a),o(a)},i.src=ci(t)});return ed[e]=n,n}const p0={};function a1e(e){return p0[e]??{}}function uV(e,t,n){const r=a1e(e.transition),o=e.duration??r.duration??500,i=e.delay??r.delay??0;return{...e,resolve:n,duration:o,delay:i,oldScreen:t}}const Jo=eo("notifications",{state:()=>({notifications:[],enabled:!0}),actions:{async addNotification(e,t,n){if(!this.enabled)return;e=$s(e);const r=`${Date.now()}-${Math.random()*1e4}`;this.notifications.push({id:r,text:e,description:t,icon:n}),Ct().notifications.alsoPrintInDialogue&&iF(`[NOTIFICATION] ${e}`),await ki(Ct().notifications.timeOnScreen*1e3),this.deleteNotification(r)},deleteNotification(e){const t=this.findNotifications(e);t&&this.notifications.splice(this.notifications.indexOf(t),1)},findNotifications(e){return this.notifications.find(t=>t.id===e)},disableNotifications(){this.enabled=!1;for(const e in this.notifications)this.deleteNotification(e)},enableNotifications(){this.enabled=!0}}}),Io=eo("inventory",{state:()=>({items:{},interactionTags:{}}),actions:{generateSaveData(){return{items:Xn(this.items),interactionTags:Xn(this.interactionTags)}},loadSaveData(e){this.items={...this.items,...e.items},this.interactionTags={...e.interactionTags}},updateConfig(e){Object.keys(e.items).forEach(t=>{this.items[t]||(this.items[t]={amount:0,id:t})})},reset(e){this.$reset(),this.updateConfig(e)},hasItem(e,t){var n;return t||(t=1),((n=this.items[e])==null?void 0:n.amount)>=t},getExistingItem(e){return this.items[e]},getItemAmount(e){var t;return((t=this.getExistingItem(e))==null?void 0:t.amount)||0},add(e){const t=this.getExistingItem(e.id);t?t.amount+=e.amount:this.items[e.id]={...e};const n=Ja(e.id).name,r=e.amount>1?`${n} x ${e.amount}`:n;Jo().addNotification(`Received item: ${r}`)},enableInteraction(e){e||(e="default"),this.interactionTags[e]={blockedInteraction:!1}},disableInteraction(e){e||(e="default"),this.interactionTags[e]={blockedInteraction:!0}},onScriptStart(){const e=Ct().interactionTags;Object.keys(e).forEach(t=>{e[t].onlyInteractOutsideOfScripts&&this.disableInteraction(t)})},onScriptEnd(){const e=Ct().interactionTags;Object.keys(e).forEach(t=>{e[t].onlyInteractOutsideOfScripts&&this.enableInteraction(t)})},isInteractionTagBlocked(e){return e||(e="default"),this.interactionTags[e]?this.interactionTags[e].blockedInteraction:!1},remove(e){const t=this.getExistingItem(e.id);t&&(t.amount-=e.amount,Jo().addNotification(`Lost item: ${Ja(e.id).name} x ${e.amount}`),t.amount<=0&&this.deleteItem(e.id))},deleteItem(e){this.getExistingItem(e)&&(this.items[e].amount=0)},canUseItem(e){var n;const t=Ja(e.id);return!!(t&&t.onUse&&!this.isInteractionTagBlocked(t.tag)&&!((n=cr().currentDialog)!=null&&n.choices))},useItem(e){let t=!1;const n=Ja(e.id);if(e&&this.canUseItem(e)&&n){const r=n.onUse;t=!0,uu("onItemUsed"),r.action==="jump"?un().jumpToLabel(r.label):r.action==="run"?un().runThenGoBackToPreviousDialog(r.label,!0):(t=!1,St(`Unknown action ${r.action}`))}return t}}}),da=eo("screens",{state:()=>({layers:[{screen:"default"}],buttons:{}}),actions:{setScreen(e,t,n){return new Promise(r=>{const o=this.layers[t||0];let i;const a=(o==null?void 0:o.screen)??null;if(a===e){r();return}n&&(i=uV(n,a,r)),this.layers[t||0]={screen:e,transition:i},i||r()})},finishTransition(e){const t=this.layers[e];if(!t)St(`Tried to finish transition on layer ${e} but it doesn't exist`);else if(t.transition){const n=t.transition.resolve;delete t.transition,n()}},transitionScreen(e,t,n){return this.setScreen(e,n??0,t)},emptyLayer(e,t){return new Promise(n=>{const r=this.layers[e];if(!r){hu(`Tried to empty layer ${e} but it doesn't exist`);return}if(t){const o=r.screen,i=uV(t,o,n);r.transition=i}r.screen="@empty",t||n()})},updateConfig(e){console.log("update config!");const t=pr().buttons.buttons;for(const n in t)this.buttons[n]||(this.buttons[n]={state:t[n].enabled})},reset(e){this.$reset(),this.updateConfig(e)},changeButton(e,t){if(!this.buttons[e]){St(`Tried to change button ${e} but it doesn't exist`);return}this.buttons[e].state=t},generateSaveData(){return{layers:Xn(this.layers).filter(e=>e).map(e=>e.screen??null),buttons:Xn(this.buttons)}},loadSaveData(e){this.layers=e.layers.map(t=>(t!==null&&typeof t!="string"&&(t=null),{screen:t})),this.buttons=fu(this.buttons,e.buttons)},isButtonDisabled(e){const t=this.getButtonState(e);return t==="hidden"||t==="greyed"||t===!1},isButtonInteractible(e){const t=this.getButtonState(e);return t?t===!0:!1},isButtonClickable(e){if(!this.isButtonInteractible(e))return!1;const n=vl(e);return!!m0(n)},getButtonState(e){const t=vl(e),n=this.buttons[e],r=t.tag||"default",o=n.state;return o===!0&&Io().isInteractionTagBlocked(r)?"greyed":o},clickOnButton(e){if(!this.isButtonClickable(e))return;const t=un(),n=vl(e);uu("onButtonClicked");const r=n.action;r&&(n.actionType==="run"?t.runLabelFunction(r):t.jumpToLabel(r))}},getters:{nonEmptyLayers(e){return e.layers.filter(t=>t)},isTransitioning(e){return e.layers.some(t=>t==null?void 0:t.transition)}}});function m0(e){if(!sn().inScript)return!0;const t=q0().clickableDuringScriptsByDefault;if(t)return e.scriptClickable!==!1;if(!t)return e.scriptClickable===!0}const s1e=["screenObject","sprite"];function fV(e){return typeof e=="object"&&e!==null&&s1e.includes(e._entityType)}function c1e(e){return typeof e=="object"&&e!==null&&e._entityType==="sprite"}function l1e(e){if(e.includes(" ")){const t=e.split(" ");return{label:t[0],args:t.slice(1)}}else return{label:e}}const Bi=eo("screenObjects",{state:()=>({tree:[],objectsList:{}}),actions:{addObject(e){e.parent?e.parent.children.push(e):this.tree.push(e),this.objectsList[e.id]=e},createObject(e){const t={_entityType:"screenObject",id:su(),name:"Screen Object",tags:[],x:0,y:0,anchor:{x:0,y:0},width:1,height:1,opacity:1,scale:1,layer:0,children:[],...e};return this.addObject(t),t},destroyObject(e){let t=e;typeof t=="string"&&(t=this.getObject(t));for(let n=t.children.length-1;n>=0;n--)this.destroyObject(t.children[n]);if(t.parent){const n=t.parent,r=n.children.indexOf(t);r!==-1?n.children.splice(r,1):console.warn(`Could not find object ${t.id} in parent's children`)}else{const n=this.tree.indexOf(t);n!==-1?this.tree.splice(n,1):console.warn(`Object to destroy not found in store (${t.id})`)}delete this.objectsList[t.id]},createSprite(e){const t=this.createObject(e);return t._entityType="sprite",o1e(e.image).then(n=>{const r=this.getObject(t.id);r.width===1&&r.height===1&&(r.width=n.width,r.height=n.height)}),t},getObject(e){return this.objectsList[e]},isScreenObjectClickable(e){return m0(e)?!!e.onClick:!1},clickObject(e){if(this.isScreenObjectClickable(e)&&e.onClick){uu("onSpriteClicked");let t;if(typeof e.onClick=="string"){const n=l1e(e.onClick);t={label:n.label,args:n.args}}else t=e.onClick;t.method=t.method??e.clickMethod??"jump",t.args=t.args??[],t.method==="run"?un().runThenGoBackToPreviousDialog(t.label,...t.args):t.method==="jump"?un().jumpToLabel(t.label,...t.args):St(`Unknown sprite click method ${e.clickMethod}`)}},generateSaveData(){return{tree:Xn(this.tree.map(e=>e.id)),objectsList:Xn(r1e(this.objectsList,e=>this.screenObjectToSave(e)))}},loadSaveData(e){this.objectsList=this.loadAllObjects(e.objectsList),this.tree=e.tree.map(t=>this.objectsList[t])},reset(){this.$reset()},screenObjectToSave(e){return{...e,children:e.children.map(t=>t.id),parent:e.parent?e.parent.id:void 0}},loadAllObjects(e){for(const t of Object.values(e)){const n=t;n.parent=n.parent?e[n.parent]:void 0,n.children=n.children.map(r=>e[r])}return e},emptyLayer(e){for(let t=this.tree.length-1;t>=0;t--){const n=this.tree[t];n.layer===e&&this.destroyObject(n)}},emptyAllLayers(){for(let e=this.tree.length-1;e>=0;e--){const t=this.tree[e];this.destroyObject(t)}}}});function dV(e){return"save"in e}function hV(e){return"globalSave"in e}function u1e(e){return"config"in e}const f1e=b.defineComponent({props:{percentage:Number,step:String},methods:{loadingStyle(){return{width:`${this.percentage*60}vw`}}},computed:{}}),d1e={id:"loading-bar"},h1e={id:"loading-text"};function p1e(e,t,n,r,o,i){return b.openBlock(),b.createElementBlock("div",d1e,[b.createElementVNode("div",{id:"inner-loading-bar",style:b.normalizeStyle(e.loadingStyle())},null,4),b.createElementVNode("div",h1e,[b.createElementVNode("h3",null,"Loading "+b.toDisplayString(Math.floor(e.percentage*100))+"% - "+b.toDisplayString(e.step),1)])])}const m1e=Xa(f1e,[["render",p1e]]),v1e="data:image/svg+xml,%3c?xml%20version='1.0'%20encoding='utf-8'?%3e%3c!--%20Generator:%20Adobe%20Illustrator%2019.0.0,%20SVG%20Export%20Plug-In%20.%20SVG%20Version:%206.00%20Build%200)%20--%3e%3csvg%20version='1.1'%20id='Rat'%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20x='0px'%20y='0px'%20viewBox='0%200%20595.3%20595.3'%20style='enable-background:new%200%200%20595.3%20595.3;'%20xml:space='preserve'%3e%3cstyle%20type='text/css'%3e%20.st0{fill:%23E23B33;}%20%3c/style%3e%3cpath%20id='Rat_Shape'%20class='st0'%20d='M556.9,82.5c-10.8-24.3-47-57.1-71.3-65.6c-24.3-8.4-64.1-0.3-88.7,22.3%20c-20,18.4-26,28.2-29.1,37c-2.1,5.9-4.8,13.5-6,20.9v0c-0.5,4.1-4.5,7-8.6,6.1c-10.4-2.3-29.5-6-44.4-6.3%20c-13.7-0.2-30.1,3.2-40.4,5.7c-4.5,1.1-8.8-2.2-8.8-6.8c-0.1-5.3-1.1-12.3-4.8-19.6c-8.5-16.9-19.6-32.6-57.8-47.4%20c-31.9-12.4-75.1-9.7-100.8,1.8c-28.1,12.6-42.4,37.9-54,61.8c-14.4,29.8-14.9,83.6-6.4,104c12.8,30.7,35.8,47.2,52.6,53%20c11.3,3.8,28.2,3.7,38.2,3.3c4.2-0.2,7.7,3.3,7.5,7.5c-0.7,13.6-0.9,41.5,7,61.4c7.7,19.4,29.7,62.3,50.7,101.2%20c0,0.1-14.6,2.9-31.4,6.8c-23.9,5.5-52.6,12.7-54.3,13.7c-3.5,2.1-3,10-2.7,12c0.5,3.4,5.3,8.1,6.9,8.3c3.9,0.3,31.3-7.6,55.7-14.6%20c18.5-5.3,34.9-9.3,35.5-8.2c5.1,9.3,10,18,14.4,25.8c5.2,9.1,10.7,16.4,14.1,23.6c1.1,2.3-16.6,5.8-32.5,14.7%20c-16.4,9.1-29.7,21-32.3,24c-1.8,2.1-3,6-1.2,10.7c1.1,2.9,10,5.7,12.4,5.1c6.8-1.7,16.5-12.5,33.1-21.1%20c16.3-8.5,32.9-14.9,33.8-13.6c9.7,14.3,16.9,21.6,22.6,31.2c9.8,16.5,27.3,45.9,46.6,39.5c6.4-2.1,31.1-33.6,53.3-68.6%20c1.3-2.1,16.1,11.3,30.4,23.2c13.8,11.4,22.7,20.6,27.1,21.4c5.4,1,14.2-7.7,14.1-14.7c-0.1-2.7-14.3-13.8-29.1-26.2%20c-14.5-12.1-30.1-22.8-29.2-24.3c7.6-12,14.5-23.7,20.1-33.9c4.3-7.8,8.9-16,13-24.7c0.6-1.2,15.9,3,31.4,7.1c15.3,4,26.7,10,31,8%20c6.9-3,11.6-13.8,9.4-18.3c-1.1-2.3-17-7.3-33.2-12c-14.2-4.1-28-6.5-27.7-7.3c15.5-34,28.8-64.8,27.6-69.6%20c-1.7-7.1,2.6-11.9,7-36.5c3.2-18.1,4.7-40.9,5.2-51.7c0.2-3.5,2.8-6.3,6.3-6.7c3.1-0.3,6.9-0.9,10.5-1.9c7.8-2,18.6-7.8,36.4-20.6%20c17.9-12.8,38.7-49.6,44.4-67.8S567.6,106.8,556.9,82.5z%20M265.1,336.2c-8.1,4-13,7-26.4,9.6c-6.9,1.4-29.4-0.2-40.7-4.6%20c-10.5-4.1-19.9-7.6-30-15.4s-15.7-13.2-15.7-15.3c0-4.4,6-9.4,11-9.4c5.1,0,14.5,9.2,29.7,16.6c14.3,7,17.9,6.1,25.4,7.3%20c2.9,0.5,7.7,0.6,10.7,0.4c14.1-1.3,21.4-5.9,25.3-8.8c4-3,13.7-12.9,17.2-12.5c8,1,18.9,3.4,18.9,7.1%20C290.4,319,273.2,332.1,265.1,336.2z%20M320.9,521.4c-4.3,3.7-17.7,13.5-23.3,13.5c-2.8,0-7.4-8.2-11.5-16.8%20c-4.1-8.5-9.1-21.1-9.1-31.6c0-4.6,6-7.4,13.4-9.2c7.2-1.7,27.3-1.8,29.9-1.1c6.8,1.7,12.9,2.2,12.7,6.4c-0.4,12.7-7,18.9-8.3,24.3%20C323.4,512.3,323.4,519.2,320.9,521.4z%20M431.1,320.3c-9.2,7.4-10.6,8.1-24.9,13.7c-11.3,4.4-28.6,5.8-41.6,3.6%20c-12.2-2.1-22.3-4.6-29.5-10.1c-9.7-7.3-16.4-15.1-16.4-19.8c0-3.7,6.4-4.3,14.5-4.9c3.5-0.3,9.3,5.9,13.2,9.2%20c8.1,6.8,14.8,8,28.8,9.9c2.9,0.4,7.8,0.4,10.7,0.1c7.5-0.9,12-0.4,25.8-8.2c20-11.2,17.8-14.4,25.1-12.6c2.2,0.6,5.8,1.2,5.6,5.6%20C442.4,309,440.5,312.7,431.1,320.3z'/%3e%3c/svg%3e",g1e={id:"engine-splash-screen",class:"flex justify-center items-center"},y1e={id:"engine-splash-title"},b1e=["src"],Lx=b.defineComponent({__name:"engine-splash",emits:["finished"],setup(e,{emit:t}){const n=t,r=b.ref("hidden"),o=b.computed(()=>({transitionDuration:`${f.value}s`})),i=b.computed(()=>({invisible:r.value!=="appear"})),a=sn(),s=b.computed(()=>{var h;return((h=Ct().splashScreens)==null?void 0:h.engineSplashScreen)??{}}),c=b.computed(()=>typeof s.value.overrideText=="string"?s.value.overrideText:"Made with narrat engine"),l=b.computed(()=>s.value.overrideLogo??v1e),f=b.computed(()=>typeof s.value.fadeDuration=="number"?s.value.fadeDuration:.8),u=b.computed(()=>typeof s.value.timeBeforeFadeout=="number"?s.value.timeBeforeFadeout:1.5);b.onMounted(async()=>{if(await ki(10),r.value="appear",s.value.skip||a.options.debug){d();return}await ki(f.value*1e3),await ki(u.value*1e3),r.value="disappear",await ki(f.value*1e3),d()});function d(){a.loading.loaded?n("finished"):a.listener.once("gameLoaded",()=>{n("finished")})}return(h,p)=>(b.openBlock(),b.createElementBlock("div",g1e,[b.createElementVNode("div",{id:"engine-splash-header",class:b.normalizeClass(["flex justify-center flex-col items-center",i.value]),style:b.normalizeStyle(o.value)},[b.createElementVNode("h1",y1e,b.toDisplayString(c.value),1),b.createElementVNode("img",{src:l.value,alt:"Narrat Logo",id:"engine-splash-logo"},null,8,b1e),b.createVNode(m1e,{percentage:b.unref(a).loading.percentage,step:b.unref(a).loading.step},null,8,["percentage","step"])],6)]))}});class Bx{constructor(){Wn(this,"listeners",{})}on(t,n){return this.listeners[t]||this.addEventToMap(t),this.listeners[t].add(n),n}off(t,n){return this.listeners[t]&&this.listeners[t].delete(n),n}once(t,n){const r=(...o)=>{this.off(t,r),n(...o)};return this.on(t,r)}emit(t,...n){this.listeners[t]&&this.listeners[t].forEach(r=>r(...n))}clear(){Object.keys(this.listeners).forEach(t=>{delete this.listeners[t]})}addEventToMap(t){this.listeners[t]=new Set}}class w1e extends Bx{setup(){const t=()=>{this.emit("preUpdate"),this.emit("update"),this.emit("postUpdate"),requestAnimationFrame(t)};t()}}const fp=new w1e;Qe.Vec2=void 0,(e=>{function t(p,m){return{x:p??0,y:m??0}}e.create=t;function n(p){return Math.sqrt(p.x*p.x+p.y*p.y)}e.magnitude=n;function r(p){const m=n(p);return m===0?t(0,0):{x:p.x/m,y:p.y/m}}e.normalize=r;function o(p,m){return{x:p.x+m.x,y:p.y+m.y}}e.add=o;function i(p,m){return{x:p.x-m.x,y:p.y-m.y}}e.subtract=i;function a(p,m){return{x:p.x*m.x,y:p.y*m.y}}e.multiply=a;function s(p,m){return{x:p.x*m,y:p.y*m}}e.scale=s;function c(p,m){return{x:p.x/m.x,y:p.y/m.y}}e.divide=c;function l(p,m){return n(i(p,m))}e.distance=l;function f(p,m,v){return{x:p.x+(m.x-p.x)*v,y:p.y+(m.y-p.y)*v}}e.lerp=f;function u(p,m){const v=Math.cos(m),g=Math.sin(m);return{x:p.x*v-p.y*g,y:p.x*g+p.y*v}}e.rotate=u;function d(p,m){const v=i(m,p);return e.normalize({x:-v.y,y:v.x})}e.normal=d;function h(p,m){return p.x*m.x+p.y*m.y}e.dot=h})(Qe.Vec2||(Qe.Vec2={}));function Fx(e,t,n,r){const o=e/n,i=t/r;return Math.min(o,i)}const Es=eo("settings",{state:()=>({baseSettings:{textSpeed:30,animateText:!0,fontSize:16},settingsSchema:{textSpeed:{type:"number",defaultValue:30,minValue:1,maxValue:100,step:5,name:"Text Speed",description:"The speed at which text plays."},animateText:{type:"boolean",defaultValue:!0,name:"Animate Text",description:"Whether or not text should animate."},fontSize:{type:"integer",defaultValue:16,minValue:8,maxValue:64,step:1,name:"Font Size",description:"The base font size for the game."}},customSettings:{},customSettingsSchema:{}}),actions:{reset(e){this.$reset(),this.updateConfig(e)},getSetting(e){if(typeof this.baseSettings[e]<"u")return this.baseSettings[e];if(typeof this.customSettings[e]<"u")return this.customSettings[e];St(`Setting ${e} does not exist.`)},getSettingSchema(e){if(typeof this.settingsSchema[e]<"u")return this.settingsSchema[e];if(typeof this.customSettingsSchema[e]<"u")return this.customSettingsSchema[e];St(`Setting ${e} does not exist.`)},getAllSettingSchemas(){return{...this.settingsSchema,...this.customSettingsSchema}},setSetting(e,t){typeof this.baseSettings[e]<"u"?this.baseSettings[e]=t:typeof this.customSettings[e]<"u"?this.customSettings[e]=t:St(`Setting ${e} does not exist.`),e==="fontSize"&&document.documentElement.style.setProperty("font-size",`${t}px`),e==="textSpeed"&&(Ct().dialogPanel.textSpeed=t),e==="animateText"&&(Ct().dialogPanel.animateText=t)},updateConfig(e){var t;if(this.setSetting("textSpeed",e.dialogPanel.textSpeed??a0),this.setSetting("animateText",e.dialogPanel.animateText??!0),this.setSetting("fontSize",e.layout.defaultFontSize??16),(t=e.settings)!=null&&t.customSettings)for(const n in e.settings.customSettings)this.addCustomSetting(n,e.settings.customSettings[n])},addCustomSetting(e,t){this.customSettings[e]=t.defaultValue,this.customSettingsSchema[e]=t},generateSaveData(){return{baseSettings:Xn(this.baseSettings),customSettings:Xn(this.customSettings)}},loadSaveData(e){for(const t in e.baseSettings)this.setSetting(t,e.baseSettings[t]);for(const t in e.customSettings)typeof this.customSettings[t]<"u"&&this.setSetting(t,e.customSettings[t])}}});function dp(e,t=50,n={}){let r;const o=n.isImmediate??!1,i=n.callback??!1,a=n.maxWait;let s=Date.now(),c=[];function l(){if(a!==void 0){const u=Date.now()-s;if(u+t>=a)return a-u}return t}const f=function(...u){const d=this;return new Promise((h,p)=>{const m=function(){if(r=void 0,s=Date.now(),!o){const y=e.apply(d,u);i&&i(y),c.forEach(({resolve:w})=>w(y)),c=[]}},v=o&&r===void 0;r!==void 0&&clearTimeout(r);const g=l();if(r=setTimeout(m,g),v){const y=e.apply(d,u);return i&&i(y),h(y)}c.push({resolve:h,reject:p})})};return f.cancel=function(u){r!==void 0&&clearTimeout(r),c.forEach(({reject:d})=>d(u)),c=[]},f}const Gr=eo("rendering",{state:()=>({screenHeight:window.innerHeight,screenWidth:window.innerWidth,layoutMode:"horizontal",resizeObserver:null,containerElement:null,narratAppElement:null,dialogPanelMode:"auto"}),actions:{generateSaveData(){return{dialogPanelMode:this.dialogPanelMode}},loadSaveData(e){this.dialogPanelMode=e.dialogPanelMode},reset(){this.dialogPanelMode="auto"},updateScreenSize(e,t){this.screenHeight=t,this.screenWidth=e,e<Ct().layout.verticalLayoutThreshold?(this.layoutMode="vertical",document.querySelector("html").style.fontSize=`${Es().baseSettings.fontSize}px`??"40px"):(this.layoutMode="horizontal",document.querySelector("html").style.fontSize=`${Es().baseSettings.fontSize}px`??"16px")},setContainer(e){this.containerElement=e,this.resizeObserver&&this.resizeObserver.disconnect(),this.resizeObserver=new ResizeObserver(dp(()=>{this.refreshScreenSize()},100,{maxWait:200})),this.resizeObserver.observe(e),this.refreshScreenSize()},refreshScreenSize(){const e=this.containerElement;e&&this.updateScreenSize(e.clientWidth,e.clientHeight)}},getters:{gameScaleRatio(e){return Fx(this.screenWidth,this.screenHeight,this.gameWidth,this.gameHeight)},overlayMode(e){return!!(Ct().dialogPanel.overlayMode&&e.layoutMode==="horizontal")},gameWidth(){const e=Ct();return this.layoutMode==="vertical"||this.overlayMode?e.layout.backgrounds.width:e.layout.backgrounds.width+G0()},gameHeight(){const e=Ct();return this.layoutMode==="vertical",e.layout.backgrounds.height},dialogWidth(){return this.layoutMode==="vertical"?this.viewportWidth:G0()},dialogHeight(){return this.layoutMode==="vertical"?this.actualGameHeight-this.gameHeight:Ct().dialogPanel.height??this.gameHeight},actualGameHeight(){let e=this.gameHeight;return this.layoutMode==="vertical"&&(e=this.screenHeight/this.gameScaleRatio),e},viewportRatio(e){if(this.layoutMode==="vertical"){const t=Ct().layout.backgrounds;return e.screenWidth/t.width}return 1},viewportHeight(e){return Ct().layout.backgrounds.height*this.viewportRatio},viewportWidth(e){return Ct().layout.backgrounds.width*this.viewportRatio},showDialog(e){if(this.dialogPanelMode==="on")return!0;if(this.dialogPanelMode==="off")return!1;if(!this.overlayMode||this.layoutMode==="vertical")return!0;const t=sn().inScript;let n=!0;return da().isTransitioning&&Ct().dialogPanel.hideDuringTransition&&(n=!1),!Ct().dialogPanel.showAfterScriptEnd&&!t&&(n=!1),n},container(){return this.containerElement?this.containerElement:document.body},inputsContainer(){return sn().hasCustomContainer?this.container:window},narratApp(){return this.narratAppElement?this.narratAppElement:document.body}}});class k1e extends EventTarget{constructor(){super(...arguments);Wn(this,"gamepadAvailable",!0);Wn(this,"gameActions",{});Wn(this,"keyboardState",{});Wn(this,"actions",{});Wn(this,"lastInputMethodUsed","km");Wn(this,"gamepad",null)}kbEvent(){this.changeLastInput("km")}getGamepads(){return navigator.getGamepads?navigator.getGamepads():(this.gamepadAvailable=!1,[])}gamepadEvent(){this.changeLastInput("gamepad")}mouseEvent(){this.changeLastInput("km")}changeLastInput(n){this.lastInputMethodUsed!==n&&(this.lastInputMethodUsed=n,this.dispatchEvent(new CustomEvent("change-input",{detail:n})))}getGamepad(){const n=this.getGamepads().filter(r=>r!==null);if(n.length>0)return n[0]}startListening(){this.updateGamepad();const n=Gr().inputsContainer;n.addEventListener("mousemove",r=>{this.mouseEvent()}),n.addEventListener("keydown",r=>{this.kbEvent();const o=this.getKeyboardState(r.key).current;this.keyboardState[r.key]={previous:o,current:!0}}),n.addEventListener("keyup",r=>{this.kbEvent();const o=this.getKeyboardState(r.key).current;this.keyboardState[r.key]={previous:o,current:!1}}),fp.on("preUpdate",()=>{this.update()})}updateGamepad(){const n=this.getGamepad();n?this.gamepad?this.updateAllNarratButtons(n,this.gamepad):this.gamepad=this.setupNarratGamepad(n):this.gamepad=null}setupNarratGamepad(n){return{id:n.id,gamepad:n,buttons:n.buttons.map((o,i)=>this.getNarratButtonFromGamepad(o,o,i))}}updateAllNarratButtons(n,r){for(const[o,i]of n.buttons.entries()){const a=r.buttons[o];a.previous=Xn(a.state),a.state=Xn(i),a.previous.pressed!==a.state.pressed&&this.gamepadEvent()}}getNarratButtonFromGamepad(n,r,o){return{index:o,state:Xn(r),previous:Xn(r)}}addAction(n){if(this.gameActions[n.id]=n,n.type==="button"){const r={config:n,active:!1,justPressed:!1,justReleased:!1};this.actions[n.id]={state:r,previous:Xn(r)}}else{const r={config:n,value:Qe.Vec2.create(0,0),fullState:{left:0,right:0,up:0,down:0}};this.actions[n.id]={state:r,previous:Xn(r)}}}getAnalog(n){return this.actions[n]||St(`Action ${n} does not exist`),this.actions[n].state}getButton(n){return this.actions[n]||St(`Action ${n} does not exist`),this.actions[n].state}getKeyboardState(n){return this.keyboardState[n]?this.keyboardState[n]:(this.keyboardState[n]={current:!1,previous:!1},this.keyboardState[n])}getGamepadState(n){return this.gamepad&&this.gamepad.buttons.length>n?{current:this.gamepad.buttons[n].state,previous:this.gamepad.buttons[n].previous}:null}debugGamepad(){if(this.gamepad)for(const[n,r]of this.gamepad.buttons.entries())r.state.pressed,r.previous.pressed}update(){this.updateGamepad(),this.debugGamepad();for(const n of Object.values(this.gameActions))if(n.type==="button"){const r=this.actions[n.id],o=Xn(r.state),i=r.state;r.previous=o,n.action==="press"&&(n.keybinds.some(s=>{let c=!1;if(typeof s.keyboardKey=="string"&&this.getKeyboardState(s.keyboardKey).current===!0&&(c=!0),typeof s.gamepadButton=="number"){const l=this.getGamepadState(s.gamepadButton);l&&l.current.pressed===!0&&(c=!0)}return c})?i.active=!0:i.active=!1,i.active&&!o.active?i.justPressed=!0:i.justPressed=!1,!i.active&&o.active?i.justReleased=!0:i.justReleased=!1)}else if(n.type==="analog"){const r=this.actions[n.id],o=r.state;Xn(r.state),r.previous=Xn(o);let i=Qe.Vec2.create(0,0);n.keybinds.forEach(a=>{this.getKeyboardState(a.left).current&&(o.fullState.left=1,i.x-=1),this.getKeyboardState(a.right).current&&(o.fullState.right=1,i.x+=1),this.getKeyboardState(a.up).current&&(o.fullState.up=1,i.y-=1),this.getKeyboardState(a.down).current&&(o.fullState.down=1,i.y+=1)}),i=Qe.Vec2.normalize(i),o.value=i}}}const ul=new k1e,No=eo("menu",{state:()=>({menus:{},activeMenu:!1}),getters:{showSkills(){return Object.entries(Ns().skills).length>0},showInventory(){return Object.entries(V0().items).length>0},showQuests(){return Object.entries(Tp().quests).length>0},showAchievements(){return Object.entries(Op().achievements).length>0},menuTabsToShow(e){return e.menus.menu.tabs.map(t=>{const n=Ct().menuButtons[t.id]||{};return{...t,...n}}).filter(t=>t.condition?t.condition():!0)},menu(e){return e.activeMenu?e.menus[e.activeMenu]:void 0},tab(){if(this.menu)return this.menu.tabs[this.menu.activeTab]}},actions:{setup(){},addMenu(e,t){this.menus[e]={...t,id:e}},addMenuOption(e,t){this.menus[e]||(this.menus[e]={id:e,label:e,tabs:[],activeTab:0}),this.menus[e].tabs.push(t)},setActiveTab(e){this.menu&&(this.menu.activeTab=e)},openMenu(e){this.activeMenu=e},closeMenu(){this.activeMenu=!1},toggleMenu(){this.activeMenu?this.activeMenu=!1:this.activeMenu="menu"}}}),x1e=[{id:"left",type:"button",action:"press",keybinds:[{keyboardKey:"ArrowLeft",gamepadButton:14}]},{id:"right",type:"button",action:"press",keybinds:[{keyboardKey:"ArrowRight",gamepadButton:15}]},{id:"up",type:"button",action:"press",keybinds:[{keyboardKey:"ArrowUp",gamepadButton:12}]},{id:"down",type:"button",action:"press",keybinds:[{keyboardKey:"ArrowDown",gamepadButton:13}]},{id:"continue",type:"button",action:"press",keybinds:[{keyboardKey:"Enter",gamepadButton:0}]},{id:"cancel",type:"button",action:"press",keybinds:[{keyboardKey:"Escape",gamepadButton:1}]},{id:"system",type:"button",action:"press",keybinds:[{keyboardKey:"n",gamepadButton:9}]},{id:"menu",type:"button",action:"press",keybinds:[{keyboardKey:"m",gamepadButton:8}]},{id:"previousTab",type:"button",action:"press",keybinds:[{keyboardKey:"p",gamepadButton:4}]},{id:"nextTab",type:"button",action:"press",keybinds:[{keyboardKey:"o",gamepadButton:5}]},{id:"subPreviousTab",type:"button",action:"press",keybinds:[{keyboardKey:"i",gamepadButton:6}]},{id:"subNextTab",type:"button",action:"press",keybinds:[{keyboardKey:"u",gamepadButton:7}]},{id:"viewportSelect",type:"button",action:"press",keybinds:[{keyboardKey:"v",gamepadButton:2}]},{id:"autoPlay",type:"button",action:"press",keybinds:[{keyboardKey:"a",gamepadButton:6}]},{id:"skip",type:"button",action:"press",keybinds:[{keyboardKey:"s",gamepadButton:7}]}],xr=eo("inputs",{state:()=>({inputStack:[],baseInputListener:null,inputMode:"mk",inGameInputListener:null}),actions:{setupInputs(){ul.addEventListener("change-input",e=>{this.inputMode=e.detail});for(const e of x1e)ul.addAction(e);this.listenToBaseNarratInputs(),fp.on("preUpdate",()=>{for(const[e,t]of Object.entries(ul.actions))if(t.state.config.type==="button"){const n=t;n.state.justPressed&&this.triggerListeners(e,"press",n),n.state.justReleased&&this.triggerListeners(e,"release",n)}else t.state.config.type})},createInGameInputListener(){this.inGameInputListener||(this.inGameInputListener=this.registerInputListener("in-game",{system:{press:()=>{No().openMenu("system")}},menu:{press:()=>{No().openMenu("menu")}}}))},removeInGameInputListener(){this.inGameInputListener&&(this.unregisterInputListener(this.inGameInputListener),this.inGameInputListener=null)},listenToContainerInputs(){ul.startListening()},listenToBaseNarratInputs(){},triggerListeners(e,t,n){const r=this.inputStack[this.inputStack.length-1];if(r&&r.actions[e]&&r.actions[e][t])if(n.state.config.type==="button"){const o=r.actions[e][t],i=n;o(n.state.config,i.state,i.previous)}else console.warn("Analog events not implemented yet")},getInputs(){return ul},registerInputListener(e,t){const r={id:`${Date.now()}-${Math.floor(Math.random()*1e8)}`,name:e,actions:t??{}};return this.inputStack.push(r),r},unregisterInputListener(e){const t=this.inputStack.findIndex(n=>n.id===e.id);if(t===-1)throw new Error("Input listener not found");this.inputStack.splice(t,1)},registerActions(e,t,n){e.actions[t]=n}}}),_i=eo("scenes-store",{state:()=>({scenes:{},activeScene:"engine-splash",currentOptions:{}}),getters:{isPlaying(e){return e.activeScene!=="engine-splash"&&e.activeScene!=="game-splash"&&e.activeScene!=="start-menu"}},actions:{generateSaveData(){return{activeScene:this.activeScene}},loadSaveData(e){},changeScene(e,t){const n=this.activeScene;if(n&&n!==e){const r=this.scenes[n];r.onLeaving&&r.onLeaving(),this.currentOptions={},this.activeScene=e,this.currentOptions=t||{},this.scenes[e].onStarting&&this.scenes[e].onStarting()}},getSceneConfig(e){return this.scenes[e]},onEngineSplashFinished(){this.changeScene("game-splash")},finishedScene(e){this.scenes[e].onFinished&&this.scenes[e].onFinished()},addNewScene(e){this.scenes[e.id]=e}}}),_1e={id:"game-splash-screen",style:{height:"100%",padding:"20px"},class:"flex justify-center items-center"},S1e={id:"game-splash-screen-header flex justify-center flex-col items-center",class:"flex justify-center flex-col items-center"},j1e={class:"title",id:"game-splash-title"},Vx=b.defineComponent({__name:"game-splash",setup(e){const t=b.ref(null),n=sn(),r=b.computed(()=>{var c;return((c=Ct().splashScreens)==null?void 0:c.gameSplashScreen)??{}}),o=b.computed(()=>typeof r.value.startButtonText=="string"?r.value.startButtonText:"Press to start"),i=b.computed(()=>n.loading.loaded),a=b.computed(()=>Ct().gameTitle||"Narrat Game");function s(){_i().changeScene("start-menu")}return b.onMounted(()=>{t.value=xr().registerInputListener("game-splash",{continue:{press:()=>{s()}},system:{press:()=>{s()}}}),n.options.debug&&s()}),b.onUnmounted(()=>{t.value&&xr().unregisterInputListener(t.value)}),(c,l)=>(b.openBlock(),b.createElementBlock("div",_1e,[b.createElementVNode("div",S1e,[b.createElementVNode("h1",j1e,b.toDisplayString(a.value),1),i.value?(b.openBlock(),b.createElementBlock("button",{key:0,class:"button menu-button main-menu-button large splash-start-button override",onClick:s},b.toDisplayString(o.value),1)):b.createCommentVNode("",!0)])]))}});function dc(e){if(!e.listener)return console.warn("No input listener provided for navigation"),null;const t=b.ref(-1),n=b.computed(()=>e.mode==="grid"?t.value%e.columns:0),r=b.ref([]),o=b.ref(ul.lastInputMethodUsed),i=b.ref(null);function a(){var D,L;return(D=e.container)!=null&&D.value?e.container.value.children:(L=e.elements)!=null&&L.value?e.elements.value.filter(I=>I!==null):[]}function s(){r.value=a()}const c=b.computed(()=>u(t.value));function l(D){return r.value?D>=0&&D<r.value.length:!1}function f(D){const L=t.value;if(l(D)&&(t.value=D,c.value)){o.value==="gamepad"&&c.value.classList.add("selected");const I=u(L);I&&L!==D&&I.classList.remove("selected"),e.onSelected&&e.onSelected(D)}}function u(D){return r.value?r.value[D]:null}function d(){r.value&&(t.value===0?e.loopForbidden||f(r.value.length-1):f(t.value-1))}function h(){r.value&&(t.value===r.value.length-1?e.loopForbidden||f(0):f(t.value+1))}function p(){if(!r.value)return;const D=e,L=t.value;!e.loopForbidden&&L<D.columns?f(r.value.length-1):f(t.value-e.columns)}function m(){if(!r.value)return;const D=e,L=t.value;!e.loopForbidden&&L>=r.value.length-D.columns?f(0):f(t.value+e.columns)}function v(){e.mode==="grid"?p():e.mode==="list"&&d()}function g(){e.mode==="grid"?m():e.mode==="list"&&h()}function y(){(e.mode==="grid"||e.mode==="list")&&d()}function w(){(e.mode==="grid"||e.mode==="list")&&h()}function k(){e.onChosen&&e.onChosen(t.value)}b.onMounted(()=>{R()});function $(){e.listener&&(e.onlyVertical||(delete e.listener.actions.left,delete e.listener.actions.right),e.onlyHorizontal||(delete e.listener.actions.up,delete e.listener.actions.down),e.noChoosing||delete e.listener.actions.continue,i.value&&ul.removeEventListener("change-input",i.value))}function S(){c.value&&c.value.classList.add("selected")}function E(){c.value&&c.value.classList.remove("selected")}function R(){e.listener&&(s(),i.value=D=>{o.value=D.detail,D.detail==="gamepad"?S():E()},ul.addEventListener("change-input",i.value),e.onlyVertical||(e.listener.actions.left={press:y},e.listener.actions.right={press:w}),e.onlyHorizontal||(e.listener.actions.up={press:v},e.listener.actions.down={press:g}),e.noChoosing||(e.listener.actions.continue={press:k}),f(0))}return b.onUnmounted(()=>{$()}),b.watch(()=>{var D;return(D=e.elements)==null?void 0:D.value},D=>{D&&s()}),{selectedIndex:t,selectedElement:c,currentColumn:n,buttonDown:g,buttonUp:v,buttonLeft:y,buttonRight:w,selectUp:p,selectDown:m,selectPrevious:d,selectNext:h,select:f,disable:$,mount:R}}const C1e={class:"used-save-slot flex flex-row justify-between items-center grow"},$1e={class:"flex flex-col save-slot-number-container"},T1e={class:"save-slot-number"},O1e={class:"flex flex-col justify-center save-info"},E1e={key:1,class:"save-name"},A1e={class:"flex flex-col"},P1e={key:0},M1e={key:1},I1e={key:2},N1e=["onClick"],zx=b.defineComponent({__name:"save-slot-ui",props:{saveSlot:{},id:{},actions:{},selected:{type:Boolean},inputListener:{}},emits:["choice","cancel"],setup(e,{expose:t,emit:n}){var k;const r=e,o=b.ref(null),i=b.ref(null),a=b.ref(null);t({slotContainer:a});const s=b.ref(((k=r.saveSlot.saveData)==null?void 0:k.metadata.name)??"Empty Save"),c=b.ref(0),l=b.computed(()=>r.saveSlot.saveData!==null),f=b.computed(()=>r.saveSlot.saveData),u=b.computed(()=>Ct().saves.mode),d=b.computed(()=>{const $=r.saveSlot.saveData;if($&&$.screen.layers[0]){const S=ud($.screen.layers[0]);if(S)return{backgroundImage:`url(${fd(S.background)})`}}return!1}),h=n;function p($){h("choice",$)}function m($){return f.value?ty(f.value.main.playTime/1e3):"00:00:00"}function v(){f.value&&Ime(r.saveSlot.id,s.value)}function g(){const $=Ct().saves.slots;let S="";const E=r.saveSlot.slotNumber;return E===0&&Ct().saves.mode==="manual"?"AUTO":($>=10&&E<10&&(S+="0"),$>=100&&E<100&&(S+="0"),S+E)}function y(){o.value=dc({mode:"list",container:i,listener:r.inputListener,onlyHorizontal:!0,onSelected:$=>{c.value=$},onChosen:$=>{p($)}}),o.value.mount()}function w(){o.value.disable(),o.value=null}return b.watch(()=>r.selected,($,S)=>{$&&!o.value&&y(),!$&&o.value&&w()}),b.onUnmounted(()=>{o.value&&w()}),($,S)=>(b.openBlock(),b.createElementBlock("div",{class:"save-slot flex flex-row",ref_key:"slotContainer",ref:a},[b.createElementVNode("div",C1e,[b.createElementVNode("div",$1e,[b.createElementVNode("h1",T1e,b.toDisplayString(g()),1)]),d.value?(b.openBlock(),b.createElementBlock("div",{key:0,class:"save-slot-screenshot",style:b.normalizeStyle(d.value)},null,4)):b.createCommentVNode("",!0),b.createElementVNode("div",O1e,[l.value?b.withDirectives((b.openBlock(),b.createElementBlock("input",{key:0,type:"text",class:"save-name","onUpdate:modelValue":S[0]||(S[0]=E=>s.value=E),onInput:v},null,544)),[[b.vModelText,s.value]]):(b.openBlock(),b.createElementBlock("h3",E1e,b.toDisplayString(s.value),1)),b.createElementVNode("div",A1e,[f.value?(b.openBlock(),b.createElementBlock("p",P1e,b.toDisplayString(new Date(f.value.metadata.saveDate).toLocaleString()),1)):b.createCommentVNode("",!0),f.value?(b.openBlock(),b.createElementBlock("p",M1e,"Play time: "+b.toDisplayString(m($.saveSlot)),1)):b.createCommentVNode("",!0),u.value==="game-slots"?(b.openBlock(),b.createElementBlock("p",I1e,b.toDisplayString($.saveSlot.slotType==="auto"?"Auto Save":"Manual Save"),1)):b.createCommentVNode("",!0)])]),b.createElementVNode("div",{class:"flex flex-row",ref_key:"actionsContainer",ref:i},[(b.openBlock(!0),b.createElementBlock(b.Fragment,null,b.renderList($.actions,(E,R)=>(b.openBlock(),b.createElementBlock("button",{class:b.normalizeClass(["button",{selected:$.selected&&R===c.value}]),onClick:()=>p(R),key:R},[b.createElementVNode("h3",null,b.toDisplayString(E),1)],10,N1e))),128))],512)])],512))}}),R1e=b.createElementVNode("h3",{class:"title"},"Confirmation",-1),v0=b.defineComponent({__name:"yes-no",props:{prompt:{type:String,required:!0},onConfirm:{type:Function,required:!1},onRefuse:{type:Function,required:!1}},emits:["choice"],setup(e,{emit:t}){const n=b.ref(xr().registerInputListener("yes-no",{cancel:{press:()=>{a(!1)}},continue:{press:()=>{a(!0)}}})),r=b.ref(null);dc({mode:"list",container:r,listener:n.value,onChosen:s=>{a(s===0)}});const o=e,i=t;function a(s){s===!0&&o.onConfirm?o.onConfirm():s===!1&&o.onRefuse&&o.onRefuse(),i("choice",s)}return b.onMounted(()=>{}),b.onUnmounted(()=>{n.value&&xr().unregisterInputListener(n.value)}),(s,c)=>(b.openBlock(),b.createBlock(Bs,{onClose:c[2]||(c[2]=()=>a(!1)),containerCssClass:"yes-no-modal"},{header:b.withCtx(()=>[R1e]),body:b.withCtx(()=>[b.createElementVNode("h3",null,b.toDisplayString(e.prompt),1),b.createElementVNode("div",{class:"flex justify-center",ref_key:"buttonsContainer",ref:r},[b.createElementVNode("button",{class:"button",onClick:c[0]||(c[0]=()=>a(!0))},"Yes"),b.createElementVNode("button",{class:"button",onClick:c[1]||(c[1]=()=>a(!1))},"No")],512)]),_:1}))}}),D1e={class:"title"},L1e={key:0},B1e={class:"saves-section"},F1e=b.createElementVNode("h3",{class:"saves-section-title"},"Auto save",-1),V1e={class:"saves-section"},z1e=b.createElementVNode("h3",{class:"saves-section-title"},"Manual Saves",-1),q1e={key:1,class:"saves-section"},U1e=b.createElementVNode("h3",{class:"saves-section-title"},"Save Slots",-1),H1e={class:"saves-container flex flex-col"},pV=b.defineComponent({__name:"save-slots",props:{mode:{}},emits:["chosen","close"],setup(e,{emit:t}){const n=e,r=b.ref(xr().registerInputListener("save-slots",{cancel:{press:()=>{R()}}})),o=b.ref(0),i=b.reactive([]),a=b.computed(()=>i.slice(0,1)),s=b.computed(()=>i.slice(1)),c=b.ref([]),l=b.ref([]),f=b.ref([]),u=b.ref([]),d=b.ref([]);b.ref({mode:"list",elements:u,listener:r.value,onlyVertical:!0,noChoosing:!0,onSelected:I=>{o.value=I}});const h=dc({mode:"list",elements:u,listener:r.value,onlyVertical:!0,noChoosing:!0,onSelected:I=>{o.value=I}}),p=b.computed(()=>{const I=o.value;return d.value.length<I+1?null:d.value[I].id}),m=b.reactive(n.mode==="load"?["Load","Delete"]:["Choose"]),v=b.computed(()=>Ct().saves.mode),g=b.reactive({prompt:"Are you sure you want to delete this save file?",saveToDelete:null,onConfirm:()=>{E(g.saveToDelete),g.saveToDelete=null},onRefuse:()=>{g.saveToDelete=null}}),y=b.reactive({prompt:"Are you sure you want to overwrite this save file?",saveToOverwrite:null,onConfirm:()=>{$(y.saveToOverwrite),y.saveToOverwrite=null},onRefuse:()=>{y.saveToOverwrite=null}}),w=t;b.onBeforeMount(()=>{lc().slots.forEach((q,N)=>{i[N]=q})});function k(){u.value=v.value==="manual"?[...l.value.map(B=>B.slotContainer),...f.value.map(B=>B.slotContainer)]:c.value.map(B=>B.slotContainer);const I=v.value==="manual"?[...a.value,...s.value]:i;d.value=I.map(B=>({id:B.id}))}b.onMounted(()=>{k()}),b.onUnmounted(()=>{h.value&&(h.value.disable(),h.value=null),r.value&&xr().unregisterInputListener(r.value)});function $(I){w("chosen",{slotId:I})}function S(I){const B=L(I);if(B){if(Ct().saves.mode==="manual"&&B.slotType==="auto"){sn().alert("Sorry","Can't delete the auto save slot!");return}g.saveToDelete=I}}function E(I){Mme(I);const B=i.find(q=>q.id===I);B&&(B.saveData=null),k()}function R(){w("close")}function D(I,B){const q=m[B];q==="Load"?$(I):q==="Delete"?S(I):q==="Choose"&&(y.saveToOverwrite=I)}function L(I){return i.find(B=>B.id===I)}return(I,B)=>(b.openBlock(),b.createBlock(Bs,{onClose:R,containerCssClass:"save-modal",cantClose:!1},{header:b.withCtx(()=>[b.createElementVNode("h3",D1e,b.toDisplayString(I.mode==="load"?"Choose a save to load":"Pick a slot to save the game"),1)]),body:b.withCtx(()=>[v.value==="manual"?(b.openBlock(),b.createElementBlock("div",L1e,[b.createElementVNode("div",B1e,[F1e,b.createVNode(b.TransitionGroup,{name:"list",tag:"div"},{default:b.withCtx(()=>[(b.openBlock(!0),b.createElementBlock(b.Fragment,null,b.renderList(a.value,q=>(b.openBlock(),b.createBlock(zx,{key:q.id,saveSlot:q,id:q.id,actions:m,onChoice:N=>D(q.id,N),inputListener:r.value,selected:p.value===q.id,ref_for:!0,ref_key:"autoSlotsElements",ref:l},null,8,["saveSlot","id","actions","onChoice","inputListener","selected"]))),128))]),_:1})]),b.createElementVNode("div",V1e,[z1e,b.createVNode(b.TransitionGroup,{name:"list",tag:"div"},{default:b.withCtx(()=>[(b.openBlock(!0),b.createElementBlock(b.Fragment,null,b.renderList(s.value,q=>(b.openBlock(),b.createBlock(zx,{key:q.id,saveSlot:q,id:q.id,actions:m,onChoice:N=>D(q.id,N),inputListener:r.value,selected:p.value===q.id,ref_for:!0,ref_key:"manualSlotsElements",ref:f},null,8,["saveSlot","id","actions","onChoice","inputListener","selected"]))),128))]),_:1})])])):(b.openBlock(),b.createElementBlock("div",q1e,[U1e,b.createElementVNode("div",H1e,[b.createVNode(b.TransitionGroup,{name:"list",tag:"div"},{default:b.withCtx(()=>[(b.openBlock(!0),b.createElementBlock(b.Fragment,null,b.renderList(i,q=>(b.openBlock(),b.createBlock(zx,{key:q.id,saveSlot:q,id:q.id,actions:m,onChoice:N=>D(q.id,N),selected:p.value===q.id,inputListener:r.value,ref_for:!0,ref_key:"saveSlotsElements",ref:c},null,8,["saveSlot","id","actions","onChoice","selected","inputListener"]))),128))]),_:1})])])),g.saveToDelete?(b.openBlock(),b.createBlock(v0,{key:2,prompt:g.prompt,onRefuse:g.onRefuse,onConfirm:g.onConfirm},null,8,["prompt","onRefuse","onConfirm"])):b.createCommentVNode("",!0),y.saveToOverwrite?(b.openBlock(),b.createBlock(v0,{key:3,prompt:y.prompt,onRefuse:y.onRefuse,onConfirm:y.onConfirm},null,8,["prompt","onRefuse","onConfirm"])):b.createCommentVNode("",!0)]),_:1}))}}),W1e=b.defineComponent({__name:"start-menu-button",props:{button:{}},emits:["click"],setup(e){return(t,n)=>(b.openBlock(),b.createElementBlock("button",{class:b.normalizeClass(["button menu-button main-menu-button large override",t.button.cssClass]),onClick:n[0]||(n[0]=r=>t.$emit("click"))},b.toDisplayString(t.button.title),3))}});class qx extends Bx{setup(t=!1){const r=t?"keydown":"keyup",o=dp(a=>{ha.emit("debouncedKeydown",a)},10,{isImmediate:!0,maxWait:10}),i=Gr().inputsContainer;i.addEventListener("keydown",a=>{ha.emit("keydown",a)}),i.addEventListener(r,a=>{o(a)})}}const ha=new qx,Ux=eo("startMenu",{state:()=>({buttons:[]}),actions:{addButtonsFromPlugins(){yn.plugins.forEach(t=>{t.startMenuButtons&&t.startMenuButtons.forEach(n=>{const r=window.narrat.app;n.popupComponent&&r.component(n.popupComponent.name,n.popupComponent.component),this.buttons.push(n)})})}}});function K1e(){SV()}function mV(){K1e(),sn().menuReturn()}async function G1e(e){if(Ct().saves.mode==="manual"){const t=ax();t&&(e=t.id)}sn().setSaveSlot(e),jV(lc().globalSave),vV(),un().runGame()}function vV(){Po().stopAll(),uu("onPressStart"),un().start(),sn().prepareToPlay(),yn.callHook("onGameStart")}async function J1e(e,t){if(Ct().saves.mode==="manual"){const n=ax();n&&(t=n.id)}if(sn().setSaveSlot(t),vV(),e.saveData){uwe({gameSave:e.saveData,globalSave:lc().globalSave}),Po().reloadAudio(e.saveData.audio);const n=un(),r=Ct().saves.runOnReload;typeof r=="string"&&await un().runLabelFunction(r),n.jumpToLabel(e.saveData.vm.lastLabel)}}const Q1e={id:"game-menu"},Y1e={id:"game-header",class:"flex flex-col justify-between items-center"},X1e={id:"game-title-container"},Z1e={id:"game-title-text"},ebe={class:"title"},Hx=b.defineComponent({__name:"StartMenu",setup(e){const t=b.ref(xr().registerInputListener("start-menu",{})),n=b.ref([]),r=b.ref(null),o=b.ref(!1),i=b.ref(!1),a=b.ref(null),s=b.ref(null),c=b.ref(!1),l=b.ref(!1),f=b.ref(null),u=Ux(),d=b.ref(!1),h=b.ref(null),p=b.computed(()=>u.buttons),m=dc({mode:"list",container:r,listener:t.value,onChosen:q=>{v(n.value[q])}});function v(q){switch(q.id){case"continue":E();break;case"new-game":g();break;case"load-game":R();break;case"exit":sn().exitGame();break;default:w(q);break}}async function g(){o.value&&Ct().saves.mode==="manual"&&!Ct().saves.disabled?l.value=!0:y()}async function y(){if(s.value===null)if(Ct().saves.mode==="manual"){const q=ax();if(!q){St("No autosave found");return}s.value=q.id}else{const q=Ame();if(!q){St("No free slot found");return}s.value=q}l.value=!1,await G1e(s.value)}function w(q){const N=p.value.findIndex(X=>X.id===q.id),W=p.value[N];W.action&&W.action(),W.popupComponent&&(d.value=W)}function k(){d.value=!1}function $(){l.value=!1}async function S(){if(!s.value)return;const q=Zh(s.value);if(!q){St("No save file found");return}J1e(q,s.value)}function E(){typeof a.value=="string"&&(s.value=a.value,S())}function R(){c.value=!0}function D({slotId:q}){const N=Zh(q);N&&N.saveData?(s.value=q,S()):g()}b.onMounted(()=>{const q=lc();q.slots.some(N=>N.saveData)&&(o.value=!0),(Ct().saves.mode==="manual"||q.slots.some(N=>!N.saveData))&&(i.value=!0),q.lastSaveSlot&&Zh(q.lastSaveSlot)&&(a.value=q.lastSaveSlot),L(),f.value=ha.on("debouncedKeydown",N=>{N.key===" "&&y(),N.key==="c"&&E()}),b.nextTick(()=>{m.select(0)}),Fi().options.defaultMusic&&(h.value=bve(Fi().options.defaultMusic))});function L(){const q=Ct().saves.disabled;a.value&&!q&&n.value.push(I({id:"continue",title:"Continue",cssClass:"continue-button"})),i.value&&n.value.push(I({id:"new-game",title:"New Game",cssClass:"start-button"})),o.value&&!q&&n.value.push(I({id:"load-game",title:"Load Game",cssClass:"continue-button"}));for(const N of p.value)n.value.push({id:N.id,title:N.text,cssClass:`${N.id}-start-menu-button`});n.value.push(I({id:"exit",title:"Exit",cssClass:"exit-button"}))}function I({id:q,title:N,cssClass:W}){const X=Ct().menuButtons[q];if(X){let H=W;return X.cssClass&&(H=`${X.cssClass} ${W}`),{id:q,title:X.text??N,cssClass:H}}return{id:q,title:N,cssClass:W}}b.onUnmounted(()=>{if(t.value&&xr().unregisterInputListener(t.value),f.value&&ha.off("debouncedKeydown",f.value),typeof h.value=="number"){const q=Fi().options.defaultMusic;wve(q,h.value)}});const B=b.computed(()=>Ct().gameTitle);return(q,N)=>(b.openBlock(),b.createElementBlock("div",Q1e,[c.value?(b.openBlock(),b.createBlock(pV,{key:0,mode:"load",onChosen:D,onClose:N[0]||(N[0]=W=>c.value=!1)})):b.createCommentVNode("",!0),l.value?(b.openBlock(),b.createBlock(v0,{key:1,prompt:"This will override your previous autosave, are you sure?",onConfirm:y,onRefuse:$})):b.createCommentVNode("",!0),b.createElementVNode("div",Y1e,[b.createElementVNode("div",X1e,[b.createElementVNode("h1",Z1e,b.toDisplayString(B.value),1)]),b.createElementVNode("div",{class:"flex flex-col start-menu-buttons-container",ref_key:"buttonsContainer",ref:r},[(b.openBlock(!0),b.createElementBlock(b.Fragment,null,b.renderList(n.value,W=>(b.openBlock(),b.createBlock(W1e,{key:W.id,button:W,onClick:X=>v(W)},null,8,["button","onClick"]))),128))],512)]),d.value?(b.openBlock(),b.createBlock(b.Teleport,{key:2,to:"#narrat-app-container"},[b.createVNode(Bs,{onClose:k,class:b.normalizeClass(`start-menu-popup-${d.value.id}`)},{header:b.withCtx(()=>[b.createElementVNode("h3",ebe,b.toDisplayString(d.value.text),1)]),body:b.withCtx(()=>[d.value.popupComponent?(b.openBlock(),b.createBlock(b.resolveDynamicComponent(d.value.popupComponent.component),{key:0,onClose:k},null,32)):b.createCommentVNode("",!0)]),_:1},8,["class"])])):b.createCommentVNode("",!0)]))}});function g0(e){const t=U0().characters[e];return t||St(`Character ${e} not found`),t}function tbe(e,t){const n=g0(e);if(n&&(t||(t="default"),n.sprites)){const r=n.sprites[t];return r==="none"?void 0:typeof r=="string"?{image:r}:r}}function gV(e){return`${U0().config.imagesPath}${e}`}function nbe(e){return typeof e=="object"&&Object.hasOwn(e,"image")}function rbe(e){return typeof e=="object"&&Object.hasOwn(e,"video")}function Wx(e){var t;return e?((t=g0(e))==null?void 0:t.style)||{}:{}}const obe=["src"],ibe=["autoplay","loop","muted"],abe=["src"],sbe=b.defineComponent({__name:"dialog-picture",props:{picture:{},video:{},character:{},pose:{}},setup(e){const t=e,n=b.computed(()=>t.video),r=b.computed(()=>Gr().layoutMode),o=b.computed(()=>{var c;const a={};if(!t.character)return{};t.character&&(a[t.character]=!0);const s=g0(t.character);return(c=s==null?void 0:s.style)!=null&&c.portraitCssClass&&(a[s.style.portraitCssClass]=!0),a}),i=b.computed(()=>{var h,p;const a=Gr(),s=Ct().layout;let c=0,l=0;const f=s.portraits;if(r.value==="vertical"){const m=((h=f.offset)==null?void 0:h.portrait)??{right:0,bottom:0};c=20+m.right,l=a.dialogHeight+m.bottom}else{const m=((p=f.offset)==null?void 0:p.landscape)??{right:0,bottom:0},v=Ct().dialogPanel.rightOffset??wx.dialogPanel.rightOffset;c=G0()-10+m.right+v,l=200+m.bottom}let u=s.portraits.width,d=s.portraits.height;return t.video&&(u=t.video.width??u,d=t.video.height??d),t.picture&&(u=t.picture.width??u,d=t.picture.height??d),{right:`${c}px`,bottom:`${l}px`,width:`${u}px`,height:`${d}px`}});return(a,s)=>{var c;return b.openBlock(),b.createElementBlock("div",{class:b.normalizeClass(["dialog-picture override",o.value]),style:b.normalizeStyle(i.value)},[a.picture?(b.openBlock(),b.createElementBlock("img",{key:0,src:b.unref(ci)(b.unref(gV)((c=a.picture)==null?void 0:c.image)),class:b.normalizeClass(["picture override",o.value])},null,10,obe)):b.createCommentVNode("",!0),n.value?(b.openBlock(),b.createElementBlock("video",{key:1,class:"picture override",autoplay:n.value.autoplay!==!1,loop:n.value.loop!==!1,muted:!!n.value.muted},[b.createElementVNode("source",{src:b.unref(ci)(b.unref(gV)(n.value.video))},null,8,abe)],8,ibe)):b.createCommentVNode("",!0)],6)}}});function cbe(){return Fi().dialogAudio}function yV(e){const t=cbe();if(t){if(t.characterAudio&&t.characterAudio[e])return t.characterAudio[e];if(t.defaultAudio)return t.defaultAudio}}function bV(e,t){if(typeof t!="string")return;const n=yV(e);return n==null?void 0:n.soundPerLetter}function lbe(e,t){if(typeof t!="string")return;const n=bV(e,t);if(!n)return;const r=n;let o="";return r.prefix&&(o+=r.prefix),o+=t,r.suffix&&(o+=r.suffix),o}function ube(e,t){if(typeof t!="string")return;const n=t.toLowerCase(),r=lbe(e,n);if(typeof r!="string")return;const o=Ua(r);if(o){const i=bV(e,n);let a=1;i.volume&&(a=i.volume);const s=Po().audioVolume("sound",r)*a;o.volume(s),o.play()}}function fbe(e){const t=yV(e);if(t!=null&&t.soundOnNewLine){const n=Ua(t.soundOnNewLine);if(n){const r=Po().audioVolume("sound",t.soundOnNewLine);n.volume(r),n.play()}}}const dbe=["innerHTML"],hbe=["innerHTML"],pbe=["innerHTML"],mbe={key:1},vbe=["onClick","innerHTML"],gbe={key:1},ybe={key:2,class:"buttons-container"},bbe=b.defineComponent({__name:"dialog-box",props:{options:{},active:{type:Boolean},inputListener:{}},setup(e,{expose:t}){const n=b.ref(null),r=b.ref(""),o=b.ref(!1),i=b.ref(null),a=b.ref(null),s=b.ref(!1),c=b.ref(null),l=b.ref(null),f=b.ref(null),u=b.ref(null),d=b.ref(null),h=e,p=b.ref(null);h.active&&(p.value=dc({mode:"list",container:n,listener:h.inputListener,onlyVertical:!0,onChosen:oe=>{xe.value&&ee.value?$(ee.value[oe]):y(" ")}})),b.onMounted(()=>{W(),s.value=!0}),b.onUnmounted(()=>{m(),B(),A({unmounted:!0})});function m(){i.value&&(clearTimeout(i.value),i.value=null),v()}function v(){p.value&&(p.value.disable(),p.value=null)}function g(oe){y(oe.key)}function y(oe){if(!xe.value){s.value&&a&&oe===" "&&A({pressedSpace:!0});return}if(xe.value&&h.options.textField&&oe==="Enter"&&L(),xe.value&&!h.options.textField){let ye=-1;switch(oe){case" ":ye=0;break;case"1":ye=0;break;case"2":ye=1;break;case"3":ye=2;break;case"4":ye=3;break;case"5":ye=4;break;case"6":ye=5;break;case"7":ye=6;break;case"8":ye=7;break}ye!==-1&&ee.value&&ye<ee.value.length?$(ee.value[ye]):ye===0&&$(ye)}}function w(){xe.value||s.value&&a&&A({pressedSpace:!0})}function k(){o.value||$(0)}function $(oe){S();let ye;typeof oe=="object"?ye=oe.originalIndex:ye=oe,sn().playerAnswered(ye)}function S(){m(),A({unmounted:!0}),o.value=!0}function E(oe){const ye={};return oe.allowed||(ye.pointerEvents="none",ye.textDecoration="line-through"),ye}function R(oe,ye){const de={index:oe+1,choice:ye.choice};let Fe='<span class="choice-index">%{$index}. </span> <span class="choice-text">%{$choice}</span>';if(aS().choiceTextTemplate&&(Fe=aS().choiceTextTemplate),ye.flag){const Y=Bz(ye.flag);Y!=null&&Y.textTemplate&&(Fe=Y.textTemplate)}return W9(de,Fe)}function D(oe){const ye={};if(oe.allowed||(ye["strike-anim"]=!0),oe.seenBefore&&(ye["seen-before"]=!0),oe.flag){const de=Bz(oe.flag);de!=null&&de.cssClass&&(ye[de.cssClass]=!0)}return ye}function L(){const oe=r.value;B(),sn().playerAnswered(oe)}function I(){h.options.textField&&(i.value=setTimeout(()=>{xe.value&&(d.value=xr().registerInputListener("text-field-input-grabber",{}),u.value&&u.value.focus())},100))}function B(){d.value&&(xr().unregisterInputListener(d.value),d.value=null)}function q(oe,ye){const de=h.options.text.substring(oe,ye);a.value.text+=de;const Fe=de.substring(0,1);return ube(h.options.styleId,Fe),ye}function N(oe){const ye=oe[0];return a.value.text+=ye,a.value.skippedChars+=ye.length,ye.length}function W(){if(!h.options.old)if(cr().playMode==="skip")X();else if(fbe(h.options.styleId),Ct().dialogPanel.animateText){a.value={text:"",index:0,startTime:Date.now(),timer:null,skippedChars:0,tags:mve(h.options.text),finished:!1};const oe=a.value;oe.timer=setInterval(()=>{K()},30)}else O.value&&(c.value=setTimeout(()=>{A()},(Ct().dialogPanel.textSpeed??a0)*h.options.text.length))}function X(){cr().playMode==="skip"&&!h.options.old&&(O.value?l.value=setTimeout(()=>{A()},100):(cr().toggleSkip(),A({unmounted:!0})))}function H(){cr().playMode==="auto"&&!h.options.old&&O.value&&xe&&k()}function K(){const oe=a.value;if(!oe)return;const ye=oe.index,de=Date.now()-oe.startTime;let Fe=!1,Y=Math.round(de/(Ct().dialogPanel.textSpeed??a0))+oe.skippedChars;if(Y>h.options.text.length&&(Fe=!0,oe.finished=!0,Y=h.options.text.length),Y!==oe.index){let Q=ye;for(;oe.tags.length>0&&Y>=oe.tags[0].index;){Q=q(Q,oe.tags[0].index);const ve=N(oe.tags.shift());Q+=ve,Y+=ve}Q=q(Q,Y),oe.index=Q}Fe&&A()}function A({unmounted:oe,pressedSpace:ye}={}){I(),setTimeout(()=>{p.value&&p.value.select(0)},10),a.value&&(a.value.timer&&clearInterval(a.value.timer),a.value=null),c.value&&!ye&&clearTimeout(c.value),l.value&&clearTimeout(l.value),f.value&&clearTimeout(f.value),!oe&&!ye&&cr().playMode!=="normal"&&O&&(f.value=setTimeout(()=>{k()},cr().playMode==="auto"?Ct().dialogPanel.timeBetweenLines??Kf.common.dialogPanel.timeBetweenLines:0))}const T=b.computed(()=>h.options.title?" &nbsp;–&nbsp; ":""),x=b.computed(()=>({...Wx(h.options.styleId).boxCss})),O=b.computed(()=>!ee.value&&!h.options.textField),j=b.computed(()=>{const oe={};return h.options.title&&(oe["dialog-box-followup"]=!0),h.options.old?oe["dialog-box-old"]=!0:oe["dialog-box-new"]=!0,oe}),C=b.computed(()=>{const oe=Wx(h.options.styleId);return{color:oe.color,...oe.nameCss}}),_=b.computed(()=>Wx(h.options.styleId).textCss),F=b.computed(()=>a.value?a.value.text:h.options.text),ee=b.computed(()=>{if(h.options.choices)return h.options.choices}),ce=b.computed(()=>cr().playMode==="skip"),_e=b.computed(()=>cr().playMode==="auto"),xe=b.computed(()=>h.active&&s.value&&!o.value&&!f.value&&!a.value&&h.options.interactive&&!Ie.value),se=sn(),Ie=b.computed(()=>se.paused);return b.watch(()=>h.options,(oe,ye)=>{!ye.old&&oe.old&&a&&A({unmounted:!0})}),b.watch(ce,(oe,ye)=>{oe&&!ye&&X()}),b.watch(_e,(oe,ye)=>{oe&&!ye&&H()}),t({keyboardEvent:g}),(oe,ye)=>{const de=b.resolveDirective("visible");return b.openBlock(),b.createElementBlock("div",{class:b.normalizeClass(["dialog-box w-full override",j.value]),style:b.normalizeStyle(x.value)},[b.createElementVNode("div",{class:"dialog-content",onClick:w},[oe.options.title?(b.openBlock(),b.createElementBlock("span",{key:0,class:"dialog-title override",style:b.normalizeStyle(C.value),innerHTML:oe.options.title},null,12,dbe)):b.createCommentVNode("",!0),b.createElementVNode("span",{class:"dialog-text dialog-separator override",style:b.normalizeStyle(_.value),innerHTML:T.value},null,12,hbe),b.createElementVNode("span",{class:b.normalizeClass(["dialog-text override",oe.options.cssClass]),style:b.normalizeStyle(_.value),innerHTML:F.value},null,14,pbe),oe.options.old?b.createCommentVNode("",!0):b.withDirectives((b.openBlock(),b.createElementBlock("div",mbe,[ee.value?(b.openBlock(),b.createElementBlock("div",{key:0,class:"dialog-choices",ref_key:"choicesDiv",ref:n},[(b.openBlock(!0),b.createElementBlock(b.Fragment,null,b.renderList(ee.value,(Fe,Y)=>(b.openBlock(),b.createElementBlock("p",{key:Y,style:b.normalizeStyle(E(Fe)),class:b.normalizeClass([D(Fe),"dialog-choice override"]),onClick:Q=>$(Fe),innerHTML:R(Y,Fe)},null,14,vbe))),128))],512)):oe.options.textField?(b.openBlock(),b.createElementBlock("div",gbe,[b.withDirectives(b.createElementVNode("input",{autofocus:"",type:"text",class:"label-input input",ref_key:"playerInput",ref:u,id:"player-input-field","onUpdate:modelValue":ye[0]||(ye[0]=Fe=>r.value=Fe)},null,512),[[b.vModelText,r.value]]),b.createElementVNode("button",{onClick:L,class:"button",id:"player-input-submit"}," Submit ")])):(b.openBlock(),b.createElementBlock("div",ybe,[b.createElementVNode("div",{onClick:ye[1]||(ye[1]=Fe=>$(0)),ref:"continue",class:"interact-button button override"}," Continue ",512)]))])),[[de,xe.value]])])],6)}}}),wbe={key:0,class:"auto-play-feedback-container"},kbe=b.defineComponent({__name:"AutoPlayFeedback",setup(e){const t=cr(),n=b.computed(()=>t.playMode==="auto"),r=b.computed(()=>t.playMode==="skip"),o=b.computed(()=>n.value?"auto-play-feedback-auto":r.value?"auto-play-feedback-skip":{}),i=b.computed(()=>n.value?"Auto Play":r.value?"Skip":"");return(a,s)=>i.value?(b.openBlock(),b.createElementBlock("div",wbe,[b.createElementVNode("div",{class:b.normalizeClass(["auto-play-feedback",o.value])},b.toDisplayString(i.value),3)])):b.createCommentVNode("",!0)}}),xbe=b.createElementVNode("div",{class:"anchor"},null,-1),Kx=b.defineComponent({__name:"game-dialog",setup(e){const t=b.computed(()=>Gr().layoutMode),n=b.computed(()=>xr().inGameInputListener),r=b.ref(sn().inScript),o=b.ref(null),i=Gr(),a=un(),s=b.computed(()=>a.stack),c=cr(),l=b.computed(()=>c.dialog),f=b.ref(null),u=b.ref(null),d=b.ref(null),h=b.computed(()=>{let B="0px";const q=Ct().layout.dialogBottomPadding;return typeof q=="number"?B=`${q}px`:typeof q=="string"&&(B=q),{paddingBottom:B}}),p=b.computed(()=>{if(l.value.length>0)return l.value[l.value.length-1]}),m=b.computed(()=>{if(p.value)return p.value.speaker}),v=b.computed(()=>{if(p.value)return p.value.pose}),g=b.computed(()=>{if(p.value){const B=m.value;let q=v.value;return B?(q||(q="idle"),q):void 0}}),y=b.computed(()=>{if(!g.value)return;const B=m.value;return tbe(B,g.value)}),w=b.computed(()=>{const B=y.value;if(nbe(B))return B}),k=b.computed(()=>{const B=y.value;if(rbe(B))return B}),$=b.computed(()=>i.dialogWidth),S=b.computed(()=>sn().inScript);b.watch(S,B=>{B?r.value=!0:cr().playMode!=="normal"?(cr().playMode==="skip"&&(cr().playMode="normal"),o.value=setTimeout(()=>{r.value=!1},500)):r.value=!1}),b.onMounted(()=>{if(n.value){const q=n.value;q.actions.autoPlay={press:()=>{cr().toggleAutoPlay()}},q.actions.skip={press:()=>{cr().toggleSkip()}}}const B=q=>{u.value&&u.value.keyboardEvent&&u.value.keyboardEvent(q)};B.value=ha.on("debouncedKeydown",B)}),b.onUnmounted(()=>{n.value&&(delete n.value.actions.autoPlay,delete n.value.actions.skip),d.value&&ha.off("debouncedKeydown",d.value),o.value&&clearTimeout(o.value)});const E=b.computed(()=>{let B;const q=`${Gr().dialogHeight}px`,N={};if(Gr().overlayMode){N.position="absolute";const W=Ct().dialogPanel.rightOffset??Kf.common.dialogPanel.rightOffset;N.right=`${W}px`;const X=Ct().dialogPanel.bottomOffset??Kf.common.dialogPanel.bottomOffset;N.bottom=`${X}px`}return{...N,width:t.value==="horizontal"?`${$.value}px`:"100%",height:q,transform:B,transformOrigin:"right"}});function R(){cr().toggleAutoPlay()}function D(){cr().toggleSkip()}function L(B,q){const N=g0(B.speaker);let W=(N==null?void 0:N.name)??"Missing Character";return q>=1&&l.value[q-1].speaker===B.speaker&&(W=void 0),B.choices&&B.choices.forEach(X=>{X.choice=$s(X.choice)}),{title:W??"",text:B.text,cssClass:B.cssClass,styleId:B.speaker,choices:B.choices,old:q<l.value.length-1,interactive:B.interactive,textField:B.textField}}function I(B){return B===c.dialog.length-1&&s.value.length>0}return b.watch(l.value,B=>{if(f.value){const q=f.value;q.scrollTop=q.scrollHeight+1e8}}),(B,q)=>(b.openBlock(),b.createElementBlock(b.Fragment,null,[b.createVNode(kbe),b.createVNode(b.Transition,{name:"fade"},{default:b.withCtx(()=>[(w.value||k.value)&&b.unref(i).showDialog?(b.openBlock(),b.createBlock(sbe,{key:0,picture:w.value,video:k.value,character:m.value,pose:v.value},null,8,["picture","video","character","pose"])):b.createCommentVNode("",!0)]),_:1}),b.createVNode(b.Transition,{name:"dialog-transition"},{default:b.withCtx(()=>[b.unref(i).showDialog?(b.openBlock(),b.createElementBlock("div",{key:0,class:"dialog override",ref_key:"dialogRef",ref:f,style:b.normalizeStyle(E.value)},[b.createVNode(b.TransitionGroup,{name:"list",tag:"div",class:"dialog-container w-full override",style:b.normalizeStyle(h.value)},{default:b.withCtx(()=>[(b.openBlock(!0),b.createElementBlock(b.Fragment,null,b.renderList(l.value,(N,W)=>(b.openBlock(),b.createBlock(bbe,{ref_for:!0,ref:X=>u.value=X,key:N.id,options:L(N,W),active:I(W),inputListener:n.value},null,8,["options","active","inputListener"]))),128))]),_:1},8,["style"]),(b.openBlock(),b.createBlock(b.Teleport,{to:"#narrat-app"},[b.createElementVNode("div",{class:"auto-skip-buttons flex"},[b.createElementVNode("div",{class:"button menu-toggle-button auto-button auto",onClick:R}," Auto "),b.createElementVNode("div",{class:"button menu-toggle-button auto-button skip",onClick:D}," Skip ")])])),xbe],4)):b.createCommentVNode("",!0)]),_:1})],64))}}),_be=["id"],Sbe=["src"],jbe={class:"tab-title"},wV=b.defineComponent({__name:"tab-selector",props:{tab:{},active:{type:Boolean}},emits:["click"],setup(e,{emit:t}){const n=e,r=t,o=b.computed(()=>n.active?"tab-active":"tab-inactive");function i(){r("click")}return(a,s)=>(b.openBlock(),b.createElementBlock("div",{class:b.normalizeClass(["tab",o.value]),id:`tab-${a.tab.id}`,onClick:i},[b.createElementVNode("div",{class:b.normalizeClass(["tab-title-container",a.active?"active":""])},[a.tab.icon?(b.openBlock(),b.createElementBlock("img",{key:0,src:a.tab.icon,alt:"tab icon",class:"tab-icon"},null,8,Sbe)):b.createCommentVNode("",!0),b.createElementVNode("span",jbe,b.toDisplayString(a.tab.label),1)],2)],10,_be))}}),Cbe={class:"tabs-controller"},$be={key:0,class:"tabs-controller__tabs"},Tbe={key:1,class:"tab-content"},Obe={key:2},Ebe=[b.createElementVNode("div",{class:"tab-content__empty"},[b.createElementVNode("p",null,"No tab selected")],-1)],Abe=b.defineComponent({__name:"TabsController",props:{tabs:{},defaultTab:{}},emits:["tab-change","close"],setup(e,{emit:t}){const n=b.ref(xr().registerInputListener("tabs-controller",{cancel:{press:()=>{r("close")}},system:{press:()=>{r("close")}},menu:{press:()=>{r("close")}},previousTab:{press:()=>{i.value>0&&a(i.value-1)}},nextTab:{press:()=>{i.value<o.tabs.length-1&&a(i.value+1)}}})),r=t,o=e,i=b.ref(o.defaultTab);function a(c){i.value=c,r("tab-change",c)}const s=b.computed(()=>o.tabs[i.value]);return b.onUnmounted(()=>{n.value&&(xr().unregisterInputListener(n.value),n.value=null)}),(c,l)=>(b.openBlock(),b.createElementBlock("div",Cbe,[c.tabs.length>1?(b.openBlock(),b.createElementBlock("div",$be,[(b.openBlock(!0),b.createElementBlock(b.Fragment,null,b.renderList(c.tabs,(f,u)=>(b.openBlock(),b.createBlock(wV,{key:f.id,tab:f,active:u===i.value,onClick:()=>a(u),inputListener:n.value},null,8,["tab","active","onClick","inputListener"]))),128))])):b.createCommentVNode("",!0),s.value?(b.openBlock(),b.createElementBlock("div",Tbe,[s.value?(b.openBlock(),b.createBlock(b.resolveDynamicComponent(s.value.component),{key:0,inputListener:n.value,onClose:l[0]||(l[0]=f=>c.$emit("close"))},null,40,["inputListener"])):b.createCommentVNode("",!0)])):(b.openBlock(),b.createElementBlock("div",Obe,Ebe))]))}}),Pbe={class:"menu-container menu-toggle"},Mbe=["onClick","id"],Ibe={class:"title"},Gx=b.defineComponent({__name:"menu-buttons",setup(e){const t=No(),n=b.ref(null);b.onMounted(()=>{yn.callHook("onGameMounted")}),b.onUnmounted(()=>{n.value&&ha.off("keydown",n.value),yn.callHook("onGameUnmounted")});function r(f){No().activeMenu=f}const o=b.computed(()=>t.menus),i=b.computed(()=>t.menu),a=b.computed(()=>{var f;return(((f=i.value)==null?void 0:f.tabs)??[]).filter(u=>u.condition?u.condition():!0).map(u=>({id:u.id,label:u.text,component:u.component}))});function s(){t.closeMenu()}function c(f){t.setActiveTab(f)}function l(){return s()}return(f,u)=>(b.openBlock(),b.createElementBlock("div",Pbe,[(b.openBlock(!0),b.createElementBlock(b.Fragment,null,b.renderList(o.value,(d,h)=>(b.openBlock(),b.createElementBlock("button",{key:d.id,onClick:p=>r(d.id),id:d.cssId??`${h}-menu-button`,class:"button menu-toggle-button"},b.toDisplayString(d.label),9,Mbe))),128)),i.value?(b.openBlock(),b.createBlock(b.Teleport,{key:0,to:"#narrat-app-container"},[b.createVNode(Bs,{containerCssClass:{[i.value.cssClass]:!0,"menu-modal":!0},onClose:s},{header:b.withCtx(()=>{var d;return[b.createElementVNode("h3",Ibe,b.toDisplayString(((d=b.unref(t).tab)==null?void 0:d.text)??i.value.label),1)]}),body:b.withCtx(()=>[b.createVNode(Abe,{onTabChange:c,onClose:l,tabs:a.value,defaultTab:i.value.activeTab},null,8,["tabs","defaultTab"])]),_:1},8,["containerCssClass"])])):b.createCommentVNode("",!0)]))}});function kV(e){const t={};return e.selected&&(t.selected=!0),e.clickable&&e.viewportClickable&&!e.transitioning&&(t.interactable=!0),(!e.clickable||!e.viewportClickable)&&(t.disabled=!0),e.transitioning&&(t.transitioning=!0),e.greyed&&(t.greyed=!0),e.hidden&&(t.hidden=!0),e.cssClass&&(t[e.cssClass]=!0),t}function Nbe(e,t,n){return{selected:t,clickable:e.onClick!==void 0,viewportClickable:m0(e),transitioning:n,greyed:!1,hidden:!1,cssClass:e.cssClass}}function Rbe(e,t,n){const r=vl(e),o=da().getButtonState(e);return{selected:t,clickable:da().isButtonInteractible(e),viewportClickable:m0(r),transitioning:n,greyed:o==="greyed",hidden:o==="hidden"||o===!1,cssClass:r.cssClass}}function Dbe(e,t,n){return kV(Rbe(e,t,n))}function Lbe(e,t,n){return kV(Nbe(e,t,n))}const Bbe=["id"],Fbe=["innerHTML"],Vbe=b.defineComponent({__name:"screen-object",props:{screenObject:{},layerSelected:{type:Boolean},transitioning:{type:Boolean},activeInteractive:{}},setup(e){const t=e,n=Bi();function r(s){t.transitioning||t.screenObject.onClick&&n.clickObject(s)}const o=b.computed(()=>{if(!t.layerSelected)return!1;const s=t.activeInteractive;return s.type==="screenObject"&&s.id===t.screenObject.id}),i=b.computed(()=>Lbe(t.screenObject,o.value,t.transitioning)),a=b.computed(()=>{const s={};t.screenObject.opacity!==1&&(s.opacity=t.screenObject.opacity);let c=t.screenObject.x,l=t.screenObject.y,f=t.screenObject.width,u=t.screenObject.height;if(t.screenObject.anchor){const h=t.screenObject.anchor;c=t.screenObject.x-f*h.x,l=t.screenObject.y-u*h.y,s.transformOrigin=`${h.x*100}% ${h.y*100}%`}t.screenObject.scale&&(f=f*t.screenObject.scale,u=u*t.screenObject.scale);const d={...s,left:`${c}px`,top:`${l}px`,width:`${f}px`,height:`${u}px`};return c1e(t.screenObject)&&(d.backgroundImage=`url(${fd(t.screenObject.image)})`),d});return(s,c)=>{const l=b.resolveComponent("ScreenObject",!0);return b.openBlock(),b.createElementBlock("div",{tabindex:"-1",class:b.normalizeClass(["viewport-object",i.value]),id:`viewport-object-${t.screenObject.id}`,onClick:c[0]||(c[0]=f=>r(s.screenObject)),style:b.normalizeStyle(a.value)},[b.createElementVNode("span",{innerHTML:t.screenObject.text?b.unref($s)(t.screenObject.text):void 0},null,8,Fbe),(b.openBlock(!0),b.createElementBlock(b.Fragment,null,b.renderList(t.screenObject.children,f=>(b.openBlock(),b.createBlock(l,{transitioning:s.transitioning,key:f.id,screenObject:f},null,8,["transitioning","screenObject"]))),128))],14,Bbe)}}}),zbe=["id","innerHTML"],qbe=b.defineComponent({__name:"viewport-button",props:{id:{},layerSelected:{type:Boolean},transitioning:{type:Boolean},activeInteractive:{}},setup(e){const t=e,n=da();b.computed(()=>n.getButtonState(t.id));const r=b.computed(()=>vl(t.id)),o=r.value.background?fd(r.value.background):null,i=b.computed(()=>{if(!t.layerSelected)return!1;const f=t.activeInteractive;return f.type==="button"&&f.id===t.id});b.computed(()=>n.isButtonClickable(t.id));const a=b.computed(()=>{const f=r.value.text??"";return $s(f)}),s=b.computed(()=>Dbe(t.id,i.value,t.transitioning)),c=b.computed(()=>{const f={};r.value.position.width&&(f.width=`${r.value.position.width}px`),r.value.position.height&&(f.height=`${r.value.position.height}px`),r.value.background&&(f.backgroundImage=`url(${o})`);let u=r.value.position.left,d=r.value.position.top;return r.value.anchor&&(u=r.value.position.left-r.value.position.width*r.value.anchor.x,d=r.value.position.top-r.value.position.height*r.value.anchor.y),{...f,left:`${u}px`,top:`${d}px`}});function l(){n.clickOnButton(t.id)}return(f,u)=>(b.openBlock(),b.createElementBlock("div",{tabindex:"-1",class:b.normalizeClass(["viewport-button",s.value]),id:`viewport-button-${f.id}`,onClick:u[0]||(u[0]=d=>l()),style:b.normalizeStyle(c.value),innerHTML:a.value},null,14,zbe))}}),Ube=["id"],Hbe=["id","loop","muted"],Wbe=["src"],Kbe=["id"],Jx=b.defineComponent({__name:"screen-layer",props:{layer:{},layerIndex:{},transitioning:{type:Boolean},activeInteractive:{}},setup(e){const t=e,n=sn(),r=Bi(),o=b.computed(()=>!!(t.activeInteractive&&t.activeInteractive.layer===t.layerIndex)),i=b.computed(()=>r.tree.filter(v=>v.layer===t.layerIndex)),a=b.computed(()=>Ct().layout.backgrounds.width),s=b.computed(()=>Ct().layout.backgrounds.height),c=b.computed(()=>t.layer),l=b.computed(()=>{const v=ud(c.value);return v||St(`Screen ${c.value} doesn't have a config`),v}),f=b.computed(()=>n.isInGame),u=b.computed(()=>l.value.buttons||[]),d=b.computed(()=>l.value.video),h=b.computed(()=>({width:`${a.value}px`,height:`${s.value}px`})),p=b.computed(()=>{let v;return l.value.background!==bx&&(v=`url(${fd(l.value.background)})`),{backgroundImage:v,position:"absolute",left:0,top:0,width:`${a.value}px`,height:`${s.value}px`}}),m=b.computed(()=>({position:"absolute",left:0,top:0,width:`${a.value}px`,height:`${s.value}px`}));return(v,g)=>f.value?(b.openBlock(),b.createElementBlock("div",{key:0,class:"viewport-layer",id:`viewport-layer-${c.value}`,style:b.normalizeStyle(h.value)},[d.value?(b.openBlock(),b.createElementBlock("video",{key:0,class:"viewport-layer-background",id:`viewport-layer-background-${c.value}`,style:b.normalizeStyle(m.value),autoplay:"",loop:d.value.loop!==!1,muted:!!d.value.muted},[b.createElementVNode("source",{src:b.unref(ci)(l.value.background)},null,8,Wbe)],12,Hbe)):(b.openBlock(),b.createElementBlock("div",{key:1,class:"viewport-layer-background",id:`viewport-layer-background-${c.value}`,style:b.normalizeStyle(p.value)},null,12,Kbe)),(b.openBlock(!0),b.createElementBlock(b.Fragment,null,b.renderList(u.value,y=>(b.openBlock(),b.createBlock(qbe,{key:y,id:y,layerSelected:o.value,transitioning:v.transitioning,activeInteractive:v.activeInteractive},null,8,["id","layerSelected","transitioning","activeInteractive"]))),128)),(b.openBlock(!0),b.createElementBlock(b.Fragment,null,b.renderList(i.value,y=>(b.openBlock(),b.createBlock(Vbe,{key:y.id,screenObject:y,transitioning:v.transitioning,layerSelected:o.value,activeInteractive:v.activeInteractive},null,8,["screenObject","transitioning","layerSelected","activeInteractive"]))),128))],12,Ube)):b.createCommentVNode("",!0)}}),Gbe=b.defineComponent({__name:"NarratTransition",props:{name:{type:String,required:!0},duration:{type:Number,required:!0},delay:Number},emits:["complete"],setup(e,{emit:t}){b.useSlots();const n=t,r=e,o=b.ref("start"),i=b.reactive({oldSlotClasses:{},oldSlotStyle:{},newSlotClasses:{},newSlotStyle:{}});return b.onMounted(async()=>{const a=`narrat-transition-${r.name}`;i.newSlotClasses={[`${a}-enter-from`]:!0},i.oldSlotClasses={[`${a}-leave-active`]:!0},await ki(30),i.oldSlotStyle={transitionDuration:`${r.duration/1e3}s`},i.newSlotStyle={transitionDuration:`${r.duration/1e3}s`},i.oldSlotClasses[`${a}-leave-to`]=!0,i.newSlotClasses[`${a}-enter-active`]=!0,await ki(r.delay??0),delete i.newSlotClasses[`${a}-enter-from`],await ki(r.duration),o.value="end",n("complete")}),(a,s)=>(b.openBlock(),b.createElementBlock(b.Fragment,null,[o.value!=="end"?(b.openBlock(),b.createElementBlock("div",{key:0,class:b.normalizeClass(["transition-holder",i.oldSlotClasses]),style:b.normalizeStyle(i.oldSlotStyle)},[b.renderSlot(a.$slots,"oldElement")],6)):b.createCommentVNode("",!0),b.createElementVNode("div",{class:b.normalizeClass(["transition-holder",i.newSlotClasses]),style:b.normalizeStyle(i.newSlotStyle)},[b.renderSlot(a.$slots,"newElement")],6)],64))}});function xV(e,t,n){return e<t?t:e>n?n:e}const Qx=b.defineComponent({__name:"screens",setup(e){const t=b.computed(()=>xr().inGameInputListener),n=sn(),r=da(),o=Bi(),i=b.ref(0),a=b.computed(()=>r.nonEmptyLayers),s=b.computed(()=>{const p=[];return a.value.reduce((m,v,g)=>{const w=ud(v.screen).buttons;if(w)for(const $ of w)r.isButtonClickable($)&&m.push({id:$,type:"button",layer:g});const k=o.tree.filter($=>$.layer===g);for(const $ of k)o.isScreenObjectClickable($)&&m.push({id:$.id,type:"screenObject",layer:g});return m},p)}),c=b.computed(()=>{if(s.value.length===0)return null;let p=i.value;return p>s.value.length-1&&(p=s.value.length-1),s.value[p]}),l=b.computed(()=>Ct().layout.backgrounds.width),f=b.computed(()=>Ct().layout.backgrounds.height),u=b.computed(()=>n.isInGame);function d(p){r.finishTransition(p)}const h=b.computed(()=>{const p=l.value;return{height:`${f.value}px`,width:`${p}px`}});return b.onMounted(()=>{b.nextTick(()=>{if(t.value){const p=t.value.actions;p.previousTab={press:()=>{i.value>0?i.value--:i.value=s.value.length-1,i.value=xV(i.value,0,s.value.length-1)}},p.left=p.previousTab,p.nextTab={press:()=>{i.value<s.value.length-1?i.value++:i.value=0,i.value=xV(i.value,0,s.value.length-1)}},p.right=p.nextTab,p.viewportSelect={press:()=>{if(c.value){const m=c.value;m.type==="button"?r.clickOnButton(m.id):m.type==="screenObject"&&o.clickObject(o.getObject(m.id))}}}}})}),b.onUnmounted(()=>{if(t.value){const p=t.value;delete p.actions.previousTab,delete p.actions.left,delete p.actions.nextTab,delete p.actions.right}}),(p,m)=>u.value?(b.openBlock(),b.createElementBlock("div",{key:0,class:"viewport",id:"narrat-viewport",style:b.normalizeStyle(h.value)},[(b.openBlock(!0),b.createElementBlock(b.Fragment,null,b.renderList(a.value,(v,g)=>(b.openBlock(),b.createElementBlock("div",{key:v.screen??"",class:"layer-container"},[v.transition?(b.openBlock(),b.createBlock(Gbe,{key:0,name:v.transition.transition,duration:v.transition.duration,delay:v.transition.delay,onComplete:()=>d(g)},{oldElement:b.withCtx(()=>[v.transition.oldScreen?(b.openBlock(),b.createBlock(Jx,{key:0,layer:v.transition.oldScreen,layerIndex:g,transitioning:!0},null,8,["layer","layerIndex"])):b.createCommentVNode("",!0)]),newElement:b.withCtx(()=>[v.screen?(b.openBlock(),b.createBlock(Jx,{key:0,layer:v.screen,layerIndex:g,transitioning:!0},null,8,["layer","layerIndex"])):b.createCommentVNode("",!0)]),_:2},1032,["name","duration","delay","onComplete"])):v.screen?(b.openBlock(),b.createBlock(Jx,{key:1,layer:v.screen,layerIndex:g,transitioning:!1,activeInteractive:c.value},null,8,["layer","layerIndex","activeInteractive"])):b.createCommentVNode("",!0)]))),128))],4)):b.createCommentVNode("",!0)}}),Si=eo("hud",{state:()=>({hudStats:{},visible:!0}),actions:{updateConfig(e){for(const t in e.hudStats)this.hudStats[t]||(this.hudStats[t]={value:e.hudStats[t].startingValue})},reset(e){this.$reset(),this.updateConfig(e)},setStat(e,t){this.hudStats[e].value=t,this.getStat(e).value<(wu(e).minValue??0)&&(this.hudStats[e].value=wu(e).minValue??0),this.getStat(e).value>(wu(e).maxValue??1/0)&&(this.hudStats[e].value=wu(e).maxValue??1/0)},addStat(e,t){this.setStat(e,this.getStatValue(e)+t)},getStat(e){return this.hudStats[e]},getStatValue(e){return this.hudStats[e].value},generateSaveData(){return{hudStats:Xn(this.hudStats),visible:this.visible}},loadSaveData(e){this.hudStats=fu(this.hudStats,e.hudStats),this.visible=e.visible},setVisibility(e){this.visible=e}}}),Jbe=b.defineComponent({data(){return{}},methods:{getStatImage(e){return ci(this.statsConfig[e].icon)},formatStat(e,t){var s;const n=wu(e),r=n.decimals??2,o=Math.floor(t*10**r)/10**r,i={};(s=n.formatting)!=null&&s.style&&(i.style=n.formatting.style,n.formatting.style==="currency"&&(i.currency=n.formatting.currency??"USD",i.currencyDisplay="narrowSymbol"),n.formatting.style==="unit"&&(i.unit=n.formatting.unit??"day"));let a;try{a=o.toLocaleString(void 0,i)}catch(c){St(`Error formatting HUD stat, probably using an invalid config: ${c}`),console.error(c),a=o.toLocaleString()}return a},statPrefix(e){const t=wu(e);return t.prefix??(t.suffix||t.hideName?"":t.name)},statSuffix(e){return wu(e).suffix??""}},computed:{...rp(Si,["hudStats"]),...rp(Gr,["layoutMode"]),statsConfig(){return Ct().hudStats},stats(){return this.hudStats},hudStyle(){let e="0";return this.layoutMode==="horizontal"&&(e=`${G0()+(Ct().dialogPanel.rightOffset??Kf.common.dialogPanel.rightOffset)}px`),{right:e}},hasHud(){return Si().visible===!1?!1:Object.keys(Si().hudStats).length>0}}}),Qbe=["src"],Ybe=["innerHTML"],Xbe=["innerHTML"];function Zbe(e,t,n,r,o,i){return e.hasHud?(b.openBlock(),b.createElementBlock("div",{key:0,class:"hud",style:b.normalizeStyle(e.hudStyle)},[(b.openBlock(!0),b.createElementBlock(b.Fragment,null,b.renderList(e.stats,(a,s)=>(b.openBlock(),b.createElementBlock("div",{key:s,class:"hud-stat"},[b.createElementVNode("img",{class:"hud-icon",src:e.getStatImage(s)},null,8,Qbe),b.createElementVNode("span",{class:"bold hud-text",innerHTML:e.statPrefix(s)},null,8,Ybe),b.createElementVNode("span",null,b.toDisplayString(e.formatStat(s,a.value)),1),e.statSuffix?(b.openBlock(),b.createElementBlock("span",{key:0,innerHTML:e.statSuffix(s)},null,8,Xbe)):b.createCommentVNode("",!0)]))),128))],4)):b.createCommentVNode("",!0)}const Yx=Xa(Jbe,[["render",Zbe]]),Xx=b.defineComponent({__name:"in-game",setup(e){const t=xr(),n=b.computed(()=>t.inGameInputListener),r=sn(),o=Gr(),i=b.computed(()=>o.layoutMode),a=b.computed(()=>r.saving),s=b.ref(null),c=cr(),l=b.ref(null),f=b.computed(()=>a.value&&!a.value.withPrompt||a.value&&s.value),u=b.computed(()=>{let m="row";return i.value==="vertical"&&(m="column"),{flexDirection:m}});function d(m){if(s.value=null,m===null){e_(m,!1);return}e_(m,!0)}function h(){s.value=!0}function p(){s.value=!1,e_(null,!1),s.value=null}return b.onBeforeMount(()=>{t.createInGameInputListener()}),b.onMounted(()=>{l.value=ha.on("debouncedKeydown",m=>{sn().debugMode||((m.key==="a"||m.key==="A")&&c.toggleAutoPlay(),(m.key==="s"||m.key==="S")&&c.toggleSkip())})}),b.onUnmounted(()=>{n.value&&t.removeInGameInputListener(),l.value&&ha.off("debouncedKeydown",l.value)}),b.computed(()=>Si().visible===!1?!1:Object.keys(Si().hudStats).length>0),(m,v)=>(b.openBlock(),b.createElementBlock("div",{class:"game",style:b.normalizeStyle(u.value)},[b.createVNode(Yx),b.createVNode(Gx),b.createVNode(Qx),b.createVNode(Kx),f.value?(b.openBlock(),b.createBlock(pV,{key:0,mode:"pick",onChosen:d,onClose:v[0]||(v[0]=()=>d(null))})):b.createCommentVNode("",!0),a.value&&a.value.withPrompt&&s.value===null?(b.openBlock(),b.createBlock(v0,{key:1,prompt:"Would you like to save the game?",onConfirm:h,onRefuse:p})):b.createCommentVNode("",!0)],4))}}),ewe={class:"chapter-title-scene"},twe=["innerHTML"],nwe=["innerHTML"],rwe=b.defineComponent({__name:"chapter-title",props:{options:{}},setup(e){const t=e,n=b.ref(null);function r(){n.value=null,_i().changeScene("playing"),un().jumpToLabel(t.options.next_label)}return b.onMounted(()=>{n.value=setTimeout(r,t.options.duration??2e3)}),b.onUnmounted(()=>{n.value&&(clearTimeout(n.value),n.value=null)}),(o,i)=>(b.openBlock(),b.createElementBlock("div",ewe,[b.createElementVNode("h1",{class:"title chapter-title",innerHTML:t.options.title},null,8,twe),t.options.subtitle?(b.openBlock(),b.createElementBlock("h2",{key:0,class:"subtitle chapter-subtitle",innerHTML:t.options.subtitle},null,8,nwe)):b.createCommentVNode("",!0)]))}}),_V={"engine-splash":{id:"engine-splash",component:b.shallowRef(Lx),props:{}},"game-splash":{id:"game-splash",component:b.shallowRef(Vx),props:{}},"start-menu":{id:"start-menu",component:b.shallowRef(Hx),props:{}},playing:{id:"playing",component:b.shallowRef(Xx),props:{}},"chapter-title":{id:"chapter-title",component:b.shallowRef(rwe),props:{}}};let As={};function owe(e){As=e}function iwe(){_V["engine-splash"].onFinished=()=>{_i().onEngineSplashFinished()},_i().scenes=_V}function awe(){return As}function SV(){for(const e in As){const t=As[e],n=t.store();let r;u1e(t)&&(r=pr()[t.config]),n.reset&&n.reset(r)}yn.plugins.forEach(e=>{e.reset&&e.reset()})}function swe(){const e={},t={};for(const n in As){const r=As[n];if(dV(r)){const o=r.store();o.generateSaveData?e[r.save]=o.generateSaveData():St(`Store ${n} has no generateSaveData method. Trying to generate save data for ${r.save}`)}if(hV(r)){const o=r.store();o.generateGlobalSaveData?t[r.globalSave]=o.generateGlobalSaveData():St(`Store ${n} has no generateGlobalSaveData method. Trying to generate save data for ${r.globalSave}`)}}return yn.plugins.forEach(n=>{n.save&&(e.plugins[n.pluginId]=n.save())}),yn.customStores().forEach(([n,r])=>{if(r.save){const o=r.save();o&&(o.customStores[n]=o)}}),{gameSave:e,globalSave:t}}function cwe(e){for(const t in As){const n=As[t];if(dV(n)){const r=n.store();r.loadSaveData?r.loadSaveData(e[n.save]):St(`Store ${t} has no loadSaveData method. Trying to load save data for ${n.save}`)}}yn.plugins.forEach(t=>{t.load&&e.plugins[t.pluginId]&&t.load(e.plugins[t.pluginId])}),yn.customStores().forEach(([t,n])=>{n.load&&n.load(e.customStores[t])})}function jV(e){for(const t in As){const n=As[t];if(hV(n)){const r=n.store();r.loadGlobalSaveData?r.loadGlobalSaveData(e[n.globalSave]):St(`Store ${t} has no loadGlobalSaveData method. Trying to load global save data for ${n.globalSave}`)}}}function lwe(e){cwe(e.gameSave),jV(e.globalSave)}function Zx({slotId:e,name:t}){const n=sn(),r=e??n.saveSlot;n.saveData=Rme({slot:r,name:t,extractedSave:swe()})}function uwe(e){lwe(e)}function CV(){un().globalData={},lc().globalSave.data={},Zx({})}function $V({saveName:e,withPrompt:t}){return new Promise(n=>{un().hasJumped?sn().startManualSave(n,e,t):n()})}function e_(e,t){var r;const n=sn();if(!n.saving){St("No saving in progress!");return}if(!t||!e){n.cancelManualSave();return}n.saveData?(Dme(n.saveData,Su(n.playTime.start,n.playTime.previousPlaytime),e.slotId,(r=n.saving)==null?void 0:r.name),n.alert("Success","Game saved!")):St("There was no data to save!"),n.cancelManualSave()}const un=eo("vm",{state:()=>({stack:[],data:{},globalData:{},lastLabel:"main",script:{},labelStack:["main"],commandsWaitingForPlayerAnswer:[],hasJumped:!1}),actions:{generateSaveData(){return{lastLabel:this.lastLabel,data:lS(this.data,e=>fV(e)?{_entityType:e._entityType,id:e.id}:e)}},generateGlobalSaveData(){return{data:Xn(this.globalData)}},loadSaveData(e){this.lastLabel=e.lastLabel,this.data=e.data,this.findEntitiesInData(this.data)},loadGlobalSaveData(e){this.globalData=e.data},findEntitiesInData(e){cV(this.data,(t,n,r)=>{if(fV(t)){const o=Bi().getObject(t.id);o?r[n]=o:hu(`Trying to reload sprite ${n} (${JSON.stringify(t)} - ${t.id}) but it does not exist.`)}})},setReturnValue(e){this.currentFrame.returnValue=e},waitForPlayerAnswer(e){this.commandsWaitingForPlayerAnswer.push(e)},popAnswerQueue(){return this.commandsWaitingForPlayerAnswer.pop()},addScopedVariable(e,t){this.currentFrame&&(this.currentFrame.scope[e]=t)},async loadScripts(e){this.readGlobalData();const t=await this.loadConfigScriptFiles(e),n=sn().options.scripts;this.addAllScripts([...t,...n])},async loadConfigScriptFiles(e){const t=[];for(const r of e)t.push(h0(K0(r)));return(await Promise.all(t)).map((r,o)=>({fileName:e[o],code:r,id:e[o],type:"script"}))},addAllScripts(e){const t=Date.now();for(const r of e)yn.addNarratScript(r);const n=Date.now();qi.log(`scripts parsed in ${n-t} ms`)},start(){this.setStack({currentIndex:0,branchData:{branch:yn.script.main.branch},label:"main"}),this.setStack({currentIndex:0,branchData:{branch:yn.script.main.branch},label:"main"})},setLastLabel(e){this.lastLabel=e},reset(){this.$reset(),this.stack=[],this.data={},this.hasJumped=!0,this.setStack({currentIndex:0,branchData:{branch:yn.script.main.branch},label:"main"})},readGlobalData(){this.globalData=lc().globalSave.data},setScript(e){yn.script=e},overrideData(e){this.data=e},setStack(e){this.stack=[];const t=this.frameOptionsToFrame(e);this.lastLabel=e.label,this.stack.push(t)},frameOptionsToFrame(e){const t=e.branchData,n={...e,blocks:[],scope:{},returnValue:null};if(this.addBlock(n,{branchData:t,currentIndex:e.currentIndex}),e.scope&&(n.scope=e.scope),e.args&&e.branchData.args)for(const[r,o]of e.branchData.args.entries())e.args.length>r&&(n.scope[o]=e.args[r]);return n},addBlock(e,t){e.blocks.push(t)},async addAndRunBlock(e){const t=this.currentFrame;if(!t)throw new Error("No frame to add block to");return this.addBlock(t,e),await this.runBlock()},setData(e,t){const n=dd();Uz(n,e,t)},addInstruction(e,t){const n=dd();Hz(n,e,t)},addFrame(e){if(!e.label)if(this.currentFrame)e.label=this.currentFrame.label;else throw new Error("Tried to add a new frame but no label was passed and there is no current frame label");const t=this.frameOptionsToFrame(e);this.stack.push(t)},async addAndRunFrame(e){return await this.addFrame(e),await this.runFrame()},async runFrame(){if(!this.currentFrame)throw new Error("Tried to run a frame but there is no current frame");let t;for(;this.currentBlock;){const n=await this.runBlock();if(n===o0||n===i0)return this.cleanFrame(),n;if(n===yx)return this.cleanFrame()}return this.cleanFrame(),t},cleanFrame(){const e=this.currentFrame,{returnValue:t}=e;return this.stack.splice(this.stack.length-1,1),t},async runBlock(){const e=this.currentBlock;if(!e)throw new Error("Tried to run a block but there is no current block");let t;for(;this.currentLine;){if(t=await this.runLineOnly(),Uve(t))return this.cleanBlock(),t;e.currentIndex++}return this.cleanBlock(),t},cleanBlock(){if(!this.currentFrame){St("Tried to clean a block but there is no current frame");return}if(!this.currentFrame.blocks){St("Tried to clean a block but there is no current block");return}this.currentFrame.blocks.splice(this.currentFrame.blocks.length-1,1)},async runGame(){let e=await this.runFrame();for(;e===o0;){const t=this.jumpTarget;if(!t){St("Tried to jump but no target was set");return}this.hasJumped=!0,this.setStack(t),await Zx({}),e=await this.runFrame()}e!==i0&&this.stack.length===0&&this.reachedEndOfScript()},async nextLineOnly(){return this.stack.length===0||this.isBlockFinished()?!1:(this.currentBlock.currentIndex++,!0)},isBlockFinished(){return!this.currentBlock||this.currentBlock&&this.currentBlock.currentIndex>=this.currentBlock.branchData.branch.length},reachedEndOfScript(){if(Ct().gameFlow.labelToJumpOnScriptEnd&&this.lastLabel!==Ct().gameFlow.labelToJumpOnScriptEnd){this.jumpToLabel(Ct().gameFlow.labelToJumpOnScriptEnd);return}sn().endingScript(),sn().options.debug&&Ct().debugging.showScriptFinishedMessage},async runLineOnly(){const e=this.currentLine;if(!e){St("There is no line of script to run.");return}return sn().startingScript(),await MV(e)},async runLabelFunction(e,...t){const n=yn.script[e];if(!n){St(`Tried to run a label that doesn't exist: ${e}`);return}const r={currentIndex:0,branchData:n,label:e,args:t};return this.addAndRunFrame(r)},runCustomFrame(e){this.addAndRunFrame(e)},async jumpToLabel(e,...t){const n=yn.script[e];if(!n){St(`Label ${e} doesn't exist. Is the file with this label added in the list of script files to load in the config?`);return}e!==this.lastLabel&&(this.hasJumped=!0),this.setLastLabel(e),this.setStack({currentIndex:0,branchData:n,args:t,label:e}),this.runGame()},async runThenGoBackToPreviousDialog(e,...t){const n=cr(),r=n.dialog[n.dialog.length-1],o=sn().inScript,i=await this.runLabelFunction(e,...t);return o?n.dialog.push(r):sn().endingScript(),i}},getters:{currentFrame(e){return e.stack[e.stack.length-1]},scope(){var e;return((e=this.currentFrame)==null?void 0:e.scope)??{}},currentBlock(){const e=this.currentFrame;return e?e.blocks[e.blocks.length-1]:void 0},currentLine(){const e=this.currentBlock;if(e&&e.branchData.branch.length>e.currentIndex)return e.branchData.branch[e.currentIndex]},commandWaitingForAnswer(){if(this.commandsWaitingForPlayerAnswer.length>0)return this.commandsWaitingForPlayerAnswer[0]}}}),TV=new Ap;TV.setupDebugger(!1);const pa=TV.logger;function fwe(e){return dwe((t,n,r)=>$we(t,n,r),e.code,e.fileName)}function dwe(e,t,n){const r={fileName:n,currentLine:0,error:(a,s)=>e(r,a,s),processCommandsFunction:t_,indentSize:0};r.indentSize=kwe(r,t);const o=ywe(r,t);r.currentLine=0,pa.log(o);const i={};for(const a of o){a.code.search(":")===-1&&r.error(a.line,"First indentation level should only be used to specify labels");const c=a.code.replace(":","").split(/ +/g),l=c[0],f=c.slice(1);a.branch||r.error(a.line,"This line should have a branch but doesn't"),i[l]={branch:t_(r,a.branch,void 0),args:f}}return i}function t_(e,t,n){const r=e.currentLine;if(!t){let a=0;return n&&(a=n.line),e.error(a,"Processing of command failed because the current branch has no lines inside"),[]}const o={processCommandsFunction:t_,parserContext:e,lines:t,currentLine:0,line:t[0]},i=[];for(;o.currentLine<t.length;){const a=t[o.currentLine];o.line=a;const s=n_(e,a,a.expression),c=yn.commands[s.command.operator];let l=c==null?void 0:c.parser;l||(l=yn.commands.text.parser),pa.log(yn.commands.text);const{newLine:f}=l(o,s);o.currentLine=f,e.currentLine=r+f,i.push(s)}return i}function n_(e,t,n){pa.log(n),typeof n[0]!="string"&&e.error(t.line,"Expression operator should be a string");const r={code:t.code,fileName:e.fileName,line:t.line,command:{staticOptions:{},commandType:n[0],operator:n[0],args:n.slice(1).map(a=>hwe(e,t,a)),options:{}}},o=n[0];if(!yn.commands[o]){const a=["else","success","failure"];!pve(o)&&!a.includes(o)&&e.error(t.line,`Unknown command ${o}`)}return r}function hwe(e,t,n){return Array.isArray(n)?n_(e,t,n):n}function pwe(e){return e==="true"?!0:e==="false"?!1:e==="undefined"?void 0:e===null?null:isNaN(Number(e))?e:Number(e)}function mwe(e,t){t.charAt(t.length-1)===":"&&(t=t.substr(0,t.length-1));const n=vwe(t),[r]=EV(e,n);return r}function vwe(e){const t=/(["'])(?:\\\1|.)*?\1/g,n=[];let r;for(;(r=t.exec(e))!=null;)n.push(r);let o=0,i=[];for(const a of n){const s=a.index;if(s>o){const l=e.substr(o,s-o),f=OV(l);i=[...i,...f]}const c=a[0].replace(/\\/g,"");i.push(`$$"${c.substring(1,c.length-1)}`),o=s+a[0].length}return i=[...i,...OV(e.substr(o))],i.push(")"),i}function OV(e){e=e.replace(/: *$/g,"");let t=e.split(" ").filter(n=>n);return t=t.reduce((n,r)=>[...n,...r.split(/(\(|\))/g)].filter(o=>o&&o),[]),t.map(n=>pwe(n))}function EV(e,t){pa.log("===============");let n=[],r=0,o=AV(t)+r,i=r_(t)+r;for(pa.log(`Parsing expression: ${t}`),pa.log(`Parenthesis start index: ${o} - end: ${i}`);o!==-1&&i>o;){n=[...n,...t.slice(r,o)];const c=t.slice(o+1);pa.log(`Found a sub expression. Before: ${n} - After: ${c}`),r=o;const[l,f]=EV(e,c),u=r+f;n.push(l),r=u+1;const d=t.slice(r);pa.log(`Sub expression came back: ${l} - rest of string: ${d}`),o=AV(d),o!==-1&&(o+=r),i=r_(d),i!==-1&&(i+=r)}i!==-1&&pa.log("Found parenthesis end before new opening parenthesis, close this expression");const a=r_(t.slice(r))+r;if(a===-1)return e.error(e.currentLine,'Expression is not closed (missing ")" closing parenthesis)'),[n,a];const s=t.slice(r,a);return pa.log(`End of expression: ${a} - ${s}`),pa.log("==================="),n=[...n,...s],gwe(e,n),[n,a+1]}function gwe(e,t){t.length<1&&e.error(e.currentLine,"Expression is empty")}function AV(e){return e.findIndex(t=>t==="(")}function r_(e){return e.findIndex(t=>t===")")}function ywe(e,t){const n=t.split(/\r?\n|$/).map(o=>{const i=o.search(/ *\/\//g);return i!==-1?o.substr(0,i):o});return PV(e,n,0,0).lines}function PV(e,t,n,r){let o=!0,i=n;const a=[];for(;o&&!(i>=t.length);){let s=t[i];if(s.search(/^\s*$/)!==-1)i++;else{const c=wwe(e,s);if(s=s.substring(c*e.indentSize),bwe(e,c,i),c<r)o=!1;else if(c>r){(a.length===0||c-r!==1)&&e.error(i,"Wrong double indentation");const l=PV(e,t,i,c);a[a.length-1].branch=l.lines,i=l.endLine}else{const l=mwe(e,s),f={code:s,indentation:c,line:i,expression:l};a.push(f),i++,e.currentLine=i}}}return{lines:a,endLine:i}}function bwe(e,t,n){t%1!==0&&e.error(n,`Indentation level of ${t} incorrect. Expected indentation of ${e.indentSize} spaces for this file.`)}function wwe(e,t){return t.search(/[^ ]/)/e.indentSize}function kwe(e,t){const n=/\n( *)/,r=t.match(n);return!r||r.length<2?(e.error(0,"Can't detect indentation level. Make sure you indent with at least 2 spaces and consistently"),0):(pa.log(r),r[1].length)}class xwe{constructor(){Wn(this,"plugins",[]);Wn(this,"pinia");Wn(this,"script",{});Wn(this,"scripts",[]);Wn(this,"commands",{})}addCommand(t){this.commands[t.keyword]=t}addPlugin(t){if(this.plugins.push(t),t.customCommands)for(const n of t.customCommands)this.addCommand(n)}callHook(t,...n){for(const r of this.plugins)typeof r[t]=="function"&&r[t](...n)}addNarratScript(t){const n=fwe(t);this.script={...this.script,...n},this.scripts.push(t)}customStores(){const t=[];for(const n of this.plugins)if(n.customStores)for(const r in n.customStores)t.push([r,n.customStores[r](this.pinia)]);return t}addCustomSettings(){for(const t of this.plugins)if(t.customSettings)for(const n in t.customSettings)Es().addCustomSetting(n,t.customSettings[n])}}const yn=new xwe;async function MV(e,t){var r;const n=un();try{return await y0(e,t)}catch(o){console.error(o),console.error(e),St(`Narrat script runtime error at <span class="error-filename">${e.fileName}:${e.line+1}</span>
206
206
  <b>${o}</b>
207
207
  Script: ${e.code}
208
208
  Label: ${((r=n.currentFrame)==null?void 0:r.label)||"none"}`)}}async function _we(e,t){const n=e.command,r=yn.commands[n.commandType];if(r){const o={args:[],options:{},operator:n.operator,staticOptions:n.staticOptions,code:e.code,commandType:n.commandType,fileName:e.fileName,line:e.line},i=r.argTypes;o.options={};for(const[a,s]of n.args.entries()){let c;if(rF(s))c=await y0(s,t);else if(typeof s=="string")if(s.search(K9)===0)c=$s(s.substring(3));else if(oF(s)){const l=dd(),f=n_e(l,s);if(f){const[u,d]=f;c=u[d]}else c=s}else c=s;else c=s;if(o.args.push(c),Array.isArray(i)&&i.length>a){const l=i[a];c!==null&&(o.options[l.name]=c)}}return o}else throw new Error(`${n.commandType} is not a valid command`)}async function y0(e,t){const n=await _we(e,t),r=yn.commands[n.commandType];if(r)return await r.run(n,t);throw new Error(`${n.commandType} is not a valid command`)}async function Swe(e){uu("onPlayerAnswered");const t=un(),n=t.popAnswerQueue(),r=t.currentLine;try{if(n){const o=yn.commands[n.commandType];if(o)return await o.processPlayerAnswer(n,e)}}catch(o){console.error(o),St(`Error after player answer at ${r.fileName}:${r.line+1} (${r.code}<br /> - Error: ${o}`)}}function jwe(){return{baseAssetsPath:"",baseDataPath:"",configPath:"data/config.json",logging:!1,debug:!1,scripts:[],container:"#game-holder"}}class Cwe extends Bx{}const sn=eo("main",{state:()=>({ready:!1,playing:!1,errors:[],playTime:{start:0,previousPlaytime:0},saveSlot:"",paused:!1,debugMode:!0,options:{baseAssetsPath:"",baseDataPath:"",configPath:"data/config.json",logging:!1,debug:!1,scripts:[]},loading:{step:"Loading",percentage:.1,loaded:!1},alerts:[],saving:null,listener:new Cwe,inScript:!1}),actions:{setLoadingStep(e,t){this.loading.step=e,this.loading.percentage=t},gameLoaded(){this.loading.loaded=!0,this.listener.emit("gameLoaded")},async alert(e,t){return new Promise(n=>{this.alerts.push({title:e,text:t,resolver:n,id:su()})})},closeAlert(e){const t=this.alerts.findIndex(n=>n.id===e);t!==-1&&(this.alerts[t].resolver(),this.alerts.splice(t,1))},startingScript(){Io().onScriptStart(),this.inScript=!0},endingScript(){Io().onScriptEnd(),this.inScript=!1},prepareToPlay(){this.ready=!0,this.startPlaying(),_i().changeScene("playing")},setSaveSlot(e){this.saveSlot=e,Eme(e)},startManualSave(e,t,n){this.saving={name:t,withPrompt:n,resolver:e}},cancelManualSave(){this.saving&&(this.saving.resolver(),this.saving=null)},playerAnswered(e){Swe(e)},menuReturn(){_i().changeScene("menu")},createError(e){this.errors.push({text:e,type:"error"})},createWarning(e){this.errors.push({text:e,type:"warning"})},clearErrors(){this.errors=[]},pause(){this.paused=!0},unpause(){this.paused=!1},setOptions(e){this.options=e},startPlaying(){this.playing=!0,this.playTime.start=Date.now()},reset(){this.ready=!1,this.paused=!1,this.playing=!1,this.ready=!0},generateSaveData(){return{playTime:Su(this.playTime.start,this.playTime.previousPlaytime)}},loadSaveData(e){this.playTime.previousPlaytime=e.playTime},exitGame(){window.close()}},getters:{isInGame(e){return _i().isPlaying},totalPlayTime(e){return Su(e.playTime.start,e.playTime.previousPlaytime)},sessionPlayTime(e){return Su(e.playTime.start,0)},hasCustomContainer(e){return(e.options.container??"")!=="#game-holder"}}});function $we(e,t,n){console.error(`Parser error: ${e.fileName}:${e.currentLine}`,n);const r=`[Parser Error] in <span class="error-filename">${e.fileName}:${t+1}</span> - <b>${n}</b>`;St(r)}function St(e,...t){const n=sn();console.error(e,...t),e=e.replace(/[\r\n]/g,`
@@ -216,7 +216,7 @@ This will fail in production.`);s=ep,s._s.has(r)||(i?hx(r,t,o,s):H9(r,o,s),proce
216
216
  depsCount: ${l},
217
217
  deps: ${f}}`};const o={keyword:"dependencies",type:"object",schemaType:"object",error:e.error,code(c){const[l,f]=i(c);a(c,l),s(c,f)}};function i({schema:c}){const l={},f={};for(const u in c){if(u==="__proto__")continue;const d=Array.isArray(c[u])?l:f;d[u]=c[u]}return[l,f]}function a(c,l=c.schema){const{gen:f,data:u,it:d}=c;if(Object.keys(l).length===0)return;const h=f.let("missing");for(const p in l){const m=l[p];if(m.length===0)continue;const v=(0,r.propertyInData)(f,u,p,d.opts.ownProperties);c.setParams({property:p,depsCount:m.length,deps:m.join(", ")}),d.allErrors?f.if(v,()=>{for(const g of m)(0,r.checkReportMissingProp)(c,g)}):(f.if((0,t._)`${v} && (${(0,r.checkMissingProp)(c,m,h)})`),(0,r.reportMissingProp)(c,h),f.else())}}e.validatePropertyDeps=a;function s(c,l=c.schema){const{gen:f,data:u,keyword:d,it:h}=c,p=f.name("valid");for(const m in l)(0,n.alwaysValidSchema)(h,l[m])||(f.if((0,r.propertyInData)(f,u,m,h.opts.ownProperties),()=>{const v=c.subschema({keyword:d,schemaProp:m},p);c.mergeValidEvaluated(v,p)},()=>f.var(p,!0)),c.ok(p))}e.validateSchemaDeps=s,e.default=o})(xz);var q_={};Object.defineProperty(q_,"__esModule",{value:!0});const _z=Fn,Q2e=Yn,Y2e={keyword:"propertyNames",type:"object",schemaType:["object","boolean"],error:{message:"property name must be valid",params:({params:e})=>(0,_z._)`{propertyName: ${e.propertyName}}`},code(e){const{gen:t,schema:n,data:r,it:o}=e;if((0,Q2e.alwaysValidSchema)(o,n))return;const i=t.name("valid");t.forIn("key",r,a=>{e.setParams({propertyName:a}),e.subschema({keyword:"propertyNames",data:a,dataTypes:["string"],propertyName:a,compositeRule:!0},i),t.if((0,_z.not)(i),()=>{e.error(!0),o.allErrors||t.break()})}),e.ok(i)}};q_.default=Y2e;var M0={};Object.defineProperty(M0,"__esModule",{value:!0});const I0=Vn,Ga=Fn,X2e=Ps,N0=Yn,Z2e={keyword:"additionalProperties",type:["object"],schemaType:["boolean","object"],allowUndefined:!0,trackErrors:!0,error:{message:"must NOT have additional properties",params:({params:e})=>(0,Ga._)`{additionalProperty: ${e.additionalProperty}}`},code(e){const{gen:t,schema:n,parentSchema:r,data:o,errsCount:i,it:a}=e;if(!i)throw new Error("ajv implementation error");const{allErrors:s,opts:c}=a;if(a.props=!0,c.removeAdditional!=="all"&&(0,N0.alwaysValidSchema)(a,n))return;const l=(0,I0.allSchemaProperties)(r.properties),f=(0,I0.allSchemaProperties)(r.patternProperties);u(),e.ok((0,Ga._)`${i} === ${X2e.default.errors}`);function u(){t.forIn("key",o,v=>{!l.length&&!f.length?p(v):t.if(d(v),()=>p(v))})}function d(v){let g;if(l.length>8){const y=(0,N0.schemaRefOrVal)(a,r.properties,"properties");g=(0,I0.isOwnProperty)(t,y,v)}else l.length?g=(0,Ga.or)(...l.map(y=>(0,Ga._)`${v} === ${y}`)):g=Ga.nil;return f.length&&(g=(0,Ga.or)(g,...f.map(y=>(0,Ga._)`${(0,I0.usePattern)(e,y)}.test(${v})`))),(0,Ga.not)(g)}function h(v){t.code((0,Ga._)`delete ${o}[${v}]`)}function p(v){if(c.removeAdditional==="all"||c.removeAdditional&&n===!1){h(v);return}if(n===!1){e.setParams({additionalProperty:v}),e.error(),s||t.break();return}if(typeof n=="object"&&!(0,N0.alwaysValidSchema)(a,n)){const g=t.name("valid");c.removeAdditional==="failing"?(m(v,g,!1),t.if((0,Ga.not)(g),()=>{e.reset(),h(v)})):(m(v,g),s||t.if((0,Ga.not)(g),()=>t.break()))}}function m(v,g,y){const w={keyword:"additionalProperties",dataProp:v,dataPropType:N0.Type.Str};y===!1&&Object.assign(w,{compositeRule:!0,createErrors:!1,allErrors:!1}),e.subschema(w,g)}}};M0.default=Z2e;var U_={};Object.defineProperty(U_,"__esModule",{value:!0});const exe=Ha,Sz=Vn,H_=Yn,jz=M0,txe={keyword:"properties",type:"object",schemaType:"object",code(e){const{gen:t,schema:n,parentSchema:r,data:o,it:i}=e;i.opts.removeAdditional==="all"&&r.additionalProperties===void 0&&jz.default.code(new exe.KeywordCxt(i,jz.default,"additionalProperties"));const a=(0,Sz.allSchemaProperties)(n);for(const u of a)i.definedProperties.add(u);i.opts.unevaluated&&a.length&&i.props!==!0&&(i.props=H_.mergeEvaluated.props(t,(0,H_.toHash)(a),i.props));const s=a.filter(u=>!(0,H_.alwaysValidSchema)(i,n[u]));if(s.length===0)return;const c=t.name("valid");for(const u of s)l(u)?f(u):(t.if((0,Sz.propertyInData)(t,o,u,i.opts.ownProperties)),f(u),i.allErrors||t.else().var(c,!0),t.endIf()),e.it.definedProperties.add(u),e.ok(c);function l(u){return i.opts.useDefaults&&!i.compositeRule&&n[u].default!==void 0}function f(u){e.subschema({keyword:"properties",schemaProp:u,dataProp:u},c)}}};U_.default=txe;var W_={};Object.defineProperty(W_,"__esModule",{value:!0});const Cz=Vn,R0=Fn,$z=Yn,Tz=Yn,nxe={keyword:"patternProperties",type:"object",schemaType:"object",code(e){const{gen:t,schema:n,data:r,parentSchema:o,it:i}=e,{opts:a}=i,s=(0,Cz.allSchemaProperties)(n),c=s.filter(m=>(0,$z.alwaysValidSchema)(i,n[m]));if(s.length===0||c.length===s.length&&(!i.opts.unevaluated||i.props===!0))return;const l=a.strictSchema&&!a.allowMatchingProperties&&o.properties,f=t.name("valid");i.props!==!0&&!(i.props instanceof R0.Name)&&(i.props=(0,Tz.evaluatedPropsToName)(t,i.props));const{props:u}=i;d();function d(){for(const m of s)l&&h(m),i.allErrors?p(m):(t.var(f,!0),p(m),t.if(f))}function h(m){for(const v in l)new RegExp(m).test(v)&&(0,$z.checkStrictMode)(i,`property ${v} matches pattern ${m} (use allowMatchingProperties)`)}function p(m){t.forIn("key",r,v=>{t.if((0,R0._)`${(0,Cz.usePattern)(e,m)}.test(${v})`,()=>{const g=c.includes(m);g||e.subschema({keyword:"patternProperties",schemaProp:m,dataProp:v,dataPropType:Tz.Type.Str},f),i.opts.unevaluated&&u!==!0?t.assign((0,R0._)`${u}[${v}]`,!0):!g&&!i.allErrors&&t.if((0,R0.not)(f),()=>t.break())})})}}};W_.default=nxe;var K_={};Object.defineProperty(K_,"__esModule",{value:!0});const rxe=Yn,oxe={keyword:"not",schemaType:["object","boolean"],trackErrors:!0,code(e){const{gen:t,schema:n,it:r}=e;if((0,rxe.alwaysValidSchema)(r,n)){e.fail();return}const o=t.name("valid");e.subschema({keyword:"not",compositeRule:!0,createErrors:!1,allErrors:!1},o),e.failResult(o,()=>e.reset(),()=>e.error())},error:{message:"must NOT be valid"}};K_.default=oxe;var G_={};Object.defineProperty(G_,"__esModule",{value:!0});const ixe={keyword:"anyOf",schemaType:"array",trackErrors:!0,code:Vn.validateUnion,error:{message:"must match a schema in anyOf"}};G_.default=ixe;var J_={};Object.defineProperty(J_,"__esModule",{value:!0});const D0=Fn,axe=Yn,sxe={keyword:"oneOf",schemaType:"array",trackErrors:!0,error:{message:"must match exactly one schema in oneOf",params:({params:e})=>(0,D0._)`{passingSchemas: ${e.passing}}`},code(e){const{gen:t,schema:n,parentSchema:r,it:o}=e;if(!Array.isArray(n))throw new Error("ajv implementation error");if(o.opts.discriminator&&r.discriminator)return;const i=n,a=t.let("valid",!1),s=t.let("passing",null),c=t.name("_valid");e.setParams({passing:s}),t.block(l),e.result(a,()=>e.reset(),()=>e.error(!0));function l(){i.forEach((f,u)=>{let d;(0,axe.alwaysValidSchema)(o,f)?t.var(c,!0):d=e.subschema({keyword:"oneOf",schemaProp:u,compositeRule:!0},c),u>0&&t.if((0,D0._)`${c} && ${a}`).assign(a,!1).assign(s,(0,D0._)`[${s}, ${u}]`).else(),t.if(c,()=>{t.assign(a,!0),t.assign(s,u),d&&e.mergeEvaluated(d,D0.Name)})})}}};J_.default=sxe;var Q_={};Object.defineProperty(Q_,"__esModule",{value:!0});const cxe=Yn,lxe={keyword:"allOf",schemaType:"array",code(e){const{gen:t,schema:n,it:r}=e;if(!Array.isArray(n))throw new Error("ajv implementation error");const o=t.name("valid");n.forEach((i,a)=>{if((0,cxe.alwaysValidSchema)(r,i))return;const s=e.subschema({keyword:"allOf",schemaProp:a},o);e.ok(o),e.mergeEvaluated(s)})}};Q_.default=lxe;var Y_={};Object.defineProperty(Y_,"__esModule",{value:!0});const L0=Fn,Oz=Yn,uxe={keyword:"if",schemaType:["object","boolean"],trackErrors:!0,error:{message:({params:e})=>(0,L0.str)`must match "${e.ifClause}" schema`,params:({params:e})=>(0,L0._)`{failingKeyword: ${e.ifClause}}`},code(e){const{gen:t,parentSchema:n,it:r}=e;n.then===void 0&&n.else===void 0&&(0,Oz.checkStrictMode)(r,'"if" without "then" and "else" is ignored');const o=Ez(r,"then"),i=Ez(r,"else");if(!o&&!i)return;const a=t.let("valid",!0),s=t.name("_valid");if(c(),e.reset(),o&&i){const f=t.let("ifClause");e.setParams({ifClause:f}),t.if(s,l("then",f),l("else",f))}else o?t.if(s,l("then")):t.if((0,L0.not)(s),l("else"));e.pass(a,()=>e.error(!0));function c(){const f=e.subschema({keyword:"if",compositeRule:!0,createErrors:!1,allErrors:!1},s);e.mergeEvaluated(f)}function l(f,u){return()=>{const d=e.subschema({keyword:f},s);t.assign(a,s),e.mergeValidEvaluated(d,a),u?t.assign(u,(0,L0._)`${f}`):e.setParams({ifClause:f})}}}};function Ez(e,t){const n=e.schema[t];return n!==void 0&&!(0,Oz.alwaysValidSchema)(e,n)}Y_.default=uxe;var X_={};Object.defineProperty(X_,"__esModule",{value:!0});const fxe=Yn,dxe={keyword:["then","else"],schemaType:["object","boolean"],code({keyword:e,parentSchema:t,it:n}){t.if===void 0&&(0,fxe.checkStrictMode)(n,`"${e}" without "if" is ignored`)}};X_.default=dxe,Object.defineProperty(L_,"__esModule",{value:!0});const hxe=id,pxe=F_,mxe=ad,vxe=V_,gxe=z_,yxe=xz,bxe=q_,wxe=M0,kxe=U_,xxe=W_,_xe=K_,Sxe=G_,jxe=J_,Cxe=Q_,$xe=Y_,Txe=X_;function Oxe(e=!1){const t=[_xe.default,Sxe.default,jxe.default,Cxe.default,$xe.default,Txe.default,bxe.default,wxe.default,yxe.default,kxe.default,xxe.default];return e?t.push(pxe.default,vxe.default):t.push(hxe.default,mxe.default),t.push(gxe.default),t}L_.default=Oxe;var Z_={},eS={};Object.defineProperty(eS,"__esModule",{value:!0});const to=Fn,Exe={keyword:"format",type:["number","string"],schemaType:"string",$data:!0,error:{message:({schemaCode:e})=>(0,to.str)`must match format "${e}"`,params:({schemaCode:e})=>(0,to._)`{format: ${e}}`},code(e,t){const{gen:n,data:r,$data:o,schema:i,schemaCode:a,it:s}=e,{opts:c,errSchemaPath:l,schemaEnv:f,self:u}=s;if(!c.validateFormats)return;o?d():h();function d(){const p=n.scopeValue("formats",{ref:u.formats,code:c.code.formats}),m=n.const("fDef",(0,to._)`${p}[${a}]`),v=n.let("fType"),g=n.let("format");n.if((0,to._)`typeof ${m} == "object" && !(${m} instanceof RegExp)`,()=>n.assign(v,(0,to._)`${m}.type || "string"`).assign(g,(0,to._)`${m}.validate`),()=>n.assign(v,(0,to._)`"string"`).assign(g,m)),e.fail$data((0,to.or)(y(),w()));function y(){return c.strictSchema===!1?to.nil:(0,to._)`${a} && !${g}`}function w(){const k=f.$async?(0,to._)`(${m}.async ? await ${g}(${r}) : ${g}(${r}))`:(0,to._)`${g}(${r})`,$=(0,to._)`(typeof ${g} == "function" ? ${k} : ${g}.test(${r}))`;return(0,to._)`${g} && ${g} !== true && ${v} === ${t} && !${$}`}}function h(){const p=u.formats[i];if(!p){y();return}if(p===!0)return;const[m,v,g]=w(p);m===t&&e.pass(k());function y(){if(c.strictSchema===!1){u.logger.warn($());return}throw new Error($());function $(){return`unknown format "${i}" ignored in schema at path "${l}"`}}function w($){const S=$ instanceof RegExp?(0,to.regexpCode)($):c.code.formats?(0,to._)`${c.code.formats}${(0,to.getProperty)(i)}`:void 0,E=n.scopeValue("formats",{key:i,ref:$,code:S});return typeof $=="object"&&!($ instanceof RegExp)?[$.type||"string",$.validate,(0,to._)`${E}.validate`]:["string",$,E]}function k(){if(typeof p=="object"&&!(p instanceof RegExp)&&p.async){if(!f.$async)throw new Error("async format in sync schema");return(0,to._)`await ${g}(${r})`}return typeof v=="function"?(0,to._)`${g}(${r})`:(0,to._)`${g}.test(${r})`}}}};eS.default=Exe,Object.defineProperty(Z_,"__esModule",{value:!0});const Axe=[eS.default];Z_.default=Axe;var sd={};Object.defineProperty(sd,"__esModule",{value:!0}),sd.contentVocabulary=sd.metadataVocabulary=void 0,sd.metadataVocabulary=["title","description","default","deprecated","readOnly","writeOnly","examples"],sd.contentVocabulary=["contentMediaType","contentEncoding","contentSchema"],Object.defineProperty(k_,"__esModule",{value:!0});const Pxe=x_,Mxe=S_,Ixe=L_,Nxe=Z_,Az=sd,Rxe=[Pxe.default,Mxe.default,(0,Ixe.default)(),Nxe.default,Az.metadataVocabulary,Az.contentVocabulary];k_.default=Rxe;var tS={},Pz={};(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.DiscrError=void 0,function(t){t.Tag="tag",t.Mapping="mapping"}(e.DiscrError||(e.DiscrError={}))})(Pz),Object.defineProperty(tS,"__esModule",{value:!0});const cd=Fn,nS=Pz,Mz=ji,Dxe=Yn,Lxe={keyword:"discriminator",type:"object",schemaType:"object",error:{message:({params:{discrError:e,tagName:t}})=>e===nS.DiscrError.Tag?`tag "${t}" must be string`:`value of tag "${t}" must be in oneOf`,params:({params:{discrError:e,tag:t,tagName:n}})=>(0,cd._)`{error: ${e}, tag: ${n}, tagValue: ${t}}`},code(e){const{gen:t,data:n,schema:r,parentSchema:o,it:i}=e,{oneOf:a}=o;if(!i.opts.discriminator)throw new Error("discriminator: requires discriminator option");const s=r.propertyName;if(typeof s!="string")throw new Error("discriminator: requires propertyName");if(r.mapping)throw new Error("discriminator: mapping is not supported");if(!a)throw new Error("discriminator: requires oneOf keyword");const c=t.let("valid",!1),l=t.const("tag",(0,cd._)`${n}${(0,cd.getProperty)(s)}`);t.if((0,cd._)`typeof ${l} == "string"`,()=>f(),()=>e.error(!1,{discrError:nS.DiscrError.Tag,tag:l,tagName:s})),e.ok(c);function f(){const h=d();t.if(!1);for(const p in h)t.elseIf((0,cd._)`${l} === ${p}`),t.assign(c,u(h[p]));t.else(),e.error(!1,{discrError:nS.DiscrError.Mapping,tag:l,tagName:s}),t.endIf()}function u(h){const p=t.name("valid"),m=e.subschema({keyword:"oneOf",schemaProp:h},p);return e.mergeEvaluated(m,cd.Name),p}function d(){var h;const p={},m=g(o);let v=!0;for(let k=0;k<a.length;k++){let $=a[k];$!=null&&$.$ref&&!(0,Dxe.schemaHasRulesButRef)($,i.self.RULES)&&($=Mz.resolveRef.call(i.self,i.schemaEnv.root,i.baseId,$==null?void 0:$.$ref),$ instanceof Mz.SchemaEnv&&($=$.schema));const S=(h=$==null?void 0:$.properties)===null||h===void 0?void 0:h[s];if(typeof S!="object")throw new Error(`discriminator: oneOf subschemas (or referenced schemas) must have "properties/${s}"`);v=v&&(m||g($)),y(S,k)}if(!v)throw new Error(`discriminator: "${s}" must be required`);return p;function g({required:k}){return Array.isArray(k)&&k.includes(s)}function y(k,$){if(k.const)w(k.const,$);else if(k.enum)for(const S of k.enum)w(S,$);else throw new Error(`discriminator: "properties/${s}" must have "const" or "enum"`)}function w(k,$){if(typeof k!="string"||k in p)throw new Error(`discriminator: "${s}" values must be unique strings`);p[k]=$}}}};tS.default=Lxe;const Bxe={$schema:"http://json-schema.org/draft-07/schema#",$id:"http://json-schema.org/draft-07/schema#",title:"Core schema meta-schema",definitions:{schemaArray:{type:"array",minItems:1,items:{$ref:"#"}},nonNegativeInteger:{type:"integer",minimum:0},nonNegativeIntegerDefault0:{allOf:[{$ref:"#/definitions/nonNegativeInteger"},{default:0}]},simpleTypes:{enum:["array","boolean","integer","null","number","object","string"]},stringArray:{type:"array",items:{type:"string"},uniqueItems:!0,default:[]}},type:["object","boolean"],properties:{$id:{type:"string",format:"uri-reference"},$schema:{type:"string",format:"uri"},$ref:{type:"string",format:"uri-reference"},$comment:{type:"string"},title:{type:"string"},description:{type:"string"},default:!0,readOnly:{type:"boolean",default:!1},examples:{type:"array",items:!0},multipleOf:{type:"number",exclusiveMinimum:0},maximum:{type:"number"},exclusiveMaximum:{type:"number"},minimum:{type:"number"},exclusiveMinimum:{type:"number"},maxLength:{$ref:"#/definitions/nonNegativeInteger"},minLength:{$ref:"#/definitions/nonNegativeIntegerDefault0"},pattern:{type:"string",format:"regex"},additionalItems:{$ref:"#"},items:{anyOf:[{$ref:"#"},{$ref:"#/definitions/schemaArray"}],default:!0},maxItems:{$ref:"#/definitions/nonNegativeInteger"},minItems:{$ref:"#/definitions/nonNegativeIntegerDefault0"},uniqueItems:{type:"boolean",default:!1},contains:{$ref:"#"},maxProperties:{$ref:"#/definitions/nonNegativeInteger"},minProperties:{$ref:"#/definitions/nonNegativeIntegerDefault0"},required:{$ref:"#/definitions/stringArray"},additionalProperties:{$ref:"#"},definitions:{type:"object",additionalProperties:{$ref:"#"},default:{}},properties:{type:"object",additionalProperties:{$ref:"#"},default:{}},patternProperties:{type:"object",additionalProperties:{$ref:"#"},propertyNames:{format:"regex"},default:{}},dependencies:{type:"object",additionalProperties:{anyOf:[{$ref:"#"},{$ref:"#/definitions/stringArray"}]}},propertyNames:{$ref:"#"},const:!0,enum:{type:"array",items:!0,minItems:1,uniqueItems:!0},type:{anyOf:[{$ref:"#/definitions/simpleTypes"},{type:"array",items:{$ref:"#/definitions/simpleTypes"},minItems:1,uniqueItems:!0}]},format:{type:"string"},contentMediaType:{type:"string"},contentEncoding:{type:"string"},if:{$ref:"#"},then:{$ref:"#"},else:{$ref:"#"},allOf:{$ref:"#/definitions/schemaArray"},anyOf:{$ref:"#/definitions/schemaArray"},oneOf:{$ref:"#/definitions/schemaArray"},not:{$ref:"#"}},default:!0};(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.MissingRefError=t.ValidationError=t.CodeGen=t.Name=t.nil=t.stringify=t.str=t._=t.KeywordCxt=void 0;const n=IV,r=k_,o=tS,i=Bxe,a=["/properties"],s="http://json-schema.org/draft-07/schema";class c extends n.default{_addVocabularies(){super._addVocabularies(),r.default.forEach(p=>this.addVocabulary(p)),this.opts.discriminator&&this.addKeyword(o.default)}_addDefaultMetaSchema(){if(super._addDefaultMetaSchema(),!this.opts.meta)return;const p=this.opts.$data?this.$dataMetaSchema(i,a):i;this.addMetaSchema(p,s,!1),this.refs["http://json-schema.org/schema"]=s}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(s)?s:void 0)}}e.exports=t=c,Object.defineProperty(t,"__esModule",{value:!0}),t.default=c;var l=Ha;Object.defineProperty(t,"KeywordCxt",{enumerable:!0,get:function(){return l.KeywordCxt}});var f=Fn;Object.defineProperty(t,"_",{enumerable:!0,get:function(){return f._}}),Object.defineProperty(t,"str",{enumerable:!0,get:function(){return f.str}}),Object.defineProperty(t,"stringify",{enumerable:!0,get:function(){return f.stringify}}),Object.defineProperty(t,"nil",{enumerable:!0,get:function(){return f.nil}}),Object.defineProperty(t,"Name",{enumerable:!0,get:function(){return f.Name}}),Object.defineProperty(t,"CodeGen",{enumerable:!0,get:function(){return f.CodeGen}});var u=yp;Object.defineProperty(t,"ValidationError",{enumerable:!0,get:function(){return u.default}});var d=bp;Object.defineProperty(t,"MissingRefError",{enumerable:!0,get:function(){return d.default}})})(s_,s_.exports);var Fxe=s_.exports;const Vxe=ey(Fxe);function zxe(e,t){for(const n in t.screens){const r=t.screens[n];if(r.buttons)for(const[o,i]of r.buttons.entries())typeof i=="object"&&(e.buttons.buttons[i.id]=i,r.buttons[o]=i.id)}return t}function qxe(e,t){if(t.transitions)for(const n in t.transitions)p0[n]?Object.assign(p0[n],t.transitions[n]):p0[n]=t.transitions[n];return t}function Uxe(e,t,n){switch(e){case"screens":return zxe(t,n);case"common":return qxe(t,n);default:return n}}function Iz(e,t,n){const r=e[t],o=(i,a,s)=>a;if(n){let i=fu(r,n,{arrayMerge:o});return i=Uxe(t,e,i),i}}function rS(e){return!(!e||!e.default)}function oS(e){if(sn().clearErrors(),!rS(e))return;console.log("Received HMR update for ",e.default.id);const t=e.default;if(iS(t))Jo().addNotification(`Reloaded ${t.fileName}`,"You can continue playing with the changes."),yn.addNarratScript(t);else if(B0(t)){const n=fo().findConfigModuleKey(t);if(n){const r=Iz(fo().config,n,t.code);fo().reloadConfigModule(n,r);const o=Object.values(awe()).find(i=>i.config===n);o&&o.store().updateConfig&&o.store().updateConfig(r)}console.log(`Yaml update ${t.fileName}}`)}else console.error("Unknown module type",t)}function iS(e){return typeof e=="object"&&e!==null&&typeof e.code=="string"&&typeof e.fileName=="string"&&typeof e.id=="string"&&e.type==="script"}function B0(e){return typeof e=="object"&&e!==null&&typeof e.code=="object"&&typeof e.fileName=="string"&&typeof e.id=="string"&&e.type==="yaml"}window.narratHMRHandler=e=>{const t=window.narrat;t&&t.handleHMR(e);const n=new CustomEvent("narrat-hmr",{detail:{newModule:e}});document.body.dispatchEvent(n)};class Re{constructor(t,n,r,o){Wn(this,"keyword");Wn(this,"runner");Wn(this,"argTypes");Wn(this,"parser");Wn(this,"onPlayerAnswered");Wn(this,"returnAfterPlayerAnswer");this.keyword=t,this.runner=r,this.argTypes=n,o?this.parser=o:this.parser=ld(this.keyword,this.argTypes),this.returnAfterPlayerAnswer=!1}async run(t,n){let r=await this.runner(t,n);return this.returnAfterPlayerAnswer&&(r=await new Promise((o,i)=>{un().waitForPlayerAnswer(t),t.finishCommand=o})),r}async processPlayerAnswer(t,n){let r=n;return this.onPlayerAnswered&&(r=await this.onPlayerAnswered(t,n)),this.returnAfterPlayerAnswer&&t.finishCommand&&t.finishCommand(r),r}static FromOptions(t){const n=new Re(t.keyword,t.argTypes,t.runner,t.parser);return n.onPlayerAnswered=t.onPlayerAnswered,n.returnAfterPlayerAnswer=t.returnAfterPlayerAnswer??!1,n}}function ld(e,t){let n=[];if(t!=="any"){n=[];let r=!1;const o=t.reduce((i,a)=>(a.type==="rest"&&(r=!0),a.optional&&i++,i),0);o>=1?n.push(t.length-o):n.push(t.length),n.push(t.length),r&&(n[1]=1/0)}return(r,o)=>{const i={newLine:r.currentLine+1},a=o.command.args;if(t!=="any"&&(a.length<n[0]||a.length>n[1]))return console.log("Error details"),console.log(o.command),console.log(a),r.parserContext.error(r.line.line,`Command ${e}: Expected ${n.join(" to ")} arguments but got ${a.length}`),i;if(o.command.commandType=e,t!=="any"){let s=!1;o.command.args.forEach((c,l)=>{if(s)return;const f=t[l];if(f.type==="rest"){s=!0;return}!rF(c)&&!oF(c)&&(f.type==="any"||typeof c===f.type||r.parserContext.error(r.line.line,`Command ${e}: Argument #${l+1} (${f.name}) should be a ${f.type}, but got type ${typeof c}: ${JSON.stringify(c)}`))})}return{newLine:r.currentLine+1}}}function xt(e,t){console.error("Runtime error ========================="),console.error(`Command: ${e.commandType}`),console.error("Args: ",e.args),console.error("Options: ",e.options),St(`Runtime error at ${e.fileName}:${e.line} (${e.commandType}) ${e.code}. -
218
218
  <br />
219
- Error: ${t}`),console.error("============================")}function Hxe(e,...t){console.log(`[${e.fileName}:${e.line}] log: `,...t)}function Nz(e,t,n){const r=Re.FromOptions({keyword:e,argTypes:t,runner:async o=>await un().runLabelFunction(n,...o.args)});yn.addCommand(r)}const Wxe=Re.FromOptions({keyword:"create_macro",argTypes:"any",runner:async e=>{e.args.length<2&&xt(e,"create_macro command needs at least a name and a label");const t=e.args[0],n=e.args[1],o=e.args.slice(2).map(i=>({name:i,type:"any"}));Nz(t,o,n)}}),Kxe=[["items",bB,wB],["achievements",FB,VB],["screens",$B,TB],["skills",AB,PB],["skillChecks",zB,qB],["buttons",SB,jB],["scripts",mB,Xve],["audio",eB,tB],["quests",kB,xB],["tooltips",RB,DB],["characters",MB,IB],["choices",HB,WB],["animations",GB,JB],["macros",QB,YB],["preload",XB,ZB]],Gxe=[["common",vB,wx]],mc=new Vxe({allErrors:!0}),Jxe=["baseAssetsPath","baseDataPath","gameTitle","saveFileName","images","layout","settings","gameFlow","dialogPanel","splashScreens","notifications","hudStats","interactionTags","transitions","menuButtons","debugging","saves"];async function Qxe(e,t){for(const[n,r,o]of Gxe){const i=t[n];let a=Rz(o);try{if(!mc.validate(r,i))throw console.error(mc.errors),new Error(`${mc.errorsText()}`)}catch(s){console.error(s),St(`${n} config error: ${s}`)}typeof i<"u"&&(a=Rz(i,a)),e[n]=a}}function Rz(e,t){return typeof e=="object"?Array.isArray(e)?[...e]:{...t,...e}:typeof e<"u"?e:t}async function Yxe(e,t){for(const n of Jxe){const r=t[n];r&&(typeof r=="object"&&!Array.isArray(r)?e.common[n]={...e.common[n],...r}:e.common[n]=r)}}async function Xxe(e){const t={...Kf};w0(e)?await Qxe(t,e):Yxe(t,e);for(const n of Kxe){const r=n[0],o=n[1],i=n[2];let a=e[r];if(a&&typeof a=="string")try{if(a=await up(sS(t.common.baseDataPath,a)),!mc.validate(o,a))throw console.error(mc.errors),new Error(`${mc.errorsText()}`)}catch(s){console.error(s),St(`${r} config error: ${s}`),a={...i}}a&&(Array.isArray(a)?t[r]=a:typeof a=="object"?t[r]={...i,...a}:t[r]=a)}for(const n in t)Iz(t,n,t[n]);for(const n of t.macros.macros){const r=n.options??[];Nz(n.keyword,r,n.label)}return t}async function Zxe(e){let t;if(e.config){const o=e.config;t={};for(const i in o){const a=o[i];B0(a)?(fo().addConfigModule(i,{id:a.id,configKey:i,code:a.code}),t[i]=a.code):t[i]=a}}else if(e.configPath)t=await up(e.configPath);else throw St("No config file or config object provided"),new Error("No config file or config object provided");let n=t;return w0(t)&&(n=t.common),n.baseAssetsPath=e.baseAssetsPath??n.baseAssetsPath??"",n.baseDataPath=e.baseDataPath??n.baseDataPath??"",mc.validate(a_,t)||(St("Config file validation failed."),console.log(mc.errors),St(mc.errorsText())),Xxe(t)}function pr(){return fo().config}function Ct(){return pr().common}function wu(e){const t=Ct().hudStats[e];return t||St(`Hud stat ${e} doesn't exist`),t}function Fi(){return pr().audio}function Dz(e){const t=Fi().files[e];if(!t){hu(`Audio file ${e} doesn't exist`);return}return t}function F0(e){const t=Dz(e),n=((t==null?void 0:t.fadeInDelay)??Fi().options.musicFadeInDelay)*1e3,r=((t==null?void 0:t.fadeInTime)??Fi().options.musicFadeInTime)*1e3,o=((t==null?void 0:t.fadeOutTime)??Fi().options.musicFadeOutTime)*1e3;return{fadeInDelay:n,fadeInTime:r,fadeOutTime:o}}function Ns(){return pr().skills}function $p(){return pr().skillChecks}function V0(){return pr().items}function Tp(){return pr().quests}function z0(){return pr().screens}function q0(){return pr().buttons}function ml(){return pr().tooltips}function U0(){return pr().characters}function aS(){return pr().choices}function Lz(){return pr().animations}function Bz(e){return aS().choicePrompts[e]}function ud(e){return e===bx?iB:z0().screens[e]?z0().screens[e]:(St(`Screen config for screen ${e} doesn't exist`),iB)}function H0(e){const n=ml().tooltips.find(r=>r.keywords.includes(e));return n||(St(`Tooltip config for keyword ${e} not found`),null)}function W0(e){const t=pr().skills.skills[e];return t||St(`Skill config for skill ${e} doesn't exist`),t}function Fz(e){const t=pr().skillChecks.skillChecks[e];return t||St(`Skill check config for skill check ${e} doesn't exist`),t}function Vz(e){return!!pr().skillChecks.skillChecks[e]}function fd(e){return e.startsWith("http")?e:ci(e)}function ci(e){var n,r,o,i;if(e.startsWith("http"))return e;let t=e;return Ct().images[e]?t=Ct().images[e]:(n=pr().preload.images)!=null&&n.assets[e]?t=(r=pr().preload.images)==null?void 0:r.assets[e]:(o=pr().preload.video)!=null&&o.assets[e]&&(t=(i=pr().preload.video)==null?void 0:i.assets[e]),Ct().baseAssetsPath?`${Ct().baseAssetsPath}${t}`:t}function sS(e,t){return`${e}${t}`}function K0(e){return Ct().baseDataPath?`${Ct().baseDataPath}${e}`:e}function vl(e){const t=q0().buttons[e];return t||St(`Button config for button ${e} doesn't exist`),t}function Ja(e){const t=V0().items[e];return t||St(`Item config for skill ${e} doesn't exist`),t}function Op(){return pr().achievements}function cS(e){const t=Op().achievements[e];return t||St(`Achievement config for achievement ${e} doesn't exist`),t}function vc(e){return Tp().quests[e]}function zz(e,t){const r=vc(e).endings;return r||St(`Quest ${e} doesn't have any endings`),r[t]||St(`Quest ${e} has no ending called ${t}`),r[t]}function Ep(e,t){return vc(e).objectives[t]}function G0(){return Ct().dialogPanel.width??Kve}const ko=eo("quests",{state:()=>({quests:{}}),actions:{getQuest(e){const t=this.quests[e];if(t)return t;{const n=`Quest ${e} doesn't exist!`;throw St(n),new Error(n)}},getObjective(e,t){const n=this.getQuest(e);if(!n){const i=`Quest ${e} doesn't exist!`;throw St(i),new Error(i)}const r=n.objectives[t];if(r)return r;const o=`Objective ${t} doesn't exist in quest ${e}!`;throw St(o),new Error(o)},updateConfig(e){const t=e.quests;for(const n of Object.keys(t)){const r=t[n];this.quests[n]||(this.quests[n]={id:n,state:"hidden",objectives:{},extraData:{}});for(const o of Object.keys(r.objectives)){const i=r.objectives[o];this.quests[n].objectives[o]||(this.quests[n].objectives[o]={extraData:{},id:o,state:i.hidden?"hidden":"unlocked"})}}},reset(e){this.$reset(),this.updateConfig(e)},startQuest(e){const t=this.getQuest(e);t?(t.state="unlocked",Jo().addNotification(`Started quest: ${vc(e).title}`)):St(`Quest ${e} doesn't exist!`)},startObjective(e,t){const n=this.getObjective(e,t);n?(n.state="unlocked",Jo().addNotification(`New quest objective: ${Ep(e,t).description}`)):St(`Objective ${t} doesn't exist in quest ${e}!`)},completeObjective(e,t){const n=this.getObjective(e,t);n?(n.state="completed",Jo().addNotification(`Completed quest objective: ${Ep(e,t).description}`)):St(`Objective ${t} doesn't exist in quest ${e}!`)},completeQuest(e,t){const n=this.getQuest(e);if(n){if(n.state="completed",typeof t=="string"){n.ending=t;const r=zz(e,t);n.succeeded=r.success}else typeof t=="boolean"?n.succeeded=t:n.succeeded=!0;Jo().addNotification(`Completed quest: ${vc(e).title}`)}else St(`Quest ${e} doesn't exist!`)},isQuestCompleted(e){const t=this.getQuest(e);return t?t.state==="completed":!1},isQuestSucceeded(e){const t=this.getQuest(e);return t?t.state==="completed"&&t.succeeded:!1},isQuestFailed(e){const t=this.getQuest(e);return t?t.state==="completed"&&!t.succeeded:!1},getQuestEnding(e){const t=this.getQuest(e);return t?t.ending:!1},questHasEnding(e,t){return this.getQuestEnding(e)===t},isObjectiveCompleted(e,t){const n=this.getObjective(e,t);return n?n.state==="completed":!1},isQuestStarted(e){const t=this.getQuest(e);return t&&t.state==="unlocked"},isObjectiveStarted(e,t){return this.getObjective(e,t).state==="unlocked"},removeQuest(e){delete this.quests[e]},generateSaveData(){return{quests:Xn(this.quests)}},loadSaveData(e){this.quests=e.quests}}});function qz(e,t,n,r="$"){if(!n.startsWith(r))return isNaN(Number(n))?[null,n]:[null,Number(n)];n=n.substring(1);const o=/\[/,i=/\]/;let a=n.search(o);n.search(i);let s=n,c=t,l=0;for(;l<n.length;){if(a>l||a===-1){const f=a>l?a:n.length;let u=n.substring(l,f);isNaN(Number(u))||(u=Number(u)),l>0&&(c=c[s]),[c,s]=t_e(c,u)}if(a!==-1){l=a;const f=n.substring(a+1),u=e_e(f)+a,d=n.substring(a+1,u),[h,p]=qz(e,e,d);let m=p;h&&(m=h[p]),typeof m=="number"||!isNaN(Number(m))?m=Number(m):typeof m!="string"&&console.error(`invalid array index (${m}) key type when compiling: ${n}`),c=c[s],s=m,l=u+1;const v=n.substring(l);a=v.search(o),a!==-1&&(a+=l),v.search(i)}else l=n.length}return[c,s]}function e_e(e){let t=!1,n=0,r,o=1;for(;!t;){r=e.substring(n);const i=r.search(/\[/),a=r.search(/\]/);i!==-1&&i<a?(n+=i+1,o++):(n+=a+1,o--),o===0&&(t=!0),i===-1&&a===-1&&!t&&St(`Could not find closing bracket in ${e}`)}return n}function t_e(e,t){if(typeof t=="number")return[e,t];t.startsWith(".")&&(t=t.substring(1));const n=t.split(".");let r=e;const o=n.length-1;let i=n[0],a=0;for(a=0;a<o;a++)i=n[a],typeof r[i]>"u"&&(r[i]={}),r=r[i];return i=n[a],[r,i]}function J0(e,t,n="$"){return qz(e,e,t)}function n_e(e,t){return J0(e,t)}function Uz(e,t,n){const[r,o]=J0(e,t);r[o]=n}function Hz(e,t,n){const[r,o]=J0(e,t),i=r[o]||0;r[o]=n+i}function dd(){const e=un(),t=Jr(),n=da(),r=Io(),o=un().scope,i={data:e.data,global:e.globalData,skills:t.skills,skillChecks:t.skillChecks,buttons:n.buttons,items:r.items,quests:ko().quests,stats:Si().hudStats,scope:o,config:Ct(),gameOptions:sn().options,baseSettings:Es().baseSettings,customSettings:Es().customSettings};return new Proxy(i,{get:(s,c,l)=>{const f=un().scope,u=un().data;return typeof f[c]<"u"?f[c]:typeof u[c]<"u"?u[c]:Reflect.get(s,c,l)},set:(s,c,l,f)=>{const u=un().scope,d=un().data;if(typeof u[c]<"u")u[c]=l;else{if(typeof s[c]<"u")return Reflect.set(s,c,l,f);typeof l=="object"?d[c]={}:d[c]=l}return!0}})}function Xn(e){if(e===null)return null;if(typeof e=="object")if(Array.isArray(e)){const t=[];for(const n in e)t[n]=Xn(e[n]);return t}else{const t={};for(const n in e)t[n]=Xn(e[n]);return t}else return e}function lS(e,t){if(e===null)return null;if(typeof e=="object"){const n=t(e);if(t(e))return n;if(Array.isArray(e)){const r=[];for(const o in e)r[o]=lS(e[o],t);return r}else{const r={};for(const o in e)r[o]=lS(e[o],t);return r}}else return t(e)}const Jr=eo("skills",{state:()=>({skillChecks:{},skills:{}}),actions:{setupSkillCheck(e,t){this.skillChecks[t]=e},passSkillCheck(e,t){this.skillChecks[e].happened=!0,this.skillChecks[e].succeeded=!0,t&&(this.skillChecks[e].hidden=!0)},failSkillCheck(e,t){this.skillChecks[e].happened=!0,this.skillChecks[e].succeeded=!1,t&&(this.skillChecks[e].hidden=!0)},resetSkillCheck(e){this.skillChecks[e].happened=!1,this.skillChecks[e].succeeded=!1,this.skillChecks[e].hidden=!1},generateSaveData(){return{skillChecks:Xn(this.skillChecks),skills:Xn(this.skills)}},getSkillCheck(e){return this.skillChecks[e]||this.setupSkillCheck(this.createSkillCheckState(),e),this.skillChecks[e]},createSkillCheckState(){return{happened:!1,succeeded:!1,hidden:!1}},loadSaveData(e){this.skillChecks=fu(this.skillChecks,e.skillChecks),this.skills=fu(this.skills,e.skills)},updateConfig(e){const t=e.skills;for(const n in t)this.skills[n]||(this.skills[n]={id:n,level:t[n].startingLevel||0,xp:0})},reset(e){this.$reset(),this.updateConfig(e)},getSkill(e){return this.skills[e]},getSkillLevel(e){return this.getSkill(e).level},getSkillXp(e){return this.getSkill(e).xp},addXp(e,t){const n=this.getSkill(e);n||St(`Skill ${e} doesn't exist`),n.xp+=t,n.xp>=Ns().skillOptions.xpPerLevel&&(n.xp=0,n.level++,this.levelledUp(e))},setSkillLevel(e,t){const n=this.getSkill(e);n||St(`Skill ${e} doesn't exist`),n.level=t,this.levelledUp(e)},incrementSkill(e,t){this.getSkill(e).level+=t,this.levelledUp(e)},levelledUp(e){const t=Ns().skills[e].name,n=this.skills[e].level;Ns().skillOptions.notifyLevelUp&&Jo().addNotification(`Your skill in ${t} is now level ${n}`)}}});function gc(e){return Array.isArray?Array.isArray(e):Gz(e)==="[object Array]"}const r_e=1/0;function o_e(e){if(typeof e=="string")return e;let t=e+"";return t=="0"&&1/e==-r_e?"-0":t}function i_e(e){return e==null?"":o_e(e)}function Rs(e){return typeof e=="string"}function Wz(e){return typeof e=="number"}function a_e(e){return e===!0||e===!1||s_e(e)&&Gz(e)=="[object Boolean]"}function Kz(e){return typeof e=="object"}function s_e(e){return Kz(e)&&e!==null}function Vi(e){return e!=null}function uS(e){return!e.trim().length}function Gz(e){return e==null?e===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(e)}const SEe="Extended search is not available",c_e="Incorrect 'index' type",l_e=e=>`Invalid value for key ${e}`,u_e=e=>`Pattern length exceeds max of ${e}.`,f_e=e=>`Missing ${e} property in key`,d_e=e=>`Property 'weight' in key '${e}' must be a positive integer`,Jz=Object.prototype.hasOwnProperty;class h_e{constructor(t){this._keys=[],this._keyMap={};let n=0;t.forEach(r=>{let o=Qz(r);n+=o.weight,this._keys.push(o),this._keyMap[o.id]=o,n+=o.weight}),this._keys.forEach(r=>{r.weight/=n})}get(t){return this._keyMap[t]}keys(){return this._keys}toJSON(){return JSON.stringify(this._keys)}}function Qz(e){let t=null,n=null,r=null,o=1,i=null;if(Rs(e)||gc(e))r=e,t=Yz(e),n=fS(e);else{if(!Jz.call(e,"name"))throw new Error(f_e("name"));const a=e.name;if(r=a,Jz.call(e,"weight")&&(o=e.weight,o<=0))throw new Error(d_e(a));t=Yz(a),n=fS(a),i=e.getFn}return{path:t,id:n,weight:o,src:r,getFn:i}}function Yz(e){return gc(e)?e:e.split(".")}function fS(e){return gc(e)?e.join("."):e}function p_e(e,t){let n=[],r=!1;const o=(i,a,s)=>{if(Vi(i))if(!a[s])n.push(i);else{let c=a[s];const l=i[c];if(!Vi(l))return;if(s===a.length-1&&(Rs(l)||Wz(l)||a_e(l)))n.push(i_e(l));else if(gc(l)){r=!0;for(let f=0,u=l.length;f<u;f+=1)o(l[f],a,s+1)}else a.length&&o(l,a,s+1)}};return o(e,Rs(t)?t.split("."):t,0),r?n:n[0]}var mn={...{isCaseSensitive:!1,includeScore:!1,keys:[],shouldSort:!0,sortFn:(e,t)=>e.score===t.score?e.idx<t.idx?-1:1:e.score<t.score?-1:1},...{includeMatches:!1,findAllMatches:!1,minMatchCharLength:1},...{location:0,threshold:.6,distance:100},...{useExtendedSearch:!1,getFn:p_e,ignoreLocation:!1,ignoreFieldNorm:!1,fieldNormWeight:1}};const m_e=/[^ ]+/g;function v_e(e=1,t=3){const n=new Map,r=Math.pow(10,t);return{get(o){const i=o.match(m_e).length;if(n.has(i))return n.get(i);const a=1/Math.pow(i,.5*e),s=parseFloat(Math.round(a*r)/r);return n.set(i,s),s},clear(){n.clear()}}}class dS{constructor({getFn:t=mn.getFn,fieldNormWeight:n=mn.fieldNormWeight}={}){this.norm=v_e(n,3),this.getFn=t,this.isCreated=!1,this.setIndexRecords()}setSources(t=[]){this.docs=t}setIndexRecords(t=[]){this.records=t}setKeys(t=[]){this.keys=t,this._keysMap={},t.forEach((n,r)=>{this._keysMap[n.id]=r})}create(){this.isCreated||!this.docs.length||(this.isCreated=!0,Rs(this.docs[0])?this.docs.forEach((t,n)=>{this._addString(t,n)}):this.docs.forEach((t,n)=>{this._addObject(t,n)}),this.norm.clear())}add(t){const n=this.size();Rs(t)?this._addString(t,n):this._addObject(t,n)}removeAt(t){this.records.splice(t,1);for(let n=t,r=this.size();n<r;n+=1)this.records[n].i-=1}getValueForItemAtKeyId(t,n){return t[this._keysMap[n]]}size(){return this.records.length}_addString(t,n){if(!Vi(t)||uS(t))return;let r={v:t,i:n,n:this.norm.get(t)};this.records.push(r)}_addObject(t,n){let r={i:n,$:{}};this.keys.forEach((o,i)=>{let a=o.getFn?o.getFn(t):this.getFn(t,o.path);if(Vi(a)){if(gc(a)){let s=[];const c=[{nestedArrIndex:-1,value:a}];for(;c.length;){const{nestedArrIndex:l,value:f}=c.pop();if(Vi(f))if(Rs(f)&&!uS(f)){let u={v:f,i:l,n:this.norm.get(f)};s.push(u)}else gc(f)&&f.forEach((u,d)=>{c.push({nestedArrIndex:d,value:u})})}r.$[i]=s}else if(Rs(a)&&!uS(a)){let s={v:a,n:this.norm.get(a)};r.$[i]=s}}}),this.records.push(r)}toJSON(){return{keys:this.keys,records:this.records}}}function Xz(e,t,{getFn:n=mn.getFn,fieldNormWeight:r=mn.fieldNormWeight}={}){const o=new dS({getFn:n,fieldNormWeight:r});return o.setKeys(e.map(Qz)),o.setSources(t),o.create(),o}function g_e(e,{getFn:t=mn.getFn,fieldNormWeight:n=mn.fieldNormWeight}={}){const{keys:r,records:o}=e,i=new dS({getFn:t,fieldNormWeight:n});return i.setKeys(r),i.setIndexRecords(o),i}function Q0(e,{errors:t=0,currentLocation:n=0,expectedLocation:r=0,distance:o=mn.distance,ignoreLocation:i=mn.ignoreLocation}={}){const a=t/e.length;if(i)return a;const s=Math.abs(r-n);return o?a+s/o:s?1:a}function y_e(e=[],t=mn.minMatchCharLength){let n=[],r=-1,o=-1,i=0;for(let a=e.length;i<a;i+=1){let s=e[i];s&&r===-1?r=i:!s&&r!==-1&&(o=i-1,o-r+1>=t&&n.push([r,o]),r=-1)}return e[i-1]&&i-r>=t&&n.push([r,i-1]),n}const ku=32;function b_e(e,t,n,{location:r=mn.location,distance:o=mn.distance,threshold:i=mn.threshold,findAllMatches:a=mn.findAllMatches,minMatchCharLength:s=mn.minMatchCharLength,includeMatches:c=mn.includeMatches,ignoreLocation:l=mn.ignoreLocation}={}){if(t.length>ku)throw new Error(u_e(ku));const f=t.length,u=e.length,d=Math.max(0,Math.min(r,u));let h=i,p=d;const m=s>1||c,v=m?Array(u):[];let g;for(;(g=e.indexOf(t,p))>-1;){let E=Q0(t,{currentLocation:g,expectedLocation:d,distance:o,ignoreLocation:l});if(h=Math.min(E,h),p=g+f,m){let R=0;for(;R<f;)v[g+R]=1,R+=1}}p=-1;let y=[],w=1,k=f+u;const $=1<<f-1;for(let E=0;E<f;E+=1){let R=0,D=k;for(;R<D;)Q0(t,{errors:E,currentLocation:d+D,expectedLocation:d,distance:o,ignoreLocation:l})<=h?R=D:k=D,D=Math.floor((k-R)/2+R);k=D;let L=Math.max(1,d-D+1),I=a?u:Math.min(d+D,u)+f,B=Array(I+2);B[I+1]=(1<<E)-1;for(let N=I;N>=L;N-=1){let W=N-1,X=n[e.charAt(W)];if(m&&(v[W]=+!!X),B[N]=(B[N+1]<<1|1)&X,E&&(B[N]|=(y[N+1]|y[N])<<1|1|y[N+1]),B[N]&$&&(w=Q0(t,{errors:E,currentLocation:W,expectedLocation:d,distance:o,ignoreLocation:l}),w<=h)){if(h=w,p=W,p<=d)break;L=Math.max(1,2*d-p)}}if(Q0(t,{errors:E+1,currentLocation:d,expectedLocation:d,distance:o,ignoreLocation:l})>h)break;y=B}const S={isMatch:p>=0,score:Math.max(.001,w)};if(m){const E=y_e(v,s);E.length?c&&(S.indices=E):S.isMatch=!1}return S}function w_e(e){let t={};for(let n=0,r=e.length;n<r;n+=1){const o=e.charAt(n);t[o]=(t[o]||0)|1<<r-n-1}return t}class Zz{constructor(t,{location:n=mn.location,threshold:r=mn.threshold,distance:o=mn.distance,includeMatches:i=mn.includeMatches,findAllMatches:a=mn.findAllMatches,minMatchCharLength:s=mn.minMatchCharLength,isCaseSensitive:c=mn.isCaseSensitive,ignoreLocation:l=mn.ignoreLocation}={}){if(this.options={location:n,threshold:r,distance:o,includeMatches:i,findAllMatches:a,minMatchCharLength:s,isCaseSensitive:c,ignoreLocation:l},this.pattern=c?t:t.toLowerCase(),this.chunks=[],!this.pattern.length)return;const f=(d,h)=>{this.chunks.push({pattern:d,alphabet:w_e(d),startIndex:h})},u=this.pattern.length;if(u>ku){let d=0;const h=u%ku,p=u-h;for(;d<p;)f(this.pattern.substr(d,ku),d),d+=ku;if(h){const m=u-ku;f(this.pattern.substr(m),m)}}else f(this.pattern,0)}searchIn(t){const{isCaseSensitive:n,includeMatches:r}=this.options;if(n||(t=t.toLowerCase()),this.pattern===t){let p={isMatch:!0,score:0};return r&&(p.indices=[[0,t.length-1]]),p}const{location:o,distance:i,threshold:a,findAllMatches:s,minMatchCharLength:c,ignoreLocation:l}=this.options;let f=[],u=0,d=!1;this.chunks.forEach(({pattern:p,alphabet:m,startIndex:v})=>{const{isMatch:g,score:y,indices:w}=b_e(t,p,m,{location:o+v,distance:i,threshold:a,findAllMatches:s,minMatchCharLength:c,includeMatches:r,ignoreLocation:l});g&&(d=!0),u+=y,g&&w&&(f=[...f,...w])});let h={isMatch:d,score:d?u/this.chunks.length:1};return d&&r&&(h.indices=f),h}}class gl{constructor(t){this.pattern=t}static isMultiMatch(t){return eq(t,this.multiRegex)}static isSingleMatch(t){return eq(t,this.singleRegex)}search(){}}function eq(e,t){const n=e.match(t);return n?n[1]:null}class k_e extends gl{constructor(t){super(t)}static get type(){return"exact"}static get multiRegex(){return/^="(.*)"$/}static get singleRegex(){return/^=(.*)$/}search(t){const n=t===this.pattern;return{isMatch:n,score:n?0:1,indices:[0,this.pattern.length-1]}}}class x_e extends gl{constructor(t){super(t)}static get type(){return"inverse-exact"}static get multiRegex(){return/^!"(.*)"$/}static get singleRegex(){return/^!(.*)$/}search(t){const r=t.indexOf(this.pattern)===-1;return{isMatch:r,score:r?0:1,indices:[0,t.length-1]}}}class __e extends gl{constructor(t){super(t)}static get type(){return"prefix-exact"}static get multiRegex(){return/^\^"(.*)"$/}static get singleRegex(){return/^\^(.*)$/}search(t){const n=t.startsWith(this.pattern);return{isMatch:n,score:n?0:1,indices:[0,this.pattern.length-1]}}}class S_e extends gl{constructor(t){super(t)}static get type(){return"inverse-prefix-exact"}static get multiRegex(){return/^!\^"(.*)"$/}static get singleRegex(){return/^!\^(.*)$/}search(t){const n=!t.startsWith(this.pattern);return{isMatch:n,score:n?0:1,indices:[0,t.length-1]}}}class j_e extends gl{constructor(t){super(t)}static get type(){return"suffix-exact"}static get multiRegex(){return/^"(.*)"\$$/}static get singleRegex(){return/^(.*)\$$/}search(t){const n=t.endsWith(this.pattern);return{isMatch:n,score:n?0:1,indices:[t.length-this.pattern.length,t.length-1]}}}class C_e extends gl{constructor(t){super(t)}static get type(){return"inverse-suffix-exact"}static get multiRegex(){return/^!"(.*)"\$$/}static get singleRegex(){return/^!(.*)\$$/}search(t){const n=!t.endsWith(this.pattern);return{isMatch:n,score:n?0:1,indices:[0,t.length-1]}}}class tq extends gl{constructor(t,{location:n=mn.location,threshold:r=mn.threshold,distance:o=mn.distance,includeMatches:i=mn.includeMatches,findAllMatches:a=mn.findAllMatches,minMatchCharLength:s=mn.minMatchCharLength,isCaseSensitive:c=mn.isCaseSensitive,ignoreLocation:l=mn.ignoreLocation}={}){super(t),this._bitapSearch=new Zz(t,{location:n,threshold:r,distance:o,includeMatches:i,findAllMatches:a,minMatchCharLength:s,isCaseSensitive:c,ignoreLocation:l})}static get type(){return"fuzzy"}static get multiRegex(){return/^"(.*)"$/}static get singleRegex(){return/^(.*)$/}search(t){return this._bitapSearch.searchIn(t)}}class nq extends gl{constructor(t){super(t)}static get type(){return"include"}static get multiRegex(){return/^'"(.*)"$/}static get singleRegex(){return/^'(.*)$/}search(t){let n=0,r;const o=[],i=this.pattern.length;for(;(r=t.indexOf(this.pattern,n))>-1;)n=r+i,o.push([r,n-1]);const a=!!o.length;return{isMatch:a,score:a?0:1,indices:o}}}const hS=[k_e,nq,__e,S_e,C_e,j_e,x_e,tq],rq=hS.length,$_e=/ +(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/,T_e="|";function O_e(e,t={}){return e.split(T_e).map(n=>{let r=n.trim().split($_e).filter(i=>i&&!!i.trim()),o=[];for(let i=0,a=r.length;i<a;i+=1){const s=r[i];let c=!1,l=-1;for(;!c&&++l<rq;){const f=hS[l];let u=f.isMultiMatch(s);u&&(o.push(new f(u,t)),c=!0)}if(!c)for(l=-1;++l<rq;){const f=hS[l];let u=f.isSingleMatch(s);if(u){o.push(new f(u,t));break}}}return o})}const E_e=new Set([tq.type,nq.type]);class A_e{constructor(t,{isCaseSensitive:n=mn.isCaseSensitive,includeMatches:r=mn.includeMatches,minMatchCharLength:o=mn.minMatchCharLength,ignoreLocation:i=mn.ignoreLocation,findAllMatches:a=mn.findAllMatches,location:s=mn.location,threshold:c=mn.threshold,distance:l=mn.distance}={}){this.query=null,this.options={isCaseSensitive:n,includeMatches:r,minMatchCharLength:o,findAllMatches:a,ignoreLocation:i,location:s,threshold:c,distance:l},this.pattern=n?t:t.toLowerCase(),this.query=O_e(this.pattern,this.options)}static condition(t,n){return n.useExtendedSearch}searchIn(t){const n=this.query;if(!n)return{isMatch:!1,score:1};const{includeMatches:r,isCaseSensitive:o}=this.options;t=o?t:t.toLowerCase();let i=0,a=[],s=0;for(let c=0,l=n.length;c<l;c+=1){const f=n[c];a.length=0,i=0;for(let u=0,d=f.length;u<d;u+=1){const h=f[u],{isMatch:p,indices:m,score:v}=h.search(t);if(p){if(i+=1,s+=v,r){const g=h.constructor.type;E_e.has(g)?a=[...a,...m]:a.push(m)}}else{s=0,i=0,a.length=0;break}}if(i){let u={isMatch:!0,score:s/i};return r&&(u.indices=a),u}}return{isMatch:!1,score:1}}}const pS=[];function P_e(...e){pS.push(...e)}function mS(e,t){for(let n=0,r=pS.length;n<r;n+=1){let o=pS[n];if(o.condition(e,t))return new o(e,t)}return new Zz(e,t)}const Y0={AND:"$and",OR:"$or"},vS={PATH:"$path",PATTERN:"$val"},gS=e=>!!(e[Y0.AND]||e[Y0.OR]),M_e=e=>!!e[vS.PATH],I_e=e=>!gc(e)&&Kz(e)&&!gS(e),oq=e=>({[Y0.AND]:Object.keys(e).map(t=>({[t]:e[t]}))});function iq(e,t,{auto:n=!0}={}){const r=o=>{let i=Object.keys(o);const a=M_e(o);if(!a&&i.length>1&&!gS(o))return r(oq(o));if(I_e(o)){const c=a?o[vS.PATH]:i[0],l=a?o[vS.PATTERN]:o[c];if(!Rs(l))throw new Error(l_e(c));const f={keyId:fS(c),pattern:l};return n&&(f.searcher=mS(l,t)),f}let s={children:[],operator:i[0]};return i.forEach(c=>{const l=o[c];gc(l)&&l.forEach(f=>{s.children.push(r(f))})}),s};return gS(e)||(e=oq(e)),r(e)}function N_e(e,{ignoreFieldNorm:t=mn.ignoreFieldNorm}){e.forEach(n=>{let r=1;n.matches.forEach(({key:o,norm:i,score:a})=>{const s=o?o.weight:null;r*=Math.pow(a===0&&s?Number.EPSILON:a,(s||1)*(t?1:i))}),n.score=r})}function R_e(e,t){const n=e.matches;t.matches=[],Vi(n)&&n.forEach(r=>{if(!Vi(r.indices)||!r.indices.length)return;const{indices:o,value:i}=r;let a={indices:o,value:i};r.key&&(a.key=r.key.src),r.idx>-1&&(a.refIndex=r.idx),t.matches.push(a)})}function D_e(e,t){t.score=e.score}function L_e(e,t,{includeMatches:n=mn.includeMatches,includeScore:r=mn.includeScore}={}){const o=[];return n&&o.push(R_e),r&&o.push(D_e),e.map(i=>{const{idx:a}=i,s={item:t[a],refIndex:a};return o.length&&o.forEach(c=>{c(i,s)}),s})}class hd{constructor(t,n={},r){this.options={...mn,...n},this.options.useExtendedSearch,this._keyStore=new h_e(this.options.keys),this.setCollection(t,r)}setCollection(t,n){if(this._docs=t,n&&!(n instanceof dS))throw new Error(c_e);this._myIndex=n||Xz(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight})}add(t){Vi(t)&&(this._docs.push(t),this._myIndex.add(t))}remove(t=()=>!1){const n=[];for(let r=0,o=this._docs.length;r<o;r+=1){const i=this._docs[r];t(i,r)&&(this.removeAt(r),r-=1,o-=1,n.push(i))}return n}removeAt(t){this._docs.splice(t,1),this._myIndex.removeAt(t)}getIndex(){return this._myIndex}search(t,{limit:n=-1}={}){const{includeMatches:r,includeScore:o,shouldSort:i,sortFn:a,ignoreFieldNorm:s}=this.options;let c=Rs(t)?Rs(this._docs[0])?this._searchStringList(t):this._searchObjectList(t):this._searchLogical(t);return N_e(c,{ignoreFieldNorm:s}),i&&c.sort(a),Wz(n)&&n>-1&&(c=c.slice(0,n)),L_e(c,this._docs,{includeMatches:r,includeScore:o})}_searchStringList(t){const n=mS(t,this.options),{records:r}=this._myIndex,o=[];return r.forEach(({v:i,i:a,n:s})=>{if(!Vi(i))return;const{isMatch:c,score:l,indices:f}=n.searchIn(i);c&&o.push({item:i,idx:a,matches:[{score:l,value:i,norm:s,indices:f}]})}),o}_searchLogical(t){const n=iq(t,this.options),r=(s,c,l)=>{if(!s.children){const{keyId:u,searcher:d}=s,h=this._findMatches({key:this._keyStore.get(u),value:this._myIndex.getValueForItemAtKeyId(c,u),searcher:d});return h&&h.length?[{idx:l,item:c,matches:h}]:[]}const f=[];for(let u=0,d=s.children.length;u<d;u+=1){const h=s.children[u],p=r(h,c,l);if(p.length)f.push(...p);else if(s.operator===Y0.AND)return[]}return f},o=this._myIndex.records,i={},a=[];return o.forEach(({$:s,i:c})=>{if(Vi(s)){let l=r(n,s,c);l.length&&(i[c]||(i[c]={idx:c,item:s,matches:[]},a.push(i[c])),l.forEach(({matches:f})=>{i[c].matches.push(...f)}))}}),a}_searchObjectList(t){const n=mS(t,this.options),{keys:r,records:o}=this._myIndex,i=[];return o.forEach(({$:a,i:s})=>{if(!Vi(a))return;let c=[];r.forEach((l,f)=>{c.push(...this._findMatches({key:l,value:a[f],searcher:n}))}),c.length&&i.push({idx:s,item:a,matches:c})}),i}_findMatches({key:t,value:n,searcher:r}){if(!Vi(n))return[];let o=[];if(gc(n))n.forEach(({v:i,i:a,n:s})=>{if(!Vi(i))return;const{isMatch:c,score:l,indices:f}=r.searchIn(i);c&&o.push({score:l,key:t,value:i,idx:a,norm:s,indices:f})});else{const{v:i,n:a}=n,{isMatch:s,score:c,indices:l}=r.searchIn(i);s&&o.push({score:c,key:t,value:i,norm:a,indices:l})}return o}}hd.version="6.6.2",hd.createIndex=Xz,hd.parseIndex=g_e,hd.config=mn,hd.parseQuery=iq,P_e(A_e);const B_e=b.createElementVNode("h3",{class:"title"},"Jump to label",-1),F_e={key:0,class:"search-results"},V_e={key:1},z_e=[b.createElementVNode("h3",null,"No matches found",-1)],q_e=b.defineComponent({__name:"debug-jumping",emits:["close","jump"],setup(e,{emit:t}){const n=t;let r;const o=b.ref(null),i=b.ref(""),a=b.ref([]),s=b.ref(0),c=b.ref(null);function l(){const d=i.value,h=r.search(d);a.value=h.map(p=>p.item),a.value.length>0&&s.value>a.value.length-1&&(s.value=a.value.length-1)}function f(d){if(d===s.value)return{background:"var(--light-background)"}}const u=b.computed(()=>Object.keys(yn.script).sort());return b.onMounted(()=>{sn().debugMode=!0,r=new hd(u.value,{includeScore:!0}),a.value=u.value,s.value=0,setTimeout(()=>{b.nextTick(()=>{c.value&&c.value.focus()})},10),o.value=xr().registerInputListener("debug-jumping",{up:{press:()=>{s.value>0?s.value--:s.value=a.value.length-1}},down:{press:()=>{a.value.length>s.value+1?s.value++:s.value=0}},continue:{press:()=>{if(a.value.length>0&&s.value<a.value.length){const d=a.value[s.value];un().jumpToLabel(d),n("close")}}},escape:{press:()=>{n("close")}}})}),b.onUnmounted(()=>{o.value&&xr().unregisterInputListener(o.value),sn().debugMode=!1}),(d,h)=>(b.openBlock(),b.createBlock(Bs,{onClose:h[1]||(h[1]=p=>d.$emit("close")),containerCssClass:"jump-menu-container"},{header:b.withCtx(()=>[B_e]),body:b.withCtx(()=>[b.withDirectives(b.createElementVNode("input",{type:"text",class:"label-input input",ref_key:"search",ref:c,"onUpdate:modelValue":h[0]||(h[0]=p=>i.value=p),onInput:l},null,544),[[b.vModelText,i.value]]),a.value.length>0?(b.openBlock(),b.createElementBlock("div",F_e,[(b.openBlock(!0),b.createElementBlock(b.Fragment,null,b.renderList(a.value,(p,m)=>(b.openBlock(),b.createElementBlock("div",{class:"search-result",style:b.normalizeStyle(f(m)),key:m},b.toDisplayString(p),5))),128))])):(b.openBlock(),b.createElementBlock("div",V_e,z_e))]),_:1}))}}),xu=eo("achievements",{state:()=>({achievements:{}}),actions:{generateGlobalSaveData(){return{achievements:Xn(this.achievements)}},loadGlobalSaveData(e){this.achievements={...this.achievements,...Xn(e.achievements)}},updateConfig(e){Object.keys(e.achievements).forEach(t=>{this.achievements[t]||(this.achievements[t]={id:t,unlocked:!1})})},reset(e){this.$reset(),this.updateConfig(e)},hasAchievement(e){var t;return((t=this.achievements[e])==null?void 0:t.unlocked)??!1},getExistingAchievement(e){return this.achievements[e]},unlock(e){const t=this.getExistingAchievement(e);if(!t){St(`Tried to unlock achievement ${e} but it doesn't exist`);return}if(!t.unlocked){const n=new Date().toISOString();t.unlocked=!0,t.unlockTime=n}if(Op().notifyNewAchievements){const n=cS(e);Jo().addNotification(`New Achievement: ${n.name}`,n.description,n.icon)}}}}),yS=eo("choices-tracking-store",{state:()=>({choices:{}}),getters:{},actions:{trackChoice(e,t){this.choices[e]||(this.choices[e]={}),this.choices[e][t]=!0},hasSeenChoice(e,t){var n;return((n=this.choices[e])==null?void 0:n[t])??!1},generateSaveData(){return{choices:Xn(this.choices)}},loadSaveData(e){this.choices=Xn(e.choices)},reset(){this.$reset()}}}),bS={main:{store:sn,save:"main"},achievements:{store:xu,config:"achievements",globalSave:"achievements"},audio:{store:Po,config:"audio",save:"audio"},choicesTracking:{store:yS,config:"choices",save:"choices"},config:{store:fo,save:"config"},dialog:{store:cr,save:"dialog"},hud:{store:Si,config:"common",save:"hud"},inputs:{store:xr},inventory:{store:Io,config:"items",save:"inventory"},menu:{store:No},notifications:{store:Jo,config:"common"},quests:{store:ko,config:"quests",save:"quests"},rendering:{store:Gr,save:"rendering"},screens:{store:da,config:"screens",save:"screens"},sprites:{store:Bi,save:"screenObjects"},settings:{store:Es,save:"settings",config:"common"},skills:{store:Jr,config:"skills",save:"skills"},startMenu:{store:Ux},tooltips:{store:Wf,config:"tooltips"},vm:{store:un,save:"vm",globalSave:"data"},scenes:{store:_i,save:"scenes"}};function aq(){const e={};for(const t in bS){const r=bS[t].store();e[t]=r}return e}function U_e(e){const t=aq();for(const n in e){const r=e[n];Object.assign(t[n],r)}}owe(bS);const H_e=b.defineComponent({components:{ModalWindow:Bs,DebugJumping:q_e},setup(){const e=Jr(),t=b.computed(()=>e.skills),n=b.computed(()=>e.skillChecks);return{skills:t,skillChecks:n}},data(){return{showDebug:!1,jumping:!1,inputListener:null}},mounted(){const e=Gr(),t=Ct().hotkeys.debugMenu??"d",n=Ct().hotkeys.jumpMenu??"j";e.inputsContainer.addEventListener("keydown",r=>{this.jumping||(r.key===t&&this.toggle(),r.key===n&&this.jump())})},methods:{closeJumping(){this.jumping=!1},labelSelected(e){const t=e.target.value;un().jumpToLabel(t),this.close()},close(){this.showDebug=!1,this.endDebug()},closeErrors(){sn().clearErrors()},open(){this.showDebug=!0,this.startDebug();const e=un(),t=ko(),n=Io(),r=Jr();this.$nextTick(()=>{new g7({target:this.$refs.variablesViewer,props:{content:{text:void 0,json:{data:this.variables,quests:t.quests,items:n.items,skills:r.skills,skillChecks:r.skillChecks}},onChange:o=>{e.overrideData(o.json.data),t.quests=o.json.quests,n.items=o.json.items,r.skills=o.json.skills,r.skillChecks=o.json.skillChecks}}}),new g7({target:this.$refs.stateViewer,props:{content:{text:void 0,json:aq()},onChange:o=>{U_e(o.json)}}})})},toggle(){this.showDebug?this.close():this.open()},startDebug(){sn().debugMode=!0},endDebug(){sn().debugMode=!1},jump(){this.jumping=!0,this.startDebug()},save(){Zx({})},resetSave(){Tme()},resetGlobalSave(){CV()},wordCount(){const t=Object.values(this.script).reduce((n,r)=>(qi.log(n),n+this.countWordsInScriptBranch(r.branch)),0);alert(`You have ${t} words`)},countWordsInScriptLine(e){if(e.command.commandType==="talk"&&typeof e.command.args[2]=="string")return this.countWordsInString(e.command.args[2]);if(e.command.commandType==="text")return this.countWordsInString(e.code);if(e.command.commandType==="choice"){const t=e.command.staticOptions;let n=this.countWordsInScriptLine(t.prompt);return n+=t.choices.reduce((o,i)=>o+this.countWordsInString(i.prompt.code),0),t.choices.reduce((o,i)=>i.branch?o+this.countWordsInScriptBranch(i.branch):o,n)}if(e.command.commandType==="if"){const t=e.command.staticOptions;return[t.success,t.failure].reduce((r,o)=>o?r+this.countWordsInScriptBranch(o):r,0)}return 0},countWordsInString(e){return e.split(" ").length},countWordsInScriptBranch(e){return e.reduce((t,n)=>n?t+this.countWordsInScriptLine(n):t,0)},getPlayTimeString(){const e=Su(this.playTime.start,this.playTime.previousPlaytime);return ty(e/1e3)}},computed:{...rp(un,["data"]),...rp(sn,["playTime","errors","playing"]),...rp(_i,["activeScene"]),labels(){const e=this.script;return Object.keys(e).sort()},script(){return yn.script},variables(){return this.data}}}),W_e={class:"debug-menu"},K_e={key:0,class:"debug-info"},G_e=[b.createStaticVNode("<h3>Debug mode is ON</h3><ul><li><b>j</b>: Quick Label Jump</li><li><b>d</b>: Debug Menu</li><li><b>a</b>: Auto Play</li><li><b>s</b>: Skip</li><li><b>Space</b>: New Game</li><li><b>c</b>: Continue</li><li><b>Escape</b>: Toggle Menu</li></ul>",2)],J_e=b.createElementVNode("h3",{class:"title"},"Error(s)",-1),Q_e=["innerHTML"],Y_e=b.createElementVNode("h3",{class:"title"},"Debug Menu!",-1),X_e={class:"container"},Z_e=b.createElementVNode("option",{class:"option",selected:"",disabled:""},"Jump to a label",-1),eSe=["value"],tSe={class:"grid grid-cols-3 gap-4"},nSe=b.createElementVNode("h2",null,"Variables Editor",-1),rSe={ref:"variablesViewer"},oSe=b.createElementVNode("h2",null,"Skill Checks",-1),iSe={class:"table-auto"},aSe=b.createElementVNode("thead",null,[b.createElementVNode("tr",null,[b.createElementVNode("th",null,"Skill Check"),b.createElementVNode("th",null,"Happened"),b.createElementVNode("th",null,"Succeeded")])],-1),sSe=b.createElementVNode("h2",null,"App State editor (entire app and engine",-1),cSe=b.createElementVNode("h3",{style:{color:"pink"}}," Use for debugging, editing some of those things can cause issues ",-1),lSe={ref:"stateViewer"};function uSe(e,t,n,r,o,i){const a=b.resolveComponent("DebugJumping"),s=b.resolveComponent("ModalWindow");return b.openBlock(),b.createElementBlock("div",W_e,[b.createElementVNode("button",{onClick:t[0]||(t[0]=(...c)=>e.open&&e.open(...c)),class:"button debug-button"},"Debug Menu"),!e.playing&&e.activeScene==="menu"?(b.openBlock(),b.createElementBlock("div",K_e,G_e)):b.createCommentVNode("",!0),e.jumping?(b.openBlock(),b.createBlock(a,{key:1,onClose:e.closeJumping},null,8,["onClose"])):b.createCommentVNode("",!0),e.errors.length>0?(b.openBlock(),b.createBlock(s,{key:2,onClose:e.closeErrors,containerCssClass:"debug-menu-container"},{header:b.withCtx(()=>[J_e]),body:b.withCtx(()=>[b.createTextVNode(" There are errors in your dialogue scripts. Open the developer console for more details. "),b.createElementVNode("ul",null,[(b.openBlock(!0),b.createElementBlock(b.Fragment,null,b.renderList(e.errors,(c,l)=>(b.openBlock(),b.createElementBlock("li",{key:l,class:b.normalizeClass(["error-message list-disc",c.type==="error"?"error":"warning"]),innerHTML:c.text},null,10,Q_e))),128))])]),_:1},8,["onClose"])):b.createCommentVNode("",!0),e.showDebug?(b.openBlock(),b.createBlock(s,{key:3,onClose:e.close,containerCssClass:"debug-menu-container"},{header:b.withCtx(()=>[Y_e]),body:b.withCtx(()=>[b.createElementVNode("div",X_e,[b.createTextVNode(" Hello this is the debug menu. "),b.createElementVNode("select",{class:"select",name:"label-selector",onChange:t[1]||(t[1]=c=>e.labelSelected(c))},[Z_e,(b.openBlock(!0),b.createElementBlock(b.Fragment,null,b.renderList(e.labels,c=>(b.openBlock(),b.createElementBlock("option",{class:"option",value:c,key:c},b.toDisplayString(c),9,eSe))),128))],32),b.createElementVNode("div",tSe,[b.createElementVNode("button",{onClick:t[2]||(t[2]=(...c)=>e.wordCount&&e.wordCount(...c)),class:"button"},"Word Count"),b.createElementVNode("button",{onClick:t[3]||(t[3]=(...c)=>e.save&&e.save(...c)),class:"button"},"Save Game"),b.createElementVNode("button",{onClick:t[4]||(t[4]=(...c)=>e.resetSave&&e.resetSave(...c)),class:"button"},"Reset Save"),b.createElementVNode("button",{onClick:t[5]||(t[5]=(...c)=>e.resetGlobalSave&&e.resetGlobalSave(...c)),class:"button"}," Reset GLOBAL Save ")]),b.createElementVNode("h3",null,"Play time: "+b.toDisplayString(e.getPlayTimeString()),1),nSe,b.createElementVNode("div",rSe,null,512),oSe,b.createElementVNode("table",iSe,[aSe,b.createElementVNode("tbody",null,[(b.openBlock(!0),b.createElementBlock(b.Fragment,null,b.renderList(e.skillChecks,(c,l)=>(b.openBlock(),b.createElementBlock("tr",{key:l},[b.createElementVNode("td",null,b.toDisplayString(l),1),b.createElementVNode("td",null,b.toDisplayString(c.happened?"✅":"❌"),1),b.createElementVNode("td",null,b.toDisplayString(c.happened?c.succeeded?"✅":"❌":"NA"),1)]))),128))])]),sSe,cSe,b.createElementVNode("div",lSe,null,512)])]),_:1},8,["onClose"])):b.createCommentVNode("",!0)])}const fSe=Xa(H_e,[["render",uSe]]),dSe=["src"],hSe=["innerHTML"],pSe=["innerHTML"],mSe=b.defineComponent({__name:"notification-toast",setup(e){const t=Jo(),n=b.computed(()=>t.notifications),r=o=>{if(o.description)return{marginTop:"10px"}};return(o,i)=>(b.openBlock(),b.createBlock(b.TransitionGroup,{name:"notification",tag:"div",class:"notifications-holder"},{default:b.withCtx(()=>[(b.openBlock(!0),b.createElementBlock(b.Fragment,null,b.renderList(n.value,(a,s)=>(b.openBlock(),b.createElementBlock("div",{class:"notification tile",key:s},[a.icon?(b.openBlock(),b.createElementBlock("img",{key:0,src:b.unref(ci)(a.icon),class:"notification-icon",style:b.normalizeStyle(r(a))},null,12,dSe)):b.createCommentVNode("",!0),b.createElementVNode("span",{innerHTML:a.text,class:"notification-text"},null,8,hSe),a.description?(b.openBlock(),b.createElementBlock("p",{key:1,innerHTML:a.description,class:"notification-description"},null,8,pSe)):b.createCommentVNode("",!0)]))),128))]),_:1}))}}),vSe={class:"title"},gSe=b.defineComponent({__name:"alert-modal",props:{title:{type:String,required:!1},text:{type:String,required:!1}},emits:["close"],setup(e,{emit:t}){const n=t;function r(){n("close")}const o=b.ref(xr().registerInputListener("yes-no",{cancel:{press:()=>{r()}},continue:{press:()=>{r()}},system:{press:()=>{r()}}}));return b.onUnmounted(()=>{o.value&&xr().unregisterInputListener(o.value)}),(i,a)=>(b.openBlock(),b.createBlock(Bs,{onClose:r,containerCssClass:"yes-no-modal"},{header:b.withCtx(()=>[b.createElementVNode("h3",vSe,b.toDisplayString(e.title??"Alert"),1)]),body:b.withCtx(()=>[b.createElementVNode("h3",null,b.toDisplayString(e.text),1)]),_:1}))}}),ySe=b.createElementVNode("hr",null,null,-1),bSe=b.defineComponent({__name:"floating-tooltip",props:{title:{},text:{},width:{},x:{},y:{},screenWidth:{},screenHeight:{},screenMargin:{},cssClass:{},textCssClass:{},titleCssClass:{}},setup(e){const t=b.ref(150),n=b.ref(null),r=e,o=b.computed(()=>r.screenWidth??window.innerWidth),i=b.computed(()=>r.screenHeight??window.innerHeight),a=b.computed(()=>{const s=r.screenMargin??5,c={};let l=r.x-r.width/2;l=Math.min(l,o.value-r.width-s),l=Math.max(s,l),c.left=`${l}px`;let f=i.value-r.y;return f=Math.max(f,s),f=Math.min(f,i.value-t.value-s),c.bottom=`${f}px`,c.width=`${r.width}px`,c});return b.onMounted(()=>{n.value&&(t.value=n.value.clientHeight)}),(s,c)=>(b.openBlock(),b.createBlock(b.Transition,{name:"fade"},{default:b.withCtx(()=>[b.createElementVNode("div",{class:b.normalizeClass(["floating-tooltip",s.cssClass]),style:b.normalizeStyle(a.value),ref_key:"element",ref:n},[s.title?(b.openBlock(),b.createElementBlock("div",{key:0,class:b.normalizeClass(["floating-tooltip-title",s.titleCssClass])},[b.createTextVNode(b.toDisplayString(r.title)+" ",1),ySe],2)):b.createCommentVNode("",!0),b.createElementVNode("div",{class:b.normalizeClass(["floating-tooltip-text",s.textCssClass])},b.toDisplayString(r.text),3)],6)]),_:1}))}}),wSe={class:"tooltips-ui"},kSe=b.defineComponent({__name:"tooltips-ui",setup(e){const t=Wf(),n=Gr(),r=b.computed(()=>t.tooltip),o=b.computed(()=>n.screenWidth),i=b.computed(()=>n.screenHeight),a=b.computed(()=>{if(r.value)return{...r.value,screenMargin:ml().options.screenEdgesMinimumMargin??5,screenWidth:o.value,screenHeight:i.value,...s(r.value)}});function s(c){var f,u;let l={};return ml().options.styling&&(l={...l,...ml().options.styling}),(f=H0(c.keyword))!=null&&f.styling&&(l={...l,...(u=H0(c.keyword))==null?void 0:u.styling}),l}return(c,l)=>(b.openBlock(),b.createElementBlock("div",wSe,[r.value?(b.openBlock(),b.createBlock(bSe,b.normalizeProps(b.mergeProps({key:0},a.value)),null,16)):b.createCommentVNode("",!0)]))}}),wS={};async function xSe(e){qi.log("Loading videos");const t=[],n=async(o,i)=>await _Se(o,i),r=(o,i)=>{t.push(n(o,i))};if(e.preload.video)for(const o in e.preload.video.assets){const i=e.preload.video.assets[o];r(o,i)}return Promise.all(t)}async function _Se(e,t){if(wS[e])return wS[e];const n=new Promise((r,o)=>{const i=document.createElement("video");i.onloadeddata=()=>{r(i)},i.onerror=a=>{St(`Could not load video ${t}`,a),o(a)},i.src=ci(t)});return wS[e]=n,n}async function SSe(){const t=pr().scripts;Po().setMasterVolume(Fi().options.volume??1),await un().loadScripts(t),No().setup();for(const[,n]of yn.customStores())if(n.setup){const r=n.setup();vx(r)&&await r}yn.addCustomSettings(),SV()}async function jSe(){const e=sn(),t=i1e(pr()),n=xSe(pr()),r=vve(Fi());if(yn.plugins){const o=[];for(const i of yn.plugins)i.loadingPromises&&o.push(Promise.all(i.loadingPromises));o.length>0&&(e.setLoadingStep("Plugins",0),await Promise.all(o))}e.setLoadingStep("Assets",.3),await Promise.all([t,n,r]),yn.callHook("onAssetsLoaded"),e.setLoadingStep("Starting",.9),await SSe(),yn.callHook("onGameSetup"),e.gameLoaded()}const CSe=["id"],$Se=b.defineComponent({__name:"GameScene",props:{sceneId:{},options:{}},setup(e){const t=e,n=_i(),r=b.computed(()=>n.getSceneConfig(t.sceneId));function o(){n.finishedScene(t.sceneId)}return(i,a)=>(b.openBlock(),b.createElementBlock("div",{class:"game-scene",id:`scene-${i.sceneId}`},[(b.openBlock(),b.createBlock(b.resolveDynamicComponent(r.value.component),{onFinished:o,options:i.options},null,40,["options"]))],8,CSe))}}),TSe=b.defineComponent({__name:"app",props:{options:{}},setup(e){const t=e,n=sn(),r=_i(),o=b.computed(()=>r.activeScene),i=b.computed(()=>n.alerts),a=Gr(),s=b.computed(()=>({transform:`scale(${a.gameScaleRatio}, ${a.gameScaleRatio})`,width:`${a.gameWidth}px`,height:`${a.actualGameHeight}px`})),c=b.computed(()=>No().activeMenu?"app-blurred-by-modal":{});function l(u){sn().closeAlert(u)}function f(){Gr().refreshScreenSize()}return b.onMounted(async()=>{yn.callHook("onAppMounted"),await jSe(),a.inputsContainer.addEventListener("resize",dp(()=>{f()},100,{maxWait:200})),ha.setup(t.options.debug),setTimeout(()=>{f()},50)}),(u,d)=>(b.openBlock(),b.createElementBlock(b.Fragment,null,[b.createElementVNode("div",{id:"narrat-app-container",style:b.normalizeStyle(s.value)},[b.createElementVNode("div",{id:"narrat-app",class:b.normalizeClass(c.value),tabindex:"0"},[b.createVNode(b.Transition,{name:"screens-fade"},{default:b.withCtx(()=>[(b.openBlock(),b.createBlock($Se,{key:o.value,sceneId:o.value,options:b.unref(r).currentOptions},null,8,["sceneId","options"]))]),_:1}),u.options.debug?(b.openBlock(),b.createBlock(fSe,{key:0})):b.createCommentVNode("",!0),b.createVNode(mSe),(b.openBlock(!0),b.createElementBlock(b.Fragment,null,b.renderList(i.value,h=>(b.openBlock(),b.createBlock(gSe,{key:h.id,title:h.title,text:h.text,onClose:()=>l(h.id)},null,8,["title","text","onClose"]))),128))],2)],4),b.createVNode(kSe)],64))}}),OSe=new Re("add_level",[{name:"skillKey",type:"string"},{name:"amount",type:"number"}],async e=>{let{skillKey:t,amount:n}=e.options;if((!t||!n)&&xt(e,"add_level command needs a skill id and a value as parameters"),!Number.isInteger(n)){const r=n;n=Math.round(n),console.warn(`add_level expects a level to be an integer. Auto Rounding ${r} to ${n}`)}Jr().incrementSkill(t,n)}),ESe=Re.FromOptions({keyword:"set_level",argTypes:[{name:"skill",type:"string"},{name:"level",type:"number"}],runner:async e=>{let{skill:t,level:n}=e.options;if((!t||!n)&&xt(e,"set_level command needs a skill id and a value as parameters"),!Number.isInteger(n)){const r=n;n=Math.round(n),console.warn(`set_level expects a level to be an integer. Auto Rounding ${r} to ${n}`)}Jr().setSkillLevel(t,n)}}),ASe=new Re("add_xp",[{name:"xpKey",type:"string"},{name:"xpToAdd",type:"number"}],async e=>{const{xpKey:t,xpToAdd:n}=e.options;(!t||!n)&&xt(e,"add_xp command needs a skill id and a value as parameters"),Jr().addXp(t,n)}),PSe=new Re("get_level",[{name:"skillKey",type:"string"}],async e=>{const{skillKey:t}=e.options;t||xt(e,"get_level command needs a skill id as parameter");const n=Jr().getSkill(t);return n||xt(e,`Skill ${t} not found`),n.level}),MSe=new Re("get_xp",[{name:"xpKey",type:"string"}],async e=>{const{xpKey:t}=e.options;t||xt(e,"get_xp command needs a skill id as parameter");const n=Jr().getSkillXp(t);return n||xt(e,`XP ${t} not found`),n}),ISe=new Re("roll",[{name:"id",type:"string"},{name:"skill",type:"string",optional:!0},{name:"difficulty",type:"number",optional:!0},{name:"mode",type:"string",optional:!0}],async e=>{const{id:t}=e.options;let n={id:t};if(e.args.length===1&&Vz(t))n={...Fz(t),id:t};else{const{skill:o,difficulty:i,mode:a}=e.options;if(!o||!i){xt(e,"roll command needs a skill and a difficulty as parameters, or the skill check id to be configured in skillChecks.yaml");return}n={skill:o,difficulty:i,id:t},a==="hideAfterRoll"&&(n.hideAfterRoll=!0),a==="repeatable"&&(n.repeatable=!0)}return nF(n).succeeded}),NSe=new Re("get_skill_check",[{name:"skillCheckId",type:"string"}],async e=>Jr().getSkillCheck(e.options.skillCheckId)),RSe=new Re("skill_check_result",[{name:"skillCheckId",type:"string"}],async e=>Jr().getSkillCheck(e.options.skillCheckId).succeeded),DSe=new Re("reset_roll",[{name:"id",type:"string"}],async e=>Jr().resetSkillCheck(e.options.id)),LSe=new Re("add_stat",[{name:"statKey",type:"string"},{name:"amountToAdd",type:"number"}],async e=>{const{statKey:t,amountToAdd:n}=e.options;(!t||typeof n!="number")&&xt(e,"add_stat command needs a stat id and a value as parameters"),Si().addStat(t,n)}),BSe=new Re("set_stat",[{name:"statKey",type:"string"},{name:"value",type:"number"}],async e=>{const{statKey:t,value:n}=e.options;(!t||typeof n!="number")&&xt(e,"set_stat command needs a stat id and a value as parameters"),Si().setStat(t,n)}),FSe=new Re("get_stat_value",[{name:"statKey",type:"string"}],async e=>{const{statKey:t}=e.options;return t||xt(e,"get_stat_value command needs a stat id as parameter"),Si().getStatValue(t)}),VSe=new Re("show_hud",[],async e=>{Si().setVisibility(!0)}),zSe=new Re("hide_hud",[],async e=>{Si().setVisibility(!1)}),qSe=Re.FromOptions({keyword:"jump",argTypes:"any",runner:async e=>{(e.args.length<1||typeof e.args[0]!="string")&&xt(e,"requires a label argument");const t=e.args[0],n=un(),r={branchData:yn.script[t],label:t,args:e.args.splice(1),currentIndex:0};if(!yn.script[t]){St(`Trying to jump but label ${t} not found`);return}return n.jumpTarget=r,o0}}),USe=Re.FromOptions({keyword:"run",argTypes:"any",runner:async e=>{(e.args.length<1||typeof e.args[0]!="string")&&xt(e,"run command needs a label to argument run");const t=e.args[0];return await un().runLabelFunction(t,...e.args.slice(1))}}),HSe=Re.FromOptions({keyword:"var",argTypes:[{name:"name",type:"string"},{name:"value",type:"any"}],runner:async e=>{const{name:t,value:n}=e.options;un().addScopedVariable(t,n)}}),WSe=Re.FromOptions({keyword:"return",argTypes:[{name:"value",type:"any"}],runner:async e=>{const{value:t}=e.options;return un().setReturnValue(t),yx}}),KSe=Re.FromOptions({keyword:"log",argTypes:"any",runner:async e=>{Hxe(e,...e.args)}}),GSe=Re.FromOptions({keyword:"menu_return",argTypes:[],runner:async e=>(mV(),i0)}),JSe=Re.FromOptions({keyword:"save",argTypes:[{name:"name",type:"string",optional:!0}],runner:async e=>{await $V({saveName:e.options.name})}}),QSe=Re.FromOptions({keyword:"save_prompt",argTypes:[{name:"name",type:"string",optional:!0}],runner:async e=>{await $V({saveName:e.options.name,withPrompt:!0})}}),YSe=Re.FromOptions({keyword:"reset_global_save",argTypes:[],runner:async e=>{await CV()}}),XSe=Re.FromOptions({keyword:"new",argTypes:[{name:"name",type:"string"},{name:"rest",type:"rest",optional:!0}],runner:async e=>{const t=e.options.name;if(t==="Array")return[...e.args.slice(1)];if(t==="Object")return{}}}),ZSe=[{name:"mode",type:"string"},{name:"audio",type:"string"},{name:"channel",type:"number",optional:!0}],eje=new Re("play",ZSe,async e=>{const t=Po(),{mode:n,audio:r,channel:o}=e.options,i=X0(e,n);i&&t.playChannel(i,r,o??0)}),tje=new Re("resume",[{name:"mode",type:"string"},{name:"channel",type:"number",optional:!0}],async e=>{const t=Po(),{mode:n,channel:r}=e.options,o=X0(e,n);o&&t.resumeChannel(o,r??0)}),nje=new Re("pause",[{name:"mode",type:"string"},{name:"channel",type:"number",optional:!0}],async e=>{const t=Po(),{mode:n,channel:r}=e.options,o=X0(e,n);o&&t.pauseChannel(o,r??0)}),rje=new Re("stop",[{name:"mode",type:"string"},{name:"channel",type:"number",optional:!0}],async e=>{const t=Po(),{mode:n,channel:r}=e.options,o=X0(e,n);o&&t.stopChannel(o,r??0)});function X0(e,t){return oje(t)?t:(xt(e,`${t} is not a valid audio mode.`),!1)}function oje(e){return!!G9.includes(e)}const ije=new Re("set",[{name:"key",type:"string"},{name:"value",type:"any"}],async e=>{const t=dd();Uz(t,`$${e.options.key}`,e.options.value)}),aje=new Re("add",[{name:"key",type:"string"},{name:"value",type:"any"}],async e=>{const t=dd();Hz(t,`$${e.options.key}`,e.options.value)}),sje=new Re("set_screen",[{name:"screen",type:"string"},{name:"layer",type:"number",optional:!0},{name:"transitionName",type:"string",optional:!0},{name:"transitionDuration",type:"number",optional:!0},{name:"transitionDelay",type:"number",optional:!0}],async e=>{const t=da();if(!ud(e.options.screen)){xt(e,`Screen ${e.options.screen} doesn't exist in the config`);return}return e.options.transitionName?t.transitionScreen(e.options.screen,{transition:e.options.transitionName,duration:e.options.transitionDuration,delay:e.options.transitionDelay},e.options.layer):t.setScreen(e.options.screen,e.options.layer??0)}),cje=new Re("empty_layer",[{name:"layer",type:"number"},{name:"transitionName",type:"string",optional:!0},{name:"transitionDuration",type:"number",optional:!0},{name:"transitionDelay",type:"number",optional:!0}],async e=>{const t=da();return e.options.transitionName?t.emptyLayer(e.options.layer,{transition:e.options.transitionName,duration:e.options.transitionDuration,delay:e.options.transitionDelay}):t.emptyLayer(e.options.layer)}),lje=new Re("set_button",[{name:"buttonId",type:"string"},{name:"state",type:"any"}],async e=>{const{buttonId:t,state:n}=e.options,r=da();if(!vl(t)){xt(e,`Button ${t} doesn't exist in the config`);return}r.changeButton(t,n)}),uje=Re.FromOptions({keyword:"talk",argTypes:[{name:"speaker",type:"string"},{name:"pose",type:"string"},{name:"text",type:"string"}],runner:async(e,t)=>{await _x({speaker:e.options.speaker,pose:e.options.pose,cssClass:"talk-command",text:`"${e.options.text}"`,choices:t,interactive:!0})},returnAfterPlayerAnswer:!0}),fje=Re.FromOptions({keyword:"think",argTypes:[{name:"speaker",type:"string"},{name:"pose",type:"string"},{name:"text",type:"string"}],runner:async(e,t)=>{await _x({speaker:e.options.speaker,pose:e.options.pose,cssClass:"think-command",text:`${e.options.text}`,choices:t,interactive:!0})},returnAfterPlayerAnswer:!0}),dje=()=>{const e=ld("text",[]);return(t,n)=>{const r=e(t,n);return n.command.staticOptions={text:n.code.substring(1,n.code.length-1)},r}},hje=Re.FromOptions({keyword:"text",argTypes:[],runner:async(e,t)=>{await _x({speaker:fo().gameCharacter,cssClass:"text-command",text:e.staticOptions.text,choices:t,interactive:!0})},parser:dje(),returnAfterPlayerAnswer:!0}),pje=new Re("add_item",[{name:"id",type:"string"},{name:"amount",type:"number"}],async e=>{const{id:t,amount:n}=e.options;Io().add({id:t,amount:n})}),mje=new Re("remove_item",[{name:"id",type:"string"},{name:"amount",type:"number"}],async e=>{const{id:t,amount:n}=e.options;Io().remove({id:t,amount:n})}),vje=new Re("has_item?",[{name:"id",type:"string"},{name:"amount",type:"number",optional:!0}],async e=>{const{id:t,amount:n}=e.options;return Io().hasItem(t,n)}),gje=new Re("item_amount?",[{name:"id",type:"string"}],async e=>{const{id:t}=e.options;return Io().getItemAmount(t)}),yje=new Re("enable_interaction",[{name:"tag",type:"string"}],async e=>{const t=e.options.tag;Io().enableInteraction(t)}),bje=new Re("disable_interaction",[{name:"tag",type:"string"}],async e=>{const t=e.options.tag;Io().disableInteraction(t)}),wje=new Re("start_quest",[{name:"questId",type:"string"}],async e=>{const t=e.options.questId;ko().startQuest(t)}),kje=new Re("start_objective",[{name:"questId",type:"string"},{name:"objectiveId",type:"string"}],async e=>{const{questId:t,objectiveId:n}=e.options;ko().startObjective(t,n)}),xje=new Re("complete_objective",[{name:"questId",type:"string"},{name:"objectiveId",type:"string"}],async e=>{const{questId:t,objectiveId:n}=e.options;ko().completeObjective(t,n)}),_je=new Re("complete_quest",[{name:"questId",type:"string"},{name:"ending",type:"any",optional:!0}],async e=>{const{questId:t,ending:n}=e.options;ko().completeQuest(t,n)}),Sje=new Re("quest_completed?",[{name:"questId",type:"string"}],async e=>{const{questId:t}=e.options;return ko().isQuestCompleted(t)}),jje=new Re("quest_succeeded?",[{name:"questId",type:"string"}],async e=>{const{questId:t}=e.options;return ko().isQuestSucceeded(t)}),Cje=new Re("quest_failed?",[{name:"questId",type:"string"}],async e=>{const{questId:t}=e.options;return ko().isQuestFailed(t)}),$je=new Re("quest_ending?",[{name:"questId",type:"string"}],async e=>{const{questId:t}=e.options;return ko().getQuestEnding(t)}),Tje=new Re("quest_has_ending?",[{name:"questId",type:"string"},{name:"ending",type:"string"}],async e=>{const{questId:t,ending:n}=e.options;return ko().questHasEnding(t,n)}),Oje=new Re("objective_completed?",[{name:"questId",type:"string"},{name:"objectiveId",type:"string"}],async e=>{const{questId:t,objectiveId:n}=e.options;return ko().isObjectiveCompleted(t,n)}),Eje=new Re("quest_started?",[{name:"questId",type:"string"}],async e=>{const{questId:t}=e.options;return ko().isQuestStarted(t)}),Aje=new Re("objective_started?",[{name:"questId",type:"string"},{name:"objectiveId",type:"string"}],async e=>{const{questId:t,objectiveId:n}=e.options;return ko().isObjectiveStarted(t,n)}),Pje=Re.FromOptions({keyword:"wait",argTypes:[{name:"duration",type:"number"}],runner:async e=>{await ki(e.options.duration)}}),Mje=new Re("notify",[{name:"text",type:"string"},{name:"description",type:"string",optional:!0},{name:"icon",type:"string",optional:!0}],async e=>{const{text:t,icon:n,description:r}=e.options;Jo().addNotification(t,r,n)}),Ije=new Re("disable_notifications",[],async e=>{Jo().disableNotifications()}),Nje=new Re("enable_notifications",[],async e=>{Jo().enableNotifications()}),Rje=new Re("clear_dialog",[],async e=>{cr().clearDialog()}),Dje=new Re("if",[{name:"condition",type:"boolean"}],async e=>{const t=[];for(const o of e.staticOptions.elseifs){const i=o.condition,a=await y0(i);t.push(a)}const n=Nge(e,t),r=un();if(n){const o={branchData:{branch:n},currentIndex:0};return r.addAndRunBlock(o)}},(e,t)=>{let n=e.currentLine;ld("if",[{name:"condition",type:"string"}])(e,t);const{lines:o,currentLine:i,line:a}=e,s=t.command;let c,l=i,f=!1;const u=[];for(;!f;){l++;const d=Rge(o,l);if(d&&d.code.startsWith("elseif")){const h=d.expression;if(!Array.isArray(h)){e.parserContext.error(d.line,"Expected an expression after elseif"),f=!0;break}if(h.length>2){e.parserContext.error(d.line,"Expected only one argument after elseif"),f=!0;break}u.push({branch:e.processCommandsFunction(e.parserContext,d.branch,a),condition:n_(e.parserContext,d,h[1])})}else d&&d.code==="else:"?c=e.processCommandsFunction(e.parserContext,d.branch,a):(f=!0,l--)}return s.staticOptions={success:e.processCommandsFunction(e.parserContext,a.branch,a),elseifs:u,failure:c},l++,n=l,{newLine:n}}),Lje=new Re("==","any",async e=>{e.args.length<1&&xt(e,"requires at least 1 arguments");let t=e.args[0],n=!0;for(const r of e.args)if(r!=t){n=!1;break}else t=r;return n}),Bje=new Re(">",[{name:"a",type:"any"},{name:"b",type:"any"}],async e=>{const{a:t,b:n}=e.options;return t>n}),Fje=new Re("<",[{name:"a",type:"any"},{name:"b",type:"any"}],async e=>{const{a:t,b:n}=e.options;return t<n}),Vje=new Re(">=",[{name:"a",type:"any"},{name:"b",type:"any"}],async e=>{const{a:t,b:n}=e.options;return t>=n}),zje=new Re("<=",[{name:"a",type:"any"},{name:"b",type:"any"}],async e=>{const{a:t,b:n}=e.options;return t<=n}),qje=new Re("!=",[{name:"a",type:"any"},{name:"b",type:"any"}],async e=>{const{a:t,b:n}=e.options;return t!=n}),Uje=new Re("!",[{name:"a",type:"any"}],async e=>{const{a:t}=e.options;return!t}),Hje=new Re("&&","any",async e=>{const t=e.args;return e.args.length<2&&xt(e,"requires at least two arguments"),t.reduce((n,r)=>n&&r,!0)}),Wje=new Re("||","any",async e=>(e.args.length<2&&xt(e,"requires at least two arguments"),e.args.reduce((t,n)=>t||n,!1))),Kje=new Re("?",[{name:"a",type:"any"},{name:"b",type:"any"},{name:"c",type:"any"}],async e=>{const{a:t,b:n,c:r}=e.options;return t?n:r}),Gje=new Re("+","any",async e=>(e.args.length<2&&xt(e,"requires at least two arguments"),e.args.reduce((t,n)=>typeof n=="number"?t+n:(xt(e,"requires all arguments to be numbers"),t),0))),Jje=new Re("-","any",async e=>(e.args.length<2&&xt(e,"requires at least two arguments"),e.args.slice(1).reduce((t,n)=>typeof n=="number"?t-n:(xt(e,"requires all arguments to be numbers"),t),e.args[0]))),Qje=new Re("neg",[{name:"a",type:"number"}],async e=>(e.args.length!==1&&xt(e,"requires one argument"),-e.options.a)),Yje=new Re("abs",[{name:"a",type:"number"}],async e=>(e.args.length!==1&&xt(e,"requires one argument"),Math.abs(e.options.a))),Xje=new Re("*","any",async e=>(e.args.length<2&&xt(e,"requires at least two arguments"),e.args.reduce((t,n)=>typeof n=="number"?t*n:(xt(e,"requires all arguments to be numbers"),t),1))),Zje=new Re("/","any",async e=>{e.args.length<2&&xt(e,"requires at least two arguments");const t=e.args[0]/e.args[1];return e.args.slice(2).reduce((n,r)=>typeof r=="number"?n/r:(xt(e,"requires all arguments to be numbers"),n),t)}),eCe=async e=>{const{prompt:t,choices:n}=e.staticOptions,r=[];for(const[,a]of n.entries()){const s=await y0(a.prompt);r.push(s)}e.options.choiceResults=r;const o=r.map((a,s)=>{var d;let c=!0;a.skillCheck&&(c=((d=a.skillCheck)==null?void 0:d.allowed)??!1);const l=yS().hasSeenChoice(t.code,n[s].prompt.code);return{flag:a.flag,seenBefore:l,choice:a.text,originalIndex:s,allowed:c}}).filter(a=>a.choice),i=await MV(t,o);return await oCe(e,i)};function tCe(e,t){t.branch||e.parserContext.error(t.line,`Choice option doesn't have any branch to go to (${t.code} - ${t.line})`);let n,r;const o=t.branch;return t.expression[1]==="roll"||t.expression[2]==="roll"?((!o[0].branch||!o[1].branch)&&e.parserContext.error(t.line,`Choice option with a skill roll needs success and failure branches (${t.code} - ${t.line})`),n={success:e.processCommandsFunction(e.parserContext,o[0].branch,t),failure:e.processCommandsFunction(e.parserContext,o[1].branch,t)}):r=e.processCommandsFunction(e.parserContext,o,t),{prompt:e.processCommandsFunction(e.parserContext,[t],t)[0],branch:r,skillBranches:n}}const nCe=(e,t)=>{let n=e.currentLine;ld("choice",[]);const{line:r}=e,o=t.command;(!r.branch||r.branch.length<2)&&e.parserContext.error(r.line,"Choice menu needs to have at least one option");const i=r.branch[0];i||e.parserContext.error(e.line.line,"Choice prompt is missing ");const s=r.branch.slice(1).map((c,l)=>(c.branch||e.parserContext.error(c.line,`Choice option doesn't have any branch to go to (${c.code})`),c=iCe(e.parserContext,c),tCe(e,c)));return o.staticOptions={prompt:e.processCommandsFunction(e.parserContext,[i],r)[0],choices:s},n++,{newLine:n}},rCe=Re.FromOptions({keyword:"choice",argTypes:[],runner:eCe,parser:nCe}),oCe=async(e,t)=>{const n=t,r=un(),{choices:o}=e.staticOptions,i=o[n],a=e.options.choiceResults[n],s=e.staticOptions.prompt;yS().trackChoice(s.code,i.prompt.code);let c=a.text,l;if(a.skillCheck?(c=null,nF(a.skillCheck.options).succeeded?l=i.skillBranches.success:l=i.skillBranches.failure):l=i.branch,c){const f={speaker:fo().playerCharacter,text:c,interactive:!1};cr().addDialog(f)}if(l){const f={currentIndex:0,branchData:{branch:l}};return await r.addAndRunBlock(f)}};function iCe(e,t){return{code:`choicePrompt ${t.code}`,indentation:t.indentation,line:t.line,branch:t.branch,expression:["choicePrompt",...t.expression]}}const aCe=new Re("choicePrompt","any",async e=>{const t=e.args;return t.length===1?sCe(t[0]):t.length===2?cCe(t):t.length>2?t[0]==="roll"||t[1]==="roll"?uCe(e,t):lCe(e,t):(xt(e,"Invalid choice prompt line"),{text:t[0]})});function sCe(e){return{text:e}}function cCe(e){return{text:e[1],flag:e[0]}}function lCe(e,t){const n=t[1]==="if"?1:2;if(t[n]!=="if")return xt(e,"Invalid choice prompt line"),{text:t[0]};const r=n===2;let o=r?t[1]:t[0],i=!0;t.length>n+1&&(i=t[n+1]),i||(o=null);const a={text:o};return r&&(a.flag=t[0]),a}function uCe(e,t){const n=t[0]==="roll"?0:1,r=n===1,o=n,i=t[o+1];let a={},s=o+2;Vz(i)?a={...Fz(i),id:i}:(a={id:i,skill:t[o+2],difficulty:t[o+3]},s=o+4);const c=t[s];s++;let l=!1,f=!1,u;t.length>s&&(t[s]==="if"?(f=!0,t.length<s+2&&xt(e,'Missing condition argument after "if" in choice with a skill check'),u=t[s+1]):(l=t[s],t.length>s+1&&(s++,t[s]==="if"?(f=!0,t.length<s+2&&xt(e,'Missing condition argument after "if" in choice with a skill check'),u=t[s+1]):xt(e,`Invalid argument after skill check mode: ${t[s]}. The next argument can only be an if condition.`)))),l==="hideAfterRoll"&&(a.hideAfterRoll=!0),l==="repeatable"&&(a.repeatable=!0);const d=Jr().getSkillCheck(i);if(d.hidden||f&&!u)return{text:null};const h=!d.happened||d.happened&&d.succeeded||a.repeatable,{difficultyText:p}=xve({skill:a.skill,skillCheckId:i,value:a.difficulty}),v={text:`${p} ${c}`,skillCheck:{allowed:h,options:a}};return r&&(v.flag=t[0]),v}const sq=Re.FromOptions({keyword:"text_field",argTypes:[{name:"prompt",type:"string"}],returnAfterPlayerAnswer:!0,runner:async e=>{const t={speaker:fo().gameCharacter,text:e.options.prompt,textField:!0,interactive:!0};cr().addDialog(t)}});sq.onPlayerAnswered=async(e,t)=>(typeof t!="string"&&xt(e,"The player's answer should be a string"),t);const fCe=Re.FromOptions({keyword:"text_field_prompt",argTypes:[{name:"prompt",type:"string"}],runner:async e=>{const t={speaker:fo().gameCharacter,text:e.options.prompt,textField:!0,interactive:!0};cr().addDialog(t)}}),dCe=new Re("random",[{name:"a",type:"number"},{name:"b",type:"number"}],async e=>{const{a:t,b:n}=e.options;return typeof t!="number"||typeof n!="number"?(xt(e,"random command needs two numbers as parameters"),0):Math.floor(Math.random()*(n-t+1))+t}),hCe=new Re("random_float",[{name:"a",type:"number"},{name:"b",type:"number"}],async e=>{const{a:t,b:n}=e.options;return typeof t!="number"||typeof n!="number"?(xt(e,"random_float command needs two numbers as parameters"),0):Math.random()*(n-t)+t}),pCe=new Re("random_from_args",[],async e=>{const t=e.args;return!t||!t.length?(xt(e,"random_from_args command needs at least one argument"),0):t[Math.floor(Math.random()*t.length)]}),mCe=new Re("random_from_array",[{name:"a",type:"any"}],async e=>{const{a:t}=e.options;return Array.isArray(t)?t[Math.floor(Math.random()*t.length)]:(xt(e,"random_from_array command needs an array as parameter"),0)}),vCe=new Re("concat","any",async e=>(e.args.length<2&&xt(e,"requires at least two arguments"),e.args.reduce((t,n)=>typeof n=="string"?`${t}${n}`:(xt(e,"requires all arguments to be strings"),t),""))),gCe=new Re("join","any",async e=>{const t=e.args[0];return e.args.length<3&&xt(e,"requires at least 3 arguments"),e.args.slice(1).reduce((n,r)=>typeof r=="string"?`${n}${t}${r}`:(xt(e,"requires all arguments to be strings"),n),"")}),yCe=Re.FromOptions({keyword:"min",argTypes:[{name:"min",type:"number"},{name:"value",type:"number"}],runner:async e=>{const{min:t,value:n}=e.options;return n<t?n:t}}),bCe=Re.FromOptions({keyword:"max",argTypes:[{name:"max",type:"number"},{name:"value",type:"number"}],runner:async e=>{const{max:t,value:n}=e.options;return n>t?n:t}}),wCe=Re.FromOptions({keyword:"clamp",argTypes:[{name:"min",type:"number"},{name:"max",type:"number"},{name:"value",type:"number"}],runner:async e=>{const{min:t,max:n,value:r}=e.options;return r<t?t:r>n?n:r}}),kCe=Re.FromOptions({keyword:"floor",argTypes:[{name:"value",type:"number"}],runner:async e=>{const{value:t}=e.options;return Math.floor(t)}}),xCe=Re.FromOptions({keyword:"ceil",argTypes:[{name:"value",type:"number"}],runner:async e=>{const{value:t}=e.options;return Math.ceil(t)}}),_Ce=Re.FromOptions({keyword:"round",argTypes:[{name:"value",type:"number"}],runner:async e=>{const{value:t}=e.options;return Math.round(t)}}),SCe=Re.FromOptions({keyword:"sqrt",argTypes:[{name:"value",type:"number"}],runner:async e=>{const{value:t}=e.options;return Math.sqrt(t)}}),jCe=Re.FromOptions({keyword:"^",argTypes:[{name:"base",type:"number"},{name:"exponent",type:"number"}],runner:async e=>{const{base:t,exponent:n}=e.options;return Math.pow(t,n)}}),CCe=new Re("create_sprite",[{name:"image",type:"string"},{name:"x",type:"number"},{name:"y",type:"number"},{name:"parent",type:"any",optional:!0}],async e=>{const t=Bi(),{x:n,y:r,image:o,parent:i}=e.options,a={x:n,y:r,image:o};return typeof i=="object"&&(a.parent=i),typeof i=="string"&&(a.parent=Bi().getObject(i)),t.createSprite(a)}),$Ce=new Re("create_object",[{name:"x",type:"number"},{name:"y",type:"number"},{name:"parent",type:"any",optional:!0}],async e=>{const t=Bi(),{x:n,y:r,parent:o}=e.options,i={x:n,y:r};return typeof o=="object"&&(i.parent=o),typeof o=="string"&&(i.parent=Bi().getObject(o)),t.createObject(i)}),TCe=new Re("delete_sprite",[{name:"sprite",type:"any"}],async e=>Bi().destroyObject(e.options.sprite)),OCe=Re.FromOptions({keyword:"empty_sprites",argTypes:[{name:"layer",type:"number",optional:!0}],runner:async e=>{const t=Bi(),{layer:n}=e.options;return typeof n=="number"?t.emptyLayer(n):t.emptyAllLayers()}}),ECe=Re.FromOptions({keyword:"shuffle",argTypes:[{name:"array",type:"any"}],runner:async e=>{const t=e.options.array;if(!Array.isArray(t)){xt(e,"requires an array argument");return}return JCe(t),t}}),ACe=Re.FromOptions({keyword:"push",argTypes:[{name:"array",type:"any"},{name:"value",type:"any"}],runner:async e=>{const{array:t,value:n}=e.options;if(!Array.isArray(t)){xt(e,"requires an array argument");return}return t.push(n),t}}),PCe=Re.FromOptions({keyword:"pop",argTypes:[{name:"array",type:"any"}],runner:async e=>{const{array:t}=e.options;if(!Array.isArray(t)){xt(e,"requires an array argument");return}return t.pop()}}),MCe=Re.FromOptions({keyword:"shift",argTypes:[{name:"array",type:"any"}],runner:async e=>{const{array:t}=e.options;if(!Array.isArray(t)){xt(e,"requires an array argument");return}return t.shift()}}),ICe=Re.FromOptions({keyword:"unshift",argTypes:[{name:"array",type:"any"},{name:"value",type:"any"}],runner:async e=>{const{array:t,value:n}=e.options;if(!Array.isArray(t)){xt(e,"requires an array argument");return}return t.unshift(n),t}}),NCe=Re.FromOptions({keyword:"array_join",argTypes:[{name:"array",type:"any"},{name:"separator",type:"string",optional:!0}],runner:async e=>{const{array:t,separator:n}=e.options;if(!Array.isArray(t)){xt(e,"requires an array argument");return}if(typeof n<"u"&&typeof n!="string"){xt(e,"array join string separator must be a string");return}return t.join(n),t}}),RCe=Re.FromOptions({keyword:"array_concat",argTypes:[{name:"array",type:"any"},{name:"rest",type:"rest",optional:!0}],runner:async e=>{const{array:t}=e.options,n=e.args;if(!Array.isArray(t)){xt(e,"requires an array argument");return}for(const r of n)if(!Array.isArray(r)){xt(e,"All concat arguments should be arrays");return}return t.concat(...n.slice(1))}}),DCe=Re.FromOptions({keyword:"includes",argTypes:[{name:"array",type:"any"},{name:"searchElement",type:"string"}],runner:async e=>{const{array:t,searchElement:n}=e.options;return Array.isArray(t)||xt(e,"requires an array argument"),typeof n>"u"&&xt(e,"requires a search element argument"),t.includes(n)}}),LCe=Re.FromOptions({keyword:"reverse",argTypes:[{name:"array",type:"any"}],runner:async e=>{const{array:t}=e.options;return Array.isArray(t)||xt(e,"requires an array argument"),t.reverse(),t}}),BCe=Re.FromOptions({keyword:"slice",argTypes:[{name:"array",type:"any"},{name:"start",type:"number"},{name:"end",type:"number",optional:!0}],runner:async e=>{const{array:t,start:n,end:r}=e.options;return Array.isArray(t)||xt(e,"requires an array argument"),typeof n!="number"&&xt(e,"requires a start index argument"),typeof r<"u"&&typeof r!="number"&&xt(e,"end index argument must be a number if present"),t.slice(n,r)}}),FCe=Re.FromOptions({keyword:"splice",argTypes:[{name:"array",type:"any"},{name:"start",type:"number"},{name:"end",type:"number",optional:!0}],runner:async e=>{const{array:t,start:n,end:r}=e.options;return Array.isArray(t)||xt(e,"requires an array argument"),typeof n!="number"&&xt(e,"requires a start index argument"),typeof r<"u"&&typeof r!="number"&&xt(e,"end index argument must be a number if present"),t.splice(n,r)}}),VCe=Re.FromOptions({keyword:"array_find_index",argTypes:[{name:"array",type:"any"},{name:"predicateLabel",type:"string"},{name:"rest",type:"rest",optional:!0}],runner:async e=>{const{array:t,predicateLabel:n}=e.options;Array.isArray(t)||xt(e,"requires an array argument");for(const[r,o]of t.entries())if(await un().runLabelFunction(n,o,r,t,...e.args.slice(2))===!0)return r;return-1}}),zCe=Re.FromOptions({keyword:"array_find",argTypes:[{name:"array",type:"any"},{name:"predicateLabel",type:"string"},{name:"rest",type:"rest",optional:!0}],runner:async e=>{const{array:t,predicateLabel:n}=e.options;Array.isArray(t)||xt(e,"requires an array argument");for(const[r,o]of t.entries())if(await un().runLabelFunction(n,o,r,t,...e.args.slice(2))===!0)return o;return null}}),qCe=Re.FromOptions({keyword:"array_filter",argTypes:[{name:"array",type:"any"},{name:"predicateLabel",type:"string"},{name:"rest",type:"rest",optional:!0}],runner:async e=>{const{array:t,predicateLabel:n}=e.options;Array.isArray(t)||xt(e,"requires an array argument");const r=[];for(const[o,i]of t.entries())await un().runLabelFunction(n,i,o,t,...e.args.slice(2))===!0&&r.push(i);return r}}),UCe=Re.FromOptions({keyword:"array_map",argTypes:[{name:"array",type:"any"},{name:"mapperLabel",type:"string"},{name:"rest",type:"rest",optional:!0}],runner:async e=>{const{array:t,mapperLabel:n}=e.options;Array.isArray(t)||xt(e,"requires an array argument");const r=[];for(const[o,i]of t.entries()){const a=await un().runLabelFunction(n,i,o,t,...e.args.slice(2));r.push(a)}return r}}),HCe=Re.FromOptions({keyword:"array_reduce",argTypes:[{name:"array",type:"any"},{name:"reducerLabel",type:"string"},{name:"initValue",type:"any"},{name:"rest",type:"rest",optional:!0}],runner:async e=>{const{array:t,reducerLabel:n,initValue:r}=e.options;Array.isArray(t)||xt(e,"requires an array argument");let o=r;for(const[i,a]of t.entries())o=await un().runLabelFunction(n,o,a,i,t,...e.args.slice(3));return o}}),WCe=Re.FromOptions({keyword:"array_some",argTypes:[{name:"array",type:"any"},{name:"predicateLabel",type:"string"},{name:"rest",type:"rest",optional:!0}],runner:async e=>{const{array:t,predicateLabel:n}=e.options;Array.isArray(t)||xt(e,"requires an array argument");for(const[r,o]of t.entries())if(await un().runLabelFunction(n,o,r,t,...e.args.slice(2))===!0)return!0;return!1}}),KCe=Re.FromOptions({keyword:"array_every",argTypes:[{name:"array",type:"any"},{name:"predicateLabel",type:"string"},{name:"rest",type:"rest",optional:!0}],runner:async e=>{const{array:t,predicateLabel:n}=e.options;Array.isArray(t)||xt(e,"requires an array argument");for(const[r,o]of t.entries())if(await un().runLabelFunction(n,o,r,t,...e.args.slice(2))!==!0)return!1;return!0}}),GCe=Re.FromOptions({keyword:"array_entries",argTypes:[{name:"array",type:"any"}],runner:async e=>{const{array:t}=e.options;return Array.isArray(t)||xt(e,"requires an array argument"),t.entries()}});function JCe(e){for(let t=e.length-1;t>0;t--){const n=Math.floor(Math.random()*(t+1));[e[t],e[n]]=[e[n],e[t]]}}const pd={keyframes:{"narrat-screenshake":[{transform:"translateX(0)"},{transform:"translateX(5px)"},{transform:"translateX(-5px)"},{transform:"translateX(5px)"},{transform:"translateX(0)"}]},animations:{"narrat-screenshake":{keyframes:"narrat-screenshake",options:{duration:150,iterations:3}}}};function QCe(e){return typeof e=="string"?document.querySelector(e):e}function YCe(e){if(typeof e=="string"){const t=Lz();t.keyframes[e]?e=t.keyframes[e]:pd.keyframes[e]?e=pd.keyframes[e]:(St(`[Animation] Animation not found: ${e}`),e=pd.keyframes["narrat-screenshake"])}return e}function XCe(e){let t;if(typeof e=="string"){const n=Lz();n.animations[e]?t=n.animations[e]:pd.animations[e]?t=pd.animations[e]:(St(`[Animation] Animation not found: ${e}`),t=pd.animations["narrat-screenshake"])}else t=e;return ZCe(t)}function ZCe(e){return{keyframes:[...YCe(e.keyframes)],options:{...e.options}}}async function cq(e,t,n){return new Promise(r=>{const o=QCe(e);o||(St(`[Animation] Element not found: ${e}`),r({}));const i=XCe(t);n&&Object.assign(i.options,n),o.animate(i.keyframes,i.options).addEventListener("finish",r)})}const e$e=Re.FromOptions({keyword:"load_data",argTypes:[{name:"url",type:"string"}],runner:async e=>{const{url:t}=e.options;return await up(K0(t))}}),t$e=Re.FromOptions({keyword:"change_player_character",argTypes:[{name:"character",type:"string"}],runner:async e=>{const{character:t}=e.options;fo().config.characters.config.playerCharacter=t}}),n$e=Re.FromOptions({keyword:"change_game_character",argTypes:[{name:"character",type:"string"}],runner:async e=>{const{character:t}=e.options;fo().config.characters.config.gameCharacter=t}}),r$e=Re.FromOptions({keyword:"json_stringify",argTypes:[{name:"value",type:"any"}],runner:async e=>{const{value:t}=e.options;return JSON.stringify(t)}}),o$e=Re.FromOptions({keyword:"json_parse",argTypes:[{name:"value",type:"string"}],runner:async e=>{const{value:t}=e.options;return JSON.parse(t)}}),i$e=Re.FromOptions({keyword:"set_dialog_panel_mode",argTypes:[{name:"mode",type:"string"}],runner:async e=>{const{mode:t}=e.options;Gr().dialogPanelMode=t}}),lq=[{name:"element",type:"string"},{name:"animation",type:"string"},{name:"duration",optional:!0,type:"number"},{name:"iterations",optional:!0,type:"number"}];function uq(e){const{element:t,animation:n,duration:r,iterations:o}=e.options,i={};return o&&(i.iterations=o),r&&(i.duration=r),i}const a$e=Re.FromOptions({keyword:"animate",argTypes:lq,runner:async e=>{const{element:t,animation:n}=e.options,r=uq(e);cq(t,n,r)}}),s$e=Re.FromOptions({keyword:"animate_wait",argTypes:lq,runner:async e=>{const{element:t,animation:n}=e.options;await cq(t,n,uq(e))}}),c$e=Re.FromOptions({keyword:"time_now",argTypes:[],runner:async e=>Date.now()}),l$e=Re.FromOptions({keyword:"total_playtime",argTypes:[],runner:async e=>sn().totalPlayTime}),u$e=Re.FromOptions({keyword:"session_playtime",argTypes:[],runner:async e=>sn().sessionPlayTime}),f$e=Re.FromOptions({keyword:"to_days",argTypes:[{name:"time",type:"number"}],runner:async e=>Math.floor(e.options.time/864e5)}),d$e=Re.FromOptions({keyword:"to_hours",argTypes:[{name:"time",type:"number"}],runner:async e=>Math.floor(e.options.time/36e5)}),h$e=Re.FromOptions({keyword:"to_minutes",argTypes:[{name:"time",type:"number"}],runner:async e=>Math.floor(e.options.time/6e4)}),p$e=Re.FromOptions({keyword:"to_seconds",argTypes:[{name:"time",type:"number"}],runner:async e=>Math.floor(e.options.time/1e3)}),m$e=new Re("unlock_achievement",[{name:"id",type:"string"}],async e=>{const{id:t}=e.options;xu().unlock(t)}),v$e=new Re("has_achievement?",[{name:"id",type:"string"}],async e=>{const{id:t}=e.options;return xu().hasAchievement(t)}),g$e=Re.FromOptions({keyword:"get_setting",argTypes:[{name:"setting",type:"string"}],runner:async e=>{const{setting:t}=e.options;return t||xt(e,"get_setting command needs a setting id"),Es().getSetting(t)}}),y$e=Re.FromOptions({keyword:"set_setting",argTypes:[{name:"setting",type:"string"},{name:"value",type:"any"}],runner:async e=>{const{setting:t,value:n}=e.options;t||xt(e,"set_setting command needs a setting id"),Es().setSetting(t,n)}}),b$e=Re.FromOptions({keyword:"object_entries",argTypes:[{name:"obj",type:"any"}],runner:async e=>{const t=e.options.obj;return typeof t!="object"?(xt(e,"Requires an object argument."),[]):Object.entries(t)}}),w$e=Re.FromOptions({keyword:"object_keys",argTypes:[{name:"obj",type:"any"}],runner:async e=>{const t=e.options.obj;return typeof t!="object"?(xt(e,"Requires an object argument."),[]):Object.keys(t)}}),k$e=Re.FromOptions({keyword:"object_values",argTypes:[{name:"obj",type:"any"}],runner:async e=>{const t=e.options.obj;return typeof t!="object"?(xt(e,"Requires an object argument."),[]):Object.values(t)}}),x$e=Re.FromOptions({keyword:"object_has",argTypes:[{name:"obj",type:"any"},{name:"key",type:"string"}],runner:async e=>{const{obj:t,key:n}=e.options;return typeof t!="object"?(xt(e,"Requires an object argument."),!1):Object.hasOwn(t,n)}}),_$e=Re.FromOptions({keyword:"for_of",argTypes:[{name:"target",type:"any"},{name:"predicateLabel",type:"string"},{name:"rest",type:"rest",optional:!0}],runner:async e=>{const{target:t,predicateLabel:n}=e.options;if(typeof t!="object")return xt(e,"Requires an object argument."),!1;for(const r of t)await un().runLabelFunction(n,r,...e.args.slice(2))}}),S$e=Re.FromOptions({keyword:"for_in",argTypes:[{name:"target",type:"any"},{name:"predicateLabel",type:"string"},{name:"rest",type:"rest",optional:!0}],runner:async e=>{const{target:t,predicateLabel:n}=e.options;if(typeof t!="object")return xt(e,"Requires an object argument."),!1;for(const r in t)await un().runLabelFunction(n,r,t[r],...e.args.slice(2))}}),j$e=Re.FromOptions({keyword:"change_scene",argTypes:[{name:"scene",type:"string"},{name:"rest",type:"rest",optional:!0}],runner:async e=>{const{scene:t}=e.options;await _i().changeScene(t,C$e(e.args.slice(1)))}});function C$e(e){const t={};let n=0;for(;n<e.length&&!(n+1>=e.length);){const r=e[n],o=e[n+1];t[r]=o,n+=2}return t}function $$e(e){e.addCommand(rCe),e.addCommand(aCe),e.addCommand(Dje),e.addCommand(LSe),e.addCommand(BSe),e.addCommand(FSe),e.addCommand(VSe),e.addCommand(zSe),e.addCommand(Rje),e.addCommand(Mje),e.addCommand(Ije),e.addCommand(Nje),e.addCommand(nje),e.addCommand(eje),e.addCommand(tje),e.addCommand(rje),e.addCommand(lje),e.addCommand(sje),e.addCommand(cje),e.addCommand(CCe),e.addCommand($Ce),e.addCommand(TCe),e.addCommand(OCe),e.addCommand(Pje),e.addCommand(Lje),e.addCommand(Bje),e.addCommand(Fje),e.addCommand(Vje),e.addCommand(zje),e.addCommand(qje),e.addCommand(Uje),e.addCommand(Hje),e.addCommand(Wje),e.addCommand(Kje),e.addCommand(Gje),e.addCommand(Jje),e.addCommand(Xje),e.addCommand(Zje),e.addCommand(Qje),e.addCommand(Yje),e.addCommand(aje),e.addCommand(ije),e.addCommand(hje),e.addCommand(uje),e.addCommand(fje),e.addCommand(qSe),e.addCommand(USe),e.addCommand(HSe),e.addCommand(WSe),e.addCommand(KSe),e.addCommand(GSe),e.addCommand(JSe),e.addCommand(YSe),e.addCommand(QSe),e.addCommand(XSe),e.addCommand(wje),e.addCommand(kje),e.addCommand(xje),e.addCommand(_je),e.addCommand(Eje),e.addCommand(Aje),e.addCommand(Sje),e.addCommand(jje),e.addCommand(Cje),e.addCommand($je),e.addCommand(Tje),e.addCommand(Oje),e.addCommand(pje),e.addCommand(mje),e.addCommand(yje),e.addCommand(bje),e.addCommand(vje),e.addCommand(gje),e.addCommand(OSe),e.addCommand(ESe),e.addCommand(ASe),e.addCommand(ISe),e.addCommand(DSe),e.addCommand(NSe),e.addCommand(RSe),e.addCommand(PSe),e.addCommand(MSe),e.addCommand(sq),e.addCommand(fCe),e.addCommand(dCe),e.addCommand(hCe),e.addCommand(pCe),e.addCommand(mCe),e.addCommand(vCe),e.addCommand(gCe),e.addCommand(yCe),e.addCommand(bCe),e.addCommand(wCe),e.addCommand(kCe),e.addCommand(_Ce),e.addCommand(xCe),e.addCommand(SCe),e.addCommand(jCe),e.addCommand(ECe),e.addCommand(ACe),e.addCommand(PCe),e.addCommand(MCe),e.addCommand(ICe),e.addCommand(NCe),e.addCommand(RCe),e.addCommand(DCe),e.addCommand(LCe),e.addCommand(BCe),e.addCommand(FCe),e.addCommand(VCe),e.addCommand(zCe),e.addCommand(qCe),e.addCommand(UCe),e.addCommand(HCe),e.addCommand(WCe),e.addCommand(KCe),e.addCommand(GCe),e.addCommand(w$e),e.addCommand(k$e),e.addCommand(b$e),e.addCommand(x$e),e.addCommand(_$e),e.addCommand(S$e),e.addCommand(e$e),e.addCommand(t$e),e.addCommand(n$e),e.addCommand(r$e),e.addCommand(o$e),e.addCommand(i$e),e.addCommand(a$e),e.addCommand(s$e),e.addCommand(c$e),e.addCommand(l$e),e.addCommand(u$e),e.addCommand(f$e),e.addCommand(d$e),e.addCommand(h$e),e.addCommand(p$e),e.addCommand(m$e),e.addCommand(v$e),e.addCommand(y$e),e.addCommand(g$e),e.addCommand(Wxe),e.addCommand(j$e)}const T$e=b.defineComponent({data(){return{muted:!1,volumes:[],modeNames:{master:"Master volume:",music:"Music:",ambiant:"Ambiant:",sound:"Sound effects:"}}},mounted(){const e=Po(),t=Ts.Howler.volume();this.volumes.push({mode:"master",volume:t}),e.modes.forEach((n,r)=>{this.volumes.push({mode:r,volume:e.modes.get(r).options.volume})})},methods:{changeVolume(e,t){const n=t.target;e==="master"?Po().setMasterVolume(n.value):Po().setModeVolume(e,n.value)},toggleMute(){this.muted?(Ts.Howler.mute(!1),this.muted=!1):(Ts.Howler.mute(!0),this.muted=!0)}}}),O$e={class:"volume-controls"},E$e=b.createElementVNode("h3",{class:"subtitle"},"Volume",-1),A$e={for:"volume",class:"volume-label"},P$e=["onUpdate:modelValue","onChange"];function M$e(e,t,n,r,o,i){return b.openBlock(),b.createElementBlock("div",O$e,[E$e,(b.openBlock(!0),b.createElementBlock(b.Fragment,null,b.renderList(e.volumes,(a,s)=>(b.openBlock(),b.createElementBlock("div",{class:"volume-control",key:a.mode},[b.createElementVNode("label",A$e,b.toDisplayString(e.modeNames[a.mode]),1),b.withDirectives(b.createElementVNode("input",{ref_for:!0,ref:"slider",class:"volume-slider",type:"range",id:"volume",name:"volume",min:"0",max:"1",step:"0.1","onUpdate:modelValue":c=>e.volumes[s].volume=c,onChange:c=>e.changeVolume(a.mode,c)},null,40,P$e),[[b.vModelText,e.volumes[s].volume]])]))),128))])}const I$e=Xa(T$e,[["render",M$e]]),N$e={class:"settings-widget-container"},R$e=["for","id"],D$e=["id","name","min","max","step"],L$e=["id","name"],B$e=["id","name"],F$e={class:"mx-8"},V$e={class:"text-left setting-description"},z$e=b.createElementVNode("hr",{class:"h-px my-8 bg-gray-200 border-0 dark:bg-gray-700 setting-separator"},null,-1),q$e=b.defineComponent({__name:"setting-widget",props:{settingId:{}},setup(e){const t=e,n=Es(),r=b.computed(()=>n.getSetting(t.settingId)),o=b.ref(r.value),i=b.computed(()=>n.getSettingSchema(t.settingId));function a(s){let c=s;rB(i.value)&&(c=Math.round(c)),n.setSetting(t.settingId,c)}return b.watch(o,s=>{a(s)}),(s,c)=>(b.openBlock(),b.createElementBlock(b.Fragment,null,[b.createElementVNode("div",N$e,[b.createElementVNode("label",{for:s.settingId,class:"setting-label",id:`setting-label-${s.settingId}`},b.toDisplayString(i.value.name),9,R$e),b.unref(Fve)(i.value)||b.unref(rB)(i.value)?b.withDirectives((b.openBlock(),b.createElementBlock("input",{key:0,ref:"slider",class:"number-slider setting-slider",type:"range",id:`setting-slider-${s.settingId}`,name:s.settingId,min:i.value.minValue,max:i.value.maxValue,step:i.value.step,"onUpdate:modelValue":c[0]||(c[0]=l=>o.value=l)},null,8,D$e)),[[b.vModelText,o.value]]):b.unref(Vve)(i.value)?b.withDirectives((b.openBlock(),b.createElementBlock("input",{key:1,type:"checkbox",class:"setting-checkbox",id:`setting-checkbox-${s.settingId}`,name:s.settingId,"onUpdate:modelValue":c[1]||(c[1]=l=>o.value=l)},null,8,L$e)),[[b.vModelCheckbox,o.value]]):b.unref(zve)(i.value)?b.withDirectives((b.openBlock(),b.createElementBlock("input",{key:2,type:"text",class:"setting-text",id:`setting-text-${s.settingId}`,name:s.settingId,"onUpdate:modelValue":c[2]||(c[2]=l=>o.value=l)},null,8,B$e)),[[b.vModelText,o.value]]):b.createCommentVNode("",!0),b.createElementVNode("span",F$e,b.toDisplayString(o.value),1)]),b.createElementVNode("p",V$e,b.toDisplayString(i.value.description),1),z$e],64))}}),U$e={class:"container mx-auto settings-menu-container"},H$e=b.createElementVNode("h2",{class:"settings-menu-title subtitle text-center"},"Settings",-1),W$e=b.defineComponent({__name:"settings-menu",setup(e){const t=Es(),n=b.computed(()=>t.getAllSettingSchemas());return(r,o)=>(b.openBlock(),b.createElementBlock("div",U$e,[H$e,(b.openBlock(!0),b.createElementBlock(b.Fragment,null,b.renderList(n.value,(i,a)=>(b.openBlock(),b.createBlock(q$e,{settingId:a,key:a},null,8,["settingId"]))),128))]))}}),K$e={class:"menu-content"},G$e=b.defineComponent({__name:"MainMenu",props:{inputListener:{}},emits:["close"],setup(e,{emit:t}){const n=e,r=t,o=b.ref(null),i=b.ref(null);function a(){window.close()}function s(){mV(),c()}function c(){r("close")}function l(){const f=Su(sn().playTime.start,sn().playTime.previousPlaytime);return ty(f/1e3)}return b.onMounted(()=>{i.value=dc({mode:"list",container:o,listener:n.inputListener,onChosen:f=>{f===0?s():f===1&&a()}}),i.value.mount()}),b.onUnmounted(()=>{i.value&&(i.value.disable(),i.value=null)}),(f,u)=>(b.openBlock(),b.createElementBlock("div",K$e,[b.createElementVNode("h3",null,"Play time: "+b.toDisplayString(l()),1),b.createVNode(I$e),b.createElementVNode("div",{ref_key:"mainActions",ref:o},[b.createElementVNode("button",{class:"button title quit-button",onClick:s}," Main Menu "),b.createElementVNode("button",{class:"button title quit-button",onClick:a},"Exit")],512),b.createVNode(W$e)]))}}),J$e={class:"sub-tabs-controller"},Q$e={key:0,class:"sub-tabs-controller__tabs"},Y$e={key:1,class:"sub-tab-content"},X$e={key:2},Z$e=[b.createElementVNode("div",{class:"sub-tab-content__empty"},[b.createElementVNode("p",null,"No tab selected")],-1)],eTe=b.defineComponent({__name:"SubTabController",props:{tabs:{},defaultTab:{},inputListener:{}},emits:["tab-change","close"],setup(e,{emit:t}){const n=t,r=e,o=b.ref(r.defaultTab);function i(s){o.value=s,n("tab-change",s)}const a=b.computed(()=>r.tabs[o.value]);return b.onMounted(()=>{r.inputListener.actions.subPreviousTab={press:()=>{o.value>0&&i(o.value-1)}},r.inputListener.actions.subNextTab={press:()=>{o.value<r.tabs.length-1&&i(o.value+1)}}}),b.onUnmounted(()=>{delete r.inputListener.actions.subPreviousTab,delete r.inputListener.actions.subNextTab}),(s,c)=>(b.openBlock(),b.createElementBlock("div",J$e,[s.tabs.length>1?(b.openBlock(),b.createElementBlock("div",Q$e,[(b.openBlock(!0),b.createElementBlock(b.Fragment,null,b.renderList(s.tabs,(l,f)=>(b.openBlock(),b.createBlock(wV,{key:l.id,tab:l,active:f===o.value,onClick:()=>i(f)},null,8,["tab","active","onClick"]))),128))])):b.createCommentVNode("",!0),a.value?(b.openBlock(),b.createElementBlock("div",Y$e,[a.value?(b.openBlock(),b.createBlock(b.resolveDynamicComponent(a.value.component),b.mergeProps({key:a.value.id,inputListener:s.inputListener},a.value.extraProps,{onClose:c[0]||(c[0]=l=>s.$emit("close"))}),null,16,["inputListener"])):b.createCommentVNode("",!0)])):(b.openBlock(),b.createElementBlock("div",X$e,Z$e))]))}}),tTe=["onClick"],nTe={class:"item-title"},rTe={class:"item-amount"},oTe=b.defineComponent({__name:"inventory-section",props:{items:{},title:{},id:{},inputListener:{}},emits:["chosen"],setup(e,{emit:t}){const n=e,r=b.ref(null),o=b.ref(null),i=t;function a(l){i("chosen",l)}function s(l){return{backgroundImage:`url(${ci(Ja(l).icon)})`}}function c(l){return Ja(l).name}return b.onMounted(()=>{o.value=dc({mode:"grid",listener:n.inputListener,columns:3,container:r,onChosen:l=>{a(n.items[l].id)}}),o.value.mount()}),b.onUnmounted(()=>{o.value&&(o.value.disable(),o.value=null)}),(l,f)=>(b.openBlock(),b.createElementBlock("div",{class:b.normalizeClass(["inventory-section",`section-${n.id}`])},[b.createElementVNode("h3",null,b.toDisplayString(l.title),1),b.createElementVNode("div",{class:"inventory-section-items",ref_key:"itemsContainer",ref:r},[(b.openBlock(!0),b.createElementBlock(b.Fragment,null,b.renderList(l.items,u=>(b.openBlock(),b.createElementBlock("button",{onClick:()=>a(u.id),class:b.normalizeClass(["item-display",`item-${u.id}`]),style:b.normalizeStyle(s(u.id)),key:u.id},[b.createElementVNode("h3",nTe,b.toDisplayString(c(u.id)),1),b.createElementVNode("h3",rTe,b.toDisplayString(u.amount),1)],14,tTe))),128))],512)],2))}}),iTe={class:"flex flex-row item-description-container"},aTe={class:"flex item-left"},sTe={class:"flex item-right"},cTe=b.createElementVNode("hr",{class:"hr-solid"},null,-1),lTe=b.defineComponent({__name:"item-details",props:{item:{}},emits:["use","close"],setup(e,{emit:t}){const n=e,r=b.ref(null),o=b.computed(()=>Ja(n.item.id)),i=b.computed(()=>({backgroundImage:`url(${ci(o.value.icon)})`})),a=t,s=b.computed(()=>Io().canUseItem(n.item));function c(){s.value&&a("use")}function l(){a("close")}return b.onMounted(()=>{r.value=xr().registerInputListener("item-details",{continue:{press:()=>{s.value&&c()}},cancel:{press:()=>{l()}}})}),b.onUnmounted(()=>{r.value&&(xr().unregisterInputListener(r.value),r.value=null)}),(f,u)=>(b.openBlock(),b.createElementBlock("div",null,[b.createElementVNode("div",iTe,[b.createElementVNode("div",aTe,[b.createElementVNode("div",{class:"item-display",style:b.normalizeStyle(i.value)},null,4)]),b.createElementVNode("div",sTe,[b.createElementVNode("h2",null,b.toDisplayString(o.value.name),1),cTe,b.createElementVNode("h3",null,"Amount: "+b.toDisplayString(f.item.amount),1),b.createElementVNode("p",null,b.toDisplayString(o.value.description),1),b.createElementVNode("button",{onClick:c,class:b.normalizeClass(["button",s.value?"":"disabled"])}," Use ",2)])]),b.createElementVNode("button",{class:"button",onClick:l},b.toDisplayString("<--"))]))}}),uTe={key:0},fTe={key:2},dTe=[b.createElementVNode("h2",null,"The inventory is empty!",-1)],hTe=b.defineComponent({__name:"inventory-ui",props:{section:{},inputListener:{}},emits:["close"],setup(e,{emit:t}){const n=Io(),r=b.computed(()=>n.items),o=b.ref(!1),i=b.computed(()=>o.value?r.value[o.value]:null);function a(){No().closeMenu()}function s(f){o.value=f}function c(){o.value=!1}function l(){n.useItem(i.value),a()}return(f,u)=>!i.value&&f.section.items.length>0?(b.openBlock(),b.createElementBlock("div",uTe,[b.createVNode(oTe,{items:f.section.items,title:f.section.title,inputListener:f.inputListener,id:f.section.id,onChosen:s},null,8,["items","title","inputListener","id"])])):typeof o.value=="string"?(b.openBlock(),b.createBlock(lTe,{key:1,item:r.value[o.value],onUse:l,onClose:c},null,8,["item"])):(b.openBlock(),b.createElementBlock("div",fTe,dTe))}}),pTe=b.defineComponent({__name:"InventoryTab",props:{inputListener:{}},setup(e){const t=Io(),n=b.computed(()=>t.items),r=b.computed(()=>Object.values(n.value).filter(a=>a.amount>0?!0:!!Ja(a.id).showIfEmpty)),o=b.computed(()=>{const a=pr().items.categories,s=[];if(a.length>1){const c={id:"all",title:"All",items:r.value};s.push(c)}for(const c in a){const l=a[c],f=l.id,u=r.value.filter(d=>Ja(d.id).category===f);s.push({id:f,title:l.title,items:u})}return s}),i=b.computed(()=>{const a=[];return o.value.forEach(s=>{a.push({id:s.id,label:s.title,component:hTe,extraProps:{section:s}})}),a});return(a,s)=>(b.openBlock(),b.createElementBlock("div",null,[b.createVNode(eTe,{tabs:i.value,defaultTab:0,inputListener:a.inputListener},null,8,["tabs","inputListener"])]))}}),mTe=["id"],vTe={class:"obtained-status"},gTe={class:"achievement-title"},yTe={class:"achievement-description"},bTe=b.defineComponent({__name:"achievement-tile",props:{achievement:{}},setup(e){const t=e,n=xu(),r=b.computed(()=>n.getExistingAchievement(t.achievement)),o=b.computed(()=>cS(t.achievement)),i=Op().secretAchievements??{censorName:!0,censorDescription:!0},a=b.computed(()=>{let f=r.value.unlocked?o.value.icon:o.value.lockedIcon;return f||(f=Op().defaultAchievementIcon),{backgroundImage:`url(${ci(f)})`}}),s=b.computed(()=>!o.value.secret||!i.censorName?o.value.name:"Hidden Achievement"),c=b.computed(()=>!o.value.secret||!i.censorDescription?o.value.description:"This achievement is hidden. Complete it to discover more."),l=b.computed(()=>r.value.unlocked?`Obtained ${new Date(r.value.unlockTime).toLocaleDateString()}`:"Not obtained yet");return(f,u)=>(b.openBlock(),b.createElementBlock("div",{class:"achievement-display tile",id:`achievement-${f.achievement}`},[b.createElementVNode("div",{class:"achievement-icon",style:b.normalizeStyle(a.value)},null,4),b.createElementVNode("p",vTe,b.toDisplayString(l.value),1),b.createElementVNode("h3",gTe,b.toDisplayString(s.value),1),b.createElementVNode("p",yTe,b.toDisplayString(c.value),1)],8,mTe))}}),wTe={class:"achievements-section-achievements"},kTe=b.defineComponent({__name:"achievements-section",props:{achievements:{},title:{},id:{}},setup(e){const t=e;return(n,r)=>(b.openBlock(),b.createElementBlock("div",{class:b.normalizeClass(["achievements-section",`section-${t.id}`])},[b.createElementVNode("h3",null,b.toDisplayString(n.title),1),b.createElementVNode("div",wTe,[(b.openBlock(!0),b.createElementBlock(b.Fragment,null,b.renderList(n.achievements,o=>(b.openBlock(),b.createBlock(bTe,{achievement:o.id,key:o.id},null,8,["achievement"]))),128))])],2))}}),xTe=b.defineComponent({setup(){const e=xu(),t=cr(),n=b.computed(()=>e.achievements),r=b.computed(()=>t.currentDialog.choices);return{achievements:n,currentlyChoosing:r}},emits:["close"],data(){return{chosenId:!1}},mounted(){},methods:{close(){this.$emit("close")},clickAchievement(e){this.chosenId=e},closeAchievement(){this.chosenId=!1}},computed:{achievementsToDisplay(){return Object.values(this.achievements)},chosenAchievement(){return this.chosenId?this.achievements[this.chosenId]:null},chosenAchievementConf(){return this.chosenId?this.achievementConf[this.chosenId]:null},achievementConf(){return pr().achievements.achievements},sections(){const e=pr().achievements.categories,t=[];return this.achievementsToDisplay.reduce((r,o)=>{const i=cS(o.id).category??"default",a=e.find(c=>c.id===i);if(!a)return St(`Unknown category ${i}`),r;let s=r.find(c=>c.id===i);return s||(s={id:i,title:a.title,achievements:[]},r.push(s)),s.achievements.push(o),r},t)}},components:{AchievementsSection:kTe}}),_Te={key:0},STe={key:1},jTe=[b.createElementVNode("h2",null,"The achievements section is empty!",-1)];function CTe(e,t,n,r,o,i){const a=b.resolveComponent("AchievementsSection");return Object.keys(e.achievementsToDisplay).length>0?(b.openBlock(),b.createElementBlock("div",_Te,[(b.openBlock(!0),b.createElementBlock(b.Fragment,null,b.renderList(e.sections,s=>(b.openBlock(),b.createBlock(a,{key:s.id,achievements:s.achievements,title:s.title,id:s.id,onChosen:e.clickAchievement},null,8,["achievements","title","id","onChosen"]))),128))])):(b.openBlock(),b.createElementBlock("div",STe,jTe))}const $Te=Xa(xTe,[["render",CTe]]),TTe={class:"quest-display"},OTe={class:"quest-title"},ETe={class:"quest-description"},ATe={key:0,class:"quest-objectives-container list-disc"},PTe=b.defineComponent({__name:"QuestDetails",props:{quest:{}},setup(e){const t=e,n=b.computed(()=>vc(t.quest.id));function r(s){return Ep(t.quest.id,s)}const o=b.computed(()=>{switch(t.quest.state){case"hidden":return" Hidden";case"unlocked":return"";case"completed":return" (Completed)";default:return" Unknown"}}),i=b.computed(()=>t.quest.ending?zz(t.quest.id,t.quest.ending).description:t.quest.succeeded&&n.value.succeededDescription?n.value.succeededDescription:!t.quest.succeeded&&n.value.failedDescription?n.value.failedDescription:n.value.description),a=b.computed(()=>Object.values(t.quest.objectives).filter(s=>s.state!=="hidden"));return(s,c)=>(b.openBlock(),b.createElementBlock("div",TTe,[b.createElementVNode("div",{class:b.normalizeClass(["quest-header",s.quest.state==="completed"?"quest-completed":"quest-in-progress"])},[b.createElementVNode("h3",OTe,b.toDisplayString(n.value.title)+" "+b.toDisplayString(o.value),1)],2),b.createElementVNode("p",ETe,b.toDisplayString(i.value),1),s.quest.state!=="completed"?(b.openBlock(),b.createElementBlock("ul",ATe,[(b.openBlock(!0),b.createElementBlock(b.Fragment,null,b.renderList(a.value,l=>(b.openBlock(),b.createElementBlock("li",{class:"quest-objective-display",key:l.id},[b.createElementVNode("p",{class:b.normalizeClass(["quest-objective-description",l.state==="completed"?"quest-objective-completed":"quest-objctive-in-progress"])},b.toDisplayString(r(l.id).description),3)]))),128))])):b.createCommentVNode("",!0)]))}}),MTe={class:"quest-list-title"},ITe=b.defineComponent({__name:"QuestDisplay",props:{quest:{}},setup(e){const t=e,n=b.computed(()=>vc(t.quest.id));return(r,o)=>(b.openBlock(),b.createElementBlock("div",{class:b.normalizeClass(["quest-list-display",r.quest.state==="completed"?"quest-list-completed":"quest-list-in-progress"])},[b.createElementVNode("p",MTe,b.toDisplayString(n.value.title),1)],2))}}),NTe={key:0},RTe={key:0},DTe={key:1},LTe=b.defineComponent({__name:"quests-list-section",props:{quests:{},sectionId:{},title:{},fallbackText:{}},emits:["quest-selected"],setup(e,{emit:t}){const n=e,r=b.computed(()=>Tp().categories),o=b.computed(()=>{const i=[];return n.quests.reduce((s,c)=>{const l=vc(c.id).category??"default",f=r.value.find(d=>d.id===l);if(!f)return St(`Quest category ${l} not found in config`),s;let u=s.find(d=>d.category.id===l);return u||(u={category:f,quests:[]},s.push(u)),u.quests.push(c),s},i)});return(i,a)=>(b.openBlock(),b.createElementBlock("div",{class:b.normalizeClass([`${i.sectionId}-quests-container`,"quests-section"])},[b.createElementVNode("h3",null,b.toDisplayString(i.title),1),i.quests.length>0?(b.openBlock(),b.createElementBlock("div",NTe,[(b.openBlock(!0),b.createElementBlock(b.Fragment,null,b.renderList(o.value,s=>(b.openBlock(),b.createElementBlock("div",{class:b.normalizeClass([`${i.sectionId}-${s.category.id}-category`,"quests-category"]),key:s.category.id},[r.value.length>1?(b.openBlock(),b.createElementBlock("h4",RTe,b.toDisplayString(s.category.title),1)):b.createCommentVNode("",!0),b.createElementVNode("div",{class:b.normalizeClass(`${i.sectionId}-${s.category.id}-quests`)},[(b.openBlock(!0),b.createElementBlock(b.Fragment,null,b.renderList(s.quests,c=>(b.openBlock(),b.createBlock(ITe,{key:c.id,quest:c,onClick:l=>i.$emit("quest-selected",c)},null,8,["quest","onClick"]))),128))],2)],2))),128))])):(b.openBlock(),b.createElementBlock("div",DTe,[b.createElementVNode("p",null,b.toDisplayString(i.fallbackText),1)]))],2))}}),BTe=b.defineComponent({setup(){const e=ko(),t=b.computed(()=>e.quests),n=b.ref(null);return{quests:t,selectedQuest:n}},computed:{questsToDisplay(){return Object.values(this.quests).filter(e=>e.state!=="hidden")},activeQuests(){return this.questsToDisplay.filter(e=>e.state==="unlocked")},completedQuests(){return this.questsToDisplay.filter(e=>e.state==="completed")},questsUiClass(){return Gr().layoutMode==="horizontal"?"quests-ui-horizontal":"quests-ui-vertical"}},mounted(){this.activeQuests.length>0?this.selectedQuest=this.activeQuests[0]:this.completedQuests.length>0&&(this.selectedQuest=this.completedQuests[0])},methods:{clickOnQuest(e){this.selectedQuest=e}},components:{QuestDetails:PTe,QuestsListSection:LTe}}),FTe={class:"quests-list-container"},VTe={class:"quest-details"};function zTe(e,t,n,r,o,i){const a=b.resolveComponent("QuestsListSection"),s=b.resolveComponent("QuestDetails");return b.openBlock(),b.createElementBlock("div",{class:b.normalizeClass(["quests-ui",e.questsUiClass])},[b.createElementVNode("div",FTe,[b.createVNode(a,{quests:e.activeQuests,sectionId:"active",title:"Active Quests",fallbackText:"No active quests",onQuestSelected:e.clickOnQuest},null,8,["quests","onQuestSelected"]),b.createVNode(a,{quests:e.completedQuests,sectionId:"completed",title:"Completed Quests",fallbackText:"No completed quests",onQuestSelected:e.clickOnQuest},null,8,["quests","onQuestSelected"])]),b.createElementVNode("div",VTe,[e.selectedQuest?(b.openBlock(),b.createBlock(s,{key:0,quest:e.selectedQuest},null,8,["quest"])):b.createCommentVNode("",!0)])],2)}const qTe=Xa(BTe,[["render",zTe]]);function fq(e){const t=Jr(),n=b.computed(()=>t.skills),r=b.computed(()=>n.value[e]),o=b.computed(()=>Ns().skills),i=b.computed(()=>Ns().skillOptions.xpPerLevel),a=b.computed(()=>({backgroundImage:`url(${ci(o.value[e].icon)})`})),s=b.computed(()=>o.value[e].name),c=b.computed(()=>o.value[e].description),l=b.computed(()=>`Level ${n.value[e].level}`);return{skills:n,skillsStore:t,skillConfig:o,xpPerLevel:i,skillState:r,skillStyle:a,skillName:s,skillDescription:c,skillLevelText:l}}const UTe=e=>(b.pushScopeId("data-v-db9d98bf"),e=e(),b.popScopeId(),e),HTe=["id"],WTe={class:"flex flex-row skill-description-container"},KTe={class:"flex skill-left"},GTe={class:"flex skill-right"},JTe=UTe(()=>b.createElementVNode("hr",{class:"hr-solid"},null,-1)),QTe=["innerHTML"],YTe=Xa(b.defineComponent({__name:"SkillDetails",props:{chosenSkill:{},inputListener:{}},emits:["cancel"],setup(e,{emit:t}){const n=e,r=t,o=b.ref(null),i=b.ref(null);function a(){r("cancel")}const{skillStyle:s,skillName:c,skillDescription:l,skillLevelText:f}=fq(n.chosenSkill);return b.onMounted(()=>{o.value=dc({mode:"list",listener:n.inputListener,container:i,onChosen:()=>{a()}}),o.value.mount()}),b.onUnmounted(()=>{o.value&&(o.value.disable(),o.value=null)}),(u,d)=>(b.openBlock(),b.createElementBlock("div",{id:`skill-display-${u.chosenSkill}`},[b.createElementVNode("div",WTe,[b.createElementVNode("div",KTe,[b.createElementVNode("div",{class:"skill-display",style:b.normalizeStyle(b.unref(s))},null,4)]),b.createElementVNode("div",GTe,[b.createElementVNode("h2",null,b.toDisplayString(b.unref(c)),1),JTe,b.createElementVNode("h3",null,b.toDisplayString(b.unref(f)),1),b.createElementVNode("p",{innerHTML:b.unref(l)},null,8,QTe)])]),b.createElementVNode("div",{ref_key:"buttonsContainer",ref:i},[b.createElementVNode("button",{class:"button",onClick:a},b.toDisplayString("<--"))],512)],8,HTe))}}),[["__scopeId","data-v-db9d98bf"]]),XTe={class:"skill-title"},ZTe={class:"skill-xp-container"},eOe={class:"skill-xp-text"},tOe={class:"skill-level"},nOe=Xa(b.defineComponent({__name:"SkillGridElement",props:{chosenSkill:{},inputListener:{}},emits:["choose"],setup(e,{expose:t,emit:n}){const r=e,o=b.ref(null);t({gridElement:o});const i=n;function a(){i("choose")}const{skillStyle:s,skillName:c,skillState:l,xpPerLevel:f}=fq(r.chosenSkill),u=b.computed(()=>({width:`${Math.floor(l.value.xp/f.value*100)}%`}));return(d,h)=>(b.openBlock(),b.createElementBlock("button",{onClick:a,class:"skill-grid-element",style:b.normalizeStyle(b.unref(s)),ref_key:"gridElement",ref:o},[b.createElementVNode("h3",XTe,b.toDisplayString(b.unref(c)),1),b.createElementVNode("div",ZTe,[b.createElementVNode("div",{class:"skill-xp-bar",style:b.normalizeStyle(u.value)},null,4),b.createElementVNode("h3",eOe,b.toDisplayString(b.unref(l).xp)+" / "+b.toDisplayString(b.unref(f))+" XP",1)]),b.createElementVNode("h3",tOe,b.toDisplayString(b.unref(l).level),1)],4))}}),[["__scopeId","data-v-8d457bf9"]]),rOe={class:"skills-container"},oOe=Xa(b.defineComponent({__name:"SkillsGrid",props:{inputListener:{},lastChosenSkill:{type:[String,Boolean]}},emits:["choose"],setup(e,{emit:t}){const n=e,r=b.ref([]),o=b.computed(()=>r.value.map(d=>d.gridElement)),i=Jr(),a=b.computed(()=>i.skills),s=b.ref(null),c=t;function l(d){c("choose",d)}const f=b.computed(()=>Ns().skills),u=b.computed(()=>{const d={};for(const h in a.value)f.value[h].hidden&&a.value[h].level<1||(d[h]=a.value[h]);return Object.values(d)});return b.onMounted(()=>{var d;if(s.value=dc({mode:"grid",listener:n.inputListener,elements:o,columns:3,onChosen:h=>{l(u.value[h].id)}}),(d=s.value)==null||d.mount(),typeof n.lastChosenSkill=="string"){const h=u.value.findIndex(p=>p.id===n.lastChosenSkill);h>=0&&s.value.select(h)}}),b.onUnmounted(()=>{s.value&&s.value.disable()}),(d,h)=>(b.openBlock(),b.createElementBlock("div",rOe,[(b.openBlock(!0),b.createElementBlock(b.Fragment,null,b.renderList(u.value,p=>(b.openBlock(),b.createBlock(nOe,{ref_for:!0,ref_key:"skillGridElements",ref:r,key:p.id,onChoose:()=>l(p.id),chosenSkill:p.id,inputListener:d.inputListener},null,8,["onChoose","chosenSkill","inputListener"]))),128))]))}}),[["__scopeId","data-v-31202bb8"]]),iOe=b.defineComponent({__name:"SkillsWindow",props:{inputListener:{}},setup(e){const t=b.ref(!1),n=b.ref(!1);function r(i){n.value=i,t.value=i}function o(){t.value=!1}return(i,a)=>t.value?typeof t.value=="string"?(b.openBlock(),b.createBlock(YTe,{key:1,chosenSkill:t.value,inputListener:i.inputListener,onCancel:o},null,8,["chosenSkill","inputListener"])):b.createCommentVNode("",!0):(b.openBlock(),b.createBlock(oOe,{key:0,inputListener:i.inputListener,lastChosenSkill:n.value,onChoose:r},null,8,["inputListener","lastChosenSkill"]))}});function aOe(e){e.component("MainMenu",G$e),e.component("InventoryTab",pTe),e.component("AchievementsUI",$Te),e.component("QuestsUi",qTe),e.component("SkillsWindow",iOe),No().menus={system:{label:"System",cssClass:"system-menu",id:"system",tabs:[{id:"system-tab",cssId:"system-tab",text:"System",component:"MainMenu"}],activeTab:0},menu:{label:"Menu",id:"menu",cssClass:"menu-menu",tabs:[{id:"skills",cssId:"skills-menu-button",text:"Skills",condition:()=>No().showSkills,component:"SkillsWindow"},{id:"inventory",cssId:"inventory-menu-button",text:"Items",condition:()=>No().showInventory,component:"InventoryTab"},{id:"quests",cssId:"quests-menu-button",text:"Quests",condition:()=>No().showQuests,component:"QuestsUi"},{id:"achievements",cssId:"achievements-menu-button",text:"Achievements",condition:()=>No().showAchievements,component:"AchievementsUI"}],activeTab:0}}}function kS(e,t,n){const r=window.narrat.app;for(const o in t.tabs){const i=t.tabs[o].component;r.component(i,n[i])}No().addMenu(e,t)}function sOe(e,t,n){window.narrat.app.component(t.component,n),No().addMenuOption(e,t)}function cOe(){for(const e of yn.plugins){if(e.customMenuButtons)for(const t of e.customMenuButtons)kS(t.config.id,t.config,t.components);if(e.customMenuTabs)for(const t of e.customMenuTabs)sOe(t.config.id,t.config,t.component)}}function lOe(e){e.directive("visible",{mounted(t,n){n.value?t.style.visibility="visible":t.style.visibility="hidden"},updated(t,n){n.value?t.style.visibility="visible":t.style.visibility="hidden"}})}class Z0{constructor(){Wn(this,"pluginId","narrat-plugin")}onPageLoaded(){}onNarratSetup(){}onAppMounted(){}onAssetsLoaded(){}onGameSetup(){}onGameStart(){}onGameMounted(){}onGameDismounted(){}}function dq(e){yn.addPlugin(e)}function hq(e){yn.addCommand(e)}const uOe={args:[],canvasResizePolicy:0,executable:"",experimentalVK:!1,fileSizes:{"index.pck":54160,"index.wasm":52315256},focusCanvas:!1,gdextensionLibs:[]};function fOe(){window.godotReady=!0,window.narratReadyCallback&&window.narratReadyCallback(),console.log("godot ready")}window.godotReadyCallback=fOe;class pq extends Z0{constructor(n){super();Wn(this,"customCommands",[]);Wn(this,"canvas");Wn(this,"app");Wn(this,"messageQueue",[]);Wn(this,"narrat");Wn(this,"narratReady",!1);Wn(this,"engineConfig");Wn(this,"engine");const r={...uOe,...n.engineConfigOverrides??{}};n.godotGamePath&&(r.executable=n.godotGamePath),this.engineConfig=r,this.customCommands=[Re.FromOptions({keyword:"godot_pause",argTypes:[],runner:async o=>{this.addMessageForGodot({type:"pause",payload:{}})}}),Re.FromOptions({keyword:"godot_resume",argTypes:[],runner:async o=>{this.addMessageForGodot({type:"resume",payload:{}})}})]}onAppMounted(){const n=document.querySelector("#narrat-app-container");if(!n){console.error("no app");return}this.narrat=window.narrat;const r=document.createElement("canvas");this.app=n,this.canvas=r,r.id="godot-canvas",r.style.position="absolute",r.style.zIndex="0",n.appendChild(r),window.addEventListener("keydown",i=>{if(i.fakeEvent)return;const a=new KeyboardEvent(i.type,i);a.fakeEvent=!0,this.canvas.dispatchEvent(a)}),window.addEventListener("keyup",i=>{if(i.fakeEvent)return;const a=new KeyboardEvent(i.type,i);a.fakeEvent=!0,this.canvas.dispatchEvent(a)}),new window.Engine(this.engineConfig).startGame(),this.resizeCanvas(),window.godot=this,this.narratReady=!0,window.narratReadyCallback&&window.narratReadyCallback()}getCanvas(){return document.querySelector("#godot-canvas")}addMessageForGodot(n){this.messageQueue.unshift(n),window.godotCallback&&window.godotCallback(n)}grabNextMessage(){return this.messageQueue.pop()}async run(n,...r){const o=await this.narrat.run(n,...r),i={type:"run_end",payload:{label:n,args:r,result:o}};this.addMessageForGodot(i)}isJson(n){try{JSON.parse(n)}catch{return!1}return!0}resizeCanvas(){const n=Gr(),r=n.gameWidth,o=n.gameHeight;this.canvas.width=r,this.canvas.height=o,this.canvas.style.width=`${r}px`,this.canvas.style.height=`${o}px`,window.requestAnimationFrame(()=>this.resizeCanvas())}}class mq extends Z0{constructor(n={}){super();Wn(this,"defaultTheme");Wn(this,"themes",[]);Wn(this,"activeTheme");Wn(this,"customCommands");Wn(this,"initialConfig");n.defaultTheme&&(this.defaultTheme=n.defaultTheme),n.themes&&(this.themes=n.themes),this.customCommands=[this.createChangeThemeCommand()]}onNarratSetup(){if(this.defaultTheme){const n=this.themes.find(r=>r.id===this.defaultTheme);if(!n){St(`Theme ${this.defaultTheme} not found`);return}this.setTheme(n)}}addTheme(n){this.themes.push(n)}createChangeThemeCommand(){return Re.FromOptions({keyword:"change_theme",argTypes:[{name:"theme",type:"string"}],runner:async r=>{this.changeTheme(r.options.theme)}})}changeTheme(n){if(n==="default"){this.removeCurrentTheme();return}const r=this.findTheme(n);this.setTheme(r)}findTheme(n){const r=this.themes.find(o=>o.id===n);return r||St(`Theme ${n} not found`),r}setTheme(n){this.activeTheme&&this.removeCurrentTheme(),this.activeTheme={themeTag:this.createThemeTag(n),id:n.id},document.head.appendChild(this.activeTheme.themeTag),n.extendedConfig&&(this.initialConfig=fu({},fo().config),fo().extendConfig(n.extendedConfig))}createThemeTag(n){if(this.isInlineTheme(n)){const r=document.createElement("style");return r.innerHTML=n.css,r}else{const r=document.createElement("link");return r.rel="stylesheet",r.href=n.cssPath,r.id=n.id,r}}isInlineTheme(n){return n.css!==void 0}isExternalTheme(n){return n.cssPath!==void 0}removeCurrentTheme(){this.activeTheme&&(this.activeTheme.themeTag&&this.activeTheme.themeTag.remove(),this.findTheme(this.activeTheme.id).extendedConfig&&(fo().config=this.initialConfig)),this.activeTheme=void 0}}const vq={css:"body{font-size:52px}",id:"narrat-fun-theme",extendedConfig:{}},gq={id:"narrat-text-only",css:"#narrat-app{--bg-color: #131720;--text-color: #d9e1f2;--primary: hsl(255, 30%, 55%);--focus: hsl(210, 90%, 50%);--secondary: #42b983;--dialog-box-bg: transparent;--dialog-box-border: none}.interact-button{background:unset;border:none;font-size:2rem;font-weight:700;color:#fff;font-family:monospace;text-shadow:-4px 4px 2px #000}.dialog{box-shadow:none!important;text-align:center}.dialog-text{font-size:1.5rem;font-family:monospace;text-shadow:-4px 4px 2px #000}",extendedConfig:{common:{dialogPanel:{textSpeed:30,animateText:!0,timeBetweenLines:100,overlayMode:!0,rightOffset:300,bottomOffset:150,width:700,height:680}}}},dOe=Object.freeze(Object.defineProperty({__proto__:null,BaseConfigInputSchema:b0,CommandPlugin:Re,ConfigInputSchema:a_,ConfigInputSchemaWithCommon:o_,ConfigInputSchemaWithoutCommon:i_,EngineSplash:Lx,GameDialog:Kx,GameSplash:Vx,GodotPlugin:pq,Hud:Yx,InGame:Xx,InputsListener:qx,LogManager:Ap,MenuButtons:Gx,ModalWindow:Bs,NarratPlugin:Z0,NarratThemesPlugin:mq,Screens:Qx,StartMenu:Hx,get Vec2(){return Qe.Vec2},addCommand:hq,aspectRatioFit:Fx,audioConfig:Fi,buttonsConfig:q0,charactersConfig:U0,constructNarratObject:xS,debounce:dp,error:St,findVariable:px,funTheme:vq,gameloop:fp,generateObjectFromList:mx,generateParser:ld,getAssetUrl:ci,getButtonConfig:vl,getConfig:Ct,getDataUrl:K0,getFile:h0,getImageUrl:fd,getItemConfig:Ja,getObjectiveConfig:Ep,getQuestConfig:vc,getScreenConfig:ud,getSkillConfig:W0,getSplitConfigUrl:sS,getWindow:n0,handleHMR:oS,inputEvents:ha,isConfigInputWithCommon:w0,isModuleValid:rS,isNarratScript:iS,isNarratYaml:B0,isPromise:vx,itemsConfig:V0,loadDataFile:up,logManager:Pp,logger:qi,processText:$s,questsConfig:Tp,randomId:su,registerMenuButton:kS,registerPlugin:dq,screensConfig:z0,skillsConfig:Ns,textOnlyTheme:gq,timeout:ki,tooltipsConfig:ml,useAchievements:xu,useAudio:Po,useConfig:fo,useDialogStore:cr,useHud:Si,useInputs:xr,useInventory:Io,useMain:sn,useMenu:No,useNotifications:Jo,useQuests:ko,useRenderingStore:Gr,useScenes:_i,useScreenObjects:Bi,useScreens:da,useSkills:Jr,useTooltips:Wf,useVM:un,warning:hu},Symbol.toStringTag,{value:"Module"}));function xS(e){const t={app:e,vm:yn,handleHMR:oS,jump:n=>un().jumpToLabel(n),run:(n,...r)=>un().runThenGoBackToPreviousDialog(n,...r),getSave:()=>lc(),exports:dOe};return window.narrat=t,t}var hOe=Object.prototype.toString,yq=function(t){if(t===void 0)return"undefined";if(t===null)return"null";var n=typeof t;if(n==="boolean")return"boolean";if(n==="string")return"string";if(n==="number")return"number";if(n==="symbol")return"symbol";if(n==="function")return yOe(t)?"generatorfunction":"function";if(pOe(t))return"array";if(kOe(t))return"buffer";if(wOe(t))return"arguments";if(vOe(t))return"date";if(mOe(t))return"error";if(gOe(t))return"regexp";switch(bq(t)){case"Symbol":return"symbol";case"Promise":return"promise";case"WeakMap":return"weakmap";case"WeakSet":return"weakset";case"Map":return"map";case"Set":return"set";case"Int8Array":return"int8array";case"Uint8Array":return"uint8array";case"Uint8ClampedArray":return"uint8clampedarray";case"Int16Array":return"int16array";case"Uint16Array":return"uint16array";case"Int32Array":return"int32array";case"Uint32Array":return"uint32array";case"Float32Array":return"float32array";case"Float64Array":return"float64array"}if(bOe(t))return"generator";switch(n=hOe.call(t),n){case"[object Object]":return"object";case"[object Map Iterator]":return"mapiterator";case"[object Set Iterator]":return"setiterator";case"[object String Iterator]":return"stringiterator";case"[object Array Iterator]":return"arrayiterator"}return n.slice(8,-1).toLowerCase().replace(/\s/g,"")};function bq(e){return typeof e.constructor=="function"?e.constructor.name:null}function pOe(e){return Array.isArray?Array.isArray(e):e instanceof Array}function mOe(e){return e instanceof Error||typeof e.message=="string"&&e.constructor&&typeof e.constructor.stackTraceLimit=="number"}function vOe(e){return e instanceof Date?!0:typeof e.toDateString=="function"&&typeof e.getDate=="function"&&typeof e.setDate=="function"}function gOe(e){return e instanceof RegExp?!0:typeof e.flags=="string"&&typeof e.ignoreCase=="boolean"&&typeof e.multiline=="boolean"&&typeof e.global=="boolean"}function yOe(e,t){return bq(e)==="GeneratorFunction"}function bOe(e){return typeof e.throw=="function"&&typeof e.return=="function"&&typeof e.next=="function"}function wOe(e){try{if(typeof e.length=="number"&&typeof e.callee=="function")return!0}catch(t){if(t.message.indexOf("callee")!==-1)return!0}return!1}function kOe(e){return e.constructor&&typeof e.constructor.isBuffer=="function"?e.constructor.isBuffer(e):!1}/*!
219
+ Error: ${t}`),console.error("============================")}function Hxe(e,...t){console.log(`[${e.fileName}:${e.line}] log: `,...t)}function Nz(e,t,n){const r=Re.FromOptions({keyword:e,argTypes:t,runner:async o=>await un().runLabelFunction(n,...o.args)});yn.addCommand(r)}const Wxe=Re.FromOptions({keyword:"create_macro",argTypes:"any",runner:async e=>{e.args.length<2&&xt(e,"create_macro command needs at least a name and a label");const t=e.args[0],n=e.args[1],o=e.args.slice(2).map(i=>({name:i,type:"any"}));Nz(t,o,n)}}),Kxe=[["items",bB,wB],["achievements",FB,VB],["screens",$B,TB],["skills",AB,PB],["skillChecks",zB,qB],["buttons",SB,jB],["scripts",mB,Xve],["audio",eB,tB],["quests",kB,xB],["tooltips",RB,DB],["characters",MB,IB],["choices",HB,WB],["animations",GB,JB],["macros",QB,YB],["preload",XB,ZB]],Gxe=[["common",vB,wx]],mc=new Vxe({allErrors:!0}),Jxe=["baseAssetsPath","baseDataPath","gameTitle","saveFileName","images","layout","settings","gameFlow","dialogPanel","splashScreens","notifications","hudStats","interactionTags","transitions","menuButtons","debugging","saves"];async function Qxe(e,t){for(const[n,r,o]of Gxe){const i=t[n];let a=Rz(o);try{if(!mc.validate(r,i))throw console.error(mc.errors),new Error(`${mc.errorsText()}`)}catch(s){console.error(s),St(`${n} config error: ${s}`)}typeof i<"u"&&(a=Rz(i,a)),e[n]=a}}function Rz(e,t){return typeof e=="object"?Array.isArray(e)?[...e]:{...t,...e}:typeof e<"u"?e:t}async function Yxe(e,t){for(const n of Jxe){const r=t[n];r&&(typeof r=="object"&&!Array.isArray(r)?e.common[n]={...e.common[n],...r}:e.common[n]=r)}}async function Xxe(e){const t={...Kf};w0(e)?await Qxe(t,e):Yxe(t,e);for(const n of Kxe){const r=n[0],o=n[1],i=n[2];let a=e[r];if(a&&typeof a=="string")try{if(a=await up(sS(t.common.baseDataPath,a)),!mc.validate(o,a))throw console.error(mc.errors),new Error(`${mc.errorsText()}`)}catch(s){console.error(s),St(`${r} config error: ${s}`),a={...i}}a&&(Array.isArray(a)?t[r]=a:typeof a=="object"?t[r]={...i,...a}:t[r]=a)}for(const n in t)Iz(t,n,t[n]);for(const n of t.macros.macros){const r=n.options??[];Nz(n.keyword,r,n.label)}return t}async function Zxe(e){let t;if(e.config){const o=e.config;t={};for(const i in o){const a=o[i];B0(a)?(fo().addConfigModule(i,{id:a.id,configKey:i,code:a.code}),t[i]=a.code):t[i]=a}}else if(e.configPath)t=await up(e.configPath);else throw St("No config file or config object provided"),new Error("No config file or config object provided");let n=t;return w0(t)&&(n=t.common),n.baseAssetsPath=e.baseAssetsPath??n.baseAssetsPath??"",n.baseDataPath=e.baseDataPath??n.baseDataPath??"",mc.validate(a_,t)||(St("Config file validation failed."),console.log(mc.errors),St(mc.errorsText())),Xxe(t)}function pr(){return fo().config}function Ct(){return pr().common}function wu(e){const t=Ct().hudStats[e];return t||St(`Hud stat ${e} doesn't exist`),t}function Fi(){return pr().audio}function Dz(e){const t=Fi().files[e];if(!t){hu(`Audio file ${e} doesn't exist`);return}return t}function F0(e){const t=Dz(e),n=((t==null?void 0:t.fadeInDelay)??Fi().options.musicFadeInDelay)*1e3,r=((t==null?void 0:t.fadeInTime)??Fi().options.musicFadeInTime)*1e3,o=((t==null?void 0:t.fadeOutTime)??Fi().options.musicFadeOutTime)*1e3;return{fadeInDelay:n,fadeInTime:r,fadeOutTime:o}}function Ns(){return pr().skills}function $p(){return pr().skillChecks}function V0(){return pr().items}function Tp(){return pr().quests}function z0(){return pr().screens}function q0(){return pr().buttons}function ml(){return pr().tooltips}function U0(){return pr().characters}function aS(){return pr().choices}function Lz(){return pr().animations}function Bz(e){return aS().choicePrompts[e]}function ud(e){return e===bx?iB:z0().screens[e]?z0().screens[e]:(St(`Screen config for screen ${e} doesn't exist`),iB)}function H0(e){const n=ml().tooltips.find(r=>r.keywords.includes(e));return n||(St(`Tooltip config for keyword ${e} not found`),null)}function W0(e){const t=pr().skills.skills[e];return t||St(`Skill config for skill ${e} doesn't exist`),t}function Fz(e){const t=pr().skillChecks.skillChecks[e];return t||St(`Skill check config for skill check ${e} doesn't exist`),t}function Vz(e){return!!pr().skillChecks.skillChecks[e]}function fd(e){return e.startsWith("http")?e:ci(e)}function ci(e){var n,r,o,i;if(e.startsWith("http"))return e;let t=e;return Ct().images[e]?t=Ct().images[e]:(n=pr().preload.images)!=null&&n.assets[e]?t=(r=pr().preload.images)==null?void 0:r.assets[e]:(o=pr().preload.video)!=null&&o.assets[e]&&(t=(i=pr().preload.video)==null?void 0:i.assets[e]),Ct().baseAssetsPath?`${Ct().baseAssetsPath}${t}`:t}function sS(e,t){return`${e}${t}`}function K0(e){return Ct().baseDataPath?`${Ct().baseDataPath}${e}`:e}function vl(e){const t=q0().buttons[e];return t||St(`Button config for button ${e} doesn't exist`),t}function Ja(e){const t=V0().items[e];return t||St(`Item config for skill ${e} doesn't exist`),t}function Op(){return pr().achievements}function cS(e){const t=Op().achievements[e];return t||St(`Achievement config for achievement ${e} doesn't exist`),t}function vc(e){return Tp().quests[e]}function zz(e,t){const r=vc(e).endings;return r||St(`Quest ${e} doesn't have any endings`),r[t]||St(`Quest ${e} has no ending called ${t}`),r[t]}function Ep(e,t){return vc(e).objectives[t]}function G0(){return Ct().dialogPanel.width??Kve}const ko=eo("quests",{state:()=>({quests:{}}),actions:{getQuest(e){const t=this.quests[e];if(t)return t;{const n=`Quest ${e} doesn't exist!`;throw St(n),new Error(n)}},getObjective(e,t){const n=this.getQuest(e);if(!n){const i=`Quest ${e} doesn't exist!`;throw St(i),new Error(i)}const r=n.objectives[t];if(r)return r;const o=`Objective ${t} doesn't exist in quest ${e}!`;throw St(o),new Error(o)},updateConfig(e){const t=e.quests;for(const n of Object.keys(t)){const r=t[n];this.quests[n]||(this.quests[n]={id:n,state:"hidden",objectives:{},extraData:{}});for(const o of Object.keys(r.objectives)){const i=r.objectives[o];this.quests[n].objectives[o]||(this.quests[n].objectives[o]={extraData:{},id:o,state:i.hidden?"hidden":"unlocked"})}}},reset(e){this.$reset(),this.updateConfig(e)},startQuest(e){const t=this.getQuest(e);t?(t.state="unlocked",Jo().addNotification(`Started quest: ${vc(e).title}`)):St(`Quest ${e} doesn't exist!`)},startObjective(e,t){const n=this.getObjective(e,t);n?(n.state="unlocked",Jo().addNotification(`New quest objective: ${Ep(e,t).description}`)):St(`Objective ${t} doesn't exist in quest ${e}!`)},completeObjective(e,t){const n=this.getObjective(e,t);n?(n.state="completed",Jo().addNotification(`Completed quest objective: ${Ep(e,t).description}`)):St(`Objective ${t} doesn't exist in quest ${e}!`)},completeQuest(e,t){const n=this.getQuest(e);if(n){if(n.state="completed",typeof t=="string"){n.ending=t;const r=zz(e,t);n.succeeded=r.success}else typeof t=="boolean"?n.succeeded=t:n.succeeded=!0;Jo().addNotification(`Completed quest: ${vc(e).title}`)}else St(`Quest ${e} doesn't exist!`)},isQuestCompleted(e){const t=this.getQuest(e);return t?t.state==="completed":!1},isQuestSucceeded(e){const t=this.getQuest(e);return t?t.state==="completed"&&t.succeeded:!1},isQuestFailed(e){const t=this.getQuest(e);return t?t.state==="completed"&&!t.succeeded:!1},getQuestEnding(e){const t=this.getQuest(e);return t?t.ending:!1},questHasEnding(e,t){return this.getQuestEnding(e)===t},isObjectiveCompleted(e,t){const n=this.getObjective(e,t);return n?n.state==="completed":!1},isQuestStarted(e){const t=this.getQuest(e);return t&&t.state==="unlocked"},isObjectiveStarted(e,t){return this.getObjective(e,t).state==="unlocked"},removeQuest(e){delete this.quests[e]},generateSaveData(){return{quests:Xn(this.quests)}},loadSaveData(e){this.quests=e.quests}}});function qz(e,t,n,r="$"){if(!n.startsWith(r))return isNaN(Number(n))?[null,n]:[null,Number(n)];n=n.substring(1);const o=/\[/,i=/\]/;let a=n.search(o);n.search(i);let s=n,c=t,l=0;for(;l<n.length;){if(a>l||a===-1){const f=a>l?a:n.length;let u=n.substring(l,f);isNaN(Number(u))||(u=Number(u)),l>0&&(c=c[s]),[c,s]=t_e(c,u)}if(a!==-1){l=a;const f=n.substring(a+1),u=e_e(f)+a,d=n.substring(a+1,u),[h,p]=qz(e,e,d);let m=p;h&&(m=h[p]),typeof m=="number"||!isNaN(Number(m))?m=Number(m):typeof m!="string"&&console.error(`invalid array index (${m}) key type when compiling: ${n}`),c=c[s],s=m,l=u+1;const v=n.substring(l);a=v.search(o),a!==-1&&(a+=l),v.search(i)}else l=n.length}return[c,s]}function e_e(e){let t=!1,n=0,r,o=1;for(;!t;){r=e.substring(n);const i=r.search(/\[/),a=r.search(/\]/);i!==-1&&i<a?(n+=i+1,o++):(n+=a+1,o--),o===0&&(t=!0),i===-1&&a===-1&&!t&&St(`Could not find closing bracket in ${e}`)}return n}function t_e(e,t){if(typeof t=="number")return[e,t];t.startsWith(".")&&(t=t.substring(1));const n=t.split(".");let r=e;const o=n.length-1;let i=n[0],a=0;for(a=0;a<o;a++)i=n[a],typeof r[i]>"u"&&(r[i]={}),r=r[i];return i=n[a],[r,i]}function J0(e,t,n="$"){return qz(e,e,t)}function n_e(e,t){return J0(e,t)}function Uz(e,t,n){const[r,o]=J0(e,t);r[o]=n}function Hz(e,t,n){const[r,o]=J0(e,t),i=r[o]||0;r[o]=n+i}function dd(){const e=un(),t=Jr(),n=da(),r=Io(),o=un().scope,i={data:e.data,global:e.globalData,skills:t.skills,skillChecks:t.skillChecks,buttons:n.buttons,items:r.items,quests:ko().quests,stats:Si().hudStats,scope:o,config:Ct(),gameOptions:sn().options,baseSettings:Es().baseSettings,customSettings:Es().customSettings};return new Proxy(i,{get:(s,c,l)=>{const f=un().scope,u=un().data;return typeof f[c]<"u"?f[c]:typeof u[c]<"u"?u[c]:Reflect.get(s,c,l)},set:(s,c,l,f)=>{const u=un().scope,d=un().data;if(typeof u[c]<"u")u[c]=l;else{if(typeof s[c]<"u")return Reflect.set(s,c,l,f);typeof l=="object"?d[c]={}:d[c]=l}return!0}})}function Xn(e){if(e===null)return null;if(typeof e=="object")if(Array.isArray(e)){const t=[];for(const n in e)t[n]=Xn(e[n]);return t}else{const t={};for(const n in e)t[n]=Xn(e[n]);return t}else return e}function lS(e,t){if(e===null)return null;if(typeof e=="object"){const n=t(e);if(t(e))return n;if(Array.isArray(e)){const r=[];for(const o in e)r[o]=lS(e[o],t);return r}else{const r={};for(const o in e)r[o]=lS(e[o],t);return r}}else return t(e)}const Jr=eo("skills",{state:()=>({skillChecks:{},skills:{}}),actions:{setupSkillCheck(e,t){this.skillChecks[t]=e},passSkillCheck(e,t){this.skillChecks[e].happened=!0,this.skillChecks[e].succeeded=!0,t&&(this.skillChecks[e].hidden=!0)},failSkillCheck(e,t){this.skillChecks[e].happened=!0,this.skillChecks[e].succeeded=!1,t&&(this.skillChecks[e].hidden=!0)},resetSkillCheck(e){this.skillChecks[e].happened=!1,this.skillChecks[e].succeeded=!1,this.skillChecks[e].hidden=!1},generateSaveData(){return{skillChecks:Xn(this.skillChecks),skills:Xn(this.skills)}},getSkillCheck(e){return this.skillChecks[e]||this.setupSkillCheck(this.createSkillCheckState(),e),this.skillChecks[e]},createSkillCheckState(){return{happened:!1,succeeded:!1,hidden:!1}},loadSaveData(e){this.skillChecks=fu(this.skillChecks,e.skillChecks),this.skills=fu(this.skills,e.skills)},updateConfig(e){const t=e.skills;for(const n in t)this.skills[n]||(this.skills[n]={id:n,level:t[n].startingLevel||0,xp:0})},reset(e){this.$reset(),this.updateConfig(e)},getSkill(e){return this.skills[e]},getSkillLevel(e){return this.getSkill(e).level},getSkillXp(e){return this.getSkill(e).xp},addXp(e,t){const n=this.getSkill(e);n||St(`Skill ${e} doesn't exist`),n.xp+=t,n.xp>=Ns().skillOptions.xpPerLevel&&(n.xp=0,n.level++,this.levelledUp(e))},setSkillLevel(e,t){const n=this.getSkill(e);n||St(`Skill ${e} doesn't exist`),n.level=t,this.levelledUp(e)},incrementSkill(e,t){this.getSkill(e).level+=t,this.levelledUp(e)},levelledUp(e){const t=Ns().skills[e].name,n=this.skills[e].level;Ns().skillOptions.notifyLevelUp&&Jo().addNotification(`Your skill in ${t} is now level ${n}`)}}});function gc(e){return Array.isArray?Array.isArray(e):Gz(e)==="[object Array]"}const r_e=1/0;function o_e(e){if(typeof e=="string")return e;let t=e+"";return t=="0"&&1/e==-r_e?"-0":t}function i_e(e){return e==null?"":o_e(e)}function Rs(e){return typeof e=="string"}function Wz(e){return typeof e=="number"}function a_e(e){return e===!0||e===!1||s_e(e)&&Gz(e)=="[object Boolean]"}function Kz(e){return typeof e=="object"}function s_e(e){return Kz(e)&&e!==null}function Vi(e){return e!=null}function uS(e){return!e.trim().length}function Gz(e){return e==null?e===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(e)}const SEe="Extended search is not available",c_e="Incorrect 'index' type",l_e=e=>`Invalid value for key ${e}`,u_e=e=>`Pattern length exceeds max of ${e}.`,f_e=e=>`Missing ${e} property in key`,d_e=e=>`Property 'weight' in key '${e}' must be a positive integer`,Jz=Object.prototype.hasOwnProperty;class h_e{constructor(t){this._keys=[],this._keyMap={};let n=0;t.forEach(r=>{let o=Qz(r);n+=o.weight,this._keys.push(o),this._keyMap[o.id]=o,n+=o.weight}),this._keys.forEach(r=>{r.weight/=n})}get(t){return this._keyMap[t]}keys(){return this._keys}toJSON(){return JSON.stringify(this._keys)}}function Qz(e){let t=null,n=null,r=null,o=1,i=null;if(Rs(e)||gc(e))r=e,t=Yz(e),n=fS(e);else{if(!Jz.call(e,"name"))throw new Error(f_e("name"));const a=e.name;if(r=a,Jz.call(e,"weight")&&(o=e.weight,o<=0))throw new Error(d_e(a));t=Yz(a),n=fS(a),i=e.getFn}return{path:t,id:n,weight:o,src:r,getFn:i}}function Yz(e){return gc(e)?e:e.split(".")}function fS(e){return gc(e)?e.join("."):e}function p_e(e,t){let n=[],r=!1;const o=(i,a,s)=>{if(Vi(i))if(!a[s])n.push(i);else{let c=a[s];const l=i[c];if(!Vi(l))return;if(s===a.length-1&&(Rs(l)||Wz(l)||a_e(l)))n.push(i_e(l));else if(gc(l)){r=!0;for(let f=0,u=l.length;f<u;f+=1)o(l[f],a,s+1)}else a.length&&o(l,a,s+1)}};return o(e,Rs(t)?t.split("."):t,0),r?n:n[0]}var mn={...{isCaseSensitive:!1,includeScore:!1,keys:[],shouldSort:!0,sortFn:(e,t)=>e.score===t.score?e.idx<t.idx?-1:1:e.score<t.score?-1:1},...{includeMatches:!1,findAllMatches:!1,minMatchCharLength:1},...{location:0,threshold:.6,distance:100},...{useExtendedSearch:!1,getFn:p_e,ignoreLocation:!1,ignoreFieldNorm:!1,fieldNormWeight:1}};const m_e=/[^ ]+/g;function v_e(e=1,t=3){const n=new Map,r=Math.pow(10,t);return{get(o){const i=o.match(m_e).length;if(n.has(i))return n.get(i);const a=1/Math.pow(i,.5*e),s=parseFloat(Math.round(a*r)/r);return n.set(i,s),s},clear(){n.clear()}}}class dS{constructor({getFn:t=mn.getFn,fieldNormWeight:n=mn.fieldNormWeight}={}){this.norm=v_e(n,3),this.getFn=t,this.isCreated=!1,this.setIndexRecords()}setSources(t=[]){this.docs=t}setIndexRecords(t=[]){this.records=t}setKeys(t=[]){this.keys=t,this._keysMap={},t.forEach((n,r)=>{this._keysMap[n.id]=r})}create(){this.isCreated||!this.docs.length||(this.isCreated=!0,Rs(this.docs[0])?this.docs.forEach((t,n)=>{this._addString(t,n)}):this.docs.forEach((t,n)=>{this._addObject(t,n)}),this.norm.clear())}add(t){const n=this.size();Rs(t)?this._addString(t,n):this._addObject(t,n)}removeAt(t){this.records.splice(t,1);for(let n=t,r=this.size();n<r;n+=1)this.records[n].i-=1}getValueForItemAtKeyId(t,n){return t[this._keysMap[n]]}size(){return this.records.length}_addString(t,n){if(!Vi(t)||uS(t))return;let r={v:t,i:n,n:this.norm.get(t)};this.records.push(r)}_addObject(t,n){let r={i:n,$:{}};this.keys.forEach((o,i)=>{let a=o.getFn?o.getFn(t):this.getFn(t,o.path);if(Vi(a)){if(gc(a)){let s=[];const c=[{nestedArrIndex:-1,value:a}];for(;c.length;){const{nestedArrIndex:l,value:f}=c.pop();if(Vi(f))if(Rs(f)&&!uS(f)){let u={v:f,i:l,n:this.norm.get(f)};s.push(u)}else gc(f)&&f.forEach((u,d)=>{c.push({nestedArrIndex:d,value:u})})}r.$[i]=s}else if(Rs(a)&&!uS(a)){let s={v:a,n:this.norm.get(a)};r.$[i]=s}}}),this.records.push(r)}toJSON(){return{keys:this.keys,records:this.records}}}function Xz(e,t,{getFn:n=mn.getFn,fieldNormWeight:r=mn.fieldNormWeight}={}){const o=new dS({getFn:n,fieldNormWeight:r});return o.setKeys(e.map(Qz)),o.setSources(t),o.create(),o}function g_e(e,{getFn:t=mn.getFn,fieldNormWeight:n=mn.fieldNormWeight}={}){const{keys:r,records:o}=e,i=new dS({getFn:t,fieldNormWeight:n});return i.setKeys(r),i.setIndexRecords(o),i}function Q0(e,{errors:t=0,currentLocation:n=0,expectedLocation:r=0,distance:o=mn.distance,ignoreLocation:i=mn.ignoreLocation}={}){const a=t/e.length;if(i)return a;const s=Math.abs(r-n);return o?a+s/o:s?1:a}function y_e(e=[],t=mn.minMatchCharLength){let n=[],r=-1,o=-1,i=0;for(let a=e.length;i<a;i+=1){let s=e[i];s&&r===-1?r=i:!s&&r!==-1&&(o=i-1,o-r+1>=t&&n.push([r,o]),r=-1)}return e[i-1]&&i-r>=t&&n.push([r,i-1]),n}const ku=32;function b_e(e,t,n,{location:r=mn.location,distance:o=mn.distance,threshold:i=mn.threshold,findAllMatches:a=mn.findAllMatches,minMatchCharLength:s=mn.minMatchCharLength,includeMatches:c=mn.includeMatches,ignoreLocation:l=mn.ignoreLocation}={}){if(t.length>ku)throw new Error(u_e(ku));const f=t.length,u=e.length,d=Math.max(0,Math.min(r,u));let h=i,p=d;const m=s>1||c,v=m?Array(u):[];let g;for(;(g=e.indexOf(t,p))>-1;){let E=Q0(t,{currentLocation:g,expectedLocation:d,distance:o,ignoreLocation:l});if(h=Math.min(E,h),p=g+f,m){let R=0;for(;R<f;)v[g+R]=1,R+=1}}p=-1;let y=[],w=1,k=f+u;const $=1<<f-1;for(let E=0;E<f;E+=1){let R=0,D=k;for(;R<D;)Q0(t,{errors:E,currentLocation:d+D,expectedLocation:d,distance:o,ignoreLocation:l})<=h?R=D:k=D,D=Math.floor((k-R)/2+R);k=D;let L=Math.max(1,d-D+1),I=a?u:Math.min(d+D,u)+f,B=Array(I+2);B[I+1]=(1<<E)-1;for(let N=I;N>=L;N-=1){let W=N-1,X=n[e.charAt(W)];if(m&&(v[W]=+!!X),B[N]=(B[N+1]<<1|1)&X,E&&(B[N]|=(y[N+1]|y[N])<<1|1|y[N+1]),B[N]&$&&(w=Q0(t,{errors:E,currentLocation:W,expectedLocation:d,distance:o,ignoreLocation:l}),w<=h)){if(h=w,p=W,p<=d)break;L=Math.max(1,2*d-p)}}if(Q0(t,{errors:E+1,currentLocation:d,expectedLocation:d,distance:o,ignoreLocation:l})>h)break;y=B}const S={isMatch:p>=0,score:Math.max(.001,w)};if(m){const E=y_e(v,s);E.length?c&&(S.indices=E):S.isMatch=!1}return S}function w_e(e){let t={};for(let n=0,r=e.length;n<r;n+=1){const o=e.charAt(n);t[o]=(t[o]||0)|1<<r-n-1}return t}class Zz{constructor(t,{location:n=mn.location,threshold:r=mn.threshold,distance:o=mn.distance,includeMatches:i=mn.includeMatches,findAllMatches:a=mn.findAllMatches,minMatchCharLength:s=mn.minMatchCharLength,isCaseSensitive:c=mn.isCaseSensitive,ignoreLocation:l=mn.ignoreLocation}={}){if(this.options={location:n,threshold:r,distance:o,includeMatches:i,findAllMatches:a,minMatchCharLength:s,isCaseSensitive:c,ignoreLocation:l},this.pattern=c?t:t.toLowerCase(),this.chunks=[],!this.pattern.length)return;const f=(d,h)=>{this.chunks.push({pattern:d,alphabet:w_e(d),startIndex:h})},u=this.pattern.length;if(u>ku){let d=0;const h=u%ku,p=u-h;for(;d<p;)f(this.pattern.substr(d,ku),d),d+=ku;if(h){const m=u-ku;f(this.pattern.substr(m),m)}}else f(this.pattern,0)}searchIn(t){const{isCaseSensitive:n,includeMatches:r}=this.options;if(n||(t=t.toLowerCase()),this.pattern===t){let p={isMatch:!0,score:0};return r&&(p.indices=[[0,t.length-1]]),p}const{location:o,distance:i,threshold:a,findAllMatches:s,minMatchCharLength:c,ignoreLocation:l}=this.options;let f=[],u=0,d=!1;this.chunks.forEach(({pattern:p,alphabet:m,startIndex:v})=>{const{isMatch:g,score:y,indices:w}=b_e(t,p,m,{location:o+v,distance:i,threshold:a,findAllMatches:s,minMatchCharLength:c,includeMatches:r,ignoreLocation:l});g&&(d=!0),u+=y,g&&w&&(f=[...f,...w])});let h={isMatch:d,score:d?u/this.chunks.length:1};return d&&r&&(h.indices=f),h}}class gl{constructor(t){this.pattern=t}static isMultiMatch(t){return eq(t,this.multiRegex)}static isSingleMatch(t){return eq(t,this.singleRegex)}search(){}}function eq(e,t){const n=e.match(t);return n?n[1]:null}class k_e extends gl{constructor(t){super(t)}static get type(){return"exact"}static get multiRegex(){return/^="(.*)"$/}static get singleRegex(){return/^=(.*)$/}search(t){const n=t===this.pattern;return{isMatch:n,score:n?0:1,indices:[0,this.pattern.length-1]}}}class x_e extends gl{constructor(t){super(t)}static get type(){return"inverse-exact"}static get multiRegex(){return/^!"(.*)"$/}static get singleRegex(){return/^!(.*)$/}search(t){const r=t.indexOf(this.pattern)===-1;return{isMatch:r,score:r?0:1,indices:[0,t.length-1]}}}class __e extends gl{constructor(t){super(t)}static get type(){return"prefix-exact"}static get multiRegex(){return/^\^"(.*)"$/}static get singleRegex(){return/^\^(.*)$/}search(t){const n=t.startsWith(this.pattern);return{isMatch:n,score:n?0:1,indices:[0,this.pattern.length-1]}}}class S_e extends gl{constructor(t){super(t)}static get type(){return"inverse-prefix-exact"}static get multiRegex(){return/^!\^"(.*)"$/}static get singleRegex(){return/^!\^(.*)$/}search(t){const n=!t.startsWith(this.pattern);return{isMatch:n,score:n?0:1,indices:[0,t.length-1]}}}class j_e extends gl{constructor(t){super(t)}static get type(){return"suffix-exact"}static get multiRegex(){return/^"(.*)"\$$/}static get singleRegex(){return/^(.*)\$$/}search(t){const n=t.endsWith(this.pattern);return{isMatch:n,score:n?0:1,indices:[t.length-this.pattern.length,t.length-1]}}}class C_e extends gl{constructor(t){super(t)}static get type(){return"inverse-suffix-exact"}static get multiRegex(){return/^!"(.*)"\$$/}static get singleRegex(){return/^!(.*)\$$/}search(t){const n=!t.endsWith(this.pattern);return{isMatch:n,score:n?0:1,indices:[0,t.length-1]}}}class tq extends gl{constructor(t,{location:n=mn.location,threshold:r=mn.threshold,distance:o=mn.distance,includeMatches:i=mn.includeMatches,findAllMatches:a=mn.findAllMatches,minMatchCharLength:s=mn.minMatchCharLength,isCaseSensitive:c=mn.isCaseSensitive,ignoreLocation:l=mn.ignoreLocation}={}){super(t),this._bitapSearch=new Zz(t,{location:n,threshold:r,distance:o,includeMatches:i,findAllMatches:a,minMatchCharLength:s,isCaseSensitive:c,ignoreLocation:l})}static get type(){return"fuzzy"}static get multiRegex(){return/^"(.*)"$/}static get singleRegex(){return/^(.*)$/}search(t){return this._bitapSearch.searchIn(t)}}class nq extends gl{constructor(t){super(t)}static get type(){return"include"}static get multiRegex(){return/^'"(.*)"$/}static get singleRegex(){return/^'(.*)$/}search(t){let n=0,r;const o=[],i=this.pattern.length;for(;(r=t.indexOf(this.pattern,n))>-1;)n=r+i,o.push([r,n-1]);const a=!!o.length;return{isMatch:a,score:a?0:1,indices:o}}}const hS=[k_e,nq,__e,S_e,C_e,j_e,x_e,tq],rq=hS.length,$_e=/ +(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/,T_e="|";function O_e(e,t={}){return e.split(T_e).map(n=>{let r=n.trim().split($_e).filter(i=>i&&!!i.trim()),o=[];for(let i=0,a=r.length;i<a;i+=1){const s=r[i];let c=!1,l=-1;for(;!c&&++l<rq;){const f=hS[l];let u=f.isMultiMatch(s);u&&(o.push(new f(u,t)),c=!0)}if(!c)for(l=-1;++l<rq;){const f=hS[l];let u=f.isSingleMatch(s);if(u){o.push(new f(u,t));break}}}return o})}const E_e=new Set([tq.type,nq.type]);class A_e{constructor(t,{isCaseSensitive:n=mn.isCaseSensitive,includeMatches:r=mn.includeMatches,minMatchCharLength:o=mn.minMatchCharLength,ignoreLocation:i=mn.ignoreLocation,findAllMatches:a=mn.findAllMatches,location:s=mn.location,threshold:c=mn.threshold,distance:l=mn.distance}={}){this.query=null,this.options={isCaseSensitive:n,includeMatches:r,minMatchCharLength:o,findAllMatches:a,ignoreLocation:i,location:s,threshold:c,distance:l},this.pattern=n?t:t.toLowerCase(),this.query=O_e(this.pattern,this.options)}static condition(t,n){return n.useExtendedSearch}searchIn(t){const n=this.query;if(!n)return{isMatch:!1,score:1};const{includeMatches:r,isCaseSensitive:o}=this.options;t=o?t:t.toLowerCase();let i=0,a=[],s=0;for(let c=0,l=n.length;c<l;c+=1){const f=n[c];a.length=0,i=0;for(let u=0,d=f.length;u<d;u+=1){const h=f[u],{isMatch:p,indices:m,score:v}=h.search(t);if(p){if(i+=1,s+=v,r){const g=h.constructor.type;E_e.has(g)?a=[...a,...m]:a.push(m)}}else{s=0,i=0,a.length=0;break}}if(i){let u={isMatch:!0,score:s/i};return r&&(u.indices=a),u}}return{isMatch:!1,score:1}}}const pS=[];function P_e(...e){pS.push(...e)}function mS(e,t){for(let n=0,r=pS.length;n<r;n+=1){let o=pS[n];if(o.condition(e,t))return new o(e,t)}return new Zz(e,t)}const Y0={AND:"$and",OR:"$or"},vS={PATH:"$path",PATTERN:"$val"},gS=e=>!!(e[Y0.AND]||e[Y0.OR]),M_e=e=>!!e[vS.PATH],I_e=e=>!gc(e)&&Kz(e)&&!gS(e),oq=e=>({[Y0.AND]:Object.keys(e).map(t=>({[t]:e[t]}))});function iq(e,t,{auto:n=!0}={}){const r=o=>{let i=Object.keys(o);const a=M_e(o);if(!a&&i.length>1&&!gS(o))return r(oq(o));if(I_e(o)){const c=a?o[vS.PATH]:i[0],l=a?o[vS.PATTERN]:o[c];if(!Rs(l))throw new Error(l_e(c));const f={keyId:fS(c),pattern:l};return n&&(f.searcher=mS(l,t)),f}let s={children:[],operator:i[0]};return i.forEach(c=>{const l=o[c];gc(l)&&l.forEach(f=>{s.children.push(r(f))})}),s};return gS(e)||(e=oq(e)),r(e)}function N_e(e,{ignoreFieldNorm:t=mn.ignoreFieldNorm}){e.forEach(n=>{let r=1;n.matches.forEach(({key:o,norm:i,score:a})=>{const s=o?o.weight:null;r*=Math.pow(a===0&&s?Number.EPSILON:a,(s||1)*(t?1:i))}),n.score=r})}function R_e(e,t){const n=e.matches;t.matches=[],Vi(n)&&n.forEach(r=>{if(!Vi(r.indices)||!r.indices.length)return;const{indices:o,value:i}=r;let a={indices:o,value:i};r.key&&(a.key=r.key.src),r.idx>-1&&(a.refIndex=r.idx),t.matches.push(a)})}function D_e(e,t){t.score=e.score}function L_e(e,t,{includeMatches:n=mn.includeMatches,includeScore:r=mn.includeScore}={}){const o=[];return n&&o.push(R_e),r&&o.push(D_e),e.map(i=>{const{idx:a}=i,s={item:t[a],refIndex:a};return o.length&&o.forEach(c=>{c(i,s)}),s})}class hd{constructor(t,n={},r){this.options={...mn,...n},this.options.useExtendedSearch,this._keyStore=new h_e(this.options.keys),this.setCollection(t,r)}setCollection(t,n){if(this._docs=t,n&&!(n instanceof dS))throw new Error(c_e);this._myIndex=n||Xz(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight})}add(t){Vi(t)&&(this._docs.push(t),this._myIndex.add(t))}remove(t=()=>!1){const n=[];for(let r=0,o=this._docs.length;r<o;r+=1){const i=this._docs[r];t(i,r)&&(this.removeAt(r),r-=1,o-=1,n.push(i))}return n}removeAt(t){this._docs.splice(t,1),this._myIndex.removeAt(t)}getIndex(){return this._myIndex}search(t,{limit:n=-1}={}){const{includeMatches:r,includeScore:o,shouldSort:i,sortFn:a,ignoreFieldNorm:s}=this.options;let c=Rs(t)?Rs(this._docs[0])?this._searchStringList(t):this._searchObjectList(t):this._searchLogical(t);return N_e(c,{ignoreFieldNorm:s}),i&&c.sort(a),Wz(n)&&n>-1&&(c=c.slice(0,n)),L_e(c,this._docs,{includeMatches:r,includeScore:o})}_searchStringList(t){const n=mS(t,this.options),{records:r}=this._myIndex,o=[];return r.forEach(({v:i,i:a,n:s})=>{if(!Vi(i))return;const{isMatch:c,score:l,indices:f}=n.searchIn(i);c&&o.push({item:i,idx:a,matches:[{score:l,value:i,norm:s,indices:f}]})}),o}_searchLogical(t){const n=iq(t,this.options),r=(s,c,l)=>{if(!s.children){const{keyId:u,searcher:d}=s,h=this._findMatches({key:this._keyStore.get(u),value:this._myIndex.getValueForItemAtKeyId(c,u),searcher:d});return h&&h.length?[{idx:l,item:c,matches:h}]:[]}const f=[];for(let u=0,d=s.children.length;u<d;u+=1){const h=s.children[u],p=r(h,c,l);if(p.length)f.push(...p);else if(s.operator===Y0.AND)return[]}return f},o=this._myIndex.records,i={},a=[];return o.forEach(({$:s,i:c})=>{if(Vi(s)){let l=r(n,s,c);l.length&&(i[c]||(i[c]={idx:c,item:s,matches:[]},a.push(i[c])),l.forEach(({matches:f})=>{i[c].matches.push(...f)}))}}),a}_searchObjectList(t){const n=mS(t,this.options),{keys:r,records:o}=this._myIndex,i=[];return o.forEach(({$:a,i:s})=>{if(!Vi(a))return;let c=[];r.forEach((l,f)=>{c.push(...this._findMatches({key:l,value:a[f],searcher:n}))}),c.length&&i.push({idx:s,item:a,matches:c})}),i}_findMatches({key:t,value:n,searcher:r}){if(!Vi(n))return[];let o=[];if(gc(n))n.forEach(({v:i,i:a,n:s})=>{if(!Vi(i))return;const{isMatch:c,score:l,indices:f}=r.searchIn(i);c&&o.push({score:l,key:t,value:i,idx:a,norm:s,indices:f})});else{const{v:i,n:a}=n,{isMatch:s,score:c,indices:l}=r.searchIn(i);s&&o.push({score:c,key:t,value:i,norm:a,indices:l})}return o}}hd.version="6.6.2",hd.createIndex=Xz,hd.parseIndex=g_e,hd.config=mn,hd.parseQuery=iq,P_e(A_e);const B_e=b.createElementVNode("h3",{class:"title"},"Jump to label",-1),F_e={key:0,class:"search-results"},V_e={key:1},z_e=[b.createElementVNode("h3",null,"No matches found",-1)],q_e=b.defineComponent({__name:"debug-jumping",emits:["close","jump"],setup(e,{emit:t}){const n=t;let r;const o=b.ref(null),i=b.ref(""),a=b.ref([]),s=b.ref(0),c=b.ref(null);function l(){const d=i.value,h=r.search(d);a.value=h.map(p=>p.item),a.value.length>0&&s.value>a.value.length-1&&(s.value=a.value.length-1)}function f(d){if(d===s.value)return{background:"var(--light-background)"}}const u=b.computed(()=>Object.keys(yn.script).sort());return b.onMounted(()=>{sn().debugMode=!0,r=new hd(u.value,{includeScore:!0}),a.value=u.value,s.value=0,setTimeout(()=>{b.nextTick(()=>{c.value&&c.value.focus()})},10),o.value=xr().registerInputListener("debug-jumping",{up:{press:()=>{s.value>0?s.value--:s.value=a.value.length-1}},down:{press:()=>{a.value.length>s.value+1?s.value++:s.value=0}},continue:{press:()=>{if(a.value.length>0&&s.value<a.value.length){const d=a.value[s.value];un().jumpToLabel(d),n("close")}}},escape:{press:()=>{n("close")}}})}),b.onUnmounted(()=>{o.value&&xr().unregisterInputListener(o.value),sn().debugMode=!1}),(d,h)=>(b.openBlock(),b.createBlock(Bs,{onClose:h[1]||(h[1]=p=>d.$emit("close")),containerCssClass:"jump-menu-container"},{header:b.withCtx(()=>[B_e]),body:b.withCtx(()=>[b.withDirectives(b.createElementVNode("input",{type:"text",class:"label-input input",ref_key:"search",ref:c,"onUpdate:modelValue":h[0]||(h[0]=p=>i.value=p),onInput:l},null,544),[[b.vModelText,i.value]]),a.value.length>0?(b.openBlock(),b.createElementBlock("div",F_e,[(b.openBlock(!0),b.createElementBlock(b.Fragment,null,b.renderList(a.value,(p,m)=>(b.openBlock(),b.createElementBlock("div",{class:"search-result",style:b.normalizeStyle(f(m)),key:m},b.toDisplayString(p),5))),128))])):(b.openBlock(),b.createElementBlock("div",V_e,z_e))]),_:1}))}}),xu=eo("achievements",{state:()=>({achievements:{}}),actions:{generateGlobalSaveData(){return{achievements:Xn(this.achievements)}},loadGlobalSaveData(e){this.achievements={...this.achievements,...Xn(e.achievements)}},updateConfig(e){Object.keys(e.achievements).forEach(t=>{this.achievements[t]||(this.achievements[t]={id:t,unlocked:!1})})},reset(e){this.$reset(),this.updateConfig(e)},hasAchievement(e){var t;return((t=this.achievements[e])==null?void 0:t.unlocked)??!1},getExistingAchievement(e){return this.achievements[e]},unlock(e){const t=this.getExistingAchievement(e);if(!t){St(`Tried to unlock achievement ${e} but it doesn't exist`);return}if(!t.unlocked){const n=new Date().toISOString();t.unlocked=!0,t.unlockTime=n}if(Op().notifyNewAchievements){const n=cS(e);Jo().addNotification(`New Achievement: ${n.name}`,n.description,n.icon)}}}}),yS=eo("choices-tracking-store",{state:()=>({choices:{}}),getters:{},actions:{trackChoice(e,t){this.choices[e]||(this.choices[e]={}),this.choices[e][t]=!0},hasSeenChoice(e,t){var n;return((n=this.choices[e])==null?void 0:n[t])??!1},generateSaveData(){return{choices:Xn(this.choices)}},loadSaveData(e){this.choices=Xn(e.choices)},reset(){this.$reset()}}}),bS={main:{store:sn,save:"main"},achievements:{store:xu,config:"achievements",globalSave:"achievements"},audio:{store:Po,config:"audio",save:"audio"},choicesTracking:{store:yS,config:"choices",save:"choices"},config:{store:fo,save:"config"},dialog:{store:cr,save:"dialog"},hud:{store:Si,config:"common",save:"hud"},inputs:{store:xr},inventory:{store:Io,config:"items",save:"inventory"},menu:{store:No},notifications:{store:Jo,config:"common"},quests:{store:ko,config:"quests",save:"quests"},rendering:{store:Gr,save:"rendering"},screens:{store:da,config:"screens",save:"screens"},sprites:{store:Bi,save:"screenObjects"},settings:{store:Es,save:"settings",config:"common"},skills:{store:Jr,config:"skills",save:"skills"},startMenu:{store:Ux},tooltips:{store:Wf,config:"tooltips"},vm:{store:un,save:"vm",globalSave:"data"},scenes:{store:_i,save:"scenes"}};function aq(){const e={};for(const t in bS){const r=bS[t].store();e[t]=r}return e}function U_e(e){const t=aq();for(const n in e){const r=e[n];Object.assign(t[n],r)}}owe(bS);const H_e=b.defineComponent({components:{ModalWindow:Bs,DebugJumping:q_e},setup(){const e=Jr(),t=b.computed(()=>e.skills),n=b.computed(()=>e.skillChecks);return{skills:t,skillChecks:n}},data(){return{showDebug:!1,jumping:!1,inputListener:null}},mounted(){const e=Gr(),t=Ct().hotkeys.debugMenu??"d",n=Ct().hotkeys.jumpMenu??"j";e.inputsContainer.addEventListener("keydown",r=>{this.jumping||(r.key===t&&this.toggle(),r.key===n&&this.jump())})},methods:{closeJumping(){this.jumping=!1},labelSelected(e){const t=e.target.value;un().jumpToLabel(t),this.close()},close(){this.showDebug=!1,this.endDebug()},closeErrors(){sn().clearErrors()},open(){this.showDebug=!0,this.startDebug();const e=un(),t=ko(),n=Io(),r=Jr();this.$nextTick(()=>{new g7({target:this.$refs.variablesViewer,props:{content:{text:void 0,json:{data:this.variables,quests:t.quests,items:n.items,skills:r.skills,skillChecks:r.skillChecks}},onChange:o=>{e.overrideData(o.json.data),t.quests=o.json.quests,n.items=o.json.items,r.skills=o.json.skills,r.skillChecks=o.json.skillChecks}}}),new g7({target:this.$refs.stateViewer,props:{content:{text:void 0,json:aq()},onChange:o=>{U_e(o.json)}}})})},toggle(){this.showDebug?this.close():this.open()},startDebug(){sn().debugMode=!0},endDebug(){sn().debugMode=!1},jump(){this.jumping=!0,this.startDebug()},save(){Zx({})},resetSave(){Tme()},resetGlobalSave(){CV()},wordCount(){const t=Object.values(this.script).reduce((n,r)=>(qi.log(n),n+this.countWordsInScriptBranch(r.branch)),0);alert(`You have ${t} words`)},countWordsInScriptLine(e){if(e.command.commandType==="talk"&&typeof e.command.args[2]=="string")return this.countWordsInString(e.command.args[2]);if(e.command.commandType==="text")return this.countWordsInString(e.code);if(e.command.commandType==="choice"){const t=e.command.staticOptions;let n=this.countWordsInScriptLine(t.prompt);return n+=t.choices.reduce((o,i)=>o+this.countWordsInString(i.prompt.code),0),t.choices.reduce((o,i)=>i.branch?o+this.countWordsInScriptBranch(i.branch):o,n)}if(e.command.commandType==="if"){const t=e.command.staticOptions;return[t.success,t.failure].reduce((r,o)=>o?r+this.countWordsInScriptBranch(o):r,0)}return 0},countWordsInString(e){return e.split(" ").length},countWordsInScriptBranch(e){return e.reduce((t,n)=>n?t+this.countWordsInScriptLine(n):t,0)},getPlayTimeString(){const e=Su(this.playTime.start,this.playTime.previousPlaytime);return ty(e/1e3)}},computed:{...rp(un,["data"]),...rp(sn,["playTime","errors","playing"]),...rp(_i,["activeScene"]),labels(){const e=this.script;return Object.keys(e).sort()},script(){return yn.script},variables(){return this.data}}}),W_e={class:"debug-menu"},K_e={key:0,class:"debug-info"},G_e=[b.createStaticVNode("<h3>Debug mode is ON</h3><ul><li><b>j</b>: Quick Label Jump</li><li><b>d</b>: Debug Menu</li><li><b>a</b>: Auto Play</li><li><b>s</b>: Skip</li><li><b>Space</b>: New Game</li><li><b>c</b>: Continue</li><li><b>Escape</b>: Toggle Menu</li></ul>",2)],J_e=b.createElementVNode("h3",{class:"title"},"Error(s)",-1),Q_e=["innerHTML"],Y_e=b.createElementVNode("h3",{class:"title"},"Debug Menu!",-1),X_e={class:"container"},Z_e=b.createElementVNode("option",{class:"option",selected:"",disabled:""},"Jump to a label",-1),eSe=["value"],tSe={class:"grid grid-cols-3 gap-4"},nSe=b.createElementVNode("h2",null,"Variables Editor",-1),rSe={ref:"variablesViewer"},oSe=b.createElementVNode("h2",null,"Skill Checks",-1),iSe={class:"table-auto"},aSe=b.createElementVNode("thead",null,[b.createElementVNode("tr",null,[b.createElementVNode("th",null,"Skill Check"),b.createElementVNode("th",null,"Happened"),b.createElementVNode("th",null,"Succeeded")])],-1),sSe=b.createElementVNode("h2",null,"App State editor (entire app and engine",-1),cSe=b.createElementVNode("h3",{style:{color:"pink"}}," Use for debugging, editing some of those things can cause issues ",-1),lSe={ref:"stateViewer"};function uSe(e,t,n,r,o,i){const a=b.resolveComponent("DebugJumping"),s=b.resolveComponent("ModalWindow");return b.openBlock(),b.createElementBlock("div",W_e,[b.createElementVNode("button",{onClick:t[0]||(t[0]=(...c)=>e.open&&e.open(...c)),class:"button debug-button"},"Debug Menu"),!e.playing&&e.activeScene==="menu"?(b.openBlock(),b.createElementBlock("div",K_e,G_e)):b.createCommentVNode("",!0),e.jumping?(b.openBlock(),b.createBlock(a,{key:1,onClose:e.closeJumping},null,8,["onClose"])):b.createCommentVNode("",!0),e.errors.length>0?(b.openBlock(),b.createBlock(s,{key:2,onClose:e.closeErrors,containerCssClass:"debug-menu-container"},{header:b.withCtx(()=>[J_e]),body:b.withCtx(()=>[b.createTextVNode(" There are errors in your dialogue scripts. Open the developer console for more details. "),b.createElementVNode("ul",null,[(b.openBlock(!0),b.createElementBlock(b.Fragment,null,b.renderList(e.errors,(c,l)=>(b.openBlock(),b.createElementBlock("li",{key:l,class:b.normalizeClass(["error-message list-disc",c.type==="error"?"error":"warning"]),innerHTML:c.text},null,10,Q_e))),128))])]),_:1},8,["onClose"])):b.createCommentVNode("",!0),e.showDebug?(b.openBlock(),b.createBlock(s,{key:3,onClose:e.close,containerCssClass:"debug-menu-container"},{header:b.withCtx(()=>[Y_e]),body:b.withCtx(()=>[b.createElementVNode("div",X_e,[b.createTextVNode(" Hello this is the debug menu. "),b.createElementVNode("select",{class:"select",name:"label-selector",onChange:t[1]||(t[1]=c=>e.labelSelected(c))},[Z_e,(b.openBlock(!0),b.createElementBlock(b.Fragment,null,b.renderList(e.labels,c=>(b.openBlock(),b.createElementBlock("option",{class:"option",value:c,key:c},b.toDisplayString(c),9,eSe))),128))],32),b.createElementVNode("div",tSe,[b.createElementVNode("button",{onClick:t[2]||(t[2]=(...c)=>e.wordCount&&e.wordCount(...c)),class:"button"},"Word Count"),b.createElementVNode("button",{onClick:t[3]||(t[3]=(...c)=>e.save&&e.save(...c)),class:"button"},"Save Game"),b.createElementVNode("button",{onClick:t[4]||(t[4]=(...c)=>e.resetSave&&e.resetSave(...c)),class:"button"},"Reset Save"),b.createElementVNode("button",{onClick:t[5]||(t[5]=(...c)=>e.resetGlobalSave&&e.resetGlobalSave(...c)),class:"button"}," Reset GLOBAL Save ")]),b.createElementVNode("h3",null,"Play time: "+b.toDisplayString(e.getPlayTimeString()),1),nSe,b.createElementVNode("div",rSe,null,512),oSe,b.createElementVNode("table",iSe,[aSe,b.createElementVNode("tbody",null,[(b.openBlock(!0),b.createElementBlock(b.Fragment,null,b.renderList(e.skillChecks,(c,l)=>(b.openBlock(),b.createElementBlock("tr",{key:l},[b.createElementVNode("td",null,b.toDisplayString(l),1),b.createElementVNode("td",null,b.toDisplayString(c.happened?"✅":"❌"),1),b.createElementVNode("td",null,b.toDisplayString(c.happened?c.succeeded?"✅":"❌":"NA"),1)]))),128))])]),sSe,cSe,b.createElementVNode("div",lSe,null,512)])]),_:1},8,["onClose"])):b.createCommentVNode("",!0)])}const fSe=Xa(H_e,[["render",uSe]]),dSe=["src"],hSe=["innerHTML"],pSe=["innerHTML"],mSe=b.defineComponent({__name:"notification-toast",setup(e){const t=Jo(),n=b.computed(()=>t.notifications),r=o=>{if(o.description)return{marginTop:"10px"}};return(o,i)=>(b.openBlock(),b.createBlock(b.TransitionGroup,{name:"notification",tag:"div",class:"notifications-holder"},{default:b.withCtx(()=>[(b.openBlock(!0),b.createElementBlock(b.Fragment,null,b.renderList(n.value,(a,s)=>(b.openBlock(),b.createElementBlock("div",{class:"notification tile",key:s},[a.icon?(b.openBlock(),b.createElementBlock("img",{key:0,src:b.unref(ci)(a.icon),class:"notification-icon",style:b.normalizeStyle(r(a))},null,12,dSe)):b.createCommentVNode("",!0),b.createElementVNode("span",{innerHTML:a.text,class:"notification-text"},null,8,hSe),a.description?(b.openBlock(),b.createElementBlock("p",{key:1,innerHTML:a.description,class:"notification-description"},null,8,pSe)):b.createCommentVNode("",!0)]))),128))]),_:1}))}}),vSe={class:"title"},gSe=b.defineComponent({__name:"alert-modal",props:{title:{type:String,required:!1},text:{type:String,required:!1}},emits:["close"],setup(e,{emit:t}){const n=t;function r(){n("close")}const o=b.ref(xr().registerInputListener("yes-no",{cancel:{press:()=>{r()}},continue:{press:()=>{r()}},system:{press:()=>{r()}}}));return b.onUnmounted(()=>{o.value&&xr().unregisterInputListener(o.value)}),(i,a)=>(b.openBlock(),b.createBlock(Bs,{onClose:r,containerCssClass:"yes-no-modal"},{header:b.withCtx(()=>[b.createElementVNode("h3",vSe,b.toDisplayString(e.title??"Alert"),1)]),body:b.withCtx(()=>[b.createElementVNode("h3",null,b.toDisplayString(e.text),1)]),_:1}))}}),ySe=b.createElementVNode("hr",null,null,-1),bSe=b.defineComponent({__name:"floating-tooltip",props:{title:{},text:{},width:{},x:{},y:{},screenWidth:{},screenHeight:{},screenMargin:{},cssClass:{},textCssClass:{},titleCssClass:{}},setup(e){const t=b.ref(150),n=b.ref(null),r=e,o=b.computed(()=>r.screenWidth??window.innerWidth),i=b.computed(()=>r.screenHeight??window.innerHeight),a=b.computed(()=>{const s=r.screenMargin??5,c={};let l=r.x-r.width/2;l=Math.min(l,o.value-r.width-s),l=Math.max(s,l),c.left=`${l}px`;let f=i.value-r.y;return f=Math.max(f,s),f=Math.min(f,i.value-t.value-s),c.bottom=`${f}px`,c.width=`${r.width}px`,c});return b.onMounted(()=>{n.value&&(t.value=n.value.clientHeight)}),(s,c)=>(b.openBlock(),b.createBlock(b.Transition,{name:"fade"},{default:b.withCtx(()=>[b.createElementVNode("div",{class:b.normalizeClass(["floating-tooltip",s.cssClass]),style:b.normalizeStyle(a.value),ref_key:"element",ref:n},[s.title?(b.openBlock(),b.createElementBlock("div",{key:0,class:b.normalizeClass(["floating-tooltip-title",s.titleCssClass])},[b.createTextVNode(b.toDisplayString(r.title)+" ",1),ySe],2)):b.createCommentVNode("",!0),b.createElementVNode("div",{class:b.normalizeClass(["floating-tooltip-text",s.textCssClass])},b.toDisplayString(r.text),3)],6)]),_:1}))}}),wSe={class:"tooltips-ui"},kSe=b.defineComponent({__name:"tooltips-ui",setup(e){const t=Wf(),n=Gr(),r=b.computed(()=>t.tooltip),o=b.computed(()=>n.screenWidth),i=b.computed(()=>n.screenHeight),a=b.computed(()=>{if(r.value)return{...r.value,screenMargin:ml().options.screenEdgesMinimumMargin??5,screenWidth:o.value,screenHeight:i.value,...s(r.value)}});function s(c){var f,u;let l={};return ml().options.styling&&(l={...l,...ml().options.styling}),(f=H0(c.keyword))!=null&&f.styling&&(l={...l,...(u=H0(c.keyword))==null?void 0:u.styling}),l}return(c,l)=>(b.openBlock(),b.createElementBlock("div",wSe,[r.value?(b.openBlock(),b.createBlock(bSe,b.normalizeProps(b.mergeProps({key:0},a.value)),null,16)):b.createCommentVNode("",!0)]))}}),wS={};async function xSe(e){qi.log("Loading videos");const t=[],n=async(o,i)=>await _Se(o,i),r=(o,i)=>{t.push(n(o,i))};if(e.preload.video)for(const o in e.preload.video.assets){const i=e.preload.video.assets[o];r(o,i)}return Promise.all(t)}async function _Se(e,t){if(wS[e])return wS[e];const n=new Promise((r,o)=>{const i=document.createElement("video");i.onloadeddata=()=>{r(i)},i.onerror=a=>{St(`Could not load video ${t}`,a),o(a)},i.src=ci(t)});return wS[e]=n,n}async function SSe(){const t=pr().scripts;Po().setMasterVolume(Fi().options.volume??1),await un().loadScripts(t),No().setup();for(const[,n]of yn.customStores())if(n.setup){const r=n.setup();vx(r)&&await r}yn.addCustomSettings(),SV()}async function jSe(){const e=sn(),t=i1e(pr()),n=xSe(pr()),r=vve(Fi());if(yn.plugins){const o=[];for(const i of yn.plugins)i.loadingPromises&&o.push(Promise.all(i.loadingPromises));o.length>0&&(e.setLoadingStep("Plugins",0),await Promise.all(o))}e.setLoadingStep("Assets",.3),await Promise.all([t,n,r]),yn.callHook("onAssetsLoaded"),e.setLoadingStep("Starting",.9),await SSe(),yn.callHook("onGameSetup"),e.gameLoaded()}const CSe=["id"],$Se=b.defineComponent({__name:"GameScene",props:{sceneId:{},options:{}},setup(e){const t=e,n=_i(),r=b.computed(()=>n.getSceneConfig(t.sceneId));function o(){n.finishedScene(t.sceneId)}return(i,a)=>(b.openBlock(),b.createElementBlock("div",{class:"game-scene",id:`scene-${i.sceneId}`},[(b.openBlock(),b.createBlock(b.resolveDynamicComponent(r.value.component),{onFinished:o,options:i.options},null,40,["options"]))],8,CSe))}}),TSe=b.defineComponent({__name:"app",props:{options:{}},setup(e){const t=e,n=sn(),r=_i(),o=b.computed(()=>r.activeScene),i=b.computed(()=>n.alerts),a=Gr(),s=b.computed(()=>({transform:`scale(${a.gameScaleRatio}, ${a.gameScaleRatio})`,width:`${a.gameWidth}px`,height:`${a.actualGameHeight}px`})),c=b.computed(()=>No().activeMenu?"app-blurred-by-modal":{});function l(u){sn().closeAlert(u)}function f(){Gr().refreshScreenSize()}return b.onMounted(async()=>{yn.callHook("onAppMounted"),await jSe(),a.inputsContainer.addEventListener("resize",dp(()=>{f()},100,{maxWait:200})),ha.setup(t.options.debug),setTimeout(()=>{f()},50)}),(u,d)=>(b.openBlock(),b.createElementBlock(b.Fragment,null,[b.createElementVNode("div",{id:"narrat-app-container",style:b.normalizeStyle(s.value)},[b.createElementVNode("div",{id:"narrat-app",class:b.normalizeClass(c.value),tabindex:"0"},[b.createVNode(b.Transition,{name:"screens-fade"},{default:b.withCtx(()=>[(b.openBlock(),b.createBlock($Se,{key:o.value,sceneId:o.value,options:b.unref(r).currentOptions},null,8,["sceneId","options"]))]),_:1}),u.options.debug?(b.openBlock(),b.createBlock(fSe,{key:0})):b.createCommentVNode("",!0),b.createVNode(mSe),(b.openBlock(!0),b.createElementBlock(b.Fragment,null,b.renderList(i.value,h=>(b.openBlock(),b.createBlock(gSe,{key:h.id,title:h.title,text:h.text,onClose:()=>l(h.id)},null,8,["title","text","onClose"]))),128))],2)],4),b.createVNode(kSe)],64))}}),OSe=new Re("add_level",[{name:"skillKey",type:"string"},{name:"amount",type:"number"}],async e=>{let{skillKey:t,amount:n}=e.options;if((!t||!n)&&xt(e,"add_level command needs a skill id and a value as parameters"),!Number.isInteger(n)){const r=n;n=Math.round(n),console.warn(`add_level expects a level to be an integer. Auto Rounding ${r} to ${n}`)}Jr().incrementSkill(t,n)}),ESe=Re.FromOptions({keyword:"set_level",argTypes:[{name:"skill",type:"string"},{name:"level",type:"number"}],runner:async e=>{let{skill:t,level:n}=e.options;if((!t||!n)&&xt(e,"set_level command needs a skill id and a value as parameters"),!Number.isInteger(n)){const r=n;n=Math.round(n),console.warn(`set_level expects a level to be an integer. Auto Rounding ${r} to ${n}`)}Jr().setSkillLevel(t,n)}}),ASe=new Re("add_xp",[{name:"xpKey",type:"string"},{name:"xpToAdd",type:"number"}],async e=>{const{xpKey:t,xpToAdd:n}=e.options;(!t||!n)&&xt(e,"add_xp command needs a skill id and a value as parameters"),Jr().addXp(t,n)}),PSe=new Re("get_level",[{name:"skillKey",type:"string"}],async e=>{const{skillKey:t}=e.options;t||xt(e,"get_level command needs a skill id as parameter");const n=Jr().getSkill(t);return n||xt(e,`Skill ${t} not found`),n.level}),MSe=new Re("get_xp",[{name:"xpKey",type:"string"}],async e=>{const{xpKey:t}=e.options;t||xt(e,"get_xp command needs a skill id as parameter");const n=Jr().getSkillXp(t);return n||xt(e,`XP ${t} not found`),n}),ISe=new Re("roll",[{name:"id",type:"string"},{name:"skill",type:"string",optional:!0},{name:"difficulty",type:"number",optional:!0},{name:"mode",type:"string",optional:!0}],async e=>{const{id:t}=e.options;let n={id:t};if(e.args.length===1&&Vz(t))n={...Fz(t),id:t};else{const{skill:o,difficulty:i,mode:a}=e.options;if(!o||!i){xt(e,"roll command needs a skill and a difficulty as parameters, or the skill check id to be configured in skillChecks.yaml");return}n={skill:o,difficulty:i,id:t},a==="hideAfterRoll"&&(n.hideAfterRoll=!0),a==="repeatable"&&(n.repeatable=!0)}return nF(n).succeeded}),NSe=new Re("get_skill_check",[{name:"skillCheckId",type:"string"}],async e=>Jr().getSkillCheck(e.options.skillCheckId)),RSe=new Re("skill_check_result",[{name:"skillCheckId",type:"string"}],async e=>Jr().getSkillCheck(e.options.skillCheckId).succeeded),DSe=new Re("reset_roll",[{name:"id",type:"string"}],async e=>Jr().resetSkillCheck(e.options.id)),LSe=new Re("add_stat",[{name:"statKey",type:"string"},{name:"amountToAdd",type:"number"}],async e=>{const{statKey:t,amountToAdd:n}=e.options;(!t||typeof n!="number")&&xt(e,"add_stat command needs a stat id and a value as parameters"),Si().addStat(t,n)}),BSe=new Re("set_stat",[{name:"statKey",type:"string"},{name:"value",type:"number"}],async e=>{const{statKey:t,value:n}=e.options;(!t||typeof n!="number")&&xt(e,"set_stat command needs a stat id and a value as parameters"),Si().setStat(t,n)}),FSe=new Re("get_stat_value",[{name:"statKey",type:"string"}],async e=>{const{statKey:t}=e.options;return t||xt(e,"get_stat_value command needs a stat id as parameter"),Si().getStatValue(t)}),VSe=new Re("show_hud",[],async e=>{Si().setVisibility(!0)}),zSe=new Re("hide_hud",[],async e=>{Si().setVisibility(!1)}),qSe=Re.FromOptions({keyword:"jump",argTypes:"any",runner:async e=>{(e.args.length<1||typeof e.args[0]!="string")&&xt(e,"requires a label argument");const t=e.args[0],n=un(),r={branchData:yn.script[t],label:t,args:e.args.splice(1),currentIndex:0};if(!yn.script[t]){St(`Trying to jump but label ${t} not found`);return}return n.jumpTarget=r,o0}}),USe=Re.FromOptions({keyword:"run",argTypes:"any",runner:async e=>{(e.args.length<1||typeof e.args[0]!="string")&&xt(e,"run command needs a label to argument run");const t=e.args[0];return await un().runLabelFunction(t,...e.args.slice(1))}}),HSe=Re.FromOptions({keyword:"var",argTypes:[{name:"name",type:"string"},{name:"value",type:"any"}],runner:async e=>{const{name:t,value:n}=e.options;un().addScopedVariable(t,n)}}),WSe=Re.FromOptions({keyword:"return",argTypes:[{name:"value",type:"any"}],runner:async e=>{const{value:t}=e.options;return un().setReturnValue(t),yx}}),KSe=Re.FromOptions({keyword:"log",argTypes:"any",runner:async e=>{Hxe(e,...e.args)}}),GSe=Re.FromOptions({keyword:"menu_return",argTypes:[],runner:async e=>(mV(),i0)}),JSe=Re.FromOptions({keyword:"save",argTypes:[{name:"name",type:"string",optional:!0}],runner:async e=>{await $V({saveName:e.options.name})}}),QSe=Re.FromOptions({keyword:"save_prompt",argTypes:[{name:"name",type:"string",optional:!0}],runner:async e=>{await $V({saveName:e.options.name,withPrompt:!0})}}),YSe=Re.FromOptions({keyword:"reset_global_save",argTypes:[],runner:async e=>{await CV()}}),XSe=Re.FromOptions({keyword:"new",argTypes:[{name:"name",type:"string"},{name:"rest",type:"rest",optional:!0}],runner:async e=>{const t=e.options.name;if(t==="Array")return[...e.args.slice(1)];if(t==="Object")return{}}}),ZSe=[{name:"mode",type:"string"},{name:"audio",type:"string"},{name:"channel",type:"number",optional:!0}],eje=new Re("play",ZSe,async e=>{const t=Po(),{mode:n,audio:r,channel:o}=e.options,i=X0(e,n);i&&t.playChannel(i,r,o??0)}),tje=new Re("resume",[{name:"mode",type:"string"},{name:"channel",type:"number",optional:!0}],async e=>{const t=Po(),{mode:n,channel:r}=e.options,o=X0(e,n);o&&t.resumeChannel(o,r??0)}),nje=new Re("pause",[{name:"mode",type:"string"},{name:"channel",type:"number",optional:!0}],async e=>{const t=Po(),{mode:n,channel:r}=e.options,o=X0(e,n);o&&t.pauseChannel(o,r??0)}),rje=new Re("stop",[{name:"mode",type:"string"},{name:"channel",type:"number",optional:!0}],async e=>{const t=Po(),{mode:n,channel:r}=e.options,o=X0(e,n);o&&t.stopChannel(o,r??0)});function X0(e,t){return oje(t)?t:(xt(e,`${t} is not a valid audio mode.`),!1)}function oje(e){return!!G9.includes(e)}const ije=new Re("set",[{name:"key",type:"string"},{name:"value",type:"any"}],async e=>{const t=dd();Uz(t,`$${e.options.key}`,e.options.value)}),aje=new Re("add",[{name:"key",type:"string"},{name:"value",type:"any"}],async e=>{const t=dd();Hz(t,`$${e.options.key}`,e.options.value)}),sje=new Re("set_screen",[{name:"screen",type:"string"},{name:"layer",type:"number",optional:!0},{name:"transitionName",type:"string",optional:!0},{name:"transitionDuration",type:"number",optional:!0},{name:"transitionDelay",type:"number",optional:!0}],async e=>{const t=da();if(!ud(e.options.screen)){xt(e,`Screen ${e.options.screen} doesn't exist in the config`);return}return e.options.transitionName?t.transitionScreen(e.options.screen,{transition:e.options.transitionName,duration:e.options.transitionDuration,delay:e.options.transitionDelay},e.options.layer):t.setScreen(e.options.screen,e.options.layer??0)}),cje=new Re("empty_layer",[{name:"layer",type:"number"},{name:"transitionName",type:"string",optional:!0},{name:"transitionDuration",type:"number",optional:!0},{name:"transitionDelay",type:"number",optional:!0}],async e=>{const t=da();return e.options.transitionName?t.emptyLayer(e.options.layer,{transition:e.options.transitionName,duration:e.options.transitionDuration,delay:e.options.transitionDelay}):t.emptyLayer(e.options.layer)}),lje=new Re("set_button",[{name:"buttonId",type:"string"},{name:"state",type:"any"}],async e=>{const{buttonId:t,state:n}=e.options,r=da();if(!vl(t)){xt(e,`Button ${t} doesn't exist in the config`);return}r.changeButton(t,n)}),uje=Re.FromOptions({keyword:"talk",argTypes:[{name:"speaker",type:"string"},{name:"pose",type:"string"},{name:"text",type:"string"}],runner:async(e,t)=>{await _x({speaker:e.options.speaker,pose:e.options.pose,cssClass:"talk-command",text:`"${e.options.text}"`,choices:t,interactive:!0})},returnAfterPlayerAnswer:!0}),fje=Re.FromOptions({keyword:"think",argTypes:[{name:"speaker",type:"string"},{name:"pose",type:"string"},{name:"text",type:"string"}],runner:async(e,t)=>{await _x({speaker:e.options.speaker,pose:e.options.pose,cssClass:"think-command",text:`${e.options.text}`,choices:t,interactive:!0})},returnAfterPlayerAnswer:!0}),dje=()=>{const e=ld("text",[]);return(t,n)=>{const r=e(t,n);return n.command.staticOptions={text:n.code.substring(1,n.code.length-1)},r}},hje=Re.FromOptions({keyword:"text",argTypes:[],runner:async(e,t)=>{await _x({speaker:fo().gameCharacter,cssClass:"text-command",text:e.staticOptions.text,choices:t,interactive:!0})},parser:dje(),returnAfterPlayerAnswer:!0}),pje=new Re("add_item",[{name:"id",type:"string"},{name:"amount",type:"number"}],async e=>{const{id:t,amount:n}=e.options;Io().add({id:t,amount:n})}),mje=new Re("remove_item",[{name:"id",type:"string"},{name:"amount",type:"number"}],async e=>{const{id:t,amount:n}=e.options;Io().remove({id:t,amount:n})}),vje=new Re("has_item?",[{name:"id",type:"string"},{name:"amount",type:"number",optional:!0}],async e=>{const{id:t,amount:n}=e.options;return Io().hasItem(t,n)}),gje=new Re("item_amount?",[{name:"id",type:"string"}],async e=>{const{id:t}=e.options;return Io().getItemAmount(t)}),yje=new Re("enable_interaction",[{name:"tag",type:"string"}],async e=>{const t=e.options.tag;Io().enableInteraction(t)}),bje=new Re("disable_interaction",[{name:"tag",type:"string"}],async e=>{const t=e.options.tag;Io().disableInteraction(t)}),wje=new Re("start_quest",[{name:"questId",type:"string"}],async e=>{const t=e.options.questId;ko().startQuest(t)}),kje=new Re("start_objective",[{name:"questId",type:"string"},{name:"objectiveId",type:"string"}],async e=>{const{questId:t,objectiveId:n}=e.options;ko().startObjective(t,n)}),xje=new Re("complete_objective",[{name:"questId",type:"string"},{name:"objectiveId",type:"string"}],async e=>{const{questId:t,objectiveId:n}=e.options;ko().completeObjective(t,n)}),_je=new Re("complete_quest",[{name:"questId",type:"string"},{name:"ending",type:"any",optional:!0}],async e=>{const{questId:t,ending:n}=e.options;ko().completeQuest(t,n)}),Sje=new Re("quest_completed?",[{name:"questId",type:"string"}],async e=>{const{questId:t}=e.options;return ko().isQuestCompleted(t)}),jje=new Re("quest_succeeded?",[{name:"questId",type:"string"}],async e=>{const{questId:t}=e.options;return ko().isQuestSucceeded(t)}),Cje=new Re("quest_failed?",[{name:"questId",type:"string"}],async e=>{const{questId:t}=e.options;return ko().isQuestFailed(t)}),$je=new Re("quest_ending?",[{name:"questId",type:"string"}],async e=>{const{questId:t}=e.options;return ko().getQuestEnding(t)}),Tje=new Re("quest_has_ending?",[{name:"questId",type:"string"},{name:"ending",type:"string"}],async e=>{const{questId:t,ending:n}=e.options;return ko().questHasEnding(t,n)}),Oje=new Re("objective_completed?",[{name:"questId",type:"string"},{name:"objectiveId",type:"string"}],async e=>{const{questId:t,objectiveId:n}=e.options;return ko().isObjectiveCompleted(t,n)}),Eje=new Re("quest_started?",[{name:"questId",type:"string"}],async e=>{const{questId:t}=e.options;return ko().isQuestStarted(t)}),Aje=new Re("objective_started?",[{name:"questId",type:"string"},{name:"objectiveId",type:"string"}],async e=>{const{questId:t,objectiveId:n}=e.options;return ko().isObjectiveStarted(t,n)}),Pje=Re.FromOptions({keyword:"wait",argTypes:[{name:"duration",type:"number"}],runner:async e=>{await ki(e.options.duration)}}),Mje=new Re("notify",[{name:"text",type:"string"},{name:"description",type:"string",optional:!0},{name:"icon",type:"string",optional:!0}],async e=>{const{text:t,icon:n,description:r}=e.options;Jo().addNotification(t,r,n)}),Ije=new Re("disable_notifications",[],async e=>{Jo().disableNotifications()}),Nje=new Re("enable_notifications",[],async e=>{Jo().enableNotifications()}),Rje=new Re("clear_dialog",[],async e=>{cr().clearDialog()}),Dje=new Re("if",[{name:"condition",type:"boolean"}],async e=>{const t=[];for(const o of e.staticOptions.elseifs){const i=o.condition,a=await y0(i);t.push(a)}const n=Nge(e,t),r=un();if(n){const o={branchData:{branch:n},currentIndex:0};return r.addAndRunBlock(o)}},(e,t)=>{let n=e.currentLine;ld("if",[{name:"condition",type:"string"}])(e,t);const{lines:o,currentLine:i,line:a}=e,s=t.command;let c,l=i,f=!1;const u=[];for(;!f;){l++;const d=Rge(o,l);if(d&&d.code.startsWith("elseif")){const h=d.expression;if(!Array.isArray(h)){e.parserContext.error(d.line,"Expected an expression after elseif"),f=!0;break}if(h.length>2){e.parserContext.error(d.line,"Expected only one argument after elseif"),f=!0;break}u.push({branch:e.processCommandsFunction(e.parserContext,d.branch,a),condition:n_(e.parserContext,d,h[1])})}else d&&d.code==="else:"?c=e.processCommandsFunction(e.parserContext,d.branch,a):(f=!0,l--)}return s.staticOptions={success:e.processCommandsFunction(e.parserContext,a.branch,a),elseifs:u,failure:c},l++,n=l,{newLine:n}}),Lje=new Re("==","any",async e=>{e.args.length<1&&xt(e,"requires at least 1 arguments");let t=e.args[0],n=!0;for(const r of e.args)if(r!=t){n=!1;break}else t=r;return n}),Bje=new Re(">",[{name:"a",type:"any"},{name:"b",type:"any"}],async e=>{const{a:t,b:n}=e.options;return t>n}),Fje=new Re("<",[{name:"a",type:"any"},{name:"b",type:"any"}],async e=>{const{a:t,b:n}=e.options;return t<n}),Vje=new Re(">=",[{name:"a",type:"any"},{name:"b",type:"any"}],async e=>{const{a:t,b:n}=e.options;return t>=n}),zje=new Re("<=",[{name:"a",type:"any"},{name:"b",type:"any"}],async e=>{const{a:t,b:n}=e.options;return t<=n}),qje=new Re("!=",[{name:"a",type:"any"},{name:"b",type:"any"}],async e=>{const{a:t,b:n}=e.options;return t!=n}),Uje=new Re("!",[{name:"a",type:"any"}],async e=>{const{a:t}=e.options;return!t}),Hje=new Re("&&","any",async e=>{const t=e.args;return e.args.length<2&&xt(e,"requires at least two arguments"),t.reduce((n,r)=>n&&r,!0)}),Wje=new Re("||","any",async e=>(e.args.length<2&&xt(e,"requires at least two arguments"),e.args.reduce((t,n)=>t||n,!1))),Kje=new Re("?",[{name:"a",type:"any"},{name:"b",type:"any"},{name:"c",type:"any"}],async e=>{const{a:t,b:n,c:r}=e.options;return t?n:r}),Gje=new Re("+","any",async e=>(e.args.length<2&&xt(e,"requires at least two arguments"),e.args.reduce((t,n)=>typeof n=="number"?t+n:(xt(e,"requires all arguments to be numbers"),t),0))),Jje=new Re("-","any",async e=>(e.args.length<2&&xt(e,"requires at least two arguments"),e.args.slice(1).reduce((t,n)=>typeof n=="number"?t-n:(xt(e,"requires all arguments to be numbers"),t),e.args[0]))),Qje=new Re("neg",[{name:"a",type:"number"}],async e=>(e.args.length!==1&&xt(e,"requires one argument"),-e.options.a)),Yje=new Re("abs",[{name:"a",type:"number"}],async e=>(e.args.length!==1&&xt(e,"requires one argument"),Math.abs(e.options.a))),Xje=new Re("*","any",async e=>(e.args.length<2&&xt(e,"requires at least two arguments"),e.args.reduce((t,n)=>typeof n=="number"?t*n:(xt(e,"requires all arguments to be numbers"),t),1))),Zje=new Re("/","any",async e=>{e.args.length<2&&xt(e,"requires at least two arguments");const t=e.args[0]/e.args[1];return e.args.slice(2).reduce((n,r)=>typeof r=="number"?n/r:(xt(e,"requires all arguments to be numbers"),n),t)}),eCe=async e=>{const{prompt:t,choices:n}=e.staticOptions,r=[];for(const[,a]of n.entries()){const s=await y0(a.prompt);r.push(s)}e.options.choiceResults=r;const o=r.map((a,s)=>{var d;let c=!0;a.skillCheck&&(c=((d=a.skillCheck)==null?void 0:d.allowed)??!1);const l=yS().hasSeenChoice(t.code,n[s].prompt.code);return{flag:a.flag,seenBefore:l,choice:a.text,originalIndex:s,allowed:c}}).filter(a=>a.choice),i=await MV(t,o);return await oCe(e,i)};function tCe(e,t){t.branch||e.parserContext.error(t.line,`Choice option doesn't have any branch to go to (${t.code} - ${t.line})`);let n,r;const o=t.branch;return t.expression[1]==="roll"||t.expression[2]==="roll"?((!o[0].branch||!o[1].branch)&&e.parserContext.error(t.line,`Choice option with a skill roll needs success and failure branches (${t.code} - ${t.line})`),n={success:e.processCommandsFunction(e.parserContext,o[0].branch,t),failure:e.processCommandsFunction(e.parserContext,o[1].branch,t)}):r=e.processCommandsFunction(e.parserContext,o,t),{prompt:e.processCommandsFunction(e.parserContext,[t],t)[0],branch:r,skillBranches:n}}const nCe=(e,t)=>{let n=e.currentLine;ld("choice",[]);const{line:r}=e,o=t.command;(!r.branch||r.branch.length<2)&&e.parserContext.error(r.line,"Choice menu needs to have at least one option");const i=r.branch[0];i||e.parserContext.error(e.line.line,"Choice prompt is missing ");const s=r.branch.slice(1).map((c,l)=>(c.branch||e.parserContext.error(c.line,`Choice option doesn't have any branch to go to (${c.code})`),c=iCe(e.parserContext,c),tCe(e,c)));return o.staticOptions={prompt:e.processCommandsFunction(e.parserContext,[i],r)[0],choices:s},n++,{newLine:n}},rCe=Re.FromOptions({keyword:"choice",argTypes:[],runner:eCe,parser:nCe}),oCe=async(e,t)=>{const n=t,r=un(),{choices:o}=e.staticOptions,i=o[n],a=e.options.choiceResults[n],s=e.staticOptions.prompt;yS().trackChoice(s.code,i.prompt.code);let c=a.text,l;if(a.skillCheck?(c=null,nF(a.skillCheck.options).succeeded?l=i.skillBranches.success:l=i.skillBranches.failure):l=i.branch,c){const f={speaker:fo().playerCharacter,text:c,interactive:!1};cr().addDialog(f)}if(l){const f={currentIndex:0,branchData:{branch:l}};return await r.addAndRunBlock(f)}};function iCe(e,t){return{code:`choicePrompt ${t.code}`,indentation:t.indentation,line:t.line,branch:t.branch,expression:["choicePrompt",...t.expression]}}const aCe=new Re("choicePrompt","any",async e=>{const t=e.args;return t.length===1?sCe(t[0]):t.length===2?cCe(t):t.length>2?t[0]==="roll"||t[1]==="roll"?uCe(e,t):lCe(e,t):(xt(e,"Invalid choice prompt line"),{text:t[0]})});function sCe(e){return{text:e}}function cCe(e){return{text:e[1],flag:e[0]}}function lCe(e,t){const n=t[1]==="if"?1:2;if(t[n]!=="if")return xt(e,"Invalid choice prompt line"),{text:t[0]};const r=n===2;let o=r?t[1]:t[0],i=!0;t.length>n+1&&(i=t[n+1]),i||(o=null);const a={text:o};return r&&(a.flag=t[0]),a}function uCe(e,t){const n=t[0]==="roll"?0:1,r=n===1,o=n,i=t[o+1];let a={},s=o+2;Vz(i)?a={...Fz(i),id:i}:(a={id:i,skill:t[o+2],difficulty:t[o+3]},s=o+4);const c=t[s];s++;let l=!1,f=!1,u;t.length>s&&(t[s]==="if"?(f=!0,t.length<s+2&&xt(e,'Missing condition argument after "if" in choice with a skill check'),u=t[s+1]):(l=t[s],t.length>s+1&&(s++,t[s]==="if"?(f=!0,t.length<s+2&&xt(e,'Missing condition argument after "if" in choice with a skill check'),u=t[s+1]):xt(e,`Invalid argument after skill check mode: ${t[s]}. The next argument can only be an if condition.`)))),l==="hideAfterRoll"&&(a.hideAfterRoll=!0),l==="repeatable"&&(a.repeatable=!0);const d=Jr().getSkillCheck(i);if(d.hidden||f&&!u)return{text:null};const h=!d.happened||d.happened&&d.succeeded||a.repeatable,{difficultyText:p}=xve({skill:a.skill,skillCheckId:i,value:a.difficulty}),v={text:`${p} ${c}`,skillCheck:{allowed:h,options:a}};return r&&(v.flag=t[0]),v}const sq=Re.FromOptions({keyword:"text_field",argTypes:[{name:"prompt",type:"string"}],returnAfterPlayerAnswer:!0,runner:async e=>{const t={speaker:fo().gameCharacter,text:e.options.prompt,textField:!0,interactive:!0};cr().addDialog(t)}});sq.onPlayerAnswered=async(e,t)=>(typeof t!="string"&&xt(e,"The player's answer should be a string"),t);const fCe=Re.FromOptions({keyword:"text_field_prompt",argTypes:[{name:"prompt",type:"string"}],runner:async e=>{const t={speaker:fo().gameCharacter,text:e.options.prompt,textField:!0,interactive:!0};cr().addDialog(t)}}),dCe=new Re("random",[{name:"a",type:"number"},{name:"b",type:"number"}],async e=>{const{a:t,b:n}=e.options;return typeof t!="number"||typeof n!="number"?(xt(e,"random command needs two numbers as parameters"),0):Math.floor(Math.random()*(n-t+1))+t}),hCe=new Re("random_float",[{name:"a",type:"number"},{name:"b",type:"number"}],async e=>{const{a:t,b:n}=e.options;return typeof t!="number"||typeof n!="number"?(xt(e,"random_float command needs two numbers as parameters"),0):Math.random()*(n-t)+t}),pCe=new Re("random_from_args",[],async e=>{const t=e.args;return!t||!t.length?(xt(e,"random_from_args command needs at least one argument"),0):t[Math.floor(Math.random()*t.length)]}),mCe=new Re("random_from_array",[{name:"a",type:"any"}],async e=>{const{a:t}=e.options;return Array.isArray(t)?t[Math.floor(Math.random()*t.length)]:(xt(e,"random_from_array command needs an array as parameter"),0)}),vCe=new Re("concat","any",async e=>(e.args.length<2&&xt(e,"requires at least two arguments"),e.args.reduce((t,n)=>typeof n=="string"?`${t}${n}`:(xt(e,"requires all arguments to be strings"),t),""))),gCe=new Re("join","any",async e=>{const t=e.args[0];return e.args.length<3&&xt(e,"requires at least 3 arguments"),e.args.slice(1).reduce((n,r)=>typeof r=="string"?`${n}${t}${r}`:(xt(e,"requires all arguments to be strings"),n),"")}),yCe=Re.FromOptions({keyword:"min",argTypes:[{name:"min",type:"number"},{name:"value",type:"number"}],runner:async e=>{const{min:t,value:n}=e.options;return n<t?n:t}}),bCe=Re.FromOptions({keyword:"max",argTypes:[{name:"max",type:"number"},{name:"value",type:"number"}],runner:async e=>{const{max:t,value:n}=e.options;return n>t?n:t}}),wCe=Re.FromOptions({keyword:"clamp",argTypes:[{name:"min",type:"number"},{name:"max",type:"number"},{name:"value",type:"number"}],runner:async e=>{const{min:t,max:n,value:r}=e.options;return r<t?t:r>n?n:r}}),kCe=Re.FromOptions({keyword:"floor",argTypes:[{name:"value",type:"number"}],runner:async e=>{const{value:t}=e.options;return Math.floor(t)}}),xCe=Re.FromOptions({keyword:"ceil",argTypes:[{name:"value",type:"number"}],runner:async e=>{const{value:t}=e.options;return Math.ceil(t)}}),_Ce=Re.FromOptions({keyword:"round",argTypes:[{name:"value",type:"number"}],runner:async e=>{const{value:t}=e.options;return Math.round(t)}}),SCe=Re.FromOptions({keyword:"sqrt",argTypes:[{name:"value",type:"number"}],runner:async e=>{const{value:t}=e.options;return Math.sqrt(t)}}),jCe=Re.FromOptions({keyword:"^",argTypes:[{name:"base",type:"number"},{name:"exponent",type:"number"}],runner:async e=>{const{base:t,exponent:n}=e.options;return Math.pow(t,n)}}),CCe=new Re("create_sprite",[{name:"image",type:"string"},{name:"x",type:"number"},{name:"y",type:"number"},{name:"parent",type:"any",optional:!0}],async e=>{const t=Bi(),{x:n,y:r,image:o,parent:i}=e.options,a={x:n,y:r,image:o};return typeof i=="object"&&(a.parent=i),typeof i=="string"&&(a.parent=Bi().getObject(i)),t.createSprite(a)}),$Ce=new Re("create_object",[{name:"x",type:"number"},{name:"y",type:"number"},{name:"parent",type:"any",optional:!0}],async e=>{const t=Bi(),{x:n,y:r,parent:o}=e.options,i={x:n,y:r};return typeof o=="object"&&(i.parent=o),typeof o=="string"&&(i.parent=Bi().getObject(o)),t.createObject(i)}),TCe=new Re("delete_sprite",[{name:"sprite",type:"any"}],async e=>Bi().destroyObject(e.options.sprite)),OCe=Re.FromOptions({keyword:"empty_sprites",argTypes:[{name:"layer",type:"number",optional:!0}],runner:async e=>{const t=Bi(),{layer:n}=e.options;return typeof n=="number"?t.emptyLayer(n):t.emptyAllLayers()}}),ECe=Re.FromOptions({keyword:"shuffle",argTypes:[{name:"array",type:"any"}],runner:async e=>{const t=e.options.array;if(!Array.isArray(t)){xt(e,"requires an array argument");return}return JCe(t),t}}),ACe=Re.FromOptions({keyword:"push",argTypes:[{name:"array",type:"any"},{name:"value",type:"any"}],runner:async e=>{const{array:t,value:n}=e.options;if(!Array.isArray(t)){xt(e,"requires an array argument");return}return t.push(n),t}}),PCe=Re.FromOptions({keyword:"pop",argTypes:[{name:"array",type:"any"}],runner:async e=>{const{array:t}=e.options;if(!Array.isArray(t)){xt(e,"requires an array argument");return}return t.pop()}}),MCe=Re.FromOptions({keyword:"shift",argTypes:[{name:"array",type:"any"}],runner:async e=>{const{array:t}=e.options;if(!Array.isArray(t)){xt(e,"requires an array argument");return}return t.shift()}}),ICe=Re.FromOptions({keyword:"unshift",argTypes:[{name:"array",type:"any"},{name:"value",type:"any"}],runner:async e=>{const{array:t,value:n}=e.options;if(!Array.isArray(t)){xt(e,"requires an array argument");return}return t.unshift(n),t}}),NCe=Re.FromOptions({keyword:"array_join",argTypes:[{name:"array",type:"any"},{name:"separator",type:"string",optional:!0}],runner:async e=>{const{array:t,separator:n}=e.options;if(!Array.isArray(t)){xt(e,"requires an array argument");return}if(typeof n<"u"&&typeof n!="string"){xt(e,"array join string separator must be a string");return}return t.join(n),t}}),RCe=Re.FromOptions({keyword:"array_concat",argTypes:[{name:"array",type:"any"},{name:"rest",type:"rest",optional:!0}],runner:async e=>{const{array:t}=e.options,n=e.args;if(!Array.isArray(t)){xt(e,"requires an array argument");return}for(const r of n)if(!Array.isArray(r)){xt(e,"All concat arguments should be arrays");return}return t.concat(...n.slice(1))}}),DCe=Re.FromOptions({keyword:"includes",argTypes:[{name:"array",type:"any"},{name:"searchElement",type:"string"}],runner:async e=>{const{array:t,searchElement:n}=e.options;return Array.isArray(t)||xt(e,"requires an array argument"),typeof n>"u"&&xt(e,"requires a search element argument"),t.includes(n)}}),LCe=Re.FromOptions({keyword:"reverse",argTypes:[{name:"array",type:"any"}],runner:async e=>{const{array:t}=e.options;return Array.isArray(t)||xt(e,"requires an array argument"),t.reverse(),t}}),BCe=Re.FromOptions({keyword:"slice",argTypes:[{name:"array",type:"any"},{name:"start",type:"number"},{name:"end",type:"number",optional:!0}],runner:async e=>{const{array:t,start:n,end:r}=e.options;return Array.isArray(t)||xt(e,"requires an array argument"),typeof n!="number"&&xt(e,"requires a start index argument"),typeof r<"u"&&typeof r!="number"&&xt(e,"end index argument must be a number if present"),t.slice(n,r)}}),FCe=Re.FromOptions({keyword:"splice",argTypes:[{name:"array",type:"any"},{name:"start",type:"number"},{name:"end",type:"number",optional:!0}],runner:async e=>{const{array:t,start:n,end:r}=e.options;return Array.isArray(t)||xt(e,"requires an array argument"),typeof n!="number"&&xt(e,"requires a start index argument"),typeof r<"u"&&typeof r!="number"&&xt(e,"end index argument must be a number if present"),t.splice(n,r)}}),VCe=Re.FromOptions({keyword:"array_find_index",argTypes:[{name:"array",type:"any"},{name:"predicateLabel",type:"string"},{name:"rest",type:"rest",optional:!0}],runner:async e=>{const{array:t,predicateLabel:n}=e.options;Array.isArray(t)||xt(e,"requires an array argument");for(const[r,o]of t.entries())if(await un().runLabelFunction(n,o,r,t,...e.args.slice(2))===!0)return r;return-1}}),zCe=Re.FromOptions({keyword:"array_find",argTypes:[{name:"array",type:"any"},{name:"predicateLabel",type:"string"},{name:"rest",type:"rest",optional:!0}],runner:async e=>{const{array:t,predicateLabel:n}=e.options;Array.isArray(t)||xt(e,"requires an array argument");for(const[r,o]of t.entries())if(await un().runLabelFunction(n,o,r,t,...e.args.slice(2))===!0)return o;return null}}),qCe=Re.FromOptions({keyword:"array_filter",argTypes:[{name:"array",type:"any"},{name:"predicateLabel",type:"string"},{name:"rest",type:"rest",optional:!0}],runner:async e=>{const{array:t,predicateLabel:n}=e.options;Array.isArray(t)||xt(e,"requires an array argument");const r=[];for(const[o,i]of t.entries())await un().runLabelFunction(n,i,o,t,...e.args.slice(2))===!0&&r.push(i);return r}}),UCe=Re.FromOptions({keyword:"array_map",argTypes:[{name:"array",type:"any"},{name:"mapperLabel",type:"string"},{name:"rest",type:"rest",optional:!0}],runner:async e=>{const{array:t,mapperLabel:n}=e.options;Array.isArray(t)||xt(e,"requires an array argument");const r=[];for(const[o,i]of t.entries()){const a=await un().runLabelFunction(n,i,o,t,...e.args.slice(2));r.push(a)}return r}}),HCe=Re.FromOptions({keyword:"array_reduce",argTypes:[{name:"array",type:"any"},{name:"reducerLabel",type:"string"},{name:"initValue",type:"any"},{name:"rest",type:"rest",optional:!0}],runner:async e=>{const{array:t,reducerLabel:n,initValue:r}=e.options;Array.isArray(t)||xt(e,"requires an array argument");let o=r;for(const[i,a]of t.entries())o=await un().runLabelFunction(n,o,a,i,t,...e.args.slice(3));return o}}),WCe=Re.FromOptions({keyword:"array_some",argTypes:[{name:"array",type:"any"},{name:"predicateLabel",type:"string"},{name:"rest",type:"rest",optional:!0}],runner:async e=>{const{array:t,predicateLabel:n}=e.options;Array.isArray(t)||xt(e,"requires an array argument");for(const[r,o]of t.entries())if(await un().runLabelFunction(n,o,r,t,...e.args.slice(2))===!0)return!0;return!1}}),KCe=Re.FromOptions({keyword:"array_every",argTypes:[{name:"array",type:"any"},{name:"predicateLabel",type:"string"},{name:"rest",type:"rest",optional:!0}],runner:async e=>{const{array:t,predicateLabel:n}=e.options;Array.isArray(t)||xt(e,"requires an array argument");for(const[r,o]of t.entries())if(await un().runLabelFunction(n,o,r,t,...e.args.slice(2))!==!0)return!1;return!0}}),GCe=Re.FromOptions({keyword:"array_entries",argTypes:[{name:"array",type:"any"}],runner:async e=>{const{array:t}=e.options;return Array.isArray(t)||xt(e,"requires an array argument"),t.entries()}});function JCe(e){for(let t=e.length-1;t>0;t--){const n=Math.floor(Math.random()*(t+1));[e[t],e[n]]=[e[n],e[t]]}}const pd={keyframes:{"narrat-screenshake":[{transform:"translateX(0)"},{transform:"translateX(5px)"},{transform:"translateX(-5px)"},{transform:"translateX(5px)"},{transform:"translateX(0)"}]},animations:{"narrat-screenshake":{keyframes:"narrat-screenshake",options:{duration:150,iterations:3}}}};function QCe(e){return typeof e=="string"?document.querySelector(e):e}function YCe(e){if(typeof e=="string"){const t=Lz();t.keyframes[e]?e=t.keyframes[e]:pd.keyframes[e]?e=pd.keyframes[e]:(St(`[Animation] Animation not found: ${e}`),e=pd.keyframes["narrat-screenshake"])}return e}function XCe(e){let t;if(typeof e=="string"){const n=Lz();n.animations[e]?t=n.animations[e]:pd.animations[e]?t=pd.animations[e]:(St(`[Animation] Animation not found: ${e}`),t=pd.animations["narrat-screenshake"])}else t=e;return ZCe(t)}function ZCe(e){return{keyframes:[...YCe(e.keyframes)],options:{...e.options}}}async function cq(e,t,n){return new Promise(r=>{const o=QCe(e);o||(St(`[Animation] Element not found: ${e}`),r({}));const i=XCe(t);n&&Object.assign(i.options,n),o.animate(i.keyframes,i.options).addEventListener("finish",r)})}const e$e=Re.FromOptions({keyword:"load_data",argTypes:[{name:"url",type:"string"}],runner:async e=>{const{url:t}=e.options;return await up(K0(t))}}),t$e=Re.FromOptions({keyword:"change_player_character",argTypes:[{name:"character",type:"string"}],runner:async e=>{const{character:t}=e.options;fo().config.characters.config.playerCharacter=t}}),n$e=Re.FromOptions({keyword:"change_game_character",argTypes:[{name:"character",type:"string"}],runner:async e=>{const{character:t}=e.options;fo().config.characters.config.gameCharacter=t}}),r$e=Re.FromOptions({keyword:"json_stringify",argTypes:[{name:"value",type:"any"}],runner:async e=>{const{value:t}=e.options;return JSON.stringify(t)}}),o$e=Re.FromOptions({keyword:"json_parse",argTypes:[{name:"value",type:"string"}],runner:async e=>{const{value:t}=e.options;return JSON.parse(t)}}),i$e=Re.FromOptions({keyword:"set_dialog_panel_mode",argTypes:[{name:"mode",type:"string"}],runner:async e=>{const{mode:t}=e.options;Gr().dialogPanelMode=t}}),lq=[{name:"element",type:"string"},{name:"animation",type:"string"},{name:"duration",optional:!0,type:"number"},{name:"iterations",optional:!0,type:"number"}];function uq(e){const{element:t,animation:n,duration:r,iterations:o}=e.options,i={};return o&&(i.iterations=o),r&&(i.duration=r),i}const a$e=Re.FromOptions({keyword:"animate",argTypes:lq,runner:async e=>{const{element:t,animation:n}=e.options,r=uq(e);cq(t,n,r)}}),s$e=Re.FromOptions({keyword:"animate_wait",argTypes:lq,runner:async e=>{const{element:t,animation:n}=e.options;await cq(t,n,uq(e))}}),c$e=Re.FromOptions({keyword:"time_now",argTypes:[],runner:async e=>Date.now()}),l$e=Re.FromOptions({keyword:"total_playtime",argTypes:[],runner:async e=>sn().totalPlayTime}),u$e=Re.FromOptions({keyword:"session_playtime",argTypes:[],runner:async e=>sn().sessionPlayTime}),f$e=Re.FromOptions({keyword:"to_days",argTypes:[{name:"time",type:"number"}],runner:async e=>Math.floor(e.options.time/864e5)}),d$e=Re.FromOptions({keyword:"to_hours",argTypes:[{name:"time",type:"number"}],runner:async e=>Math.floor(e.options.time/36e5)}),h$e=Re.FromOptions({keyword:"to_minutes",argTypes:[{name:"time",type:"number"}],runner:async e=>Math.floor(e.options.time/6e4)}),p$e=Re.FromOptions({keyword:"to_seconds",argTypes:[{name:"time",type:"number"}],runner:async e=>Math.floor(e.options.time/1e3)}),m$e=new Re("unlock_achievement",[{name:"id",type:"string"}],async e=>{const{id:t}=e.options;xu().unlock(t)}),v$e=new Re("has_achievement?",[{name:"id",type:"string"}],async e=>{const{id:t}=e.options;return xu().hasAchievement(t)}),g$e=Re.FromOptions({keyword:"get_setting",argTypes:[{name:"setting",type:"string"}],runner:async e=>{const{setting:t}=e.options;return t||xt(e,"get_setting command needs a setting id"),Es().getSetting(t)}}),y$e=Re.FromOptions({keyword:"set_setting",argTypes:[{name:"setting",type:"string"},{name:"value",type:"any"}],runner:async e=>{const{setting:t,value:n}=e.options;t||xt(e,"set_setting command needs a setting id"),Es().setSetting(t,n)}}),b$e=Re.FromOptions({keyword:"object_entries",argTypes:[{name:"obj",type:"any"}],runner:async e=>{const t=e.options.obj;return typeof t!="object"?(xt(e,"Requires an object argument."),[]):Object.entries(t)}}),w$e=Re.FromOptions({keyword:"object_keys",argTypes:[{name:"obj",type:"any"}],runner:async e=>{const t=e.options.obj;return typeof t!="object"?(xt(e,"Requires an object argument."),[]):Object.keys(t)}}),k$e=Re.FromOptions({keyword:"object_values",argTypes:[{name:"obj",type:"any"}],runner:async e=>{const t=e.options.obj;return typeof t!="object"?(xt(e,"Requires an object argument."),[]):Object.values(t)}}),x$e=Re.FromOptions({keyword:"object_has",argTypes:[{name:"obj",type:"any"},{name:"key",type:"string"}],runner:async e=>{const{obj:t,key:n}=e.options;return typeof t!="object"?(xt(e,"Requires an object argument."),!1):Object.hasOwn(t,n)}}),_$e=Re.FromOptions({keyword:"for_of",argTypes:[{name:"target",type:"any"},{name:"predicateLabel",type:"string"},{name:"rest",type:"rest",optional:!0}],runner:async e=>{const{target:t,predicateLabel:n}=e.options;if(typeof t!="object")return xt(e,"Requires an object argument."),!1;for(const r of t)await un().runLabelFunction(n,r,...e.args.slice(2))}}),S$e=Re.FromOptions({keyword:"for_in",argTypes:[{name:"target",type:"any"},{name:"predicateLabel",type:"string"},{name:"rest",type:"rest",optional:!0}],runner:async e=>{const{target:t,predicateLabel:n}=e.options;if(typeof t!="object")return xt(e,"Requires an object argument."),!1;for(const r in t)await un().runLabelFunction(n,r,t[r],...e.args.slice(2))}}),j$e=Re.FromOptions({keyword:"change_scene",argTypes:[{name:"scene",type:"string"},{name:"rest",type:"rest",optional:!0}],runner:async e=>{const{scene:t}=e.options;await _i().changeScene(t,C$e(e.args.slice(1)))}});function C$e(e){const t={};let n=0;for(;n<e.length&&!(n+1>=e.length);){const r=e[n],o=e[n+1];t[r]=o,n+=2}return t}function $$e(e){e.addCommand(rCe),e.addCommand(aCe),e.addCommand(Dje),e.addCommand(LSe),e.addCommand(BSe),e.addCommand(FSe),e.addCommand(VSe),e.addCommand(zSe),e.addCommand(Rje),e.addCommand(Mje),e.addCommand(Ije),e.addCommand(Nje),e.addCommand(nje),e.addCommand(eje),e.addCommand(tje),e.addCommand(rje),e.addCommand(lje),e.addCommand(sje),e.addCommand(cje),e.addCommand(CCe),e.addCommand($Ce),e.addCommand(TCe),e.addCommand(OCe),e.addCommand(Pje),e.addCommand(Lje),e.addCommand(Bje),e.addCommand(Fje),e.addCommand(Vje),e.addCommand(zje),e.addCommand(qje),e.addCommand(Uje),e.addCommand(Hje),e.addCommand(Wje),e.addCommand(Kje),e.addCommand(Gje),e.addCommand(Jje),e.addCommand(Xje),e.addCommand(Zje),e.addCommand(Qje),e.addCommand(Yje),e.addCommand(aje),e.addCommand(ije),e.addCommand(hje),e.addCommand(uje),e.addCommand(fje),e.addCommand(qSe),e.addCommand(USe),e.addCommand(HSe),e.addCommand(WSe),e.addCommand(KSe),e.addCommand(GSe),e.addCommand(JSe),e.addCommand(YSe),e.addCommand(QSe),e.addCommand(XSe),e.addCommand(wje),e.addCommand(kje),e.addCommand(xje),e.addCommand(_je),e.addCommand(Eje),e.addCommand(Aje),e.addCommand(Sje),e.addCommand(jje),e.addCommand(Cje),e.addCommand($je),e.addCommand(Tje),e.addCommand(Oje),e.addCommand(pje),e.addCommand(mje),e.addCommand(yje),e.addCommand(bje),e.addCommand(vje),e.addCommand(gje),e.addCommand(OSe),e.addCommand(ESe),e.addCommand(ASe),e.addCommand(ISe),e.addCommand(DSe),e.addCommand(NSe),e.addCommand(RSe),e.addCommand(PSe),e.addCommand(MSe),e.addCommand(sq),e.addCommand(fCe),e.addCommand(dCe),e.addCommand(hCe),e.addCommand(pCe),e.addCommand(mCe),e.addCommand(vCe),e.addCommand(gCe),e.addCommand(yCe),e.addCommand(bCe),e.addCommand(wCe),e.addCommand(kCe),e.addCommand(_Ce),e.addCommand(xCe),e.addCommand(SCe),e.addCommand(jCe),e.addCommand(ECe),e.addCommand(ACe),e.addCommand(PCe),e.addCommand(MCe),e.addCommand(ICe),e.addCommand(NCe),e.addCommand(RCe),e.addCommand(DCe),e.addCommand(LCe),e.addCommand(BCe),e.addCommand(FCe),e.addCommand(VCe),e.addCommand(zCe),e.addCommand(qCe),e.addCommand(UCe),e.addCommand(HCe),e.addCommand(WCe),e.addCommand(KCe),e.addCommand(GCe),e.addCommand(w$e),e.addCommand(k$e),e.addCommand(b$e),e.addCommand(x$e),e.addCommand(_$e),e.addCommand(S$e),e.addCommand(e$e),e.addCommand(t$e),e.addCommand(n$e),e.addCommand(r$e),e.addCommand(o$e),e.addCommand(i$e),e.addCommand(a$e),e.addCommand(s$e),e.addCommand(c$e),e.addCommand(l$e),e.addCommand(u$e),e.addCommand(f$e),e.addCommand(d$e),e.addCommand(h$e),e.addCommand(p$e),e.addCommand(m$e),e.addCommand(v$e),e.addCommand(y$e),e.addCommand(g$e),e.addCommand(Wxe),e.addCommand(j$e)}const T$e=b.defineComponent({data(){return{muted:!1,volumes:[],modeNames:{master:"Master volume:",music:"Music:",ambiant:"Ambiant:",sound:"Sound effects:"}}},mounted(){const e=Po(),t=Ts.Howler.volume();this.volumes.push({mode:"master",volume:t}),e.modes.forEach((n,r)=>{this.volumes.push({mode:r,volume:e.modes.get(r).options.volume})})},methods:{changeVolume(e,t){const n=t.target;e==="master"?Po().setMasterVolume(n.value):Po().setModeVolume(e,n.value)},toggleMute(){this.muted?(Ts.Howler.mute(!1),this.muted=!1):(Ts.Howler.mute(!0),this.muted=!0)}}}),O$e={class:"volume-controls"},E$e=b.createElementVNode("h3",{class:"subtitle"},"Volume",-1),A$e={for:"volume",class:"volume-label"},P$e=["onUpdate:modelValue","onChange"];function M$e(e,t,n,r,o,i){return b.openBlock(),b.createElementBlock("div",O$e,[E$e,(b.openBlock(!0),b.createElementBlock(b.Fragment,null,b.renderList(e.volumes,(a,s)=>(b.openBlock(),b.createElementBlock("div",{class:"volume-control",key:a.mode},[b.createElementVNode("label",A$e,b.toDisplayString(e.modeNames[a.mode]),1),b.withDirectives(b.createElementVNode("input",{ref_for:!0,ref:"slider",class:"volume-slider",type:"range",id:"volume",name:"volume",min:"0",max:"1",step:"0.1","onUpdate:modelValue":c=>e.volumes[s].volume=c,onChange:c=>e.changeVolume(a.mode,c)},null,40,P$e),[[b.vModelText,e.volumes[s].volume]])]))),128))])}const I$e=Xa(T$e,[["render",M$e]]),N$e={class:"settings-widget-container"},R$e=["for","id"],D$e=["id","name","min","max","step"],L$e=["id","name"],B$e=["id","name"],F$e={class:"mx-8"},V$e={class:"text-left setting-description"},z$e=b.createElementVNode("hr",{class:"h-px my-8 bg-gray-200 border-0 dark:bg-gray-700 setting-separator"},null,-1),q$e=b.defineComponent({__name:"setting-widget",props:{settingId:{}},setup(e){const t=e,n=Es(),r=b.computed(()=>n.getSetting(t.settingId)),o=b.ref(r.value),i=b.computed(()=>n.getSettingSchema(t.settingId));function a(s){let c=s;rB(i.value)&&(c=Math.round(c)),n.setSetting(t.settingId,c)}return b.watch(o,s=>{a(s)}),(s,c)=>(b.openBlock(),b.createElementBlock(b.Fragment,null,[b.createElementVNode("div",N$e,[b.createElementVNode("label",{for:s.settingId,class:"setting-label",id:`setting-label-${s.settingId}`},b.toDisplayString(i.value.name),9,R$e),b.unref(Fve)(i.value)||b.unref(rB)(i.value)?b.withDirectives((b.openBlock(),b.createElementBlock("input",{key:0,ref:"slider",class:"number-slider setting-slider",type:"range",id:`setting-slider-${s.settingId}`,name:s.settingId,min:i.value.minValue,max:i.value.maxValue,step:i.value.step,"onUpdate:modelValue":c[0]||(c[0]=l=>o.value=l)},null,8,D$e)),[[b.vModelText,o.value]]):b.unref(Vve)(i.value)?b.withDirectives((b.openBlock(),b.createElementBlock("input",{key:1,type:"checkbox",class:"setting-checkbox",id:`setting-checkbox-${s.settingId}`,name:s.settingId,"onUpdate:modelValue":c[1]||(c[1]=l=>o.value=l)},null,8,L$e)),[[b.vModelCheckbox,o.value]]):b.unref(zve)(i.value)?b.withDirectives((b.openBlock(),b.createElementBlock("input",{key:2,type:"text",class:"setting-text",id:`setting-text-${s.settingId}`,name:s.settingId,"onUpdate:modelValue":c[2]||(c[2]=l=>o.value=l)},null,8,B$e)),[[b.vModelText,o.value]]):b.createCommentVNode("",!0),b.createElementVNode("span",F$e,b.toDisplayString(o.value),1)]),b.createElementVNode("p",V$e,b.toDisplayString(i.value.description),1),z$e],64))}}),U$e={class:"container mx-auto settings-menu-container"},H$e=b.createElementVNode("h2",{class:"settings-menu-title subtitle text-center"},"Settings",-1),W$e=b.defineComponent({__name:"settings-menu",setup(e){const t=Es(),n=b.computed(()=>t.getAllSettingSchemas());return(r,o)=>(b.openBlock(),b.createElementBlock("div",U$e,[H$e,(b.openBlock(!0),b.createElementBlock(b.Fragment,null,b.renderList(n.value,(i,a)=>(b.openBlock(),b.createBlock(q$e,{settingId:a,key:a},null,8,["settingId"]))),128))]))}}),K$e={class:"menu-content"},G$e=b.defineComponent({__name:"MainMenu",props:{inputListener:{}},emits:["close"],setup(e,{emit:t}){const n=e,r=t,o=b.ref(null),i=b.ref(null);function a(){window.close()}function s(){mV(),c()}function c(){r("close")}function l(){const f=Su(sn().playTime.start,sn().playTime.previousPlaytime);return ty(f/1e3)}return b.onMounted(()=>{i.value=dc({mode:"list",container:o,listener:n.inputListener,onChosen:f=>{f===0?s():f===1&&a()}}),i.value.mount()}),b.onUnmounted(()=>{i.value&&(i.value.disable(),i.value=null)}),(f,u)=>(b.openBlock(),b.createElementBlock("div",K$e,[b.createElementVNode("h3",null,"Play time: "+b.toDisplayString(l()),1),b.createVNode(I$e),b.createElementVNode("div",{ref_key:"mainActions",ref:o},[b.createElementVNode("button",{class:"button title quit-button",onClick:s}," Main Menu "),b.createElementVNode("button",{class:"button title quit-button",onClick:a},"Exit")],512),b.createVNode(W$e)]))}}),J$e={class:"sub-tabs-controller"},Q$e={key:0,class:"sub-tabs-controller__tabs"},Y$e={key:1,class:"sub-tab-content"},X$e={key:2},Z$e=[b.createElementVNode("div",{class:"sub-tab-content__empty"},[b.createElementVNode("p",null,"No tab selected")],-1)],eTe=b.defineComponent({__name:"SubTabController",props:{tabs:{},defaultTab:{},inputListener:{}},emits:["tab-change","close"],setup(e,{emit:t}){const n=t,r=e,o=b.ref(r.defaultTab);function i(s){o.value=s,n("tab-change",s)}const a=b.computed(()=>r.tabs[o.value]);return b.onMounted(()=>{r.inputListener.actions.subPreviousTab={press:()=>{o.value>0&&i(o.value-1)}},r.inputListener.actions.subNextTab={press:()=>{o.value<r.tabs.length-1&&i(o.value+1)}}}),b.onUnmounted(()=>{delete r.inputListener.actions.subPreviousTab,delete r.inputListener.actions.subNextTab}),(s,c)=>(b.openBlock(),b.createElementBlock("div",J$e,[s.tabs.length>1?(b.openBlock(),b.createElementBlock("div",Q$e,[(b.openBlock(!0),b.createElementBlock(b.Fragment,null,b.renderList(s.tabs,(l,f)=>(b.openBlock(),b.createBlock(wV,{key:l.id,tab:l,active:f===o.value,onClick:()=>i(f)},null,8,["tab","active","onClick"]))),128))])):b.createCommentVNode("",!0),a.value?(b.openBlock(),b.createElementBlock("div",Y$e,[a.value?(b.openBlock(),b.createBlock(b.resolveDynamicComponent(a.value.component),b.mergeProps({key:a.value.id,inputListener:s.inputListener},a.value.extraProps,{onClose:c[0]||(c[0]=l=>s.$emit("close"))}),null,16,["inputListener"])):b.createCommentVNode("",!0)])):(b.openBlock(),b.createElementBlock("div",X$e,Z$e))]))}}),tTe=["onClick"],nTe={class:"item-title"},rTe={class:"item-amount"},oTe=b.defineComponent({__name:"inventory-section",props:{items:{},title:{},id:{},inputListener:{}},emits:["chosen"],setup(e,{emit:t}){const n=e,r=b.ref(null),o=b.ref(null),i=t;function a(l){i("chosen",l)}function s(l){return{backgroundImage:`url(${ci(Ja(l).icon)})`}}function c(l){return Ja(l).name}return b.onMounted(()=>{o.value=dc({mode:"grid",listener:n.inputListener,columns:3,container:r,onChosen:l=>{a(n.items[l].id)}}),o.value.mount()}),b.onUnmounted(()=>{o.value&&(o.value.disable(),o.value=null)}),(l,f)=>(b.openBlock(),b.createElementBlock("div",{class:b.normalizeClass(["inventory-section",`section-${n.id}`])},[b.createElementVNode("h3",null,b.toDisplayString(l.title),1),b.createElementVNode("div",{class:"inventory-section-items",ref_key:"itemsContainer",ref:r},[(b.openBlock(!0),b.createElementBlock(b.Fragment,null,b.renderList(l.items,u=>(b.openBlock(),b.createElementBlock("button",{onClick:()=>a(u.id),class:b.normalizeClass(["item-display",`item-${u.id}`]),style:b.normalizeStyle(s(u.id)),key:u.id},[b.createElementVNode("h3",nTe,b.toDisplayString(c(u.id)),1),b.createElementVNode("h3",rTe,b.toDisplayString(u.amount),1)],14,tTe))),128))],512)],2))}}),iTe={class:"flex flex-row item-description-container"},aTe={class:"flex item-left"},sTe={class:"flex item-right"},cTe=b.createElementVNode("hr",{class:"hr-solid"},null,-1),lTe=b.defineComponent({__name:"item-details",props:{item:{}},emits:["use","close"],setup(e,{emit:t}){const n=e,r=b.ref(null),o=b.computed(()=>Ja(n.item.id)),i=b.computed(()=>({backgroundImage:`url(${ci(o.value.icon)})`})),a=t,s=b.computed(()=>Io().canUseItem(n.item));function c(){s.value&&a("use")}function l(){a("close")}return b.onMounted(()=>{r.value=xr().registerInputListener("item-details",{continue:{press:()=>{s.value&&c()}},cancel:{press:()=>{l()}}})}),b.onUnmounted(()=>{r.value&&(xr().unregisterInputListener(r.value),r.value=null)}),(f,u)=>(b.openBlock(),b.createElementBlock("div",null,[b.createElementVNode("div",iTe,[b.createElementVNode("div",aTe,[b.createElementVNode("div",{class:"item-display",style:b.normalizeStyle(i.value)},null,4)]),b.createElementVNode("div",sTe,[b.createElementVNode("h2",null,b.toDisplayString(o.value.name),1),cTe,b.createElementVNode("h3",null,"Amount: "+b.toDisplayString(f.item.amount),1),b.createElementVNode("p",null,b.toDisplayString(o.value.description),1),b.createElementVNode("button",{onClick:c,class:b.normalizeClass(["button",s.value?"":"disabled"])}," Use ",2)])]),b.createElementVNode("button",{class:"button",onClick:l},b.toDisplayString("<--"))]))}}),uTe={key:0},fTe={key:2},dTe=[b.createElementVNode("h2",null,"The inventory is empty!",-1)],hTe=b.defineComponent({__name:"inventory-ui",props:{section:{},inputListener:{}},emits:["close"],setup(e,{emit:t}){const n=Io(),r=b.computed(()=>n.items),o=b.ref(!1),i=b.computed(()=>o.value?r.value[o.value]:null);function a(){No().closeMenu()}function s(f){o.value=f}function c(){o.value=!1}function l(){n.useItem(i.value)&&a()}return(f,u)=>!i.value&&f.section.items.length>0?(b.openBlock(),b.createElementBlock("div",uTe,[b.createVNode(oTe,{items:f.section.items,title:f.section.title,inputListener:f.inputListener,id:f.section.id,onChosen:s},null,8,["items","title","inputListener","id"])])):typeof o.value=="string"?(b.openBlock(),b.createBlock(lTe,{key:1,item:r.value[o.value],onUse:l,onClose:c},null,8,["item"])):(b.openBlock(),b.createElementBlock("div",fTe,dTe))}}),pTe=b.defineComponent({__name:"InventoryTab",props:{inputListener:{}},setup(e){const t=Io(),n=b.computed(()=>t.items),r=b.computed(()=>Object.values(n.value).filter(a=>a.amount>0?!0:!!Ja(a.id).showIfEmpty)),o=b.computed(()=>{const a=pr().items.categories,s=[];if(a.length>1){const c={id:"all",title:"All",items:r.value};s.push(c)}for(const c in a){const l=a[c],f=l.id,u=r.value.filter(d=>Ja(d.id).category===f);s.push({id:f,title:l.title,items:u})}return s}),i=b.computed(()=>{const a=[];return o.value.forEach(s=>{a.push({id:s.id,label:s.title,component:hTe,extraProps:{section:s}})}),a});return(a,s)=>(b.openBlock(),b.createElementBlock("div",null,[b.createVNode(eTe,{tabs:i.value,defaultTab:0,inputListener:a.inputListener},null,8,["tabs","inputListener"])]))}}),mTe=["id"],vTe={class:"obtained-status"},gTe={class:"achievement-title"},yTe={class:"achievement-description"},bTe=b.defineComponent({__name:"achievement-tile",props:{achievement:{}},setup(e){const t=e,n=xu(),r=b.computed(()=>n.getExistingAchievement(t.achievement)),o=b.computed(()=>cS(t.achievement)),i=Op().secretAchievements??{censorName:!0,censorDescription:!0},a=b.computed(()=>{let f=r.value.unlocked?o.value.icon:o.value.lockedIcon;return f||(f=Op().defaultAchievementIcon),{backgroundImage:`url(${ci(f)})`}}),s=b.computed(()=>!o.value.secret||!i.censorName?o.value.name:"Hidden Achievement"),c=b.computed(()=>!o.value.secret||!i.censorDescription?o.value.description:"This achievement is hidden. Complete it to discover more."),l=b.computed(()=>r.value.unlocked?`Obtained ${new Date(r.value.unlockTime).toLocaleDateString()}`:"Not obtained yet");return(f,u)=>(b.openBlock(),b.createElementBlock("div",{class:"achievement-display tile",id:`achievement-${f.achievement}`},[b.createElementVNode("div",{class:"achievement-icon",style:b.normalizeStyle(a.value)},null,4),b.createElementVNode("p",vTe,b.toDisplayString(l.value),1),b.createElementVNode("h3",gTe,b.toDisplayString(s.value),1),b.createElementVNode("p",yTe,b.toDisplayString(c.value),1)],8,mTe))}}),wTe={class:"achievements-section-achievements"},kTe=b.defineComponent({__name:"achievements-section",props:{achievements:{},title:{},id:{}},setup(e){const t=e;return(n,r)=>(b.openBlock(),b.createElementBlock("div",{class:b.normalizeClass(["achievements-section",`section-${t.id}`])},[b.createElementVNode("h3",null,b.toDisplayString(n.title),1),b.createElementVNode("div",wTe,[(b.openBlock(!0),b.createElementBlock(b.Fragment,null,b.renderList(n.achievements,o=>(b.openBlock(),b.createBlock(bTe,{achievement:o.id,key:o.id},null,8,["achievement"]))),128))])],2))}}),xTe=b.defineComponent({setup(){const e=xu(),t=cr(),n=b.computed(()=>e.achievements),r=b.computed(()=>t.currentDialog.choices);return{achievements:n,currentlyChoosing:r}},emits:["close"],data(){return{chosenId:!1}},mounted(){},methods:{close(){this.$emit("close")},clickAchievement(e){this.chosenId=e},closeAchievement(){this.chosenId=!1}},computed:{achievementsToDisplay(){return Object.values(this.achievements)},chosenAchievement(){return this.chosenId?this.achievements[this.chosenId]:null},chosenAchievementConf(){return this.chosenId?this.achievementConf[this.chosenId]:null},achievementConf(){return pr().achievements.achievements},sections(){const e=pr().achievements.categories,t=[];return this.achievementsToDisplay.reduce((r,o)=>{const i=cS(o.id).category??"default",a=e.find(c=>c.id===i);if(!a)return St(`Unknown category ${i}`),r;let s=r.find(c=>c.id===i);return s||(s={id:i,title:a.title,achievements:[]},r.push(s)),s.achievements.push(o),r},t)}},components:{AchievementsSection:kTe}}),_Te={key:0},STe={key:1},jTe=[b.createElementVNode("h2",null,"The achievements section is empty!",-1)];function CTe(e,t,n,r,o,i){const a=b.resolveComponent("AchievementsSection");return Object.keys(e.achievementsToDisplay).length>0?(b.openBlock(),b.createElementBlock("div",_Te,[(b.openBlock(!0),b.createElementBlock(b.Fragment,null,b.renderList(e.sections,s=>(b.openBlock(),b.createBlock(a,{key:s.id,achievements:s.achievements,title:s.title,id:s.id,onChosen:e.clickAchievement},null,8,["achievements","title","id","onChosen"]))),128))])):(b.openBlock(),b.createElementBlock("div",STe,jTe))}const $Te=Xa(xTe,[["render",CTe]]),TTe={class:"quest-display"},OTe={class:"quest-title"},ETe={class:"quest-description"},ATe={key:0,class:"quest-objectives-container list-disc"},PTe=b.defineComponent({__name:"QuestDetails",props:{quest:{}},setup(e){const t=e,n=b.computed(()=>vc(t.quest.id));function r(s){return Ep(t.quest.id,s)}const o=b.computed(()=>{switch(t.quest.state){case"hidden":return" Hidden";case"unlocked":return"";case"completed":return" (Completed)";default:return" Unknown"}}),i=b.computed(()=>t.quest.ending?zz(t.quest.id,t.quest.ending).description:t.quest.succeeded&&n.value.succeededDescription?n.value.succeededDescription:!t.quest.succeeded&&n.value.failedDescription?n.value.failedDescription:n.value.description),a=b.computed(()=>Object.values(t.quest.objectives).filter(s=>s.state!=="hidden"));return(s,c)=>(b.openBlock(),b.createElementBlock("div",TTe,[b.createElementVNode("div",{class:b.normalizeClass(["quest-header",s.quest.state==="completed"?"quest-completed":"quest-in-progress"])},[b.createElementVNode("h3",OTe,b.toDisplayString(n.value.title)+" "+b.toDisplayString(o.value),1)],2),b.createElementVNode("p",ETe,b.toDisplayString(i.value),1),s.quest.state!=="completed"?(b.openBlock(),b.createElementBlock("ul",ATe,[(b.openBlock(!0),b.createElementBlock(b.Fragment,null,b.renderList(a.value,l=>(b.openBlock(),b.createElementBlock("li",{class:"quest-objective-display",key:l.id},[b.createElementVNode("p",{class:b.normalizeClass(["quest-objective-description",l.state==="completed"?"quest-objective-completed":"quest-objctive-in-progress"])},b.toDisplayString(r(l.id).description),3)]))),128))])):b.createCommentVNode("",!0)]))}}),MTe={class:"quest-list-title"},ITe=b.defineComponent({__name:"QuestDisplay",props:{quest:{}},setup(e){const t=e,n=b.computed(()=>vc(t.quest.id));return(r,o)=>(b.openBlock(),b.createElementBlock("div",{class:b.normalizeClass(["quest-list-display",r.quest.state==="completed"?"quest-list-completed":"quest-list-in-progress"])},[b.createElementVNode("p",MTe,b.toDisplayString(n.value.title),1)],2))}}),NTe={key:0},RTe={key:0},DTe={key:1},LTe=b.defineComponent({__name:"quests-list-section",props:{quests:{},sectionId:{},title:{},fallbackText:{}},emits:["quest-selected"],setup(e,{emit:t}){const n=e,r=b.computed(()=>Tp().categories),o=b.computed(()=>{const i=[];return n.quests.reduce((s,c)=>{const l=vc(c.id).category??"default",f=r.value.find(d=>d.id===l);if(!f)return St(`Quest category ${l} not found in config`),s;let u=s.find(d=>d.category.id===l);return u||(u={category:f,quests:[]},s.push(u)),u.quests.push(c),s},i)});return(i,a)=>(b.openBlock(),b.createElementBlock("div",{class:b.normalizeClass([`${i.sectionId}-quests-container`,"quests-section"])},[b.createElementVNode("h3",null,b.toDisplayString(i.title),1),i.quests.length>0?(b.openBlock(),b.createElementBlock("div",NTe,[(b.openBlock(!0),b.createElementBlock(b.Fragment,null,b.renderList(o.value,s=>(b.openBlock(),b.createElementBlock("div",{class:b.normalizeClass([`${i.sectionId}-${s.category.id}-category`,"quests-category"]),key:s.category.id},[r.value.length>1?(b.openBlock(),b.createElementBlock("h4",RTe,b.toDisplayString(s.category.title),1)):b.createCommentVNode("",!0),b.createElementVNode("div",{class:b.normalizeClass(`${i.sectionId}-${s.category.id}-quests`)},[(b.openBlock(!0),b.createElementBlock(b.Fragment,null,b.renderList(s.quests,c=>(b.openBlock(),b.createBlock(ITe,{key:c.id,quest:c,onClick:l=>i.$emit("quest-selected",c)},null,8,["quest","onClick"]))),128))],2)],2))),128))])):(b.openBlock(),b.createElementBlock("div",DTe,[b.createElementVNode("p",null,b.toDisplayString(i.fallbackText),1)]))],2))}}),BTe=b.defineComponent({setup(){const e=ko(),t=b.computed(()=>e.quests),n=b.ref(null);return{quests:t,selectedQuest:n}},computed:{questsToDisplay(){return Object.values(this.quests).filter(e=>e.state!=="hidden")},activeQuests(){return this.questsToDisplay.filter(e=>e.state==="unlocked")},completedQuests(){return this.questsToDisplay.filter(e=>e.state==="completed")},questsUiClass(){return Gr().layoutMode==="horizontal"?"quests-ui-horizontal":"quests-ui-vertical"}},mounted(){this.activeQuests.length>0?this.selectedQuest=this.activeQuests[0]:this.completedQuests.length>0&&(this.selectedQuest=this.completedQuests[0])},methods:{clickOnQuest(e){this.selectedQuest=e}},components:{QuestDetails:PTe,QuestsListSection:LTe}}),FTe={class:"quests-list-container"},VTe={class:"quest-details"};function zTe(e,t,n,r,o,i){const a=b.resolveComponent("QuestsListSection"),s=b.resolveComponent("QuestDetails");return b.openBlock(),b.createElementBlock("div",{class:b.normalizeClass(["quests-ui",e.questsUiClass])},[b.createElementVNode("div",FTe,[b.createVNode(a,{quests:e.activeQuests,sectionId:"active",title:"Active Quests",fallbackText:"No active quests",onQuestSelected:e.clickOnQuest},null,8,["quests","onQuestSelected"]),b.createVNode(a,{quests:e.completedQuests,sectionId:"completed",title:"Completed Quests",fallbackText:"No completed quests",onQuestSelected:e.clickOnQuest},null,8,["quests","onQuestSelected"])]),b.createElementVNode("div",VTe,[e.selectedQuest?(b.openBlock(),b.createBlock(s,{key:0,quest:e.selectedQuest},null,8,["quest"])):b.createCommentVNode("",!0)])],2)}const qTe=Xa(BTe,[["render",zTe]]);function fq(e){const t=Jr(),n=b.computed(()=>t.skills),r=b.computed(()=>n.value[e]),o=b.computed(()=>Ns().skills),i=b.computed(()=>Ns().skillOptions.xpPerLevel),a=b.computed(()=>({backgroundImage:`url(${ci(o.value[e].icon)})`})),s=b.computed(()=>o.value[e].name),c=b.computed(()=>o.value[e].description),l=b.computed(()=>`Level ${n.value[e].level}`);return{skills:n,skillsStore:t,skillConfig:o,xpPerLevel:i,skillState:r,skillStyle:a,skillName:s,skillDescription:c,skillLevelText:l}}const UTe=e=>(b.pushScopeId("data-v-db9d98bf"),e=e(),b.popScopeId(),e),HTe=["id"],WTe={class:"flex flex-row skill-description-container"},KTe={class:"flex skill-left"},GTe={class:"flex skill-right"},JTe=UTe(()=>b.createElementVNode("hr",{class:"hr-solid"},null,-1)),QTe=["innerHTML"],YTe=Xa(b.defineComponent({__name:"SkillDetails",props:{chosenSkill:{},inputListener:{}},emits:["cancel"],setup(e,{emit:t}){const n=e,r=t,o=b.ref(null),i=b.ref(null);function a(){r("cancel")}const{skillStyle:s,skillName:c,skillDescription:l,skillLevelText:f}=fq(n.chosenSkill);return b.onMounted(()=>{o.value=dc({mode:"list",listener:n.inputListener,container:i,onChosen:()=>{a()}}),o.value.mount()}),b.onUnmounted(()=>{o.value&&(o.value.disable(),o.value=null)}),(u,d)=>(b.openBlock(),b.createElementBlock("div",{id:`skill-display-${u.chosenSkill}`},[b.createElementVNode("div",WTe,[b.createElementVNode("div",KTe,[b.createElementVNode("div",{class:"skill-display",style:b.normalizeStyle(b.unref(s))},null,4)]),b.createElementVNode("div",GTe,[b.createElementVNode("h2",null,b.toDisplayString(b.unref(c)),1),JTe,b.createElementVNode("h3",null,b.toDisplayString(b.unref(f)),1),b.createElementVNode("p",{innerHTML:b.unref(l)},null,8,QTe)])]),b.createElementVNode("div",{ref_key:"buttonsContainer",ref:i},[b.createElementVNode("button",{class:"button",onClick:a},b.toDisplayString("<--"))],512)],8,HTe))}}),[["__scopeId","data-v-db9d98bf"]]),XTe={class:"skill-title"},ZTe={class:"skill-xp-container"},eOe={class:"skill-xp-text"},tOe={class:"skill-level"},nOe=Xa(b.defineComponent({__name:"SkillGridElement",props:{chosenSkill:{},inputListener:{}},emits:["choose"],setup(e,{expose:t,emit:n}){const r=e,o=b.ref(null);t({gridElement:o});const i=n;function a(){i("choose")}const{skillStyle:s,skillName:c,skillState:l,xpPerLevel:f}=fq(r.chosenSkill),u=b.computed(()=>({width:`${Math.floor(l.value.xp/f.value*100)}%`}));return(d,h)=>(b.openBlock(),b.createElementBlock("button",{onClick:a,class:"skill-grid-element",style:b.normalizeStyle(b.unref(s)),ref_key:"gridElement",ref:o},[b.createElementVNode("h3",XTe,b.toDisplayString(b.unref(c)),1),b.createElementVNode("div",ZTe,[b.createElementVNode("div",{class:"skill-xp-bar",style:b.normalizeStyle(u.value)},null,4),b.createElementVNode("h3",eOe,b.toDisplayString(b.unref(l).xp)+" / "+b.toDisplayString(b.unref(f))+" XP",1)]),b.createElementVNode("h3",tOe,b.toDisplayString(b.unref(l).level),1)],4))}}),[["__scopeId","data-v-8d457bf9"]]),rOe={class:"skills-container"},oOe=Xa(b.defineComponent({__name:"SkillsGrid",props:{inputListener:{},lastChosenSkill:{type:[String,Boolean]}},emits:["choose"],setup(e,{emit:t}){const n=e,r=b.ref([]),o=b.computed(()=>r.value.map(d=>d.gridElement)),i=Jr(),a=b.computed(()=>i.skills),s=b.ref(null),c=t;function l(d){c("choose",d)}const f=b.computed(()=>Ns().skills),u=b.computed(()=>{const d={};for(const h in a.value)f.value[h].hidden&&a.value[h].level<1||(d[h]=a.value[h]);return Object.values(d)});return b.onMounted(()=>{var d;if(s.value=dc({mode:"grid",listener:n.inputListener,elements:o,columns:3,onChosen:h=>{l(u.value[h].id)}}),(d=s.value)==null||d.mount(),typeof n.lastChosenSkill=="string"){const h=u.value.findIndex(p=>p.id===n.lastChosenSkill);h>=0&&s.value.select(h)}}),b.onUnmounted(()=>{s.value&&s.value.disable()}),(d,h)=>(b.openBlock(),b.createElementBlock("div",rOe,[(b.openBlock(!0),b.createElementBlock(b.Fragment,null,b.renderList(u.value,p=>(b.openBlock(),b.createBlock(nOe,{ref_for:!0,ref_key:"skillGridElements",ref:r,key:p.id,onChoose:()=>l(p.id),chosenSkill:p.id,inputListener:d.inputListener},null,8,["onChoose","chosenSkill","inputListener"]))),128))]))}}),[["__scopeId","data-v-31202bb8"]]),iOe=b.defineComponent({__name:"SkillsWindow",props:{inputListener:{}},setup(e){const t=b.ref(!1),n=b.ref(!1);function r(i){n.value=i,t.value=i}function o(){t.value=!1}return(i,a)=>t.value?typeof t.value=="string"?(b.openBlock(),b.createBlock(YTe,{key:1,chosenSkill:t.value,inputListener:i.inputListener,onCancel:o},null,8,["chosenSkill","inputListener"])):b.createCommentVNode("",!0):(b.openBlock(),b.createBlock(oOe,{key:0,inputListener:i.inputListener,lastChosenSkill:n.value,onChoose:r},null,8,["inputListener","lastChosenSkill"]))}});function aOe(e){e.component("MainMenu",G$e),e.component("InventoryTab",pTe),e.component("AchievementsUI",$Te),e.component("QuestsUi",qTe),e.component("SkillsWindow",iOe),No().menus={system:{label:"System",cssClass:"system-menu",id:"system",tabs:[{id:"system-tab",cssId:"system-tab",text:"System",component:"MainMenu"}],activeTab:0},menu:{label:"Menu",id:"menu",cssClass:"menu-menu",tabs:[{id:"skills",cssId:"skills-menu-button",text:"Skills",condition:()=>No().showSkills,component:"SkillsWindow"},{id:"inventory",cssId:"inventory-menu-button",text:"Items",condition:()=>No().showInventory,component:"InventoryTab"},{id:"quests",cssId:"quests-menu-button",text:"Quests",condition:()=>No().showQuests,component:"QuestsUi"},{id:"achievements",cssId:"achievements-menu-button",text:"Achievements",condition:()=>No().showAchievements,component:"AchievementsUI"}],activeTab:0}}}function kS(e,t,n){const r=window.narrat.app;for(const o in t.tabs){const i=t.tabs[o].component;r.component(i,n[i])}No().addMenu(e,t)}function sOe(e,t,n){window.narrat.app.component(t.component,n),No().addMenuOption(e,t)}function cOe(){for(const e of yn.plugins){if(e.customMenuButtons)for(const t of e.customMenuButtons)kS(t.config.id,t.config,t.components);if(e.customMenuTabs)for(const t of e.customMenuTabs)sOe(t.config.id,t.config,t.component)}}function lOe(e){e.directive("visible",{mounted(t,n){n.value?t.style.visibility="visible":t.style.visibility="hidden"},updated(t,n){n.value?t.style.visibility="visible":t.style.visibility="hidden"}})}class Z0{constructor(){Wn(this,"pluginId","narrat-plugin")}onPageLoaded(){}onNarratSetup(){}onAppMounted(){}onAssetsLoaded(){}onGameSetup(){}onGameStart(){}onGameMounted(){}onGameDismounted(){}}function dq(e){yn.addPlugin(e)}function hq(e){yn.addCommand(e)}const uOe={args:[],canvasResizePolicy:0,executable:"",experimentalVK:!1,fileSizes:{"index.pck":54160,"index.wasm":52315256},focusCanvas:!1,gdextensionLibs:[]};function fOe(){window.godotReady=!0,window.narratReadyCallback&&window.narratReadyCallback(),console.log("godot ready")}window.godotReadyCallback=fOe;class pq extends Z0{constructor(n){super();Wn(this,"customCommands",[]);Wn(this,"canvas");Wn(this,"app");Wn(this,"messageQueue",[]);Wn(this,"narrat");Wn(this,"narratReady",!1);Wn(this,"engineConfig");Wn(this,"engine");const r={...uOe,...n.engineConfigOverrides??{}};n.godotGamePath&&(r.executable=n.godotGamePath),this.engineConfig=r,this.customCommands=[Re.FromOptions({keyword:"godot_pause",argTypes:[],runner:async o=>{this.addMessageForGodot({type:"pause",payload:{}})}}),Re.FromOptions({keyword:"godot_resume",argTypes:[],runner:async o=>{this.addMessageForGodot({type:"resume",payload:{}})}})]}onAppMounted(){const n=document.querySelector("#narrat-app-container");if(!n){console.error("no app");return}this.narrat=window.narrat;const r=document.createElement("canvas");this.app=n,this.canvas=r,r.id="godot-canvas",r.style.position="absolute",r.style.zIndex="0",n.appendChild(r),window.addEventListener("keydown",i=>{if(i.fakeEvent)return;const a=new KeyboardEvent(i.type,i);a.fakeEvent=!0,this.canvas.dispatchEvent(a)}),window.addEventListener("keyup",i=>{if(i.fakeEvent)return;const a=new KeyboardEvent(i.type,i);a.fakeEvent=!0,this.canvas.dispatchEvent(a)}),new window.Engine(this.engineConfig).startGame(),this.resizeCanvas(),window.godot=this,this.narratReady=!0,window.narratReadyCallback&&window.narratReadyCallback()}getCanvas(){return document.querySelector("#godot-canvas")}addMessageForGodot(n){this.messageQueue.unshift(n),window.godotCallback&&window.godotCallback(n)}grabNextMessage(){return this.messageQueue.pop()}async run(n,...r){const o=await this.narrat.run(n,...r),i={type:"run_end",payload:{label:n,args:r,result:o}};this.addMessageForGodot(i)}isJson(n){try{JSON.parse(n)}catch{return!1}return!0}resizeCanvas(){const n=Gr(),r=n.gameWidth,o=n.gameHeight;this.canvas.width=r,this.canvas.height=o,this.canvas.style.width=`${r}px`,this.canvas.style.height=`${o}px`,window.requestAnimationFrame(()=>this.resizeCanvas())}}class mq extends Z0{constructor(n={}){super();Wn(this,"defaultTheme");Wn(this,"themes",[]);Wn(this,"activeTheme");Wn(this,"customCommands");Wn(this,"initialConfig");n.defaultTheme&&(this.defaultTheme=n.defaultTheme),n.themes&&(this.themes=n.themes),this.customCommands=[this.createChangeThemeCommand()]}onNarratSetup(){if(this.defaultTheme){const n=this.themes.find(r=>r.id===this.defaultTheme);if(!n){St(`Theme ${this.defaultTheme} not found`);return}this.setTheme(n)}}addTheme(n){this.themes.push(n)}createChangeThemeCommand(){return Re.FromOptions({keyword:"change_theme",argTypes:[{name:"theme",type:"string"}],runner:async r=>{this.changeTheme(r.options.theme)}})}changeTheme(n){if(n==="default"){this.removeCurrentTheme();return}const r=this.findTheme(n);this.setTheme(r)}findTheme(n){const r=this.themes.find(o=>o.id===n);return r||St(`Theme ${n} not found`),r}setTheme(n){this.activeTheme&&this.removeCurrentTheme(),this.activeTheme={themeTag:this.createThemeTag(n),id:n.id},document.head.appendChild(this.activeTheme.themeTag),n.extendedConfig&&(this.initialConfig=fu({},fo().config),fo().extendConfig(n.extendedConfig))}createThemeTag(n){if(this.isInlineTheme(n)){const r=document.createElement("style");return r.innerHTML=n.css,r}else{const r=document.createElement("link");return r.rel="stylesheet",r.href=n.cssPath,r.id=n.id,r}}isInlineTheme(n){return n.css!==void 0}isExternalTheme(n){return n.cssPath!==void 0}removeCurrentTheme(){this.activeTheme&&(this.activeTheme.themeTag&&this.activeTheme.themeTag.remove(),this.findTheme(this.activeTheme.id).extendedConfig&&(fo().config=this.initialConfig)),this.activeTheme=void 0}}const vq={css:"body{font-size:52px}",id:"narrat-fun-theme",extendedConfig:{}},gq={id:"narrat-text-only",css:"#narrat-app{--bg-color: #131720;--text-color: #d9e1f2;--primary: hsl(255, 30%, 55%);--focus: hsl(210, 90%, 50%);--secondary: #42b983;--dialog-box-bg: transparent;--dialog-box-border: none}.interact-button{background:unset;border:none;font-size:2rem;font-weight:700;color:#fff;font-family:monospace;text-shadow:-4px 4px 2px #000}.dialog{box-shadow:none!important;text-align:center}.dialog-text{font-size:1.5rem;font-family:monospace;text-shadow:-4px 4px 2px #000}",extendedConfig:{common:{dialogPanel:{textSpeed:30,animateText:!0,timeBetweenLines:100,overlayMode:!0,rightOffset:300,bottomOffset:150,width:700,height:680}}}},dOe=Object.freeze(Object.defineProperty({__proto__:null,BaseConfigInputSchema:b0,CommandPlugin:Re,ConfigInputSchema:a_,ConfigInputSchemaWithCommon:o_,ConfigInputSchemaWithoutCommon:i_,EngineSplash:Lx,GameDialog:Kx,GameSplash:Vx,GodotPlugin:pq,Hud:Yx,InGame:Xx,InputsListener:qx,LogManager:Ap,MenuButtons:Gx,ModalWindow:Bs,NarratPlugin:Z0,NarratThemesPlugin:mq,Screens:Qx,StartMenu:Hx,get Vec2(){return Qe.Vec2},addCommand:hq,aspectRatioFit:Fx,audioConfig:Fi,buttonsConfig:q0,charactersConfig:U0,constructNarratObject:xS,debounce:dp,error:St,findVariable:px,funTheme:vq,gameloop:fp,generateObjectFromList:mx,generateParser:ld,getAssetUrl:ci,getButtonConfig:vl,getConfig:Ct,getDataUrl:K0,getFile:h0,getImageUrl:fd,getItemConfig:Ja,getObjectiveConfig:Ep,getQuestConfig:vc,getScreenConfig:ud,getSkillConfig:W0,getSplitConfigUrl:sS,getWindow:n0,handleHMR:oS,inputEvents:ha,isConfigInputWithCommon:w0,isModuleValid:rS,isNarratScript:iS,isNarratYaml:B0,isPromise:vx,itemsConfig:V0,loadDataFile:up,logManager:Pp,logger:qi,processText:$s,questsConfig:Tp,randomId:su,registerMenuButton:kS,registerPlugin:dq,screensConfig:z0,skillsConfig:Ns,textOnlyTheme:gq,timeout:ki,tooltipsConfig:ml,useAchievements:xu,useAudio:Po,useConfig:fo,useDialogStore:cr,useHud:Si,useInputs:xr,useInventory:Io,useMain:sn,useMenu:No,useNotifications:Jo,useQuests:ko,useRenderingStore:Gr,useScenes:_i,useScreenObjects:Bi,useScreens:da,useSkills:Jr,useTooltips:Wf,useVM:un,warning:hu},Symbol.toStringTag,{value:"Module"}));function xS(e){const t={app:e,vm:yn,handleHMR:oS,jump:n=>un().jumpToLabel(n),run:(n,...r)=>un().runThenGoBackToPreviousDialog(n,...r),getSave:()=>lc(),exports:dOe};return window.narrat=t,t}var hOe=Object.prototype.toString,yq=function(t){if(t===void 0)return"undefined";if(t===null)return"null";var n=typeof t;if(n==="boolean")return"boolean";if(n==="string")return"string";if(n==="number")return"number";if(n==="symbol")return"symbol";if(n==="function")return yOe(t)?"generatorfunction":"function";if(pOe(t))return"array";if(kOe(t))return"buffer";if(wOe(t))return"arguments";if(vOe(t))return"date";if(mOe(t))return"error";if(gOe(t))return"regexp";switch(bq(t)){case"Symbol":return"symbol";case"Promise":return"promise";case"WeakMap":return"weakmap";case"WeakSet":return"weakset";case"Map":return"map";case"Set":return"set";case"Int8Array":return"int8array";case"Uint8Array":return"uint8array";case"Uint8ClampedArray":return"uint8clampedarray";case"Int16Array":return"int16array";case"Uint16Array":return"uint16array";case"Int32Array":return"int32array";case"Uint32Array":return"uint32array";case"Float32Array":return"float32array";case"Float64Array":return"float64array"}if(bOe(t))return"generator";switch(n=hOe.call(t),n){case"[object Object]":return"object";case"[object Map Iterator]":return"mapiterator";case"[object Set Iterator]":return"setiterator";case"[object String Iterator]":return"stringiterator";case"[object Array Iterator]":return"arrayiterator"}return n.slice(8,-1).toLowerCase().replace(/\s/g,"")};function bq(e){return typeof e.constructor=="function"?e.constructor.name:null}function pOe(e){return Array.isArray?Array.isArray(e):e instanceof Array}function mOe(e){return e instanceof Error||typeof e.message=="string"&&e.constructor&&typeof e.constructor.stackTraceLimit=="number"}function vOe(e){return e instanceof Date?!0:typeof e.toDateString=="function"&&typeof e.getDate=="function"&&typeof e.setDate=="function"}function gOe(e){return e instanceof RegExp?!0:typeof e.flags=="string"&&typeof e.ignoreCase=="boolean"&&typeof e.multiline=="boolean"&&typeof e.global=="boolean"}function yOe(e,t){return bq(e)==="GeneratorFunction"}function bOe(e){return typeof e.throw=="function"&&typeof e.return=="function"&&typeof e.next=="function"}function wOe(e){try{if(typeof e.length=="number"&&typeof e.callee=="function")return!0}catch(t){if(t.message.indexOf("callee")!==-1)return!0}return!1}function kOe(e){return e.constructor&&typeof e.constructor.isBuffer=="function"?e.constructor.isBuffer(e):!1}/*!
220
220
  * shallow-clone <https://github.com/jonschlinkert/shallow-clone>
221
221
  *
222
222
  * Copyright (c) 2015-present, Jon Schlinkert.