narrat 3.2.11 → 3.2.12

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.
@@ -148,7 +148,7 @@ return query;
148
148
  * goldfirestudios.com
149
149
  *
150
150
  * MIT License
151
- */(function(e){(function(){var t=function(){this.init()};t.prototype={init:function(){var u=this||n;return u._counter=1e3,u._html5AudioPool=[],u.html5PoolSize=10,u._codecs={},u._howls=[],u._muted=!1,u._volume=1,u._canPlayEvent="canplaythrough",u._navigator=typeof window<"u"&&window.navigator?window.navigator:null,u.masterGain=null,u.noAudio=!1,u.usingWebAudio=!0,u.autoSuspend=!0,u.ctx=null,u.autoUnlock=!0,u._setup(),u},volume:function(u){var d=this||n;if(u=parseFloat(u),d.ctx||f(),typeof u<"u"&&u>=0&&u<=1){if(d._volume=u,d._muted)return d;d.usingWebAudio&&d.masterGain.gain.setValueAtTime(u,n.ctx.currentTime);for(var h=0;h<d._howls.length;h++)if(!d._howls[h]._webAudio)for(var p=d._howls[h]._getSoundIds(),m=0;m<p.length;m++){var v=d._howls[h]._soundById(p[m]);v&&v._node&&(v._node.volume=v._volume*u)}return d}return d._volume},mute:function(u){var d=this||n;d.ctx||f(),d._muted=u,d.usingWebAudio&&d.masterGain.gain.setValueAtTime(u?0:d._volume,n.ctx.currentTime);for(var h=0;h<d._howls.length;h++)if(!d._howls[h]._webAudio)for(var p=d._howls[h]._getSoundIds(),m=0;m<p.length;m++){var v=d._howls[h]._soundById(p[m]);v&&v._node&&(v._node.muted=u?!0:v._muted)}return d},stop:function(){for(var u=this||n,d=0;d<u._howls.length;d++)u._howls[d].stop();return u},unload:function(){for(var u=this||n,d=u._howls.length-1;d>=0;d--)u._howls[d].unload();return u.usingWebAudio&&u.ctx&&typeof u.ctx.close<"u"&&(u.ctx.close(),u.ctx=null,f()),u},codecs:function(u){return(this||n)._codecs[u.replace(/^x-/,"")]},_setup:function(){var u=this||n;if(u.state=u.ctx&&u.ctx.state||"suspended",u._autoSuspend(),!u.usingWebAudio)if(typeof Audio<"u")try{var d=new Audio;typeof d.oncanplaythrough>"u"&&(u._canPlayEvent="canplay")}catch{u.noAudio=!0}else u.noAudio=!0;try{var d=new Audio;d.muted&&(u.noAudio=!0)}catch{}return u.noAudio||u._setupCodecs(),u},_setupCodecs:function(){var u=this||n,d=null;try{d=typeof Audio<"u"?new Audio:null}catch{return u}if(!d||typeof d.canPlayType!="function")return u;var h=d.canPlayType("audio/mpeg;").replace(/^no$/,""),p=u._navigator?u._navigator.userAgent:"",m=p.match(/OPR\/([0-6].)/g),v=m&&parseInt(m[0].split("/")[1],10)<33,g=p.indexOf("Safari")!==-1&&p.indexOf("Chrome")===-1,y=p.match(/Version\/(.*?) /),w=g&&y&&parseInt(y[1],10)<15;return u._codecs={mp3:!!(!v&&(h||d.canPlayType("audio/mp3;").replace(/^no$/,""))),mpeg:!!h,opus:!!d.canPlayType('audio/ogg; codecs="opus"').replace(/^no$/,""),ogg:!!d.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/,""),oga:!!d.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/,""),wav:!!(d.canPlayType('audio/wav; codecs="1"')||d.canPlayType("audio/wav")).replace(/^no$/,""),aac:!!d.canPlayType("audio/aac;").replace(/^no$/,""),caf:!!d.canPlayType("audio/x-caf;").replace(/^no$/,""),m4a:!!(d.canPlayType("audio/x-m4a;")||d.canPlayType("audio/m4a;")||d.canPlayType("audio/aac;")).replace(/^no$/,""),m4b:!!(d.canPlayType("audio/x-m4b;")||d.canPlayType("audio/m4b;")||d.canPlayType("audio/aac;")).replace(/^no$/,""),mp4:!!(d.canPlayType("audio/x-mp4;")||d.canPlayType("audio/mp4;")||d.canPlayType("audio/aac;")).replace(/^no$/,""),weba:!!(!w&&d.canPlayType('audio/webm; codecs="vorbis"').replace(/^no$/,"")),webm:!!(!w&&d.canPlayType('audio/webm; codecs="vorbis"').replace(/^no$/,"")),dolby:!!d.canPlayType('audio/mp4; codecs="ec-3"').replace(/^no$/,""),flac:!!(d.canPlayType("audio/x-flac;")||d.canPlayType("audio/flac;")).replace(/^no$/,"")},u},_unlockAudio:function(){var u=this||n;if(!(u._audioUnlocked||!u.ctx)){u._audioUnlocked=!1,u.autoUnlock=!1,!u._mobileUnloaded&&u.ctx.sampleRate!==44100&&(u._mobileUnloaded=!0,u.unload()),u._scratchBuffer=u.ctx.createBuffer(1,1,22050);var d=function(h){for(;u._html5AudioPool.length<u.html5PoolSize;)try{var p=new Audio;p._unlocked=!0,u._releaseHtml5Audio(p)}catch{u.noAudio=!0;break}for(var m=0;m<u._howls.length;m++)if(!u._howls[m]._webAudio)for(var v=u._howls[m]._getSoundIds(),g=0;g<v.length;g++){var y=u._howls[m]._soundById(v[g]);y&&y._node&&!y._node._unlocked&&(y._node._unlocked=!0,y._node.load())}u._autoResume();var w=u.ctx.createBufferSource();w.buffer=u._scratchBuffer,w.connect(u.ctx.destination),typeof w.start>"u"?w.noteOn(0):w.start(0),typeof u.ctx.resume=="function"&&u.ctx.resume(),w.onended=function(){w.disconnect(0),u._audioUnlocked=!0,document.removeEventListener("touchstart",d,!0),document.removeEventListener("touchend",d,!0),document.removeEventListener("click",d,!0),document.removeEventListener("keydown",d,!0);for(var k=0;k<u._howls.length;k++)u._howls[k]._emit("unlock")}};return document.addEventListener("touchstart",d,!0),document.addEventListener("touchend",d,!0),document.addEventListener("click",d,!0),document.addEventListener("keydown",d,!0),u}},_obtainHtml5Audio:function(){var u=this||n;if(u._html5AudioPool.length)return u._html5AudioPool.pop();var d=new Audio().play();return d&&typeof Promise<"u"&&(d instanceof Promise||typeof d.then=="function")&&d.catch(function(){console.warn("HTML5 Audio pool exhausted, returning potentially locked audio object.")}),new Audio},_releaseHtml5Audio:function(u){var d=this||n;return u._unlocked&&d._html5AudioPool.push(u),d},_autoSuspend:function(){var u=this;if(!(!u.autoSuspend||!u.ctx||typeof u.ctx.suspend>"u"||!n.usingWebAudio)){for(var d=0;d<u._howls.length;d++)if(u._howls[d]._webAudio){for(var h=0;h<u._howls[d]._sounds.length;h++)if(!u._howls[d]._sounds[h]._paused)return u}return u._suspendTimer&&clearTimeout(u._suspendTimer),u._suspendTimer=setTimeout(function(){if(u.autoSuspend){u._suspendTimer=null,u.state="suspending";var p=function(){u.state="suspended",u._resumeAfterSuspend&&(delete u._resumeAfterSuspend,u._autoResume())};u.ctx.suspend().then(p,p)}},3e4),u}},_autoResume:function(){var u=this;if(!(!u.ctx||typeof u.ctx.resume>"u"||!n.usingWebAudio))return u.state==="running"&&u.ctx.state!=="interrupted"&&u._suspendTimer?(clearTimeout(u._suspendTimer),u._suspendTimer=null):u.state==="suspended"||u.state==="running"&&u.ctx.state==="interrupted"?(u.ctx.resume().then(function(){u.state="running";for(var d=0;d<u._howls.length;d++)u._howls[d]._emit("resume")}),u._suspendTimer&&(clearTimeout(u._suspendTimer),u._suspendTimer=null)):u.state==="suspending"&&(u._resumeAfterSuspend=!0),u}};var n=new t,r=function(u){var d=this;if(!u.src||u.src.length===0){console.error("An array of source files must be passed with any new Howl.");return}d.init(u)};r.prototype={init:function(u){var d=this;return n.ctx||f(),d._autoplay=u.autoplay||!1,d._format=typeof u.format!="string"?u.format:[u.format],d._html5=u.html5||!1,d._muted=u.mute||!1,d._loop=u.loop||!1,d._pool=u.pool||5,d._preload=typeof u.preload=="boolean"||u.preload==="metadata"?u.preload:!0,d._rate=u.rate||1,d._sprite=u.sprite||{},d._src=typeof u.src!="string"?u.src:[u.src],d._volume=u.volume!==void 0?u.volume:1,d._xhr={method:u.xhr&&u.xhr.method?u.xhr.method:"GET",headers:u.xhr&&u.xhr.headers?u.xhr.headers:null,withCredentials:u.xhr&&u.xhr.withCredentials?u.xhr.withCredentials:!1},d._duration=0,d._state="unloaded",d._sounds=[],d._endTimers={},d._queue=[],d._playLock=!1,d._onend=u.onend?[{fn:u.onend}]:[],d._onfade=u.onfade?[{fn:u.onfade}]:[],d._onload=u.onload?[{fn:u.onload}]:[],d._onloaderror=u.onloaderror?[{fn:u.onloaderror}]:[],d._onplayerror=u.onplayerror?[{fn:u.onplayerror}]:[],d._onpause=u.onpause?[{fn:u.onpause}]:[],d._onplay=u.onplay?[{fn:u.onplay}]:[],d._onstop=u.onstop?[{fn:u.onstop}]:[],d._onmute=u.onmute?[{fn:u.onmute}]:[],d._onvolume=u.onvolume?[{fn:u.onvolume}]:[],d._onrate=u.onrate?[{fn:u.onrate}]:[],d._onseek=u.onseek?[{fn:u.onseek}]:[],d._onunlock=u.onunlock?[{fn:u.onunlock}]:[],d._onresume=[],d._webAudio=n.usingWebAudio&&!d._html5,typeof n.ctx<"u"&&n.ctx&&n.autoUnlock&&n._unlockAudio(),n._howls.push(d),d._autoplay&&d._queue.push({event:"play",action:function(){d.play()}}),d._preload&&d._preload!=="none"&&d.load(),d},load:function(){var u=this,d=null;if(n.noAudio){u._emit("loaderror",null,"No audio support.");return}typeof u._src=="string"&&(u._src=[u._src]);for(var h=0;h<u._src.length;h++){var p,m;if(u._format&&u._format[h])p=u._format[h];else{if(m=u._src[h],typeof m!="string"){u._emit("loaderror",null,"Non-string found in selected audio sources - ignoring.");continue}p=/^data:audio\/([^;,]+);/i.exec(m),p||(p=/\.([^.]+)$/.exec(m.split("?",1)[0])),p&&(p=p[1].toLowerCase())}if(p||console.warn('No file extension was found. Consider using the "format" property or specify an extension.'),p&&n.codecs(p)){d=u._src[h];break}}if(!d){u._emit("loaderror",null,"No codec support for selected audio sources.");return}return u._src=d,u._state="loading",window.location.protocol==="https:"&&d.slice(0,5)==="http:"&&(u._html5=!0,u._webAudio=!1),new o(u),u._webAudio&&a(u),u},play:function(u,d){var h=this,p=null;if(typeof u=="number")p=u,u=null;else{if(typeof u=="string"&&h._state==="loaded"&&!h._sprite[u])return null;if(typeof u>"u"&&(u="__default",!h._playLock)){for(var m=0,v=0;v<h._sounds.length;v++)h._sounds[v]._paused&&!h._sounds[v]._ended&&(m++,p=h._sounds[v]._id);m===1?u=null:p=null}}var g=p?h._soundById(p):h._inactiveSound();if(!g)return null;if(p&&!u&&(u=g._sprite||"__default"),h._state!=="loaded"){g._sprite=u,g._ended=!1;var y=g._id;return h._queue.push({event:"play",action:function(){h.play(y)}}),y}if(p&&!g._paused)return d||h._loadQueue("play"),g._id;h._webAudio&&n._autoResume();var w=Math.max(0,g._seek>0?g._seek:h._sprite[u][0]/1e3),k=Math.max(0,(h._sprite[u][0]+h._sprite[u][1])/1e3-w),$=k*1e3/Math.abs(g._rate),x=h._sprite[u][0]/1e3,E=(h._sprite[u][0]+h._sprite[u][1])/1e3;g._sprite=u,g._ended=!1;var R=function(){g._paused=!1,g._seek=w,g._start=x,g._stop=E,g._loop=!!(g._loop||h._sprite[u][2])};if(w>=E){h._ended(g);return}var M=g._node;if(h._webAudio){var j=function(){h._playLock=!1,R(),h._refreshBuffer(g);var T=g._muted||h._muted?0:g._volume;M.gain.setValueAtTime(T,n.ctx.currentTime),g._playStart=n.ctx.currentTime,typeof M.bufferSource.start>"u"?g._loop?M.bufferSource.noteGrainOn(0,w,86400):M.bufferSource.noteGrainOn(0,w,k):g._loop?M.bufferSource.start(0,w,86400):M.bufferSource.start(0,w,k),$!==1/0&&(h._endTimers[g._id]=setTimeout(h._ended.bind(h,g),$)),d||setTimeout(function(){h._emit("play",g._id),h._loadQueue()},0)};n.state==="running"&&n.ctx.state!=="interrupted"?j():(h._playLock=!0,h.once("resume",j),h._clearTimer(g._id))}else{var C=function(){M.currentTime=w,M.muted=g._muted||h._muted||n._muted||M.muted,M.volume=g._volume*n.volume(),M.playbackRate=g._rate;try{var T=M.play();if(T&&typeof Promise<"u"&&(T instanceof Promise||typeof T.then=="function")?(h._playLock=!0,R(),T.then(function(){h._playLock=!1,M._unlocked=!0,d?h._loadQueue():h._emit("play",g._id)}).catch(function(){h._playLock=!1,h._emit("playerror",g._id,"Playback was unable to start. This is most commonly an issue on mobile devices and Chrome where playback was not within a user interaction."),g._ended=!0,g._paused=!0})):d||(h._playLock=!1,R(),h._emit("play",g._id)),M.playbackRate=g._rate,M.paused){h._emit("playerror",g._id,"Playback was unable to start. This is most commonly an issue on mobile devices and Chrome where playback was not within a user interaction.");return}u!=="__default"||g._loop?h._endTimers[g._id]=setTimeout(h._ended.bind(h,g),$):(h._endTimers[g._id]=function(){h._ended(g),M.removeEventListener("ended",h._endTimers[g._id],!1)},M.addEventListener("ended",h._endTimers[g._id],!1))}catch(L){h._emit("playerror",g._id,L)}};M.src==="data:audio/wav;base64,UklGRigAAABXQVZFZm10IBIAAAABAAEARKwAAIhYAQACABAAAABkYXRhAgAAAAEA"&&(M.src=h._src,M.load());var O=window&&window.ejecta||!M.readyState&&n._navigator.isCocoonJS;if(M.readyState>=3||O)C();else{h._playLock=!0,h._state="loading";var F=function(){h._state="loaded",C(),M.removeEventListener(n._canPlayEvent,F,!1)};M.addEventListener(n._canPlayEvent,F,!1),h._clearTimer(g._id)}}return g._id},pause:function(u){var d=this;if(d._state!=="loaded"||d._playLock)return d._queue.push({event:"pause",action:function(){d.pause(u)}}),d;for(var h=d._getSoundIds(u),p=0;p<h.length;p++){d._clearTimer(h[p]);var m=d._soundById(h[p]);if(m&&!m._paused&&(m._seek=d.seek(h[p]),m._rateSeek=0,m._paused=!0,d._stopFade(h[p]),m._node))if(d._webAudio){if(!m._node.bufferSource)continue;typeof m._node.bufferSource.stop>"u"?m._node.bufferSource.noteOff(0):m._node.bufferSource.stop(0),d._cleanBuffer(m._node)}else(!isNaN(m._node.duration)||m._node.duration===1/0)&&m._node.pause();arguments[1]||d._emit("pause",m?m._id:null)}return d},stop:function(u,d){var h=this;if(h._state!=="loaded"||h._playLock)return h._queue.push({event:"stop",action:function(){h.stop(u)}}),h;for(var p=h._getSoundIds(u),m=0;m<p.length;m++){h._clearTimer(p[m]);var v=h._soundById(p[m]);v&&(v._seek=v._start||0,v._rateSeek=0,v._paused=!0,v._ended=!0,h._stopFade(p[m]),v._node&&(h._webAudio?v._node.bufferSource&&(typeof v._node.bufferSource.stop>"u"?v._node.bufferSource.noteOff(0):v._node.bufferSource.stop(0),h._cleanBuffer(v._node)):(!isNaN(v._node.duration)||v._node.duration===1/0)&&(v._node.currentTime=v._start||0,v._node.pause(),v._node.duration===1/0&&h._clearSound(v._node))),d||h._emit("stop",v._id))}return h},mute:function(u,d){var h=this;if(h._state!=="loaded"||h._playLock)return h._queue.push({event:"mute",action:function(){h.mute(u,d)}}),h;if(typeof d>"u")if(typeof u=="boolean")h._muted=u;else return h._muted;for(var p=h._getSoundIds(d),m=0;m<p.length;m++){var v=h._soundById(p[m]);v&&(v._muted=u,v._interval&&h._stopFade(v._id),h._webAudio&&v._node?v._node.gain.setValueAtTime(u?0:v._volume,n.ctx.currentTime):v._node&&(v._node.muted=n._muted?!0:u),h._emit("mute",v._id))}return h},volume:function(){var u=this,d=arguments,h,p;if(d.length===0)return u._volume;if(d.length===1||d.length===2&&typeof d[1]>"u"){var m=u._getSoundIds(),v=m.indexOf(d[0]);v>=0?p=parseInt(d[0],10):h=parseFloat(d[0])}else d.length>=2&&(h=parseFloat(d[0]),p=parseInt(d[1],10));var g;if(typeof h<"u"&&h>=0&&h<=1){if(u._state!=="loaded"||u._playLock)return u._queue.push({event:"volume",action:function(){u.volume.apply(u,d)}}),u;typeof p>"u"&&(u._volume=h),p=u._getSoundIds(p);for(var y=0;y<p.length;y++)g=u._soundById(p[y]),g&&(g._volume=h,d[2]||u._stopFade(p[y]),u._webAudio&&g._node&&!g._muted?g._node.gain.setValueAtTime(h,n.ctx.currentTime):g._node&&!g._muted&&(g._node.volume=h*n.volume()),u._emit("volume",g._id))}else return g=p?u._soundById(p):u._sounds[0],g?g._volume:0;return u},fade:function(u,d,h,p){var m=this;if(m._state!=="loaded"||m._playLock)return m._queue.push({event:"fade",action:function(){m.fade(u,d,h,p)}}),m;u=Math.min(Math.max(0,parseFloat(u)),1),d=Math.min(Math.max(0,parseFloat(d)),1),h=parseFloat(h),m.volume(u,p);for(var v=m._getSoundIds(p),g=0;g<v.length;g++){var y=m._soundById(v[g]);if(y){if(p||m._stopFade(v[g]),m._webAudio&&!y._muted){var w=n.ctx.currentTime,k=w+h/1e3;y._volume=u,y._node.gain.setValueAtTime(u,w),y._node.gain.linearRampToValueAtTime(d,k)}m._startFadeInterval(y,u,d,h,v[g],typeof p>"u")}}return m},_startFadeInterval:function(u,d,h,p,m,v){var g=this,y=d,w=h-d,k=Math.abs(w/.01),$=Math.max(4,k>0?p/k:p),x=Date.now();u._fadeTo=h,u._interval=setInterval(function(){var E=(Date.now()-x)/p;x=Date.now(),y+=w*E,y=Math.round(y*100)/100,w<0?y=Math.max(h,y):y=Math.min(h,y),g._webAudio?u._volume=y:g.volume(y,u._id,!0),v&&(g._volume=y),(h<d&&y<=h||h>d&&y>=h)&&(clearInterval(u._interval),u._interval=null,u._fadeTo=null,g.volume(h,u._id),g._emit("fade",u._id))},$)},_stopFade:function(u){var d=this,h=d._soundById(u);return h&&h._interval&&(d._webAudio&&h._node.gain.cancelScheduledValues(n.ctx.currentTime),clearInterval(h._interval),h._interval=null,d.volume(h._fadeTo,u),h._fadeTo=null,d._emit("fade",u)),d},loop:function(){var u=this,d=arguments,h,p,m;if(d.length===0)return u._loop;if(d.length===1)if(typeof d[0]=="boolean")h=d[0],u._loop=h;else return m=u._soundById(parseInt(d[0],10)),m?m._loop:!1;else d.length===2&&(h=d[0],p=parseInt(d[1],10));for(var v=u._getSoundIds(p),g=0;g<v.length;g++)m=u._soundById(v[g]),m&&(m._loop=h,u._webAudio&&m._node&&m._node.bufferSource&&(m._node.bufferSource.loop=h,h&&(m._node.bufferSource.loopStart=m._start||0,m._node.bufferSource.loopEnd=m._stop,u.playing(v[g])&&(u.pause(v[g],!0),u.play(v[g],!0)))));return u},rate:function(){var u=this,d=arguments,h,p;if(d.length===0)p=u._sounds[0]._id;else if(d.length===1){var m=u._getSoundIds(),v=m.indexOf(d[0]);v>=0?p=parseInt(d[0],10):h=parseFloat(d[0])}else d.length===2&&(h=parseFloat(d[0]),p=parseInt(d[1],10));var g;if(typeof h=="number"){if(u._state!=="loaded"||u._playLock)return u._queue.push({event:"rate",action:function(){u.rate.apply(u,d)}}),u;typeof p>"u"&&(u._rate=h),p=u._getSoundIds(p);for(var y=0;y<p.length;y++)if(g=u._soundById(p[y]),g){u.playing(p[y])&&(g._rateSeek=u.seek(p[y]),g._playStart=u._webAudio?n.ctx.currentTime:g._playStart),g._rate=h,u._webAudio&&g._node&&g._node.bufferSource?g._node.bufferSource.playbackRate.setValueAtTime(h,n.ctx.currentTime):g._node&&(g._node.playbackRate=h);var w=u.seek(p[y]),k=(u._sprite[g._sprite][0]+u._sprite[g._sprite][1])/1e3-w,$=k*1e3/Math.abs(g._rate);(u._endTimers[p[y]]||!g._paused)&&(u._clearTimer(p[y]),u._endTimers[p[y]]=setTimeout(u._ended.bind(u,g),$)),u._emit("rate",g._id)}}else return g=u._soundById(p),g?g._rate:u._rate;return u},seek:function(){var u=this,d=arguments,h,p;if(d.length===0)u._sounds.length&&(p=u._sounds[0]._id);else if(d.length===1){var m=u._getSoundIds(),v=m.indexOf(d[0]);v>=0?p=parseInt(d[0],10):u._sounds.length&&(p=u._sounds[0]._id,h=parseFloat(d[0]))}else d.length===2&&(h=parseFloat(d[0]),p=parseInt(d[1],10));if(typeof p>"u")return 0;if(typeof h=="number"&&(u._state!=="loaded"||u._playLock))return u._queue.push({event:"seek",action:function(){u.seek.apply(u,d)}}),u;var g=u._soundById(p);if(g)if(typeof h=="number"&&h>=0){var y=u.playing(p);y&&u.pause(p,!0),g._seek=h,g._ended=!1,u._clearTimer(p),!u._webAudio&&g._node&&!isNaN(g._node.duration)&&(g._node.currentTime=h);var w=function(){y&&u.play(p,!0),u._emit("seek",p)};if(y&&!u._webAudio){var k=function(){u._playLock?setTimeout(k,0):w()};setTimeout(k,0)}else w()}else if(u._webAudio){var $=u.playing(p)?n.ctx.currentTime-g._playStart:0,x=g._rateSeek?g._rateSeek-g._seek:0;return g._seek+(x+$*Math.abs(g._rate))}else return g._node.currentTime;return u},playing:function(u){var d=this;if(typeof u=="number"){var h=d._soundById(u);return h?!h._paused:!1}for(var p=0;p<d._sounds.length;p++)if(!d._sounds[p]._paused)return!0;return!1},duration:function(u){var d=this,h=d._duration,p=d._soundById(u);return p&&(h=d._sprite[p._sprite][1]/1e3),h},state:function(){return this._state},unload:function(){for(var u=this,d=u._sounds,h=0;h<d.length;h++)d[h]._paused||u.stop(d[h]._id),u._webAudio||(u._clearSound(d[h]._node),d[h]._node.removeEventListener("error",d[h]._errorFn,!1),d[h]._node.removeEventListener(n._canPlayEvent,d[h]._loadFn,!1),d[h]._node.removeEventListener("ended",d[h]._endFn,!1),n._releaseHtml5Audio(d[h]._node)),delete d[h]._node,u._clearTimer(d[h]._id);var p=n._howls.indexOf(u);p>=0&&n._howls.splice(p,1);var m=!0;for(h=0;h<n._howls.length;h++)if(n._howls[h]._src===u._src||u._src.indexOf(n._howls[h]._src)>=0){m=!1;break}return i&&m&&delete i[u._src],n.noAudio=!1,u._state="unloaded",u._sounds=[],u=null,null},on:function(u,d,h,p){var m=this,v=m["_on"+u];return typeof d=="function"&&v.push(p?{id:h,fn:d,once:p}:{id:h,fn:d}),m},off:function(u,d,h){var p=this,m=p["_on"+u],v=0;if(typeof d=="number"&&(h=d,d=null),d||h)for(v=0;v<m.length;v++){var g=h===m[v].id;if(d===m[v].fn&&g||!d&&g){m.splice(v,1);break}}else if(u)p["_on"+u]=[];else{var y=Object.keys(p);for(v=0;v<y.length;v++)y[v].indexOf("_on")===0&&Array.isArray(p[y[v]])&&(p[y[v]]=[])}return p},once:function(u,d,h){var p=this;return p.on(u,d,h,1),p},_emit:function(u,d,h){for(var p=this,m=p["_on"+u],v=m.length-1;v>=0;v--)(!m[v].id||m[v].id===d||u==="load")&&(setTimeout(function(g){g.call(this,d,h)}.bind(p,m[v].fn),0),m[v].once&&p.off(u,m[v].fn,m[v].id));return p._loadQueue(u),p},_loadQueue:function(u){var d=this;if(d._queue.length>0){var h=d._queue[0];h.event===u&&(d._queue.shift(),d._loadQueue()),u||h.action()}return d},_ended:function(u){var d=this,h=u._sprite;if(!d._webAudio&&u._node&&!u._node.paused&&!u._node.ended&&u._node.currentTime<u._stop)return setTimeout(d._ended.bind(d,u),100),d;var p=!!(u._loop||d._sprite[h][2]);if(d._emit("end",u._id),!d._webAudio&&p&&d.stop(u._id,!0).play(u._id),d._webAudio&&p){d._emit("play",u._id),u._seek=u._start||0,u._rateSeek=0,u._playStart=n.ctx.currentTime;var m=(u._stop-u._start)*1e3/Math.abs(u._rate);d._endTimers[u._id]=setTimeout(d._ended.bind(d,u),m)}return d._webAudio&&!p&&(u._paused=!0,u._ended=!0,u._seek=u._start||0,u._rateSeek=0,d._clearTimer(u._id),d._cleanBuffer(u._node),n._autoSuspend()),!d._webAudio&&!p&&d.stop(u._id,!0),d},_clearTimer:function(u){var d=this;if(d._endTimers[u]){if(typeof d._endTimers[u]!="function")clearTimeout(d._endTimers[u]);else{var h=d._soundById(u);h&&h._node&&h._node.removeEventListener("ended",d._endTimers[u],!1)}delete d._endTimers[u]}return d},_soundById:function(u){for(var d=this,h=0;h<d._sounds.length;h++)if(u===d._sounds[h]._id)return d._sounds[h];return null},_inactiveSound:function(){var u=this;u._drain();for(var d=0;d<u._sounds.length;d++)if(u._sounds[d]._ended)return u._sounds[d].reset();return new o(u)},_drain:function(){var u=this,d=u._pool,h=0,p=0;if(!(u._sounds.length<d)){for(p=0;p<u._sounds.length;p++)u._sounds[p]._ended&&h++;for(p=u._sounds.length-1;p>=0;p--){if(h<=d)return;u._sounds[p]._ended&&(u._webAudio&&u._sounds[p]._node&&u._sounds[p]._node.disconnect(0),u._sounds.splice(p,1),h--)}}},_getSoundIds:function(u){var d=this;if(typeof u>"u"){for(var h=[],p=0;p<d._sounds.length;p++)h.push(d._sounds[p]._id);return h}else return[u]},_refreshBuffer:function(u){var d=this;return u._node.bufferSource=n.ctx.createBufferSource(),u._node.bufferSource.buffer=i[d._src],u._panner?u._node.bufferSource.connect(u._panner):u._node.bufferSource.connect(u._node),u._node.bufferSource.loop=u._loop,u._loop&&(u._node.bufferSource.loopStart=u._start||0,u._node.bufferSource.loopEnd=u._stop||0),u._node.bufferSource.playbackRate.setValueAtTime(u._rate,n.ctx.currentTime),d},_cleanBuffer:function(u){var d=this,h=n._navigator&&n._navigator.vendor.indexOf("Apple")>=0;if(n._scratchBuffer&&u.bufferSource&&(u.bufferSource.onended=null,u.bufferSource.disconnect(0),h))try{u.bufferSource.buffer=n._scratchBuffer}catch{}return u.bufferSource=null,d},_clearSound:function(u){var d=/MSIE |Trident\//.test(n._navigator&&n._navigator.userAgent);d||(u.src="data:audio/wav;base64,UklGRigAAABXQVZFZm10IBIAAAABAAEARKwAAIhYAQACABAAAABkYXRhAgAAAAEA")}};var o=function(u){this._parent=u,this.init()};o.prototype={init:function(){var u=this,d=u._parent;return u._muted=d._muted,u._loop=d._loop,u._volume=d._volume,u._rate=d._rate,u._seek=0,u._paused=!0,u._ended=!0,u._sprite="__default",u._id=++n._counter,d._sounds.push(u),u.create(),u},create:function(){var u=this,d=u._parent,h=n._muted||u._muted||u._parent._muted?0:u._volume;return d._webAudio?(u._node=typeof n.ctx.createGain>"u"?n.ctx.createGainNode():n.ctx.createGain(),u._node.gain.setValueAtTime(h,n.ctx.currentTime),u._node.paused=!0,u._node.connect(n.masterGain)):n.noAudio||(u._node=n._obtainHtml5Audio(),u._errorFn=u._errorListener.bind(u),u._node.addEventListener("error",u._errorFn,!1),u._loadFn=u._loadListener.bind(u),u._node.addEventListener(n._canPlayEvent,u._loadFn,!1),u._endFn=u._endListener.bind(u),u._node.addEventListener("ended",u._endFn,!1),u._node.src=d._src,u._node.preload=d._preload===!0?"auto":d._preload,u._node.volume=h*n.volume(),u._node.load()),u},reset:function(){var u=this,d=u._parent;return u._muted=d._muted,u._loop=d._loop,u._volume=d._volume,u._rate=d._rate,u._seek=0,u._rateSeek=0,u._paused=!0,u._ended=!0,u._sprite="__default",u._id=++n._counter,u},_errorListener:function(){var u=this;u._parent._emit("loaderror",u._id,u._node.error?u._node.error.code:0),u._node.removeEventListener("error",u._errorFn,!1)},_loadListener:function(){var u=this,d=u._parent;d._duration=Math.ceil(u._node.duration*10)/10,Object.keys(d._sprite).length===0&&(d._sprite={__default:[0,d._duration*1e3]}),d._state!=="loaded"&&(d._state="loaded",d._emit("load"),d._loadQueue()),u._node.removeEventListener(n._canPlayEvent,u._loadFn,!1)},_endListener:function(){var u=this,d=u._parent;d._duration===1/0&&(d._duration=Math.ceil(u._node.duration*10)/10,d._sprite.__default[1]===1/0&&(d._sprite.__default[1]=d._duration*1e3),d._ended(u)),u._node.removeEventListener("ended",u._endFn,!1)}};var i={},a=function(u){var d=u._src;if(i[d]){u._duration=i[d].duration,c(u);return}if(/^data:[^;]+;base64,/.test(d)){for(var h=atob(d.split(",")[1]),p=new Uint8Array(h.length),m=0;m<h.length;++m)p[m]=h.charCodeAt(m);l(p.buffer,u)}else{var v=new XMLHttpRequest;v.open(u._xhr.method,d,!0),v.withCredentials=u._xhr.withCredentials,v.responseType="arraybuffer",u._xhr.headers&&Object.keys(u._xhr.headers).forEach(function(g){v.setRequestHeader(g,u._xhr.headers[g])}),v.onload=function(){var g=(v.status+"")[0];if(g!=="0"&&g!=="2"&&g!=="3"){u._emit("loaderror",null,"Failed loading audio file with status: "+v.status+".");return}l(v.response,u)},v.onerror=function(){u._webAudio&&(u._html5=!0,u._webAudio=!1,u._sounds=[],delete i[d],u.load())},s(v)}},s=function(u){try{u.send()}catch{u.onerror()}},l=function(u,d){var h=function(){d._emit("loaderror",null,"Decoding audio data failed.")},p=function(m){m&&d._sounds.length>0?(i[d._src]=m,c(d,m)):h()};typeof Promise<"u"&&n.ctx.decodeAudioData.length===1?n.ctx.decodeAudioData(u).then(p).catch(h):n.ctx.decodeAudioData(u,p,h)},c=function(u,d){d&&!u._duration&&(u._duration=d.duration),Object.keys(u._sprite).length===0&&(u._sprite={__default:[0,u._duration*1e3]}),u._state!=="loaded"&&(u._state="loaded",u._emit("load"),u._loadQueue())},f=function(){if(n.usingWebAudio){try{typeof AudioContext<"u"?n.ctx=new AudioContext:typeof webkitAudioContext<"u"?n.ctx=new webkitAudioContext:n.usingWebAudio=!1}catch{n.usingWebAudio=!1}n.ctx||(n.usingWebAudio=!1);var u=/iP(hone|od|ad)/.test(n._navigator&&n._navigator.platform),d=n._navigator&&n._navigator.appVersion.match(/OS (\d+)_(\d+)_?(\d+)?/),h=d?parseInt(d[1],10):null;if(u&&h&&h<9){var p=/safari/.test(n._navigator&&n._navigator.userAgent.toLowerCase());n._navigator&&!p&&(n.usingWebAudio=!1)}n.usingWebAudio&&(n.masterGain=typeof n.ctx.createGain>"u"?n.ctx.createGainNode():n.ctx.createGain(),n.masterGain.gain.setValueAtTime(n._muted?0:n._volume,n.ctx.currentTime),n.masterGain.connect(n.ctx.destination)),n._setup()}};e.Howler=n,e.Howl=r,typeof Wo<"u"?(Wo.HowlerGlobal=t,Wo.Howler=n,Wo.Howl=r,Wo.Sound=o):typeof window<"u"&&(window.HowlerGlobal=t,window.Howler=n,window.Howl=r,window.Sound=o)})();/*!
151
+ */(function(e){(function(){var t=function(){this.init()};t.prototype={init:function(){var u=this||n;return u._counter=1e3,u._html5AudioPool=[],u.html5PoolSize=10,u._codecs={},u._howls=[],u._muted=!1,u._volume=1,u._canPlayEvent="canplaythrough",u._navigator=typeof window<"u"&&window.navigator?window.navigator:null,u.masterGain=null,u.noAudio=!1,u.usingWebAudio=!0,u.autoSuspend=!0,u.ctx=null,u.autoUnlock=!0,u._setup(),u},volume:function(u){var d=this||n;if(u=parseFloat(u),d.ctx||f(),typeof u<"u"&&u>=0&&u<=1){if(d._volume=u,d._muted)return d;d.usingWebAudio&&d.masterGain.gain.setValueAtTime(u,n.ctx.currentTime);for(var h=0;h<d._howls.length;h++)if(!d._howls[h]._webAudio)for(var p=d._howls[h]._getSoundIds(),m=0;m<p.length;m++){var v=d._howls[h]._soundById(p[m]);v&&v._node&&(v._node.volume=v._volume*u)}return d}return d._volume},mute:function(u){var d=this||n;d.ctx||f(),d._muted=u,d.usingWebAudio&&d.masterGain.gain.setValueAtTime(u?0:d._volume,n.ctx.currentTime);for(var h=0;h<d._howls.length;h++)if(!d._howls[h]._webAudio)for(var p=d._howls[h]._getSoundIds(),m=0;m<p.length;m++){var v=d._howls[h]._soundById(p[m]);v&&v._node&&(v._node.muted=u?!0:v._muted)}return d},stop:function(){for(var u=this||n,d=0;d<u._howls.length;d++)u._howls[d].stop();return u},unload:function(){for(var u=this||n,d=u._howls.length-1;d>=0;d--)u._howls[d].unload();return u.usingWebAudio&&u.ctx&&typeof u.ctx.close<"u"&&(u.ctx.close(),u.ctx=null,f()),u},codecs:function(u){return(this||n)._codecs[u.replace(/^x-/,"")]},_setup:function(){var u=this||n;if(u.state=u.ctx&&u.ctx.state||"suspended",u._autoSuspend(),!u.usingWebAudio)if(typeof Audio<"u")try{var d=new Audio;typeof d.oncanplaythrough>"u"&&(u._canPlayEvent="canplay")}catch{u.noAudio=!0}else u.noAudio=!0;try{var d=new Audio;d.muted&&(u.noAudio=!0)}catch{}return u.noAudio||u._setupCodecs(),u},_setupCodecs:function(){var u=this||n,d=null;try{d=typeof Audio<"u"?new Audio:null}catch{return u}if(!d||typeof d.canPlayType!="function")return u;var h=d.canPlayType("audio/mpeg;").replace(/^no$/,""),p=u._navigator?u._navigator.userAgent:"",m=p.match(/OPR\/([0-6].)/g),v=m&&parseInt(m[0].split("/")[1],10)<33,g=p.indexOf("Safari")!==-1&&p.indexOf("Chrome")===-1,y=p.match(/Version\/(.*?) /),w=g&&y&&parseInt(y[1],10)<15;return u._codecs={mp3:!!(!v&&(h||d.canPlayType("audio/mp3;").replace(/^no$/,""))),mpeg:!!h,opus:!!d.canPlayType('audio/ogg; codecs="opus"').replace(/^no$/,""),ogg:!!d.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/,""),oga:!!d.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/,""),wav:!!(d.canPlayType('audio/wav; codecs="1"')||d.canPlayType("audio/wav")).replace(/^no$/,""),aac:!!d.canPlayType("audio/aac;").replace(/^no$/,""),caf:!!d.canPlayType("audio/x-caf;").replace(/^no$/,""),m4a:!!(d.canPlayType("audio/x-m4a;")||d.canPlayType("audio/m4a;")||d.canPlayType("audio/aac;")).replace(/^no$/,""),m4b:!!(d.canPlayType("audio/x-m4b;")||d.canPlayType("audio/m4b;")||d.canPlayType("audio/aac;")).replace(/^no$/,""),mp4:!!(d.canPlayType("audio/x-mp4;")||d.canPlayType("audio/mp4;")||d.canPlayType("audio/aac;")).replace(/^no$/,""),weba:!!(!w&&d.canPlayType('audio/webm; codecs="vorbis"').replace(/^no$/,"")),webm:!!(!w&&d.canPlayType('audio/webm; codecs="vorbis"').replace(/^no$/,"")),dolby:!!d.canPlayType('audio/mp4; codecs="ec-3"').replace(/^no$/,""),flac:!!(d.canPlayType("audio/x-flac;")||d.canPlayType("audio/flac;")).replace(/^no$/,"")},u},_unlockAudio:function(){var u=this||n;if(!(u._audioUnlocked||!u.ctx)){u._audioUnlocked=!1,u.autoUnlock=!1,!u._mobileUnloaded&&u.ctx.sampleRate!==44100&&(u._mobileUnloaded=!0,u.unload()),u._scratchBuffer=u.ctx.createBuffer(1,1,22050);var d=function(h){for(;u._html5AudioPool.length<u.html5PoolSize;)try{var p=new Audio;p._unlocked=!0,u._releaseHtml5Audio(p)}catch{u.noAudio=!0;break}for(var m=0;m<u._howls.length;m++)if(!u._howls[m]._webAudio)for(var v=u._howls[m]._getSoundIds(),g=0;g<v.length;g++){var y=u._howls[m]._soundById(v[g]);y&&y._node&&!y._node._unlocked&&(y._node._unlocked=!0,y._node.load())}u._autoResume();var w=u.ctx.createBufferSource();w.buffer=u._scratchBuffer,w.connect(u.ctx.destination),typeof w.start>"u"?w.noteOn(0):w.start(0),typeof u.ctx.resume=="function"&&u.ctx.resume(),w.onended=function(){w.disconnect(0),u._audioUnlocked=!0,document.removeEventListener("touchstart",d,!0),document.removeEventListener("touchend",d,!0),document.removeEventListener("click",d,!0),document.removeEventListener("keydown",d,!0);for(var k=0;k<u._howls.length;k++)u._howls[k]._emit("unlock")}};return document.addEventListener("touchstart",d,!0),document.addEventListener("touchend",d,!0),document.addEventListener("click",d,!0),document.addEventListener("keydown",d,!0),u}},_obtainHtml5Audio:function(){var u=this||n;if(u._html5AudioPool.length)return u._html5AudioPool.pop();var d=new Audio().play();return d&&typeof Promise<"u"&&(d instanceof Promise||typeof d.then=="function")&&d.catch(function(){console.warn("HTML5 Audio pool exhausted, returning potentially locked audio object.")}),new Audio},_releaseHtml5Audio:function(u){var d=this||n;return u._unlocked&&d._html5AudioPool.push(u),d},_autoSuspend:function(){var u=this;if(!(!u.autoSuspend||!u.ctx||typeof u.ctx.suspend>"u"||!n.usingWebAudio)){for(var d=0;d<u._howls.length;d++)if(u._howls[d]._webAudio){for(var h=0;h<u._howls[d]._sounds.length;h++)if(!u._howls[d]._sounds[h]._paused)return u}return u._suspendTimer&&clearTimeout(u._suspendTimer),u._suspendTimer=setTimeout(function(){if(u.autoSuspend){u._suspendTimer=null,u.state="suspending";var p=function(){u.state="suspended",u._resumeAfterSuspend&&(delete u._resumeAfterSuspend,u._autoResume())};u.ctx.suspend().then(p,p)}},3e4),u}},_autoResume:function(){var u=this;if(!(!u.ctx||typeof u.ctx.resume>"u"||!n.usingWebAudio))return u.state==="running"&&u.ctx.state!=="interrupted"&&u._suspendTimer?(clearTimeout(u._suspendTimer),u._suspendTimer=null):u.state==="suspended"||u.state==="running"&&u.ctx.state==="interrupted"?(u.ctx.resume().then(function(){u.state="running";for(var d=0;d<u._howls.length;d++)u._howls[d]._emit("resume")}),u._suspendTimer&&(clearTimeout(u._suspendTimer),u._suspendTimer=null)):u.state==="suspending"&&(u._resumeAfterSuspend=!0),u}};var n=new t,r=function(u){var d=this;if(!u.src||u.src.length===0){console.error("An array of source files must be passed with any new Howl.");return}d.init(u)};r.prototype={init:function(u){var d=this;return n.ctx||f(),d._autoplay=u.autoplay||!1,d._format=typeof u.format!="string"?u.format:[u.format],d._html5=u.html5||!1,d._muted=u.mute||!1,d._loop=u.loop||!1,d._pool=u.pool||5,d._preload=typeof u.preload=="boolean"||u.preload==="metadata"?u.preload:!0,d._rate=u.rate||1,d._sprite=u.sprite||{},d._src=typeof u.src!="string"?u.src:[u.src],d._volume=u.volume!==void 0?u.volume:1,d._xhr={method:u.xhr&&u.xhr.method?u.xhr.method:"GET",headers:u.xhr&&u.xhr.headers?u.xhr.headers:null,withCredentials:u.xhr&&u.xhr.withCredentials?u.xhr.withCredentials:!1},d._duration=0,d._state="unloaded",d._sounds=[],d._endTimers={},d._queue=[],d._playLock=!1,d._onend=u.onend?[{fn:u.onend}]:[],d._onfade=u.onfade?[{fn:u.onfade}]:[],d._onload=u.onload?[{fn:u.onload}]:[],d._onloaderror=u.onloaderror?[{fn:u.onloaderror}]:[],d._onplayerror=u.onplayerror?[{fn:u.onplayerror}]:[],d._onpause=u.onpause?[{fn:u.onpause}]:[],d._onplay=u.onplay?[{fn:u.onplay}]:[],d._onstop=u.onstop?[{fn:u.onstop}]:[],d._onmute=u.onmute?[{fn:u.onmute}]:[],d._onvolume=u.onvolume?[{fn:u.onvolume}]:[],d._onrate=u.onrate?[{fn:u.onrate}]:[],d._onseek=u.onseek?[{fn:u.onseek}]:[],d._onunlock=u.onunlock?[{fn:u.onunlock}]:[],d._onresume=[],d._webAudio=n.usingWebAudio&&!d._html5,typeof n.ctx<"u"&&n.ctx&&n.autoUnlock&&n._unlockAudio(),n._howls.push(d),d._autoplay&&d._queue.push({event:"play",action:function(){d.play()}}),d._preload&&d._preload!=="none"&&d.load(),d},load:function(){var u=this,d=null;if(n.noAudio){u._emit("loaderror",null,"No audio support.");return}typeof u._src=="string"&&(u._src=[u._src]);for(var h=0;h<u._src.length;h++){var p,m;if(u._format&&u._format[h])p=u._format[h];else{if(m=u._src[h],typeof m!="string"){u._emit("loaderror",null,"Non-string found in selected audio sources - ignoring.");continue}p=/^data:audio\/([^;,]+);/i.exec(m),p||(p=/\.([^.]+)$/.exec(m.split("?",1)[0])),p&&(p=p[1].toLowerCase())}if(p||console.warn('No file extension was found. Consider using the "format" property or specify an extension.'),p&&n.codecs(p)){d=u._src[h];break}}if(!d){u._emit("loaderror",null,"No codec support for selected audio sources.");return}return u._src=d,u._state="loading",window.location.protocol==="https:"&&d.slice(0,5)==="http:"&&(u._html5=!0,u._webAudio=!1),new o(u),u._webAudio&&a(u),u},play:function(u,d){var h=this,p=null;if(typeof u=="number")p=u,u=null;else{if(typeof u=="string"&&h._state==="loaded"&&!h._sprite[u])return null;if(typeof u>"u"&&(u="__default",!h._playLock)){for(var m=0,v=0;v<h._sounds.length;v++)h._sounds[v]._paused&&!h._sounds[v]._ended&&(m++,p=h._sounds[v]._id);m===1?u=null:p=null}}var g=p?h._soundById(p):h._inactiveSound();if(!g)return null;if(p&&!u&&(u=g._sprite||"__default"),h._state!=="loaded"){g._sprite=u,g._ended=!1;var y=g._id;return h._queue.push({event:"play",action:function(){h.play(y)}}),y}if(p&&!g._paused)return d||h._loadQueue("play"),g._id;h._webAudio&&n._autoResume();var w=Math.max(0,g._seek>0?g._seek:h._sprite[u][0]/1e3),k=Math.max(0,(h._sprite[u][0]+h._sprite[u][1])/1e3-w),$=k*1e3/Math.abs(g._rate),x=h._sprite[u][0]/1e3,E=(h._sprite[u][0]+h._sprite[u][1])/1e3;g._sprite=u,g._ended=!1;var R=function(){g._paused=!1,g._seek=w,g._start=x,g._stop=E,g._loop=!!(g._loop||h._sprite[u][2])};if(w>=E){h._ended(g);return}var M=g._node;if(h._webAudio){var j=function(){h._playLock=!1,R(),h._refreshBuffer(g);var T=g._muted||h._muted?0:g._volume;M.gain.setValueAtTime(T,n.ctx.currentTime),g._playStart=n.ctx.currentTime,typeof M.bufferSource.start>"u"?g._loop?M.bufferSource.noteGrainOn(0,w,86400):M.bufferSource.noteGrainOn(0,w,k):g._loop?M.bufferSource.start(0,w,86400):M.bufferSource.start(0,w,k),$!==1/0&&(h._endTimers[g._id]=setTimeout(h._ended.bind(h,g),$)),d||setTimeout(function(){h._emit("play",g._id),h._loadQueue()},0)};n.state==="running"&&n.ctx.state!=="interrupted"?j():(h._playLock=!0,h.once("resume",j),h._clearTimer(g._id))}else{var C=function(){M.currentTime=w,M.muted=g._muted||h._muted||n._muted||M.muted,M.volume=g._volume*n.volume(),M.playbackRate=g._rate;try{var T=M.play();if(T&&typeof Promise<"u"&&(T instanceof Promise||typeof T.then=="function")?(h._playLock=!0,R(),T.then(function(){h._playLock=!1,M._unlocked=!0,d?h._loadQueue():h._emit("play",g._id)}).catch(function(){h._playLock=!1,h._emit("playerror",g._id,"Playback was unable to start. This is most commonly an issue on mobile devices and Chrome where playback was not within a user interaction."),g._ended=!0,g._paused=!0})):d||(h._playLock=!1,R(),h._emit("play",g._id)),M.playbackRate=g._rate,M.paused){h._emit("playerror",g._id,"Playback was unable to start. This is most commonly an issue on mobile devices and Chrome where playback was not within a user interaction.");return}u!=="__default"||g._loop?h._endTimers[g._id]=setTimeout(h._ended.bind(h,g),$):(h._endTimers[g._id]=function(){h._ended(g),M.removeEventListener("ended",h._endTimers[g._id],!1)},M.addEventListener("ended",h._endTimers[g._id],!1))}catch(L){h._emit("playerror",g._id,L)}};M.src==="data:audio/wav;base64,UklGRigAAABXQVZFZm10IBIAAAABAAEARKwAAIhYAQACABAAAABkYXRhAgAAAAEA"&&(M.src=h._src,M.load());var O=window&&window.ejecta||!M.readyState&&n._navigator.isCocoonJS;if(M.readyState>=3||O)C();else{h._playLock=!0,h._state="loading";var F=function(){h._state="loaded",C(),M.removeEventListener(n._canPlayEvent,F,!1)};M.addEventListener(n._canPlayEvent,F,!1),h._clearTimer(g._id)}}return g._id},pause:function(u){var d=this;if(d._state!=="loaded"||d._playLock)return d._queue.push({event:"pause",action:function(){d.pause(u)}}),d;for(var h=d._getSoundIds(u),p=0;p<h.length;p++){d._clearTimer(h[p]);var m=d._soundById(h[p]);if(m&&!m._paused&&(m._seek=d.seek(h[p]),m._rateSeek=0,m._paused=!0,d._stopFade(h[p]),m._node))if(d._webAudio){if(!m._node.bufferSource)continue;typeof m._node.bufferSource.stop>"u"?m._node.bufferSource.noteOff(0):m._node.bufferSource.stop(0),d._cleanBuffer(m._node)}else(!isNaN(m._node.duration)||m._node.duration===1/0)&&m._node.pause();arguments[1]||d._emit("pause",m?m._id:null)}return d},stop:function(u,d){var h=this;if(h._state!=="loaded"||h._playLock)return h._queue.push({event:"stop",action:function(){h.stop(u)}}),h;for(var p=h._getSoundIds(u),m=0;m<p.length;m++){h._clearTimer(p[m]);var v=h._soundById(p[m]);v&&(v._seek=v._start||0,v._rateSeek=0,v._paused=!0,v._ended=!0,h._stopFade(p[m]),v._node&&(h._webAudio?v._node.bufferSource&&(typeof v._node.bufferSource.stop>"u"?v._node.bufferSource.noteOff(0):v._node.bufferSource.stop(0),h._cleanBuffer(v._node)):(!isNaN(v._node.duration)||v._node.duration===1/0)&&(v._node.currentTime=v._start||0,v._node.pause(),v._node.duration===1/0&&h._clearSound(v._node))),d||h._emit("stop",v._id))}return h},mute:function(u,d){var h=this;if(h._state!=="loaded"||h._playLock)return h._queue.push({event:"mute",action:function(){h.mute(u,d)}}),h;if(typeof d>"u")if(typeof u=="boolean")h._muted=u;else return h._muted;for(var p=h._getSoundIds(d),m=0;m<p.length;m++){var v=h._soundById(p[m]);v&&(v._muted=u,v._interval&&h._stopFade(v._id),h._webAudio&&v._node?v._node.gain.setValueAtTime(u?0:v._volume,n.ctx.currentTime):v._node&&(v._node.muted=n._muted?!0:u),h._emit("mute",v._id))}return h},volume:function(){var u=this,d=arguments,h,p;if(d.length===0)return u._volume;if(d.length===1||d.length===2&&typeof d[1]>"u"){var m=u._getSoundIds(),v=m.indexOf(d[0]);v>=0?p=parseInt(d[0],10):h=parseFloat(d[0])}else d.length>=2&&(h=parseFloat(d[0]),p=parseInt(d[1],10));var g;if(typeof h<"u"&&h>=0&&h<=1){if(u._state!=="loaded"||u._playLock)return u._queue.push({event:"volume",action:function(){u.volume.apply(u,d)}}),u;typeof p>"u"&&(u._volume=h),p=u._getSoundIds(p);for(var y=0;y<p.length;y++)g=u._soundById(p[y]),g&&(g._volume=h,d[2]||u._stopFade(p[y]),u._webAudio&&g._node&&!g._muted?g._node.gain.setValueAtTime(h,n.ctx.currentTime):g._node&&!g._muted&&(g._node.volume=h*n.volume()),u._emit("volume",g._id))}else return g=p?u._soundById(p):u._sounds[0],g?g._volume:0;return u},fade:function(u,d,h,p){var m=this;if(m._state!=="loaded"||m._playLock)return m._queue.push({event:"fade",action:function(){m.fade(u,d,h,p)}}),m;u=Math.min(Math.max(0,parseFloat(u)),1),d=Math.min(Math.max(0,parseFloat(d)),1),h=parseFloat(h),m.volume(u,p);for(var v=m._getSoundIds(p),g=0;g<v.length;g++){var y=m._soundById(v[g]);if(y){if(p||m._stopFade(v[g]),m._webAudio&&!y._muted){var w=n.ctx.currentTime,k=w+h/1e3;y._volume=u,y._node.gain.setValueAtTime(u,w),y._node.gain.linearRampToValueAtTime(d,k)}m._startFadeInterval(y,u,d,h,v[g],typeof p>"u")}}return m},_startFadeInterval:function(u,d,h,p,m,v){var g=this,y=d,w=h-d,k=Math.abs(w/.01),$=Math.max(4,k>0?p/k:p),x=Date.now();u._fadeTo=h,u._interval=setInterval(function(){var E=(Date.now()-x)/p;x=Date.now(),y+=w*E,y=Math.round(y*100)/100,w<0?y=Math.max(h,y):y=Math.min(h,y),g._webAudio?u._volume=y:g.volume(y,u._id,!0),v&&(g._volume=y),(h<d&&y<=h||h>d&&y>=h)&&(clearInterval(u._interval),u._interval=null,u._fadeTo=null,g.volume(h,u._id),g._emit("fade",u._id))},$)},_stopFade:function(u){var d=this,h=d._soundById(u);return h&&h._interval&&(d._webAudio&&h._node.gain.cancelScheduledValues(n.ctx.currentTime),clearInterval(h._interval),h._interval=null,d.volume(h._fadeTo,u),h._fadeTo=null,d._emit("fade",u)),d},loop:function(){var u=this,d=arguments,h,p,m;if(d.length===0)return u._loop;if(d.length===1)if(typeof d[0]=="boolean")h=d[0],u._loop=h;else return m=u._soundById(parseInt(d[0],10)),m?m._loop:!1;else d.length===2&&(h=d[0],p=parseInt(d[1],10));for(var v=u._getSoundIds(p),g=0;g<v.length;g++)m=u._soundById(v[g]),m&&(m._loop=h,u._webAudio&&m._node&&m._node.bufferSource&&(m._node.bufferSource.loop=h,h&&(m._node.bufferSource.loopStart=m._start||0,m._node.bufferSource.loopEnd=m._stop,u.playing(v[g])&&(u.pause(v[g],!0),u.play(v[g],!0)))));return u},rate:function(){var u=this,d=arguments,h,p;if(d.length===0)p=u._sounds[0]._id;else if(d.length===1){var m=u._getSoundIds(),v=m.indexOf(d[0]);v>=0?p=parseInt(d[0],10):h=parseFloat(d[0])}else d.length===2&&(h=parseFloat(d[0]),p=parseInt(d[1],10));var g;if(typeof h=="number"){if(u._state!=="loaded"||u._playLock)return u._queue.push({event:"rate",action:function(){u.rate.apply(u,d)}}),u;typeof p>"u"&&(u._rate=h),p=u._getSoundIds(p);for(var y=0;y<p.length;y++)if(g=u._soundById(p[y]),g){u.playing(p[y])&&(g._rateSeek=u.seek(p[y]),g._playStart=u._webAudio?n.ctx.currentTime:g._playStart),g._rate=h,u._webAudio&&g._node&&g._node.bufferSource?g._node.bufferSource.playbackRate.setValueAtTime(h,n.ctx.currentTime):g._node&&(g._node.playbackRate=h);var w=u.seek(p[y]),k=(u._sprite[g._sprite][0]+u._sprite[g._sprite][1])/1e3-w,$=k*1e3/Math.abs(g._rate);(u._endTimers[p[y]]||!g._paused)&&(u._clearTimer(p[y]),u._endTimers[p[y]]=setTimeout(u._ended.bind(u,g),$)),u._emit("rate",g._id)}}else return g=u._soundById(p),g?g._rate:u._rate;return u},seek:function(){var u=this,d=arguments,h,p;if(d.length===0)u._sounds.length&&(p=u._sounds[0]._id);else if(d.length===1){var m=u._getSoundIds(),v=m.indexOf(d[0]);v>=0?p=parseInt(d[0],10):u._sounds.length&&(p=u._sounds[0]._id,h=parseFloat(d[0]))}else d.length===2&&(h=parseFloat(d[0]),p=parseInt(d[1],10));if(typeof p>"u")return 0;if(typeof h=="number"&&(u._state!=="loaded"||u._playLock))return u._queue.push({event:"seek",action:function(){u.seek.apply(u,d)}}),u;var g=u._soundById(p);if(g)if(typeof h=="number"&&h>=0){var y=u.playing(p);y&&u.pause(p,!0),g._seek=h,g._ended=!1,u._clearTimer(p),!u._webAudio&&g._node&&!isNaN(g._node.duration)&&(g._node.currentTime=h);var w=function(){y&&u.play(p,!0),u._emit("seek",p)};if(y&&!u._webAudio){var k=function(){u._playLock?setTimeout(k,0):w()};setTimeout(k,0)}else w()}else if(u._webAudio){var $=u.playing(p)?n.ctx.currentTime-g._playStart:0,x=g._rateSeek?g._rateSeek-g._seek:0;return g._seek+(x+$*Math.abs(g._rate))}else return g._node.currentTime;return u},playing:function(u){var d=this;if(typeof u=="number"){var h=d._soundById(u);return h?!h._paused:!1}for(var p=0;p<d._sounds.length;p++)if(!d._sounds[p]._paused)return!0;return!1},duration:function(u){var d=this,h=d._duration,p=d._soundById(u);return p&&(h=d._sprite[p._sprite][1]/1e3),h},state:function(){return this._state},unload:function(){for(var u=this,d=u._sounds,h=0;h<d.length;h++)d[h]._paused||u.stop(d[h]._id),u._webAudio||(u._clearSound(d[h]._node),d[h]._node.removeEventListener("error",d[h]._errorFn,!1),d[h]._node.removeEventListener(n._canPlayEvent,d[h]._loadFn,!1),d[h]._node.removeEventListener("ended",d[h]._endFn,!1),n._releaseHtml5Audio(d[h]._node)),delete d[h]._node,u._clearTimer(d[h]._id);var p=n._howls.indexOf(u);p>=0&&n._howls.splice(p,1);var m=!0;for(h=0;h<n._howls.length;h++)if(n._howls[h]._src===u._src||u._src.indexOf(n._howls[h]._src)>=0){m=!1;break}return i&&m&&delete i[u._src],n.noAudio=!1,u._state="unloaded",u._sounds=[],u=null,null},on:function(u,d,h,p){var m=this,v=m["_on"+u];return typeof d=="function"&&v.push(p?{id:h,fn:d,once:p}:{id:h,fn:d}),m},off:function(u,d,h){var p=this,m=p["_on"+u],v=0;if(typeof d=="number"&&(h=d,d=null),d||h)for(v=0;v<m.length;v++){var g=h===m[v].id;if(d===m[v].fn&&g||!d&&g){m.splice(v,1);break}}else if(u)p["_on"+u]=[];else{var y=Object.keys(p);for(v=0;v<y.length;v++)y[v].indexOf("_on")===0&&Array.isArray(p[y[v]])&&(p[y[v]]=[])}return p},once:function(u,d,h){var p=this;return p.on(u,d,h,1),p},_emit:function(u,d,h){for(var p=this,m=p["_on"+u],v=m.length-1;v>=0;v--)(!m[v].id||m[v].id===d||u==="load")&&(setTimeout((function(g){g.call(this,d,h)}).bind(p,m[v].fn),0),m[v].once&&p.off(u,m[v].fn,m[v].id));return p._loadQueue(u),p},_loadQueue:function(u){var d=this;if(d._queue.length>0){var h=d._queue[0];h.event===u&&(d._queue.shift(),d._loadQueue()),u||h.action()}return d},_ended:function(u){var d=this,h=u._sprite;if(!d._webAudio&&u._node&&!u._node.paused&&!u._node.ended&&u._node.currentTime<u._stop)return setTimeout(d._ended.bind(d,u),100),d;var p=!!(u._loop||d._sprite[h][2]);if(d._emit("end",u._id),!d._webAudio&&p&&d.stop(u._id,!0).play(u._id),d._webAudio&&p){d._emit("play",u._id),u._seek=u._start||0,u._rateSeek=0,u._playStart=n.ctx.currentTime;var m=(u._stop-u._start)*1e3/Math.abs(u._rate);d._endTimers[u._id]=setTimeout(d._ended.bind(d,u),m)}return d._webAudio&&!p&&(u._paused=!0,u._ended=!0,u._seek=u._start||0,u._rateSeek=0,d._clearTimer(u._id),d._cleanBuffer(u._node),n._autoSuspend()),!d._webAudio&&!p&&d.stop(u._id,!0),d},_clearTimer:function(u){var d=this;if(d._endTimers[u]){if(typeof d._endTimers[u]!="function")clearTimeout(d._endTimers[u]);else{var h=d._soundById(u);h&&h._node&&h._node.removeEventListener("ended",d._endTimers[u],!1)}delete d._endTimers[u]}return d},_soundById:function(u){for(var d=this,h=0;h<d._sounds.length;h++)if(u===d._sounds[h]._id)return d._sounds[h];return null},_inactiveSound:function(){var u=this;u._drain();for(var d=0;d<u._sounds.length;d++)if(u._sounds[d]._ended)return u._sounds[d].reset();return new o(u)},_drain:function(){var u=this,d=u._pool,h=0,p=0;if(!(u._sounds.length<d)){for(p=0;p<u._sounds.length;p++)u._sounds[p]._ended&&h++;for(p=u._sounds.length-1;p>=0;p--){if(h<=d)return;u._sounds[p]._ended&&(u._webAudio&&u._sounds[p]._node&&u._sounds[p]._node.disconnect(0),u._sounds.splice(p,1),h--)}}},_getSoundIds:function(u){var d=this;if(typeof u>"u"){for(var h=[],p=0;p<d._sounds.length;p++)h.push(d._sounds[p]._id);return h}else return[u]},_refreshBuffer:function(u){var d=this;return u._node.bufferSource=n.ctx.createBufferSource(),u._node.bufferSource.buffer=i[d._src],u._panner?u._node.bufferSource.connect(u._panner):u._node.bufferSource.connect(u._node),u._node.bufferSource.loop=u._loop,u._loop&&(u._node.bufferSource.loopStart=u._start||0,u._node.bufferSource.loopEnd=u._stop||0),u._node.bufferSource.playbackRate.setValueAtTime(u._rate,n.ctx.currentTime),d},_cleanBuffer:function(u){var d=this,h=n._navigator&&n._navigator.vendor.indexOf("Apple")>=0;if(n._scratchBuffer&&u.bufferSource&&(u.bufferSource.onended=null,u.bufferSource.disconnect(0),h))try{u.bufferSource.buffer=n._scratchBuffer}catch{}return u.bufferSource=null,d},_clearSound:function(u){var d=/MSIE |Trident\//.test(n._navigator&&n._navigator.userAgent);d||(u.src="data:audio/wav;base64,UklGRigAAABXQVZFZm10IBIAAAABAAEARKwAAIhYAQACABAAAABkYXRhAgAAAAEA")}};var o=function(u){this._parent=u,this.init()};o.prototype={init:function(){var u=this,d=u._parent;return u._muted=d._muted,u._loop=d._loop,u._volume=d._volume,u._rate=d._rate,u._seek=0,u._paused=!0,u._ended=!0,u._sprite="__default",u._id=++n._counter,d._sounds.push(u),u.create(),u},create:function(){var u=this,d=u._parent,h=n._muted||u._muted||u._parent._muted?0:u._volume;return d._webAudio?(u._node=typeof n.ctx.createGain>"u"?n.ctx.createGainNode():n.ctx.createGain(),u._node.gain.setValueAtTime(h,n.ctx.currentTime),u._node.paused=!0,u._node.connect(n.masterGain)):n.noAudio||(u._node=n._obtainHtml5Audio(),u._errorFn=u._errorListener.bind(u),u._node.addEventListener("error",u._errorFn,!1),u._loadFn=u._loadListener.bind(u),u._node.addEventListener(n._canPlayEvent,u._loadFn,!1),u._endFn=u._endListener.bind(u),u._node.addEventListener("ended",u._endFn,!1),u._node.src=d._src,u._node.preload=d._preload===!0?"auto":d._preload,u._node.volume=h*n.volume(),u._node.load()),u},reset:function(){var u=this,d=u._parent;return u._muted=d._muted,u._loop=d._loop,u._volume=d._volume,u._rate=d._rate,u._seek=0,u._rateSeek=0,u._paused=!0,u._ended=!0,u._sprite="__default",u._id=++n._counter,u},_errorListener:function(){var u=this;u._parent._emit("loaderror",u._id,u._node.error?u._node.error.code:0),u._node.removeEventListener("error",u._errorFn,!1)},_loadListener:function(){var u=this,d=u._parent;d._duration=Math.ceil(u._node.duration*10)/10,Object.keys(d._sprite).length===0&&(d._sprite={__default:[0,d._duration*1e3]}),d._state!=="loaded"&&(d._state="loaded",d._emit("load"),d._loadQueue()),u._node.removeEventListener(n._canPlayEvent,u._loadFn,!1)},_endListener:function(){var u=this,d=u._parent;d._duration===1/0&&(d._duration=Math.ceil(u._node.duration*10)/10,d._sprite.__default[1]===1/0&&(d._sprite.__default[1]=d._duration*1e3),d._ended(u)),u._node.removeEventListener("ended",u._endFn,!1)}};var i={},a=function(u){var d=u._src;if(i[d]){u._duration=i[d].duration,c(u);return}if(/^data:[^;]+;base64,/.test(d)){for(var h=atob(d.split(",")[1]),p=new Uint8Array(h.length),m=0;m<h.length;++m)p[m]=h.charCodeAt(m);l(p.buffer,u)}else{var v=new XMLHttpRequest;v.open(u._xhr.method,d,!0),v.withCredentials=u._xhr.withCredentials,v.responseType="arraybuffer",u._xhr.headers&&Object.keys(u._xhr.headers).forEach(function(g){v.setRequestHeader(g,u._xhr.headers[g])}),v.onload=function(){var g=(v.status+"")[0];if(g!=="0"&&g!=="2"&&g!=="3"){u._emit("loaderror",null,"Failed loading audio file with status: "+v.status+".");return}l(v.response,u)},v.onerror=function(){u._webAudio&&(u._html5=!0,u._webAudio=!1,u._sounds=[],delete i[d],u.load())},s(v)}},s=function(u){try{u.send()}catch{u.onerror()}},l=function(u,d){var h=function(){d._emit("loaderror",null,"Decoding audio data failed.")},p=function(m){m&&d._sounds.length>0?(i[d._src]=m,c(d,m)):h()};typeof Promise<"u"&&n.ctx.decodeAudioData.length===1?n.ctx.decodeAudioData(u).then(p).catch(h):n.ctx.decodeAudioData(u,p,h)},c=function(u,d){d&&!u._duration&&(u._duration=d.duration),Object.keys(u._sprite).length===0&&(u._sprite={__default:[0,u._duration*1e3]}),u._state!=="loaded"&&(u._state="loaded",u._emit("load"),u._loadQueue())},f=function(){if(n.usingWebAudio){try{typeof AudioContext<"u"?n.ctx=new AudioContext:typeof webkitAudioContext<"u"?n.ctx=new webkitAudioContext:n.usingWebAudio=!1}catch{n.usingWebAudio=!1}n.ctx||(n.usingWebAudio=!1);var u=/iP(hone|od|ad)/.test(n._navigator&&n._navigator.platform),d=n._navigator&&n._navigator.appVersion.match(/OS (\d+)_(\d+)_?(\d+)?/),h=d?parseInt(d[1],10):null;if(u&&h&&h<9){var p=/safari/.test(n._navigator&&n._navigator.userAgent.toLowerCase());n._navigator&&!p&&(n.usingWebAudio=!1)}n.usingWebAudio&&(n.masterGain=typeof n.ctx.createGain>"u"?n.ctx.createGainNode():n.ctx.createGain(),n.masterGain.gain.setValueAtTime(n._muted?0:n._volume,n.ctx.currentTime),n.masterGain.connect(n.ctx.destination)),n._setup()}};e.Howler=n,e.Howl=r,typeof Wo<"u"?(Wo.HowlerGlobal=t,Wo.Howler=n,Wo.Howl=r,Wo.Sound=o):typeof window<"u"&&(window.HowlerGlobal=t,window.Howler=n,window.Howl=r,window.Sound=o)})();/*!
152
152
  * Spatial Plugin - Adds support for stereo and 3D audio where Web Audio is supported.
153
153
  *
154
154
  * howler.js v2.2.3
@@ -172,7 +172,7 @@ Found in store "${E.$id}".`),p&&i&&n.hydrate&&n.hydrate(E.$state,p),c=!0,f=!0,E}
172
172
  This will fail in production.`);s=Ih,s._s.has(r)||(i?Fx(r,t,o,s):q7(r,o,s),process.env.NODE_ENV!=="production"&&(a._pinia=s));const f=s._s.get(r);if(process.env.NODE_ENV!=="production"&&l){const u="__hot:"+r,d=i?Fx(u,t,o,s,!0):q7(u,ta({},o),s,!0);l._hotUpdate(d),delete s.state.value[u],s._s.delete(u)}if(process.env.NODE_ENV!=="production"&&Ng){const u=b.getCurrentInstance();if(u&&u.proxy&&!l){const d=u.proxy,h="_pStores"in d?d._pStores:d._pStores={};h[r]=f}}return f}return a.$id=r,a}function Kc(e,t){return Array.isArray(t)?t.reduce((n,r)=>(n[r]=function(){return e(this.$pinia)[r]},n),{}):Object.keys(t).reduce((n,r)=>(n[r]=function(){const o=e(this.$pinia),i=t[r];return typeof i=="function"?i.call(this,o):o[i]},n),{})}const H7=["music","ambiant","sound"],W7=$he(H7),yo=ao("audio",{state:()=>{const e=new Map;for(const t in W7)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){if(this.setAudioChannel(e,t,null),$s().options.musicFadeOutTime){const r=Jc(n.audio);r&&r.fade(r.volume(n.howlerId),0,$s().options.musicFadeOutTime*1e3,n.howlerId),await ea($s().options.musicFadeOutTime*1e3)}this.actuallyStopChannel(n)}},async pauseChannel(e,t){const n=this.getAudioChannel(e,t);if(!n)return;const r=Jc(n.audio);if(!r){Wt(`Could not find audio ${n.audio}`);return}r.pause(n.howlerId)},async playChannel(e,t,n){ws.Howler.ctx.state==="suspended"&&(console.warn("Audio context is suspended :o"),ws.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=Jc(n.audio);if(!r){Wt(`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){ipe(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=Jc(n);if(!r){Wt(`Could not find audio ${n}`);return}if(e!=="sound"){const o=r.play();r.volume(0,o),r.pause(o),this.setAudioChannel(e,t,{audio:n,howlerId:o}),await ea($s().options.musicFadeInDelay*1e3);const i=this.getAudioChannel(e,t);i!==null&&i.audio===n&&(r.play(o),r.fade(0,this.modeVolume(e)*r.volume(),$s().options.musicFadeInTime*1e3,o))}else if(e==="sound"){const o=r.play();r.volume(this.modeVolume(e)*r.volume(),o),this.setAudioChannel(e,t,{audio:n,howlerId:o})}},reloadAudio(e){for(const t in e.modes){if(t==="sound")continue;const n=t;this.modes.get(n).options=or(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=Jc(e);t&&t.stop()},generateSaveData(){const e={};for(const t in W7){const n=this.modes.get(t);e[t]={options:or(n.options),channels:or(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=Jc(o.audio);i&&i.volume(this.modeVolume(e),o.howlerId)}}},setMasterVolume(e){this.masterVolume=e,ws.Howler.volume(e)},modeVolume(e){return this.masterVolume*this.modes.get(e).options.volume}}}),K7={};ws.Howler.volume(.5);let Vx={};async function rpe(e){ki.log("Loading audio");const t=[];ws.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(ope(n,e.files[n]))}return e.audioTriggers&&(Vx=e.audioTriggers),Promise.all(t)}function Gc(e){Vx[e]&&yo().playChannel("sound",Vx[e],0)}async function ope(e,t){return new Promise((n,r)=>{ki.log(`Loading audio ${t.src}`);const o=new ws.Howl({...t,src:oa(t.src)});o.load(),K7[e]=o,n()})}function ipe(e,t){const n=Jc(e);if(!n){Kh(`Could not find music ${e}`);return}n.stop(t)}function Jc(e){return K7[e]}const Mf={};async function ape(e){return Mf[e]?Mf[e]:G7(e,e)}async function spe(e){ki.log("Loading images");let t=0,n=0;const r=[],o=async(a,s)=>{n++;const l=await G7(a,s);return t++,console.log(`Loaded ${t} / ${n} images`),l},i=(a,s)=>{r.push(o(a,s))};for(const a in e.images){const s=e.images[a];i(a,s)}for(const a in e.screens.screens){const s=e.screens.screens[a];if(s.background&&!e.images[s.background]&&i(s.background,s.background),s.buttons)for(const l in s.buttons){const c=s.buttons[l];typeof c=="object"&&c.background&&!e.images[c.background]&&i(c.background,c.background)}}return Promise.all(r)}async function G7(e,t){if(Mf[e])return Mf[e];const n=new Promise((r,o)=>{ki.log(`Loading image ${e} at ${t}`);const i=new Image;i.onload=()=>{Mf[e]=i,ki.log(`Loaded image ${e} successfully`),r(i)},i.onerror=a=>{Wt(`Failed to load image ${e} at ${t}`,a),o(a)},i.src=oa(t)});return Mf[e]=n,n}function Pf(){return`${Date.now()}-${Math.floor(Math.random()*1e11)}-${Math.floor(Math.random()*1e11)}`}const J7="3.2.3";function zx(){return`NARRAT_SAVE_${wt().saveFileName}`}const lpe="gameSave";let Zr;function Xs(){if(Zr)return Zr;if(!Zr){let e=null;try{let t=localStorage.getItem(zx());t||(t=localStorage.getItem(lpe)),t&&(localStorage.setItem(`${zx()}_BACKUP`,t),e=JSON.parse(t)),e&&typeof e=="object"&&e.slots&&e.slots[0]&&e.slots[0].id||(e=null,localStorage.clear())}catch(t){Kh(`Save file deleted because it was either broken or an outdated format: ${t}`)}e?Zr=e:Zr=Y7()}return upe(Zr),X7(Zr),Lh(),Zr}function cpe(){Zr=Y7(),Lh()}function Q7(){return{achievements:{achievements:{}},data:{}}}function upe(e){e.version==="1.4.0"&&(e.globalSave=Q7(),e.version="1.5.0"),e.version==="1.5.0"&&(e.version="2.16.0"),e.version==="2.16.0"&&(e.slots.forEach(t=>{t&&t.saveData&&(t.saveData.settings={baseSettings:{textSpeed:30,animateText:!0,fontSize:16},customSettings:{}})}),e.version="2.17.0"),e.version==="2.17.0"&&(e.slots.forEach(t=>{t&&t.saveData&&(t.saveData.config={gameCharacter:"game",playerCharacter:"player"})}),e.version="3.2.3")}function Y7(){const e={version:J7,slots:[],globalSave:Q7()};return X7(e),e}function X7(e){const t=wt().saves.slots??10;e.slots.length<1&&(e.slots[0]={slotType:"auto",id:Pf(),saveData:null,slotNumber:0}),e.slots[0].slotType="auto";for(let n=1;n<t+1;n++)e.slots.length<=n&&(e.slots[n]={slotNumber:n,slotType:wt().saves.mode==="manual"?"manual":"auto",id:Pf(),saveData:null})}function Z7(e,t,n){const r=hpe(n);if(Zr.slots[r])Zr.slots[r].saveData=e;else{Wt(`Tried to save to slot ${n} but it doesn't exist`);return}Zr.globalSave=t,Lh()}function fpe(e){Zr.lastSaveSlot=e}function Lh(){localStorage.setItem(zx(),JSON.stringify(Zr))}function dpe(){const e=Zr.slots.find(t=>!t.saveData);return e?e.id:!1}function hpe(e){return Zr.slots.findIndex(t=>t.id===e)}function Bh(e){return Zr.slots.find(t=>t.id===e)}function Ux(){return Zr.slots.find(e=>e.slotType==="auto")}function ppe(e){const t=Zr.slots.findIndex(n=>n.id===e);Zr.slots[t].saveData=null,Lh()}function mpe(e,t){const n=Bh(e);n&&n.saveData&&(n.saveData.metadata.name=t),Lh()}function vpe(){return{saveDate:new Date().toISOString(),name:"New Save"}}const Bg=ao("tooltips",{state:()=>({tooltip:null}),actions:{addCustomTooltip(e){e.title&&(e.title=Zs(e.title)),e.text=Zs(e.text),this.tooltip=e},addTooltip(e,t){const n=eV(e);n&&this.addCustomTooltip({title:n.title,text:n.description,x:(t==null?void 0:t.x)??window.screenX,y:(t==null?void 0:t.y)??window.screenY,width:fp().options.width})},deleteTooltip(){this.tooltip=null}}});function qx(){return window}function gpe(e){const t=fp().options.keywordsPrefix,n=new RegExp(`${t}(\\w*)`,"gi");return e=e.replace(n,ype),e}qx().onTooltipEnter=(e,t)=>{const n={x:e.clientX,y:e.clientY-20};Bg().addTooltip(t,n)},qx().onTooltipLeave=()=>{Bg().deleteTooltip()};function ype(e,t){const n=t.toLowerCase();return eV(n)?`<span class='highlighted-tooltip-keyword'
173
173
  onmouseenter="onTooltipEnter(event, '${n}')"
174
174
  onmouseleave="onTooltipLeave()">${t}</span>`:n}function Zs(e){const t=e.replace(/%{[^}]*}/g,n=>{const r=n.substr(2,n.length-3);return e9(r)});return gpe(t)}function e9(e){const t=Yf(),[n,r]=w0(t,e);return n[r]}const t9=/\$\$"/,bpe=e=>typeof e=="string"&&e.search(t9)===0;function wpe(e){let t=null;const n=[],r=/<[^>]*>/g;do t=r.exec(e),t&&n.push(t);while(t);return n}const qn=ao("dialog",{state:()=>({dialog:[],playMode:"normal"}),actions:{generateSaveData(){return{dialog:or(this.dialog)}},loadSaveData(e){this.dialog=e.dialog},addDialog(e){this.dialog.push({...e,interactive:e.interactive??!1,id:Pf(),text:Zs(e.text)}),this.dialog.length>200&&this.dialog.shift()},toggleAutoPlay(){this.playMode=this.playMode==="auto"?"normal":"auto"},toggleSkip(){this.playMode=this.playMode==="skip"?"normal":"skip"},clearDialog(){this.dialog.splice(0,this.dialog.length)},reset(){this.dialog=[],this.playMode="normal"}},getters:{currentDialog(){return this.dialog[this.dialog.length-1]}}});function kpe(e,t){return e-t*cp().options.extraPointsPerLevel}function n9(e,t){const{options:n}=cp();let r=e;n.showDifficultyWithoutModifiers||(r=kpe(e,t));const o=cp().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 l="";return n.showDifficultyText&&n.showDifficultyNumber?l=`${s} (${r})`:n.showDifficultyText?l=s:n.showDifficultyNumber&&(l=r.toString()),l}function xpe({skill:e,skillCheckId:t,value:n}){const r=Dr(),o=r.getSkillCheck(t),i=d_(e),a=r.skills[e].level,s=n9(n,a);let l=!0,c=`<span class='skill-check'>[<span class='skill-check-name'>${i.name}</span> - `;return o.happened?o.succeeded?c="":(l=!1,c+=` <span class='skill-check-difficulty'>${s}</span> - <span class='skill-check-failed'>FAILED</span>]</span>`):c+=` <span class='skill-check-difficulty'>${s}</span>]</span>`,{difficultyText:c,allowed:l}}function _pe(e,t){const n=Dr(),r=d_(t.skill),o=n9(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 jpe(e){const{options:t}=cp(),n=Spe(t,e),i=Dr().skills[e].level*t.extraPointsPerLevel;let a=n.reduce((s,l)=>s+l.unmodified,i);return t.finalRollIsHighest?(a=n.reduce((s,l)=>l.modified>s?l.modified:s,0),ki.log(`[SKILL CHECK] Keeping only highest roll: ${a}`)):t.finalRollIsLowest&&(a=n.reduce((s,l)=>l.modified<s?l.modified:s,n[0].modified),ki.log(`[SKILL CHECK] Keeping only lowest roll: ${a}`)),{roll:a,rolls:n}}function Spe(e,t){const r=Dr().skills[t],o=r.level*e.extraPointsPerLevel;let{diceRange:i,diceCount:a}=e;e.extraDicePerLevel&&(a+=e.extraDicePerLevel*r.level);const s=[];for(let l=0;l<a;l++){const c=Cpe(i),f=c+o;ki.log(`[SKILL CHECK] Roll ${l+1}/${a}: ${f}. (Base roll: ${c}, modifier: ${o} - Skill level: ${r.level})`),s.push({unmodified:c,modified:f})}return s}function Cpe(e){return Math.floor(Math.random()*e[1])+e[0]}function $pe(e){const{skills:t}=rl(),{roll:n,rolls:r}=jpe(e.skill),o=t[e.skill];let i=!1;if(typeof e.winsNeeded=="number"){const a=r.reduce((s,l)=>(r9(l.modified,e.difficulty)&&s++,s),0);a>=e.winsNeeded&&(i=!0),ki.log(`[SKILL CHECK ${o.name}] - Dice pool mode. ${e.winsNeeded} wins needed. Got ${a} successes.
175
- (${e.id} - ${a}/${e.winsNeeded} - rolls: ${JSON.stringify(r.map(s=>s.modified))})`)}else i=r9(n,e.difficulty),ki.log(`[SKILL CHECK ${o.name}]: ${i?"✅":"❌"}`,`(${e.id}) - ${n}/${e.difficulty}`);return Gc(i?"onSkillCheckSuccess":"onSkillCheckFailure"),i}function r9(e,t){const{options:n}=cp();let r=e>=t;return n.successOnRollsBelowThreshold&&(r=e<=t),n.failOnRollsEqualToThreshold&&e===t&&(r=!1),r}var J={};(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.Type=e.StandardType=e.ExtendedTypeBuilder=e.StandardTypeBuilder=e.TypeBuilder=e.TemplateLiteralDslParser=e.TemplateLiteralGenerator=e.TemplateLiteralFinite=e.TemplateLiteralParser=e.TemplateLiteralParserError=e.TemplateLiteralResolver=e.TemplateLiteralPattern=e.UnionResolver=e.KeyArrayResolver=e.KeyResolver=e.ObjectMap=e.IndexedAccessor=e.TypeClone=e.TypeExtends=e.TypeExtendsResult=e.ExtendsUndefined=e.TypeGuard=e.TypeGuardUnknownTypeError=e.FormatRegistry=e.TypeRegistry=e.PatternStringExact=e.PatternNumberExact=e.PatternBooleanExact=e.PatternString=e.PatternNumber=e.PatternBoolean=e.Kind=e.Hint=e.Modifier=void 0,e.Modifier=Symbol.for("TypeBox.Modifier"),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(M){const j=new Map;function C(){return new Map(j)}M.Entries=C;function O(){return j.clear()}M.Clear=O;function F(H){return j.has(H)}M.Has=F;function T(H,z){j.set(H,z)}M.Set=T;function L(H){return j.get(H)}M.Get=L})(t||(e.TypeRegistry=t={}));var n;(function(M){const j=new Map;function C(){return new Map(j)}M.Entries=C;function O(){return j.clear()}M.Clear=O;function F(H){return j.has(H)}M.Has=F;function T(H,z){j.set(H,z)}M.Set=T;function L(H){return j.get(H)}M.Get=L})(n||(e.FormatRegistry=n={}));class r extends Error{constructor(j){super("TypeGuard: Unknown type"),this.schema=j}}e.TypeGuardUnknownTypeError=r;var o;(function(M){function j(W){return typeof W=="object"&&W!==null&&!Array.isArray(W)}function C(W){return typeof W=="object"&&W!==null&&Array.isArray(W)}function O(W){try{return new RegExp(W),!0}catch{return!1}}function F(W){if(typeof W!="string")return!1;for(let qe=0;qe<W.length;qe++){const st=W.charCodeAt(qe);if(st>=7&&st<=13||st===27||st===127)return!1}return!0}function T(W){return N(W)||At(W)}function L(W){return typeof W=="bigint"}function H(W){return typeof W=="string"}function z(W){return typeof W=="number"&&globalThis.Number.isFinite(W)}function V(W){return typeof W=="boolean"}function I(W){return W===void 0||W!==void 0&&L(W)}function P(W){return W===void 0||W!==void 0&&z(W)}function N(W){return W===void 0||W!==void 0&&V(W)}function D(W){return W===void 0||W!==void 0&&H(W)}function S(W){return W===void 0||W!==void 0&&H(W)&&F(W)&&O(W)}function A(W){return W===void 0||W!==void 0&&H(W)&&F(W)}function B(W){return W===void 0||At(W)}function Q(W){return Le(W)&&W[e.Kind]==="Any"&&D(W.$id)}M.TAny=Q;function te(W){return Le(W)&&W[e.Kind]==="Array"&&W.type==="array"&&D(W.$id)&&At(W.items)&&P(W.minItems)&&P(W.maxItems)&&N(W.uniqueItems)}M.TArray=te;function he(W){return Le(W)&&W[e.Kind]==="BigInt"&&W.type==="null"&&W.typeOf==="BigInt"&&D(W.$id)&&I(W.multipleOf)&&I(W.minimum)&&I(W.maximum)&&I(W.exclusiveMinimum)&&I(W.exclusiveMaximum)}M.TBigInt=he;function ke(W){return Le(W)&&W[e.Kind]==="Boolean"&&W.type==="boolean"&&D(W.$id)}M.TBoolean=ke;function be(W){if(!(Le(W)&&W[e.Kind]==="Constructor"&&W.type==="object"&&W.instanceOf==="Constructor"&&D(W.$id)&&C(W.parameters)&&At(W.returns)))return!1;for(const qe of W.parameters)if(!At(qe))return!1;return!0}M.TConstructor=be;function de(W){return Le(W)&&W[e.Kind]==="Date"&&W.type==="object"&&W.instanceOf==="Date"&&D(W.$id)&&P(W.minimumTimestamp)&&P(W.maximumTimestamp)&&P(W.exclusiveMinimumTimestamp)&&P(W.exclusiveMaximumTimestamp)}M.TDate=de;function Be(W){if(!(Le(W)&&W[e.Kind]==="Function"&&W.type==="object"&&W.instanceOf==="Function"&&D(W.$id)&&C(W.parameters)&&At(W.returns)))return!1;for(const qe of W.parameters)if(!At(qe))return!1;return!0}M.TFunction=Be;function ee(W){return Le(W)&&W[e.Kind]==="Integer"&&W.type==="integer"&&D(W.$id)&&P(W.multipleOf)&&P(W.minimum)&&P(W.maximum)&&P(W.exclusiveMinimum)&&P(W.exclusiveMaximum)}M.TInteger=ee;function Oe(W){if(!(Le(W)&&W[e.Kind]==="Intersect"&&C(W.allOf)&&D(W.type)&&(N(W.unevaluatedProperties)||B(W.unevaluatedProperties))&&D(W.$id))||"type"in W&&W.type!=="object")return!1;for(const qe of W.allOf)if(!At(qe))return!1;return!0}M.TIntersect=Oe;function Le(W){return j(W)&&e.Kind in W&&typeof W[e.Kind]=="string"}M.TKind=Le;function Ce(W){return Le(W)&&W[e.Kind]==="Literal"&&D(W.$id)&&typeof W.const=="string"}M.TLiteralString=Ce;function X(W){return Le(W)&&W[e.Kind]==="Literal"&&D(W.$id)&&typeof W.const=="number"}M.TLiteralNumber=X;function re(W){return Le(W)&&W[e.Kind]==="Literal"&&D(W.$id)&&typeof W.const=="boolean"}M.TLiteralBoolean=re;function we(W){return Ce(W)||X(W)||re(W)}M.TLiteral=we;function Me(W){return Le(W)&&W[e.Kind]==="Never"&&j(W.not)&&globalThis.Object.getOwnPropertyNames(W.not).length===0}M.TNever=Me;function Ee(W){return Le(W)&&W[e.Kind]==="Not"&&At(W.not)}M.TNot=Ee;function Ze(W){return Le(W)&&W[e.Kind]==="Null"&&W.type==="null"&&D(W.$id)}M.TNull=Ze;function ve(W){return Le(W)&&W[e.Kind]==="Number"&&W.type==="number"&&D(W.$id)&&P(W.multipleOf)&&P(W.minimum)&&P(W.maximum)&&P(W.exclusiveMinimum)&&P(W.exclusiveMaximum)}M.TNumber=ve;function Ne(W){if(!(Le(W)&&W[e.Kind]==="Object"&&W.type==="object"&&D(W.$id)&&j(W.properties)&&T(W.additionalProperties)&&P(W.minProperties)&&P(W.maxProperties)))return!1;for(const[qe,st]of Object.entries(W.properties))if(!F(qe)||!At(st))return!1;return!0}M.TObject=Ne;function ze(W){return Le(W)&&W[e.Kind]==="Promise"&&W.type==="object"&&W.instanceOf==="Promise"&&D(W.$id)&&At(W.item)}M.TPromise=ze;function Ye(W){if(!(Le(W)&&W[e.Kind]==="Record"&&W.type==="object"&&D(W.$id)&&T(W.additionalProperties)&&j(W.patternProperties)))return!1;const qe=Object.keys(W.patternProperties);return!(qe.length!==1||!O(qe[0])||!At(W.patternProperties[qe[0]]))}M.TRecord=Ye;function We(W){return Le(W)&&W[e.Kind]==="Ref"&&D(W.$id)&&H(W.$ref)}M.TRef=We;function at(W){return Le(W)&&W[e.Kind]==="String"&&W.type==="string"&&D(W.$id)&&P(W.minLength)&&P(W.maxLength)&&S(W.pattern)&&A(W.format)}M.TString=at;function dt(W){return Le(W)&&W[e.Kind]==="Symbol"&&W.type==="null"&&W.typeOf==="Symbol"&&D(W.$id)}M.TSymbol=dt;function ln(W){return Le(W)&&W[e.Kind]==="TemplateLiteral"&&W.type==="string"&&H(W.pattern)&&W.pattern[0]==="^"&&W.pattern[W.pattern.length-1]==="$"}M.TTemplateLiteral=ln;function yt(W){return Le(W)&&W[e.Kind]==="This"&&D(W.$id)&&H(W.$ref)}M.TThis=yt;function vn(W){if(!(Le(W)&&W[e.Kind]==="Tuple"&&W.type==="array"&&D(W.$id)&&z(W.minItems)&&z(W.maxItems)&&W.minItems===W.maxItems))return!1;if(W.items===void 0&&W.additionalItems===void 0&&W.minItems===0)return!0;if(!C(W.items))return!1;for(const qe of W.items)if(!At(qe))return!1;return!0}M.TTuple=vn;function Kt(W){return Le(W)&&W[e.Kind]==="Undefined"&&W.type==="null"&&W.typeOf==="Undefined"&&D(W.$id)}M.TUndefined=Kt;function nn(W){return cn(W)&&W.anyOf.every(qe=>Ce(qe)||X(qe))}M.TUnionLiteral=nn;function cn(W){if(!(Le(W)&&W[e.Kind]==="Union"&&C(W.anyOf)&&D(W.$id)))return!1;for(const qe of W.anyOf)if(!At(qe))return!1;return!0}M.TUnion=cn;function Qn(W){return Le(W)&&W[e.Kind]==="Uint8Array"&&W.type==="object"&&D(W.$id)&&W.instanceOf==="Uint8Array"&&P(W.minByteLength)&&P(W.maxByteLength)}M.TUint8Array=Qn;function En(W){return Le(W)&&W[e.Kind]==="Unknown"&&D(W.$id)}M.TUnknown=En;function Xn(W){return Le(W)&&W[e.Kind]==="Unsafe"}M.TUnsafe=Xn;function zn(W){return Le(W)&&W[e.Kind]==="Void"&&W.type==="null"&&W.typeOf==="Void"&&D(W.$id)}M.TVoid=zn;function dn(W){return j(W)&&W[e.Modifier]==="ReadonlyOptional"}M.TReadonlyOptional=dn;function Ae(W){return j(W)&&W[e.Modifier]==="Readonly"}M.TReadonly=Ae;function bt(W){return j(W)&&W[e.Modifier]==="Optional"}M.TOptional=bt;function At(W){return typeof W=="object"&&(Q(W)||te(W)||ke(W)||he(W)||be(W)||de(W)||Be(W)||ee(W)||Oe(W)||we(W)||Me(W)||Ee(W)||Ze(W)||ve(W)||Ne(W)||ze(W)||Ye(W)||We(W)||at(W)||dt(W)||ln(W)||yt(W)||vn(W)||Kt(W)||cn(W)||Qn(W)||En(W)||Xn(W)||zn(W)||Le(W)&&t.Has(W[e.Kind]))}M.TSchema=At})(o||(e.TypeGuard=o={}));var i;(function(M){function j(C){return C[e.Kind]==="Undefined"?!0:C[e.Kind]==="Not"?!j(C.not):C[e.Kind]==="Intersect"?C.allOf.every(F=>j(F)):C[e.Kind]==="Union"?C.anyOf.some(F=>j(F)):!1}M.Check=j})(i||(e.ExtendsUndefined=i={}));var a;(function(M){M[M.Union=0]="Union",M[M.True=1]="True",M[M.False=2]="False"})(a||(e.TypeExtendsResult=a={}));var s;(function(M){function j(q){return q===a.False?a.False:a.True}function C(q,_){return a.True}function O(q,_){return o.TIntersect(_)?S(q,_):o.TUnion(_)&&_.anyOf.some(G=>o.TAny(G)||o.TUnknown(G))?a.True:o.TUnion(_)?a.Union:o.TUnknown(_)||o.TAny(_)?a.True:a.Union}function F(q,_){return o.TUnknown(q)?a.False:o.TAny(q)?a.Union:o.TNever(q)?a.True:a.False}function T(q,_){return o.TIntersect(_)?S(q,_):o.TUnion(_)?qe(q,_):o.TUnknown(_)?ht():o.TAny(_)?C():o.TObject(_)&&Ye(_)?a.True:o.TArray(_)?j(oe(q.items,_.items)):a.False}function L(q,_){return o.TIntersect(_)?S(q,_):o.TUnion(_)?qe(q,_):o.TNever(_)?ke():o.TUnknown(_)?ht():o.TAny(_)?C():o.TObject(_)?dt(q,_):o.TRecord(_)?nn(q,_):o.TBigInt(_)?a.True:a.False}function H(q,_){return o.TLiteral(q)&&typeof q.const=="boolean"||o.TBoolean(q)?a.True:a.False}function z(q,_){return o.TIntersect(_)?S(q,_):o.TUnion(_)?qe(q,_):o.TNever(_)?ke():o.TUnknown(_)?ht():o.TAny(_)?C():o.TObject(_)?dt(q,_):o.TRecord(_)?nn(q,_):o.TBoolean(_)?a.True:a.False}function V(q,_){return o.TIntersect(_)?S(q,_):o.TUnion(_)?qe(q,_):o.TUnknown(_)?ht():o.TAny(_)?C():o.TObject(_)?dt(q,_):!o.TConstructor(_)||q.parameters.length>_.parameters.length||!q.parameters.every((G,le)=>j(oe(_.parameters[le],G))===a.True)?a.False:j(oe(q.returns,_.returns))}function I(q,_){return o.TIntersect(_)?S(q,_):o.TUnion(_)?qe(q,_):o.TUnknown(_)?ht():o.TAny(_)?C():o.TObject(_)?dt(q,_):o.TRecord(_)?nn(q,_):o.TDate(_)?a.True:a.False}function P(q,_){return o.TIntersect(_)?S(q,_):o.TUnion(_)?qe(q,_):o.TUnknown(_)?ht():o.TAny(_)?C():o.TObject(_)?dt(q,_):!o.TFunction(_)||q.parameters.length>_.parameters.length||!q.parameters.every((G,le)=>j(oe(_.parameters[le],G))===a.True)?a.False:j(oe(q.returns,_.returns))}function N(q,_){return o.TLiteral(q)&&typeof q.const=="number"||o.TNumber(q)||o.TInteger(q)?a.True:a.False}function D(q,_){return o.TIntersect(_)?S(q,_):o.TUnion(_)?qe(q,_):o.TNever(_)?ke():o.TUnknown(_)?ht():o.TAny(_)?C():o.TObject(_)?dt(q,_):o.TRecord(_)?nn(q,_):o.TInteger(_)||o.TNumber(_)?a.True:a.False}function S(q,_){return _.allOf.every(G=>oe(q,G)===a.True)?a.True:a.False}function A(q,_){return q.allOf.some(G=>oe(G,_)===a.True)?a.True:a.False}function B(q){return typeof q.const=="string"}function Q(q){return typeof q.const=="number"}function te(q){return typeof q.const=="boolean"}function he(q,_){return o.TIntersect(_)?S(q,_):o.TUnion(_)?qe(q,_):o.TNever(_)?ke():o.TUnknown(_)?ht():o.TAny(_)?C():o.TObject(_)?dt(q,_):o.TRecord(_)?nn(q,_):o.TString(_)?Qn(q):o.TNumber(_)?Oe(q):o.TInteger(_)?N(q):o.TBoolean(_)?H(q):o.TLiteral(_)&&_.const===q.const?a.True:a.False}function ke(q,_){return a.False}function be(q,_){return a.True}function de(q){let[_,G]=[q,0];for(;o.TNot(_);)_=_.not,G+=1;return G%2===0?_:e.Type.Unknown()}function Be(q,_){if(o.TNot(q))return oe(de(q),_);if(o.TNot(_))return oe(q,de(_));throw new Error("TypeExtends: Invalid fallthrough for Not")}function ee(q,_){return o.TIntersect(_)?S(q,_):o.TUnion(_)?qe(q,_):o.TNever(_)?ke():o.TUnknown(_)?ht():o.TAny(_)?C():o.TObject(_)?dt(q,_):o.TRecord(_)?nn(q,_):o.TNull(_)?a.True:a.False}function Oe(q,_){return o.TLiteral(q)&&Q(q)||o.TNumber(q)||o.TInteger(q)?a.True:a.False}function Le(q,_){return o.TIntersect(_)?S(q,_):o.TUnion(_)?qe(q,_):o.TNever(_)?ke():o.TUnknown(_)?ht():o.TAny(_)?C():o.TObject(_)?dt(q,_):o.TRecord(_)?nn(q,_):o.TInteger(_)||o.TNumber(_)?a.True:a.False}function Ce(q,_){return globalThis.Object.keys(q.properties).length===_}function X(q){return Ye(q)}function re(q){return Ce(q,0)||Ce(q,1)&&"description"in q.properties&&o.TUnion(q.properties.description)&&q.properties.description.anyOf.length===2&&(o.TString(q.properties.description.anyOf[0])&&o.TUndefined(q.properties.description.anyOf[1])||o.TString(q.properties.description.anyOf[1])&&o.TUndefined(q.properties.description.anyOf[0]))}function we(q){return Ce(q,0)}function Me(q){return Ce(q,0)}function Ee(q){return Ce(q,0)}function Ze(q){return Ce(q,0)}function ve(q){return Ye(q)}function Ne(q){const _=e.Type.Number();return Ce(q,0)||Ce(q,1)&&"length"in q.properties&&j(oe(q.properties.length,_))===a.True}function ze(q){return Ce(q,0)}function Ye(q){const _=e.Type.Number();return Ce(q,0)||Ce(q,1)&&"length"in q.properties&&j(oe(q.properties.length,_))===a.True}function We(q){const _=e.Type.Function([e.Type.Any()],e.Type.Any());return Ce(q,0)||Ce(q,1)&&"then"in q.properties&&j(oe(q.properties.then,_))===a.True}function at(q,_){return oe(q,_)===a.False||o.TOptional(q)&&!o.TOptional(_)?a.False:a.True}function dt(q,_){return o.TUnknown(q)?a.False:o.TAny(q)?a.Union:o.TNever(q)||o.TLiteral(q)&&B(q)&&X(_)||o.TLiteral(q)&&Q(q)&&we(_)||o.TLiteral(q)&&te(q)&&Me(_)||o.TSymbol(q)&&re(_)||o.TBigInt(q)&&Ee(_)||o.TString(q)&&X(_)||o.TSymbol(q)&&re(_)||o.TNumber(q)&&we(_)||o.TInteger(q)&&we(_)||o.TBoolean(q)&&Me(_)||o.TUint8Array(q)&&ve(_)||o.TDate(q)&&Ze(_)||o.TConstructor(q)&&ze(_)||o.TFunction(q)&&Ne(_)?a.True:o.TRecord(q)&&o.TString(vn(q))?_[e.Hint]==="Record"?a.True:a.False:o.TRecord(q)&&o.TNumber(vn(q))&&Ce(_,0)?a.True:a.False}function ln(q,_){if(o.TIntersect(_))return S(q,_);if(o.TUnion(_))return qe(q,_);if(o.TUnknown(_))return ht();if(o.TAny(_))return C();if(o.TRecord(_))return nn(q,_);if(!o.TObject(_))return a.False;for(const G of globalThis.Object.keys(_.properties))if(!(G in q.properties)||at(q.properties[G],_.properties[G])===a.False)return a.False;return a.True}function yt(q,_){return o.TIntersect(_)?S(q,_):o.TUnion(_)?qe(q,_):o.TUnknown(_)?ht():o.TAny(_)?C():o.TObject(_)&&We(_)?a.True:o.TPromise(_)?j(oe(q.item,_.item)):a.False}function vn(q){if(e.PatternNumberExact in q.patternProperties)return e.Type.Number();if(e.PatternStringExact in q.patternProperties)return e.Type.String();throw Error("TypeExtends: Cannot get record key")}function Kt(q){if(e.PatternNumberExact in q.patternProperties)return q.patternProperties[e.PatternNumberExact];if(e.PatternStringExact in q.patternProperties)return q.patternProperties[e.PatternStringExact];throw Error("TypeExtends: Cannot get record value")}function nn(q,_){const G=vn(_),le=Kt(_);if(o.TLiteral(q)&&B(q)&&o.TNumber(G)&&j(oe(q,le))===a.True)return a.True;if(o.TUint8Array(q)&&o.TNumber(G)||o.TString(q)&&o.TNumber(G)||o.TArray(q)&&o.TNumber(G))return oe(q,le);if(o.TObject(q)){for(const xe of globalThis.Object.keys(q.properties))if(at(le,q.properties[xe])===a.False)return a.False;return a.True}return a.False}function cn(q,_){const G=Kt(q);return o.TIntersect(_)?S(q,_):o.TUnion(_)?qe(q,_):o.TUnknown(_)?ht():o.TAny(_)?C():o.TObject(_)?dt(q,_):o.TRecord(_)?oe(G,Kt(_)):a.False}function Qn(q,_){return o.TLiteral(q)&&typeof q.const=="string"||o.TString(q)?a.True:a.False}function En(q,_){return o.TIntersect(_)?S(q,_):o.TUnion(_)?qe(q,_):o.TNever(_)?ke():o.TUnknown(_)?ht():o.TAny(_)?C():o.TObject(_)?dt(q,_):o.TRecord(_)?nn(q,_):o.TString(_)?a.True:a.False}function Xn(q,_){return o.TIntersect(_)?S(q,_):o.TUnion(_)?qe(q,_):o.TNever(_)?ke():o.TUnknown(_)?ht():o.TAny(_)?C():o.TObject(_)?dt(q,_):o.TRecord(_)?nn(q,_):o.TSymbol(_)?a.True:a.False}function zn(q,_){if(o.TTemplateLiteral(q))return oe(m.Resolve(q),_);if(o.TTemplateLiteral(_))return oe(q,m.Resolve(_));throw new Error("TypeExtends: Invalid fallthrough for TemplateLiteral")}function dn(q,_){return o.TUnknown(q)?a.False:o.TAny(q)?a.Union:o.TNever(q)?a.True:a.False}function Ae(q,_){return o.TArray(_)&&q.items!==void 0&&q.items.every(G=>oe(G,_.items)===a.True)}function bt(q,_){return o.TIntersect(_)?S(q,_):o.TUnion(_)?qe(q,_):o.TUnknown(_)?ht():o.TAny(_)?C():o.TObject(_)&&Ye(_)||o.TArray(_)&&Ae(q,_)?a.True:!o.TTuple(_)||q.items===void 0&&_.items!==void 0||q.items!==void 0&&_.items===void 0?a.False:q.items===void 0&&_.items===void 0||q.items.every((G,le)=>oe(G,_.items[le])===a.True)?a.True:a.False}function At(q,_){return o.TIntersect(_)?S(q,_):o.TUnion(_)?qe(q,_):o.TUnknown(_)?ht():o.TAny(_)?C():o.TObject(_)?dt(q,_):o.TRecord(_)?nn(q,_):o.TUint8Array(_)?a.True:a.False}function W(q,_){return o.TIntersect(_)?S(q,_):o.TUnion(_)?qe(q,_):o.TNever(_)?ke():o.TUnknown(_)?ht():o.TAny(_)?C():o.TObject(_)?dt(q,_):o.TRecord(_)?nn(q,_):o.TVoid(_)?hn(q):o.TUndefined(_)?a.True:a.False}function qe(q,_){return _.anyOf.some(G=>oe(q,G)===a.True)?a.True:a.False}function st(q,_){return q.anyOf.every(G=>oe(G,_)===a.True)?a.True:a.False}function ht(q,_){return a.True}function Un(q,_){return o.TIntersect(_)?S(q,_):o.TUnion(_)?qe(q,_):o.TAny(_)?C():o.TString(_)?Qn(q):o.TNumber(_)?Oe(q):o.TInteger(_)?N(q):o.TBoolean(_)?H(q):o.TArray(_)?F(q):o.TTuple(_)?dn(q):o.TObject(_)?dt(q,_):o.TUnknown(_)?a.True:a.False}function hn(q,_){return o.TUndefined(q)||o.TUndefined(q)?a.True:a.False}function Rr(q,_){return o.TIntersect(_)?S(q,_):o.TUnion(_)?qe(q,_):o.TUnknown(_)?ht():o.TAny(_)?C():o.TObject(_)?dt(q,_):o.TVoid(_)?a.True:a.False}function oe(q,_){if(o.TTemplateLiteral(q)||o.TTemplateLiteral(_))return zn(q,_);if(o.TNot(q)||o.TNot(_))return Be(q,_);if(o.TAny(q))return O(q,_);if(o.TArray(q))return T(q,_);if(o.TBigInt(q))return L(q,_);if(o.TBoolean(q))return z(q,_);if(o.TConstructor(q))return V(q,_);if(o.TDate(q))return I(q,_);if(o.TFunction(q))return P(q,_);if(o.TInteger(q))return D(q,_);if(o.TIntersect(q))return A(q,_);if(o.TLiteral(q))return he(q,_);if(o.TNever(q))return be();if(o.TNull(q))return ee(q,_);if(o.TNumber(q))return Le(q,_);if(o.TObject(q))return ln(q,_);if(o.TRecord(q))return cn(q,_);if(o.TString(q))return En(q,_);if(o.TSymbol(q))return Xn(q,_);if(o.TTuple(q))return bt(q,_);if(o.TPromise(q))return yt(q,_);if(o.TUint8Array(q))return At(q,_);if(o.TUndefined(q))return W(q,_);if(o.TUnion(q))return st(q,_);if(o.TUnknown(q))return Un(q,_);if(o.TVoid(q))return Rr(q,_);throw Error(`TypeExtends: Unknown left type operand '${q[e.Kind]}'`)}function ye(q,_){return oe(q,_)}M.Extends=ye})(s||(e.TypeExtends=s={}));var l;(function(M){function j(H){return typeof H=="object"&&H!==null}function C(H){return globalThis.Array.isArray(H)}function O(H){return H.map(z=>T(z))}function F(H){const z=globalThis.Object.getOwnPropertyNames(H).reduce((I,P)=>({...I,[P]:T(H[P])}),{}),V=globalThis.Object.getOwnPropertySymbols(H).reduce((I,P)=>({...I,[P]:T(H[P])}),{});return{...z,...V}}function T(H){return C(H)?O(H):j(H)?F(H):H}function L(H,z){return{...T(H),...z}}M.Clone=L})(l||(e.TypeClone=l={}));var c;(function(M){function j(H,z){const V=H.allOf.reduce((I,P)=>{const N=T(P,z);return N[e.Kind]==="Never"?I:[...I,N]},[]);return e.Type.Intersect(V)}function C(H,z){const V=H.anyOf.map(I=>T(I,z));return e.Type.Union(V)}function O(H,z){const V=H.properties[z];return V===void 0?e.Type.Never():e.Type.Union([V])}function F(H,z){const V=H.items;if(V===void 0)return e.Type.Never();const I=V[z];return I===void 0?e.Type.Never():I}function T(H,z){return H[e.Kind]==="Intersect"?j(H,z):H[e.Kind]==="Union"?C(H,z):H[e.Kind]==="Object"?O(H,z):H[e.Kind]==="Tuple"?F(H,z):e.Type.Never()}function L(H,z,V={}){return e.Type.Union(z.map(I=>T(H,I.toString())),V)}M.Resolve=L})(c||(e.IndexedAccessor=c={}));var f;(function(M){function j(L,H){return e.Type.Intersect(L.allOf.map(z=>F(z,H)),{...L})}function C(L,H){return e.Type.Union(L.anyOf.map(z=>F(z,H)),{...L})}function O(L,H){return H(L)}function F(L,H){return L[e.Kind]==="Intersect"?j(L,H):L[e.Kind]==="Union"?C(L,H):L[e.Kind]==="Object"?O(L,H):L}function T(L,H,z){return{...F(l.Clone(L,{}),H),...z}}M.Map=T})(f||(e.ObjectMap=f={}));var u;(function(M){function j(V){return V[0]==="^"&&V[V.length-1]==="$"?V.slice(1,V.length-1):V}function C(V,I){return V.allOf.reduce((P,N)=>[...P,...L(N,I)],[])}function O(V,I){const P=V.anyOf.map(N=>L(N,I));return[...P.reduce((N,D)=>D.map(S=>P.every(A=>A.includes(S))?N.add(S):N)[0],new Set)]}function F(V,I){return globalThis.Object.keys(V.properties)}function T(V,I){return I.includePatterns?globalThis.Object.keys(V.patternProperties):[]}function L(V,I){return o.TIntersect(V)?C(V,I):o.TUnion(V)?O(V,I):o.TObject(V)?F(V):o.TRecord(V)?T(V,I):[]}function H(V,I){return[...new Set(L(V,I))]}M.ResolveKeys=H;function z(V){return`^(${H(V,{includePatterns:!0}).map(N=>`(${j(N)})`).join("|")})$`}M.ResolvePattern=z})(u||(e.KeyResolver=u={}));var d;(function(M){function j(C){if(globalThis.Array.isArray(C))return C;if(o.TUnionLiteral(C))return C.anyOf.map(O=>O.const.toString());if(o.TLiteral(C))return[C.const];if(o.TTemplateLiteral(C)){const O=g.ParseExact(C.pattern);if(!y.Check(O))throw Error("KeyArrayResolver: Cannot resolve keys from infinite template expression");return[...w.Generate(O)]}return[]}M.Resolve=j})(d||(e.KeyArrayResolver=d={}));var h;(function(M){function*j(O){for(const F of O.anyOf)F[e.Kind]==="Union"?yield*j(F):yield F}function C(O){return e.Type.Union([...j(O)],{...O})}M.Resolve=C})(h||(e.UnionResolver=h={}));var p;(function(M){function j(F){return F.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function C(F,T){if(o.TTemplateLiteral(F))return F.pattern.slice(1,F.pattern.length-1);if(o.TUnion(F))return`(${F.anyOf.map(H=>C(H,T)).join("|")})`;if(o.TNumber(F))return`${T}${e.PatternNumber}`;if(o.TInteger(F))return`${T}${e.PatternNumber}`;if(o.TBigInt(F))return`${T}${e.PatternNumber}`;if(o.TString(F))return`${T}${e.PatternString}`;if(o.TLiteral(F))return`${T}${j(F.const.toString())}`;if(o.TBoolean(F))return`${T}${e.PatternBoolean}`;throw o.TNever(F)?Error("TemplateLiteralPattern: TemplateLiteral cannot operate on types of TNever"):Error(`TemplateLiteralPattern: Unexpected Kind '${F[e.Kind]}'`)}function O(F){return`^${F.map(T=>C(T,"")).join("")}$`}M.Create=O})(p||(e.TemplateLiteralPattern=p={}));var m;(function(M){function j(C){const O=g.ParseExact(C.pattern);if(!y.Check(O))return e.Type.String();const F=[...w.Generate(O)].map(T=>e.Type.Literal(T));return e.Type.Union(F)}M.Resolve=j})(m||(e.TemplateLiteralResolver=m={}));class v extends Error{constructor(j){super(j)}}e.TemplateLiteralParserError=v;var g;(function(M){function j(D,S,A){return D[S]===A&&D.charCodeAt(S-1)!==92}function C(D,S){return j(D,S,"(")}function O(D,S){return j(D,S,")")}function F(D,S){return j(D,S,"|")}function T(D){if(!(C(D,0)&&O(D,D.length-1)))return!1;let S=0;for(let A=0;A<D.length;A++)if(C(D,A)&&(S+=1),O(D,A)&&(S-=1),S===0&&A!==D.length-1)return!1;return!0}function L(D){return D.slice(1,D.length-1)}function H(D){let S=0;for(let A=0;A<D.length;A++)if(C(D,A)&&(S+=1),O(D,A)&&(S-=1),F(D,A)&&S===0)return!0;return!1}function z(D){for(let S=0;S<D.length;S++)if(C(D,S))return!0;return!1}function V(D){let[S,A]=[0,0];const B=[];for(let te=0;te<D.length;te++)if(C(D,te)&&(S+=1),O(D,te)&&(S-=1),F(D,te)&&S===0){const he=D.slice(A,te);he.length>0&&B.push(P(he)),A=te+1}const Q=D.slice(A);return Q.length>0&&B.push(P(Q)),B.length===0?{type:"const",const:""}:B.length===1?B[0]:{type:"or",expr:B}}function I(D){function S(Q,te){if(!C(Q,te))throw new v("TemplateLiteralParser: Index must point to open parens");let he=0;for(let ke=te;ke<Q.length;ke++)if(C(Q,ke)&&(he+=1),O(Q,ke)&&(he-=1),he===0)return[te,ke];throw new v("TemplateLiteralParser: Unclosed group parens in expression")}function A(Q,te){for(let he=te;he<Q.length;he++)if(C(Q,he))return[te,he];return[te,Q.length]}const B=[];for(let Q=0;Q<D.length;Q++)if(C(D,Q)){const[te,he]=S(D,Q),ke=D.slice(te,he+1);B.push(P(ke)),Q=he}else{const[te,he]=A(D,Q),ke=D.slice(te,he);ke.length>0&&B.push(P(ke)),Q=he-1}return B.length===0?{type:"const",const:""}:B.length===1?B[0]:{type:"and",expr:B}}function P(D){return T(D)?P(L(D)):H(D)?V(D):z(D)?I(D):{type:"const",const:D}}M.Parse=P;function N(D){return P(D.slice(1,D.length-1))}M.ParseExact=N})(g||(e.TemplateLiteralParser=g={}));var y;(function(M){function j(T){return T.type==="or"&&T.expr.length===2&&T.expr[0].type==="const"&&T.expr[0].const==="0"&&T.expr[1].type==="const"&&T.expr[1].const==="[1-9][0-9]*"}function C(T){return T.type==="or"&&T.expr.length===2&&T.expr[0].type==="const"&&T.expr[0].const==="true"&&T.expr[1].type==="const"&&T.expr[1].const==="false"}function O(T){return T.type==="const"&&T.const===".*"}function F(T){if(C(T))return!0;if(j(T)||O(T))return!1;if(T.type==="and")return T.expr.every(L=>F(L));if(T.type==="or")return T.expr.every(L=>F(L));if(T.type==="const")return!0;throw Error("TemplateLiteralFinite: Unknown expression type")}M.Check=F})(y||(e.TemplateLiteralFinite=y={}));var w;(function(M){function*j(L){if(L.length===1)return yield*L[0];for(const H of L[0])for(const z of j(L.slice(1)))yield`${H}${z}`}function*C(L){return yield*j(L.expr.map(H=>[...T(H)]))}function*O(L){for(const H of L.expr)yield*T(H)}function*F(L){return yield L.const}function*T(L){if(L.type==="and")return yield*C(L);if(L.type==="or")return yield*O(L);if(L.type==="const")return yield*F(L);throw Error("TemplateLiteralGenerator: Unknown expression")}M.Generate=T})(w||(e.TemplateLiteralGenerator=w={}));var k;(function(M){function*j(T){const L=T.trim().replace(/"|'/g,"");if(L==="boolean")return yield e.Type.Boolean();if(L==="number")return yield e.Type.Number();if(L==="bigint")return yield e.Type.BigInt();if(L==="string")return yield e.Type.String();const H=L.split("|").map(z=>e.Type.Literal(z.trim()));return yield H.length===0?e.Type.Never():H.length===1?H[0]:e.Type.Union(H)}function*C(T){if(T[1]!=="{"){const L=e.Type.Literal("$"),H=O(T.slice(1));return yield*[L,...H]}for(let L=2;L<T.length;L++)if(T[L]==="}"){const H=j(T.slice(2,L)),z=O(T.slice(L+1));return yield*[...H,...z]}yield e.Type.Literal(T)}function*O(T){for(let L=0;L<T.length;L++)if(T[L]==="$"){const H=e.Type.Literal(T.slice(0,L)),z=C(T.slice(L));return yield*[H,...z]}yield e.Type.Literal(T)}function F(T){return[...O(T)]}M.Parse=F})(k||(e.TemplateLiteralDslParser=k={}));let $=0;class x{Create(j){return j}Strict(j){return JSON.parse(JSON.stringify(j))}}e.TypeBuilder=x;class E extends x{Optional(j){return{[e.Modifier]:"Optional",...l.Clone(j,{})}}ReadonlyOptional(j){return{[e.Modifier]:"ReadonlyOptional",...l.Clone(j,{})}}Readonly(j){return{[e.Modifier]:"Readonly",...j}}Any(j={}){return this.Create({...j,[e.Kind]:"Any"})}Array(j,C={}){return this.Create({...C,[e.Kind]:"Array",type:"array",items:l.Clone(j,{})})}Boolean(j={}){return this.Create({...j,[e.Kind]:"Boolean",type:"boolean"})}Composite(j,C){const O=e.Type.Intersect(j,{}),T=u.ResolveKeys(O,{includePatterns:!1}).reduce((L,H)=>({...L,[H]:e.Type.Index(O,[H])}),{});return e.Type.Object(T,C)}Enum(j,C={}){const F=globalThis.Object.keys(j).filter(T=>isNaN(T)).map(T=>j[T]).map(T=>typeof T=="string"?{[e.Kind]:"Literal",type:"string",const:T}:{[e.Kind]:"Literal",type:"number",const:T});return this.Create({...C,[e.Kind]:"Union",anyOf:F})}Extends(j,C,O,F,T={}){switch(s.Extends(j,C)){case a.Union:return this.Union([l.Clone(O,T),l.Clone(F,T)]);case a.True:return l.Clone(O,T);case a.False:return l.Clone(F,T)}}Exclude(j,C,O={}){if(o.TTemplateLiteral(j))return this.Exclude(m.Resolve(j),C,O);if(o.TTemplateLiteral(C))return this.Exclude(j,m.Resolve(C),O);if(o.TUnion(j)){const F=j.anyOf.filter(T=>s.Extends(T,C)===a.False);return F.length===1?l.Clone(F[0],O):this.Union(F,O)}else return s.Extends(j,C)!==a.False?this.Never(O):l.Clone(j,O)}Extract(j,C,O={}){if(o.TTemplateLiteral(j))return this.Extract(m.Resolve(j),C,O);if(o.TTemplateLiteral(C))return this.Extract(j,m.Resolve(C),O);if(o.TUnion(j)){const F=j.anyOf.filter(T=>s.Extends(T,C)!==a.False);return F.length===1?l.Clone(F[0],O):this.Union(F,O)}else return s.Extends(j,C)!==a.False?l.Clone(j,O):this.Never(O)}Index(j,C,O={}){if(o.TArray(j)&&o.TNumber(C))return l.Clone(j.items,O);if(o.TTuple(j)&&o.TNumber(C)){const T=(j.items===void 0?[]:j.items).map(L=>l.Clone(L,{}));return this.Union(T,O)}else{const F=d.Resolve(C),T=l.Clone(j,{});return c.Resolve(T,F,O)}}Integer(j={}){return this.Create({...j,[e.Kind]:"Integer",type:"integer"})}Intersect(j,C={}){if(j.length===0)return e.Type.Never();if(j.length===1)return l.Clone(j[0],C);const O=j.every(L=>o.TObject(L)),F=j.map(L=>l.Clone(L,{})),T=o.TSchema(C.unevaluatedProperties)?{unevaluatedProperties:l.Clone(C.unevaluatedProperties,{})}:{};return C.unevaluatedProperties===!1||o.TSchema(C.unevaluatedProperties)||O?this.Create({...C,...T,[e.Kind]:"Intersect",type:"object",allOf:F}):this.Create({...C,...T,[e.Kind]:"Intersect",allOf:F})}KeyOf(j,C={}){if(o.TRecord(j)){const O=Object.getOwnPropertyNames(j.patternProperties)[0];if(O===e.PatternNumberExact)return this.Number(C);if(O===e.PatternStringExact)return this.String(C);throw Error("StandardTypeBuilder: Unable to resolve key type from Record key pattern")}else if(o.TTuple(j)){const F=(j.items===void 0?[]:j.items).map((T,L)=>e.Type.Literal(L));return this.Union(F,C)}else{if(o.TArray(j))return this.Number(C);{const O=u.ResolveKeys(j,{includePatterns:!1});if(O.length===0)return this.Never(C);const F=O.map(T=>this.Literal(T));return this.Union(F,C)}}}Literal(j,C={}){return this.Create({...C,[e.Kind]:"Literal",const:j,type:typeof j})}Never(j={}){return this.Create({...j,[e.Kind]:"Never",not:{}})}Not(j,C){return this.Create({...C,[e.Kind]:"Not",not:j})}Null(j={}){return this.Create({...j,[e.Kind]:"Null",type:"null"})}Number(j={}){return this.Create({...j,[e.Kind]:"Number",type:"number"})}Object(j,C={}){const O=globalThis.Object.getOwnPropertyNames(j),F=O.filter(z=>o.TOptional(j[z])||o.TReadonlyOptional(j[z])),T=O.filter(z=>!F.includes(z)),L=o.TSchema(C.additionalProperties)?{additionalProperties:l.Clone(C.additionalProperties,{})}:{},H=O.reduce((z,V)=>({...z,[V]:l.Clone(j[V],{})}),{});return T.length>0?this.Create({...C,...L,[e.Kind]:"Object",type:"object",properties:H,required:T}):this.Create({...C,...L,[e.Kind]:"Object",type:"object",properties:H})}Omit(j,C,O={}){const F=d.Resolve(C);return f.Map(l.Clone(j,{}),T=>{T.required&&(T.required=T.required.filter(L=>!F.includes(L)),T.required.length===0&&delete T.required);for(const L of globalThis.Object.keys(T.properties))F.includes(L)&&delete T.properties[L];return this.Create(T)},O)}Partial(j,C={}){function O(F){switch(F[e.Modifier]){case"ReadonlyOptional":F[e.Modifier]="ReadonlyOptional";break;case"Readonly":F[e.Modifier]="ReadonlyOptional";break;case"Optional":F[e.Modifier]="Optional";break;default:F[e.Modifier]="Optional";break}}return f.Map(l.Clone(j,{}),F=>(delete F.required,globalThis.Object.keys(F.properties).forEach(T=>O(F.properties[T])),F),C)}Pick(j,C,O={}){const F=d.Resolve(C);return f.Map(l.Clone(j,{}),T=>{T.required&&(T.required=T.required.filter(L=>F.includes(L)),T.required.length===0&&delete T.required);for(const L of globalThis.Object.keys(T.properties))F.includes(L)||delete T.properties[L];return this.Create(T)},O)}Record(j,C,O={}){if(o.TTemplateLiteral(j)){const F=g.ParseExact(j.pattern);return y.Check(F)?this.Object([...w.Generate(F)].reduce((T,L)=>({...T,[L]:l.Clone(C,{})}),{}),O):this.Create({...O,[e.Kind]:"Record",type:"object",patternProperties:{[j.pattern]:l.Clone(C,{})}})}else if(o.TUnion(j)){const F=h.Resolve(j);if(o.TUnionLiteral(F)){const T=F.anyOf.reduce((L,H)=>({...L,[H.const]:l.Clone(C,{})}),{});return this.Object(T,{...O,[e.Hint]:"Record"})}else throw Error("TypeBuilder: Record key of type union contains non-literal types")}else if(o.TLiteral(j)){if(typeof j.const=="string"||typeof j.const=="number")return this.Object({[j.const]:l.Clone(C,{})},O);throw Error("TypeBuilder: Record key of type literal is not of type string or number")}else if(o.TInteger(j)||o.TNumber(j)){const F=e.PatternNumberExact;return this.Create({...O,[e.Kind]:"Record",type:"object",patternProperties:{[F]:l.Clone(C,{})}})}else if(o.TString(j)){const F=j.pattern===void 0?e.PatternStringExact:j.pattern;return this.Create({...O,[e.Kind]:"Record",type:"object",patternProperties:{[F]:l.Clone(C,{})}})}else throw Error("StandardTypeBuilder: Record key is an invalid type")}Recursive(j,C={}){C.$id===void 0&&(C.$id=`T${$++}`);const O=j({[e.Kind]:"This",$ref:`${C.$id}`});return O.$id=C.$id,this.Create({...C,[e.Hint]:"Recursive",...O})}Ref(j,C={}){if(j.$id===void 0)throw Error("StandardTypeBuilder.Ref: Target type must specify an $id");return this.Create({...C,[e.Kind]:"Ref",$ref:j.$id})}Required(j,C={}){function O(F){switch(F[e.Modifier]){case"ReadonlyOptional":F[e.Modifier]="Readonly";break;case"Readonly":F[e.Modifier]="Readonly";break;case"Optional":delete F[e.Modifier];break;default:delete F[e.Modifier];break}}return f.Map(l.Clone(j,{}),F=>(F.required=globalThis.Object.keys(F.properties),globalThis.Object.keys(F.properties).forEach(T=>O(F.properties[T])),F),C)}Rest(j){return o.TTuple(j)?j.items===void 0?[]:j.items.map(C=>l.Clone(C,{})):[l.Clone(j,{})]}String(j={}){return this.Create({...j,[e.Kind]:"String",type:"string"})}TemplateLiteral(j,C={}){const O=typeof j=="string"?p.Create(k.Parse(j)):p.Create(j);return this.Create({...C,[e.Kind]:"TemplateLiteral",type:"string",pattern:O})}Tuple(j,C={}){const[O,F,T]=[!1,j.length,j.length],L=j.map(z=>l.Clone(z,{})),H=j.length>0?{...C,[e.Kind]:"Tuple",type:"array",items:L,additionalItems:O,minItems:F,maxItems:T}:{...C,[e.Kind]:"Tuple",type:"array",minItems:F,maxItems:T};return this.Create(H)}Union(j,C={}){if(o.TTemplateLiteral(j))return m.Resolve(j);{const O=j;if(O.length===0)return this.Never(C);if(O.length===1)return this.Create(l.Clone(O[0],C));const F=O.map(T=>l.Clone(T,{}));return this.Create({...C,[e.Kind]:"Union",anyOf:F})}}Unknown(j={}){return this.Create({...j,[e.Kind]:"Unknown"})}Unsafe(j={}){return this.Create({...j,[e.Kind]:j[e.Kind]||"Unsafe"})}}e.StandardTypeBuilder=E;class R extends E{BigInt(j={}){return this.Create({...j,[e.Kind]:"BigInt",type:"null",typeOf:"BigInt"})}ConstructorParameters(j,C={}){return this.Tuple([...j.parameters],{...C})}Constructor(j,C,O){const F=l.Clone(C,{}),T=j.map(L=>l.Clone(L,{}));return this.Create({...O,[e.Kind]:"Constructor",type:"object",instanceOf:"Constructor",parameters:T,returns:F})}Date(j={}){return this.Create({...j,[e.Kind]:"Date",type:"object",instanceOf:"Date"})}Function(j,C,O){const F=l.Clone(C,{}),T=j.map(L=>l.Clone(L,{}));return this.Create({...O,[e.Kind]:"Function",type:"object",instanceOf:"Function",parameters:T,returns:F})}InstanceType(j,C={}){return l.Clone(j.returns,C)}Parameters(j,C={}){return this.Tuple(j.parameters,{...C})}Promise(j,C={}){return this.Create({...C,[e.Kind]:"Promise",type:"object",instanceOf:"Promise",item:l.Clone(j,{})})}RegEx(j,C={}){return this.Create({...C,[e.Kind]:"String",type:"string",pattern:j.source})}ReturnType(j,C={}){return l.Clone(j.returns,C)}Symbol(j){return this.Create({...j,[e.Kind]:"Symbol",type:"null",typeOf:"Symbol"})}Undefined(j={}){return this.Create({...j,[e.Kind]:"Undefined",type:"null",typeOf:"Undefined"})}Uint8Array(j={}){return this.Create({...j,[e.Kind]:"Uint8Array",type:"object",instanceOf:"Uint8Array"})}Void(j={}){return this.Create({...j,[e.Kind]:"Void",type:"null",typeOf:"Void"})}}e.ExtendedTypeBuilder=R,e.StandardType=new E,e.Type=new R})(J);const Tpe=J.Type.Object({src:J.Type.String(),path:J.Type.Optional(J.Type.String()),volume:J.Type.Optional(J.Type.Number()),rate:J.Type.Optional(J.Type.Number()),html5:J.Type.Optional(J.Type.Boolean())}),Epe=J.Type.Record(J.Type.String(),Tpe),Ope=J.Type.Object({volume:J.Type.Optional(J.Type.Number()),defaultMusic:J.Type.Optional(J.Type.String()),musicFadeInTime:J.Type.Optional(J.Type.Number()),musicFadeOutTime:J.Type.Optional(J.Type.Number()),musicFadeInDelay:J.Type.Optional(J.Type.Number())}),Ape=J.Type.Record(J.Type.String(),J.Type.String()),o9=J.Type.Object({files:Epe,audioTriggers:Ape,options:Ope}),i9={files:{},audioTriggers:{},options:{volume:1,musicFadeInTime:.5,musicFadeInDelay:.5,musicFadeOutTime:.5}},Mpe=J.Type.Object({name:J.Type.String(),description:J.Type.String(),icon:J.Type.String(),onUse:J.Type.Optional(J.Type.Object({action:J.Type.String(),label:J.Type.String()})),tag:J.Type.Optional(J.Type.String()),category:J.Type.Optional(J.Type.String()),showIfEmpty:J.Type.Optional(J.Type.Boolean())}),a9=J.Type.Object({id:J.Type.String(),title:J.Type.String()}),s9=J.Type.Record(J.Type.String(),Mpe);J.Type.Object({categories:J.Type.Array(a9),items:s9});const l9=J.Type.Object({categories:J.Type.Optional(J.Type.Array(a9)),items:J.Type.Optional(s9)}),c9={categories:[{id:"default",title:"Items"}],items:{}},Ppe=J.Type.Object({description:J.Type.String(),hidden:J.Type.Optional(J.Type.Boolean())}),Npe=J.Type.Object({title:J.Type.String(),description:J.Type.String(),objectives:J.Type.Record(J.Type.String(),Ppe),category:J.Type.Optional(J.Type.String())}),Ipe=J.Type.Object({id:J.Type.String(),title:J.Type.String()}),Dpe=J.Type.Record(J.Type.String(),Npe),u9=J.Type.Object({quests:Dpe,categories:J.Type.Array(Ipe)}),f9={quests:{},categories:[{id:"default",title:"Quests"}]},d9=J.Type.Object({enabled:J.Type.Boolean(),background:J.Type.Optional(J.Type.String()),text:J.Type.Optional(J.Type.String()),cssClass:J.Type.Optional(J.Type.String()),position:J.Type.Object({left:J.Type.Number(),top:J.Type.Number(),width:J.Type.Optional(J.Type.Number()),height:J.Type.Optional(J.Type.Number())}),anchor:J.Type.Optional(J.Type.Object({x:J.Type.Number(),y:J.Type.Number()})),action:J.Type.Optional(J.Type.String()),actionType:J.Type.Optional(J.Type.String()),scriptClickable:J.Type.Optional(J.Type.Boolean()),tag:J.Type.Optional(J.Type.String())}),Rpe=J.Type.Record(J.Type.String(),d9),h9=J.Type.Object({buttons:Rpe,clickableDuringScriptsByDefault:J.Type.Optional(J.Type.Boolean())}),p9={buttons:{},clickableDuringScriptsByDefault:!1},Lpe=J.Type.Intersect([d9,J.Type.Object({id:J.Type.String()})]),Bpe=J.Type.Object({background:J.Type.String(),buttons:J.Type.Optional(J.Type.Array(J.Type.Union([J.Type.String(),Lpe])))}),m9=J.Type.Record(J.Type.String(),Bpe);J.Type.Object({screens:m9});const v9=J.Type.Object({screens:J.Type.Optional(m9)}),g9={screens:{}},Fpe=J.Type.Object({name:J.Type.String(),description:J.Type.String(),startingLevel:J.Type.Number(),hidden:J.Type.Optional(J.Type.Boolean()),icon:J.Type.String()}),y9=J.Type.Record(J.Type.String(),Fpe),b9=J.Type.Object({xpPerLevel:J.Type.Number(),notifyLevelUp:J.Type.Boolean()});J.Type.Object({skills:y9,skillOptions:b9});const w9=J.Type.Object({skills:J.Type.Optional(y9),skillOptions:J.Type.Optional(b9)}),k9={skills:{},skillOptions:{xpPerLevel:10,notifyLevelUp:!0}},Fg="###_--_~=:;_JUMP",Hx="###_--_~=:;_RETURN",Vpe="###_--_~=:;_OK",Vg="###_--_~=:;_STOP";function zpe(e){return e===Fg||e===Hx||e===Vpe||e===Vg}const Upe="3.2.11",qpe=new Date("2023-07-11T19:44:03.128Z"),Hpe=400,zg=20,Wx="@empty",x9={background:Wx},Wpe=J.Type.Object({color:J.Type.Optional(J.Type.String()),boxCss:J.Type.Optional(J.Type.Record(J.Type.String(),J.Type.Any())),nameCss:J.Type.Optional(J.Type.Record(J.Type.String(),J.Type.Any())),textCss:J.Type.Optional(J.Type.Record(J.Type.String(),J.Type.Any()))}),Kpe=J.Type.Object({sprites:J.Type.Optional(J.Type.Record(J.Type.String(),J.Type.String())),name:J.Type.String(),style:J.Type.Optional(Wpe)}),_9=J.Type.Object({config:J.Type.Object({imagesPath:J.Type.String(),playerCharacter:J.Type.Optional(J.Type.String()),gameCharacter:J.Type.Optional(J.Type.String())}),characters:J.Type.Record(J.Type.String(),Kpe)}),j9={config:{imagesPath:"",playerCharacter:"player",gameCharacter:"game"},characters:{}},Gpe=J.Type.Object({backgrounds:J.Type.Object({width:J.Type.Number(),height:J.Type.Number()}),dialogBottomPadding:J.Type.Union([J.Type.Number(),J.Type.String()]),minTextWidth:J.Type.Optional(J.Type.Number()),verticalLayoutThreshold:J.Type.Number(),defaultFontSize:J.Type.Optional(J.Type.Number()),portraits:J.Type.Object({width:J.Type.Number(),height:J.Type.Number(),offset:J.Type.Optional(J.Type.Object({landscape:J.Type.Optional(J.Type.Object({right:J.Type.Number(),bottom:J.Type.Number()})),portrait:J.Type.Optional(J.Type.Object({right:J.Type.Number(),bottom:J.Type.Number()}))}))})}),Jpe={backgrounds:{width:880,height:720},dialogBottomPadding:70,verticalLayoutThreshold:600,defaultFontSize:16,portraits:{width:100,height:100}},S9=J.Type.Object({options:J.Type.Object({delay:J.Type.Optional(J.Type.Number()),width:J.Type.Number(),keywordsPrefix:J.Type.String(),screenEdgesMinimumMargin:J.Type.Optional(J.Type.Number())}),tooltips:J.Type.Array(J.Type.Object({keywords:J.Type.Array(J.Type.String()),title:J.Type.String(),description:J.Type.String()}))}),C9={options:{delay:0,width:350,keywordsPrefix:"@@"},tooltips:[]},Qpe=J.Type.Object({name:J.Type.String(),description:J.Type.String(),icon:J.Type.String(),secret:J.Type.Optional(J.Type.Boolean()),category:J.Type.Optional(J.Type.String())}),$9=J.Type.Object({id:J.Type.String(),title:J.Type.String()}),T9=J.Type.Record(J.Type.String(),Qpe);J.Type.Object({defaultAchievementIcon:J.Type.String(),categories:J.Type.Array($9),achievements:T9,notifyNewAchievements:J.Type.Boolean(),secretAchievements:J.Type.Optional(J.Type.Object({censorDescription:J.Type.Optional(J.Type.Boolean()),censorName:J.Type.Optional(J.Type.Boolean()),hideUntilObtained:J.Type.Optional(J.Type.Boolean())}))});const Ype=J.Type.Object({categories:J.Type.Optional(J.Type.Array($9)),achievements:J.Type.Optional(T9)}),E9={categories:[{id:"default",title:"Achievements"}],achievements:{},notifyNewAchievements:!0,defaultAchievementIcon:"img/achievements/trophy.png"},Xpe=J.Type.Object({diceRange:J.Type.Tuple([J.Type.Number(),J.Type.Number()]),diceCount:J.Type.Number(),difficultyText:J.Type.Array(J.Type.Tuple([J.Type.Number(),J.Type.String()])),extraPointsPerLevel:J.Type.Number(),extraDicePerLevel:J.Type.Optional(J.Type.Number()),successOnRollsBelowThreshold:J.Type.Boolean(),showDifficultyText:J.Type.Boolean(),showDifficultyNumber:J.Type.Boolean(),showDifficultyWithoutModifiers:J.Type.Boolean(),finalRollIsHighest:J.Type.Optional(J.Type.Boolean()),finalRollIsLowest:J.Type.Optional(J.Type.Boolean()),failOnRollsEqualToThreshold:J.Type.Optional(J.Type.Boolean())}),Zpe=J.Type.Object({skill:J.Type.String(),difficulty:J.Type.Number(),winsNeeded:J.Type.Optional(J.Type.Number()),hideAfterRoll:J.Type.Optional(J.Type.Boolean()),repeatable:J.Type.Optional(J.Type.Boolean())}),O9=J.Type.Object({options:Xpe,skillChecks:J.Type.Record(J.Type.String(),Zpe)}),A9={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:{}},Qc={baseAssetsPath:"",baseDataPath:"",gameTitle:"Narrat Game",saveFileName:"narrat save",images:{},layout:Jpe,settings:{},gameFlow:{},dialogPanel:{overlayMode:!0,rightOffset:100,bottomOffset:50,width:475,height:680,textSpeed:zg,animateText:!0,timeBetweenLines:100},splashScreens:{},screens:g9,buttons:p9,skills:k9,skillChecks:A9,scripts:[],audio:i9,notifications:{timeOnScreen:2.5,alsoPrintInDialogue:!1},tooltips:C9,hudStats:{},achievements:E9,items:c9,interactionTags:{default:{onlyInteractOutsideOfScripts:!0}},quests:f9,transitions:{},menuButtons:{},debugging:{showScriptFinishedMessage:!1},saves:{mode:"manual",slots:10},characters:j9};var eme=function(t){return tme(t)&&!nme(t)};function tme(e){return!!e&&typeof e=="object"}function nme(e){var t=Object.prototype.toString.call(e);return t==="[object RegExp]"||t==="[object Date]"||ime(e)}var rme=typeof Symbol=="function"&&Symbol.for,ome=rme?Symbol.for("react.element"):60103;function ime(e){return e.$$typeof===ome}function ame(e){return Array.isArray(e)?[]:{}}function Fh(e,t){return t.clone!==!1&&t.isMergeableObject(e)?Nf(ame(e),e,t):e}function sme(e,t,n){return e.concat(t).map(function(r){return Fh(r,n)})}function lme(e,t){if(!t.customMerge)return Nf;var n=t.customMerge(e);return typeof n=="function"?n:Nf}function cme(e){return Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(e).filter(function(t){return Object.propertyIsEnumerable.call(e,t)}):[]}function M9(e){return Object.keys(e).concat(cme(e))}function P9(e,t){try{return t in e}catch{return!1}}function ume(e,t){return P9(e,t)&&!(Object.hasOwnProperty.call(e,t)&&Object.propertyIsEnumerable.call(e,t))}function fme(e,t,n){var r={};return n.isMergeableObject(e)&&M9(e).forEach(function(o){r[o]=Fh(e[o],n)}),M9(t).forEach(function(o){ume(e,o)||(P9(e,o)&&n.isMergeableObject(t[o])?r[o]=lme(o,n)(e[o],t[o],n):r[o]=Fh(t[o],n))}),r}function Nf(e,t,n){n=n||{},n.arrayMerge=n.arrayMerge||sme,n.isMergeableObject=n.isMergeableObject||eme,n.cloneUnlessOtherwiseSpecified=Fh;var r=Array.isArray(t),o=Array.isArray(e),i=r===o;return i?r?n.arrayMerge(e,t,n):fme(e,t,n):Fh(t,n)}Nf.all=function(t,n){if(!Array.isArray(t))throw new Error("first argument should be an array");return t.reduce(function(r,o){return Nf(r,o,n)},{})};var dme=Nf,hme=dme;const Vh=$_(hme),pi=ao("config",{state:()=>({config:Qc}),actions:{async setConfig(e){this.config=e},extendConfig(e){this.config=Vh(this.config,e)},generateSaveData(){return{playerCharacter:this.playerCharacter,gameCharacter:this.gameCharacter}},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 N9(e){const t=Dr(),n=t.getSkillCheck(e.id);if(n&&n.happened&&(n.succeeded||!e.repeatable))return n;const r=$pe(e);return R9(_pe(r,e)),r?t.passSkillCheck(e.id,e.hideAfterRoll):t.failSkillCheck(e.id,e.hideAfterRoll),t.getSkillCheck(e.id)}function pme(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 I9(e){return typeof e=="object"}function D9(e){return typeof e=="string"&&e.search(/\$/)===0}function R9(e){const t={speaker:pi().gameCharacter,text:e,interactive:!1};qn().addDialog(t)}async function Kx(e){qn().addDialog(e)}function mme(e,t){if(t<e.length)return e[t]}/*! js-yaml 4.1.0 https://github.com/nodeca/js-yaml @license MIT */function L9(e){return typeof e>"u"||e===null}function vme(e){return typeof e=="object"&&e!==null}function gme(e){return Array.isArray(e)?e:L9(e)?[]:[e]}function yme(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 bme(e,t){var n="",r;for(r=0;r<t;r+=1)n+=e;return n}function wme(e){return e===0&&Number.NEGATIVE_INFINITY===1/e}var kme=L9,xme=vme,_me=gme,jme=bme,Sme=wme,Cme=yme,so={isNothing:kme,isObject:xme,toArray:_me,repeat:jme,isNegativeZero:Sme,extend:Cme};function B9(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
+ (${e.id} - ${a}/${e.winsNeeded} - rolls: ${JSON.stringify(r.map(s=>s.modified))})`)}else i=r9(n,e.difficulty),ki.log(`[SKILL CHECK ${o.name}]: ${i?"✅":"❌"}`,`(${e.id}) - ${n}/${e.difficulty}`);return Gc(i?"onSkillCheckSuccess":"onSkillCheckFailure"),i}function r9(e,t){const{options:n}=cp();let r=e>=t;return n.successOnRollsBelowThreshold&&(r=e<=t),n.failOnRollsEqualToThreshold&&e===t&&(r=!1),r}var J={};(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.Type=e.StandardType=e.ExtendedTypeBuilder=e.StandardTypeBuilder=e.TypeBuilder=e.TemplateLiteralDslParser=e.TemplateLiteralGenerator=e.TemplateLiteralFinite=e.TemplateLiteralParser=e.TemplateLiteralParserError=e.TemplateLiteralResolver=e.TemplateLiteralPattern=e.UnionResolver=e.KeyArrayResolver=e.KeyResolver=e.ObjectMap=e.IndexedAccessor=e.TypeClone=e.TypeExtends=e.TypeExtendsResult=e.ExtendsUndefined=e.TypeGuard=e.TypeGuardUnknownTypeError=e.FormatRegistry=e.TypeRegistry=e.PatternStringExact=e.PatternNumberExact=e.PatternBooleanExact=e.PatternString=e.PatternNumber=e.PatternBoolean=e.Kind=e.Hint=e.Modifier=void 0,e.Modifier=Symbol.for("TypeBox.Modifier"),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(M){const j=new Map;function C(){return new Map(j)}M.Entries=C;function O(){return j.clear()}M.Clear=O;function F(H){return j.has(H)}M.Has=F;function T(H,z){j.set(H,z)}M.Set=T;function L(H){return j.get(H)}M.Get=L})(t||(e.TypeRegistry=t={}));var n;(function(M){const j=new Map;function C(){return new Map(j)}M.Entries=C;function O(){return j.clear()}M.Clear=O;function F(H){return j.has(H)}M.Has=F;function T(H,z){j.set(H,z)}M.Set=T;function L(H){return j.get(H)}M.Get=L})(n||(e.FormatRegistry=n={}));class r extends Error{constructor(j){super("TypeGuard: Unknown type"),this.schema=j}}e.TypeGuardUnknownTypeError=r;var o;(function(M){function j(W){return typeof W=="object"&&W!==null&&!Array.isArray(W)}function C(W){return typeof W=="object"&&W!==null&&Array.isArray(W)}function O(W){try{return new RegExp(W),!0}catch{return!1}}function F(W){if(typeof W!="string")return!1;for(let qe=0;qe<W.length;qe++){const st=W.charCodeAt(qe);if(st>=7&&st<=13||st===27||st===127)return!1}return!0}function T(W){return N(W)||At(W)}function L(W){return typeof W=="bigint"}function H(W){return typeof W=="string"}function z(W){return typeof W=="number"&&globalThis.Number.isFinite(W)}function V(W){return typeof W=="boolean"}function I(W){return W===void 0||W!==void 0&&L(W)}function P(W){return W===void 0||W!==void 0&&z(W)}function N(W){return W===void 0||W!==void 0&&V(W)}function D(W){return W===void 0||W!==void 0&&H(W)}function S(W){return W===void 0||W!==void 0&&H(W)&&F(W)&&O(W)}function A(W){return W===void 0||W!==void 0&&H(W)&&F(W)}function B(W){return W===void 0||At(W)}function Q(W){return Le(W)&&W[e.Kind]==="Any"&&D(W.$id)}M.TAny=Q;function te(W){return Le(W)&&W[e.Kind]==="Array"&&W.type==="array"&&D(W.$id)&&At(W.items)&&P(W.minItems)&&P(W.maxItems)&&N(W.uniqueItems)}M.TArray=te;function he(W){return Le(W)&&W[e.Kind]==="BigInt"&&W.type==="null"&&W.typeOf==="BigInt"&&D(W.$id)&&I(W.multipleOf)&&I(W.minimum)&&I(W.maximum)&&I(W.exclusiveMinimum)&&I(W.exclusiveMaximum)}M.TBigInt=he;function ke(W){return Le(W)&&W[e.Kind]==="Boolean"&&W.type==="boolean"&&D(W.$id)}M.TBoolean=ke;function be(W){if(!(Le(W)&&W[e.Kind]==="Constructor"&&W.type==="object"&&W.instanceOf==="Constructor"&&D(W.$id)&&C(W.parameters)&&At(W.returns)))return!1;for(const qe of W.parameters)if(!At(qe))return!1;return!0}M.TConstructor=be;function de(W){return Le(W)&&W[e.Kind]==="Date"&&W.type==="object"&&W.instanceOf==="Date"&&D(W.$id)&&P(W.minimumTimestamp)&&P(W.maximumTimestamp)&&P(W.exclusiveMinimumTimestamp)&&P(W.exclusiveMaximumTimestamp)}M.TDate=de;function Be(W){if(!(Le(W)&&W[e.Kind]==="Function"&&W.type==="object"&&W.instanceOf==="Function"&&D(W.$id)&&C(W.parameters)&&At(W.returns)))return!1;for(const qe of W.parameters)if(!At(qe))return!1;return!0}M.TFunction=Be;function ee(W){return Le(W)&&W[e.Kind]==="Integer"&&W.type==="integer"&&D(W.$id)&&P(W.multipleOf)&&P(W.minimum)&&P(W.maximum)&&P(W.exclusiveMinimum)&&P(W.exclusiveMaximum)}M.TInteger=ee;function Oe(W){if(!(Le(W)&&W[e.Kind]==="Intersect"&&C(W.allOf)&&D(W.type)&&(N(W.unevaluatedProperties)||B(W.unevaluatedProperties))&&D(W.$id))||"type"in W&&W.type!=="object")return!1;for(const qe of W.allOf)if(!At(qe))return!1;return!0}M.TIntersect=Oe;function Le(W){return j(W)&&e.Kind in W&&typeof W[e.Kind]=="string"}M.TKind=Le;function Ce(W){return Le(W)&&W[e.Kind]==="Literal"&&D(W.$id)&&typeof W.const=="string"}M.TLiteralString=Ce;function X(W){return Le(W)&&W[e.Kind]==="Literal"&&D(W.$id)&&typeof W.const=="number"}M.TLiteralNumber=X;function re(W){return Le(W)&&W[e.Kind]==="Literal"&&D(W.$id)&&typeof W.const=="boolean"}M.TLiteralBoolean=re;function we(W){return Ce(W)||X(W)||re(W)}M.TLiteral=we;function Me(W){return Le(W)&&W[e.Kind]==="Never"&&j(W.not)&&globalThis.Object.getOwnPropertyNames(W.not).length===0}M.TNever=Me;function Ee(W){return Le(W)&&W[e.Kind]==="Not"&&At(W.not)}M.TNot=Ee;function Ze(W){return Le(W)&&W[e.Kind]==="Null"&&W.type==="null"&&D(W.$id)}M.TNull=Ze;function ve(W){return Le(W)&&W[e.Kind]==="Number"&&W.type==="number"&&D(W.$id)&&P(W.multipleOf)&&P(W.minimum)&&P(W.maximum)&&P(W.exclusiveMinimum)&&P(W.exclusiveMaximum)}M.TNumber=ve;function Ne(W){if(!(Le(W)&&W[e.Kind]==="Object"&&W.type==="object"&&D(W.$id)&&j(W.properties)&&T(W.additionalProperties)&&P(W.minProperties)&&P(W.maxProperties)))return!1;for(const[qe,st]of Object.entries(W.properties))if(!F(qe)||!At(st))return!1;return!0}M.TObject=Ne;function ze(W){return Le(W)&&W[e.Kind]==="Promise"&&W.type==="object"&&W.instanceOf==="Promise"&&D(W.$id)&&At(W.item)}M.TPromise=ze;function Ye(W){if(!(Le(W)&&W[e.Kind]==="Record"&&W.type==="object"&&D(W.$id)&&T(W.additionalProperties)&&j(W.patternProperties)))return!1;const qe=Object.keys(W.patternProperties);return!(qe.length!==1||!O(qe[0])||!At(W.patternProperties[qe[0]]))}M.TRecord=Ye;function We(W){return Le(W)&&W[e.Kind]==="Ref"&&D(W.$id)&&H(W.$ref)}M.TRef=We;function at(W){return Le(W)&&W[e.Kind]==="String"&&W.type==="string"&&D(W.$id)&&P(W.minLength)&&P(W.maxLength)&&S(W.pattern)&&A(W.format)}M.TString=at;function dt(W){return Le(W)&&W[e.Kind]==="Symbol"&&W.type==="null"&&W.typeOf==="Symbol"&&D(W.$id)}M.TSymbol=dt;function ln(W){return Le(W)&&W[e.Kind]==="TemplateLiteral"&&W.type==="string"&&H(W.pattern)&&W.pattern[0]==="^"&&W.pattern[W.pattern.length-1]==="$"}M.TTemplateLiteral=ln;function yt(W){return Le(W)&&W[e.Kind]==="This"&&D(W.$id)&&H(W.$ref)}M.TThis=yt;function vn(W){if(!(Le(W)&&W[e.Kind]==="Tuple"&&W.type==="array"&&D(W.$id)&&z(W.minItems)&&z(W.maxItems)&&W.minItems===W.maxItems))return!1;if(W.items===void 0&&W.additionalItems===void 0&&W.minItems===0)return!0;if(!C(W.items))return!1;for(const qe of W.items)if(!At(qe))return!1;return!0}M.TTuple=vn;function Kt(W){return Le(W)&&W[e.Kind]==="Undefined"&&W.type==="null"&&W.typeOf==="Undefined"&&D(W.$id)}M.TUndefined=Kt;function nn(W){return cn(W)&&W.anyOf.every(qe=>Ce(qe)||X(qe))}M.TUnionLiteral=nn;function cn(W){if(!(Le(W)&&W[e.Kind]==="Union"&&C(W.anyOf)&&D(W.$id)))return!1;for(const qe of W.anyOf)if(!At(qe))return!1;return!0}M.TUnion=cn;function Qn(W){return Le(W)&&W[e.Kind]==="Uint8Array"&&W.type==="object"&&D(W.$id)&&W.instanceOf==="Uint8Array"&&P(W.minByteLength)&&P(W.maxByteLength)}M.TUint8Array=Qn;function En(W){return Le(W)&&W[e.Kind]==="Unknown"&&D(W.$id)}M.TUnknown=En;function Xn(W){return Le(W)&&W[e.Kind]==="Unsafe"}M.TUnsafe=Xn;function zn(W){return Le(W)&&W[e.Kind]==="Void"&&W.type==="null"&&W.typeOf==="Void"&&D(W.$id)}M.TVoid=zn;function dn(W){return j(W)&&W[e.Modifier]==="ReadonlyOptional"}M.TReadonlyOptional=dn;function Ae(W){return j(W)&&W[e.Modifier]==="Readonly"}M.TReadonly=Ae;function bt(W){return j(W)&&W[e.Modifier]==="Optional"}M.TOptional=bt;function At(W){return typeof W=="object"&&(Q(W)||te(W)||ke(W)||he(W)||be(W)||de(W)||Be(W)||ee(W)||Oe(W)||we(W)||Me(W)||Ee(W)||Ze(W)||ve(W)||Ne(W)||ze(W)||Ye(W)||We(W)||at(W)||dt(W)||ln(W)||yt(W)||vn(W)||Kt(W)||cn(W)||Qn(W)||En(W)||Xn(W)||zn(W)||Le(W)&&t.Has(W[e.Kind]))}M.TSchema=At})(o||(e.TypeGuard=o={}));var i;(function(M){function j(C){return C[e.Kind]==="Undefined"?!0:C[e.Kind]==="Not"?!j(C.not):C[e.Kind]==="Intersect"?C.allOf.every(F=>j(F)):C[e.Kind]==="Union"?C.anyOf.some(F=>j(F)):!1}M.Check=j})(i||(e.ExtendsUndefined=i={}));var a;(function(M){M[M.Union=0]="Union",M[M.True=1]="True",M[M.False=2]="False"})(a||(e.TypeExtendsResult=a={}));var s;(function(M){function j(q){return q===a.False?a.False:a.True}function C(q,_){return a.True}function O(q,_){return o.TIntersect(_)?S(q,_):o.TUnion(_)&&_.anyOf.some(G=>o.TAny(G)||o.TUnknown(G))?a.True:o.TUnion(_)?a.Union:o.TUnknown(_)||o.TAny(_)?a.True:a.Union}function F(q,_){return o.TUnknown(q)?a.False:o.TAny(q)?a.Union:o.TNever(q)?a.True:a.False}function T(q,_){return o.TIntersect(_)?S(q,_):o.TUnion(_)?qe(q,_):o.TUnknown(_)?ht():o.TAny(_)?C():o.TObject(_)&&Ye(_)?a.True:o.TArray(_)?j(oe(q.items,_.items)):a.False}function L(q,_){return o.TIntersect(_)?S(q,_):o.TUnion(_)?qe(q,_):o.TNever(_)?ke():o.TUnknown(_)?ht():o.TAny(_)?C():o.TObject(_)?dt(q,_):o.TRecord(_)?nn(q,_):o.TBigInt(_)?a.True:a.False}function H(q,_){return o.TLiteral(q)&&typeof q.const=="boolean"||o.TBoolean(q)?a.True:a.False}function z(q,_){return o.TIntersect(_)?S(q,_):o.TUnion(_)?qe(q,_):o.TNever(_)?ke():o.TUnknown(_)?ht():o.TAny(_)?C():o.TObject(_)?dt(q,_):o.TRecord(_)?nn(q,_):o.TBoolean(_)?a.True:a.False}function V(q,_){return o.TIntersect(_)?S(q,_):o.TUnion(_)?qe(q,_):o.TUnknown(_)?ht():o.TAny(_)?C():o.TObject(_)?dt(q,_):!o.TConstructor(_)||q.parameters.length>_.parameters.length||!q.parameters.every((G,le)=>j(oe(_.parameters[le],G))===a.True)?a.False:j(oe(q.returns,_.returns))}function I(q,_){return o.TIntersect(_)?S(q,_):o.TUnion(_)?qe(q,_):o.TUnknown(_)?ht():o.TAny(_)?C():o.TObject(_)?dt(q,_):o.TRecord(_)?nn(q,_):o.TDate(_)?a.True:a.False}function P(q,_){return o.TIntersect(_)?S(q,_):o.TUnion(_)?qe(q,_):o.TUnknown(_)?ht():o.TAny(_)?C():o.TObject(_)?dt(q,_):!o.TFunction(_)||q.parameters.length>_.parameters.length||!q.parameters.every((G,le)=>j(oe(_.parameters[le],G))===a.True)?a.False:j(oe(q.returns,_.returns))}function N(q,_){return o.TLiteral(q)&&typeof q.const=="number"||o.TNumber(q)||o.TInteger(q)?a.True:a.False}function D(q,_){return o.TIntersect(_)?S(q,_):o.TUnion(_)?qe(q,_):o.TNever(_)?ke():o.TUnknown(_)?ht():o.TAny(_)?C():o.TObject(_)?dt(q,_):o.TRecord(_)?nn(q,_):o.TInteger(_)||o.TNumber(_)?a.True:a.False}function S(q,_){return _.allOf.every(G=>oe(q,G)===a.True)?a.True:a.False}function A(q,_){return q.allOf.some(G=>oe(G,_)===a.True)?a.True:a.False}function B(q){return typeof q.const=="string"}function Q(q){return typeof q.const=="number"}function te(q){return typeof q.const=="boolean"}function he(q,_){return o.TIntersect(_)?S(q,_):o.TUnion(_)?qe(q,_):o.TNever(_)?ke():o.TUnknown(_)?ht():o.TAny(_)?C():o.TObject(_)?dt(q,_):o.TRecord(_)?nn(q,_):o.TString(_)?Qn(q):o.TNumber(_)?Oe(q):o.TInteger(_)?N(q):o.TBoolean(_)?H(q):o.TLiteral(_)&&_.const===q.const?a.True:a.False}function ke(q,_){return a.False}function be(q,_){return a.True}function de(q){let[_,G]=[q,0];for(;o.TNot(_);)_=_.not,G+=1;return G%2===0?_:e.Type.Unknown()}function Be(q,_){if(o.TNot(q))return oe(de(q),_);if(o.TNot(_))return oe(q,de(_));throw new Error("TypeExtends: Invalid fallthrough for Not")}function ee(q,_){return o.TIntersect(_)?S(q,_):o.TUnion(_)?qe(q,_):o.TNever(_)?ke():o.TUnknown(_)?ht():o.TAny(_)?C():o.TObject(_)?dt(q,_):o.TRecord(_)?nn(q,_):o.TNull(_)?a.True:a.False}function Oe(q,_){return o.TLiteral(q)&&Q(q)||o.TNumber(q)||o.TInteger(q)?a.True:a.False}function Le(q,_){return o.TIntersect(_)?S(q,_):o.TUnion(_)?qe(q,_):o.TNever(_)?ke():o.TUnknown(_)?ht():o.TAny(_)?C():o.TObject(_)?dt(q,_):o.TRecord(_)?nn(q,_):o.TInteger(_)||o.TNumber(_)?a.True:a.False}function Ce(q,_){return globalThis.Object.keys(q.properties).length===_}function X(q){return Ye(q)}function re(q){return Ce(q,0)||Ce(q,1)&&"description"in q.properties&&o.TUnion(q.properties.description)&&q.properties.description.anyOf.length===2&&(o.TString(q.properties.description.anyOf[0])&&o.TUndefined(q.properties.description.anyOf[1])||o.TString(q.properties.description.anyOf[1])&&o.TUndefined(q.properties.description.anyOf[0]))}function we(q){return Ce(q,0)}function Me(q){return Ce(q,0)}function Ee(q){return Ce(q,0)}function Ze(q){return Ce(q,0)}function ve(q){return Ye(q)}function Ne(q){const _=e.Type.Number();return Ce(q,0)||Ce(q,1)&&"length"in q.properties&&j(oe(q.properties.length,_))===a.True}function ze(q){return Ce(q,0)}function Ye(q){const _=e.Type.Number();return Ce(q,0)||Ce(q,1)&&"length"in q.properties&&j(oe(q.properties.length,_))===a.True}function We(q){const _=e.Type.Function([e.Type.Any()],e.Type.Any());return Ce(q,0)||Ce(q,1)&&"then"in q.properties&&j(oe(q.properties.then,_))===a.True}function at(q,_){return oe(q,_)===a.False||o.TOptional(q)&&!o.TOptional(_)?a.False:a.True}function dt(q,_){return o.TUnknown(q)?a.False:o.TAny(q)?a.Union:o.TNever(q)||o.TLiteral(q)&&B(q)&&X(_)||o.TLiteral(q)&&Q(q)&&we(_)||o.TLiteral(q)&&te(q)&&Me(_)||o.TSymbol(q)&&re(_)||o.TBigInt(q)&&Ee(_)||o.TString(q)&&X(_)||o.TSymbol(q)&&re(_)||o.TNumber(q)&&we(_)||o.TInteger(q)&&we(_)||o.TBoolean(q)&&Me(_)||o.TUint8Array(q)&&ve(_)||o.TDate(q)&&Ze(_)||o.TConstructor(q)&&ze(_)||o.TFunction(q)&&Ne(_)?a.True:o.TRecord(q)&&o.TString(vn(q))?_[e.Hint]==="Record"?a.True:a.False:o.TRecord(q)&&o.TNumber(vn(q))&&Ce(_,0)?a.True:a.False}function ln(q,_){if(o.TIntersect(_))return S(q,_);if(o.TUnion(_))return qe(q,_);if(o.TUnknown(_))return ht();if(o.TAny(_))return C();if(o.TRecord(_))return nn(q,_);if(!o.TObject(_))return a.False;for(const G of globalThis.Object.keys(_.properties))if(!(G in q.properties)||at(q.properties[G],_.properties[G])===a.False)return a.False;return a.True}function yt(q,_){return o.TIntersect(_)?S(q,_):o.TUnion(_)?qe(q,_):o.TUnknown(_)?ht():o.TAny(_)?C():o.TObject(_)&&We(_)?a.True:o.TPromise(_)?j(oe(q.item,_.item)):a.False}function vn(q){if(e.PatternNumberExact in q.patternProperties)return e.Type.Number();if(e.PatternStringExact in q.patternProperties)return e.Type.String();throw Error("TypeExtends: Cannot get record key")}function Kt(q){if(e.PatternNumberExact in q.patternProperties)return q.patternProperties[e.PatternNumberExact];if(e.PatternStringExact in q.patternProperties)return q.patternProperties[e.PatternStringExact];throw Error("TypeExtends: Cannot get record value")}function nn(q,_){const G=vn(_),le=Kt(_);if(o.TLiteral(q)&&B(q)&&o.TNumber(G)&&j(oe(q,le))===a.True)return a.True;if(o.TUint8Array(q)&&o.TNumber(G)||o.TString(q)&&o.TNumber(G)||o.TArray(q)&&o.TNumber(G))return oe(q,le);if(o.TObject(q)){for(const xe of globalThis.Object.keys(q.properties))if(at(le,q.properties[xe])===a.False)return a.False;return a.True}return a.False}function cn(q,_){const G=Kt(q);return o.TIntersect(_)?S(q,_):o.TUnion(_)?qe(q,_):o.TUnknown(_)?ht():o.TAny(_)?C():o.TObject(_)?dt(q,_):o.TRecord(_)?oe(G,Kt(_)):a.False}function Qn(q,_){return o.TLiteral(q)&&typeof q.const=="string"||o.TString(q)?a.True:a.False}function En(q,_){return o.TIntersect(_)?S(q,_):o.TUnion(_)?qe(q,_):o.TNever(_)?ke():o.TUnknown(_)?ht():o.TAny(_)?C():o.TObject(_)?dt(q,_):o.TRecord(_)?nn(q,_):o.TString(_)?a.True:a.False}function Xn(q,_){return o.TIntersect(_)?S(q,_):o.TUnion(_)?qe(q,_):o.TNever(_)?ke():o.TUnknown(_)?ht():o.TAny(_)?C():o.TObject(_)?dt(q,_):o.TRecord(_)?nn(q,_):o.TSymbol(_)?a.True:a.False}function zn(q,_){if(o.TTemplateLiteral(q))return oe(m.Resolve(q),_);if(o.TTemplateLiteral(_))return oe(q,m.Resolve(_));throw new Error("TypeExtends: Invalid fallthrough for TemplateLiteral")}function dn(q,_){return o.TUnknown(q)?a.False:o.TAny(q)?a.Union:o.TNever(q)?a.True:a.False}function Ae(q,_){return o.TArray(_)&&q.items!==void 0&&q.items.every(G=>oe(G,_.items)===a.True)}function bt(q,_){return o.TIntersect(_)?S(q,_):o.TUnion(_)?qe(q,_):o.TUnknown(_)?ht():o.TAny(_)?C():o.TObject(_)&&Ye(_)||o.TArray(_)&&Ae(q,_)?a.True:!o.TTuple(_)||q.items===void 0&&_.items!==void 0||q.items!==void 0&&_.items===void 0?a.False:q.items===void 0&&_.items===void 0||q.items.every((G,le)=>oe(G,_.items[le])===a.True)?a.True:a.False}function At(q,_){return o.TIntersect(_)?S(q,_):o.TUnion(_)?qe(q,_):o.TUnknown(_)?ht():o.TAny(_)?C():o.TObject(_)?dt(q,_):o.TRecord(_)?nn(q,_):o.TUint8Array(_)?a.True:a.False}function W(q,_){return o.TIntersect(_)?S(q,_):o.TUnion(_)?qe(q,_):o.TNever(_)?ke():o.TUnknown(_)?ht():o.TAny(_)?C():o.TObject(_)?dt(q,_):o.TRecord(_)?nn(q,_):o.TVoid(_)?hn(q):o.TUndefined(_)?a.True:a.False}function qe(q,_){return _.anyOf.some(G=>oe(q,G)===a.True)?a.True:a.False}function st(q,_){return q.anyOf.every(G=>oe(G,_)===a.True)?a.True:a.False}function ht(q,_){return a.True}function Un(q,_){return o.TIntersect(_)?S(q,_):o.TUnion(_)?qe(q,_):o.TAny(_)?C():o.TString(_)?Qn(q):o.TNumber(_)?Oe(q):o.TInteger(_)?N(q):o.TBoolean(_)?H(q):o.TArray(_)?F(q):o.TTuple(_)?dn(q):o.TObject(_)?dt(q,_):o.TUnknown(_)?a.True:a.False}function hn(q,_){return o.TUndefined(q)||o.TUndefined(q)?a.True:a.False}function Rr(q,_){return o.TIntersect(_)?S(q,_):o.TUnion(_)?qe(q,_):o.TUnknown(_)?ht():o.TAny(_)?C():o.TObject(_)?dt(q,_):o.TVoid(_)?a.True:a.False}function oe(q,_){if(o.TTemplateLiteral(q)||o.TTemplateLiteral(_))return zn(q,_);if(o.TNot(q)||o.TNot(_))return Be(q,_);if(o.TAny(q))return O(q,_);if(o.TArray(q))return T(q,_);if(o.TBigInt(q))return L(q,_);if(o.TBoolean(q))return z(q,_);if(o.TConstructor(q))return V(q,_);if(o.TDate(q))return I(q,_);if(o.TFunction(q))return P(q,_);if(o.TInteger(q))return D(q,_);if(o.TIntersect(q))return A(q,_);if(o.TLiteral(q))return he(q,_);if(o.TNever(q))return be();if(o.TNull(q))return ee(q,_);if(o.TNumber(q))return Le(q,_);if(o.TObject(q))return ln(q,_);if(o.TRecord(q))return cn(q,_);if(o.TString(q))return En(q,_);if(o.TSymbol(q))return Xn(q,_);if(o.TTuple(q))return bt(q,_);if(o.TPromise(q))return yt(q,_);if(o.TUint8Array(q))return At(q,_);if(o.TUndefined(q))return W(q,_);if(o.TUnion(q))return st(q,_);if(o.TUnknown(q))return Un(q,_);if(o.TVoid(q))return Rr(q,_);throw Error(`TypeExtends: Unknown left type operand '${q[e.Kind]}'`)}function ye(q,_){return oe(q,_)}M.Extends=ye})(s||(e.TypeExtends=s={}));var l;(function(M){function j(H){return typeof H=="object"&&H!==null}function C(H){return globalThis.Array.isArray(H)}function O(H){return H.map(z=>T(z))}function F(H){const z=globalThis.Object.getOwnPropertyNames(H).reduce((I,P)=>({...I,[P]:T(H[P])}),{}),V=globalThis.Object.getOwnPropertySymbols(H).reduce((I,P)=>({...I,[P]:T(H[P])}),{});return{...z,...V}}function T(H){return C(H)?O(H):j(H)?F(H):H}function L(H,z){return{...T(H),...z}}M.Clone=L})(l||(e.TypeClone=l={}));var c;(function(M){function j(H,z){const V=H.allOf.reduce((I,P)=>{const N=T(P,z);return N[e.Kind]==="Never"?I:[...I,N]},[]);return e.Type.Intersect(V)}function C(H,z){const V=H.anyOf.map(I=>T(I,z));return e.Type.Union(V)}function O(H,z){const V=H.properties[z];return V===void 0?e.Type.Never():e.Type.Union([V])}function F(H,z){const V=H.items;if(V===void 0)return e.Type.Never();const I=V[z];return I===void 0?e.Type.Never():I}function T(H,z){return H[e.Kind]==="Intersect"?j(H,z):H[e.Kind]==="Union"?C(H,z):H[e.Kind]==="Object"?O(H,z):H[e.Kind]==="Tuple"?F(H,z):e.Type.Never()}function L(H,z,V={}){return e.Type.Union(z.map(I=>T(H,I.toString())),V)}M.Resolve=L})(c||(e.IndexedAccessor=c={}));var f;(function(M){function j(L,H){return e.Type.Intersect(L.allOf.map(z=>F(z,H)),{...L})}function C(L,H){return e.Type.Union(L.anyOf.map(z=>F(z,H)),{...L})}function O(L,H){return H(L)}function F(L,H){return L[e.Kind]==="Intersect"?j(L,H):L[e.Kind]==="Union"?C(L,H):L[e.Kind]==="Object"?O(L,H):L}function T(L,H,z){return{...F(l.Clone(L,{}),H),...z}}M.Map=T})(f||(e.ObjectMap=f={}));var u;(function(M){function j(V){return V[0]==="^"&&V[V.length-1]==="$"?V.slice(1,V.length-1):V}function C(V,I){return V.allOf.reduce((P,N)=>[...P,...L(N,I)],[])}function O(V,I){const P=V.anyOf.map(N=>L(N,I));return[...P.reduce((N,D)=>D.map(S=>P.every(A=>A.includes(S))?N.add(S):N)[0],new Set)]}function F(V,I){return globalThis.Object.keys(V.properties)}function T(V,I){return I.includePatterns?globalThis.Object.keys(V.patternProperties):[]}function L(V,I){return o.TIntersect(V)?C(V,I):o.TUnion(V)?O(V,I):o.TObject(V)?F(V):o.TRecord(V)?T(V,I):[]}function H(V,I){return[...new Set(L(V,I))]}M.ResolveKeys=H;function z(V){return`^(${H(V,{includePatterns:!0}).map(N=>`(${j(N)})`).join("|")})$`}M.ResolvePattern=z})(u||(e.KeyResolver=u={}));var d;(function(M){function j(C){if(globalThis.Array.isArray(C))return C;if(o.TUnionLiteral(C))return C.anyOf.map(O=>O.const.toString());if(o.TLiteral(C))return[C.const];if(o.TTemplateLiteral(C)){const O=g.ParseExact(C.pattern);if(!y.Check(O))throw Error("KeyArrayResolver: Cannot resolve keys from infinite template expression");return[...w.Generate(O)]}return[]}M.Resolve=j})(d||(e.KeyArrayResolver=d={}));var h;(function(M){function*j(O){for(const F of O.anyOf)F[e.Kind]==="Union"?yield*j(F):yield F}function C(O){return e.Type.Union([...j(O)],{...O})}M.Resolve=C})(h||(e.UnionResolver=h={}));var p;(function(M){function j(F){return F.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function C(F,T){if(o.TTemplateLiteral(F))return F.pattern.slice(1,F.pattern.length-1);if(o.TUnion(F))return`(${F.anyOf.map(H=>C(H,T)).join("|")})`;if(o.TNumber(F))return`${T}${e.PatternNumber}`;if(o.TInteger(F))return`${T}${e.PatternNumber}`;if(o.TBigInt(F))return`${T}${e.PatternNumber}`;if(o.TString(F))return`${T}${e.PatternString}`;if(o.TLiteral(F))return`${T}${j(F.const.toString())}`;if(o.TBoolean(F))return`${T}${e.PatternBoolean}`;throw o.TNever(F)?Error("TemplateLiteralPattern: TemplateLiteral cannot operate on types of TNever"):Error(`TemplateLiteralPattern: Unexpected Kind '${F[e.Kind]}'`)}function O(F){return`^${F.map(T=>C(T,"")).join("")}$`}M.Create=O})(p||(e.TemplateLiteralPattern=p={}));var m;(function(M){function j(C){const O=g.ParseExact(C.pattern);if(!y.Check(O))return e.Type.String();const F=[...w.Generate(O)].map(T=>e.Type.Literal(T));return e.Type.Union(F)}M.Resolve=j})(m||(e.TemplateLiteralResolver=m={}));class v extends Error{constructor(j){super(j)}}e.TemplateLiteralParserError=v;var g;(function(M){function j(D,S,A){return D[S]===A&&D.charCodeAt(S-1)!==92}function C(D,S){return j(D,S,"(")}function O(D,S){return j(D,S,")")}function F(D,S){return j(D,S,"|")}function T(D){if(!(C(D,0)&&O(D,D.length-1)))return!1;let S=0;for(let A=0;A<D.length;A++)if(C(D,A)&&(S+=1),O(D,A)&&(S-=1),S===0&&A!==D.length-1)return!1;return!0}function L(D){return D.slice(1,D.length-1)}function H(D){let S=0;for(let A=0;A<D.length;A++)if(C(D,A)&&(S+=1),O(D,A)&&(S-=1),F(D,A)&&S===0)return!0;return!1}function z(D){for(let S=0;S<D.length;S++)if(C(D,S))return!0;return!1}function V(D){let[S,A]=[0,0];const B=[];for(let te=0;te<D.length;te++)if(C(D,te)&&(S+=1),O(D,te)&&(S-=1),F(D,te)&&S===0){const he=D.slice(A,te);he.length>0&&B.push(P(he)),A=te+1}const Q=D.slice(A);return Q.length>0&&B.push(P(Q)),B.length===0?{type:"const",const:""}:B.length===1?B[0]:{type:"or",expr:B}}function I(D){function S(Q,te){if(!C(Q,te))throw new v("TemplateLiteralParser: Index must point to open parens");let he=0;for(let ke=te;ke<Q.length;ke++)if(C(Q,ke)&&(he+=1),O(Q,ke)&&(he-=1),he===0)return[te,ke];throw new v("TemplateLiteralParser: Unclosed group parens in expression")}function A(Q,te){for(let he=te;he<Q.length;he++)if(C(Q,he))return[te,he];return[te,Q.length]}const B=[];for(let Q=0;Q<D.length;Q++)if(C(D,Q)){const[te,he]=S(D,Q),ke=D.slice(te,he+1);B.push(P(ke)),Q=he}else{const[te,he]=A(D,Q),ke=D.slice(te,he);ke.length>0&&B.push(P(ke)),Q=he-1}return B.length===0?{type:"const",const:""}:B.length===1?B[0]:{type:"and",expr:B}}function P(D){return T(D)?P(L(D)):H(D)?V(D):z(D)?I(D):{type:"const",const:D}}M.Parse=P;function N(D){return P(D.slice(1,D.length-1))}M.ParseExact=N})(g||(e.TemplateLiteralParser=g={}));var y;(function(M){function j(T){return T.type==="or"&&T.expr.length===2&&T.expr[0].type==="const"&&T.expr[0].const==="0"&&T.expr[1].type==="const"&&T.expr[1].const==="[1-9][0-9]*"}function C(T){return T.type==="or"&&T.expr.length===2&&T.expr[0].type==="const"&&T.expr[0].const==="true"&&T.expr[1].type==="const"&&T.expr[1].const==="false"}function O(T){return T.type==="const"&&T.const===".*"}function F(T){if(C(T))return!0;if(j(T)||O(T))return!1;if(T.type==="and")return T.expr.every(L=>F(L));if(T.type==="or")return T.expr.every(L=>F(L));if(T.type==="const")return!0;throw Error("TemplateLiteralFinite: Unknown expression type")}M.Check=F})(y||(e.TemplateLiteralFinite=y={}));var w;(function(M){function*j(L){if(L.length===1)return yield*L[0];for(const H of L[0])for(const z of j(L.slice(1)))yield`${H}${z}`}function*C(L){return yield*j(L.expr.map(H=>[...T(H)]))}function*O(L){for(const H of L.expr)yield*T(H)}function*F(L){return yield L.const}function*T(L){if(L.type==="and")return yield*C(L);if(L.type==="or")return yield*O(L);if(L.type==="const")return yield*F(L);throw Error("TemplateLiteralGenerator: Unknown expression")}M.Generate=T})(w||(e.TemplateLiteralGenerator=w={}));var k;(function(M){function*j(T){const L=T.trim().replace(/"|'/g,"");if(L==="boolean")return yield e.Type.Boolean();if(L==="number")return yield e.Type.Number();if(L==="bigint")return yield e.Type.BigInt();if(L==="string")return yield e.Type.String();const H=L.split("|").map(z=>e.Type.Literal(z.trim()));return yield H.length===0?e.Type.Never():H.length===1?H[0]:e.Type.Union(H)}function*C(T){if(T[1]!=="{"){const L=e.Type.Literal("$"),H=O(T.slice(1));return yield*[L,...H]}for(let L=2;L<T.length;L++)if(T[L]==="}"){const H=j(T.slice(2,L)),z=O(T.slice(L+1));return yield*[...H,...z]}yield e.Type.Literal(T)}function*O(T){for(let L=0;L<T.length;L++)if(T[L]==="$"){const H=e.Type.Literal(T.slice(0,L)),z=C(T.slice(L));return yield*[H,...z]}yield e.Type.Literal(T)}function F(T){return[...O(T)]}M.Parse=F})(k||(e.TemplateLiteralDslParser=k={}));let $=0;class x{Create(j){return j}Strict(j){return JSON.parse(JSON.stringify(j))}}e.TypeBuilder=x;class E extends x{Optional(j){return{[e.Modifier]:"Optional",...l.Clone(j,{})}}ReadonlyOptional(j){return{[e.Modifier]:"ReadonlyOptional",...l.Clone(j,{})}}Readonly(j){return{[e.Modifier]:"Readonly",...j}}Any(j={}){return this.Create({...j,[e.Kind]:"Any"})}Array(j,C={}){return this.Create({...C,[e.Kind]:"Array",type:"array",items:l.Clone(j,{})})}Boolean(j={}){return this.Create({...j,[e.Kind]:"Boolean",type:"boolean"})}Composite(j,C){const O=e.Type.Intersect(j,{}),T=u.ResolveKeys(O,{includePatterns:!1}).reduce((L,H)=>({...L,[H]:e.Type.Index(O,[H])}),{});return e.Type.Object(T,C)}Enum(j,C={}){const F=globalThis.Object.keys(j).filter(T=>isNaN(T)).map(T=>j[T]).map(T=>typeof T=="string"?{[e.Kind]:"Literal",type:"string",const:T}:{[e.Kind]:"Literal",type:"number",const:T});return this.Create({...C,[e.Kind]:"Union",anyOf:F})}Extends(j,C,O,F,T={}){switch(s.Extends(j,C)){case a.Union:return this.Union([l.Clone(O,T),l.Clone(F,T)]);case a.True:return l.Clone(O,T);case a.False:return l.Clone(F,T)}}Exclude(j,C,O={}){if(o.TTemplateLiteral(j))return this.Exclude(m.Resolve(j),C,O);if(o.TTemplateLiteral(C))return this.Exclude(j,m.Resolve(C),O);if(o.TUnion(j)){const F=j.anyOf.filter(T=>s.Extends(T,C)===a.False);return F.length===1?l.Clone(F[0],O):this.Union(F,O)}else return s.Extends(j,C)!==a.False?this.Never(O):l.Clone(j,O)}Extract(j,C,O={}){if(o.TTemplateLiteral(j))return this.Extract(m.Resolve(j),C,O);if(o.TTemplateLiteral(C))return this.Extract(j,m.Resolve(C),O);if(o.TUnion(j)){const F=j.anyOf.filter(T=>s.Extends(T,C)!==a.False);return F.length===1?l.Clone(F[0],O):this.Union(F,O)}else return s.Extends(j,C)!==a.False?l.Clone(j,O):this.Never(O)}Index(j,C,O={}){if(o.TArray(j)&&o.TNumber(C))return l.Clone(j.items,O);if(o.TTuple(j)&&o.TNumber(C)){const T=(j.items===void 0?[]:j.items).map(L=>l.Clone(L,{}));return this.Union(T,O)}else{const F=d.Resolve(C),T=l.Clone(j,{});return c.Resolve(T,F,O)}}Integer(j={}){return this.Create({...j,[e.Kind]:"Integer",type:"integer"})}Intersect(j,C={}){if(j.length===0)return e.Type.Never();if(j.length===1)return l.Clone(j[0],C);const O=j.every(L=>o.TObject(L)),F=j.map(L=>l.Clone(L,{})),T=o.TSchema(C.unevaluatedProperties)?{unevaluatedProperties:l.Clone(C.unevaluatedProperties,{})}:{};return C.unevaluatedProperties===!1||o.TSchema(C.unevaluatedProperties)||O?this.Create({...C,...T,[e.Kind]:"Intersect",type:"object",allOf:F}):this.Create({...C,...T,[e.Kind]:"Intersect",allOf:F})}KeyOf(j,C={}){if(o.TRecord(j)){const O=Object.getOwnPropertyNames(j.patternProperties)[0];if(O===e.PatternNumberExact)return this.Number(C);if(O===e.PatternStringExact)return this.String(C);throw Error("StandardTypeBuilder: Unable to resolve key type from Record key pattern")}else if(o.TTuple(j)){const F=(j.items===void 0?[]:j.items).map((T,L)=>e.Type.Literal(L));return this.Union(F,C)}else{if(o.TArray(j))return this.Number(C);{const O=u.ResolveKeys(j,{includePatterns:!1});if(O.length===0)return this.Never(C);const F=O.map(T=>this.Literal(T));return this.Union(F,C)}}}Literal(j,C={}){return this.Create({...C,[e.Kind]:"Literal",const:j,type:typeof j})}Never(j={}){return this.Create({...j,[e.Kind]:"Never",not:{}})}Not(j,C){return this.Create({...C,[e.Kind]:"Not",not:j})}Null(j={}){return this.Create({...j,[e.Kind]:"Null",type:"null"})}Number(j={}){return this.Create({...j,[e.Kind]:"Number",type:"number"})}Object(j,C={}){const O=globalThis.Object.getOwnPropertyNames(j),F=O.filter(z=>o.TOptional(j[z])||o.TReadonlyOptional(j[z])),T=O.filter(z=>!F.includes(z)),L=o.TSchema(C.additionalProperties)?{additionalProperties:l.Clone(C.additionalProperties,{})}:{},H=O.reduce((z,V)=>({...z,[V]:l.Clone(j[V],{})}),{});return T.length>0?this.Create({...C,...L,[e.Kind]:"Object",type:"object",properties:H,required:T}):this.Create({...C,...L,[e.Kind]:"Object",type:"object",properties:H})}Omit(j,C,O={}){const F=d.Resolve(C);return f.Map(l.Clone(j,{}),T=>{T.required&&(T.required=T.required.filter(L=>!F.includes(L)),T.required.length===0&&delete T.required);for(const L of globalThis.Object.keys(T.properties))F.includes(L)&&delete T.properties[L];return this.Create(T)},O)}Partial(j,C={}){function O(F){switch(F[e.Modifier]){case"ReadonlyOptional":F[e.Modifier]="ReadonlyOptional";break;case"Readonly":F[e.Modifier]="ReadonlyOptional";break;case"Optional":F[e.Modifier]="Optional";break;default:F[e.Modifier]="Optional";break}}return f.Map(l.Clone(j,{}),F=>(delete F.required,globalThis.Object.keys(F.properties).forEach(T=>O(F.properties[T])),F),C)}Pick(j,C,O={}){const F=d.Resolve(C);return f.Map(l.Clone(j,{}),T=>{T.required&&(T.required=T.required.filter(L=>F.includes(L)),T.required.length===0&&delete T.required);for(const L of globalThis.Object.keys(T.properties))F.includes(L)||delete T.properties[L];return this.Create(T)},O)}Record(j,C,O={}){if(o.TTemplateLiteral(j)){const F=g.ParseExact(j.pattern);return y.Check(F)?this.Object([...w.Generate(F)].reduce((T,L)=>({...T,[L]:l.Clone(C,{})}),{}),O):this.Create({...O,[e.Kind]:"Record",type:"object",patternProperties:{[j.pattern]:l.Clone(C,{})}})}else if(o.TUnion(j)){const F=h.Resolve(j);if(o.TUnionLiteral(F)){const T=F.anyOf.reduce((L,H)=>({...L,[H.const]:l.Clone(C,{})}),{});return this.Object(T,{...O,[e.Hint]:"Record"})}else throw Error("TypeBuilder: Record key of type union contains non-literal types")}else if(o.TLiteral(j)){if(typeof j.const=="string"||typeof j.const=="number")return this.Object({[j.const]:l.Clone(C,{})},O);throw Error("TypeBuilder: Record key of type literal is not of type string or number")}else if(o.TInteger(j)||o.TNumber(j)){const F=e.PatternNumberExact;return this.Create({...O,[e.Kind]:"Record",type:"object",patternProperties:{[F]:l.Clone(C,{})}})}else if(o.TString(j)){const F=j.pattern===void 0?e.PatternStringExact:j.pattern;return this.Create({...O,[e.Kind]:"Record",type:"object",patternProperties:{[F]:l.Clone(C,{})}})}else throw Error("StandardTypeBuilder: Record key is an invalid type")}Recursive(j,C={}){C.$id===void 0&&(C.$id=`T${$++}`);const O=j({[e.Kind]:"This",$ref:`${C.$id}`});return O.$id=C.$id,this.Create({...C,[e.Hint]:"Recursive",...O})}Ref(j,C={}){if(j.$id===void 0)throw Error("StandardTypeBuilder.Ref: Target type must specify an $id");return this.Create({...C,[e.Kind]:"Ref",$ref:j.$id})}Required(j,C={}){function O(F){switch(F[e.Modifier]){case"ReadonlyOptional":F[e.Modifier]="Readonly";break;case"Readonly":F[e.Modifier]="Readonly";break;case"Optional":delete F[e.Modifier];break;default:delete F[e.Modifier];break}}return f.Map(l.Clone(j,{}),F=>(F.required=globalThis.Object.keys(F.properties),globalThis.Object.keys(F.properties).forEach(T=>O(F.properties[T])),F),C)}Rest(j){return o.TTuple(j)?j.items===void 0?[]:j.items.map(C=>l.Clone(C,{})):[l.Clone(j,{})]}String(j={}){return this.Create({...j,[e.Kind]:"String",type:"string"})}TemplateLiteral(j,C={}){const O=typeof j=="string"?p.Create(k.Parse(j)):p.Create(j);return this.Create({...C,[e.Kind]:"TemplateLiteral",type:"string",pattern:O})}Tuple(j,C={}){const[O,F,T]=[!1,j.length,j.length],L=j.map(z=>l.Clone(z,{})),H=j.length>0?{...C,[e.Kind]:"Tuple",type:"array",items:L,additionalItems:O,minItems:F,maxItems:T}:{...C,[e.Kind]:"Tuple",type:"array",minItems:F,maxItems:T};return this.Create(H)}Union(j,C={}){if(o.TTemplateLiteral(j))return m.Resolve(j);{const O=j;if(O.length===0)return this.Never(C);if(O.length===1)return this.Create(l.Clone(O[0],C));const F=O.map(T=>l.Clone(T,{}));return this.Create({...C,[e.Kind]:"Union",anyOf:F})}}Unknown(j={}){return this.Create({...j,[e.Kind]:"Unknown"})}Unsafe(j={}){return this.Create({...j,[e.Kind]:j[e.Kind]||"Unsafe"})}}e.StandardTypeBuilder=E;class R extends E{BigInt(j={}){return this.Create({...j,[e.Kind]:"BigInt",type:"null",typeOf:"BigInt"})}ConstructorParameters(j,C={}){return this.Tuple([...j.parameters],{...C})}Constructor(j,C,O){const F=l.Clone(C,{}),T=j.map(L=>l.Clone(L,{}));return this.Create({...O,[e.Kind]:"Constructor",type:"object",instanceOf:"Constructor",parameters:T,returns:F})}Date(j={}){return this.Create({...j,[e.Kind]:"Date",type:"object",instanceOf:"Date"})}Function(j,C,O){const F=l.Clone(C,{}),T=j.map(L=>l.Clone(L,{}));return this.Create({...O,[e.Kind]:"Function",type:"object",instanceOf:"Function",parameters:T,returns:F})}InstanceType(j,C={}){return l.Clone(j.returns,C)}Parameters(j,C={}){return this.Tuple(j.parameters,{...C})}Promise(j,C={}){return this.Create({...C,[e.Kind]:"Promise",type:"object",instanceOf:"Promise",item:l.Clone(j,{})})}RegEx(j,C={}){return this.Create({...C,[e.Kind]:"String",type:"string",pattern:j.source})}ReturnType(j,C={}){return l.Clone(j.returns,C)}Symbol(j){return this.Create({...j,[e.Kind]:"Symbol",type:"null",typeOf:"Symbol"})}Undefined(j={}){return this.Create({...j,[e.Kind]:"Undefined",type:"null",typeOf:"Undefined"})}Uint8Array(j={}){return this.Create({...j,[e.Kind]:"Uint8Array",type:"object",instanceOf:"Uint8Array"})}Void(j={}){return this.Create({...j,[e.Kind]:"Void",type:"null",typeOf:"Void"})}}e.ExtendedTypeBuilder=R,e.StandardType=new E,e.Type=new R})(J);const Tpe=J.Type.Object({src:J.Type.String(),path:J.Type.Optional(J.Type.String()),volume:J.Type.Optional(J.Type.Number()),rate:J.Type.Optional(J.Type.Number()),html5:J.Type.Optional(J.Type.Boolean())}),Epe=J.Type.Record(J.Type.String(),Tpe),Ope=J.Type.Object({volume:J.Type.Optional(J.Type.Number()),defaultMusic:J.Type.Optional(J.Type.String()),musicFadeInTime:J.Type.Optional(J.Type.Number()),musicFadeOutTime:J.Type.Optional(J.Type.Number()),musicFadeInDelay:J.Type.Optional(J.Type.Number())}),Ape=J.Type.Record(J.Type.String(),J.Type.String()),o9=J.Type.Object({files:Epe,audioTriggers:Ape,options:Ope}),i9={files:{},audioTriggers:{},options:{volume:1,musicFadeInTime:.5,musicFadeInDelay:.5,musicFadeOutTime:.5}},Mpe=J.Type.Object({name:J.Type.String(),description:J.Type.String(),icon:J.Type.String(),onUse:J.Type.Optional(J.Type.Object({action:J.Type.String(),label:J.Type.String()})),tag:J.Type.Optional(J.Type.String()),category:J.Type.Optional(J.Type.String()),showIfEmpty:J.Type.Optional(J.Type.Boolean())}),a9=J.Type.Object({id:J.Type.String(),title:J.Type.String()}),s9=J.Type.Record(J.Type.String(),Mpe);J.Type.Object({categories:J.Type.Array(a9),items:s9});const l9=J.Type.Object({categories:J.Type.Optional(J.Type.Array(a9)),items:J.Type.Optional(s9)}),c9={categories:[{id:"default",title:"Items"}],items:{}},Ppe=J.Type.Object({description:J.Type.String(),hidden:J.Type.Optional(J.Type.Boolean())}),Npe=J.Type.Object({title:J.Type.String(),description:J.Type.String(),objectives:J.Type.Record(J.Type.String(),Ppe),category:J.Type.Optional(J.Type.String())}),Ipe=J.Type.Object({id:J.Type.String(),title:J.Type.String()}),Dpe=J.Type.Record(J.Type.String(),Npe),u9=J.Type.Object({quests:Dpe,categories:J.Type.Array(Ipe)}),f9={quests:{},categories:[{id:"default",title:"Quests"}]},d9=J.Type.Object({enabled:J.Type.Boolean(),background:J.Type.Optional(J.Type.String()),text:J.Type.Optional(J.Type.String()),cssClass:J.Type.Optional(J.Type.String()),position:J.Type.Object({left:J.Type.Number(),top:J.Type.Number(),width:J.Type.Optional(J.Type.Number()),height:J.Type.Optional(J.Type.Number())}),anchor:J.Type.Optional(J.Type.Object({x:J.Type.Number(),y:J.Type.Number()})),action:J.Type.Optional(J.Type.String()),actionType:J.Type.Optional(J.Type.String()),scriptClickable:J.Type.Optional(J.Type.Boolean()),tag:J.Type.Optional(J.Type.String())}),Rpe=J.Type.Record(J.Type.String(),d9),h9=J.Type.Object({buttons:Rpe,clickableDuringScriptsByDefault:J.Type.Optional(J.Type.Boolean())}),p9={buttons:{},clickableDuringScriptsByDefault:!1},Lpe=J.Type.Intersect([d9,J.Type.Object({id:J.Type.String()})]),Bpe=J.Type.Object({background:J.Type.String(),buttons:J.Type.Optional(J.Type.Array(J.Type.Union([J.Type.String(),Lpe])))}),m9=J.Type.Record(J.Type.String(),Bpe);J.Type.Object({screens:m9});const v9=J.Type.Object({screens:J.Type.Optional(m9)}),g9={screens:{}},Fpe=J.Type.Object({name:J.Type.String(),description:J.Type.String(),startingLevel:J.Type.Number(),hidden:J.Type.Optional(J.Type.Boolean()),icon:J.Type.String()}),y9=J.Type.Record(J.Type.String(),Fpe),b9=J.Type.Object({xpPerLevel:J.Type.Number(),notifyLevelUp:J.Type.Boolean()});J.Type.Object({skills:y9,skillOptions:b9});const w9=J.Type.Object({skills:J.Type.Optional(y9),skillOptions:J.Type.Optional(b9)}),k9={skills:{},skillOptions:{xpPerLevel:10,notifyLevelUp:!0}},Fg="###_--_~=:;_JUMP",Hx="###_--_~=:;_RETURN",Vpe="###_--_~=:;_OK",Vg="###_--_~=:;_STOP";function zpe(e){return e===Fg||e===Hx||e===Vpe||e===Vg}const Upe="3.2.12",qpe=new Date("2023-07-13T22:40:50.739Z"),Hpe=400,zg=20,Wx="@empty",x9={background:Wx},Wpe=J.Type.Object({color:J.Type.Optional(J.Type.String()),boxCss:J.Type.Optional(J.Type.Record(J.Type.String(),J.Type.Any())),nameCss:J.Type.Optional(J.Type.Record(J.Type.String(),J.Type.Any())),textCss:J.Type.Optional(J.Type.Record(J.Type.String(),J.Type.Any()))}),Kpe=J.Type.Object({sprites:J.Type.Optional(J.Type.Record(J.Type.String(),J.Type.String())),name:J.Type.String(),style:J.Type.Optional(Wpe)}),_9=J.Type.Object({config:J.Type.Object({imagesPath:J.Type.String(),playerCharacter:J.Type.Optional(J.Type.String()),gameCharacter:J.Type.Optional(J.Type.String())}),characters:J.Type.Record(J.Type.String(),Kpe)}),j9={config:{imagesPath:"",playerCharacter:"player",gameCharacter:"game"},characters:{}},Gpe=J.Type.Object({backgrounds:J.Type.Object({width:J.Type.Number(),height:J.Type.Number()}),dialogBottomPadding:J.Type.Union([J.Type.Number(),J.Type.String()]),minTextWidth:J.Type.Optional(J.Type.Number()),verticalLayoutThreshold:J.Type.Number(),defaultFontSize:J.Type.Optional(J.Type.Number()),portraits:J.Type.Object({width:J.Type.Number(),height:J.Type.Number(),offset:J.Type.Optional(J.Type.Object({landscape:J.Type.Optional(J.Type.Object({right:J.Type.Number(),bottom:J.Type.Number()})),portrait:J.Type.Optional(J.Type.Object({right:J.Type.Number(),bottom:J.Type.Number()}))}))})}),Jpe={backgrounds:{width:880,height:720},dialogBottomPadding:70,verticalLayoutThreshold:600,defaultFontSize:16,portraits:{width:100,height:100}},S9=J.Type.Object({options:J.Type.Object({delay:J.Type.Optional(J.Type.Number()),width:J.Type.Number(),keywordsPrefix:J.Type.String(),screenEdgesMinimumMargin:J.Type.Optional(J.Type.Number())}),tooltips:J.Type.Array(J.Type.Object({keywords:J.Type.Array(J.Type.String()),title:J.Type.String(),description:J.Type.String()}))}),C9={options:{delay:0,width:350,keywordsPrefix:"@@"},tooltips:[]},Qpe=J.Type.Object({name:J.Type.String(),description:J.Type.String(),icon:J.Type.String(),secret:J.Type.Optional(J.Type.Boolean()),category:J.Type.Optional(J.Type.String())}),$9=J.Type.Object({id:J.Type.String(),title:J.Type.String()}),T9=J.Type.Record(J.Type.String(),Qpe);J.Type.Object({defaultAchievementIcon:J.Type.String(),categories:J.Type.Array($9),achievements:T9,notifyNewAchievements:J.Type.Boolean(),secretAchievements:J.Type.Optional(J.Type.Object({censorDescription:J.Type.Optional(J.Type.Boolean()),censorName:J.Type.Optional(J.Type.Boolean()),hideUntilObtained:J.Type.Optional(J.Type.Boolean())}))});const Ype=J.Type.Object({categories:J.Type.Optional(J.Type.Array($9)),achievements:J.Type.Optional(T9)}),E9={categories:[{id:"default",title:"Achievements"}],achievements:{},notifyNewAchievements:!0,defaultAchievementIcon:"img/achievements/trophy.png"},Xpe=J.Type.Object({diceRange:J.Type.Tuple([J.Type.Number(),J.Type.Number()]),diceCount:J.Type.Number(),difficultyText:J.Type.Array(J.Type.Tuple([J.Type.Number(),J.Type.String()])),extraPointsPerLevel:J.Type.Number(),extraDicePerLevel:J.Type.Optional(J.Type.Number()),successOnRollsBelowThreshold:J.Type.Boolean(),showDifficultyText:J.Type.Boolean(),showDifficultyNumber:J.Type.Boolean(),showDifficultyWithoutModifiers:J.Type.Boolean(),finalRollIsHighest:J.Type.Optional(J.Type.Boolean()),finalRollIsLowest:J.Type.Optional(J.Type.Boolean()),failOnRollsEqualToThreshold:J.Type.Optional(J.Type.Boolean())}),Zpe=J.Type.Object({skill:J.Type.String(),difficulty:J.Type.Number(),winsNeeded:J.Type.Optional(J.Type.Number()),hideAfterRoll:J.Type.Optional(J.Type.Boolean()),repeatable:J.Type.Optional(J.Type.Boolean())}),O9=J.Type.Object({options:Xpe,skillChecks:J.Type.Record(J.Type.String(),Zpe)}),A9={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:{}},Qc={baseAssetsPath:"",baseDataPath:"",gameTitle:"Narrat Game",saveFileName:"narrat save",images:{},layout:Jpe,settings:{},gameFlow:{},dialogPanel:{overlayMode:!0,rightOffset:100,bottomOffset:50,width:475,height:680,textSpeed:zg,animateText:!0,timeBetweenLines:100},splashScreens:{},screens:g9,buttons:p9,skills:k9,skillChecks:A9,scripts:[],audio:i9,notifications:{timeOnScreen:2.5,alsoPrintInDialogue:!1},tooltips:C9,hudStats:{},achievements:E9,items:c9,interactionTags:{default:{onlyInteractOutsideOfScripts:!0}},quests:f9,transitions:{},menuButtons:{},debugging:{showScriptFinishedMessage:!1},saves:{mode:"manual",slots:10},characters:j9};var eme=function(t){return tme(t)&&!nme(t)};function tme(e){return!!e&&typeof e=="object"}function nme(e){var t=Object.prototype.toString.call(e);return t==="[object RegExp]"||t==="[object Date]"||ime(e)}var rme=typeof Symbol=="function"&&Symbol.for,ome=rme?Symbol.for("react.element"):60103;function ime(e){return e.$$typeof===ome}function ame(e){return Array.isArray(e)?[]:{}}function Fh(e,t){return t.clone!==!1&&t.isMergeableObject(e)?Nf(ame(e),e,t):e}function sme(e,t,n){return e.concat(t).map(function(r){return Fh(r,n)})}function lme(e,t){if(!t.customMerge)return Nf;var n=t.customMerge(e);return typeof n=="function"?n:Nf}function cme(e){return Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(e).filter(function(t){return Object.propertyIsEnumerable.call(e,t)}):[]}function M9(e){return Object.keys(e).concat(cme(e))}function P9(e,t){try{return t in e}catch{return!1}}function ume(e,t){return P9(e,t)&&!(Object.hasOwnProperty.call(e,t)&&Object.propertyIsEnumerable.call(e,t))}function fme(e,t,n){var r={};return n.isMergeableObject(e)&&M9(e).forEach(function(o){r[o]=Fh(e[o],n)}),M9(t).forEach(function(o){ume(e,o)||(P9(e,o)&&n.isMergeableObject(t[o])?r[o]=lme(o,n)(e[o],t[o],n):r[o]=Fh(t[o],n))}),r}function Nf(e,t,n){n=n||{},n.arrayMerge=n.arrayMerge||sme,n.isMergeableObject=n.isMergeableObject||eme,n.cloneUnlessOtherwiseSpecified=Fh;var r=Array.isArray(t),o=Array.isArray(e),i=r===o;return i?r?n.arrayMerge(e,t,n):fme(e,t,n):Fh(t,n)}Nf.all=function(t,n){if(!Array.isArray(t))throw new Error("first argument should be an array");return t.reduce(function(r,o){return Nf(r,o,n)},{})};var dme=Nf,hme=dme;const Vh=$_(hme),pi=ao("config",{state:()=>({config:Qc}),actions:{async setConfig(e){this.config=e},extendConfig(e){this.config=Vh(this.config,e)},generateSaveData(){return{playerCharacter:this.playerCharacter,gameCharacter:this.gameCharacter}},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 N9(e){const t=Dr(),n=t.getSkillCheck(e.id);if(n&&n.happened&&(n.succeeded||!e.repeatable))return n;const r=$pe(e);return R9(_pe(r,e)),r?t.passSkillCheck(e.id,e.hideAfterRoll):t.failSkillCheck(e.id,e.hideAfterRoll),t.getSkillCheck(e.id)}function pme(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 I9(e){return typeof e=="object"}function D9(e){return typeof e=="string"&&e.search(/\$/)===0}function R9(e){const t={speaker:pi().gameCharacter,text:e,interactive:!1};qn().addDialog(t)}async function Kx(e){qn().addDialog(e)}function mme(e,t){if(t<e.length)return e[t]}/*! js-yaml 4.1.0 https://github.com/nodeca/js-yaml @license MIT */function L9(e){return typeof e>"u"||e===null}function vme(e){return typeof e=="object"&&e!==null}function gme(e){return Array.isArray(e)?e:L9(e)?[]:[e]}function yme(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 bme(e,t){var n="",r;for(r=0;r<t;r+=1)n+=e;return n}function wme(e){return e===0&&Number.NEGATIVE_INFINITY===1/e}var kme=L9,xme=vme,_me=gme,jme=bme,Sme=wme,Cme=yme,so={isNothing:kme,isObject:xme,toArray:_me,repeat:jme,isNegativeZero:Sme,extend:Cme};function B9(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+=`
176
176
 
177
177
  `+e.mark.snippet),r+" "+n):r}function zh(e,t){Error.call(this),this.name="YAMLException",this.reason=e,this.mark=t,this.message=B9(this,!1),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack||""}zh.prototype=Object.create(Error.prototype),zh.prototype.constructor=zh,zh.prototype.toString=function(t){return this.name+": "+B9(this,t)};var Zo=zh;function Gx(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 so.repeat(" ",t-e.length)+e}function $me(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="",l,c,f=Math.min(e.line+t.linesAfter,o.length).toString().length,u=t.maxLength-(t.indent+f+3);for(l=1;l<=t.linesBefore&&!(a-l<0);l++)c=Gx(e.buffer,r[a-l],o[a-l],e.position-(r[a]-r[a-l]),u),s=so.repeat(" ",t.indent)+Jx((e.line-l+1).toString(),f)+" | "+c.str+`
178
178
  `+s;for(c=Gx(e.buffer,r[a],o[a],e.position,u),s+=so.repeat(" ",t.indent)+Jx((e.line+1).toString(),f)+" | "+c.str+`
@@ -215,7 +215,7 @@ This will fail in production.`);s=Ih,s._s.has(r)||(i?Fx(r,t,o,s):q7(r,o,s),proce
215
215
  || ${M} === "boolean" || ${E} === null`).assign(j,(0,o._)`[${E}]`)}}}function h({gen:w,parentData:k,parentDataProperty:$},x){w.if((0,o._)`${k} !== undefined`,()=>w.assign((0,o._)`${k}[${$}]`,x))}function p(w,k,$,x=a.Correct){const E=x===a.Correct?o.operators.EQ:o.operators.NEQ;let R;switch(w){case"null":return(0,o._)`${k} ${E} null`;case"array":R=(0,o._)`Array.isArray(${k})`;break;case"object":R=(0,o._)`${k} && typeof ${k} == "object" && !Array.isArray(${k})`;break;case"integer":R=M((0,o._)`!(${k} % 1) && !isNaN(${k})`);break;case"number":R=M();break;default:return(0,o._)`typeof ${k} ${E} ${w}`}return x===a.Correct?R:(0,o.not)(R);function M(j=o.nil){return(0,o.and)((0,o._)`typeof ${k} == "number"`,j,$?(0,o._)`isFinite(${k})`:o.nil)}}e.checkDataType=p;function m(w,k,$,x){if(w.length===1)return p(w[0],k,$,x);let E;const R=(0,i.toHash)(w);if(R.array&&R.object){const M=(0,o._)`typeof ${k} != "object"`;E=R.null?M:(0,o._)`!${k} || ${M}`,delete R.null,delete R.array,delete R.object}else E=o.nil;R.number&&delete R.integer;for(const M in R)E=(0,o.and)(E,p(M,k,$,x));return E}e.checkDataTypes=m;const v={message:({schema:w})=>`must be ${w}`,params:({schema:w,schemaValue:k})=>typeof w=="string"?(0,o._)`{type: ${w}}`:(0,o._)`{type: ${k}}`};function g(w){const k=y(w);(0,r.reportError)(k,v)}e.reportTypeError=g;function y(w){const{gen:k,data:$,schema:x}=w,E=(0,i.schemaRefOrVal)(w,x,"type");return{gen:k,keyword:"type",data:$,schema:x.type,schemaCode:E,schemaValue:E,parentSchema:x,params:{},it:w}}}(Qh);var Zg={};Object.defineProperty(Zg,"__esModule",{value:!0}),Zg.assignDefaults=void 0;const Vf=Dn,L0e=Jn;function B0e(e,t){const{properties:n,items:r}=e.schema;if(t==="object"&&n)for(const o in n)oF(e,o,n[o].default);else t==="array"&&Array.isArray(r)&&r.forEach((o,i)=>oF(e,i,o.default))}Zg.assignDefaults=B0e;function oF(e,t,n){const{gen:r,compositeRule:o,data:i,opts:a}=e;if(n===void 0)return;const s=(0,Vf._)`${i}${(0,Vf.getProperty)(t)}`;if(o){(0,L0e.checkStrictMode)(e,`default is ignored for: ${s}`);return}let l=(0,Vf._)`${s} === undefined`;a.useDefaults==="empty"&&(l=(0,Vf._)`${l} || ${s} === null || ${s} === ""`),r.if(l,(0,Vf._)`${s} = ${(0,Vf.stringify)(n)}`)}var Ss={},Rn={};Object.defineProperty(Rn,"__esModule",{value:!0}),Rn.validateUnion=Rn.validateArray=Rn.usePattern=Rn.callValidateCode=Rn.schemaProperties=Rn.allSchemaProperties=Rn.noPropertyInData=Rn.propertyInData=Rn.isOwnProperty=Rn.hasPropFunc=Rn.reportMissingProp=Rn.checkMissingProp=Rn.checkReportMissingProp=void 0;const kr=Dn,m2=Jn,Xl=js,F0e=Jn;function V0e(e,t){const{gen:n,data:r,it:o}=e;n.if(g2(n,r,t,o.opts.ownProperties),()=>{e.setParams({missingProperty:(0,kr._)`${t}`},!0),e.error()})}Rn.checkReportMissingProp=V0e;function z0e({gen:e,data:t,it:{opts:n}},r,o){return(0,kr.or)(...r.map(i=>(0,kr.and)(g2(e,t,i,n.ownProperties),(0,kr._)`${o} = ${i}`)))}Rn.checkMissingProp=z0e;function U0e(e,t){e.setParams({missingProperty:t},!0),e.error()}Rn.reportMissingProp=U0e;function iF(e){return e.scopeValue("func",{ref:Object.prototype.hasOwnProperty,code:(0,kr._)`Object.prototype.hasOwnProperty`})}Rn.hasPropFunc=iF;function v2(e,t,n){return(0,kr._)`${iF(e)}.call(${t}, ${n})`}Rn.isOwnProperty=v2;function q0e(e,t,n,r){const o=(0,kr._)`${t}${(0,kr.getProperty)(n)} !== undefined`;return r?(0,kr._)`${o} && ${v2(e,t,n)}`:o}Rn.propertyInData=q0e;function g2(e,t,n,r){const o=(0,kr._)`${t}${(0,kr.getProperty)(n)} === undefined`;return r?(0,kr.or)(o,(0,kr.not)(v2(e,t,n))):o}Rn.noPropertyInData=g2;function aF(e){return e?Object.keys(e).filter(t=>t!=="__proto__"):[]}Rn.allSchemaProperties=aF;function H0e(e,t){return aF(t).filter(n=>!(0,m2.alwaysValidSchema)(e,t[n]))}Rn.schemaProperties=H0e;function W0e({schemaCode:e,data:t,it:{gen:n,topSchemaRef:r,schemaPath:o,errorPath:i},it:a},s,l,c){const f=c?(0,kr._)`${e}, ${t}, ${r}${o}`:t,u=[[Xl.default.instancePath,(0,kr.strConcat)(Xl.default.instancePath,i)],[Xl.default.parentData,a.parentData],[Xl.default.parentDataProperty,a.parentDataProperty],[Xl.default.rootData,Xl.default.rootData]];a.opts.dynamicRef&&u.push([Xl.default.dynamicAnchors,Xl.default.dynamicAnchors]);const d=(0,kr._)`${f}, ${n.object(...u)}`;return l!==kr.nil?(0,kr._)`${s}.call(${l}, ${d})`:(0,kr._)`${s}(${d})`}Rn.callValidateCode=W0e;const K0e=(0,kr._)`new RegExp`;function G0e({gen:e,it:{opts:t}},n){const r=t.unicodeRegExp?"u":"",{regExp:o}=t.code,i=o(n,r);return e.scopeValue("pattern",{key:i.toString(),ref:i,code:(0,kr._)`${o.code==="new RegExp"?K0e:(0,F0e.useFunc)(e,o)}(${n}, ${r})`})}Rn.usePattern=G0e;function J0e(e){const{gen:t,data:n,keyword:r,it:o}=e,i=t.name("valid");if(o.allErrors){const s=t.let("valid",!0);return a(()=>t.assign(s,!1)),s}return t.var(i,!0),a(()=>t.break()),i;function a(s){const l=t.const("len",(0,kr._)`${n}.length`);t.forRange("i",0,l,c=>{e.subschema({keyword:r,dataProp:c,dataPropType:m2.Type.Num},i),t.if((0,kr.not)(i),s)})}}Rn.validateArray=J0e;function Q0e(e){const{gen:t,schema:n,keyword:r,it:o}=e;if(!Array.isArray(n))throw new Error("ajv implementation error");if(n.some(l=>(0,m2.alwaysValidSchema)(o,l))&&!o.opts.unevaluated)return;const a=t.let("valid",!1),s=t.name("_valid");t.block(()=>n.forEach((l,c)=>{const f=e.subschema({keyword:r,schemaProp:c,compositeRule:!0},s);t.assign(a,(0,kr._)`${a} || ${s}`),e.mergeValidEvaluated(f,s)||t.if((0,kr.not)(a))})),e.result(a,()=>e.reset(),()=>e.error(!0))}Rn.validateUnion=Q0e,Object.defineProperty(Ss,"__esModule",{value:!0}),Ss.validateKeywordUsage=Ss.validSchemaType=Ss.funcKeywordCode=Ss.macroKeywordCode=void 0;const ti=Dn,Zc=js,Y0e=Rn,X0e=Gh;function Z0e(e,t){const{gen:n,keyword:r,schema:o,parentSchema:i,it:a}=e,s=t.macro.call(a.self,o,i,a),l=lF(n,r,s);a.opts.validateSchema!==!1&&a.self.validateSchema(s,!0);const c=n.name("valid");e.subschema({schema:s,schemaPath:ti.nil,errSchemaPath:`${a.errSchemaPath}/${r}`,topSchemaRef:l,compositeRule:!0},c),e.pass(c,()=>e.error(!0))}Ss.macroKeywordCode=Z0e;function eye(e,t){var n;const{gen:r,keyword:o,schema:i,parentSchema:a,$data:s,it:l}=e;nye(l,t);const c=!s&&t.compile?t.compile.call(l.self,i,a,l):t.validate,f=lF(r,o,c),u=r.let("valid");e.block$data(u,d),e.ok((n=t.valid)!==null&&n!==void 0?n:u);function d(){if(t.errors===!1)m(),t.modifying&&sF(e),v(()=>e.error());else{const g=t.async?h():p();t.modifying&&sF(e),v(()=>tye(e,g))}}function h(){const g=r.let("ruleErrs",null);return r.try(()=>m((0,ti._)`await `),y=>r.assign(u,!1).if((0,ti._)`${y} instanceof ${l.ValidationError}`,()=>r.assign(g,(0,ti._)`${y}.errors`),()=>r.throw(y))),g}function p(){const g=(0,ti._)`${f}.errors`;return r.assign(g,null),m(ti.nil),g}function m(g=t.async?(0,ti._)`await `:ti.nil){const y=l.opts.passContext?Zc.default.this:Zc.default.self,w=!("compile"in t&&!s||t.schema===!1);r.assign(u,(0,ti._)`${g}${(0,Y0e.callValidateCode)(e,f,y,w)}`,t.modifying)}function v(g){var y;r.if((0,ti.not)((y=t.valid)!==null&&y!==void 0?y:u),g)}}Ss.funcKeywordCode=eye;function sF(e){const{gen:t,data:n,it:r}=e;t.if(r.parentData,()=>t.assign(n,(0,ti._)`${r.parentData}[${r.parentDataProperty}]`))}function tye(e,t){const{gen:n}=e;n.if((0,ti._)`Array.isArray(${t})`,()=>{n.assign(Zc.default.vErrors,(0,ti._)`${Zc.default.vErrors} === null ? ${t} : ${Zc.default.vErrors}.concat(${t})`).assign(Zc.default.errors,(0,ti._)`${Zc.default.vErrors}.length`),(0,X0e.extendErrors)(e)},()=>e.error())}function nye({schemaEnv:e},t){if(t.async&&!e.$async)throw new Error("async keyword in sync schema")}function lF(e,t,n){if(n===void 0)throw new Error(`keyword "${t}" failed to compile`);return e.scopeValue("keyword",typeof n=="function"?{ref:n}:{ref:n,code:(0,ti.stringify)(n)})}function rye(e,t,n=!1){return!t.length||t.some(r=>r==="array"?Array.isArray(e):r==="object"?e&&typeof e=="object"&&!Array.isArray(e):typeof e==r||n&&typeof e>"u")}Ss.validSchemaType=rye;function oye({schema:e,opts:t,self:n,errSchemaPath:r},o,i){if(Array.isArray(o.keyword)?!o.keyword.includes(i):o.keyword!==i)throw new Error("ajv implementation error");const a=o.dependencies;if(a!=null&&a.some(s=>!Object.prototype.hasOwnProperty.call(e,s)))throw new Error(`parent schema must have dependencies of ${i}: ${a.join(",")}`);if(o.validateSchema&&!o.validateSchema(e[i])){const l=`keyword "${i}" value is invalid at path "${r}": `+n.errorsText(o.validateSchema.errors);if(t.validateSchema==="log")n.logger.error(l);else throw new Error(l)}}Ss.validateKeywordUsage=oye;var Zl={};Object.defineProperty(Zl,"__esModule",{value:!0}),Zl.extendSubschemaMode=Zl.extendSubschemaData=Zl.getSubschema=void 0;const Cs=Dn,cF=Jn;function iye(e,{keyword:t,schemaProp:n,schema:r,schemaPath:o,errSchemaPath:i,topSchemaRef:a}){if(t!==void 0&&r!==void 0)throw new Error('both "keyword" and "schema" passed, only one allowed');if(t!==void 0){const s=e.schema[t];return n===void 0?{schema:s,schemaPath:(0,Cs._)`${e.schemaPath}${(0,Cs.getProperty)(t)}`,errSchemaPath:`${e.errSchemaPath}/${t}`}:{schema:s[n],schemaPath:(0,Cs._)`${e.schemaPath}${(0,Cs.getProperty)(t)}${(0,Cs.getProperty)(n)}`,errSchemaPath:`${e.errSchemaPath}/${t}/${(0,cF.escapeFragment)(n)}`}}if(r!==void 0){if(o===void 0||i===void 0||a===void 0)throw new Error('"schemaPath", "errSchemaPath" and "topSchemaRef" are required with "schema"');return{schema:r,schemaPath:o,topSchemaRef:a,errSchemaPath:i}}throw new Error('either "keyword" or "schema" must be passed')}Zl.getSubschema=iye;function aye(e,t,{dataProp:n,dataPropType:r,data:o,dataTypes:i,propertyName:a}){if(o!==void 0&&n!==void 0)throw new Error('both "data" and "dataProp" passed, only one allowed');const{gen:s}=t;if(n!==void 0){const{errorPath:c,dataPathArr:f,opts:u}=t,d=s.let("data",(0,Cs._)`${t.data}${(0,Cs.getProperty)(n)}`,!0);l(d),e.errorPath=(0,Cs.str)`${c}${(0,cF.getErrorPath)(n,r,u.jsPropertySyntax)}`,e.parentDataProperty=(0,Cs._)`${n}`,e.dataPathArr=[...f,e.parentDataProperty]}if(o!==void 0){const c=o instanceof Cs.Name?o:s.let("data",o,!0);l(c),a!==void 0&&(e.propertyName=a)}i&&(e.dataTypes=i);function l(c){e.data=c,e.dataLevel=t.dataLevel+1,e.dataTypes=[],t.definedProperties=new Set,e.parentData=t.data,e.dataNames=[...t.dataNames,c]}}Zl.extendSubschemaData=aye;function sye(e,{jtdDiscriminator:t,jtdMetadata:n,compositeRule:r,createErrors:o,allErrors:i}){r!==void 0&&(e.compositeRule=r),o!==void 0&&(e.createErrors=o),i!==void 0&&(e.allErrors=i),e.jtdDiscriminator=t,e.jtdMetadata=n}Zl.extendSubschemaMode=sye;var Oo={},uF=function e(t,n){if(t===n)return!0;if(t&&n&&typeof t=="object"&&typeof n=="object"){if(t.constructor!==n.constructor)return!1;var r,o,i;if(Array.isArray(t)){if(r=t.length,r!=n.length)return!1;for(o=r;o--!==0;)if(!e(t[o],n[o]))return!1;return!0}if(t.constructor===RegExp)return t.source===n.source&&t.flags===n.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===n.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===n.toString();if(i=Object.keys(t),r=i.length,r!==Object.keys(n).length)return!1;for(o=r;o--!==0;)if(!Object.prototype.hasOwnProperty.call(n,i[o]))return!1;for(o=r;o--!==0;){var a=i[o];if(!e(t[a],n[a]))return!1}return!0}return t!==t&&n!==n},fF={exports:{}},ec=fF.exports=function(e,t,n){typeof t=="function"&&(n=t,t={}),n=t.cb||n;var r=typeof n=="function"?n:n.pre||function(){},o=n.post||function(){};e0(t,r,o,e,"",e)};ec.keywords={additionalItems:!0,items:!0,contains:!0,additionalProperties:!0,propertyNames:!0,not:!0,if:!0,then:!0,else:!0},ec.arrayKeywords={items:!0,allOf:!0,anyOf:!0,oneOf:!0},ec.propsKeywords={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependencies:!0},ec.skipKeywords={default:!0,enum:!0,const:!0,required:!0,maximum:!0,minimum:!0,exclusiveMaximum:!0,exclusiveMinimum:!0,multipleOf:!0,maxLength:!0,minLength:!0,pattern:!0,format:!0,maxItems:!0,minItems:!0,uniqueItems:!0,maxProperties:!0,minProperties:!0};function e0(e,t,n,r,o,i,a,s,l,c){if(r&&typeof r=="object"&&!Array.isArray(r)){t(r,o,i,a,s,l,c);for(var f in r){var u=r[f];if(Array.isArray(u)){if(f in ec.arrayKeywords)for(var d=0;d<u.length;d++)e0(e,t,n,u[d],o+"/"+f+"/"+d,i,o,f,r,d)}else if(f in ec.propsKeywords){if(u&&typeof u=="object")for(var h in u)e0(e,t,n,u[h],o+"/"+f+"/"+lye(h),i,o,f,r,h)}else(f in ec.keywords||e.allKeys&&!(f in ec.skipKeywords))&&e0(e,t,n,u,o+"/"+f,i,o,f,r)}n(r,o,i,a,s,l,c)}}function lye(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}var cye=fF.exports;Object.defineProperty(Oo,"__esModule",{value:!0}),Oo.getSchemaRefs=Oo.resolveUrl=Oo.normalizeId=Oo._getFullPath=Oo.getFullPath=Oo.inlineRef=void 0;const uye=Jn,fye=uF,dye=cye,hye=new Set(["type","format","pattern","maxLength","minLength","maxProperties","minProperties","maxItems","minItems","maximum","minimum","uniqueItems","multipleOf","required","enum","const"]);function pye(e,t=!0){return typeof e=="boolean"?!0:t===!0?!y2(e):t?dF(e)<=t:!1}Oo.inlineRef=pye;const mye=new Set(["$ref","$recursiveRef","$recursiveAnchor","$dynamicRef","$dynamicAnchor"]);function y2(e){for(const t in e){if(mye.has(t))return!0;const n=e[t];if(Array.isArray(n)&&n.some(y2)||typeof n=="object"&&y2(n))return!0}return!1}function dF(e){let t=0;for(const n in e){if(n==="$ref")return 1/0;if(t++,!hye.has(n)&&(typeof e[n]=="object"&&(0,uye.eachItem)(e[n],r=>t+=dF(r)),t===1/0))return 1/0}return t}function hF(e,t="",n){n!==!1&&(t=zf(t));const r=e.parse(t);return pF(e,r)}Oo.getFullPath=hF;function pF(e,t){return e.serialize(t).split("#")[0]+"#"}Oo._getFullPath=pF;const vye=/#\/?$/;function zf(e){return e?e.replace(vye,""):""}Oo.normalizeId=zf;function gye(e,t,n){return n=zf(n),e.resolve(t,n)}Oo.resolveUrl=gye;const yye=/^[a-z_][-a-z0-9._]*$/i;function bye(e,t){if(typeof e=="boolean")return{};const{schemaId:n,uriResolver:r}=this.opts,o=zf(e[n]||t),i={"":o},a=hF(r,o,!1),s={},l=new Set;return dye(e,{allKeys:!0},(u,d,h,p)=>{if(p===void 0)return;const m=a+d;let v=i[p];typeof u[n]=="string"&&(v=g.call(this,u[n])),y.call(this,u.$anchor),y.call(this,u.$dynamicAnchor),i[d]=v;function g(w){const k=this.opts.uriResolver.resolve;if(w=zf(v?k(v,w):w),l.has(w))throw f(w);l.add(w);let $=this.refs[w];return typeof $=="string"&&($=this.refs[$]),typeof $=="object"?c(u,$.schema,w):w!==zf(m)&&(w[0]==="#"?(c(u,s[w],w),s[w]=u):this.refs[w]=m),w}function y(w){if(typeof w=="string"){if(!yye.test(w))throw new Error(`invalid anchor "${w}"`);g.call(this,`#${w}`)}}}),s;function c(u,d,h){if(d!==void 0&&!fye(u,d))throw f(h)}function f(u){return new Error(`reference "${u}" resolves to more than one schema`)}}Oo.getSchemaRefs=bye,Object.defineProperty(Ra,"__esModule",{value:!0}),Ra.getData=Ra.KeywordCxt=Ra.validateFunctionCode=void 0;const mF=Ff,vF=Qh,b2=tl,t0=Qh,wye=Zg,Yh=Ss,w2=Zl,Jt=Dn,fn=js,kye=Oo,nl=Jn,Xh=Gh;function xye(e){if(wF(e)&&(kF(e),bF(e))){Sye(e);return}gF(e,()=>(0,mF.topBoolOrEmptySchema)(e))}Ra.validateFunctionCode=xye;function gF({gen:e,validateName:t,schema:n,schemaEnv:r,opts:o},i){o.code.es5?e.func(t,(0,Jt._)`${fn.default.data}, ${fn.default.valCxt}`,r.$async,()=>{e.code((0,Jt._)`"use strict"; ${yF(n,o)}`),jye(e,o),e.code(i)}):e.func(t,(0,Jt._)`${fn.default.data}, ${_ye(o)}`,r.$async,()=>e.code(yF(n,o)).code(i))}function _ye(e){return(0,Jt._)`{${fn.default.instancePath}="", ${fn.default.parentData}, ${fn.default.parentDataProperty}, ${fn.default.rootData}=${fn.default.data}${e.dynamicRef?(0,Jt._)`, ${fn.default.dynamicAnchors}={}`:Jt.nil}}={}`}function jye(e,t){e.if(fn.default.valCxt,()=>{e.var(fn.default.instancePath,(0,Jt._)`${fn.default.valCxt}.${fn.default.instancePath}`),e.var(fn.default.parentData,(0,Jt._)`${fn.default.valCxt}.${fn.default.parentData}`),e.var(fn.default.parentDataProperty,(0,Jt._)`${fn.default.valCxt}.${fn.default.parentDataProperty}`),e.var(fn.default.rootData,(0,Jt._)`${fn.default.valCxt}.${fn.default.rootData}`),t.dynamicRef&&e.var(fn.default.dynamicAnchors,(0,Jt._)`${fn.default.valCxt}.${fn.default.dynamicAnchors}`)},()=>{e.var(fn.default.instancePath,(0,Jt._)`""`),e.var(fn.default.parentData,(0,Jt._)`undefined`),e.var(fn.default.parentDataProperty,(0,Jt._)`undefined`),e.var(fn.default.rootData,fn.default.data),t.dynamicRef&&e.var(fn.default.dynamicAnchors,(0,Jt._)`{}`)})}function Sye(e){const{schema:t,opts:n,gen:r}=e;gF(e,()=>{n.$comment&&t.$comment&&_F(e),Oye(e),r.let(fn.default.vErrors,null),r.let(fn.default.errors,0),n.unevaluated&&Cye(e),xF(e),Pye(e)})}function Cye(e){const{gen:t,validateName:n}=e;e.evaluated=t.const("evaluated",(0,Jt._)`${n}.evaluated`),t.if((0,Jt._)`${e.evaluated}.dynamicProps`,()=>t.assign((0,Jt._)`${e.evaluated}.props`,(0,Jt._)`undefined`)),t.if((0,Jt._)`${e.evaluated}.dynamicItems`,()=>t.assign((0,Jt._)`${e.evaluated}.items`,(0,Jt._)`undefined`))}function yF(e,t){const n=typeof e=="object"&&e[t.schemaId];return n&&(t.code.source||t.code.process)?(0,Jt._)`/*# sourceURL=${n} */`:Jt.nil}function $ye(e,t){if(wF(e)&&(kF(e),bF(e))){Tye(e,t);return}(0,mF.boolOrEmptySchema)(e,t)}function bF({schema:e,self:t}){if(typeof e=="boolean")return!e;for(const n in e)if(t.RULES.all[n])return!0;return!1}function wF(e){return typeof e.schema!="boolean"}function Tye(e,t){const{schema:n,gen:r,opts:o}=e;o.$comment&&n.$comment&&_F(e),Aye(e),Mye(e);const i=r.const("_errs",fn.default.errors);xF(e,i),r.var(t,(0,Jt._)`${i} === ${fn.default.errors}`)}function kF(e){(0,nl.checkUnknownRules)(e),Eye(e)}function xF(e,t){if(e.opts.jtd)return jF(e,[],!1,t);const n=(0,vF.getSchemaTypes)(e.schema),r=(0,vF.coerceAndCheckDataType)(e,n);jF(e,n,!r,t)}function Eye(e){const{schema:t,errSchemaPath:n,opts:r,self:o}=e;t.$ref&&r.ignoreKeywordsWithRef&&(0,nl.schemaHasRulesButRef)(t,o.RULES)&&o.logger.warn(`$ref: keywords ignored in schema at path "${n}"`)}function Oye(e){const{schema:t,opts:n}=e;t.default!==void 0&&n.useDefaults&&n.strictSchema&&(0,nl.checkStrictMode)(e,"default is ignored in the schema root")}function Aye(e){const t=e.schema[e.opts.schemaId];t&&(e.baseId=(0,kye.resolveUrl)(e.opts.uriResolver,e.baseId,t))}function Mye(e){if(e.schema.$async&&!e.schemaEnv.$async)throw new Error("async schema in sync schema")}function _F({gen:e,schemaEnv:t,schema:n,errSchemaPath:r,opts:o}){const i=n.$comment;if(o.$comment===!0)e.code((0,Jt._)`${fn.default.self}.logger.log(${i})`);else if(typeof o.$comment=="function"){const a=(0,Jt.str)`${r}/$comment`,s=e.scopeValue("root",{ref:t.root});e.code((0,Jt._)`${fn.default.self}.opts.$comment(${i}, ${a}, ${s}.schema)`)}}function Pye(e){const{gen:t,schemaEnv:n,validateName:r,ValidationError:o,opts:i}=e;n.$async?t.if((0,Jt._)`${fn.default.errors} === 0`,()=>t.return(fn.default.data),()=>t.throw((0,Jt._)`new ${o}(${fn.default.vErrors})`)):(t.assign((0,Jt._)`${r}.errors`,fn.default.vErrors),i.unevaluated&&Nye(e),t.return((0,Jt._)`${fn.default.errors} === 0`))}function Nye({gen:e,evaluated:t,props:n,items:r}){n instanceof Jt.Name&&e.assign((0,Jt._)`${t}.props`,n),r instanceof Jt.Name&&e.assign((0,Jt._)`${t}.items`,r)}function jF(e,t,n,r){const{gen:o,schema:i,data:a,allErrors:s,opts:l,self:c}=e,{RULES:f}=c;if(i.$ref&&(l.ignoreKeywordsWithRef||!(0,nl.schemaHasRulesButRef)(i,f))){o.block(()=>TF(e,"$ref",f.all.$ref.definition));return}l.jtd||Iye(e,t),o.block(()=>{for(const d of f.rules)u(d);u(f.post)});function u(d){(0,b2.shouldUseGroup)(i,d)&&(d.type?(o.if((0,t0.checkDataType)(d.type,a,l.strictNumbers)),SF(e,d),t.length===1&&t[0]===d.type&&n&&(o.else(),(0,t0.reportTypeError)(e)),o.endIf()):SF(e,d),s||o.if((0,Jt._)`${fn.default.errors} === ${r||0}`))}}function SF(e,t){const{gen:n,schema:r,opts:{useDefaults:o}}=e;o&&(0,wye.assignDefaults)(e,t.type),n.block(()=>{for(const i of t.rules)(0,b2.shouldUseRule)(r,i)&&TF(e,i.keyword,i.definition,t.type)})}function Iye(e,t){e.schemaEnv.meta||!e.opts.strictTypes||(Dye(e,t),e.opts.allowUnionTypes||Rye(e,t),Lye(e,e.dataTypes))}function Dye(e,t){if(t.length){if(!e.dataTypes.length){e.dataTypes=t;return}t.forEach(n=>{CF(e.dataTypes,n)||k2(e,`type "${n}" not allowed by context "${e.dataTypes.join(",")}"`)}),Fye(e,t)}}function Rye(e,t){t.length>1&&!(t.length===2&&t.includes("null"))&&k2(e,"use allowUnionTypes to allow union type keyword")}function Lye(e,t){const n=e.self.RULES.all;for(const r in n){const o=n[r];if(typeof o=="object"&&(0,b2.shouldUseRule)(e.schema,o)){const{type:i}=o.definition;i.length&&!i.some(a=>Bye(t,a))&&k2(e,`missing type "${i.join(",")}" for keyword "${r}"`)}}}function Bye(e,t){return e.includes(t)||t==="number"&&e.includes("integer")}function CF(e,t){return e.includes(t)||t==="integer"&&e.includes("number")}function Fye(e,t){const n=[];for(const r of e.dataTypes)CF(t,r)?n.push(r):t.includes("integer")&&r==="number"&&n.push("integer");e.dataTypes=n}function k2(e,t){const n=e.schemaEnv.baseId+e.errSchemaPath;t+=` at "${n}" (strictTypes)`,(0,nl.checkStrictMode)(e,t,e.opts.strictTypes)}class $F{constructor(t,n,r){if((0,Yh.validateKeywordUsage)(t,n,r),this.gen=t.gen,this.allErrors=t.allErrors,this.keyword=r,this.data=t.data,this.schema=t.schema[r],this.$data=n.$data&&t.opts.$data&&this.schema&&this.schema.$data,this.schemaValue=(0,nl.schemaRefOrVal)(t,this.schema,r,this.$data),this.schemaType=n.schemaType,this.parentSchema=t.schema,this.params={},this.it=t,this.def=n,this.$data)this.schemaCode=t.gen.const("vSchema",EF(this.$data,t));else if(this.schemaCode=this.schemaValue,!(0,Yh.validSchemaType)(this.schema,n.schemaType,n.allowUndefined))throw new Error(`${r} value must be ${JSON.stringify(n.schemaType)}`);("code"in n?n.trackErrors:n.errors!==!1)&&(this.errsCount=t.gen.const("_errs",fn.default.errors))}result(t,n,r){this.failResult((0,Jt.not)(t),n,r)}failResult(t,n,r){this.gen.if(t),r?r():this.error(),n?(this.gen.else(),n(),this.allErrors&&this.gen.endIf()):this.allErrors?this.gen.endIf():this.gen.else()}pass(t,n){this.failResult((0,Jt.not)(t),void 0,n)}fail(t){if(t===void 0){this.error(),this.allErrors||this.gen.if(!1);return}this.gen.if(t),this.error(),this.allErrors?this.gen.endIf():this.gen.else()}fail$data(t){if(!this.$data)return this.fail(t);const{schemaCode:n}=this;this.fail((0,Jt._)`${n} !== undefined && (${(0,Jt.or)(this.invalid$data(),t)})`)}error(t,n,r){if(n){this.setParams(n),this._error(t,r),this.setParams({});return}this._error(t,r)}_error(t,n){(t?Xh.reportExtraError:Xh.reportError)(this,this.def.error,n)}$dataError(){(0,Xh.reportError)(this,this.def.$dataError||Xh.keyword$DataError)}reset(){if(this.errsCount===void 0)throw new Error('add "trackErrors" to keyword definition');(0,Xh.resetErrorsCount)(this.gen,this.errsCount)}ok(t){this.allErrors||this.gen.if(t)}setParams(t,n){n?Object.assign(this.params,t):this.params=t}block$data(t,n,r=Jt.nil){this.gen.block(()=>{this.check$data(t,r),n()})}check$data(t=Jt.nil,n=Jt.nil){if(!this.$data)return;const{gen:r,schemaCode:o,schemaType:i,def:a}=this;r.if((0,Jt.or)((0,Jt._)`${o} === undefined`,n)),t!==Jt.nil&&r.assign(t,!0),(i.length||a.validateSchema)&&(r.elseIf(this.invalid$data()),this.$dataError(),t!==Jt.nil&&r.assign(t,!1)),r.else()}invalid$data(){const{gen:t,schemaCode:n,schemaType:r,def:o,it:i}=this;return(0,Jt.or)(a(),s());function a(){if(r.length){if(!(n instanceof Jt.Name))throw new Error("ajv implementation error");const l=Array.isArray(r)?r:[r];return(0,Jt._)`${(0,t0.checkDataTypes)(l,n,i.opts.strictNumbers,t0.DataType.Wrong)}`}return Jt.nil}function s(){if(o.validateSchema){const l=t.scopeValue("validate$data",{ref:o.validateSchema});return(0,Jt._)`!${l}(${n})`}return Jt.nil}}subschema(t,n){const r=(0,w2.getSubschema)(this.it,t);(0,w2.extendSubschemaData)(r,this.it,t),(0,w2.extendSubschemaMode)(r,t);const o={...this.it,...r,items:void 0,props:void 0};return $ye(o,n),o}mergeEvaluated(t,n){const{it:r,gen:o}=this;r.opts.unevaluated&&(r.props!==!0&&t.props!==void 0&&(r.props=nl.mergeEvaluated.props(o,t.props,r.props,n)),r.items!==!0&&t.items!==void 0&&(r.items=nl.mergeEvaluated.items(o,t.items,r.items,n)))}mergeValidEvaluated(t,n){const{it:r,gen:o}=this;if(r.opts.unevaluated&&(r.props!==!0||r.items!==!0))return o.if(n,()=>this.mergeEvaluated(t,Jt.Name)),!0}}Ra.KeywordCxt=$F;function TF(e,t,n,r){const o=new $F(e,n,t);"code"in n?n.code(o,r):o.$data&&n.validate?(0,Yh.funcKeywordCode)(o,n):"macro"in n?(0,Yh.macroKeywordCode)(o,n):(n.compile||n.validate)&&(0,Yh.funcKeywordCode)(o,n)}const Vye=/^\/(?:[^~]|~0|~1)*$/,zye=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function EF(e,{dataLevel:t,dataNames:n,dataPathArr:r}){let o,i;if(e==="")return fn.default.rootData;if(e[0]==="/"){if(!Vye.test(e))throw new Error(`Invalid JSON-pointer: ${e}`);o=e,i=fn.default.rootData}else{const c=zye.exec(e);if(!c)throw new Error(`Invalid JSON-pointer: ${e}`);const f=+c[1];if(o=c[2],o==="#"){if(f>=t)throw new Error(l("property/index",f));return r[t-f]}if(f>t)throw new Error(l("data",f));if(i=n[t-f],!o)return i}let a=i;const s=o.split("/");for(const c of s)c&&(i=(0,Jt._)`${i}${(0,Jt.getProperty)((0,nl.unescapeJsonPointer)(c))}`,a=(0,Jt._)`${a} && ${i}`);return a;function l(c,f){return`Cannot access ${c} ${f} levels up, current level is ${t}`}}Ra.getData=EF;var Zh={};Object.defineProperty(Zh,"__esModule",{value:!0});class Uye extends Error{constructor(t){super("validation failed"),this.errors=t,this.ajv=this.validation=!0}}Zh.default=Uye;var ep={};Object.defineProperty(ep,"__esModule",{value:!0});const x2=Oo;class qye extends Error{constructor(t,n,r,o){super(o||`can't resolve reference ${r} from id ${n}`),this.missingRef=(0,x2.resolveUrl)(t,n,r),this.missingSchema=(0,x2.normalizeId)((0,x2.getFullPath)(t,this.missingRef))}}ep.default=qye;var yi={};Object.defineProperty(yi,"__esModule",{value:!0}),yi.resolveSchema=yi.getCompilingSchema=yi.resolveRef=yi.compileSchema=yi.SchemaEnv=void 0;const La=Dn,Hye=Zh,eu=js,Ba=Oo,OF=Jn,Wye=Ra;class n0{constructor(t){var n;this.refs={},this.dynamicAnchors={};let r;typeof t.schema=="object"&&(r=t.schema),this.schema=t.schema,this.schemaId=t.schemaId,this.root=t.root||this,this.baseId=(n=t.baseId)!==null&&n!==void 0?n:(0,Ba.normalizeId)(r==null?void 0:r[t.schemaId||"$id"]),this.schemaPath=t.schemaPath,this.localRefs=t.localRefs,this.meta=t.meta,this.$async=r==null?void 0:r.$async,this.refs={}}}yi.SchemaEnv=n0;function _2(e){const t=AF.call(this,e);if(t)return t;const n=(0,Ba.getFullPath)(this.opts.uriResolver,e.root.baseId),{es5:r,lines:o}=this.opts.code,{ownProperties:i}=this.opts,a=new La.CodeGen(this.scope,{es5:r,lines:o,ownProperties:i});let s;e.$async&&(s=a.scopeValue("Error",{ref:Hye.default,code:(0,La._)`require("ajv/dist/runtime/validation_error").default`}));const l=a.scopeName("validate");e.validateName=l;const c={gen:a,allErrors:this.opts.allErrors,data:eu.default.data,parentData:eu.default.parentData,parentDataProperty:eu.default.parentDataProperty,dataNames:[eu.default.data],dataPathArr:[La.nil],dataLevel:0,dataTypes:[],definedProperties:new Set,topSchemaRef:a.scopeValue("schema",this.opts.code.source===!0?{ref:e.schema,code:(0,La.stringify)(e.schema)}:{ref:e.schema}),validateName:l,ValidationError:s,schema:e.schema,schemaEnv:e,rootId:n,baseId:e.baseId||n,schemaPath:La.nil,errSchemaPath:e.schemaPath||(this.opts.jtd?"":"#"),errorPath:(0,La._)`""`,opts:this.opts,self:this};let f;try{this._compilations.add(e),(0,Wye.validateFunctionCode)(c),a.optimize(this.opts.code.optimize);const u=a.toString();f=`${a.scopeRefs(eu.default.scope)}return ${u}`,this.opts.code.process&&(f=this.opts.code.process(f,e));const h=new Function(`${eu.default.self}`,`${eu.default.scope}`,f)(this,this.scope.get());if(this.scope.value(l,{ref:h}),h.errors=null,h.schema=e.schema,h.schemaEnv=e,e.$async&&(h.$async=!0),this.opts.code.source===!0&&(h.source={validateName:l,validateCode:u,scopeValues:a._values}),this.opts.unevaluated){const{props:p,items:m}=c;h.evaluated={props:p instanceof La.Name?void 0:p,items:m instanceof La.Name?void 0:m,dynamicProps:p instanceof La.Name,dynamicItems:m instanceof La.Name},h.source&&(h.source.evaluated=(0,La.stringify)(h.evaluated))}return e.validate=h,e}catch(u){throw delete e.validate,delete e.validateName,f&&this.logger.error("Error compiling schema, function code:",f),u}finally{this._compilations.delete(e)}}yi.compileSchema=_2;function Kye(e,t,n){var r;n=(0,Ba.resolveUrl)(this.opts.uriResolver,t,n);const o=e.refs[n];if(o)return o;let i=Qye.call(this,e,n);if(i===void 0){const a=(r=e.localRefs)===null||r===void 0?void 0:r[n],{schemaId:s}=this.opts;a&&(i=new n0({schema:a,schemaId:s,root:e,baseId:t}))}if(i!==void 0)return e.refs[n]=Gye.call(this,i)}yi.resolveRef=Kye;function Gye(e){return(0,Ba.inlineRef)(e.schema,this.opts.inlineRefs)?e.schema:e.validate?e:_2.call(this,e)}function AF(e){for(const t of this._compilations)if(Jye(t,e))return t}yi.getCompilingSchema=AF;function Jye(e,t){return e.schema===t.schema&&e.root===t.root&&e.baseId===t.baseId}function Qye(e,t){let n;for(;typeof(n=this.refs[t])=="string";)t=n;return n||this.schemas[t]||r0.call(this,e,t)}function r0(e,t){const n=this.opts.uriResolver.parse(t),r=(0,Ba._getFullPath)(this.opts.uriResolver,n);let o=(0,Ba.getFullPath)(this.opts.uriResolver,e.baseId,void 0);if(Object.keys(e.schema).length>0&&r===o)return j2.call(this,n,e);const i=(0,Ba.normalizeId)(r),a=this.refs[i]||this.schemas[i];if(typeof a=="string"){const s=r0.call(this,e,a);return typeof(s==null?void 0:s.schema)!="object"?void 0:j2.call(this,n,s)}if(typeof(a==null?void 0:a.schema)=="object"){if(a.validate||_2.call(this,a),i===(0,Ba.normalizeId)(t)){const{schema:s}=a,{schemaId:l}=this.opts,c=s[l];return c&&(o=(0,Ba.resolveUrl)(this.opts.uriResolver,o,c)),new n0({schema:s,schemaId:l,root:e,baseId:o})}return j2.call(this,n,a)}}yi.resolveSchema=r0;const Yye=new Set(["properties","patternProperties","enum","dependencies","definitions"]);function j2(e,{baseId:t,schema:n,root:r}){var o;if(((o=e.fragment)===null||o===void 0?void 0:o[0])!=="/")return;for(const s of e.fragment.slice(1).split("/")){if(typeof n=="boolean")return;const l=n[(0,OF.unescapeFragment)(s)];if(l===void 0)return;n=l;const c=typeof n=="object"&&n[this.opts.schemaId];!Yye.has(s)&&c&&(t=(0,Ba.resolveUrl)(this.opts.uriResolver,t,c))}let i;if(typeof n!="boolean"&&n.$ref&&!(0,OF.schemaHasRulesButRef)(n,this.RULES)){const s=(0,Ba.resolveUrl)(this.opts.uriResolver,t,n.$ref);i=r0.call(this,r,s)}const{schemaId:a}=this.opts;if(i=i||new n0({schema:n,schemaId:a,root:r,baseId:t}),i.schema!==i.root.schema)return i}const Xye={$id:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#",description:"Meta-schema for $data reference (JSON AnySchema extension proposal)",type:"object",required:["$data"],properties:{$data:{type:"string",anyOf:[{format:"relative-json-pointer"},{format:"json-pointer"}]}},additionalProperties:!1};var S2={},C2={exports:{}};/** @license URI.js v4.4.1 (c) 2011 Gary Court. License: http://github.com/garycourt/uri-js */(function(e,t){(function(n,r){r(t)})(Wo,function(n){function r(){for(var _=arguments.length,G=Array(_),le=0;le<_;le++)G[le]=arguments[le];if(G.length>1){G[0]=G[0].slice(0,-1);for(var xe=G.length-1,$e=1;$e<xe;++$e)G[$e]=G[$e].slice(1,-1);return G[xe]=G[xe].slice(1),G.join("")}else return G[0]}function o(_){return"(?:"+_+")"}function i(_){return _===void 0?"undefined":_===null?"null":Object.prototype.toString.call(_).split(" ").pop().split("]").shift().toLowerCase()}function a(_){return _.toUpperCase()}function s(_){return _!=null?_ instanceof Array?_:typeof _.length!="number"||_.split||_.setInterval||_.call?[_]:Array.prototype.slice.call(_):[]}function l(_,G){var le=_;if(G)for(var xe in G)le[xe]=G[xe];return le}function c(_){var G="[A-Za-z]",le="[0-9]",xe=r(le,"[A-Fa-f]"),$e=o(o("%[EFef]"+xe+"%"+xe+xe+"%"+xe+xe)+"|"+o("%[89A-Fa-f]"+xe+"%"+xe+xe)+"|"+o("%"+xe+xe)),rt="[\\:\\/\\?\\#\\[\\]\\@]",pt="[\\!\\$\\&\\'\\(\\)\\*\\+\\,\\;\\=]",Rt=r(rt,pt),xt=_?"[\\xA0-\\u200D\\u2010-\\u2029\\u202F-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF]":"[]",Ht=_?"[\\uE000-\\uF8FF]":"[]",ae=r(G,le,"[\\-\\.\\_\\~]",xt);o(G+r(G,le,"[\\+\\-\\.]")+"*"),o(o($e+"|"+r(ae,pt,"[\\:]"))+"*");var Pe=o(o("25[0-5]")+"|"+o("2[0-4]"+le)+"|"+o("1"+le+le)+"|"+o("0?[1-9]"+le)+"|0?0?"+le),Ke=o(Pe+"\\."+Pe+"\\."+Pe+"\\."+Pe),Ge=o(xe+"{1,4}"),it=o(o(Ge+"\\:"+Ge)+"|"+Ke),Et=o(o(Ge+"\\:")+"{6}"+it),It=o("\\:\\:"+o(Ge+"\\:")+"{5}"+it),$t=o(o(Ge)+"?\\:\\:"+o(Ge+"\\:")+"{4}"+it),jt=o(o(o(Ge+"\\:")+"{0,1}"+Ge)+"?\\:\\:"+o(Ge+"\\:")+"{3}"+it),Tt=o(o(o(Ge+"\\:")+"{0,2}"+Ge)+"?\\:\\:"+o(Ge+"\\:")+"{2}"+it),Sn=o(o(o(Ge+"\\:")+"{0,3}"+Ge)+"?\\:\\:"+Ge+"\\:"+it),kn=o(o(o(Ge+"\\:")+"{0,4}"+Ge)+"?\\:\\:"+it),Hn=o(o(o(Ge+"\\:")+"{0,5}"+Ge)+"?\\:\\:"+Ge),Lr=o(o(o(Ge+"\\:")+"{0,6}"+Ge)+"?\\:\\:"),ni=o([Et,It,$t,jt,Tt,Sn,kn,Hn,Lr].join("|")),co=o(o(ae+"|"+$e)+"+");o("[vV]"+xe+"+\\."+r(ae,pt,"[\\:]")+"+"),o(o($e+"|"+r(ae,pt))+"*");var Kr=o($e+"|"+r(ae,pt,"[\\:\\@]"));return o(o($e+"|"+r(ae,pt,"[\\@]"))+"+"),o(o(Kr+"|"+r("[\\/\\?]",Ht))+"*"),{NOT_SCHEME:new RegExp(r("[^]",G,le,"[\\+\\-\\.]"),"g"),NOT_USERINFO:new RegExp(r("[^\\%\\:]",ae,pt),"g"),NOT_HOST:new RegExp(r("[^\\%\\[\\]\\:]",ae,pt),"g"),NOT_PATH:new RegExp(r("[^\\%\\/\\:\\@]",ae,pt),"g"),NOT_PATH_NOSCHEME:new RegExp(r("[^\\%\\/\\@]",ae,pt),"g"),NOT_QUERY:new RegExp(r("[^\\%]",ae,pt,"[\\:\\@\\/\\?]",Ht),"g"),NOT_FRAGMENT:new RegExp(r("[^\\%]",ae,pt,"[\\:\\@\\/\\?]"),"g"),ESCAPE:new RegExp(r("[^]",ae,pt),"g"),UNRESERVED:new RegExp(ae,"g"),OTHER_CHARS:new RegExp(r("[^\\%]",ae,Rt),"g"),PCT_ENCODED:new RegExp($e,"g"),IPV4ADDRESS:new RegExp("^("+Ke+")$"),IPV6ADDRESS:new RegExp("^\\[?("+ni+")"+o(o("\\%25|\\%(?!"+xe+"{2})")+"("+co+")")+"?\\]?$")}}var f=c(!1),u=c(!0),d=function(){function _(G,le){var xe=[],$e=!0,rt=!1,pt=void 0;try{for(var Rt=G[Symbol.iterator](),xt;!($e=(xt=Rt.next()).done)&&(xe.push(xt.value),!(le&&xe.length===le));$e=!0);}catch(Ht){rt=!0,pt=Ht}finally{try{!$e&&Rt.return&&Rt.return()}finally{if(rt)throw pt}}return xe}return function(G,le){if(Array.isArray(G))return G;if(Symbol.iterator in Object(G))return _(G,le);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),h=function(_){if(Array.isArray(_)){for(var G=0,le=Array(_.length);G<_.length;G++)le[G]=_[G];return le}else return Array.from(_)},p=2147483647,m=36,v=1,g=26,y=38,w=700,k=72,$=128,x="-",E=/^xn--/,R=/[^\0-\x7E]/,M=/[\x2E\u3002\uFF0E\uFF61]/g,j={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},C=m-v,O=Math.floor,F=String.fromCharCode;function T(_){throw new RangeError(j[_])}function L(_,G){for(var le=[],xe=_.length;xe--;)le[xe]=G(_[xe]);return le}function H(_,G){var le=_.split("@"),xe="";le.length>1&&(xe=le[0]+"@",_=le[1]),_=_.replace(M,".");var $e=_.split("."),rt=L($e,G).join(".");return xe+rt}function z(_){for(var G=[],le=0,xe=_.length;le<xe;){var $e=_.charCodeAt(le++);if($e>=55296&&$e<=56319&&le<xe){var rt=_.charCodeAt(le++);(rt&64512)==56320?G.push((($e&1023)<<10)+(rt&1023)+65536):(G.push($e),le--)}else G.push($e)}return G}var V=function(G){return String.fromCodePoint.apply(String,h(G))},I=function(G){return G-48<10?G-22:G-65<26?G-65:G-97<26?G-97:m},P=function(G,le){return G+22+75*(G<26)-((le!=0)<<5)},N=function(G,le,xe){var $e=0;for(G=xe?O(G/w):G>>1,G+=O(G/le);G>C*g>>1;$e+=m)G=O(G/C);return O($e+(C+1)*G/(G+y))},D=function(G){var le=[],xe=G.length,$e=0,rt=$,pt=k,Rt=G.lastIndexOf(x);Rt<0&&(Rt=0);for(var xt=0;xt<Rt;++xt)G.charCodeAt(xt)>=128&&T("not-basic"),le.push(G.charCodeAt(xt));for(var Ht=Rt>0?Rt+1:0;Ht<xe;){for(var ae=$e,Pe=1,Ke=m;;Ke+=m){Ht>=xe&&T("invalid-input");var Ge=I(G.charCodeAt(Ht++));(Ge>=m||Ge>O((p-$e)/Pe))&&T("overflow"),$e+=Ge*Pe;var it=Ke<=pt?v:Ke>=pt+g?g:Ke-pt;if(Ge<it)break;var Et=m-it;Pe>O(p/Et)&&T("overflow"),Pe*=Et}var It=le.length+1;pt=N($e-ae,It,ae==0),O($e/It)>p-rt&&T("overflow"),rt+=O($e/It),$e%=It,le.splice($e++,0,rt)}return String.fromCodePoint.apply(String,le)},S=function(G){var le=[];G=z(G);var xe=G.length,$e=$,rt=0,pt=k,Rt=!0,xt=!1,Ht=void 0;try{for(var ae=G[Symbol.iterator](),Pe;!(Rt=(Pe=ae.next()).done);Rt=!0){var Ke=Pe.value;Ke<128&&le.push(F(Ke))}}catch(Te){xt=!0,Ht=Te}finally{try{!Rt&&ae.return&&ae.return()}finally{if(xt)throw Ht}}var Ge=le.length,it=Ge;for(Ge&&le.push(x);it<xe;){var Et=p,It=!0,$t=!1,jt=void 0;try{for(var Tt=G[Symbol.iterator](),Sn;!(It=(Sn=Tt.next()).done);It=!0){var kn=Sn.value;kn>=$e&&kn<Et&&(Et=kn)}}catch(Te){$t=!0,jt=Te}finally{try{!It&&Tt.return&&Tt.return()}finally{if($t)throw jt}}var Hn=it+1;Et-$e>O((p-rt)/Hn)&&T("overflow"),rt+=(Et-$e)*Hn,$e=Et;var Lr=!0,ni=!1,co=void 0;try{for(var Kr=G[Symbol.iterator](),Uo;!(Lr=(Uo=Kr.next()).done);Lr=!0){var ia=Uo.value;if(ia<$e&&++rt>p&&T("overflow"),ia==$e){for(var fr=rt,qo=m;;qo+=m){var Ho=qo<=pt?v:qo>=pt+g?g:qo-pt;if(fr<Ho)break;var au=fr-Ho,se=m-Ho;le.push(F(P(Ho+au%se,0))),fr=O(au/se)}le.push(F(P(fr,0))),pt=N(rt,Hn,it==Ge),rt=0,++it}}}catch(Te){ni=!0,co=Te}finally{try{!Lr&&Kr.return&&Kr.return()}finally{if(ni)throw co}}++rt,++$e}return le.join("")},A=function(G){return H(G,function(le){return E.test(le)?D(le.slice(4).toLowerCase()):le})},B=function(G){return H(G,function(le){return R.test(le)?"xn--"+S(le):le})},Q={version:"2.1.0",ucs2:{decode:z,encode:V},decode:D,encode:S,toASCII:B,toUnicode:A},te={};function he(_){var G=_.charCodeAt(0),le=void 0;return G<16?le="%0"+G.toString(16).toUpperCase():G<128?le="%"+G.toString(16).toUpperCase():G<2048?le="%"+(G>>6|192).toString(16).toUpperCase()+"%"+(G&63|128).toString(16).toUpperCase():le="%"+(G>>12|224).toString(16).toUpperCase()+"%"+(G>>6&63|128).toString(16).toUpperCase()+"%"+(G&63|128).toString(16).toUpperCase(),le}function ke(_){for(var G="",le=0,xe=_.length;le<xe;){var $e=parseInt(_.substr(le+1,2),16);if($e<128)G+=String.fromCharCode($e),le+=3;else if($e>=194&&$e<224){if(xe-le>=6){var rt=parseInt(_.substr(le+4,2),16);G+=String.fromCharCode(($e&31)<<6|rt&63)}else G+=_.substr(le,6);le+=6}else if($e>=224){if(xe-le>=9){var pt=parseInt(_.substr(le+4,2),16),Rt=parseInt(_.substr(le+7,2),16);G+=String.fromCharCode(($e&15)<<12|(pt&63)<<6|Rt&63)}else G+=_.substr(le,9);le+=9}else G+=_.substr(le,3),le+=3}return G}function be(_,G){function le(xe){var $e=ke(xe);return $e.match(G.UNRESERVED)?$e:xe}return _.scheme&&(_.scheme=String(_.scheme).replace(G.PCT_ENCODED,le).toLowerCase().replace(G.NOT_SCHEME,"")),_.userinfo!==void 0&&(_.userinfo=String(_.userinfo).replace(G.PCT_ENCODED,le).replace(G.NOT_USERINFO,he).replace(G.PCT_ENCODED,a)),_.host!==void 0&&(_.host=String(_.host).replace(G.PCT_ENCODED,le).toLowerCase().replace(G.NOT_HOST,he).replace(G.PCT_ENCODED,a)),_.path!==void 0&&(_.path=String(_.path).replace(G.PCT_ENCODED,le).replace(_.scheme?G.NOT_PATH:G.NOT_PATH_NOSCHEME,he).replace(G.PCT_ENCODED,a)),_.query!==void 0&&(_.query=String(_.query).replace(G.PCT_ENCODED,le).replace(G.NOT_QUERY,he).replace(G.PCT_ENCODED,a)),_.fragment!==void 0&&(_.fragment=String(_.fragment).replace(G.PCT_ENCODED,le).replace(G.NOT_FRAGMENT,he).replace(G.PCT_ENCODED,a)),_}function de(_){return _.replace(/^0*(.*)/,"$1")||"0"}function Be(_,G){var le=_.match(G.IPV4ADDRESS)||[],xe=d(le,2),$e=xe[1];return $e?$e.split(".").map(de).join("."):_}function ee(_,G){var le=_.match(G.IPV6ADDRESS)||[],xe=d(le,3),$e=xe[1],rt=xe[2];if($e){for(var pt=$e.toLowerCase().split("::").reverse(),Rt=d(pt,2),xt=Rt[0],Ht=Rt[1],ae=Ht?Ht.split(":").map(de):[],Pe=xt.split(":").map(de),Ke=G.IPV4ADDRESS.test(Pe[Pe.length-1]),Ge=Ke?7:8,it=Pe.length-Ge,Et=Array(Ge),It=0;It<Ge;++It)Et[It]=ae[It]||Pe[it+It]||"";Ke&&(Et[Ge-1]=Be(Et[Ge-1],G));var $t=Et.reduce(function(Hn,Lr,ni){if(!Lr||Lr==="0"){var co=Hn[Hn.length-1];co&&co.index+co.length===ni?co.length++:Hn.push({index:ni,length:1})}return Hn},[]),jt=$t.sort(function(Hn,Lr){return Lr.length-Hn.length})[0],Tt=void 0;if(jt&&jt.length>1){var Sn=Et.slice(0,jt.index),kn=Et.slice(jt.index+jt.length);Tt=Sn.join(":")+"::"+kn.join(":")}else Tt=Et.join(":");return rt&&(Tt+="%"+rt),Tt}else return _}var Oe=/^(?:([^:\/?#]+):)?(?:\/\/((?:([^\/?#@]*)@)?(\[[^\/?#\]]+\]|[^\/?#:]*)(?:\:(\d*))?))?([^?#]*)(?:\?([^#]*))?(?:#((?:.|\n|\r)*))?/i,Le="".match(/(){0}/)[1]===void 0;function Ce(_){var G=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},le={},xe=G.iri!==!1?u:f;G.reference==="suffix"&&(_=(G.scheme?G.scheme+":":"")+"//"+_);var $e=_.match(Oe);if($e){Le?(le.scheme=$e[1],le.userinfo=$e[3],le.host=$e[4],le.port=parseInt($e[5],10),le.path=$e[6]||"",le.query=$e[7],le.fragment=$e[8],isNaN(le.port)&&(le.port=$e[5])):(le.scheme=$e[1]||void 0,le.userinfo=_.indexOf("@")!==-1?$e[3]:void 0,le.host=_.indexOf("//")!==-1?$e[4]:void 0,le.port=parseInt($e[5],10),le.path=$e[6]||"",le.query=_.indexOf("?")!==-1?$e[7]:void 0,le.fragment=_.indexOf("#")!==-1?$e[8]:void 0,isNaN(le.port)&&(le.port=_.match(/\/\/(?:.|\n)*\:(?:\/|\?|\#|$)/)?$e[4]:void 0)),le.host&&(le.host=ee(Be(le.host,xe),xe)),le.scheme===void 0&&le.userinfo===void 0&&le.host===void 0&&le.port===void 0&&!le.path&&le.query===void 0?le.reference="same-document":le.scheme===void 0?le.reference="relative":le.fragment===void 0?le.reference="absolute":le.reference="uri",G.reference&&G.reference!=="suffix"&&G.reference!==le.reference&&(le.error=le.error||"URI is not a "+G.reference+" reference.");var rt=te[(G.scheme||le.scheme||"").toLowerCase()];if(!G.unicodeSupport&&(!rt||!rt.unicodeSupport)){if(le.host&&(G.domainHost||rt&&rt.domainHost))try{le.host=Q.toASCII(le.host.replace(xe.PCT_ENCODED,ke).toLowerCase())}catch(pt){le.error=le.error||"Host's domain name can not be converted to ASCII via punycode: "+pt}be(le,f)}else be(le,xe);rt&&rt.parse&&rt.parse(le,G)}else le.error=le.error||"URI can not be parsed.";return le}function X(_,G){var le=G.iri!==!1?u:f,xe=[];return _.userinfo!==void 0&&(xe.push(_.userinfo),xe.push("@")),_.host!==void 0&&xe.push(ee(Be(String(_.host),le),le).replace(le.IPV6ADDRESS,function($e,rt,pt){return"["+rt+(pt?"%25"+pt:"")+"]"})),(typeof _.port=="number"||typeof _.port=="string")&&(xe.push(":"),xe.push(String(_.port))),xe.length?xe.join(""):void 0}var re=/^\.\.?\//,we=/^\/\.(\/|$)/,Me=/^\/\.\.(\/|$)/,Ee=/^\/?(?:.|\n)*?(?=\/|$)/;function Ze(_){for(var G=[];_.length;)if(_.match(re))_=_.replace(re,"");else if(_.match(we))_=_.replace(we,"/");else if(_.match(Me))_=_.replace(Me,"/"),G.pop();else if(_==="."||_==="..")_="";else{var le=_.match(Ee);if(le){var xe=le[0];_=_.slice(xe.length),G.push(xe)}else throw new Error("Unexpected dot segment condition")}return G.join("")}function ve(_){var G=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},le=G.iri?u:f,xe=[],$e=te[(G.scheme||_.scheme||"").toLowerCase()];if($e&&$e.serialize&&$e.serialize(_,G),_.host&&!le.IPV6ADDRESS.test(_.host)){if(G.domainHost||$e&&$e.domainHost)try{_.host=G.iri?Q.toUnicode(_.host):Q.toASCII(_.host.replace(le.PCT_ENCODED,ke).toLowerCase())}catch(Rt){_.error=_.error||"Host's domain name can not be converted to "+(G.iri?"Unicode":"ASCII")+" via punycode: "+Rt}}be(_,le),G.reference!=="suffix"&&_.scheme&&(xe.push(_.scheme),xe.push(":"));var rt=X(_,G);if(rt!==void 0&&(G.reference!=="suffix"&&xe.push("//"),xe.push(rt),_.path&&_.path.charAt(0)!=="/"&&xe.push("/")),_.path!==void 0){var pt=_.path;!G.absolutePath&&(!$e||!$e.absolutePath)&&(pt=Ze(pt)),rt===void 0&&(pt=pt.replace(/^\/\//,"/%2F")),xe.push(pt)}return _.query!==void 0&&(xe.push("?"),xe.push(_.query)),_.fragment!==void 0&&(xe.push("#"),xe.push(_.fragment)),xe.join("")}function Ne(_,G){var le=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},xe=arguments[3],$e={};return xe||(_=Ce(ve(_,le),le),G=Ce(ve(G,le),le)),le=le||{},!le.tolerant&&G.scheme?($e.scheme=G.scheme,$e.userinfo=G.userinfo,$e.host=G.host,$e.port=G.port,$e.path=Ze(G.path||""),$e.query=G.query):(G.userinfo!==void 0||G.host!==void 0||G.port!==void 0?($e.userinfo=G.userinfo,$e.host=G.host,$e.port=G.port,$e.path=Ze(G.path||""),$e.query=G.query):(G.path?(G.path.charAt(0)==="/"?$e.path=Ze(G.path):((_.userinfo!==void 0||_.host!==void 0||_.port!==void 0)&&!_.path?$e.path="/"+G.path:_.path?$e.path=_.path.slice(0,_.path.lastIndexOf("/")+1)+G.path:$e.path=G.path,$e.path=Ze($e.path)),$e.query=G.query):($e.path=_.path,G.query!==void 0?$e.query=G.query:$e.query=_.query),$e.userinfo=_.userinfo,$e.host=_.host,$e.port=_.port),$e.scheme=_.scheme),$e.fragment=G.fragment,$e}function ze(_,G,le){var xe=l({scheme:"null"},le);return ve(Ne(Ce(_,xe),Ce(G,xe),xe,!0),xe)}function Ye(_,G){return typeof _=="string"?_=ve(Ce(_,G),G):i(_)==="object"&&(_=Ce(ve(_,G),G)),_}function We(_,G,le){return typeof _=="string"?_=ve(Ce(_,le),le):i(_)==="object"&&(_=ve(_,le)),typeof G=="string"?G=ve(Ce(G,le),le):i(G)==="object"&&(G=ve(G,le)),_===G}function at(_,G){return _&&_.toString().replace(!G||!G.iri?f.ESCAPE:u.ESCAPE,he)}function dt(_,G){return _&&_.toString().replace(!G||!G.iri?f.PCT_ENCODED:u.PCT_ENCODED,ke)}var ln={scheme:"http",domainHost:!0,parse:function(G,le){return G.host||(G.error=G.error||"HTTP URIs must have a host."),G},serialize:function(G,le){var xe=String(G.scheme).toLowerCase()==="https";return(G.port===(xe?443:80)||G.port==="")&&(G.port=void 0),G.path||(G.path="/"),G}},yt={scheme:"https",domainHost:ln.domainHost,parse:ln.parse,serialize:ln.serialize};function vn(_){return typeof _.secure=="boolean"?_.secure:String(_.scheme).toLowerCase()==="wss"}var Kt={scheme:"ws",domainHost:!0,parse:function(G,le){var xe=G;return xe.secure=vn(xe),xe.resourceName=(xe.path||"/")+(xe.query?"?"+xe.query:""),xe.path=void 0,xe.query=void 0,xe},serialize:function(G,le){if((G.port===(vn(G)?443:80)||G.port==="")&&(G.port=void 0),typeof G.secure=="boolean"&&(G.scheme=G.secure?"wss":"ws",G.secure=void 0),G.resourceName){var xe=G.resourceName.split("?"),$e=d(xe,2),rt=$e[0],pt=$e[1];G.path=rt&&rt!=="/"?rt:void 0,G.query=pt,G.resourceName=void 0}return G.fragment=void 0,G}},nn={scheme:"wss",domainHost:Kt.domainHost,parse:Kt.parse,serialize:Kt.serialize},cn={},Qn="[A-Za-z0-9\\-\\.\\_\\~\\xA0-\\u200D\\u2010-\\u2029\\u202F-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF]",En="[0-9A-Fa-f]",Xn=o(o("%[EFef]"+En+"%"+En+En+"%"+En+En)+"|"+o("%[89A-Fa-f]"+En+"%"+En+En)+"|"+o("%"+En+En)),zn="[A-Za-z0-9\\!\\$\\%\\'\\*\\+\\-\\^\\_\\`\\{\\|\\}\\~]",dn="[\\!\\$\\%\\'\\(\\)\\*\\+\\,\\-\\.0-9\\<\\>A-Z\\x5E-\\x7E]",Ae=r(dn,'[\\"\\\\]'),bt="[\\!\\$\\'\\(\\)\\*\\+\\,\\;\\:\\@]",At=new RegExp(Qn,"g"),W=new RegExp(Xn,"g"),qe=new RegExp(r("[^]",zn,"[\\.]",'[\\"]',Ae),"g"),st=new RegExp(r("[^]",Qn,bt),"g"),ht=st;function Un(_){var G=ke(_);return G.match(At)?G:_}var hn={scheme:"mailto",parse:function(G,le){var xe=G,$e=xe.to=xe.path?xe.path.split(","):[];if(xe.path=void 0,xe.query){for(var rt=!1,pt={},Rt=xe.query.split("&"),xt=0,Ht=Rt.length;xt<Ht;++xt){var ae=Rt[xt].split("=");switch(ae[0]){case"to":for(var Pe=ae[1].split(","),Ke=0,Ge=Pe.length;Ke<Ge;++Ke)$e.push(Pe[Ke]);break;case"subject":xe.subject=dt(ae[1],le);break;case"body":xe.body=dt(ae[1],le);break;default:rt=!0,pt[dt(ae[0],le)]=dt(ae[1],le);break}}rt&&(xe.headers=pt)}xe.query=void 0;for(var it=0,Et=$e.length;it<Et;++it){var It=$e[it].split("@");if(It[0]=dt(It[0]),le.unicodeSupport)It[1]=dt(It[1],le).toLowerCase();else try{It[1]=Q.toASCII(dt(It[1],le).toLowerCase())}catch($t){xe.error=xe.error||"Email address's domain name can not be converted to ASCII via punycode: "+$t}$e[it]=It.join("@")}return xe},serialize:function(G,le){var xe=G,$e=s(G.to);if($e){for(var rt=0,pt=$e.length;rt<pt;++rt){var Rt=String($e[rt]),xt=Rt.lastIndexOf("@"),Ht=Rt.slice(0,xt).replace(W,Un).replace(W,a).replace(qe,he),ae=Rt.slice(xt+1);try{ae=le.iri?Q.toUnicode(ae):Q.toASCII(dt(ae,le).toLowerCase())}catch(it){xe.error=xe.error||"Email address's domain name can not be converted to "+(le.iri?"Unicode":"ASCII")+" via punycode: "+it}$e[rt]=Ht+"@"+ae}xe.path=$e.join(",")}var Pe=G.headers=G.headers||{};G.subject&&(Pe.subject=G.subject),G.body&&(Pe.body=G.body);var Ke=[];for(var Ge in Pe)Pe[Ge]!==cn[Ge]&&Ke.push(Ge.replace(W,Un).replace(W,a).replace(st,he)+"="+Pe[Ge].replace(W,Un).replace(W,a).replace(ht,he));return Ke.length&&(xe.query=Ke.join("&")),xe}},Rr=/^([^\:]+)\:(.*)/,oe={scheme:"urn",parse:function(G,le){var xe=G.path&&G.path.match(Rr),$e=G;if(xe){var rt=le.scheme||$e.scheme||"urn",pt=xe[1].toLowerCase(),Rt=xe[2],xt=rt+":"+(le.nid||pt),Ht=te[xt];$e.nid=pt,$e.nss=Rt,$e.path=void 0,Ht&&($e=Ht.parse($e,le))}else $e.error=$e.error||"URN can not be parsed.";return $e},serialize:function(G,le){var xe=le.scheme||G.scheme||"urn",$e=G.nid,rt=xe+":"+(le.nid||$e),pt=te[rt];pt&&(G=pt.serialize(G,le));var Rt=G,xt=G.nss;return Rt.path=($e||le.nid)+":"+xt,Rt}},ye=/^[0-9A-Fa-f]{8}(?:\-[0-9A-Fa-f]{4}){3}\-[0-9A-Fa-f]{12}$/,q={scheme:"urn:uuid",parse:function(G,le){var xe=G;return xe.uuid=xe.nss,xe.nss=void 0,!le.tolerant&&(!xe.uuid||!xe.uuid.match(ye))&&(xe.error=xe.error||"UUID is not valid."),xe},serialize:function(G,le){var xe=G;return xe.nss=(G.uuid||"").toLowerCase(),xe}};te[ln.scheme]=ln,te[yt.scheme]=yt,te[Kt.scheme]=Kt,te[nn.scheme]=nn,te[hn.scheme]=hn,te[oe.scheme]=oe,te[q.scheme]=q,n.SCHEMES=te,n.pctEncChar=he,n.pctDecChars=ke,n.parse=Ce,n.removeDotSegments=Ze,n.serialize=ve,n.resolveComponents=Ne,n.resolve=ze,n.normalize=Ye,n.equal=We,n.escapeComponent=at,n.unescapeComponent=dt,Object.defineProperty(n,"__esModule",{value:!0})})})(C2,C2.exports);var Zye=C2.exports;Object.defineProperty(S2,"__esModule",{value:!0});const MF=Zye;MF.code='require("ajv/dist/runtime/uri").default',S2.default=MF,function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.CodeGen=e.Name=e.nil=e.stringify=e.str=e._=e.KeywordCxt=void 0;var t=Ra;Object.defineProperty(e,"KeywordCxt",{enumerable:!0,get:function(){return t.KeywordCxt}});var n=Dn;Object.defineProperty(e,"_",{enumerable:!0,get:function(){return n._}}),Object.defineProperty(e,"str",{enumerable:!0,get:function(){return n.str}}),Object.defineProperty(e,"stringify",{enumerable:!0,get:function(){return n.stringify}}),Object.defineProperty(e,"nil",{enumerable:!0,get:function(){return n.nil}}),Object.defineProperty(e,"Name",{enumerable:!0,get:function(){return n.Name}}),Object.defineProperty(e,"CodeGen",{enumerable:!0,get:function(){return n.CodeGen}});const r=Zh,o=ep,i=Xc,a=yi,s=Dn,l=Oo,c=Qh,f=Jn,u=Xye,d=S2,h=(P,N)=>new RegExp(P,N);h.code="new RegExp";const p=["removeAdditional","useDefaults","coerceTypes"],m=new Set(["validate","serialize","parse","wrapper","root","schema","keyword","pattern","formats","validate$data","func","obj","Error"]),v={errorDataPath:"",format:"`validateFormats: false` can be used instead.",nullable:'"nullable" keyword is supported by default.',jsonPointers:"Deprecated jsPropertySyntax can be used instead.",extendRefs:"Deprecated ignoreKeywordsWithRef can be used instead.",missingRefs:"Pass empty schema with $id that should be ignored to ajv.addSchema.",processCode:"Use option `code: {process: (code, schemaEnv: object) => string}`",sourceCode:"Use option `code: {source: true}`",strictDefaults:"It is default now, see option `strict`.",strictKeywords:"It is default now, see option `strict`.",uniqueItems:'"uniqueItems" keyword is always validated.',unknownFormats:"Disable strict mode or pass `true` to `ajv.addFormat` (or `formats` option).",cache:"Map is used as cache, schema object as key.",serialize:"Map is used as cache, schema object as key.",ajvErrors:"It is default now."},g={ignoreKeywordsWithRef:"",jsPropertySyntax:"",unicode:'"minLength"/"maxLength" account for unicode characters by default.'},y=200;function w(P){var N,D,S,A,B,Q,te,he,ke,be,de,Be,ee,Oe,Le,Ce,X,re,we,Me,Ee,Ze,ve,Ne,ze;const Ye=P.strict,We=(N=P.code)===null||N===void 0?void 0:N.optimize,at=We===!0||We===void 0?1:We||0,dt=(S=(D=P.code)===null||D===void 0?void 0:D.regExp)!==null&&S!==void 0?S:h,ln=(A=P.uriResolver)!==null&&A!==void 0?A:d.default;return{strictSchema:(Q=(B=P.strictSchema)!==null&&B!==void 0?B:Ye)!==null&&Q!==void 0?Q:!0,strictNumbers:(he=(te=P.strictNumbers)!==null&&te!==void 0?te:Ye)!==null&&he!==void 0?he:!0,strictTypes:(be=(ke=P.strictTypes)!==null&&ke!==void 0?ke:Ye)!==null&&be!==void 0?be:"log",strictTuples:(Be=(de=P.strictTuples)!==null&&de!==void 0?de:Ye)!==null&&Be!==void 0?Be:"log",strictRequired:(Oe=(ee=P.strictRequired)!==null&&ee!==void 0?ee:Ye)!==null&&Oe!==void 0?Oe:!1,code:P.code?{...P.code,optimize:at,regExp:dt}:{optimize:at,regExp:dt},loopRequired:(Le=P.loopRequired)!==null&&Le!==void 0?Le:y,loopEnum:(Ce=P.loopEnum)!==null&&Ce!==void 0?Ce:y,meta:(X=P.meta)!==null&&X!==void 0?X:!0,messages:(re=P.messages)!==null&&re!==void 0?re:!0,inlineRefs:(we=P.inlineRefs)!==null&&we!==void 0?we:!0,schemaId:(Me=P.schemaId)!==null&&Me!==void 0?Me:"$id",addUsedSchema:(Ee=P.addUsedSchema)!==null&&Ee!==void 0?Ee:!0,validateSchema:(Ze=P.validateSchema)!==null&&Ze!==void 0?Ze:!0,validateFormats:(ve=P.validateFormats)!==null&&ve!==void 0?ve:!0,unicodeRegExp:(Ne=P.unicodeRegExp)!==null&&Ne!==void 0?Ne:!0,int32range:(ze=P.int32range)!==null&&ze!==void 0?ze:!0,uriResolver:ln}}class k{constructor(N={}){this.schemas={},this.refs={},this.formats={},this._compilations=new Set,this._loading={},this._cache=new Map,N=this.opts={...N,...w(N)};const{es5:D,lines:S}=this.opts.code;this.scope=new s.ValueScope({scope:{},prefixes:m,es5:D,lines:S}),this.logger=O(N.logger);const A=N.validateFormats;N.validateFormats=!1,this.RULES=(0,i.getRules)(),$.call(this,v,N,"NOT SUPPORTED"),$.call(this,g,N,"DEPRECATED","warn"),this._metaOpts=j.call(this),N.formats&&R.call(this),this._addVocabularies(),this._addDefaultMetaSchema(),N.keywords&&M.call(this,N.keywords),typeof N.meta=="object"&&this.addMetaSchema(N.meta),E.call(this),N.validateFormats=A}_addVocabularies(){this.addKeyword("$async")}_addDefaultMetaSchema(){const{$data:N,meta:D,schemaId:S}=this.opts;let A=u;S==="id"&&(A={...u},A.id=A.$id,delete A.$id),D&&N&&this.addMetaSchema(A,A[S],!1)}defaultMeta(){const{meta:N,schemaId:D}=this.opts;return this.opts.defaultMeta=typeof N=="object"?N[D]||N:void 0}validate(N,D){let S;if(typeof N=="string"){if(S=this.getSchema(N),!S)throw new Error(`no schema with key or ref "${N}"`)}else S=this.compile(N);const A=S(D);return"$async"in S||(this.errors=S.errors),A}compile(N,D){const S=this._addSchema(N,D);return S.validate||this._compileSchemaEnv(S)}compileAsync(N,D){if(typeof this.opts.loadSchema!="function")throw new Error("options.loadSchema should be a function");const{loadSchema:S}=this.opts;return A.call(this,N,D);async function A(be,de){await B.call(this,be.$schema);const Be=this._addSchema(be,de);return Be.validate||Q.call(this,Be)}async function B(be){be&&!this.getSchema(be)&&await A.call(this,{$ref:be},!0)}async function Q(be){try{return this._compileSchemaEnv(be)}catch(de){if(!(de instanceof o.default))throw de;return te.call(this,de),await he.call(this,de.missingSchema),Q.call(this,be)}}function te({missingSchema:be,missingRef:de}){if(this.refs[be])throw new Error(`AnySchema ${be} is loaded but ${de} cannot be resolved`)}async function he(be){const de=await ke.call(this,be);this.refs[be]||await B.call(this,de.$schema),this.refs[be]||this.addSchema(de,be,D)}async function ke(be){const de=this._loading[be];if(de)return de;try{return await(this._loading[be]=S(be))}finally{delete this._loading[be]}}}addSchema(N,D,S,A=this.opts.validateSchema){if(Array.isArray(N)){for(const Q of N)this.addSchema(Q,void 0,S,A);return this}let B;if(typeof N=="object"){const{schemaId:Q}=this.opts;if(B=N[Q],B!==void 0&&typeof B!="string")throw new Error(`schema ${Q} must be string`)}return D=(0,l.normalizeId)(D||B),this._checkUnique(D),this.schemas[D]=this._addSchema(N,S,D,A,!0),this}addMetaSchema(N,D,S=this.opts.validateSchema){return this.addSchema(N,D,!0,S),this}validateSchema(N,D){if(typeof N=="boolean")return!0;let S;if(S=N.$schema,S!==void 0&&typeof S!="string")throw new Error("$schema must be a string");if(S=S||this.opts.defaultMeta||this.defaultMeta(),!S)return this.logger.warn("meta-schema not available"),this.errors=null,!0;const A=this.validate(S,N);if(!A&&D){const B="schema is invalid: "+this.errorsText();if(this.opts.validateSchema==="log")this.logger.error(B);else throw new Error(B)}return A}getSchema(N){let D;for(;typeof(D=x.call(this,N))=="string";)N=D;if(D===void 0){const{schemaId:S}=this.opts,A=new a.SchemaEnv({schema:{},schemaId:S});if(D=a.resolveSchema.call(this,A,N),!D)return;this.refs[N]=D}return D.validate||this._compileSchemaEnv(D)}removeSchema(N){if(N instanceof RegExp)return this._removeAllSchemas(this.schemas,N),this._removeAllSchemas(this.refs,N),this;switch(typeof N){case"undefined":return this._removeAllSchemas(this.schemas),this._removeAllSchemas(this.refs),this._cache.clear(),this;case"string":{const D=x.call(this,N);return typeof D=="object"&&this._cache.delete(D.schema),delete this.schemas[N],delete this.refs[N],this}case"object":{const D=N;this._cache.delete(D);let S=N[this.opts.schemaId];return S&&(S=(0,l.normalizeId)(S),delete this.schemas[S],delete this.refs[S]),this}default:throw new Error("ajv.removeSchema: invalid parameter")}}addVocabulary(N){for(const D of N)this.addKeyword(D);return this}addKeyword(N,D){let S;if(typeof N=="string")S=N,typeof D=="object"&&(this.logger.warn("these parameters are deprecated, see docs for addKeyword"),D.keyword=S);else if(typeof N=="object"&&D===void 0){if(D=N,S=D.keyword,Array.isArray(S)&&!S.length)throw new Error("addKeywords: keyword must be string or non-empty array")}else throw new Error("invalid addKeywords parameters");if(T.call(this,S,D),!D)return(0,f.eachItem)(S,B=>L.call(this,B)),this;z.call(this,D);const A={...D,type:(0,c.getJSONTypes)(D.type),schemaType:(0,c.getJSONTypes)(D.schemaType)};return(0,f.eachItem)(S,A.type.length===0?B=>L.call(this,B,A):B=>A.type.forEach(Q=>L.call(this,B,A,Q))),this}getKeyword(N){const D=this.RULES.all[N];return typeof D=="object"?D.definition:!!D}removeKeyword(N){const{RULES:D}=this;delete D.keywords[N],delete D.all[N];for(const S of D.rules){const A=S.rules.findIndex(B=>B.keyword===N);A>=0&&S.rules.splice(A,1)}return this}addFormat(N,D){return typeof D=="string"&&(D=new RegExp(D)),this.formats[N]=D,this}errorsText(N=this.errors,{separator:D=", ",dataVar:S="data"}={}){return!N||N.length===0?"No errors":N.map(A=>`${S}${A.instancePath} ${A.message}`).reduce((A,B)=>A+D+B)}$dataMetaSchema(N,D){const S=this.RULES.all;N=JSON.parse(JSON.stringify(N));for(const A of D){const B=A.split("/").slice(1);let Q=N;for(const te of B)Q=Q[te];for(const te in S){const he=S[te];if(typeof he!="object")continue;const{$data:ke}=he.definition,be=Q[te];ke&&be&&(Q[te]=I(be))}}return N}_removeAllSchemas(N,D){for(const S in N){const A=N[S];(!D||D.test(S))&&(typeof A=="string"?delete N[S]:A&&!A.meta&&(this._cache.delete(A.schema),delete N[S]))}}_addSchema(N,D,S,A=this.opts.validateSchema,B=this.opts.addUsedSchema){let Q;const{schemaId:te}=this.opts;if(typeof N=="object")Q=N[te];else{if(this.opts.jtd)throw new Error("schema must be object");if(typeof N!="boolean")throw new Error("schema must be object or boolean")}let he=this._cache.get(N);if(he!==void 0)return he;S=(0,l.normalizeId)(Q||S);const ke=l.getSchemaRefs.call(this,N,S);return he=new a.SchemaEnv({schema:N,schemaId:te,meta:D,baseId:S,localRefs:ke}),this._cache.set(he.schema,he),B&&!S.startsWith("#")&&(S&&this._checkUnique(S),this.refs[S]=he),A&&this.validateSchema(N,!0),he}_checkUnique(N){if(this.schemas[N]||this.refs[N])throw new Error(`schema with key or id "${N}" already exists`)}_compileSchemaEnv(N){if(N.meta?this._compileMetaSchema(N):a.compileSchema.call(this,N),!N.validate)throw new Error("ajv implementation error");return N.validate}_compileMetaSchema(N){const D=this.opts;this.opts=this._metaOpts;try{a.compileSchema.call(this,N)}finally{this.opts=D}}}e.default=k,k.ValidationError=r.default,k.MissingRefError=o.default;function $(P,N,D,S="error"){for(const A in P){const B=A;B in N&&this.logger[S](`${D}: option ${A}. ${P[B]}`)}}function x(P){return P=(0,l.normalizeId)(P),this.schemas[P]||this.refs[P]}function E(){const P=this.opts.schemas;if(P)if(Array.isArray(P))this.addSchema(P);else for(const N in P)this.addSchema(P[N],N)}function R(){for(const P in this.opts.formats){const N=this.opts.formats[P];N&&this.addFormat(P,N)}}function M(P){if(Array.isArray(P)){this.addVocabulary(P);return}this.logger.warn("keywords option as map is deprecated, pass array");for(const N in P){const D=P[N];D.keyword||(D.keyword=N),this.addKeyword(D)}}function j(){const P={...this.opts};for(const N of p)delete P[N];return P}const C={log(){},warn(){},error(){}};function O(P){if(P===!1)return C;if(P===void 0)return console;if(P.log&&P.warn&&P.error)return P;throw new Error("logger must implement log, warn and error methods")}const F=/^[a-z_$][a-z0-9_$:-]*$/i;function T(P,N){const{RULES:D}=this;if((0,f.eachItem)(P,S=>{if(D.keywords[S])throw new Error(`Keyword ${S} is already defined`);if(!F.test(S))throw new Error(`Keyword ${S} has invalid name`)}),!!N&&N.$data&&!("code"in N||"validate"in N))throw new Error('$data keyword must have "code" or "validate" function')}function L(P,N,D){var S;const A=N==null?void 0:N.post;if(D&&A)throw new Error('keyword with "post" flag cannot have "type"');const{RULES:B}=this;let Q=A?B.post:B.rules.find(({type:he})=>he===D);if(Q||(Q={type:D,rules:[]},B.rules.push(Q)),B.keywords[P]=!0,!N)return;const te={keyword:P,definition:{...N,type:(0,c.getJSONTypes)(N.type),schemaType:(0,c.getJSONTypes)(N.schemaType)}};N.before?H.call(this,Q,te,N.before):Q.rules.push(te),B.all[P]=te,(S=N.implements)===null||S===void 0||S.forEach(he=>this.addKeyword(he))}function H(P,N,D){const S=P.rules.findIndex(A=>A.keyword===D);S>=0?P.rules.splice(S,0,N):(P.rules.push(N),this.logger.warn(`rule ${D} is not defined`))}function z(P){let{metaSchema:N}=P;N!==void 0&&(P.$data&&this.opts.$data&&(N=I(N)),P.validateSchema=this.compile(N,!0))}const V={$ref:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#"};function I(P){return{anyOf:[P,V]}}}(eF);var $2={},T2={},E2={};Object.defineProperty(E2,"__esModule",{value:!0});const e1e={keyword:"id",code(){throw new Error('NOT SUPPORTED: keyword "id", use "$id" for schema ID')}};E2.default=e1e;var tu={};Object.defineProperty(tu,"__esModule",{value:!0}),tu.callRef=tu.getValidate=void 0;const t1e=ep,PF=Rn,bi=Dn,Uf=js,NF=yi,o0=Jn,n1e={keyword:"$ref",schemaType:"string",code(e){const{gen:t,schema:n,it:r}=e,{baseId:o,schemaEnv:i,validateName:a,opts:s,self:l}=r,{root:c}=i;if((n==="#"||n==="#/")&&o===c.baseId)return u();const f=NF.resolveRef.call(l,c,o,n);if(f===void 0)throw new t1e.default(r.opts.uriResolver,o,n);if(f instanceof NF.SchemaEnv)return d(f);return h(f);function u(){if(i===c)return i0(e,a,i,i.$async);const p=t.scopeValue("root",{ref:c});return i0(e,(0,bi._)`${p}.validate`,c,c.$async)}function d(p){const m=IF(e,p);i0(e,m,p,p.$async)}function h(p){const m=t.scopeValue("schema",s.code.source===!0?{ref:p,code:(0,bi.stringify)(p)}:{ref:p}),v=t.name("valid"),g=e.subschema({schema:p,dataTypes:[],schemaPath:bi.nil,topSchemaRef:m,errSchemaPath:n},v);e.mergeEvaluated(g),e.ok(v)}}};function IF(e,t){const{gen:n}=e;return t.validate?n.scopeValue("validate",{ref:t.validate}):(0,bi._)`${n.scopeValue("wrapper",{ref:t})}.validate`}tu.getValidate=IF;function i0(e,t,n,r){const{gen:o,it:i}=e,{allErrors:a,schemaEnv:s,opts:l}=i,c=l.passContext?Uf.default.this:bi.nil;r?f():u();function f(){if(!s.$async)throw new Error("async schema referenced by sync schema");const p=o.let("valid");o.try(()=>{o.code((0,bi._)`await ${(0,PF.callValidateCode)(e,t,c)}`),h(t),a||o.assign(p,!0)},m=>{o.if((0,bi._)`!(${m} instanceof ${i.ValidationError})`,()=>o.throw(m)),d(m),a||o.assign(p,!1)}),e.ok(p)}function u(){e.result((0,PF.callValidateCode)(e,t,c),()=>h(t),()=>d(t))}function d(p){const m=(0,bi._)`${p}.errors`;o.assign(Uf.default.vErrors,(0,bi._)`${Uf.default.vErrors} === null ? ${m} : ${Uf.default.vErrors}.concat(${m})`),o.assign(Uf.default.errors,(0,bi._)`${Uf.default.vErrors}.length`)}function h(p){var m;if(!i.opts.unevaluated)return;const v=(m=n==null?void 0:n.validate)===null||m===void 0?void 0:m.evaluated;if(i.props!==!0)if(v&&!v.dynamicProps)v.props!==void 0&&(i.props=o0.mergeEvaluated.props(o,v.props,i.props));else{const g=o.var("props",(0,bi._)`${p}.evaluated.props`);i.props=o0.mergeEvaluated.props(o,g,i.props,bi.Name)}if(i.items!==!0)if(v&&!v.dynamicItems)v.items!==void 0&&(i.items=o0.mergeEvaluated.items(o,v.items,i.items));else{const g=o.var("items",(0,bi._)`${p}.evaluated.items`);i.items=o0.mergeEvaluated.items(o,g,i.items,bi.Name)}}}tu.callRef=i0,tu.default=n1e,Object.defineProperty(T2,"__esModule",{value:!0});const r1e=E2,o1e=tu,i1e=["$schema","$id","$defs","$vocabulary",{keyword:"$comment"},"definitions",r1e.default,o1e.default];T2.default=i1e;var O2={},A2={};Object.defineProperty(A2,"__esModule",{value:!0});const a0=Dn,tc=a0.operators,s0={maximum:{okStr:"<=",ok:tc.LTE,fail:tc.GT},minimum:{okStr:">=",ok:tc.GTE,fail:tc.LT},exclusiveMaximum:{okStr:"<",ok:tc.LT,fail:tc.GTE},exclusiveMinimum:{okStr:">",ok:tc.GT,fail:tc.LTE}},a1e={message:({keyword:e,schemaCode:t})=>(0,a0.str)`must be ${s0[e].okStr} ${t}`,params:({keyword:e,schemaCode:t})=>(0,a0._)`{comparison: ${s0[e].okStr}, limit: ${t}}`},s1e={keyword:Object.keys(s0),type:"number",schemaType:"number",$data:!0,error:a1e,code(e){const{keyword:t,data:n,schemaCode:r}=e;e.fail$data((0,a0._)`${n} ${s0[t].fail} ${r} || isNaN(${n})`)}};A2.default=s1e;var M2={};Object.defineProperty(M2,"__esModule",{value:!0});const tp=Dn,l1e={keyword:"multipleOf",type:"number",schemaType:"number",$data:!0,error:{message:({schemaCode:e})=>(0,tp.str)`must be multiple of ${e}`,params:({schemaCode:e})=>(0,tp._)`{multipleOf: ${e}}`},code(e){const{gen:t,data:n,schemaCode:r,it:o}=e,i=o.opts.multipleOfPrecision,a=t.let("res"),s=i?(0,tp._)`Math.abs(Math.round(${a}) - ${a}) > 1e-${i}`:(0,tp._)`${a} !== parseInt(${a})`;e.fail$data((0,tp._)`(${r} === 0 || (${a} = ${n}/${r}, ${s}))`)}};M2.default=l1e;var P2={},N2={};Object.defineProperty(N2,"__esModule",{value:!0});function DF(e){const t=e.length;let n=0,r=0,o;for(;r<t;)n++,o=e.charCodeAt(r++),o>=55296&&o<=56319&&r<t&&(o=e.charCodeAt(r),(o&64512)===56320&&r++);return n}N2.default=DF,DF.code='require("ajv/dist/runtime/ucs2length").default',Object.defineProperty(P2,"__esModule",{value:!0});const nu=Dn,c1e=Jn,u1e=N2,f1e={keyword:["maxLength","minLength"],type:"string",schemaType:"number",$data:!0,error:{message({keyword:e,schemaCode:t}){const n=e==="maxLength"?"more":"fewer";return(0,nu.str)`must NOT have ${n} than ${t} characters`},params:({schemaCode:e})=>(0,nu._)`{limit: ${e}}`},code(e){const{keyword:t,data:n,schemaCode:r,it:o}=e,i=t==="maxLength"?nu.operators.GT:nu.operators.LT,a=o.opts.unicode===!1?(0,nu._)`${n}.length`:(0,nu._)`${(0,c1e.useFunc)(e.gen,u1e.default)}(${n})`;e.fail$data((0,nu._)`${a} ${i} ${r}`)}};P2.default=f1e;var I2={};Object.defineProperty(I2,"__esModule",{value:!0});const d1e=Rn,l0=Dn,h1e={keyword:"pattern",type:"string",schemaType:"string",$data:!0,error:{message:({schemaCode:e})=>(0,l0.str)`must match pattern "${e}"`,params:({schemaCode:e})=>(0,l0._)`{pattern: ${e}}`},code(e){const{data:t,$data:n,schema:r,schemaCode:o,it:i}=e,a=i.opts.unicodeRegExp?"u":"",s=n?(0,l0._)`(new RegExp(${o}, ${a}))`:(0,d1e.usePattern)(e,r);e.fail$data((0,l0._)`!${s}.test(${t})`)}};I2.default=h1e;var D2={};Object.defineProperty(D2,"__esModule",{value:!0});const np=Dn,p1e={keyword:["maxProperties","minProperties"],type:"object",schemaType:"number",$data:!0,error:{message({keyword:e,schemaCode:t}){const n=e==="maxProperties"?"more":"fewer";return(0,np.str)`must NOT have ${n} than ${t} properties`},params:({schemaCode:e})=>(0,np._)`{limit: ${e}}`},code(e){const{keyword:t,data:n,schemaCode:r}=e,o=t==="maxProperties"?np.operators.GT:np.operators.LT;e.fail$data((0,np._)`Object.keys(${n}).length ${o} ${r}`)}};D2.default=p1e;var R2={};Object.defineProperty(R2,"__esModule",{value:!0});const rp=Rn,op=Dn,m1e=Jn,v1e={keyword:"required",type:"object",schemaType:"array",$data:!0,error:{message:({params:{missingProperty:e}})=>(0,op.str)`must have required property '${e}'`,params:({params:{missingProperty:e}})=>(0,op._)`{missingProperty: ${e}}`},code(e){const{gen:t,schema:n,schemaCode:r,data:o,$data:i,it:a}=e,{opts:s}=a;if(!i&&n.length===0)return;const l=n.length>=s.loopRequired;if(a.allErrors?c():f(),s.strictRequired){const h=e.parentSchema.properties,{definedProperties:p}=e.it;for(const m of n)if((h==null?void 0:h[m])===void 0&&!p.has(m)){const v=a.schemaEnv.baseId+a.errSchemaPath,g=`required property "${m}" is not defined at "${v}" (strictRequired)`;(0,m1e.checkStrictMode)(a,g,a.opts.strictRequired)}}function c(){if(l||i)e.block$data(op.nil,u);else for(const h of n)(0,rp.checkReportMissingProp)(e,h)}function f(){const h=t.let("missing");if(l||i){const p=t.let("valid",!0);e.block$data(p,()=>d(h,p)),e.ok(p)}else t.if((0,rp.checkMissingProp)(e,n,h)),(0,rp.reportMissingProp)(e,h),t.else()}function u(){t.forOf("prop",r,h=>{e.setParams({missingProperty:h}),t.if((0,rp.noPropertyInData)(t,o,h,s.ownProperties),()=>e.error())})}function d(h,p){e.setParams({missingProperty:h}),t.forOf(h,r,()=>{t.assign(p,(0,rp.propertyInData)(t,o,h,s.ownProperties)),t.if((0,op.not)(p),()=>{e.error(),t.break()})},op.nil)}}};R2.default=v1e;var L2={};Object.defineProperty(L2,"__esModule",{value:!0});const ip=Dn,g1e={keyword:["maxItems","minItems"],type:"array",schemaType:"number",$data:!0,error:{message({keyword:e,schemaCode:t}){const n=e==="maxItems"?"more":"fewer";return(0,ip.str)`must NOT have ${n} than ${t} items`},params:({schemaCode:e})=>(0,ip._)`{limit: ${e}}`},code(e){const{keyword:t,data:n,schemaCode:r}=e,o=t==="maxItems"?ip.operators.GT:ip.operators.LT;e.fail$data((0,ip._)`${n}.length ${o} ${r}`)}};L2.default=g1e;var B2={},ap={};Object.defineProperty(ap,"__esModule",{value:!0});const RF=uF;RF.code='require("ajv/dist/runtime/equal").default',ap.default=RF,Object.defineProperty(B2,"__esModule",{value:!0});const F2=Qh,Ao=Dn,y1e=Jn,b1e=ap,w1e={keyword:"uniqueItems",type:"array",schemaType:"boolean",$data:!0,error:{message:({params:{i:e,j:t}})=>(0,Ao.str)`must NOT have duplicate items (items ## ${t} and ${e} are identical)`,params:({params:{i:e,j:t}})=>(0,Ao._)`{i: ${e}, j: ${t}}`},code(e){const{gen:t,data:n,$data:r,schema:o,parentSchema:i,schemaCode:a,it:s}=e;if(!r&&!o)return;const l=t.let("valid"),c=i.items?(0,F2.getSchemaTypes)(i.items):[];e.block$data(l,f,(0,Ao._)`${a} === false`),e.ok(l);function f(){const p=t.let("i",(0,Ao._)`${n}.length`),m=t.let("j");e.setParams({i:p,j:m}),t.assign(l,!0),t.if((0,Ao._)`${p} > 1`,()=>(u()?d:h)(p,m))}function u(){return c.length>0&&!c.some(p=>p==="object"||p==="array")}function d(p,m){const v=t.name("item"),g=(0,F2.checkDataTypes)(c,v,s.opts.strictNumbers,F2.DataType.Wrong),y=t.const("indices",(0,Ao._)`{}`);t.for((0,Ao._)`;${p}--;`,()=>{t.let(v,(0,Ao._)`${n}[${p}]`),t.if(g,(0,Ao._)`continue`),c.length>1&&t.if((0,Ao._)`typeof ${v} == "string"`,(0,Ao._)`${v} += "_"`),t.if((0,Ao._)`typeof ${y}[${v}] == "number"`,()=>{t.assign(m,(0,Ao._)`${y}[${v}]`),e.error(),t.assign(l,!1).break()}).code((0,Ao._)`${y}[${v}] = ${p}`)})}function h(p,m){const v=(0,y1e.useFunc)(t,b1e.default),g=t.name("outer");t.label(g).for((0,Ao._)`;${p}--;`,()=>t.for((0,Ao._)`${m} = ${p}; ${m}--;`,()=>t.if((0,Ao._)`${v}(${n}[${p}], ${n}[${m}])`,()=>{e.error(),t.assign(l,!1).break(g)})))}}};B2.default=w1e;var V2={};Object.defineProperty(V2,"__esModule",{value:!0});const z2=Dn,k1e=Jn,x1e=ap,_1e={keyword:"const",$data:!0,error:{message:"must be equal to constant",params:({schemaCode:e})=>(0,z2._)`{allowedValue: ${e}}`},code(e){const{gen:t,data:n,$data:r,schemaCode:o,schema:i}=e;r||i&&typeof i=="object"?e.fail$data((0,z2._)`!${(0,k1e.useFunc)(t,x1e.default)}(${n}, ${o})`):e.fail((0,z2._)`${i} !== ${n}`)}};V2.default=_1e;var U2={};Object.defineProperty(U2,"__esModule",{value:!0});const sp=Dn,j1e=Jn,S1e=ap,C1e={keyword:"enum",schemaType:"array",$data:!0,error:{message:"must be equal to one of the allowed values",params:({schemaCode:e})=>(0,sp._)`{allowedValues: ${e}}`},code(e){const{gen:t,data:n,$data:r,schema:o,schemaCode:i,it:a}=e;if(!r&&o.length===0)throw new Error("enum must have non-empty array");const s=o.length>=a.opts.loopEnum;let l;const c=()=>l??(l=(0,j1e.useFunc)(t,S1e.default));let f;if(s||r)f=t.let("valid"),e.block$data(f,u);else{if(!Array.isArray(o))throw new Error("ajv implementation error");const h=t.const("vSchema",i);f=(0,sp.or)(...o.map((p,m)=>d(h,m)))}e.pass(f);function u(){t.assign(f,!1),t.forOf("v",i,h=>t.if((0,sp._)`${c()}(${n}, ${h})`,()=>t.assign(f,!0).break()))}function d(h,p){const m=o[p];return typeof m=="object"&&m!==null?(0,sp._)`${c()}(${n}, ${h}[${p}])`:(0,sp._)`${n} === ${m}`}}};U2.default=C1e,Object.defineProperty(O2,"__esModule",{value:!0});const $1e=A2,T1e=M2,E1e=P2,O1e=I2,A1e=D2,M1e=R2,P1e=L2,N1e=B2,I1e=V2,D1e=U2,R1e=[$1e.default,T1e.default,E1e.default,O1e.default,A1e.default,M1e.default,P1e.default,N1e.default,{keyword:"type",schemaType:["string","array"]},{keyword:"nullable",schemaType:"boolean"},I1e.default,D1e.default];O2.default=R1e;var q2={},qf={};Object.defineProperty(qf,"__esModule",{value:!0}),qf.validateAdditionalItems=void 0;const ru=Dn,H2=Jn,L1e={keyword:"additionalItems",type:"array",schemaType:["boolean","object"],before:"uniqueItems",error:{message:({params:{len:e}})=>(0,ru.str)`must NOT have more than ${e} items`,params:({params:{len:e}})=>(0,ru._)`{limit: ${e}}`},code(e){const{parentSchema:t,it:n}=e,{items:r}=t;if(!Array.isArray(r)){(0,H2.checkStrictMode)(n,'"additionalItems" is ignored when "items" is not an array of schemas');return}LF(e,r)}};function LF(e,t){const{gen:n,schema:r,data:o,keyword:i,it:a}=e;a.items=!0;const s=n.const("len",(0,ru._)`${o}.length`);if(r===!1)e.setParams({len:t.length}),e.pass((0,ru._)`${s} <= ${t.length}`);else if(typeof r=="object"&&!(0,H2.alwaysValidSchema)(a,r)){const c=n.var("valid",(0,ru._)`${s} <= ${t.length}`);n.if((0,ru.not)(c),()=>l(c)),e.ok(c)}function l(c){n.forRange("i",t.length,s,f=>{e.subschema({keyword:i,dataProp:f,dataPropType:H2.Type.Num},c),a.allErrors||n.if((0,ru.not)(c),()=>n.break())})}}qf.validateAdditionalItems=LF,qf.default=L1e;var W2={},Hf={};Object.defineProperty(Hf,"__esModule",{value:!0}),Hf.validateTuple=void 0;const BF=Dn,c0=Jn,B1e=Rn,F1e={keyword:"items",type:"array",schemaType:["object","array","boolean"],before:"uniqueItems",code(e){const{schema:t,it:n}=e;if(Array.isArray(t))return FF(e,"additionalItems",t);n.items=!0,!(0,c0.alwaysValidSchema)(n,t)&&e.ok((0,B1e.validateArray)(e))}};function FF(e,t,n=e.schema){const{gen:r,parentSchema:o,data:i,keyword:a,it:s}=e;f(o),s.opts.unevaluated&&n.length&&s.items!==!0&&(s.items=c0.mergeEvaluated.items(r,n.length,s.items));const l=r.name("valid"),c=r.const("len",(0,BF._)`${i}.length`);n.forEach((u,d)=>{(0,c0.alwaysValidSchema)(s,u)||(r.if((0,BF._)`${c} > ${d}`,()=>e.subschema({keyword:a,schemaProp:d,dataProp:d},l)),e.ok(l))});function f(u){const{opts:d,errSchemaPath:h}=s,p=n.length,m=p===u.minItems&&(p===u.maxItems||u[t]===!1);if(d.strictTuples&&!m){const v=`"${a}" is ${p}-tuple, but minItems or maxItems/${t} are not specified or different at path "${h}"`;(0,c0.checkStrictMode)(s,v,d.strictTuples)}}}Hf.validateTuple=FF,Hf.default=F1e,Object.defineProperty(W2,"__esModule",{value:!0});const V1e=Hf,z1e={keyword:"prefixItems",type:"array",schemaType:["array"],before:"uniqueItems",code:e=>(0,V1e.validateTuple)(e,"items")};W2.default=z1e;var K2={};Object.defineProperty(K2,"__esModule",{value:!0});const VF=Dn,U1e=Jn,q1e=Rn,H1e=qf,W1e={keyword:"items",type:"array",schemaType:["object","boolean"],before:"uniqueItems",error:{message:({params:{len:e}})=>(0,VF.str)`must NOT have more than ${e} items`,params:({params:{len:e}})=>(0,VF._)`{limit: ${e}}`},code(e){const{schema:t,parentSchema:n,it:r}=e,{prefixItems:o}=n;r.items=!0,!(0,U1e.alwaysValidSchema)(r,t)&&(o?(0,H1e.validateAdditionalItems)(e,o):e.ok((0,q1e.validateArray)(e)))}};K2.default=W1e;var G2={};Object.defineProperty(G2,"__esModule",{value:!0});const ra=Dn,u0=Jn,K1e={keyword:"contains",type:"array",schemaType:["object","boolean"],before:"uniqueItems",trackErrors:!0,error:{message:({params:{min:e,max:t}})=>t===void 0?(0,ra.str)`must contain at least ${e} valid item(s)`:(0,ra.str)`must contain at least ${e} and no more than ${t} valid item(s)`,params:({params:{min:e,max:t}})=>t===void 0?(0,ra._)`{minContains: ${e}}`:(0,ra._)`{minContains: ${e}, maxContains: ${t}}`},code(e){const{gen:t,schema:n,parentSchema:r,data:o,it:i}=e;let a,s;const{minContains:l,maxContains:c}=r;i.opts.next?(a=l===void 0?1:l,s=c):a=1;const f=t.const("len",(0,ra._)`${o}.length`);if(e.setParams({min:a,max:s}),s===void 0&&a===0){(0,u0.checkStrictMode)(i,'"minContains" == 0 without "maxContains": "contains" keyword ignored');return}if(s!==void 0&&a>s){(0,u0.checkStrictMode)(i,'"minContains" > "maxContains" is always invalid'),e.fail();return}if((0,u0.alwaysValidSchema)(i,n)){let m=(0,ra._)`${f} >= ${a}`;s!==void 0&&(m=(0,ra._)`${m} && ${f} <= ${s}`),e.pass(m);return}i.items=!0;const u=t.name("valid");s===void 0&&a===1?h(u,()=>t.if(u,()=>t.break())):a===0?(t.let(u,!0),s!==void 0&&t.if((0,ra._)`${o}.length > 0`,d)):(t.let(u,!1),d()),e.result(u,()=>e.reset());function d(){const m=t.name("_valid"),v=t.let("count",0);h(m,()=>t.if(m,()=>p(v)))}function h(m,v){t.forRange("i",0,f,g=>{e.subschema({keyword:"contains",dataProp:g,dataPropType:u0.Type.Num,compositeRule:!0},m),v()})}function p(m){t.code((0,ra._)`${m}++`),s===void 0?t.if((0,ra._)`${m} >= ${a}`,()=>t.assign(u,!0).break()):(t.if((0,ra._)`${m} > ${s}`,()=>t.assign(u,!1).break()),a===1?t.assign(u,!0):t.if((0,ra._)`${m} >= ${a}`,()=>t.assign(u,!0)))}}};G2.default=K1e;var zF={};(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.validateSchemaDeps=e.validatePropertyDeps=e.error=void 0;const t=Dn,n=Jn,r=Rn;e.error={message:({params:{property:l,depsCount:c,deps:f}})=>{const u=c===1?"property":"properties";return(0,t.str)`must have ${u} ${f} when property ${l} is present`},params:({params:{property:l,depsCount:c,deps:f,missingProperty:u}})=>(0,t._)`{property: ${l},
216
216
  missingProperty: ${u},
217
217
  depsCount: ${c},
218
- deps: ${f}}`};const o={keyword:"dependencies",type:"object",schemaType:"object",error:e.error,code(l){const[c,f]=i(l);a(l,c),s(l,f)}};function i({schema:l}){const c={},f={};for(const u in l){if(u==="__proto__")continue;const d=Array.isArray(l[u])?c:f;d[u]=l[u]}return[c,f]}function a(l,c=l.schema){const{gen:f,data:u,it:d}=l;if(Object.keys(c).length===0)return;const h=f.let("missing");for(const p in c){const m=c[p];if(m.length===0)continue;const v=(0,r.propertyInData)(f,u,p,d.opts.ownProperties);l.setParams({property:p,depsCount:m.length,deps:m.join(", ")}),d.allErrors?f.if(v,()=>{for(const g of m)(0,r.checkReportMissingProp)(l,g)}):(f.if((0,t._)`${v} && (${(0,r.checkMissingProp)(l,m,h)})`),(0,r.reportMissingProp)(l,h),f.else())}}e.validatePropertyDeps=a;function s(l,c=l.schema){const{gen:f,data:u,keyword:d,it:h}=l,p=f.name("valid");for(const m in c)(0,n.alwaysValidSchema)(h,c[m])||(f.if((0,r.propertyInData)(f,u,m,h.opts.ownProperties),()=>{const v=l.subschema({keyword:d,schemaProp:m},p);l.mergeValidEvaluated(v,p)},()=>f.var(p,!0)),l.ok(p))}e.validateSchemaDeps=s,e.default=o})(zF);var J2={};Object.defineProperty(J2,"__esModule",{value:!0});const UF=Dn,G1e=Jn,J1e={keyword:"propertyNames",type:"object",schemaType:["object","boolean"],error:{message:"property name must be valid",params:({params:e})=>(0,UF._)`{propertyName: ${e.propertyName}}`},code(e){const{gen:t,schema:n,data:r,it:o}=e;if((0,G1e.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,UF.not)(i),()=>{e.error(!0),o.allErrors||t.break()})}),e.ok(i)}};J2.default=J1e;var f0={};Object.defineProperty(f0,"__esModule",{value:!0});const d0=Rn,Fa=Dn,Q1e=js,h0=Jn,Y1e={keyword:"additionalProperties",type:["object"],schemaType:["boolean","object"],allowUndefined:!0,trackErrors:!0,error:{message:"must NOT have additional properties",params:({params:e})=>(0,Fa._)`{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:l}=a;if(a.props=!0,l.removeAdditional!=="all"&&(0,h0.alwaysValidSchema)(a,n))return;const c=(0,d0.allSchemaProperties)(r.properties),f=(0,d0.allSchemaProperties)(r.patternProperties);u(),e.ok((0,Fa._)`${i} === ${Q1e.default.errors}`);function u(){t.forIn("key",o,v=>{!c.length&&!f.length?p(v):t.if(d(v),()=>p(v))})}function d(v){let g;if(c.length>8){const y=(0,h0.schemaRefOrVal)(a,r.properties,"properties");g=(0,d0.isOwnProperty)(t,y,v)}else c.length?g=(0,Fa.or)(...c.map(y=>(0,Fa._)`${v} === ${y}`)):g=Fa.nil;return f.length&&(g=(0,Fa.or)(g,...f.map(y=>(0,Fa._)`${(0,d0.usePattern)(e,y)}.test(${v})`))),(0,Fa.not)(g)}function h(v){t.code((0,Fa._)`delete ${o}[${v}]`)}function p(v){if(l.removeAdditional==="all"||l.removeAdditional&&n===!1){h(v);return}if(n===!1){e.setParams({additionalProperty:v}),e.error(),s||t.break();return}if(typeof n=="object"&&!(0,h0.alwaysValidSchema)(a,n)){const g=t.name("valid");l.removeAdditional==="failing"?(m(v,g,!1),t.if((0,Fa.not)(g),()=>{e.reset(),h(v)})):(m(v,g),s||t.if((0,Fa.not)(g),()=>t.break()))}}function m(v,g,y){const w={keyword:"additionalProperties",dataProp:v,dataPropType:h0.Type.Str};y===!1&&Object.assign(w,{compositeRule:!0,createErrors:!1,allErrors:!1}),e.subschema(w,g)}}};f0.default=Y1e;var Q2={};Object.defineProperty(Q2,"__esModule",{value:!0});const X1e=Ra,qF=Rn,Y2=Jn,HF=f0,Z1e={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&&HF.default.code(new X1e.KeywordCxt(i,HF.default,"additionalProperties"));const a=(0,qF.allSchemaProperties)(n);for(const u of a)i.definedProperties.add(u);i.opts.unevaluated&&a.length&&i.props!==!0&&(i.props=Y2.mergeEvaluated.props(t,(0,Y2.toHash)(a),i.props));const s=a.filter(u=>!(0,Y2.alwaysValidSchema)(i,n[u]));if(s.length===0)return;const l=t.name("valid");for(const u of s)c(u)?f(u):(t.if((0,qF.propertyInData)(t,o,u,i.opts.ownProperties)),f(u),i.allErrors||t.else().var(l,!0),t.endIf()),e.it.definedProperties.add(u),e.ok(l);function c(u){return i.opts.useDefaults&&!i.compositeRule&&n[u].default!==void 0}function f(u){e.subschema({keyword:"properties",schemaProp:u,dataProp:u},l)}}};Q2.default=Z1e;var X2={};Object.defineProperty(X2,"__esModule",{value:!0});const WF=Rn,p0=Dn,KF=Jn,GF=Jn,ebe={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,WF.allSchemaProperties)(n),l=s.filter(m=>(0,KF.alwaysValidSchema)(i,n[m]));if(s.length===0||l.length===s.length&&(!i.opts.unevaluated||i.props===!0))return;const c=a.strictSchema&&!a.allowMatchingProperties&&o.properties,f=t.name("valid");i.props!==!0&&!(i.props instanceof p0.Name)&&(i.props=(0,GF.evaluatedPropsToName)(t,i.props));const{props:u}=i;d();function d(){for(const m of s)c&&h(m),i.allErrors?p(m):(t.var(f,!0),p(m),t.if(f))}function h(m){for(const v in c)new RegExp(m).test(v)&&(0,KF.checkStrictMode)(i,`property ${v} matches pattern ${m} (use allowMatchingProperties)`)}function p(m){t.forIn("key",r,v=>{t.if((0,p0._)`${(0,WF.usePattern)(e,m)}.test(${v})`,()=>{const g=l.includes(m);g||e.subschema({keyword:"patternProperties",schemaProp:m,dataProp:v,dataPropType:GF.Type.Str},f),i.opts.unevaluated&&u!==!0?t.assign((0,p0._)`${u}[${v}]`,!0):!g&&!i.allErrors&&t.if((0,p0.not)(f),()=>t.break())})})}}};X2.default=ebe;var Z2={};Object.defineProperty(Z2,"__esModule",{value:!0});const tbe=Jn,nbe={keyword:"not",schemaType:["object","boolean"],trackErrors:!0,code(e){const{gen:t,schema:n,it:r}=e;if((0,tbe.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"}};Z2.default=nbe;var e_={};Object.defineProperty(e_,"__esModule",{value:!0});const rbe={keyword:"anyOf",schemaType:"array",trackErrors:!0,code:Rn.validateUnion,error:{message:"must match a schema in anyOf"}};e_.default=rbe;var t_={};Object.defineProperty(t_,"__esModule",{value:!0});const m0=Dn,obe=Jn,ibe={keyword:"oneOf",schemaType:"array",trackErrors:!0,error:{message:"must match exactly one schema in oneOf",params:({params:e})=>(0,m0._)`{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),l=t.name("_valid");e.setParams({passing:s}),t.block(c),e.result(a,()=>e.reset(),()=>e.error(!0));function c(){i.forEach((f,u)=>{let d;(0,obe.alwaysValidSchema)(o,f)?t.var(l,!0):d=e.subschema({keyword:"oneOf",schemaProp:u,compositeRule:!0},l),u>0&&t.if((0,m0._)`${l} && ${a}`).assign(a,!1).assign(s,(0,m0._)`[${s}, ${u}]`).else(),t.if(l,()=>{t.assign(a,!0),t.assign(s,u),d&&e.mergeEvaluated(d,m0.Name)})})}}};t_.default=ibe;var n_={};Object.defineProperty(n_,"__esModule",{value:!0});const abe=Jn,sbe={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,abe.alwaysValidSchema)(r,i))return;const s=e.subschema({keyword:"allOf",schemaProp:a},o);e.ok(o),e.mergeEvaluated(s)})}};n_.default=sbe;var r_={};Object.defineProperty(r_,"__esModule",{value:!0});const v0=Dn,JF=Jn,lbe={keyword:"if",schemaType:["object","boolean"],trackErrors:!0,error:{message:({params:e})=>(0,v0.str)`must match "${e.ifClause}" schema`,params:({params:e})=>(0,v0._)`{failingKeyword: ${e.ifClause}}`},code(e){const{gen:t,parentSchema:n,it:r}=e;n.then===void 0&&n.else===void 0&&(0,JF.checkStrictMode)(r,'"if" without "then" and "else" is ignored');const o=QF(r,"then"),i=QF(r,"else");if(!o&&!i)return;const a=t.let("valid",!0),s=t.name("_valid");if(l(),e.reset(),o&&i){const f=t.let("ifClause");e.setParams({ifClause:f}),t.if(s,c("then",f),c("else",f))}else o?t.if(s,c("then")):t.if((0,v0.not)(s),c("else"));e.pass(a,()=>e.error(!0));function l(){const f=e.subschema({keyword:"if",compositeRule:!0,createErrors:!1,allErrors:!1},s);e.mergeEvaluated(f)}function c(f,u){return()=>{const d=e.subschema({keyword:f},s);t.assign(a,s),e.mergeValidEvaluated(d,a),u?t.assign(u,(0,v0._)`${f}`):e.setParams({ifClause:f})}}}};function QF(e,t){const n=e.schema[t];return n!==void 0&&!(0,JF.alwaysValidSchema)(e,n)}r_.default=lbe;var o_={};Object.defineProperty(o_,"__esModule",{value:!0});const cbe=Jn,ube={keyword:["then","else"],schemaType:["object","boolean"],code({keyword:e,parentSchema:t,it:n}){t.if===void 0&&(0,cbe.checkStrictMode)(n,`"${e}" without "if" is ignored`)}};o_.default=ube,Object.defineProperty(q2,"__esModule",{value:!0});const fbe=qf,dbe=W2,hbe=Hf,pbe=K2,mbe=G2,vbe=zF,gbe=J2,ybe=f0,bbe=Q2,wbe=X2,kbe=Z2,xbe=e_,_be=t_,jbe=n_,Sbe=r_,Cbe=o_;function $be(e=!1){const t=[kbe.default,xbe.default,_be.default,jbe.default,Sbe.default,Cbe.default,gbe.default,ybe.default,vbe.default,bbe.default,wbe.default];return e?t.push(dbe.default,pbe.default):t.push(fbe.default,hbe.default),t.push(mbe.default),t}q2.default=$be;var i_={},a_={};Object.defineProperty(a_,"__esModule",{value:!0});const Wr=Dn,Tbe={keyword:"format",type:["number","string"],schemaType:"string",$data:!0,error:{message:({schemaCode:e})=>(0,Wr.str)`must match format "${e}"`,params:({schemaCode:e})=>(0,Wr._)`{format: ${e}}`},code(e,t){const{gen:n,data:r,$data:o,schema:i,schemaCode:a,it:s}=e,{opts:l,errSchemaPath:c,schemaEnv:f,self:u}=s;if(!l.validateFormats)return;o?d():h();function d(){const p=n.scopeValue("formats",{ref:u.formats,code:l.code.formats}),m=n.const("fDef",(0,Wr._)`${p}[${a}]`),v=n.let("fType"),g=n.let("format");n.if((0,Wr._)`typeof ${m} == "object" && !(${m} instanceof RegExp)`,()=>n.assign(v,(0,Wr._)`${m}.type || "string"`).assign(g,(0,Wr._)`${m}.validate`),()=>n.assign(v,(0,Wr._)`"string"`).assign(g,m)),e.fail$data((0,Wr.or)(y(),w()));function y(){return l.strictSchema===!1?Wr.nil:(0,Wr._)`${a} && !${g}`}function w(){const k=f.$async?(0,Wr._)`(${m}.async ? await ${g}(${r}) : ${g}(${r}))`:(0,Wr._)`${g}(${r})`,$=(0,Wr._)`(typeof ${g} == "function" ? ${k} : ${g}.test(${r}))`;return(0,Wr._)`${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(l.strictSchema===!1){u.logger.warn($());return}throw new Error($());function $(){return`unknown format "${i}" ignored in schema at path "${c}"`}}function w($){const x=$ instanceof RegExp?(0,Wr.regexpCode)($):l.code.formats?(0,Wr._)`${l.code.formats}${(0,Wr.getProperty)(i)}`:void 0,E=n.scopeValue("formats",{key:i,ref:$,code:x});return typeof $=="object"&&!($ instanceof RegExp)?[$.type||"string",$.validate,(0,Wr._)`${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,Wr._)`await ${g}(${r})`}return typeof v=="function"?(0,Wr._)`${g}(${r})`:(0,Wr._)`${g}.test(${r})`}}}};a_.default=Tbe,Object.defineProperty(i_,"__esModule",{value:!0});const Ebe=[a_.default];i_.default=Ebe;var Wf={};Object.defineProperty(Wf,"__esModule",{value:!0}),Wf.contentVocabulary=Wf.metadataVocabulary=void 0,Wf.metadataVocabulary=["title","description","default","deprecated","readOnly","writeOnly","examples"],Wf.contentVocabulary=["contentMediaType","contentEncoding","contentSchema"],Object.defineProperty($2,"__esModule",{value:!0});const Obe=T2,Abe=O2,Mbe=q2,Pbe=i_,YF=Wf,Nbe=[Obe.default,Abe.default,(0,Mbe.default)(),Pbe.default,YF.metadataVocabulary,YF.contentVocabulary];$2.default=Nbe;var s_={},XF={};(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.DiscrError=void 0,function(t){t.Tag="tag",t.Mapping="mapping"}(e.DiscrError||(e.DiscrError={}))})(XF),Object.defineProperty(s_,"__esModule",{value:!0});const Kf=Dn,l_=XF,ZF=yi,Ibe=Jn,Dbe={keyword:"discriminator",type:"object",schemaType:"object",error:{message:({params:{discrError:e,tagName:t}})=>e===l_.DiscrError.Tag?`tag "${t}" must be string`:`value of tag "${t}" must be in oneOf`,params:({params:{discrError:e,tag:t,tagName:n}})=>(0,Kf._)`{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 l=t.let("valid",!1),c=t.const("tag",(0,Kf._)`${n}${(0,Kf.getProperty)(s)}`);t.if((0,Kf._)`typeof ${c} == "string"`,()=>f(),()=>e.error(!1,{discrError:l_.DiscrError.Tag,tag:c,tagName:s})),e.ok(l);function f(){const h=d();t.if(!1);for(const p in h)t.elseIf((0,Kf._)`${c} === ${p}`),t.assign(l,u(h[p]));t.else(),e.error(!1,{discrError:l_.DiscrError.Mapping,tag:c,tagName:s}),t.endIf()}function u(h){const p=t.name("valid"),m=e.subschema({keyword:"oneOf",schemaProp:h},p);return e.mergeEvaluated(m,Kf.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,Ibe.schemaHasRulesButRef)($,i.self.RULES)&&($=ZF.resolveRef.call(i.self,i.schemaEnv.root,i.baseId,$==null?void 0:$.$ref),$ instanceof ZF.SchemaEnv&&($=$.schema));const x=(h=$==null?void 0:$.properties)===null||h===void 0?void 0:h[s];if(typeof x!="object")throw new Error(`discriminator: oneOf subschemas (or referenced schemas) must have "properties/${s}"`);v=v&&(m||g($)),y(x,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 x of k.enum)w(x,$);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]=$}}}};s_.default=Dbe;const Rbe={$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=eF,r=$2,o=s_,i=Rbe,a=["/properties"],s="http://json-schema.org/draft-07/schema";class l 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=l,Object.defineProperty(t,"__esModule",{value:!0}),t.default=l;var c=Ra;Object.defineProperty(t,"KeywordCxt",{enumerable:!0,get:function(){return c.KeywordCxt}});var f=Dn;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=Zh;Object.defineProperty(t,"ValidationError",{enumerable:!0,get:function(){return u.default}});var d=ep;Object.defineProperty(t,"MissingRefError",{enumerable:!0,get:function(){return d.default}})})(h2,h2.exports);var Lbe=h2.exports;const Bbe=$_(Lbe);let lp;const Fbe=[["items",l9,c9],["achievements",Ype,E9],["screens",v9,g9],["skills",w9,k9],["skillChecks",O9,A9],["buttons",h9,p9],["scripts",YB,v0e],["audio",o9,i9],["quests",u9,f9],["tooltips",S9,C9],["characters",_9,j9]],Vbe=["baseAssetsPath","baseDataPath","gameTitle","saveFileName","images","layout","settings","gameFlow","dialogPanel","splashScreens","notifications","hudStats","interactionTags","transitions","menuButtons","debugging","saves"],Gf=new Bbe({allErrors:!0});async function zbe(e){const t={...Qc};for(const n of Vbe){const r=e[n];r&&(typeof r=="object"&&!Array.isArray(r)?t[n]={...t[n],...r}:t[n]=r)}for(const n of Fbe){const r=n[0],o=n[1],i=n[2];let a=e[r];if(a&&typeof a=="string")try{if(a=await Jg(rV(e.baseDataPath,a)),!Gf.validate(o,a))throw console.error(Gf.errors),new Error(`${Gf.errorsText()}`)}catch(s){console.error(s),Wt(`${r} config error: ${s}`),a={...i}}a&&(Array.isArray(a)?t[r]=a:typeof a=="object"?t[r]={...i,...a}:t[r]=a)}if(lp=t,e.skills&&e&&lp.transitions)for(const n in lp.transitions)Qg[n]?Object.assign(Qg[n],lp.transitions[n]):Qg[n]=lp.transitions[n];return t}async function Ube(e){const t=await Jg(e.configPath);return e.baseAssetsPath?t.baseAssetsPath=e.baseAssetsPath:t.baseAssetsPath=t.baseAssetsPath||"",e.baseDataPath?t.baseDataPath=e.baseDataPath:t.baseDataPath=t.baseDataPath||"",Gf.validate(ZB,t)||(Wt("Config file validation failed."),console.log(Gf.errors),Wt(Gf.errorsText())),zbe(t)}function wt(){return pi().config}function $s(){return wt().audio}function rl(){return wt().skills}function cp(){return wt().skillChecks}function g0(){return wt().items}function up(){return wt().quests}function c_(){return wt().screens}function u_(){return wt().buttons}function fp(){return wt().tooltips}function f_(){return wt().characters}function dp(e){return e===Wx?x9:c_().screens[e]?c_().screens[e]:(Wt(`Screen config for screen ${e} doesn't exist`),x9)}function eV(e){const n=fp().tooltips.find(r=>r.keywords.includes(e));return n||(Wt(`Tooltip config for keyword ${e} not found`),null)}function d_(e){const t=wt().skills.skills[e];return t||Wt(`Skill config for skill ${e} doesn't exist`),t}function tV(e){const t=wt().skillChecks.skillChecks[e];return t||Wt(`Skill check config for skill check ${e} doesn't exist`),t}function nV(e){return!!wt().skillChecks.skillChecks[e]}function hp(e){return e.startsWith("http")?e:wt().images[e]?oa(wt().images[e]):oa(e)}function oa(e){return e.startsWith("http")?e:wt().baseAssetsPath?`${wt().baseAssetsPath}${e}`:e}function rV(e,t){return`${e}${t}`}function h_(e){return wt().baseDataPath?`${wt().baseDataPath}${e}`:e}function Jf(e){const t=u_().buttons[e];return t||Wt(`Button config for button ${e} doesn't exist`),t}function ol(e){const t=g0().items[e];return t||Wt(`Item config for skill ${e} doesn't exist`),t}function Qf(){return wt().achievements}function p_(e){const t=Qf().achievements[e];return t||Wt(`Achievement config for achievement ${e} doesn't exist`),t}function ou(e){return up().quests[e]}function y0(e,t){return ou(e).objectives[t]}function b0(){return wt().dialogPanel.width??Hpe}function oV(e,t,n){if(!n.startsWith("$"))return isNaN(Number(n))?[null,n]:[null,Number(n)];n=n.substring(1);const r=/\[/,o=/\]/;let i=n.search(r);n.search(o);let a=n,s=t,l=0;for(;l<n.length;){if(i>l||i===-1){const c=i>l?i:n.length;let f=n.substring(l,c);isNaN(Number(f))||(f=Number(f)),l>0&&(s=s[a]),[s,a]=Hbe(s,f)}if(i!==-1){l=i;const c=n.substring(i+1),f=qbe(c)+i,u=n.substring(i+1,f),[d,h]=oV(e,e,u);let p=h;d&&(p=d[h]),typeof p=="number"||!isNaN(Number(p))?p=Number(p):typeof p!="string"&&console.error(`invalid array index (${p}) key type when compiling: ${n}`),s=s[a],a=p,l=f+1;const m=n.substring(l);i=m.search(r),i!==-1&&(i+=l),m.search(o)}else l=n.length}return[s,a]}function qbe(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&&Wt(`Could not find closing bracket in ${e}`)}return n}function Hbe(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 w0(e,t){return oV(e,e,t)}function Wbe(e,t){return w0(e,t)}function iV(e,t,n){const[r,o]=w0(e,t);r[o]=n}function aV(e,t,n){const[r,o]=w0(e,t),i=r[o]||0;r[o]=n+i}function Yf(){const e=an(),t=Dr(),n=Ia(),r=lo(),o=an().scope,i={data:e.data,global:e.globalData,skills:t.skills,skillChecks:t.skillChecks,buttons:n.buttons,items:r.items,quests:Fo().quests,stats:_s().hudStats,scope:o,config:wt(),gameOptions:Zt().options,baseSettings:Da().baseSettings,customSettings:Da().customSettings};return new Proxy(i,{get:(s,l,c)=>{const f=an().scope,u=an().data;return typeof f[l]<"u"?f[l]:typeof u[l]<"u"?u[l]:Reflect.get(s,l,c)},set:(s,l,c,f)=>{const u=an().scope,d=an().data;if(typeof u[l]<"u")u[l]=c;else{if(typeof s[l]<"u")return Reflect.set(s,l,c,f);typeof c=="object"?d[l]={}:d[l]=c}return!0}})}function or(e){if(e===null)return null;if(typeof e=="object")if(Array.isArray(e)){const t=[];for(const n in e)t[n]=or(e[n]);return t}else{const t={};for(const n in e)t[n]=or(e[n]);return t}else return e}function m_(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]=m_(e[o],t);return r}else{const r={};for(const o in e)r[o]=m_(e[o],t);return r}}else return t(e)}const Dr=ao("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:or(this.skillChecks),skills:or(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=Vh(this.skillChecks,e.skillChecks),this.skills=Vh(this.skills,e.skills)},setupSkills(e){const t=e.skills;for(const n in t)this.skills[n]={id:n,level:t[n].startingLevel||0,xp:0}},reset(e){this.$reset(),this.setupSkills(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||Wt(`Skill ${e} doesn't exist`),n.xp+=t,n.xp>=rl().skillOptions.xpPerLevel&&(n.xp=0,n.level++,this.levelledUp(e))},setSkillLevel(e,t){const n=this.getSkill(e);n||Wt(`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=rl().skills[e].name,n=this.skills[e].level;rl().skillOptions.notifyLevelUp&&vi().addNotification(`Your skill in ${t} is now level ${n}`)}}});function il(e){return Array.isArray?Array.isArray(e):cV(e)==="[object Array]"}const Kbe=1/0;function Gbe(e){if(typeof e=="string")return e;let t=e+"";return t=="0"&&1/e==-Kbe?"-0":t}function Jbe(e){return e==null?"":Gbe(e)}function Ts(e){return typeof e=="string"}function sV(e){return typeof e=="number"}function Qbe(e){return e===!0||e===!1||Ybe(e)&&cV(e)=="[object Boolean]"}function lV(e){return typeof e=="object"}function Ybe(e){return lV(e)&&e!==null}function Ni(e){return e!=null}function v_(e){return!e.trim().length}function cV(e){return e==null?e===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(e)}const YCe="Extended search is not available",Xbe="Incorrect 'index' type",Zbe=e=>`Invalid value for key ${e}`,ewe=e=>`Pattern length exceeds max of ${e}.`,twe=e=>`Missing ${e} property in key`,nwe=e=>`Property 'weight' in key '${e}' must be a positive integer`,uV=Object.prototype.hasOwnProperty;class rwe{constructor(t){this._keys=[],this._keyMap={};let n=0;t.forEach(r=>{let o=fV(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 fV(e){let t=null,n=null,r=null,o=1,i=null;if(Ts(e)||il(e))r=e,t=dV(e),n=g_(e);else{if(!uV.call(e,"name"))throw new Error(twe("name"));const a=e.name;if(r=a,uV.call(e,"weight")&&(o=e.weight,o<=0))throw new Error(nwe(a));t=dV(a),n=g_(a),i=e.getFn}return{path:t,id:n,weight:o,src:r,getFn:i}}function dV(e){return il(e)?e:e.split(".")}function g_(e){return il(e)?e.join("."):e}function owe(e,t){let n=[],r=!1;const o=(i,a,s)=>{if(Ni(i))if(!a[s])n.push(i);else{let l=a[s];const c=i[l];if(!Ni(c))return;if(s===a.length-1&&(Ts(c)||sV(c)||Qbe(c)))n.push(Jbe(c));else if(il(c)){r=!0;for(let f=0,u=c.length;f<u;f+=1)o(c[f],a,s+1)}else a.length&&o(c,a,s+1)}};return o(e,Ts(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:owe,ignoreLocation:!1,ignoreFieldNorm:!1,fieldNormWeight:1}};const iwe=/[^ ]+/g;function awe(e=1,t=3){const n=new Map,r=Math.pow(10,t);return{get(o){const i=o.match(iwe).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 y_{constructor({getFn:t=mn.getFn,fieldNormWeight:n=mn.fieldNormWeight}={}){this.norm=awe(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,Ts(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();Ts(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(!Ni(t)||v_(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(Ni(a)){if(il(a)){let s=[];const l=[{nestedArrIndex:-1,value:a}];for(;l.length;){const{nestedArrIndex:c,value:f}=l.pop();if(Ni(f))if(Ts(f)&&!v_(f)){let u={v:f,i:c,n:this.norm.get(f)};s.push(u)}else il(f)&&f.forEach((u,d)=>{l.push({nestedArrIndex:d,value:u})})}r.$[i]=s}else if(Ts(a)&&!v_(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 hV(e,t,{getFn:n=mn.getFn,fieldNormWeight:r=mn.fieldNormWeight}={}){const o=new y_({getFn:n,fieldNormWeight:r});return o.setKeys(e.map(fV)),o.setSources(t),o.create(),o}function swe(e,{getFn:t=mn.getFn,fieldNormWeight:n=mn.fieldNormWeight}={}){const{keys:r,records:o}=e,i=new y_({getFn:t,fieldNormWeight:n});return i.setKeys(r),i.setIndexRecords(o),i}function k0(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 lwe(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 iu=32;function cwe(e,t,n,{location:r=mn.location,distance:o=mn.distance,threshold:i=mn.threshold,findAllMatches:a=mn.findAllMatches,minMatchCharLength:s=mn.minMatchCharLength,includeMatches:l=mn.includeMatches,ignoreLocation:c=mn.ignoreLocation}={}){if(t.length>iu)throw new Error(ewe(iu));const f=t.length,u=e.length,d=Math.max(0,Math.min(r,u));let h=i,p=d;const m=s>1||l,v=m?Array(u):[];let g;for(;(g=e.indexOf(t,p))>-1;){let E=k0(t,{currentLocation:g,expectedLocation:d,distance:o,ignoreLocation:c});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,M=k;for(;R<M;)k0(t,{errors:E,currentLocation:d+M,expectedLocation:d,distance:o,ignoreLocation:c})<=h?R=M:k=M,M=Math.floor((k-R)/2+R);k=M;let j=Math.max(1,d-M+1),C=a?u:Math.min(d+M,u)+f,O=Array(C+2);O[C+1]=(1<<E)-1;for(let T=C;T>=j;T-=1){let L=T-1,H=n[e.charAt(L)];if(m&&(v[L]=+!!H),O[T]=(O[T+1]<<1|1)&H,E&&(O[T]|=(y[T+1]|y[T])<<1|1|y[T+1]),O[T]&$&&(w=k0(t,{errors:E,currentLocation:L,expectedLocation:d,distance:o,ignoreLocation:c}),w<=h)){if(h=w,p=L,p<=d)break;j=Math.max(1,2*d-p)}}if(k0(t,{errors:E+1,currentLocation:d,expectedLocation:d,distance:o,ignoreLocation:c})>h)break;y=O}const x={isMatch:p>=0,score:Math.max(.001,w)};if(m){const E=lwe(v,s);E.length?l&&(x.indices=E):x.isMatch=!1}return x}function uwe(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 pV{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:l=mn.isCaseSensitive,ignoreLocation:c=mn.ignoreLocation}={}){if(this.options={location:n,threshold:r,distance:o,includeMatches:i,findAllMatches:a,minMatchCharLength:s,isCaseSensitive:l,ignoreLocation:c},this.pattern=l?t:t.toLowerCase(),this.chunks=[],!this.pattern.length)return;const f=(d,h)=>{this.chunks.push({pattern:d,alphabet:uwe(d),startIndex:h})},u=this.pattern.length;if(u>iu){let d=0;const h=u%iu,p=u-h;for(;d<p;)f(this.pattern.substr(d,iu),d),d+=iu;if(h){const m=u-iu;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:l,ignoreLocation:c}=this.options;let f=[],u=0,d=!1;this.chunks.forEach(({pattern:p,alphabet:m,startIndex:v})=>{const{isMatch:g,score:y,indices:w}=cwe(t,p,m,{location:o+v,distance:i,threshold:a,findAllMatches:s,minMatchCharLength:l,includeMatches:r,ignoreLocation:c});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 nc{constructor(t){this.pattern=t}static isMultiMatch(t){return mV(t,this.multiRegex)}static isSingleMatch(t){return mV(t,this.singleRegex)}search(){}}function mV(e,t){const n=e.match(t);return n?n[1]:null}class fwe extends nc{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 dwe extends nc{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 hwe extends nc{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 pwe extends nc{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 mwe extends nc{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 vwe extends nc{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 vV extends nc{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:l=mn.isCaseSensitive,ignoreLocation:c=mn.ignoreLocation}={}){super(t),this._bitapSearch=new pV(t,{location:n,threshold:r,distance:o,includeMatches:i,findAllMatches:a,minMatchCharLength:s,isCaseSensitive:l,ignoreLocation:c})}static get type(){return"fuzzy"}static get multiRegex(){return/^"(.*)"$/}static get singleRegex(){return/^(.*)$/}search(t){return this._bitapSearch.searchIn(t)}}class gV extends nc{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 b_=[fwe,gV,hwe,pwe,vwe,mwe,dwe,vV],yV=b_.length,gwe=/ +(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/,ywe="|";function bwe(e,t={}){return e.split(ywe).map(n=>{let r=n.trim().split(gwe).filter(i=>i&&!!i.trim()),o=[];for(let i=0,a=r.length;i<a;i+=1){const s=r[i];let l=!1,c=-1;for(;!l&&++c<yV;){const f=b_[c];let u=f.isMultiMatch(s);u&&(o.push(new f(u,t)),l=!0)}if(!l)for(c=-1;++c<yV;){const f=b_[c];let u=f.isSingleMatch(s);if(u){o.push(new f(u,t));break}}}return o})}const wwe=new Set([vV.type,gV.type]);class kwe{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:l=mn.threshold,distance:c=mn.distance}={}){this.query=null,this.options={isCaseSensitive:n,includeMatches:r,minMatchCharLength:o,findAllMatches:a,ignoreLocation:i,location:s,threshold:l,distance:c},this.pattern=n?t:t.toLowerCase(),this.query=bwe(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 l=0,c=n.length;l<c;l+=1){const f=n[l];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;wwe.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 w_=[];function xwe(...e){w_.push(...e)}function k_(e,t){for(let n=0,r=w_.length;n<r;n+=1){let o=w_[n];if(o.condition(e,t))return new o(e,t)}return new pV(e,t)}const x0={AND:"$and",OR:"$or"},x_={PATH:"$path",PATTERN:"$val"},__=e=>!!(e[x0.AND]||e[x0.OR]),_we=e=>!!e[x_.PATH],jwe=e=>!il(e)&&lV(e)&&!__(e),bV=e=>({[x0.AND]:Object.keys(e).map(t=>({[t]:e[t]}))});function wV(e,t,{auto:n=!0}={}){const r=o=>{let i=Object.keys(o);const a=_we(o);if(!a&&i.length>1&&!__(o))return r(bV(o));if(jwe(o)){const l=a?o[x_.PATH]:i[0],c=a?o[x_.PATTERN]:o[l];if(!Ts(c))throw new Error(Zbe(l));const f={keyId:g_(l),pattern:c};return n&&(f.searcher=k_(c,t)),f}let s={children:[],operator:i[0]};return i.forEach(l=>{const c=o[l];il(c)&&c.forEach(f=>{s.children.push(r(f))})}),s};return __(e)||(e=bV(e)),r(e)}function Swe(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 Cwe(e,t){const n=e.matches;t.matches=[],Ni(n)&&n.forEach(r=>{if(!Ni(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 $we(e,t){t.score=e.score}function Twe(e,t,{includeMatches:n=mn.includeMatches,includeScore:r=mn.includeScore}={}){const o=[];return n&&o.push(Cwe),r&&o.push($we),e.map(i=>{const{idx:a}=i,s={item:t[a],refIndex:a};return o.length&&o.forEach(l=>{l(i,s)}),s})}class Xf{constructor(t,n={},r){this.options={...mn,...n},this.options.useExtendedSearch,this._keyStore=new rwe(this.options.keys),this.setCollection(t,r)}setCollection(t,n){if(this._docs=t,n&&!(n instanceof y_))throw new Error(Xbe);this._myIndex=n||hV(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight})}add(t){Ni(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 l=Ts(t)?Ts(this._docs[0])?this._searchStringList(t):this._searchObjectList(t):this._searchLogical(t);return Swe(l,{ignoreFieldNorm:s}),i&&l.sort(a),sV(n)&&n>-1&&(l=l.slice(0,n)),Twe(l,this._docs,{includeMatches:r,includeScore:o})}_searchStringList(t){const n=k_(t,this.options),{records:r}=this._myIndex,o=[];return r.forEach(({v:i,i:a,n:s})=>{if(!Ni(i))return;const{isMatch:l,score:c,indices:f}=n.searchIn(i);l&&o.push({item:i,idx:a,matches:[{score:c,value:i,norm:s,indices:f}]})}),o}_searchLogical(t){const n=wV(t,this.options),r=(s,l,c)=>{if(!s.children){const{keyId:u,searcher:d}=s,h=this._findMatches({key:this._keyStore.get(u),value:this._myIndex.getValueForItemAtKeyId(l,u),searcher:d});return h&&h.length?[{idx:c,item:l,matches:h}]:[]}const f=[];for(let u=0,d=s.children.length;u<d;u+=1){const h=s.children[u],p=r(h,l,c);if(p.length)f.push(...p);else if(s.operator===x0.AND)return[]}return f},o=this._myIndex.records,i={},a=[];return o.forEach(({$:s,i:l})=>{if(Ni(s)){let c=r(n,s,l);c.length&&(i[l]||(i[l]={idx:l,item:s,matches:[]},a.push(i[l])),c.forEach(({matches:f})=>{i[l].matches.push(...f)}))}}),a}_searchObjectList(t){const n=k_(t,this.options),{keys:r,records:o}=this._myIndex,i=[];return o.forEach(({$:a,i:s})=>{if(!Ni(a))return;let l=[];r.forEach((c,f)=>{l.push(...this._findMatches({key:c,value:a[f],searcher:n}))}),l.length&&i.push({idx:s,item:a,matches:l})}),i}_findMatches({key:t,value:n,searcher:r}){if(!Ni(n))return[];let o=[];if(il(n))n.forEach(({v:i,i:a,n:s})=>{if(!Ni(i))return;const{isMatch:l,score:c,indices:f}=r.searchIn(i);l&&o.push({score:c,key:t,value:i,idx:a,norm:s,indices:f})});else{const{v:i,n:a}=n,{isMatch:s,score:l,indices:c}=r.searchIn(i);s&&o.push({score:l,key:t,value:i,norm:a,indices:c})}return o}}Xf.version="6.6.2",Xf.createIndex=hV,Xf.parseIndex=swe,Xf.config=mn,Xf.parseQuery=wV,xwe(kwe);class Ewe extends d2{setup(){const t=()=>{this.emit("preUpdate"),this.emit("update"),this.emit("postUpdate"),requestAnimationFrame(t)};t()}}const _0=new Ewe;ut.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 l(p,m){return{x:p.x/m.x,y:p.y/m.y}}e.divide=l;function c(p,m){return n(i(p,m))}e.distance=c;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})(ut.Vec2||(ut.Vec2={}));class Owe{constructor(){ro(this,"gameActions",{});ro(this,"keyboardState",{});ro(this,"actions",{});ro(this,"gamepad",null)}getGamepad(){const t=navigator.getGamepads().filter(n=>n!==null);if(t.length>0)return t[0]}startListening(){this.updateGamepad(),window.addEventListener("keydown",t=>{console.log("keydown",t.key);const n=this.getKeyboardState(t.key).current;this.keyboardState[t.key]={previous:n,current:!0}}),window.addEventListener("keyup",t=>{console.log("keyup",t.key);const n=this.getKeyboardState(t.key).current;this.keyboardState[t.key]={previous:n,current:!1}}),_0.on("preUpdate",()=>{this.update()})}updateGamepad(){const t=this.getGamepad();t?this.gamepad?this.updateAllNarratButtons(t,this.gamepad):this.gamepad=this.setupNarratGamepad(t):this.gamepad=null}setupNarratGamepad(t){return{id:t.id,gamepad:t,buttons:t.buttons.map((r,o)=>this.getNarratButtonFromGamepad(r,r,o))}}updateAllNarratButtons(t,n){for(const[r,o]of t.buttons.entries()){const i=n.buttons[r];i.previous=or(i.state),i.state=or(o)}}getNarratButtonFromGamepad(t,n,r){return{index:r,state:or(n),previous:or(n)}}addAction(t){if(this.gameActions[t.id]=t,t.type==="button"){const n={config:t,active:!1,justPressed:!1,justReleased:!1};this.actions[t.id]={state:n,previous:or(n)}}else{const n={config:t,value:ut.Vec2.create(0,0),fullState:{left:0,right:0,up:0,down:0}};this.actions[t.id]={state:n,previous:or(n)}}}getAnalog(t){return this.actions[t]||Wt(`Action ${t} does not exist`),this.actions[t].state}getButton(t){return this.actions[t]||Wt(`Action ${t} does not exist`),this.actions[t].state}getKeyboardState(t){return this.keyboardState[t]?this.keyboardState[t]:(this.keyboardState[t]={current:!1,previous:!1},this.keyboardState[t])}getGamepadState(t){return this.gamepad&&this.gamepad.buttons.length>t?{current:this.gamepad.buttons[t].state,previous:this.gamepad.buttons[t].previous}:null}debugGamepad(){if(this.gamepad)for(const[t,n]of this.gamepad.buttons.entries())n.state.pressed,n.previous.pressed}update(){this.updateGamepad(),this.debugGamepad();for(const t of Object.values(this.gameActions))if(t.type==="button"){const n=this.actions[t.id],r=or(n.state),o=n.state;n.previous=r,t.action==="press"&&(t.keybinds.some(a=>{let s=!1;if(typeof a.keyboardKey=="string"&&this.getKeyboardState(a.keyboardKey).current===!0&&(s=!0),typeof a.gamepadButton=="number"){const l=this.getGamepadState(a.gamepadButton);l&&l.current.pressed===!0&&(s=!0)}return s})?o.active=!0:o.active=!1,o.active&&!r.active?o.justPressed=!0:o.justPressed=!1,!o.active&&r.active?o.justReleased=!0:o.justReleased=!1)}else if(t.type==="analog"){const n=this.actions[t.id],r=n.state;or(n.state),n.previous=or(r);let o=ut.Vec2.create(0,0);t.keybinds.forEach(i=>{this.getKeyboardState(i.left).current&&(r.fullState.left=1,o.x-=1),this.getKeyboardState(i.right).current&&(r.fullState.right=1,o.x+=1),this.getKeyboardState(i.up).current&&(r.fullState.up=1,o.y-=1),this.getKeyboardState(i.down).current&&(r.fullState.down=1,o.y+=1)}),o=ut.Vec2.normalize(o),r.value=o}}}const j0=new Owe,Awe=[{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:"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}]}],zo=ao("inputs",{state:()=>({inputStack:[],baseInputListener:null}),actions:{setupInputs(){j0.startListening();for(const e of Awe)j0.addAction(e);this.listenToBaseNarratInputs(),_0.on("preUpdate",()=>{for(const[e,t]of Object.entries(j0.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})},listenToBaseNarratInputs(){},triggerListeners(e,t,n){console.log(`Triggering action ${e} ${t}`);const r=this.inputStack[this.inputStack.length-1];if(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 j0},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}}}),Mwe=b.createElementVNode("h3",{class:"title"},"Jump to label",-1),Pwe={key:0,class:"search-results"},Nwe={key:1},Iwe=[b.createElementVNode("h3",null,"No matches found",-1)],Dwe=b.defineComponent({__name:"debug-jumping",emits:["close","jump"],setup(e,{emit:t}){let n;const r=b.ref(null),o=b.ref(""),i=b.ref([]),a=b.ref(0),s=b.ref(null);function l(){const u=o.value,d=n.search(u);i.value=d.map(h=>h.item),i.value.length>0&&a.value>i.value.length-1&&(a.value=i.value.length-1)}function c(u){if(u===a.value)return{background:"var(--light-background)"}}const f=b.computed(()=>Object.keys(bn.script).sort());return b.onMounted(()=>{Zt().debugMode=!0,n=new Xf(f.value,{includeScore:!0}),i.value=f.value,a.value=0,setTimeout(()=>{b.nextTick(()=>{s.value&&s.value.focus()})},10),r.value=zo().registerInputListener("debug-jumping",{up:{press:()=>{a.value>0?a.value--:a.value=i.value.length-1}},down:{press:()=>{i.value.length>a.value+1?a.value++:a.value=0}},continue:{press:()=>{if(i.value.length>0&&a.value<i.value.length){const u=i.value[a.value];an().jumpToLabel(u),t("close")}}},escape:{press:()=>{t("close")}}})}),b.onUnmounted(()=>{r.value&&zo().unregisterInputListener(r.value),Zt().debugMode=!1}),(u,d)=>(b.openBlock(),b.createBlock(al,{onClose:d[1]||(d[1]=h=>u.$emit("close")),containerCssClass:"jump-menu-container"},{header:b.withCtx(()=>[Mwe]),body:b.withCtx(()=>[b.withDirectives(b.createElementVNode("input",{type:"text",class:"label-input input",ref_key:"search",ref:s,"onUpdate:modelValue":d[0]||(d[0]=h=>o.value=h),onInput:l},null,544),[[b.vModelText,o.value]]),i.value.length>0?(b.openBlock(),b.createElementBlock("div",Pwe,[(b.openBlock(!0),b.createElementBlock(b.Fragment,null,b.renderList(i.value,(h,p)=>(b.openBlock(),b.createElementBlock("div",{class:"search-result",style:b.normalizeStyle(c(p)),key:p},b.toDisplayString(h),5))),128))])):(b.openBlock(),b.createElementBlock("div",Nwe,Iwe))]),_:1}))}}),r$e="",Rwe=b.defineComponent({components:{ModalWindow:al,DebugJumping:Dwe},setup(){const e=Dr(),t=b.computed(()=>e.skills),n=b.computed(()=>e.skillChecks);return{skills:t,skillChecks:n}},data(){return{showDebug:!1,jumping:!1,inputListener:null}},mounted(){window.addEventListener("keydown",e=>{this.jumping||(e.key==="d"&&this.toggle(),e.key==="j"&&this.jump())})},methods:{closeJumping(){this.jumping=!1},labelSelected(e){const t=e.target.value;an().jumpToLabel(t),this.close()},close(){this.showDebug=!1,this.endDebug()},closeErrors(){Zt().clearErrors()},open(){this.showDebug=!0,this.startDebug();const e=an(),t=Zt(),n=Fo(),r=lo(),o=Dr();this.$nextTick(()=>{new xL({target:this.$refs.variablesViewer,props:{content:{text:void 0,json:{data:this.variables,quests:n.quests,items:r.items,skills:o.skills,skillChecks:o.skillChecks}},onChange:i=>{e.overrideData(i.json.data),n.quests=i.json.quests,r.items=i.json.items,o.skills=i.json.skills,o.skillChecks=i.json.skillChecks}}}),new xL({target:this.$refs.stateViewer,props:{content:{text:void 0,json:t.getAllStates()},onChange:i=>{t.overrideStates(i.json)}}})})},toggle(){this.showDebug?this.close():this.open()},startDebug(){Zt().debugMode=!0},endDebug(){Zt().debugMode=!1},jump(){this.jumping=!0,this.startDebug()},save(){Zt().autoSaveGame({})},resetSave(){cpe()},resetGlobalSave(){Zt().resetGlobalSave()},wordCount(){const t=Object.values(this.script).reduce((n,r)=>(ki.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 O0(e/1e3)}},computed:{...Kc(an,["data"]),...Kc(Zt,["playTime","errors","playing","flowState"]),labels(){const e=this.script;return Object.keys(e).sort()},script(){return bn.script},variables(){return this.data}}}),o$e="",Lwe={class:"debug-menu"},Bwe={key:0,class:"debug-info"},Fwe=[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)],Vwe=b.createElementVNode("h3",{class:"title"},"Error(s)",-1),zwe=["innerHTML"],Uwe=b.createElementVNode("h3",{class:"title"},"Debug Menu!",-1),qwe={class:"container"},Hwe=b.createElementVNode("option",{class:"option",selected:"",disabled:""},"Jump to a label",-1),Wwe=["value"],Kwe={class:"grid grid-cols-3 gap-4"},Gwe=b.createElementVNode("h2",null,"Variables Editor",-1),Jwe={ref:"variablesViewer"},Qwe=b.createElementVNode("h2",null,"Skill Checks",-1),Ywe={class:"table-auto"},Xwe=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),Zwe=b.createElementVNode("h2",null,"App State editor (entire app and engine",-1),eke=b.createElementVNode("h3",{style:{color:"pink"}}," Use for debugging, editing some of those things can cause issues ",-1),tke={ref:"stateViewer"};function nke(e,t,n,r,o,i){const a=b.resolveComponent("DebugJumping"),s=b.resolveComponent("ModalWindow");return b.openBlock(),b.createElementBlock("div",Lwe,[b.createElementVNode("button",{onClick:t[0]||(t[0]=(...l)=>e.open&&e.open(...l)),class:"button debug-button"},"Debug Menu"),!e.playing&&e.flowState==="menu"?(b.openBlock(),b.createElementBlock("div",Bwe,Fwe)):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(()=>[Vwe]),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,(l,c)=>(b.openBlock(),b.createElementBlock("li",{key:c,class:b.normalizeClass(["error-message list-disc",l.type==="error"?"error":"warning"]),innerHTML:l.text},null,10,zwe))),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(()=>[Uwe]),body:b.withCtx(()=>[b.createElementVNode("div",qwe,[b.createTextVNode(" Hello this is the debug menu. "),b.createElementVNode("select",{class:"select",name:"label-selector",onChange:t[1]||(t[1]=l=>e.labelSelected(l))},[Hwe,(b.openBlock(!0),b.createElementBlock(b.Fragment,null,b.renderList(e.labels,l=>(b.openBlock(),b.createElementBlock("option",{class:"option",value:l,key:l},b.toDisplayString(l),9,Wwe))),128))],32),b.createElementVNode("div",Kwe,[b.createElementVNode("button",{onClick:t[2]||(t[2]=(...l)=>e.wordCount&&e.wordCount(...l)),class:"button"},"Word Count"),b.createElementVNode("button",{onClick:t[3]||(t[3]=(...l)=>e.save&&e.save(...l)),class:"button"},"Save Game"),b.createElementVNode("button",{onClick:t[4]||(t[4]=(...l)=>e.resetSave&&e.resetSave(...l)),class:"button"},"Reset Save"),b.createElementVNode("button",{onClick:t[5]||(t[5]=(...l)=>e.resetGlobalSave&&e.resetGlobalSave(...l)),class:"button"}," Reset GLOBAL Save ")]),b.createElementVNode("h3",null,"Play time: "+b.toDisplayString(e.getPlayTimeString()),1),Gwe,b.createElementVNode("div",Jwe,null,512),Qwe,b.createElementVNode("table",Ywe,[Xwe,b.createElementVNode("tbody",null,[(b.openBlock(!0),b.createElementBlock(b.Fragment,null,b.renderList(e.skillChecks,(l,c)=>(b.openBlock(),b.createElementBlock("tr",{key:c},[b.createElementVNode("td",null,b.toDisplayString(c),1),b.createElementVNode("td",null,b.toDisplayString(l.happened?"✅":"❌"),1),b.createElementVNode("td",null,b.toDisplayString(l.happened?l.succeeded?"✅":"❌":"NA"),1)]))),128))])]),Zwe,eke,b.createElementVNode("div",tke,null,512)])]),_:1},8,["onClose"])):b.createCommentVNode("",!0)])}const rke=la(Rwe,[["render",nke]]),oke=["src"],ike=["innerHTML"],ake=["innerHTML"],ske=b.defineComponent({__name:"notification-toast",setup(e){const t=vi(),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(oa)(a.icon),class:"notification-icon",style:b.normalizeStyle(r(a))},null,12,oke)):b.createCommentVNode("",!0),b.createElementVNode("span",{innerHTML:a.text,class:"notification-text"},null,8,ike),a.description?(b.openBlock(),b.createElementBlock("p",{key:1,innerHTML:a.description,class:"notification-description"},null,8,ake)):b.createCommentVNode("",!0)]))),128))]),_:1}))}}),a$e="";function kV(e,t=50,n={}){let r;const o=n.isImmediate??!1,i=n.callback??!1,a=n.maxWait;let s=Date.now(),l=[];function c(){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),l.forEach(({resolve:w})=>w(y)),l=[]}},v=o&&r===void 0;r!==void 0&&clearTimeout(r);const g=c();if(r=setTimeout(m,g),v){const y=e.apply(d,u);return i&&i(y),h(y)}l.push({resolve:h,reject:p})})};return f.cancel=function(u){r!==void 0&&clearTimeout(r),l.forEach(({reject:d})=>d(u)),l=[]},f}function pp(e){if(!e.listener)return console.warn("No input listener provided for navigation"),null;const t=b.ref(0),n=b.computed(()=>e.mode==="grid"?t.value%e.columns:0),r=b.ref([]);function o(){var $,x;return($=e.container)!=null&&$.value?e.container.value.children:(x=e.elements)!=null&&x.value?e.elements.value.filter(E=>E!==null):[]}function i(){r.value=o()}const a=b.computed(()=>c(t.value));function s($){return r.value?$>=0&&$<r.value.length:!1}function l($){const x=t.value;s($)&&(t.value=$,a.value&&(a.value.classList.add("selected"),c(x).classList.remove("selected"),e.onSelected&&e.onSelected($)))}function c($){return r.value?r.value[$]:null}function f(){r.value&&(t.value===0?e.loopForbidden||l(r.value.length-1):l(t.value-1))}function u(){r.value&&(t.value===r.value.length-1?e.loopForbidden||l(0):l(t.value+1))}function d(){if(!r.value)return;const $=e,x=t.value;!e.loopForbidden&&x<$.columns?l(r.value.length-1):l(t.value-e.columns)}function h(){if(!r.value)return;const $=e,x=t.value;!e.loopForbidden&&x>=r.value.length-$.columns?l(0):l(t.value+e.columns)}function p(){e.mode==="grid"?d():e.mode==="list"&&f()}function m(){e.mode==="grid"?h():e.mode==="list"&&(console.log("button down"),u())}function v(){(e.mode==="grid"||e.mode==="list")&&f()}function g(){(e.mode==="grid"||e.mode==="list")&&u()}function y(){e.onChosen&&e.onChosen(t.value)}b.onMounted(()=>{k()});function w(){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)}function k(){e.listener&&(i(),e.onlyVertical||(e.listener.actions.left={press:v},e.listener.actions.right={press:g}),e.onlyHorizontal||(e.listener.actions.up={press:p},e.listener.actions.down={press:m}),e.noChoosing||(e.listener.actions.continue={press:y}),l(0))}return b.onUnmounted(()=>{w()}),b.watch(()=>{var $;return($=e.elements)==null?void 0:$.value},$=>{$&&i()}),{selectedIndex:t,selectedElement:a,currentColumn:n,buttonDown:m,buttonUp:p,buttonLeft:v,buttonRight:g,selectUp:d,selectDown:h,selectPrevious:f,selectNext:u,select:l,disable:w,mount:k}}const lke={class:"used-save-slot flex flex-row justify-between items-center grow"},cke={class:"flex flex-col save-slot-number-container"},uke={class:"save-slot-number"},fke={class:"flex flex-col justify-center save-info"},dke={key:1,class:"save-name"},hke={class:"flex flex-col"},pke={key:0},mke={key:1},vke={key:2},gke=["onClick"],j_=b.defineComponent({__name:"save-slot-ui",props:{saveSlot:{},id:{},actions:{},selected:{type:Boolean},inputListener:{}},emits:["choice","cancel"],setup(e,{expose:t,emit:n}){var w;const r=e,o=b.ref(null),i=b.ref(null),a=b.ref(null);t({slotContainer:a});const s=b.ref(((w=r.saveSlot.saveData)==null?void 0:w.metadata.name)??"Empty Save"),l=b.ref(0),c=b.computed(()=>r.saveSlot.saveData!==null),f=b.computed(()=>r.saveSlot.saveData),u=b.computed(()=>wt().saves.mode),d=b.computed(()=>{const k=r.saveSlot.saveData;if(k&&k.screen.layers[0]){const $=dp(k.screen.layers[0]);if($)return{backgroundImage:`url(${hp($.background)})`}}return!1});function h(k){n("choice",k)}function p(k){return f.value?O0(f.value.main.playTime/1e3):"00:00:00"}function m(){f.value&&mpe(r.saveSlot.id,s.value)}function v(){const k=wt().saves.slots;let $="";const x=r.saveSlot.slotNumber;return x===0&&wt().saves.mode==="manual"?"AUTO":(k>=10&&x<10&&($+="0"),k>=100&&x<100&&($+="0"),$+x)}function g(){o.value=pp({mode:"list",container:i,listener:r.inputListener,onlyHorizontal:!0,onSelected:k=>{l.value=k},onChosen:k=>{h(k)}}),o.value.mount()}function y(){o.value.disable(),o.value=null}return b.watch(()=>r.selected,(k,$)=>{k&&!o.value&&g(),!k&&o.value&&y()}),b.onUnmounted(()=>{o.value&&y()}),(k,$)=>(b.openBlock(),b.createElementBlock("div",{class:"save-slot flex flex-row",ref_key:"slotContainer",ref:a},[b.createElementVNode("div",lke,[b.createElementVNode("div",cke,[b.createElementVNode("h1",uke,b.toDisplayString(v()),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",fke,[c.value?b.withDirectives((b.openBlock(),b.createElementBlock("input",{key:0,type:"text",class:"save-name","onUpdate:modelValue":$[0]||($[0]=x=>s.value=x),onInput:m},null,544)),[[b.vModelText,s.value]]):(b.openBlock(),b.createElementBlock("h3",dke,b.toDisplayString(s.value),1)),b.createElementVNode("div",hke,[f.value?(b.openBlock(),b.createElementBlock("p",pke,b.toDisplayString(new Date(f.value.metadata.saveDate).toLocaleString()),1)):b.createCommentVNode("",!0),f.value?(b.openBlock(),b.createElementBlock("p",mke,"Play time: "+b.toDisplayString(p(k.saveSlot)),1)):b.createCommentVNode("",!0),u.value==="game-slots"?(b.openBlock(),b.createElementBlock("p",vke,b.toDisplayString(k.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(k.actions,(x,E)=>(b.openBlock(),b.createElementBlock("button",{class:b.normalizeClass(["button",{selected:k.selected&&E===l.value}]),onClick:()=>h(E),key:E},[b.createElementVNode("h3",null,b.toDisplayString(x),1)],10,gke))),128))],512)])],512))}}),s$e="",yke=b.createElementVNode("h3",{class:"title"},"Confirmation",-1),S0=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=e,r=b.ref(zo().registerInputListener("yes-no",{cancel:{press:()=>{i(!1)}},continue:{press:()=>{i(!0)}}})),o=b.ref(null);pp({mode:"list",container:o,listener:r.value,onChosen:a=>{i(a===0)}});function i(a){a===!0&&n.onConfirm?n.onConfirm():a===!1&&n.onRefuse&&n.onRefuse(),t("choice",a)}return b.onMounted(()=>{}),b.onUnmounted(()=>{r.value&&zo().unregisterInputListener(r.value)}),(a,s)=>(b.openBlock(),b.createBlock(al,{onClose:s[2]||(s[2]=()=>i(!1)),containerCssClass:"yes-no-modal"},{header:b.withCtx(()=>[yke]),body:b.withCtx(()=>[b.createElementVNode("h3",null,b.toDisplayString(e.prompt),1),b.createElementVNode("div",{class:"flex justify-center",ref_key:"buttonsContainer",ref:o},[b.createElementVNode("button",{class:"button",onClick:s[0]||(s[0]=()=>i(!0))},"Yes"),b.createElementVNode("button",{class:"button",onClick:s[1]||(s[1]=()=>i(!1))},"No")],512)]),_:1}))}}),l$e="",bke={class:"title"},wke={key:0},kke={class:"saves-section"},xke=b.createElementVNode("h3",{class:"saves-section-title"},"Auto save",-1),_ke={class:"saves-section"},jke=b.createElementVNode("h3",{class:"saves-section-title"},"Manual Saves",-1),Ske={key:1,class:"saves-section"},Cke=b.createElementVNode("h3",{class:"saves-section-title"},"Save Slots",-1),$ke={class:"saves-container flex flex-col"},xV=b.defineComponent({__name:"save-slots",props:{mode:{}},emits:["chosen","close"],setup(e,{emit:t}){const n=e,r=b.ref(zo().registerInputListener("save-slots",{cancel:{press:()=>{E()}}})),o=b.ref(0),i=b.reactive([]),a=b.computed(()=>i.slice(0,1)),s=b.computed(()=>i.slice(1)),l=b.ref([]),c=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:j=>{o.value=j}});const h=pp({mode:"list",elements:u,listener:r.value,onlyVertical:!0,noChoosing:!0,onSelected:j=>{o.value=j}}),p=b.computed(()=>{const j=o.value;return d.value.length<j+1?null:d.value[j].id}),m=b.reactive(n.mode==="load"?["Load","Delete"]:["Choose"]),v=b.computed(()=>wt().saves.mode),g=b.reactive({prompt:"Are you sure you want to delete this save file?",saveToDelete:null,onConfirm:()=>{x(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:()=>{k(y.saveToOverwrite),y.saveToOverwrite=null},onRefuse:()=>{y.saveToOverwrite=null}});b.onBeforeMount(()=>{const C=Xs().slots;console.log(C),C.forEach((O,F)=>{i[F]=O})});function w(){console.log(c.value),u.value=v.value==="manual"?[...c.value.map(C=>C.slotContainer),...f.value.map(C=>C.slotContainer)]:l.value.map(C=>C.slotContainer);const j=v.value==="manual"?[...a.value,...s.value]:i;d.value=j.map(C=>({id:C.id}))}b.onMounted(()=>{w()}),b.onUnmounted(()=>{h.value&&(h.value.disable(),h.value=null),r.value&&zo().unregisterInputListener(r.value)});function k(j){t("chosen",{slotId:j})}function $(j){const C=M(j);if(C){if(wt().saves.mode==="manual"&&C.slotType==="auto"){Zt().alert("Sorry","Can't delete the auto save slot!");return}g.saveToDelete=j}}function x(j){ppe(j);const C=i.find(O=>O.id===j);C&&(C.saveData=null),w()}function E(){t("close")}function R(j,C){const O=m[C];O==="Load"?k(j):O==="Delete"?$(j):O==="Choose"&&(y.saveToOverwrite=j)}function M(j){return i.find(C=>C.id===j)}return(j,C)=>(b.openBlock(),b.createBlock(al,{onClose:E,containerCssClass:"save-modal",cantClose:!1},{header:b.withCtx(()=>[b.createElementVNode("h3",bke,b.toDisplayString(j.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",wke,[b.createElementVNode("div",kke,[xke,b.createVNode(b.TransitionGroup,{name:"list",tag:"div"},{default:b.withCtx(()=>[(b.openBlock(!0),b.createElementBlock(b.Fragment,null,b.renderList(a.value,O=>(b.openBlock(),b.createBlock(j_,{key:O.id,saveSlot:O,id:O.id,actions:m,onChoice:F=>R(O.id,F),inputListener:r.value,selected:p.value===O.id,ref_for:!0,ref_key:"autoSlotsElements",ref:c},null,8,["saveSlot","id","actions","onChoice","inputListener","selected"]))),128))]),_:1})]),b.createElementVNode("div",_ke,[jke,b.createVNode(b.TransitionGroup,{name:"list",tag:"div"},{default:b.withCtx(()=>[(b.openBlock(!0),b.createElementBlock(b.Fragment,null,b.renderList(s.value,O=>(b.openBlock(),b.createBlock(j_,{key:O.id,saveSlot:O,id:O.id,actions:m,onChoice:F=>R(O.id,F),inputListener:r.value,selected:p.value===O.id,ref_for:!0,ref_key:"manualSlotsElements",ref:f},null,8,["saveSlot","id","actions","onChoice","inputListener","selected"]))),128))]),_:1})])])):(b.openBlock(),b.createElementBlock("div",Ske,[Cke,b.createElementVNode("div",$ke,[b.createVNode(b.TransitionGroup,{name:"list",tag:"div"},{default:b.withCtx(()=>[(b.openBlock(!0),b.createElementBlock(b.Fragment,null,b.renderList(i,O=>(b.openBlock(),b.createBlock(j_,{key:O.id,saveSlot:O,id:O.id,actions:m,onChoice:F=>R(O.id,F),selected:p.value===O.id,inputListener:r.value,ref_for:!0,ref_key:"saveSlotsElements",ref:l},null,8,["saveSlot","id","actions","onChoice","selected","inputListener"]))),128))]),_:1})])])),g.saveToDelete?(b.openBlock(),b.createBlock(S0,{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(S0,{key:3,prompt:y.prompt,onRefuse:y.onRefuse,onConfirm:y.onConfirm},null,8,["prompt","onRefuse","onConfirm"])):b.createCommentVNode("",!0)]),_:1}))}}),c$e="",Tke=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 _V extends d2{setup(t=!1){const r=t?"keydown":"keyup",o=kV(i=>{Va.emit("debouncedKeydown",i)},10,{isImmediate:!0,maxWait:10});window.addEventListener("keydown",i=>{Va.emit("keydown",i)}),window.addEventListener(r,i=>{o(i)})}}const Va=new _V,jV=ao("startMenu",{state:()=>({buttons:[]}),actions:{addButtonsFromPlugins(){bn.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)})})}}}),Eke={id:"game-menu"},Oke={id:"game-header",class:"flex flex-col justify-between items-center"},Ake={id:"game-title-container"},Mke={id:"game-title-text"},Pke={class:"title"},Nke=b.defineComponent({__name:"StartMenu",setup(e){const t=b.ref(zo().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),l=b.ref(!1),c=b.ref(!1),f=b.ref(null),u=jV(),d=b.ref(!1),h=b.computed(()=>u.buttons),p=pp({mode:"list",container:r,listener:t.value,onChosen:O=>{m(n.value[O])}});function m(O){switch(O.id){case"continue":x();break;case"new-game":v();break;case"load-game":E();break;case"exit":Zt().exitGame();break;default:y(O);break}}async function v(){o.value&&wt().saves.mode==="manual"?c.value=!0:g()}async function g(){const O=Zt();if(s.value===null)if(wt().saves.mode==="manual"){const F=Ux();if(!F){Wt("No autosave found");return}s.value=F.id}else{const F=dpe();if(!F){Wt("No free slot found");return}s.value=F}c.value=!1,await O.startGame(s.value)}function y(O){const F=h.value.findIndex(L=>L.id===O.id),T=h.value[F];T.action&&T.action(),T.popupComponent&&(d.value=T)}function w(){d.value=!1}function k(){c.value=!1}async function $(){if(!s.value)return;const O=Bh(s.value);if(!O){Wt("No save file found");return}Zt().loadGame(O,s.value)}function x(){typeof a.value=="string"&&(s.value=a.value,$())}function E(){l.value=!0}function R({slotId:O}){const F=Bh(O);F&&F.saveData?(s.value=O,$()):v()}b.onMounted(()=>{const O=wt();O.audio.options.defaultMusic&&yo().playChannel("music",O.audio.options.defaultMusic,0);const F=Xs();F.slots.some(T=>T.saveData)&&(o.value=!0),(wt().saves.mode==="manual"||F.slots.some(T=>!T.saveData))&&(i.value=!0),F.lastSaveSlot&&Bh(F.lastSaveSlot)&&(a.value=F.lastSaveSlot),M(),f.value=Va.on("debouncedKeydown",T=>{T.key===" "&&g(),T.key==="c"&&x()}),b.nextTick(()=>{p.select(0)})});function M(){wt().menuButtons,a.value&&n.value.push(j({id:"continue",title:"Continue",cssClass:"continue-button"})),i.value&&n.value.push(j({id:"new-game",title:"New Game",cssClass:"start-button"})),o.value&&n.value.push(j({id:"load-game",title:"Load Game",cssClass:"continue-button"}));for(const O of h.value)n.value.push({id:O.id,title:O.text,cssClass:`${O.id}-start-menu-button`});n.value.push(j({id:"exit",title:"Exit",cssClass:"exit-button"}))}function j({id:O,title:F,cssClass:T}){const L=wt().menuButtons[O];if(L){let H=T;return L.cssClass&&(H=`${L.cssClass} ${T}`),{id:O,title:L.text??F,cssClass:H}}return{id:O,title:F,cssClass:T}}b.onUnmounted(()=>{t.value&&zo().unregisterInputListener(t.value),f.value&&Va.off("debouncedKeydown",f.value)});const C=b.computed(()=>wt().gameTitle);return(O,F)=>(b.openBlock(),b.createElementBlock("div",Eke,[l.value?(b.openBlock(),b.createBlock(xV,{key:0,mode:"load",onChosen:R,onClose:F[0]||(F[0]=T=>l.value=!1)})):b.createCommentVNode("",!0),c.value?(b.openBlock(),b.createBlock(S0,{key:1,prompt:"This will override your previous autosave, are you sure?",onConfirm:g,onRefuse:k})):b.createCommentVNode("",!0),b.createElementVNode("div",Oke,[b.createElementVNode("div",Ake,[b.createElementVNode("h1",Mke,b.toDisplayString(C.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,T=>(b.openBlock(),b.createBlock(Tke,{key:T.id,button:T,onClick:L=>m(T)},null,8,["button","onClick"]))),128))],512)]),d.value?(b.openBlock(),b.createBlock(b.Teleport,{key:2,to:"#app-container"},[b.createVNode(al,{onClose:w,class:b.normalizeClass(`start-menu-popup-${d.value.id}`)},{header:b.withCtx(()=>[b.createElementVNode("h3",Pke,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:w},null,32)):b.createCommentVNode("",!0)]),_:1},8,["class"])])):b.createCommentVNode("",!0)]))}}),u$e="",Ike={class:"title"},Dke=b.defineComponent({__name:"alert-modal",props:{title:{type:String,required:!1},text:{type:String,required:!1}},setup(e){return(t,n)=>(b.openBlock(),b.createBlock(al,{onClose:n[0]||(n[0]=r=>t.$emit("close")),containerCssClass:"yes-no-modal"},{header:b.withCtx(()=>[b.createElementVNode("h3",Ike,b.toDisplayString(e.title??"Alert"),1)]),body:b.withCtx(()=>[b.createElementVNode("h3",null,b.toDisplayString(e.text),1)]),_:1}))}}),f$e="";function S_(e){const t=f_().characters[e];return t||Wt(`Character ${e} not found`),t}function Rke(e,t){const n=S_(e);if(n&&(t||(t="default"),n.sprites)){const r=`${f_().config.imagesPath}${n.sprites[t]}`;return r||Wt(`Character ${e} pose ${t} not found`),r}}function C0(e){var t;return e?((t=S_(e))==null?void 0:t.style)||{}:{}}const Lke=b.defineComponent({props:{pictureUrl:String},methods:{getAssetUrl(e){return oa(e)}},computed:{...Kc(Pi,["layoutMode"]),boxStyle(){var i,a;const e=Pi(),t=wt().layout;let n=0,r=0;const o=t.portraits;if(this.layoutMode==="vertical"){const s=((i=o.offset)==null?void 0:i.portrait)??{right:0,bottom:0};n=20+s.right,r=e.dialogHeight+s.bottom}else{const s=((a=o.offset)==null?void 0:a.landscape)??{right:0,bottom:0},l=wt().dialogPanel.rightOffset??Qc.dialogPanel.rightOffset;n=b0()-10+s.right+l,r=200+s.bottom}return{right:`${n}px`,bottom:`${r}px`,width:`${t.portraits.width}px`,height:`${t.portraits.height}px`}}}}),d$e="",Bke=["src"];function Fke(e,t,n,r,o,i){return b.openBlock(),b.createElementBlock("div",{class:"dialog-picture override",style:b.normalizeStyle(e.boxStyle)},[b.createElementVNode("img",{src:e.getAssetUrl(e.pictureUrl),class:"picture override"},null,8,Bke)],4)}const Vke=la(Lke,[["render",Fke]]),zke=["innerHTML"],Uke=["innerHTML"],qke=["innerHTML"],Hke={key:1},Wke=["onClick","innerHTML"],Kke={key:1},Gke={key:2,class:"buttons-container"},Jke=b.defineComponent({__name:"dialog-box",props:{options:{},active:{type:Boolean},inputListener:{}},setup(e,{expose:t}){const n=e,r=b.ref(null),o=b.ref(""),i=b.ref(!1),a=b.ref(null),s=b.ref(null),l=b.ref(!1),c=b.ref(null),f=b.ref(null),u=b.ref(null),d=b.ref(null),h=b.ref(null);n.active&&(h.value=pp({mode:"list",container:r,listener:n.inputListener,onlyVertical:!0,onChosen:be=>{te.value&&A.value?k(A.value[be]):g(" ")}})),b.onMounted(()=>{C(),H(),l.value=!0}),b.onUnmounted(()=>{p(),L({unmounted:!0})});function p(){a.value&&(clearTimeout(a),a.value=null),m()}function m(){h.value&&(h.value.disable(),h.value=null)}function v(be){g(be.key)}function g(be){if(!te.value){l.value&&s&&be===" "&&L({pressedSpace:!0});return}if(te.value&&n.options.textField&&be==="Enter"&&R(),te.value&&!n.options.textField){let de=-1;switch(be){case" ":de=0;break;case"1":de=0;break;case"2":de=1;break;case"3":de=2;break;case"4":de=3;break;case"5":de=4;break;case"6":de=5;break;case"7":de=6;break;case"8":de=7;break}de!==-1&&A.value&&de<A.value.length?k(A.value[de]):de===0&&k(de)}}function y(){te.value||l.value&&s&&L({pressedSpace:!0})}function w(){i.value||k(0)}function k(be){$();let de;typeof be=="object"?de=be.originalIndex:de=be,Zt().playerAnswered(de)}function $(){p(),L({unmounted:!0}),i.value=!0}function x(be){const de={};return be.allowed||(de.pointerEvents="none",de.textDecoration="line-through"),de}function E(be){if(!be.allowed)return"strike-anim"}function R(){const be=o.value;Zt().playerAnswered(be)}function M(be,de){const Be=n.options.text.substring(be,de);return s.value.text+=Be,de}function j(be){const de=be[0];return s.value.text+=de,s.value.skippedChars+=de.length,de.length}function C(){if(!n.options.old)if(qn().playMode==="skip")O();else if(wt().dialogPanel.animateText){s.value={text:"",index:0,startTime:Date.now(),timer:null,skippedChars:0,tags:wpe(n.options.text),finished:!1};const be=s.value;be.timer=setInterval(()=>{T()},30)}else I.value&&(c.value=setTimeout(()=>{L()},(wt().dialogPanel.textSpeed??zg)*n.options.text.length))}function O(){qn().playMode==="skip"&&!n.options.old&&(I.value?f.value=setTimeout(()=>{L()},100):(qn().toggleSkip(),L({unmounted:!0})))}function F(){qn().playMode==="auto"&&!n.options.old&&I.value&&te&&w()}function T(){const be=s.value;if(!be)return;const de=be.index,Be=Date.now()-be.startTime;let ee=!1,Oe=Math.round(Be/(wt().dialogPanel.textSpeed??zg))+be.skippedChars;if(Oe>n.options.text.length&&(ee=!0,be.finished=!0,Oe=n.options.text.length),Oe!==be.index){let Le=de;for(;be.tags.length>0&&Oe>=be.tags[0].index;){Le=M(Le,be.tags[0].index);const Ce=j(be.tags.shift());Le+=Ce,Oe+=Ce}Le=M(Le,Oe),be.index=Le}ee&&L()}function L({unmounted:be,pressedSpace:de}={}){setTimeout(()=>{h.value&&h.value.select(0)},10),s.value&&(s.value.timer&&clearInterval(s.value.timer),s.value=null),c.value&&!de&&clearTimeout(c.value),f.value&&clearTimeout(f.value),u.value&&clearTimeout(u.value),!be&&!de&&qn().playMode!=="normal"&&I&&(u.value=setTimeout(()=>{w()},qn().playMode==="auto"?wt().dialogPanel.timeBetweenLines??Qc.dialogPanel.timeBetweenLines:0))}function H(){a.value=setTimeout(()=>{n.options.textField&&te.value&&d.value.focus()},10)}const z=b.computed(()=>n.options.title?" &nbsp;–&nbsp; ":"");b.computed(()=>C0(n.options.styleId));const V=b.computed(()=>{const be=C0(n.options.styleId),de={opacity:n.options.old?"0.7":"1"};return{...be.boxCss,...de}}),I=b.computed(()=>!A.value&&!n.options.textField),P=b.computed(()=>n.options.title?"dialog-box-followup":!1),N=b.computed(()=>{const be=C0(n.options.styleId);return{color:be.color,...be.nameCss}}),D=b.computed(()=>C0(n.options.styleId).textCss),S=b.computed(()=>s.value?s.value.text:n.options.text),A=b.computed(()=>{if(n.options.choices)return n.options.choices}),B=b.computed(()=>qn().playMode==="skip"),Q=b.computed(()=>qn().playMode==="auto"),te=b.computed(()=>n.active&&l.value&&!i.value&&!u.value&&!s.value&&n.options.interactive&&!ke.value),he=Zt(),ke=b.computed(()=>he.paused);return b.watch(()=>n.options,(be,de)=>{!de.old&&be.old&&s&&L({unmounted:!0})}),b.watch(B,(be,de)=>{be&&!de&&O()}),b.watch(Q,(be,de)=>{be&&!de&&F()}),t({keyboardEvent:v}),(be,de)=>{const Be=b.resolveDirective("visible");return b.openBlock(),b.createElementBlock("div",{class:b.normalizeClass(["dialog-box w-full override",P.value]),style:b.normalizeStyle(V.value)},[b.createElementVNode("div",{class:"dialog-content",onClick:y},[be.options.title?(b.openBlock(),b.createElementBlock("span",{key:0,class:"dialog-title override",style:b.normalizeStyle(N.value),innerHTML:be.options.title},null,12,zke)):b.createCommentVNode("",!0),b.createElementVNode("span",{class:"dialog-text dialog-separator override",style:b.normalizeStyle(D.value),innerHTML:z.value},null,12,Uke),b.createElementVNode("span",{class:b.normalizeClass(["dialog-text override",be.options.cssClass]),style:b.normalizeStyle(D.value),innerHTML:S.value},null,14,qke),be.options.old?b.createCommentVNode("",!0):b.withDirectives((b.openBlock(),b.createElementBlock("div",Hke,[A.value?(b.openBlock(),b.createElementBlock("div",{key:0,class:"dialog-choices",ref_key:"choicesDiv",ref:r},[(b.openBlock(!0),b.createElementBlock(b.Fragment,null,b.renderList(A.value,(ee,Oe)=>(b.openBlock(),b.createElementBlock("p",{key:Oe,style:b.normalizeStyle(x(ee)),class:b.normalizeClass([E(ee),"dialog-choice override"]),onClick:Le=>k(ee),innerHTML:`${Oe+1}. –  ${ee.choice}`},null,14,Wke))),128))],512)):be.options.textField?(b.openBlock(),b.createElementBlock("div",Kke,[b.withDirectives(b.createElementVNode("input",{type:"text",class:"label-input input",ref_key:"playerInput",ref:d,id:"player-input-field","onUpdate:modelValue":de[0]||(de[0]=ee=>o.value=ee)},null,512),[[b.vModelText,o.value]]),b.createElementVNode("button",{onClick:R,class:"button",id:"player-input-submit"}," Submit ")])):(b.openBlock(),b.createElementBlock("div",Gke,[b.createElementVNode("div",{onClick:de[1]||(de[1]=ee=>k(0)),ref:"continue",class:"interact-button button override"}," Continue ",512)]))])),[[Be,te.value]])])],6)}}}),h$e="",Qke=b.createElementVNode("div",{class:"anchor"},null,-1),Yke=b.defineComponent({__name:"game-dialog",props:{layoutMode:{},inGame:{type:Boolean},inputListener:{}},setup(e){const t=e,n=b.ref(Zt().inScript),r=b.ref(null),o=Pi(),i=an(),a=b.computed(()=>i.stack),s=qn(),l=b.computed(()=>s.dialog),c=b.ref(null),f=b.ref(null),u=b.ref(null),d=b.computed(()=>{let x="0px";const E=wt().layout.dialogBottomPadding;return typeof E=="number"?x=`${E}px`:typeof E=="string"&&(x=E),{paddingBottom:x}}),h=b.computed(()=>{if(l.value.length>0)return l.value[l.value.length-1]}),p=b.computed(()=>{if(h.value){const x=h.value.speaker;let E=h.value.pose;return x?(E||(E="idle"),Rke(x,E)):void 0}}),m=b.computed(()=>o.dialogWidth),v=b.computed(()=>Zt().inScript);b.watch(v,x=>{x?n.value=!0:qn().playMode!=="normal"?(qn().playMode==="skip"&&(qn().playMode="normal"),r.value=setTimeout(()=>{n.value=!1},500)):n.value=!1}),b.onMounted(()=>{t.inputListener.actions.autoPlay={press:()=>{qn().toggleAutoPlay()}},t.inputListener.actions.skip={press:()=>{qn().toggleSkip()}};const x=E=>{f.value&&f.value.keyboardEvent&&f.value.keyboardEvent(E)};x.value=Va.on("debouncedKeydown",x)}),b.onUnmounted(()=>{t.inputListener&&(delete t.inputListener.actions.autoPlay,delete t.inputListener.actions.skip),u.value&&Va.off("debouncedKeydown",u.value),r.value&&clearTimeout(r.value)});const g=b.computed(()=>{let x;const E=`${Pi().dialogHeight}px`,R={};if(Pi().overlayMode){R.position="absolute";const M=wt().dialogPanel.rightOffset??Qc.dialogPanel.rightOffset;R.right=`${M}px`;const j=wt().dialogPanel.bottomOffset??Qc.dialogPanel.bottomOffset;R.bottom=`${j}px`}return{...R,width:t.layoutMode==="horizontal"?`${m.value}px`:"100%",height:E,transform:x,transformOrigin:"right"}});function y(){qn().toggleAutoPlay()}function w(){qn().toggleSkip()}function k(x,E){const R=S_(x.speaker);let M=(R==null?void 0:R.name)??"Missing Character";return E>=1&&l.value[E-1].speaker===x.speaker&&(M=void 0),x.choices&&x.choices.forEach(j=>{j.choice=Zs(j.choice)}),{title:M??"",text:x.text,cssClass:x.cssClass,styleId:x.speaker,choices:x.choices,old:E<l.value.length-1,interactive:x.interactive,textField:x.textField}}function $(x){return x===s.dialog.length-1&&a.value.length>0}return b.watch(l.value,x=>{if(c.value){const E=c.value;E.scrollTop=E.scrollHeight+1e8}}),(x,E)=>(b.openBlock(),b.createElementBlock(b.Fragment,null,[b.createVNode(b.Transition,{name:"fade"},{default:b.withCtx(()=>[p.value&&b.unref(o).showDialog?(b.openBlock(),b.createBlock(Vke,{key:0,pictureUrl:p.value},null,8,["pictureUrl"])):b.createCommentVNode("",!0)]),_:1}),b.createVNode(b.Transition,{name:"dialog-transition"},{default:b.withCtx(()=>[x.inGame&&b.unref(o).showDialog?(b.openBlock(),b.createElementBlock("div",{key:0,class:"dialog override",ref_key:"dialogRef",ref:c,style:b.normalizeStyle(g.value)},[b.createVNode(b.TransitionGroup,{name:"list",tag:"div",class:"dialog-container w-full override",style:b.normalizeStyle(d.value)},{default:b.withCtx(()=>[(b.openBlock(!0),b.createElementBlock(b.Fragment,null,b.renderList(l.value,(R,M)=>(b.openBlock(),b.createBlock(Jke,{ref_for:!0,ref:j=>f.value=j,key:R.id,options:k(R,M),active:$(M),inputListener:x.inputListener},null,8,["options","active","inputListener"]))),128))]),_:1},8,["style"]),(b.openBlock(),b.createBlock(b.Teleport,{to:"#app"},[b.createElementVNode("div",{class:"auto-skip-buttons flex"},[b.createElementVNode("div",{class:"button menu-toggle-button auto-button auto",onClick:y}," Auto "),b.createElementVNode("div",{class:"button menu-toggle-button auto-button skip",onClick:w}," Skip ")])])),Qke],4)):b.createCommentVNode("",!0)]),_:1})],64))}}),p$e="",Xke=["id"],Zke=["src"],exe={class:"tab-title"},txe=b.defineComponent({__name:"tab-selector",props:{tab:{},active:{type:Boolean}},emits:["click"],setup(e,{emit:t}){const n=e,r=b.computed(()=>n.active?"tab-active":"tab-inactive");function o(){t("click")}return(i,a)=>(b.openBlock(),b.createElementBlock("div",{class:b.normalizeClass(["tab",r.value]),id:`tab-${i.tab.id}`,onClick:o},[b.createElementVNode("div",{class:b.normalizeClass(["tab-title-container",i.active?"active":""])},[i.tab.icon?(b.openBlock(),b.createElementBlock("img",{key:0,src:i.tab.icon,alt:"tab icon",class:"tab-icon"},null,8,Zke)):b.createCommentVNode("",!0),b.createElementVNode("span",exe,b.toDisplayString(i.tab.label),1)],2)],10,Xke))}}),m$e="",nxe={class:"tabs-controller"},rxe={key:0,class:"tabs-controller__tabs"},oxe={key:1,class:"tab-content"},ixe={key:2},axe=[b.createElementVNode("div",{class:"tab-content__empty"},[b.createElementVNode("p",null,"No tab selected")],-1)],sxe=b.defineComponent({__name:"TabsController",props:{tabs:{},defaultTab:{}},emits:["tab-change","close"],setup(e,{emit:t}){const n=e,r=b.ref(null),o=b.ref(n.defaultTab);function i(s){o.value=s,t("tab-change",s)}const a=b.computed(()=>n.tabs[o.value]);return b.onMounted(()=>{r.value=zo().registerInputListener("tabs-controller",{cancel:{press:()=>{t("close")}},previousTab:{press:()=>{o.value>0&&i(o.value-1)}},nextTab:{press:()=>{o.value<n.tabs.length-1&&(console.log(`Next tab ${o.value+1}`),i(o.value+1))}}})}),b.onUnmounted(()=>{r.value&&(zo().unregisterInputListener(r.value),r.value=null)}),(s,l)=>(b.openBlock(),b.createElementBlock("div",nxe,[s.tabs.length>1?(b.openBlock(),b.createElementBlock("div",rxe,[(b.openBlock(!0),b.createElementBlock(b.Fragment,null,b.renderList(s.tabs,(c,f)=>(b.openBlock(),b.createBlock(txe,{key:c.id,tab:c,active:f===o.value,onClick:()=>i(f),inputListener:r.value},null,8,["tab","active","onClick","inputListener"]))),128))])):b.createCommentVNode("",!0),a.value?(b.openBlock(),b.createElementBlock("div",oxe,[a.value?(b.openBlock(),b.createBlock(b.resolveDynamicComponent(a.value.component),{key:0,onClose:l[0]||(l[0]=c=>s.$emit("close"))},null,32)):b.createCommentVNode("",!0)])):(b.openBlock(),b.createElementBlock("div",ixe,axe))]))}}),g$e="",lxe={class:"menu-container"},cxe=["onClick","id"],uxe={class:"title"},fxe=b.defineComponent({__name:"menu-buttons",setup(e){const t=gi(),n=b.ref(null);b.onMounted(()=>{bn.callHook("onGameMounted")}),b.onUnmounted(()=>{n.value&&Va.off("keydown",n.value),bn.callHook("onGameUnmounted")});function r(f){gi().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 l(f){t.setActiveTab(f)}function c(){return s()}return(f,u)=>(b.openBlock(),b.createElementBlock("div",lxe,[(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,cxe))),128)),i.value?(b.openBlock(),b.createBlock(b.Teleport,{key:0,to:"#app-container"},[b.createVNode(al,{containerCssClass:{[i.value.cssClass]:!0,"menu-modal":!0},onClose:s},{header:b.withCtx(()=>{var d;return[b.createElementVNode("h3",uxe,b.toDisplayString(((d=b.unref(t).tab)==null?void 0:d.text)??i.value.label),1)]}),body:b.withCtx(()=>[b.createVNode(sxe,{onTabChange:l,onClose:c,tabs:a.value,defaultTab:i.value.activeTab},null,8,["tabs","defaultTab"])]),_:1},8,["containerCssClass"])])):b.createCommentVNode("",!0)]))}}),y$e="",dxe=["id"],hxe=["innerHTML"],pxe=b.defineComponent({__name:"screen-object",props:{screenObject:{},layerSelected:{type:Boolean},transitioning:{type:Boolean},activeInteractive:{}},setup(e){const t=e,n=ei();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(()=>{const s={};return o.value&&(s.selected=!0),n.isScreenObjectClickable(t.screenObject)?s.interactable=!0:s.disabled=!0,t.screenObject.cssClass&&(s[t.screenObject.cssClass]=!0),s}),a=b.computed(()=>{const s={};t.screenObject.opacity!==1&&(s.opacity=t.screenObject.opacity);let l=t.screenObject.x,c=t.screenObject.y,f=t.screenObject.width,u=t.screenObject.height;if(t.screenObject.anchor){const h=t.screenObject.anchor;l=t.screenObject.x-f*h.x,c=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:`${l}px`,top:`${c}px`,width:`${f}px`,height:`${u}px`};return Bge(t.screenObject)&&(d.backgroundImage=`url(${hp(t.screenObject.image)})`),d});return(s,l)=>{const c=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:l[0]||(l[0]=f=>r(s.screenObject)),style:b.normalizeStyle(a.value)},[b.createElementVNode("span",{innerHTML:t.screenObject.text?b.unref(Zs)(t.screenObject.text):void 0},null,8,hxe),(b.openBlock(!0),b.createElementBlock(b.Fragment,null,b.renderList(t.screenObject.children,f=>(b.openBlock(),b.createBlock(c,{transitioning:s.transitioning,key:f.id,screenObject:f},null,8,["transitioning","screenObject"]))),128))],14,dxe)}}}),b$e="",mxe=["id","innerHTML"],vxe=b.defineComponent({__name:"viewport-button",props:{id:{},layerSelected:{type:Boolean},transitioning:{type:Boolean},activeInteractive:{}},setup(e){const t=e,n=Ia();an();const r=b.computed(()=>n.getButtonState(t.id)),o=Jf(t.id),i=o.background?hp(o.background):null,a=b.computed(()=>{if(!t.layerSelected)return!1;const d=t.activeInteractive;return d.type==="button"&&d.id===t.id}),s=b.computed(()=>n.isButtonClickable(t.id)),l=b.computed(()=>{const d=o.text??"";return Zs(d)}),c=b.computed(()=>{const d={};return a.value&&(d.selected=!0),s.value?d.interactable=!0:(d.disabled=!0,r.value==="greyed"?d.greyed=!0:(r.value==="hidden"||r.value===!1)&&(d.hidden=!0)),o.cssClass&&(d[o.cssClass]=!0),d}),f=b.computed(()=>{const d={};o.position.width&&(d.width=`${o.position.width}px`),o.position.height&&(d.height=`${o.position.height}px`),o.background&&(d.backgroundImage=`url(${i})`);let h=o.position.left,p=o.position.top;return o.anchor&&(h=o.position.left-o.position.width*o.anchor.x,p=o.position.top-o.position.height*o.anchor.y),{...d,left:`${h}px`,top:`${p}px`}});function u(){n.clickOnButton(t.id)}return(d,h)=>(b.openBlock(),b.createElementBlock("div",{tabindex:"-1",class:b.normalizeClass(["viewport-button",c.value]),id:`viewport-button-${d.id}`,onClick:h[0]||(h[0]=p=>u()),style:b.normalizeStyle(f.value),innerHTML:l.value},null,14,mxe))}}),w$e="",gxe=["id"],C_=b.defineComponent({__name:"screen-layer",props:{layer:{},layerIndex:{},transitioning:{type:Boolean},activeInteractive:{}},setup(e){const t=e,n=Zt(),r=ei(),o=b.computed(()=>!!(t.activeInteractive&&t.activeInteractive.layer===t.layerIndex)),i=b.computed(()=>r.tree.filter(h=>h.layer===t.layerIndex)),a=b.computed(()=>wt().layout.backgrounds.width),s=b.computed(()=>wt().layout.backgrounds.height),l=b.computed(()=>t.layer),c=b.computed(()=>{const h=dp(l.value);return h||(console.log(l),Wt(`Screen ${l.value} doesn't have a config`)),h}),f=b.computed(()=>n.isInGame),u=b.computed(()=>c.value.buttons||[]),d=b.computed(()=>{let h=`url(${hp(c.value.background)})`;return c.value.background===Wx&&(h=void 0),{backgroundImage:h,width:`${a.value}px`,height:`${s.value}px`}});return(h,p)=>f.value?(b.openBlock(),b.createElementBlock("div",{key:0,class:"viewport-layer",id:`viewport-layer-${l.value}`,style:b.normalizeStyle(d.value)},[(b.openBlock(!0),b.createElementBlock(b.Fragment,null,b.renderList(u.value,(m,v)=>(b.openBlock(),b.createBlock(vxe,{key:v,id:m,layerSelected:o.value,transitioning:h.transitioning,activeInteractive:h.activeInteractive},null,8,["id","layerSelected","transitioning","activeInteractive"]))),128)),(b.openBlock(!0),b.createElementBlock(b.Fragment,null,b.renderList(i.value,m=>(b.openBlock(),b.createBlock(pxe,{key:m.id,screenObject:m,transitioning:h.transitioning,layerSelected:o.value,activeInteractive:h.activeInteractive},null,8,["screenObject","transitioning","layerSelected","activeInteractive"]))),128))],12,gxe)):b.createCommentVNode("",!0)}}),k$e="",yxe=b.defineComponent({__name:"NarratTransition",props:{name:{type:String,required:!0},duration:{type:Number,required:!0},delay:Number},emits:["complete"],setup(e,{emit:t}){const n=e,r=b.useSlots(),o=b.ref("start"),i=b.reactive({oldSlotClasses:{},oldSlotStyle:{},newSlotClasses:{},newSlotStyle:{}});return b.computed(()=>r.oldElement&&r.oldElement.length>0),b.computed(()=>r.newElement&&r.newElement.length>0),b.onMounted(async()=>{const a=`narrat-transition-${n.name}`;i.newSlotClasses={[`${a}-enter-from`]:!0,[`${a}-enter-active`]:!0},i.oldSlotStyle={transitionDuration:`${n.duration/1e3}s`},i.newSlotStyle={transitionDuration:`${n.duration/1e3}s`},i.oldSlotClasses={[`${a}-leave-active`]:!0},await ea(30),i.oldSlotClasses[`${a}-leave-to`]=!0,await ea(n.delay??0),delete i.newSlotClasses[`${a}-enter-from`],await ea(n.duration),delete i.newSlotClasses[`${a}-enter-active`],delete i.oldSlotClasses[`${a}-leave-active`],o.value="end",t("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))}}),x$e="";function SV(e,t,n){return e<t?t:e>n?n:e}const bxe=b.defineComponent({__name:"screens",props:{inputListener:{}},setup(e){const t=e,n=Pi(),r=Zt(),o=Ia(),i=ei(),a=b.ref(0),s=b.computed(()=>o.nonEmptyLayers),l=b.computed(()=>{const v=[];return s.value.reduce((g,y,w)=>{const $=dp(y.screen).buttons;if($)for(const E of $)o.isButtonClickable(E)&&g.push({id:E,type:"button",layer:w});const x=i.tree.filter(E=>E.layer===w);for(const E of x)i.isScreenObjectClickable(E)&&g.push({id:E.id,type:"screenObject",layer:w});return g},v)}),c=b.computed(()=>{if(l.value.length===0)return null;let v=a.value;return v>l.value.length-1&&(v=l.value.length-1),l.value[v]}),f=b.computed(()=>n.layoutMode),u=b.computed(()=>wt().layout.backgrounds.width),d=b.computed(()=>wt().layout.backgrounds.height),h=b.computed(()=>r.isInGame);function p(v){o.finishTransition(v)}const m=b.computed(()=>{const v=u.value,g=d.value;return f.value,{height:`${g}px`,width:`${v}px`}});return b.onMounted(()=>{b.nextTick(()=>{if(t.inputListener){const v=t.inputListener.actions;v.previousTab={press:()=>{a.value>0?a.value--:a.value=l.value.length-1,a.value=SV(a.value,0,l.value.length-1)}},v.left=v.previousTab,v.nextTab={press:()=>{a.value<l.value.length-1?a.value++:a.value=0,a.value=SV(a.value,0,l.value.length-1)}},v.right=v.nextTab,v.viewportSelect={press:()=>{if(c.value){const g=c.value;g.type==="button"?o.clickOnButton(g.id):g.type==="screenObject"&&i.clickObject(i.getObject(g.id))}}}}})}),b.onUnmounted(()=>{t.inputListener&&(delete t.inputListener.actions.previousTab,delete t.inputListener.actions.left,delete t.inputListener.actions.nextTab,delete t.inputListener.actions.right)}),(v,g)=>h.value?(b.openBlock(),b.createElementBlock("div",{key:0,class:"viewport",id:"narrat-viewport",style:b.normalizeStyle(m.value)},[(b.openBlock(!0),b.createElementBlock(b.Fragment,null,b.renderList(s.value,(y,w)=>(b.openBlock(),b.createElementBlock("div",{key:w,class:"layer-container"},[y.transition?(b.openBlock(),b.createBlock(yxe,{key:0,name:y.transition.transition,duration:y.transition.duration,delay:y.transition.delay,onComplete:()=>p(w)},{oldElement:b.withCtx(()=>[y.transition.oldScreen?(b.openBlock(),b.createBlock(C_,{key:0,layer:y.transition.oldScreen,layerIndex:w,transitioning:!0},null,8,["layer","layerIndex"])):b.createCommentVNode("",!0)]),newElement:b.withCtx(()=>[y.screen?(b.openBlock(),b.createBlock(C_,{key:0,layer:y.screen,layerIndex:w,transitioning:!0},null,8,["layer","layerIndex"])):b.createCommentVNode("",!0)]),_:2},1032,["name","duration","delay","onComplete"])):y.screen?(b.openBlock(),b.createBlock(C_,{key:1,layer:y.screen,layerIndex:w,transitioning:!1,activeInteractive:c.value},null,8,["layer","layerIndex","activeInteractive"])):b.createCommentVNode("",!0)]))),128))],4)):b.createCommentVNode("",!0)}}),_$e="",wxe=b.defineComponent({data(){return{}},methods:{getStatImage(e){return oa(this.statsConfig[e].icon)}},computed:{...Kc(_s,["hudStats"]),...Kc(Pi,["layoutMode"]),statsConfig(){return wt().hudStats},stats(){return this.hudStats},hudStyle(){let e="0";return this.layoutMode==="horizontal"&&(e=`${b0()+(wt().dialogPanel.rightOffset??Qc.dialogPanel.rightOffset)}px`),{right:e}}}}),j$e="",kxe=["src"],xxe={class:"bold hud-text"};function _xe(e,t,n,r,o,i){return b.openBlock(),b.createElementBlock("div",{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,kxe),b.createElementVNode("span",xxe,b.toDisplayString(e.statsConfig[s].name),1),b.createTextVNode(": "),b.createElementVNode("span",null,b.toDisplayString(Math.floor(a.value*100)/100),1)]))),128))],4)}const jxe=la(wxe,[["render",_xe]]),Sxe={key:0,class:"auto-play-feedback-container"},Cxe=b.defineComponent({__name:"AutoPlayFeedback",setup(e){const t=qn(),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",Sxe,[b.createElementVNode("div",{class:b.normalizeClass(["auto-play-feedback",o.value])},b.toDisplayString(i.value),3)])):b.createCommentVNode("",!0)}}),S$e="",$xe=b.defineComponent({__name:"in-game",setup(e){const t=b.ref(null),n=Zt(),r=Pi(),o=b.computed(()=>r.layoutMode),i=b.computed(()=>n.saving),a=b.ref(null),s=qn(),l=b.ref(null),c=b.computed(()=>i.value&&!i.value.withPrompt||i.value&&a.value),f=b.computed(()=>{let p="row";return o.value==="vertical"&&(p="column"),{flexDirection:p}});function u(p){if(a.value=null,p===null){Zt().finishManualSave(p,!1);return}Zt().finishManualSave(p,!0)}function d(){a.value=!0}function h(){a.value=!1,n.finishManualSave(null,!1),a.value=null}return b.onBeforeMount(()=>{t.value=zo().registerInputListener("in-game",{system:{press:()=>{gi().openMenu("system")}},menu:{press:()=>{gi().openMenu("menu")}}})}),b.onMounted(()=>{l.value=Va.on("debouncedKeydown",p=>{Zt().debugMode||((p.key==="a"||p.key==="A")&&s.toggleAutoPlay(),(p.key==="s"||p.key==="S")&&s.toggleSkip())})}),b.onUnmounted(()=>{t.value&&zo().unregisterInputListener(t.value),l.value&&Va.off("debouncedKeydown",l.value)}),(p,m)=>(b.openBlock(),b.createElementBlock("div",{class:"game",style:b.normalizeStyle(f.value)},[b.createVNode(jxe),b.createVNode(fxe,{class:"menu-toggle"}),b.createVNode(bxe,{inputListener:t.value},null,8,["inputListener"]),b.unref(r).showDialog?(b.openBlock(),b.createBlock(Yke,{key:0,inGame:!0,layoutMode:o.value,inputListener:t.value},null,8,["layoutMode","inputListener"])):b.createCommentVNode("",!0),c.value?(b.openBlock(),b.createBlock(xV,{key:1,mode:"pick",onChosen:u,onClose:m[0]||(m[0]=()=>u(null))})):b.createCommentVNode("",!0),b.createVNode(Cxe),i.value&&i.value.withPrompt&&a.value===null?(b.openBlock(),b.createBlock(S0,{key:2,prompt:"Would you like to save the game?",onConfirm:d,onRefuse:h})):b.createCommentVNode("",!0)],4))}}),C$e="",Txe=b.defineComponent({props:{percentage:Number,step:String},methods:{loadingStyle(){return{width:`${this.percentage*60}vw`}}},computed:{}}),$$e="",Exe={id:"loading-bar"},Oxe={id:"loading-text"};function Axe(e,t,n,r,o,i){return b.openBlock(),b.createElementBlock("div",Exe,[b.createElementVNode("div",{id:"inner-loading-bar",style:b.normalizeStyle(e.loadingStyle())},null,4),b.createElementVNode("div",Oxe,[b.createElementVNode("h3",null,"Loading "+b.toDisplayString(Math.floor(e.percentage*100))+"% - "+b.toDisplayString(e.step),1)])])}const Mxe=la(Txe,[["render",Axe]]),Pxe="data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4KPCEtLSBHZW5lcmF0b3I6IEFkb2JlIElsbHVzdHJhdG9yIDE5LjAuMCwgU1ZHIEV4cG9ydCBQbHVnLUluIC4gU1ZHIFZlcnNpb246IDYuMDAgQnVpbGQgMCkgIC0tPgo8c3ZnIHZlcnNpb249IjEuMSIgaWQ9IlJhdCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgeD0iMHB4IiB5PSIwcHgiCgkgdmlld0JveD0iMCAwIDU5NS4zIDU5NS4zIiBzdHlsZT0iZW5hYmxlLWJhY2tncm91bmQ6bmV3IDAgMCA1OTUuMyA1OTUuMzsiIHhtbDpzcGFjZT0icHJlc2VydmUiPgo8c3R5bGUgdHlwZT0idGV4dC9jc3MiPgoJLnN0MHtmaWxsOiNFMjNCMzM7fQo8L3N0eWxlPgo8cGF0aCBpZD0iUmF0X1NoYXBlIiBjbGFzcz0ic3QwIiBkPSJNNTU2LjksODIuNWMtMTAuOC0yNC4zLTQ3LTU3LjEtNzEuMy02NS42Yy0yNC4zLTguNC02NC4xLTAuMy04OC43LDIyLjMKCWMtMjAsMTguNC0yNiwyOC4yLTI5LjEsMzdjLTIuMSw1LjktNC44LDEzLjUtNiwyMC45djBjLTAuNSw0LjEtNC41LDctOC42LDYuMWMtMTAuNC0yLjMtMjkuNS02LTQ0LjQtNi4zCgljLTEzLjctMC4yLTMwLjEsMy4yLTQwLjQsNS43Yy00LjUsMS4xLTguOC0yLjItOC44LTYuOGMtMC4xLTUuMy0xLjEtMTIuMy00LjgtMTkuNmMtOC41LTE2LjktMTkuNi0zMi42LTU3LjgtNDcuNAoJYy0zMS45LTEyLjQtNzUuMS05LjctMTAwLjgsMS44Yy0yOC4xLDEyLjYtNDIuNCwzNy45LTU0LDYxLjhjLTE0LjQsMjkuOC0xNC45LDgzLjYtNi40LDEwNGMxMi44LDMwLjcsMzUuOCw0Ny4yLDUyLjYsNTMKCWMxMS4zLDMuOCwyOC4yLDMuNywzOC4yLDMuM2M0LjItMC4yLDcuNywzLjMsNy41LDcuNWMtMC43LDEzLjYtMC45LDQxLjUsNyw2MS40YzcuNywxOS40LDI5LjcsNjIuMyw1MC43LDEwMS4yCgljMCwwLjEtMTQuNiwyLjktMzEuNCw2LjhjLTIzLjksNS41LTUyLjYsMTIuNy01NC4zLDEzLjdjLTMuNSwyLjEtMywxMC0yLjcsMTJjMC41LDMuNCw1LjMsOC4xLDYuOSw4LjNjMy45LDAuMywzMS4zLTcuNiw1NS43LTE0LjYKCWMxOC41LTUuMywzNC45LTkuMywzNS41LTguMmM1LjEsOS4zLDEwLDE4LDE0LjQsMjUuOGM1LjIsOS4xLDEwLjcsMTYuNCwxNC4xLDIzLjZjMS4xLDIuMy0xNi42LDUuOC0zMi41LDE0LjcKCWMtMTYuNCw5LjEtMjkuNywyMS0zMi4zLDI0Yy0xLjgsMi4xLTMsNi0xLjIsMTAuN2MxLjEsMi45LDEwLDUuNywxMi40LDUuMWM2LjgtMS43LDE2LjUtMTIuNSwzMy4xLTIxLjEKCWMxNi4zLTguNSwzMi45LTE0LjksMzMuOC0xMy42YzkuNywxNC4zLDE2LjksMjEuNiwyMi42LDMxLjJjOS44LDE2LjUsMjcuMyw0NS45LDQ2LjYsMzkuNWM2LjQtMi4xLDMxLjEtMzMuNiw1My4zLTY4LjYKCWMxLjMtMi4xLDE2LjEsMTEuMywzMC40LDIzLjJjMTMuOCwxMS40LDIyLjcsMjAuNiwyNy4xLDIxLjRjNS40LDEsMTQuMi03LjcsMTQuMS0xNC43Yy0wLjEtMi43LTE0LjMtMTMuOC0yOS4xLTI2LjIKCWMtMTQuNS0xMi4xLTMwLjEtMjIuOC0yOS4yLTI0LjNjNy42LTEyLDE0LjUtMjMuNywyMC4xLTMzLjljNC4zLTcuOCw4LjktMTYsMTMtMjQuN2MwLjYtMS4yLDE1LjksMywzMS40LDcuMWMxNS4zLDQsMjYuNywxMCwzMSw4CgljNi45LTMsMTEuNi0xMy44LDkuNC0xOC4zYy0xLjEtMi4zLTE3LTcuMy0zMy4yLTEyYy0xNC4yLTQuMS0yOC02LjUtMjcuNy03LjNjMTUuNS0zNCwyOC44LTY0LjgsMjcuNi02OS42CgljLTEuNy03LjEsMi42LTExLjksNy0zNi41YzMuMi0xOC4xLDQuNy00MC45LDUuMi01MS43YzAuMi0zLjUsMi44LTYuMyw2LjMtNi43YzMuMS0wLjMsNi45LTAuOSwxMC41LTEuOWM3LjgtMiwxOC42LTcuOCwzNi40LTIwLjYKCWMxNy45LTEyLjgsMzguNy00OS42LDQ0LjQtNjcuOFM1NjcuNiwxMDYuOCw1NTYuOSw4Mi41eiBNMjY1LjEsMzM2LjJjLTguMSw0LTEzLDctMjYuNCw5LjZjLTYuOSwxLjQtMjkuNC0wLjItNDAuNy00LjYKCWMtMTAuNS00LjEtMTkuOS03LjYtMzAtMTUuNHMtMTUuNy0xMy4yLTE1LjctMTUuM2MwLTQuNCw2LTkuNCwxMS05LjRjNS4xLDAsMTQuNSw5LjIsMjkuNywxNi42YzE0LjMsNywxNy45LDYuMSwyNS40LDcuMwoJYzIuOSwwLjUsNy43LDAuNiwxMC43LDAuNGMxNC4xLTEuMywyMS40LTUuOSwyNS4zLTguOGM0LTMsMTMuNy0xMi45LDE3LjItMTIuNWM4LDEsMTguOSwzLjQsMTguOSw3LjEKCUMyOTAuNCwzMTksMjczLjIsMzMyLjEsMjY1LjEsMzM2LjJ6IE0zMjAuOSw1MjEuNGMtNC4zLDMuNy0xNy43LDEzLjUtMjMuMywxMy41Yy0yLjgsMC03LjQtOC4yLTExLjUtMTYuOAoJYy00LjEtOC41LTkuMS0yMS4xLTkuMS0zMS42YzAtNC42LDYtNy40LDEzLjQtOS4yYzcuMi0xLjcsMjcuMy0xLjgsMjkuOS0xLjFjNi44LDEuNywxMi45LDIuMiwxMi43LDYuNGMtMC40LDEyLjctNywxOC45LTguMywyNC4zCglDMzIzLjQsNTEyLjMsMzIzLjQsNTE5LjIsMzIwLjksNTIxLjR6IE00MzEuMSwzMjAuM2MtOS4yLDcuNC0xMC42LDguMS0yNC45LDEzLjdjLTExLjMsNC40LTI4LjYsNS44LTQxLjYsMy42CgljLTEyLjItMi4xLTIyLjMtNC42LTI5LjUtMTAuMWMtOS43LTcuMy0xNi40LTE1LjEtMTYuNC0xOS44YzAtMy43LDYuNC00LjMsMTQuNS00LjljMy41LTAuMyw5LjMsNS45LDEzLjIsOS4yCgljOC4xLDYuOCwxNC44LDgsMjguOCw5LjljMi45LDAuNCw3LjgsMC40LDEwLjcsMC4xYzcuNS0wLjksMTItMC40LDI1LjgtOC4yYzIwLTExLjIsMTcuOC0xNC40LDI1LjEtMTIuNmMyLjIsMC42LDUuOCwxLjIsNS42LDUuNgoJQzQ0Mi40LDMwOSw0NDAuNSwzMTIuNyw0MzEuMSwzMjAuM3oiLz4KPC9zdmc+Cg==",Nxe={id:"engine-splash-screen",class:"flex justify-center items-center"},Ixe={id:"engine-splash-title"},Dxe=["src"],Rxe=b.defineComponent({__name:"engine-splash",emits:["finished"],setup(e,{emit:t}){const n=b.ref("hidden"),r=b.computed(()=>({transitionDuration:`${c.value}s`})),o=b.computed(()=>({invisible:n.value!=="appear"})),i=Zt(),a=b.computed(()=>{var d;return((d=wt().splashScreens)==null?void 0:d.engineSplashScreen)??{}}),s=b.computed(()=>typeof a.value.overrideText=="string"?a.value.overrideText:"Made with narrat engine"),l=b.computed(()=>a.value.overrideLogo??Pxe),c=b.computed(()=>typeof a.value.fadeDuration=="number"?a.value.fadeDuration:.8),f=b.computed(()=>typeof a.value.timeBeforeFadeout=="number"?a.value.timeBeforeFadeout:1.5);b.onMounted(async()=>{if(await ea(10),n.value="appear",a.value.skip||i.options.debug){u();return}await ea(c.value*1e3),await ea(f.value*1e3),n.value="disappear",await ea(c.value*1e3),u()});function u(){i.loading.loaded?t("finished"):i.listener.once("gameLoaded",()=>{t("finished")})}return(d,h)=>(b.openBlock(),b.createElementBlock("div",Nxe,[b.createElementVNode("div",{id:"engine-splash-header",class:b.normalizeClass(["flex justify-center flex-col items-center",o.value]),style:b.normalizeStyle(r.value)},[b.createElementVNode("h1",Ixe,b.toDisplayString(s.value),1),b.createElementVNode("img",{src:l.value,alt:"Narrat Logo",id:"engine-splash-logo"},null,8,Dxe),b.createVNode(Mxe,{percentage:b.unref(i).loading.percentage,step:b.unref(i).loading.step},null,8,["percentage","step"])],6)]))}}),T$e="",Lxe={id:"game-splash-screen",style:{height:"100%",padding:"20px"},class:"flex justify-center items-center"},Bxe={id:"game-splash-screen-header flex justify-center flex-col items-center",class:"flex justify-center flex-col items-center"},Fxe={class:"title",id:"game-splash-title"},Vxe=b.defineComponent({__name:"game-splash",setup(e){const t=b.ref(null),n=Zt(),r=b.computed(()=>{var l;return((l=wt().splashScreens)==null?void 0:l.gameSplashScreen)??{}}),o=b.computed(()=>typeof r.value.startButtonText=="string"?r.value.startButtonText:"Press to start"),i=b.computed(()=>n.loading.loaded),a=b.computed(()=>wt().gameTitle||"Narrat Game");function s(){n.flowState="menu"}return b.onMounted(()=>{t.value=zo().registerInputListener("game-splash",{continue:{press:()=>{s()}}}),n.options.debug&&s()}),b.onUnmounted(()=>{t.value&&zo().unregisterInputListener(t.value)}),(l,c)=>(b.openBlock(),b.createElementBlock("div",Lxe,[b.createElementVNode("div",Bxe,[b.createElementVNode("h1",Fxe,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)])]))}}),E$e="",zxe={key:0,class:"floating-tooltip-title"},Uxe=b.createElementVNode("hr",null,null,-1),qxe={class:"floating-tooltip-text"},Hxe=b.defineComponent({__name:"floating-tooltip",props:{title:{},text:{},width:{},x:{},y:{},screenMargin:{}},setup(e){const t=e,n=b.ref(150),r=b.ref(null),o=b.computed(()=>{const i=t.screenMargin??5,a={};let s=t.x-t.width/2;s=Math.min(s,window.innerWidth-t.width-i),s=Math.max(i,s),a.left=`${s}px`;let l=window.innerHeight-t.y;return l=Math.max(l,i),l=Math.min(l,window.innerHeight-n.value-i),a.bottom=`${l}px`,a.width=`${t.width}px`,a});return b.onMounted(()=>{r.value&&(n.value=r.value.clientHeight)}),(i,a)=>(b.openBlock(),b.createBlock(b.Transition,{name:"fade"},{default:b.withCtx(()=>[b.createElementVNode("div",{class:"floating-tooltip",style:b.normalizeStyle(o.value),ref_key:"element",ref:r},[i.title?(b.openBlock(),b.createElementBlock("div",zxe,[b.createTextVNode(b.toDisplayString(t.title)+" ",1),Uxe])):b.createCommentVNode("",!0),b.createElementVNode("div",qxe,b.toDisplayString(t.text),1)],4)]),_:1}))}}),O$e="",Wxe={class:"tooltips-ui"},Kxe=b.defineComponent({__name:"tooltips-ui",setup(e){const t=Bg().tooltip,n=b.computed(()=>({...t,screenMargin:fp().options.screenEdgesMinimumMargin??5}));return(r,o)=>(b.openBlock(),b.createElementBlock("div",Wxe,[b.unref(t)?(b.openBlock(),b.createBlock(Hxe,b.normalizeProps(b.mergeProps({key:0},n.value)),null,16)):b.createCommentVNode("",!0)]))}}),Gxe=b.defineComponent({setup(){const e=qn(),t=an(),n=Zt();return{dialog:b.computed(()=>e.dialog),stack:b.computed(()=>t.stack),flowState:b.computed(()=>n.flowState),alerts:b.computed(()=>n.alerts)}},$refs:{dialogContainer:HTMLInputElement},components:{DebugMenu:rke,NotificationToast:ske,StartMenu:Nke,AlertModal:Dke,InGame:$xe,EngineSplash:Rxe,GameSplash:Vxe,TooltipsUi:Kxe},data(){return{lineTitle:"title",lineText:"hello"}},props:{options:Object},async mounted(){bn.callHook("onAppMounted"),await Zt().engineLoading(),window.addEventListener("resize",kV(()=>{this.updateScreenSize()},100,{maxWait:200})),Va.setup(this.options.debug),setTimeout(()=>{this.updateScreenSize()},50)},computed:{...Kc(Pi,["screenWidth","screenHeight","layoutMode","gameWidth","gameHeight","gameScaleRatio","actualGameHeight"]),...Kc(an,["currentLine"]),appStyle(){return{transform:`scale(${this.gameScaleRatio}, ${this.gameScaleRatio})`,width:`${this.gameWidth}px`,height:`${this.actualGameHeight}px`}},appClass(){return gi().activeMenu?"app-blurred-by-modal":{}}},methods:{closeAlert(e){Zt().closeAlert(e)},engineSplashDone(){Zt().flowState="game-splash"},updateScreenSize(){Pi().updateScreenSize(window.innerWidth,window.innerHeight)}}}),A$e="";function Jxe(e,t,n,r,o,i){const a=b.resolveComponent("EngineSplash"),s=b.resolveComponent("GameSplash"),l=b.resolveComponent("StartMenu"),c=b.resolveComponent("InGame"),f=b.resolveComponent("DebugMenu"),u=b.resolveComponent("NotificationToast"),d=b.resolveComponent("AlertModal"),h=b.resolveComponent("TooltipsUi");return b.openBlock(),b.createElementBlock(b.Fragment,null,[b.createElementVNode("div",{id:"app-container",style:b.normalizeStyle(e.appStyle)},[b.createElementVNode("div",{id:"app",class:b.normalizeClass(e.appClass)},[e.flowState==="engine-splash"?(b.openBlock(),b.createBlock(a,{key:0,onFinished:e.engineSplashDone},null,8,["onFinished"])):(b.openBlock(),b.createBlock(b.Transition,{key:1,name:"screens-fade"},{default:b.withCtx(()=>[e.flowState==="game-splash"?(b.openBlock(),b.createBlock(s,{key:"1"})):e.flowState==="menu"?(b.openBlock(),b.createBlock(l,{key:"2"})):e.flowState==="playing"?(b.openBlock(),b.createBlock(c,{key:"3"})):b.createCommentVNode("",!0)]),_:1})),e.options.debug?(b.openBlock(),b.createBlock(f,{key:2})):b.createCommentVNode("",!0),b.createVNode(u),(b.openBlock(!0),b.createElementBlock(b.Fragment,null,b.renderList(e.alerts,p=>(b.openBlock(),b.createBlock(d,{key:p.id,title:p.title,text:p.text,onClose:()=>e.closeAlert(p.id)},null,8,["title","text","onClose"]))),128))],2)],4),b.createVNode(h)],64)}const Qxe=la(Gxe,[["render",Jxe]]);function St(e,t){console.error("Runtime error ========================="),console.error(`Command: ${e.commandType}`),console.error("Args: ",e.args),console.error("Options: ",e.options),Wt(`Runtime error at ${e.fileName}:${e.line} (${e.commandType}) ${e.code}. -
218
+ deps: ${f}}`};const o={keyword:"dependencies",type:"object",schemaType:"object",error:e.error,code(l){const[c,f]=i(l);a(l,c),s(l,f)}};function i({schema:l}){const c={},f={};for(const u in l){if(u==="__proto__")continue;const d=Array.isArray(l[u])?c:f;d[u]=l[u]}return[c,f]}function a(l,c=l.schema){const{gen:f,data:u,it:d}=l;if(Object.keys(c).length===0)return;const h=f.let("missing");for(const p in c){const m=c[p];if(m.length===0)continue;const v=(0,r.propertyInData)(f,u,p,d.opts.ownProperties);l.setParams({property:p,depsCount:m.length,deps:m.join(", ")}),d.allErrors?f.if(v,()=>{for(const g of m)(0,r.checkReportMissingProp)(l,g)}):(f.if((0,t._)`${v} && (${(0,r.checkMissingProp)(l,m,h)})`),(0,r.reportMissingProp)(l,h),f.else())}}e.validatePropertyDeps=a;function s(l,c=l.schema){const{gen:f,data:u,keyword:d,it:h}=l,p=f.name("valid");for(const m in c)(0,n.alwaysValidSchema)(h,c[m])||(f.if((0,r.propertyInData)(f,u,m,h.opts.ownProperties),()=>{const v=l.subschema({keyword:d,schemaProp:m},p);l.mergeValidEvaluated(v,p)},()=>f.var(p,!0)),l.ok(p))}e.validateSchemaDeps=s,e.default=o})(zF);var J2={};Object.defineProperty(J2,"__esModule",{value:!0});const UF=Dn,G1e=Jn,J1e={keyword:"propertyNames",type:"object",schemaType:["object","boolean"],error:{message:"property name must be valid",params:({params:e})=>(0,UF._)`{propertyName: ${e.propertyName}}`},code(e){const{gen:t,schema:n,data:r,it:o}=e;if((0,G1e.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,UF.not)(i),()=>{e.error(!0),o.allErrors||t.break()})}),e.ok(i)}};J2.default=J1e;var f0={};Object.defineProperty(f0,"__esModule",{value:!0});const d0=Rn,Fa=Dn,Q1e=js,h0=Jn,Y1e={keyword:"additionalProperties",type:["object"],schemaType:["boolean","object"],allowUndefined:!0,trackErrors:!0,error:{message:"must NOT have additional properties",params:({params:e})=>(0,Fa._)`{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:l}=a;if(a.props=!0,l.removeAdditional!=="all"&&(0,h0.alwaysValidSchema)(a,n))return;const c=(0,d0.allSchemaProperties)(r.properties),f=(0,d0.allSchemaProperties)(r.patternProperties);u(),e.ok((0,Fa._)`${i} === ${Q1e.default.errors}`);function u(){t.forIn("key",o,v=>{!c.length&&!f.length?p(v):t.if(d(v),()=>p(v))})}function d(v){let g;if(c.length>8){const y=(0,h0.schemaRefOrVal)(a,r.properties,"properties");g=(0,d0.isOwnProperty)(t,y,v)}else c.length?g=(0,Fa.or)(...c.map(y=>(0,Fa._)`${v} === ${y}`)):g=Fa.nil;return f.length&&(g=(0,Fa.or)(g,...f.map(y=>(0,Fa._)`${(0,d0.usePattern)(e,y)}.test(${v})`))),(0,Fa.not)(g)}function h(v){t.code((0,Fa._)`delete ${o}[${v}]`)}function p(v){if(l.removeAdditional==="all"||l.removeAdditional&&n===!1){h(v);return}if(n===!1){e.setParams({additionalProperty:v}),e.error(),s||t.break();return}if(typeof n=="object"&&!(0,h0.alwaysValidSchema)(a,n)){const g=t.name("valid");l.removeAdditional==="failing"?(m(v,g,!1),t.if((0,Fa.not)(g),()=>{e.reset(),h(v)})):(m(v,g),s||t.if((0,Fa.not)(g),()=>t.break()))}}function m(v,g,y){const w={keyword:"additionalProperties",dataProp:v,dataPropType:h0.Type.Str};y===!1&&Object.assign(w,{compositeRule:!0,createErrors:!1,allErrors:!1}),e.subschema(w,g)}}};f0.default=Y1e;var Q2={};Object.defineProperty(Q2,"__esModule",{value:!0});const X1e=Ra,qF=Rn,Y2=Jn,HF=f0,Z1e={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&&HF.default.code(new X1e.KeywordCxt(i,HF.default,"additionalProperties"));const a=(0,qF.allSchemaProperties)(n);for(const u of a)i.definedProperties.add(u);i.opts.unevaluated&&a.length&&i.props!==!0&&(i.props=Y2.mergeEvaluated.props(t,(0,Y2.toHash)(a),i.props));const s=a.filter(u=>!(0,Y2.alwaysValidSchema)(i,n[u]));if(s.length===0)return;const l=t.name("valid");for(const u of s)c(u)?f(u):(t.if((0,qF.propertyInData)(t,o,u,i.opts.ownProperties)),f(u),i.allErrors||t.else().var(l,!0),t.endIf()),e.it.definedProperties.add(u),e.ok(l);function c(u){return i.opts.useDefaults&&!i.compositeRule&&n[u].default!==void 0}function f(u){e.subschema({keyword:"properties",schemaProp:u,dataProp:u},l)}}};Q2.default=Z1e;var X2={};Object.defineProperty(X2,"__esModule",{value:!0});const WF=Rn,p0=Dn,KF=Jn,GF=Jn,ebe={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,WF.allSchemaProperties)(n),l=s.filter(m=>(0,KF.alwaysValidSchema)(i,n[m]));if(s.length===0||l.length===s.length&&(!i.opts.unevaluated||i.props===!0))return;const c=a.strictSchema&&!a.allowMatchingProperties&&o.properties,f=t.name("valid");i.props!==!0&&!(i.props instanceof p0.Name)&&(i.props=(0,GF.evaluatedPropsToName)(t,i.props));const{props:u}=i;d();function d(){for(const m of s)c&&h(m),i.allErrors?p(m):(t.var(f,!0),p(m),t.if(f))}function h(m){for(const v in c)new RegExp(m).test(v)&&(0,KF.checkStrictMode)(i,`property ${v} matches pattern ${m} (use allowMatchingProperties)`)}function p(m){t.forIn("key",r,v=>{t.if((0,p0._)`${(0,WF.usePattern)(e,m)}.test(${v})`,()=>{const g=l.includes(m);g||e.subschema({keyword:"patternProperties",schemaProp:m,dataProp:v,dataPropType:GF.Type.Str},f),i.opts.unevaluated&&u!==!0?t.assign((0,p0._)`${u}[${v}]`,!0):!g&&!i.allErrors&&t.if((0,p0.not)(f),()=>t.break())})})}}};X2.default=ebe;var Z2={};Object.defineProperty(Z2,"__esModule",{value:!0});const tbe=Jn,nbe={keyword:"not",schemaType:["object","boolean"],trackErrors:!0,code(e){const{gen:t,schema:n,it:r}=e;if((0,tbe.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"}};Z2.default=nbe;var e_={};Object.defineProperty(e_,"__esModule",{value:!0});const rbe={keyword:"anyOf",schemaType:"array",trackErrors:!0,code:Rn.validateUnion,error:{message:"must match a schema in anyOf"}};e_.default=rbe;var t_={};Object.defineProperty(t_,"__esModule",{value:!0});const m0=Dn,obe=Jn,ibe={keyword:"oneOf",schemaType:"array",trackErrors:!0,error:{message:"must match exactly one schema in oneOf",params:({params:e})=>(0,m0._)`{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),l=t.name("_valid");e.setParams({passing:s}),t.block(c),e.result(a,()=>e.reset(),()=>e.error(!0));function c(){i.forEach((f,u)=>{let d;(0,obe.alwaysValidSchema)(o,f)?t.var(l,!0):d=e.subschema({keyword:"oneOf",schemaProp:u,compositeRule:!0},l),u>0&&t.if((0,m0._)`${l} && ${a}`).assign(a,!1).assign(s,(0,m0._)`[${s}, ${u}]`).else(),t.if(l,()=>{t.assign(a,!0),t.assign(s,u),d&&e.mergeEvaluated(d,m0.Name)})})}}};t_.default=ibe;var n_={};Object.defineProperty(n_,"__esModule",{value:!0});const abe=Jn,sbe={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,abe.alwaysValidSchema)(r,i))return;const s=e.subschema({keyword:"allOf",schemaProp:a},o);e.ok(o),e.mergeEvaluated(s)})}};n_.default=sbe;var r_={};Object.defineProperty(r_,"__esModule",{value:!0});const v0=Dn,JF=Jn,lbe={keyword:"if",schemaType:["object","boolean"],trackErrors:!0,error:{message:({params:e})=>(0,v0.str)`must match "${e.ifClause}" schema`,params:({params:e})=>(0,v0._)`{failingKeyword: ${e.ifClause}}`},code(e){const{gen:t,parentSchema:n,it:r}=e;n.then===void 0&&n.else===void 0&&(0,JF.checkStrictMode)(r,'"if" without "then" and "else" is ignored');const o=QF(r,"then"),i=QF(r,"else");if(!o&&!i)return;const a=t.let("valid",!0),s=t.name("_valid");if(l(),e.reset(),o&&i){const f=t.let("ifClause");e.setParams({ifClause:f}),t.if(s,c("then",f),c("else",f))}else o?t.if(s,c("then")):t.if((0,v0.not)(s),c("else"));e.pass(a,()=>e.error(!0));function l(){const f=e.subschema({keyword:"if",compositeRule:!0,createErrors:!1,allErrors:!1},s);e.mergeEvaluated(f)}function c(f,u){return()=>{const d=e.subschema({keyword:f},s);t.assign(a,s),e.mergeValidEvaluated(d,a),u?t.assign(u,(0,v0._)`${f}`):e.setParams({ifClause:f})}}}};function QF(e,t){const n=e.schema[t];return n!==void 0&&!(0,JF.alwaysValidSchema)(e,n)}r_.default=lbe;var o_={};Object.defineProperty(o_,"__esModule",{value:!0});const cbe=Jn,ube={keyword:["then","else"],schemaType:["object","boolean"],code({keyword:e,parentSchema:t,it:n}){t.if===void 0&&(0,cbe.checkStrictMode)(n,`"${e}" without "if" is ignored`)}};o_.default=ube,Object.defineProperty(q2,"__esModule",{value:!0});const fbe=qf,dbe=W2,hbe=Hf,pbe=K2,mbe=G2,vbe=zF,gbe=J2,ybe=f0,bbe=Q2,wbe=X2,kbe=Z2,xbe=e_,_be=t_,jbe=n_,Sbe=r_,Cbe=o_;function $be(e=!1){const t=[kbe.default,xbe.default,_be.default,jbe.default,Sbe.default,Cbe.default,gbe.default,ybe.default,vbe.default,bbe.default,wbe.default];return e?t.push(dbe.default,pbe.default):t.push(fbe.default,hbe.default),t.push(mbe.default),t}q2.default=$be;var i_={},a_={};Object.defineProperty(a_,"__esModule",{value:!0});const Wr=Dn,Tbe={keyword:"format",type:["number","string"],schemaType:"string",$data:!0,error:{message:({schemaCode:e})=>(0,Wr.str)`must match format "${e}"`,params:({schemaCode:e})=>(0,Wr._)`{format: ${e}}`},code(e,t){const{gen:n,data:r,$data:o,schema:i,schemaCode:a,it:s}=e,{opts:l,errSchemaPath:c,schemaEnv:f,self:u}=s;if(!l.validateFormats)return;o?d():h();function d(){const p=n.scopeValue("formats",{ref:u.formats,code:l.code.formats}),m=n.const("fDef",(0,Wr._)`${p}[${a}]`),v=n.let("fType"),g=n.let("format");n.if((0,Wr._)`typeof ${m} == "object" && !(${m} instanceof RegExp)`,()=>n.assign(v,(0,Wr._)`${m}.type || "string"`).assign(g,(0,Wr._)`${m}.validate`),()=>n.assign(v,(0,Wr._)`"string"`).assign(g,m)),e.fail$data((0,Wr.or)(y(),w()));function y(){return l.strictSchema===!1?Wr.nil:(0,Wr._)`${a} && !${g}`}function w(){const k=f.$async?(0,Wr._)`(${m}.async ? await ${g}(${r}) : ${g}(${r}))`:(0,Wr._)`${g}(${r})`,$=(0,Wr._)`(typeof ${g} == "function" ? ${k} : ${g}.test(${r}))`;return(0,Wr._)`${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(l.strictSchema===!1){u.logger.warn($());return}throw new Error($());function $(){return`unknown format "${i}" ignored in schema at path "${c}"`}}function w($){const x=$ instanceof RegExp?(0,Wr.regexpCode)($):l.code.formats?(0,Wr._)`${l.code.formats}${(0,Wr.getProperty)(i)}`:void 0,E=n.scopeValue("formats",{key:i,ref:$,code:x});return typeof $=="object"&&!($ instanceof RegExp)?[$.type||"string",$.validate,(0,Wr._)`${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,Wr._)`await ${g}(${r})`}return typeof v=="function"?(0,Wr._)`${g}(${r})`:(0,Wr._)`${g}.test(${r})`}}}};a_.default=Tbe,Object.defineProperty(i_,"__esModule",{value:!0});const Ebe=[a_.default];i_.default=Ebe;var Wf={};Object.defineProperty(Wf,"__esModule",{value:!0}),Wf.contentVocabulary=Wf.metadataVocabulary=void 0,Wf.metadataVocabulary=["title","description","default","deprecated","readOnly","writeOnly","examples"],Wf.contentVocabulary=["contentMediaType","contentEncoding","contentSchema"],Object.defineProperty($2,"__esModule",{value:!0});const Obe=T2,Abe=O2,Mbe=q2,Pbe=i_,YF=Wf,Nbe=[Obe.default,Abe.default,(0,Mbe.default)(),Pbe.default,YF.metadataVocabulary,YF.contentVocabulary];$2.default=Nbe;var s_={},XF={};(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.DiscrError=void 0,function(t){t.Tag="tag",t.Mapping="mapping"}(e.DiscrError||(e.DiscrError={}))})(XF),Object.defineProperty(s_,"__esModule",{value:!0});const Kf=Dn,l_=XF,ZF=yi,Ibe=Jn,Dbe={keyword:"discriminator",type:"object",schemaType:"object",error:{message:({params:{discrError:e,tagName:t}})=>e===l_.DiscrError.Tag?`tag "${t}" must be string`:`value of tag "${t}" must be in oneOf`,params:({params:{discrError:e,tag:t,tagName:n}})=>(0,Kf._)`{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 l=t.let("valid",!1),c=t.const("tag",(0,Kf._)`${n}${(0,Kf.getProperty)(s)}`);t.if((0,Kf._)`typeof ${c} == "string"`,()=>f(),()=>e.error(!1,{discrError:l_.DiscrError.Tag,tag:c,tagName:s})),e.ok(l);function f(){const h=d();t.if(!1);for(const p in h)t.elseIf((0,Kf._)`${c} === ${p}`),t.assign(l,u(h[p]));t.else(),e.error(!1,{discrError:l_.DiscrError.Mapping,tag:c,tagName:s}),t.endIf()}function u(h){const p=t.name("valid"),m=e.subschema({keyword:"oneOf",schemaProp:h},p);return e.mergeEvaluated(m,Kf.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,Ibe.schemaHasRulesButRef)($,i.self.RULES)&&($=ZF.resolveRef.call(i.self,i.schemaEnv.root,i.baseId,$==null?void 0:$.$ref),$ instanceof ZF.SchemaEnv&&($=$.schema));const x=(h=$==null?void 0:$.properties)===null||h===void 0?void 0:h[s];if(typeof x!="object")throw new Error(`discriminator: oneOf subschemas (or referenced schemas) must have "properties/${s}"`);v=v&&(m||g($)),y(x,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 x of k.enum)w(x,$);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]=$}}}};s_.default=Dbe;const Rbe={$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=eF,r=$2,o=s_,i=Rbe,a=["/properties"],s="http://json-schema.org/draft-07/schema";class l 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=l,Object.defineProperty(t,"__esModule",{value:!0}),t.default=l;var c=Ra;Object.defineProperty(t,"KeywordCxt",{enumerable:!0,get:function(){return c.KeywordCxt}});var f=Dn;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=Zh;Object.defineProperty(t,"ValidationError",{enumerable:!0,get:function(){return u.default}});var d=ep;Object.defineProperty(t,"MissingRefError",{enumerable:!0,get:function(){return d.default}})})(h2,h2.exports);var Lbe=h2.exports;const Bbe=$_(Lbe);let lp;const Fbe=[["items",l9,c9],["achievements",Ype,E9],["screens",v9,g9],["skills",w9,k9],["skillChecks",O9,A9],["buttons",h9,p9],["scripts",YB,v0e],["audio",o9,i9],["quests",u9,f9],["tooltips",S9,C9],["characters",_9,j9]],Vbe=["baseAssetsPath","baseDataPath","gameTitle","saveFileName","images","layout","settings","gameFlow","dialogPanel","splashScreens","notifications","hudStats","interactionTags","transitions","menuButtons","debugging","saves"],Gf=new Bbe({allErrors:!0});async function zbe(e){const t={...Qc};for(const n of Vbe){const r=e[n];r&&(typeof r=="object"&&!Array.isArray(r)?t[n]={...t[n],...r}:t[n]=r)}for(const n of Fbe){const r=n[0],o=n[1],i=n[2];let a=e[r];if(a&&typeof a=="string")try{if(a=await Jg(rV(e.baseDataPath,a)),!Gf.validate(o,a))throw console.error(Gf.errors),new Error(`${Gf.errorsText()}`)}catch(s){console.error(s),Wt(`${r} config error: ${s}`),a={...i}}a&&(Array.isArray(a)?t[r]=a:typeof a=="object"?t[r]={...i,...a}:t[r]=a)}if(lp=t,e.skills&&e&&lp.transitions)for(const n in lp.transitions)Qg[n]?Object.assign(Qg[n],lp.transitions[n]):Qg[n]=lp.transitions[n];return t}async function Ube(e){const t=await Jg(e.configPath);return e.baseAssetsPath?t.baseAssetsPath=e.baseAssetsPath:t.baseAssetsPath=t.baseAssetsPath||"",e.baseDataPath?t.baseDataPath=e.baseDataPath:t.baseDataPath=t.baseDataPath||"",Gf.validate(ZB,t)||(Wt("Config file validation failed."),console.log(Gf.errors),Wt(Gf.errorsText())),zbe(t)}function wt(){return pi().config}function $s(){return wt().audio}function rl(){return wt().skills}function cp(){return wt().skillChecks}function g0(){return wt().items}function up(){return wt().quests}function c_(){return wt().screens}function u_(){return wt().buttons}function fp(){return wt().tooltips}function f_(){return wt().characters}function dp(e){return e===Wx?x9:c_().screens[e]?c_().screens[e]:(Wt(`Screen config for screen ${e} doesn't exist`),x9)}function eV(e){const n=fp().tooltips.find(r=>r.keywords.includes(e));return n||(Wt(`Tooltip config for keyword ${e} not found`),null)}function d_(e){const t=wt().skills.skills[e];return t||Wt(`Skill config for skill ${e} doesn't exist`),t}function tV(e){const t=wt().skillChecks.skillChecks[e];return t||Wt(`Skill check config for skill check ${e} doesn't exist`),t}function nV(e){return!!wt().skillChecks.skillChecks[e]}function hp(e){return e.startsWith("http")?e:wt().images[e]?oa(wt().images[e]):oa(e)}function oa(e){return e.startsWith("http")?e:wt().baseAssetsPath?`${wt().baseAssetsPath}${e}`:e}function rV(e,t){return`${e}${t}`}function h_(e){return wt().baseDataPath?`${wt().baseDataPath}${e}`:e}function Jf(e){const t=u_().buttons[e];return t||Wt(`Button config for button ${e} doesn't exist`),t}function ol(e){const t=g0().items[e];return t||Wt(`Item config for skill ${e} doesn't exist`),t}function Qf(){return wt().achievements}function p_(e){const t=Qf().achievements[e];return t||Wt(`Achievement config for achievement ${e} doesn't exist`),t}function ou(e){return up().quests[e]}function y0(e,t){return ou(e).objectives[t]}function b0(){return wt().dialogPanel.width??Hpe}function oV(e,t,n){if(!n.startsWith("$"))return isNaN(Number(n))?[null,n]:[null,Number(n)];n=n.substring(1);const r=/\[/,o=/\]/;let i=n.search(r);n.search(o);let a=n,s=t,l=0;for(;l<n.length;){if(i>l||i===-1){const c=i>l?i:n.length;let f=n.substring(l,c);isNaN(Number(f))||(f=Number(f)),l>0&&(s=s[a]),[s,a]=Hbe(s,f)}if(i!==-1){l=i;const c=n.substring(i+1),f=qbe(c)+i,u=n.substring(i+1,f),[d,h]=oV(e,e,u);let p=h;d&&(p=d[h]),typeof p=="number"||!isNaN(Number(p))?p=Number(p):typeof p!="string"&&console.error(`invalid array index (${p}) key type when compiling: ${n}`),s=s[a],a=p,l=f+1;const m=n.substring(l);i=m.search(r),i!==-1&&(i+=l),m.search(o)}else l=n.length}return[s,a]}function qbe(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&&Wt(`Could not find closing bracket in ${e}`)}return n}function Hbe(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 w0(e,t){return oV(e,e,t)}function Wbe(e,t){return w0(e,t)}function iV(e,t,n){const[r,o]=w0(e,t);r[o]=n}function aV(e,t,n){const[r,o]=w0(e,t),i=r[o]||0;r[o]=n+i}function Yf(){const e=an(),t=Dr(),n=Ia(),r=lo(),o=an().scope,i={data:e.data,global:e.globalData,skills:t.skills,skillChecks:t.skillChecks,buttons:n.buttons,items:r.items,quests:Fo().quests,stats:_s().hudStats,scope:o,config:wt(),gameOptions:Zt().options,baseSettings:Da().baseSettings,customSettings:Da().customSettings};return new Proxy(i,{get:(s,l,c)=>{const f=an().scope,u=an().data;return typeof f[l]<"u"?f[l]:typeof u[l]<"u"?u[l]:Reflect.get(s,l,c)},set:(s,l,c,f)=>{const u=an().scope,d=an().data;if(typeof u[l]<"u")u[l]=c;else{if(typeof s[l]<"u")return Reflect.set(s,l,c,f);typeof c=="object"?d[l]={}:d[l]=c}return!0}})}function or(e){if(e===null)return null;if(typeof e=="object")if(Array.isArray(e)){const t=[];for(const n in e)t[n]=or(e[n]);return t}else{const t={};for(const n in e)t[n]=or(e[n]);return t}else return e}function m_(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]=m_(e[o],t);return r}else{const r={};for(const o in e)r[o]=m_(e[o],t);return r}}else return t(e)}const Dr=ao("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:or(this.skillChecks),skills:or(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=Vh(this.skillChecks,e.skillChecks),this.skills=Vh(this.skills,e.skills)},setupSkills(e){const t=e.skills;for(const n in t)this.skills[n]={id:n,level:t[n].startingLevel||0,xp:0}},reset(e){this.$reset(),this.setupSkills(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||Wt(`Skill ${e} doesn't exist`),n.xp+=t,n.xp>=rl().skillOptions.xpPerLevel&&(n.xp=0,n.level++,this.levelledUp(e))},setSkillLevel(e,t){const n=this.getSkill(e);n||Wt(`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=rl().skills[e].name,n=this.skills[e].level;rl().skillOptions.notifyLevelUp&&vi().addNotification(`Your skill in ${t} is now level ${n}`)}}});function il(e){return Array.isArray?Array.isArray(e):cV(e)==="[object Array]"}const Kbe=1/0;function Gbe(e){if(typeof e=="string")return e;let t=e+"";return t=="0"&&1/e==-Kbe?"-0":t}function Jbe(e){return e==null?"":Gbe(e)}function Ts(e){return typeof e=="string"}function sV(e){return typeof e=="number"}function Qbe(e){return e===!0||e===!1||Ybe(e)&&cV(e)=="[object Boolean]"}function lV(e){return typeof e=="object"}function Ybe(e){return lV(e)&&e!==null}function Ni(e){return e!=null}function v_(e){return!e.trim().length}function cV(e){return e==null?e===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(e)}const YCe="Extended search is not available",Xbe="Incorrect 'index' type",Zbe=e=>`Invalid value for key ${e}`,ewe=e=>`Pattern length exceeds max of ${e}.`,twe=e=>`Missing ${e} property in key`,nwe=e=>`Property 'weight' in key '${e}' must be a positive integer`,uV=Object.prototype.hasOwnProperty;class rwe{constructor(t){this._keys=[],this._keyMap={};let n=0;t.forEach(r=>{let o=fV(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 fV(e){let t=null,n=null,r=null,o=1,i=null;if(Ts(e)||il(e))r=e,t=dV(e),n=g_(e);else{if(!uV.call(e,"name"))throw new Error(twe("name"));const a=e.name;if(r=a,uV.call(e,"weight")&&(o=e.weight,o<=0))throw new Error(nwe(a));t=dV(a),n=g_(a),i=e.getFn}return{path:t,id:n,weight:o,src:r,getFn:i}}function dV(e){return il(e)?e:e.split(".")}function g_(e){return il(e)?e.join("."):e}function owe(e,t){let n=[],r=!1;const o=(i,a,s)=>{if(Ni(i))if(!a[s])n.push(i);else{let l=a[s];const c=i[l];if(!Ni(c))return;if(s===a.length-1&&(Ts(c)||sV(c)||Qbe(c)))n.push(Jbe(c));else if(il(c)){r=!0;for(let f=0,u=c.length;f<u;f+=1)o(c[f],a,s+1)}else a.length&&o(c,a,s+1)}};return o(e,Ts(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:owe,ignoreLocation:!1,ignoreFieldNorm:!1,fieldNormWeight:1}};const iwe=/[^ ]+/g;function awe(e=1,t=3){const n=new Map,r=Math.pow(10,t);return{get(o){const i=o.match(iwe).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 y_{constructor({getFn:t=mn.getFn,fieldNormWeight:n=mn.fieldNormWeight}={}){this.norm=awe(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,Ts(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();Ts(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(!Ni(t)||v_(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(Ni(a)){if(il(a)){let s=[];const l=[{nestedArrIndex:-1,value:a}];for(;l.length;){const{nestedArrIndex:c,value:f}=l.pop();if(Ni(f))if(Ts(f)&&!v_(f)){let u={v:f,i:c,n:this.norm.get(f)};s.push(u)}else il(f)&&f.forEach((u,d)=>{l.push({nestedArrIndex:d,value:u})})}r.$[i]=s}else if(Ts(a)&&!v_(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 hV(e,t,{getFn:n=mn.getFn,fieldNormWeight:r=mn.fieldNormWeight}={}){const o=new y_({getFn:n,fieldNormWeight:r});return o.setKeys(e.map(fV)),o.setSources(t),o.create(),o}function swe(e,{getFn:t=mn.getFn,fieldNormWeight:n=mn.fieldNormWeight}={}){const{keys:r,records:o}=e,i=new y_({getFn:t,fieldNormWeight:n});return i.setKeys(r),i.setIndexRecords(o),i}function k0(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 lwe(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 iu=32;function cwe(e,t,n,{location:r=mn.location,distance:o=mn.distance,threshold:i=mn.threshold,findAllMatches:a=mn.findAllMatches,minMatchCharLength:s=mn.minMatchCharLength,includeMatches:l=mn.includeMatches,ignoreLocation:c=mn.ignoreLocation}={}){if(t.length>iu)throw new Error(ewe(iu));const f=t.length,u=e.length,d=Math.max(0,Math.min(r,u));let h=i,p=d;const m=s>1||l,v=m?Array(u):[];let g;for(;(g=e.indexOf(t,p))>-1;){let E=k0(t,{currentLocation:g,expectedLocation:d,distance:o,ignoreLocation:c});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,M=k;for(;R<M;)k0(t,{errors:E,currentLocation:d+M,expectedLocation:d,distance:o,ignoreLocation:c})<=h?R=M:k=M,M=Math.floor((k-R)/2+R);k=M;let j=Math.max(1,d-M+1),C=a?u:Math.min(d+M,u)+f,O=Array(C+2);O[C+1]=(1<<E)-1;for(let T=C;T>=j;T-=1){let L=T-1,H=n[e.charAt(L)];if(m&&(v[L]=+!!H),O[T]=(O[T+1]<<1|1)&H,E&&(O[T]|=(y[T+1]|y[T])<<1|1|y[T+1]),O[T]&$&&(w=k0(t,{errors:E,currentLocation:L,expectedLocation:d,distance:o,ignoreLocation:c}),w<=h)){if(h=w,p=L,p<=d)break;j=Math.max(1,2*d-p)}}if(k0(t,{errors:E+1,currentLocation:d,expectedLocation:d,distance:o,ignoreLocation:c})>h)break;y=O}const x={isMatch:p>=0,score:Math.max(.001,w)};if(m){const E=lwe(v,s);E.length?l&&(x.indices=E):x.isMatch=!1}return x}function uwe(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 pV{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:l=mn.isCaseSensitive,ignoreLocation:c=mn.ignoreLocation}={}){if(this.options={location:n,threshold:r,distance:o,includeMatches:i,findAllMatches:a,minMatchCharLength:s,isCaseSensitive:l,ignoreLocation:c},this.pattern=l?t:t.toLowerCase(),this.chunks=[],!this.pattern.length)return;const f=(d,h)=>{this.chunks.push({pattern:d,alphabet:uwe(d),startIndex:h})},u=this.pattern.length;if(u>iu){let d=0;const h=u%iu,p=u-h;for(;d<p;)f(this.pattern.substr(d,iu),d),d+=iu;if(h){const m=u-iu;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:l,ignoreLocation:c}=this.options;let f=[],u=0,d=!1;this.chunks.forEach(({pattern:p,alphabet:m,startIndex:v})=>{const{isMatch:g,score:y,indices:w}=cwe(t,p,m,{location:o+v,distance:i,threshold:a,findAllMatches:s,minMatchCharLength:l,includeMatches:r,ignoreLocation:c});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 nc{constructor(t){this.pattern=t}static isMultiMatch(t){return mV(t,this.multiRegex)}static isSingleMatch(t){return mV(t,this.singleRegex)}search(){}}function mV(e,t){const n=e.match(t);return n?n[1]:null}class fwe extends nc{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 dwe extends nc{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 hwe extends nc{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 pwe extends nc{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 mwe extends nc{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 vwe extends nc{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 vV extends nc{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:l=mn.isCaseSensitive,ignoreLocation:c=mn.ignoreLocation}={}){super(t),this._bitapSearch=new pV(t,{location:n,threshold:r,distance:o,includeMatches:i,findAllMatches:a,minMatchCharLength:s,isCaseSensitive:l,ignoreLocation:c})}static get type(){return"fuzzy"}static get multiRegex(){return/^"(.*)"$/}static get singleRegex(){return/^(.*)$/}search(t){return this._bitapSearch.searchIn(t)}}class gV extends nc{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 b_=[fwe,gV,hwe,pwe,vwe,mwe,dwe,vV],yV=b_.length,gwe=/ +(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/,ywe="|";function bwe(e,t={}){return e.split(ywe).map(n=>{let r=n.trim().split(gwe).filter(i=>i&&!!i.trim()),o=[];for(let i=0,a=r.length;i<a;i+=1){const s=r[i];let l=!1,c=-1;for(;!l&&++c<yV;){const f=b_[c];let u=f.isMultiMatch(s);u&&(o.push(new f(u,t)),l=!0)}if(!l)for(c=-1;++c<yV;){const f=b_[c];let u=f.isSingleMatch(s);if(u){o.push(new f(u,t));break}}}return o})}const wwe=new Set([vV.type,gV.type]);class kwe{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:l=mn.threshold,distance:c=mn.distance}={}){this.query=null,this.options={isCaseSensitive:n,includeMatches:r,minMatchCharLength:o,findAllMatches:a,ignoreLocation:i,location:s,threshold:l,distance:c},this.pattern=n?t:t.toLowerCase(),this.query=bwe(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 l=0,c=n.length;l<c;l+=1){const f=n[l];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;wwe.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 w_=[];function xwe(...e){w_.push(...e)}function k_(e,t){for(let n=0,r=w_.length;n<r;n+=1){let o=w_[n];if(o.condition(e,t))return new o(e,t)}return new pV(e,t)}const x0={AND:"$and",OR:"$or"},x_={PATH:"$path",PATTERN:"$val"},__=e=>!!(e[x0.AND]||e[x0.OR]),_we=e=>!!e[x_.PATH],jwe=e=>!il(e)&&lV(e)&&!__(e),bV=e=>({[x0.AND]:Object.keys(e).map(t=>({[t]:e[t]}))});function wV(e,t,{auto:n=!0}={}){const r=o=>{let i=Object.keys(o);const a=_we(o);if(!a&&i.length>1&&!__(o))return r(bV(o));if(jwe(o)){const l=a?o[x_.PATH]:i[0],c=a?o[x_.PATTERN]:o[l];if(!Ts(c))throw new Error(Zbe(l));const f={keyId:g_(l),pattern:c};return n&&(f.searcher=k_(c,t)),f}let s={children:[],operator:i[0]};return i.forEach(l=>{const c=o[l];il(c)&&c.forEach(f=>{s.children.push(r(f))})}),s};return __(e)||(e=bV(e)),r(e)}function Swe(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 Cwe(e,t){const n=e.matches;t.matches=[],Ni(n)&&n.forEach(r=>{if(!Ni(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 $we(e,t){t.score=e.score}function Twe(e,t,{includeMatches:n=mn.includeMatches,includeScore:r=mn.includeScore}={}){const o=[];return n&&o.push(Cwe),r&&o.push($we),e.map(i=>{const{idx:a}=i,s={item:t[a],refIndex:a};return o.length&&o.forEach(l=>{l(i,s)}),s})}class Xf{constructor(t,n={},r){this.options={...mn,...n},this.options.useExtendedSearch,this._keyStore=new rwe(this.options.keys),this.setCollection(t,r)}setCollection(t,n){if(this._docs=t,n&&!(n instanceof y_))throw new Error(Xbe);this._myIndex=n||hV(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight})}add(t){Ni(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 l=Ts(t)?Ts(this._docs[0])?this._searchStringList(t):this._searchObjectList(t):this._searchLogical(t);return Swe(l,{ignoreFieldNorm:s}),i&&l.sort(a),sV(n)&&n>-1&&(l=l.slice(0,n)),Twe(l,this._docs,{includeMatches:r,includeScore:o})}_searchStringList(t){const n=k_(t,this.options),{records:r}=this._myIndex,o=[];return r.forEach(({v:i,i:a,n:s})=>{if(!Ni(i))return;const{isMatch:l,score:c,indices:f}=n.searchIn(i);l&&o.push({item:i,idx:a,matches:[{score:c,value:i,norm:s,indices:f}]})}),o}_searchLogical(t){const n=wV(t,this.options),r=(s,l,c)=>{if(!s.children){const{keyId:u,searcher:d}=s,h=this._findMatches({key:this._keyStore.get(u),value:this._myIndex.getValueForItemAtKeyId(l,u),searcher:d});return h&&h.length?[{idx:c,item:l,matches:h}]:[]}const f=[];for(let u=0,d=s.children.length;u<d;u+=1){const h=s.children[u],p=r(h,l,c);if(p.length)f.push(...p);else if(s.operator===x0.AND)return[]}return f},o=this._myIndex.records,i={},a=[];return o.forEach(({$:s,i:l})=>{if(Ni(s)){let c=r(n,s,l);c.length&&(i[l]||(i[l]={idx:l,item:s,matches:[]},a.push(i[l])),c.forEach(({matches:f})=>{i[l].matches.push(...f)}))}}),a}_searchObjectList(t){const n=k_(t,this.options),{keys:r,records:o}=this._myIndex,i=[];return o.forEach(({$:a,i:s})=>{if(!Ni(a))return;let l=[];r.forEach((c,f)=>{l.push(...this._findMatches({key:c,value:a[f],searcher:n}))}),l.length&&i.push({idx:s,item:a,matches:l})}),i}_findMatches({key:t,value:n,searcher:r}){if(!Ni(n))return[];let o=[];if(il(n))n.forEach(({v:i,i:a,n:s})=>{if(!Ni(i))return;const{isMatch:l,score:c,indices:f}=r.searchIn(i);l&&o.push({score:c,key:t,value:i,idx:a,norm:s,indices:f})});else{const{v:i,n:a}=n,{isMatch:s,score:l,indices:c}=r.searchIn(i);s&&o.push({score:l,key:t,value:i,norm:a,indices:c})}return o}}Xf.version="6.6.2",Xf.createIndex=hV,Xf.parseIndex=swe,Xf.config=mn,Xf.parseQuery=wV,xwe(kwe);class Ewe extends d2{setup(){const t=()=>{this.emit("preUpdate"),this.emit("update"),this.emit("postUpdate"),requestAnimationFrame(t)};t()}}const _0=new Ewe;ut.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 l(p,m){return{x:p.x/m.x,y:p.y/m.y}}e.divide=l;function c(p,m){return n(i(p,m))}e.distance=c;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})(ut.Vec2||(ut.Vec2={}));class Owe{constructor(){ro(this,"gameActions",{});ro(this,"keyboardState",{});ro(this,"actions",{});ro(this,"gamepad",null)}getGamepad(){const t=navigator.getGamepads().filter(n=>n!==null);if(t.length>0)return t[0]}startListening(){this.updateGamepad(),window.addEventListener("keydown",t=>{console.log("keydown",t.key);const n=this.getKeyboardState(t.key).current;this.keyboardState[t.key]={previous:n,current:!0}}),window.addEventListener("keyup",t=>{console.log("keyup",t.key);const n=this.getKeyboardState(t.key).current;this.keyboardState[t.key]={previous:n,current:!1}}),_0.on("preUpdate",()=>{this.update()})}updateGamepad(){const t=this.getGamepad();t?this.gamepad?this.updateAllNarratButtons(t,this.gamepad):this.gamepad=this.setupNarratGamepad(t):this.gamepad=null}setupNarratGamepad(t){return{id:t.id,gamepad:t,buttons:t.buttons.map((r,o)=>this.getNarratButtonFromGamepad(r,r,o))}}updateAllNarratButtons(t,n){for(const[r,o]of t.buttons.entries()){const i=n.buttons[r];i.previous=or(i.state),i.state=or(o)}}getNarratButtonFromGamepad(t,n,r){return{index:r,state:or(n),previous:or(n)}}addAction(t){if(this.gameActions[t.id]=t,t.type==="button"){const n={config:t,active:!1,justPressed:!1,justReleased:!1};this.actions[t.id]={state:n,previous:or(n)}}else{const n={config:t,value:ut.Vec2.create(0,0),fullState:{left:0,right:0,up:0,down:0}};this.actions[t.id]={state:n,previous:or(n)}}}getAnalog(t){return this.actions[t]||Wt(`Action ${t} does not exist`),this.actions[t].state}getButton(t){return this.actions[t]||Wt(`Action ${t} does not exist`),this.actions[t].state}getKeyboardState(t){return this.keyboardState[t]?this.keyboardState[t]:(this.keyboardState[t]={current:!1,previous:!1},this.keyboardState[t])}getGamepadState(t){return this.gamepad&&this.gamepad.buttons.length>t?{current:this.gamepad.buttons[t].state,previous:this.gamepad.buttons[t].previous}:null}debugGamepad(){if(this.gamepad)for(const[t,n]of this.gamepad.buttons.entries())n.state.pressed,n.previous.pressed}update(){this.updateGamepad(),this.debugGamepad();for(const t of Object.values(this.gameActions))if(t.type==="button"){const n=this.actions[t.id],r=or(n.state),o=n.state;n.previous=r,t.action==="press"&&(t.keybinds.some(a=>{let s=!1;if(typeof a.keyboardKey=="string"&&this.getKeyboardState(a.keyboardKey).current===!0&&(s=!0),typeof a.gamepadButton=="number"){const l=this.getGamepadState(a.gamepadButton);l&&l.current.pressed===!0&&(s=!0)}return s})?o.active=!0:o.active=!1,o.active&&!r.active?o.justPressed=!0:o.justPressed=!1,!o.active&&r.active?o.justReleased=!0:o.justReleased=!1)}else if(t.type==="analog"){const n=this.actions[t.id],r=n.state;or(n.state),n.previous=or(r);let o=ut.Vec2.create(0,0);t.keybinds.forEach(i=>{this.getKeyboardState(i.left).current&&(r.fullState.left=1,o.x-=1),this.getKeyboardState(i.right).current&&(r.fullState.right=1,o.x+=1),this.getKeyboardState(i.up).current&&(r.fullState.up=1,o.y-=1),this.getKeyboardState(i.down).current&&(r.fullState.down=1,o.y+=1)}),o=ut.Vec2.normalize(o),r.value=o}}}const j0=new Owe,Awe=[{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:"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}]}],zo=ao("inputs",{state:()=>({inputStack:[],baseInputListener:null}),actions:{setupInputs(){j0.startListening();for(const e of Awe)j0.addAction(e);this.listenToBaseNarratInputs(),_0.on("preUpdate",()=>{for(const[e,t]of Object.entries(j0.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})},listenToBaseNarratInputs(){},triggerListeners(e,t,n){console.log(`Triggering action ${e} ${t}`);const r=this.inputStack[this.inputStack.length-1];if(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 j0},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}}}),Mwe=b.createElementVNode("h3",{class:"title"},"Jump to label",-1),Pwe={key:0,class:"search-results"},Nwe={key:1},Iwe=[b.createElementVNode("h3",null,"No matches found",-1)],Dwe=b.defineComponent({__name:"debug-jumping",emits:["close","jump"],setup(e,{emit:t}){let n;const r=b.ref(null),o=b.ref(""),i=b.ref([]),a=b.ref(0),s=b.ref(null);function l(){const u=o.value,d=n.search(u);i.value=d.map(h=>h.item),i.value.length>0&&a.value>i.value.length-1&&(a.value=i.value.length-1)}function c(u){if(u===a.value)return{background:"var(--light-background)"}}const f=b.computed(()=>Object.keys(bn.script).sort());return b.onMounted(()=>{Zt().debugMode=!0,n=new Xf(f.value,{includeScore:!0}),i.value=f.value,a.value=0,setTimeout(()=>{b.nextTick(()=>{s.value&&s.value.focus()})},10),r.value=zo().registerInputListener("debug-jumping",{up:{press:()=>{a.value>0?a.value--:a.value=i.value.length-1}},down:{press:()=>{i.value.length>a.value+1?a.value++:a.value=0}},continue:{press:()=>{if(i.value.length>0&&a.value<i.value.length){const u=i.value[a.value];an().jumpToLabel(u),t("close")}}},escape:{press:()=>{t("close")}}})}),b.onUnmounted(()=>{r.value&&zo().unregisterInputListener(r.value),Zt().debugMode=!1}),(u,d)=>(b.openBlock(),b.createBlock(al,{onClose:d[1]||(d[1]=h=>u.$emit("close")),containerCssClass:"jump-menu-container"},{header:b.withCtx(()=>[Mwe]),body:b.withCtx(()=>[b.withDirectives(b.createElementVNode("input",{type:"text",class:"label-input input",ref_key:"search",ref:s,"onUpdate:modelValue":d[0]||(d[0]=h=>o.value=h),onInput:l},null,544),[[b.vModelText,o.value]]),i.value.length>0?(b.openBlock(),b.createElementBlock("div",Pwe,[(b.openBlock(!0),b.createElementBlock(b.Fragment,null,b.renderList(i.value,(h,p)=>(b.openBlock(),b.createElementBlock("div",{class:"search-result",style:b.normalizeStyle(c(p)),key:p},b.toDisplayString(h),5))),128))])):(b.openBlock(),b.createElementBlock("div",Nwe,Iwe))]),_:1}))}}),r$e="",Rwe=b.defineComponent({components:{ModalWindow:al,DebugJumping:Dwe},setup(){const e=Dr(),t=b.computed(()=>e.skills),n=b.computed(()=>e.skillChecks);return{skills:t,skillChecks:n}},data(){return{showDebug:!1,jumping:!1,inputListener:null}},mounted(){window.addEventListener("keydown",e=>{this.jumping||(e.key==="d"&&this.toggle(),e.key==="j"&&this.jump())})},methods:{closeJumping(){this.jumping=!1},labelSelected(e){const t=e.target.value;an().jumpToLabel(t),this.close()},close(){this.showDebug=!1,this.endDebug()},closeErrors(){Zt().clearErrors()},open(){this.showDebug=!0,this.startDebug();const e=an(),t=Zt(),n=Fo(),r=lo(),o=Dr();this.$nextTick(()=>{new xL({target:this.$refs.variablesViewer,props:{content:{text:void 0,json:{data:this.variables,quests:n.quests,items:r.items,skills:o.skills,skillChecks:o.skillChecks}},onChange:i=>{e.overrideData(i.json.data),n.quests=i.json.quests,r.items=i.json.items,o.skills=i.json.skills,o.skillChecks=i.json.skillChecks}}}),new xL({target:this.$refs.stateViewer,props:{content:{text:void 0,json:t.getAllStates()},onChange:i=>{t.overrideStates(i.json)}}})})},toggle(){this.showDebug?this.close():this.open()},startDebug(){Zt().debugMode=!0},endDebug(){Zt().debugMode=!1},jump(){this.jumping=!0,this.startDebug()},save(){Zt().autoSaveGame({})},resetSave(){cpe()},resetGlobalSave(){Zt().resetGlobalSave()},wordCount(){const t=Object.values(this.script).reduce((n,r)=>(ki.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 O0(e/1e3)}},computed:{...Kc(an,["data"]),...Kc(Zt,["playTime","errors","playing","flowState"]),labels(){const e=this.script;return Object.keys(e).sort()},script(){return bn.script},variables(){return this.data}}}),o$e="",Lwe={class:"debug-menu"},Bwe={key:0,class:"debug-info"},Fwe=[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)],Vwe=b.createElementVNode("h3",{class:"title"},"Error(s)",-1),zwe=["innerHTML"],Uwe=b.createElementVNode("h3",{class:"title"},"Debug Menu!",-1),qwe={class:"container"},Hwe=b.createElementVNode("option",{class:"option",selected:"",disabled:""},"Jump to a label",-1),Wwe=["value"],Kwe={class:"grid grid-cols-3 gap-4"},Gwe=b.createElementVNode("h2",null,"Variables Editor",-1),Jwe={ref:"variablesViewer"},Qwe=b.createElementVNode("h2",null,"Skill Checks",-1),Ywe={class:"table-auto"},Xwe=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),Zwe=b.createElementVNode("h2",null,"App State editor (entire app and engine",-1),eke=b.createElementVNode("h3",{style:{color:"pink"}}," Use for debugging, editing some of those things can cause issues ",-1),tke={ref:"stateViewer"};function nke(e,t,n,r,o,i){const a=b.resolveComponent("DebugJumping"),s=b.resolveComponent("ModalWindow");return b.openBlock(),b.createElementBlock("div",Lwe,[b.createElementVNode("button",{onClick:t[0]||(t[0]=(...l)=>e.open&&e.open(...l)),class:"button debug-button"},"Debug Menu"),!e.playing&&e.flowState==="menu"?(b.openBlock(),b.createElementBlock("div",Bwe,Fwe)):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(()=>[Vwe]),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,(l,c)=>(b.openBlock(),b.createElementBlock("li",{key:c,class:b.normalizeClass(["error-message list-disc",l.type==="error"?"error":"warning"]),innerHTML:l.text},null,10,zwe))),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(()=>[Uwe]),body:b.withCtx(()=>[b.createElementVNode("div",qwe,[b.createTextVNode(" Hello this is the debug menu. "),b.createElementVNode("select",{class:"select",name:"label-selector",onChange:t[1]||(t[1]=l=>e.labelSelected(l))},[Hwe,(b.openBlock(!0),b.createElementBlock(b.Fragment,null,b.renderList(e.labels,l=>(b.openBlock(),b.createElementBlock("option",{class:"option",value:l,key:l},b.toDisplayString(l),9,Wwe))),128))],32),b.createElementVNode("div",Kwe,[b.createElementVNode("button",{onClick:t[2]||(t[2]=(...l)=>e.wordCount&&e.wordCount(...l)),class:"button"},"Word Count"),b.createElementVNode("button",{onClick:t[3]||(t[3]=(...l)=>e.save&&e.save(...l)),class:"button"},"Save Game"),b.createElementVNode("button",{onClick:t[4]||(t[4]=(...l)=>e.resetSave&&e.resetSave(...l)),class:"button"},"Reset Save"),b.createElementVNode("button",{onClick:t[5]||(t[5]=(...l)=>e.resetGlobalSave&&e.resetGlobalSave(...l)),class:"button"}," Reset GLOBAL Save ")]),b.createElementVNode("h3",null,"Play time: "+b.toDisplayString(e.getPlayTimeString()),1),Gwe,b.createElementVNode("div",Jwe,null,512),Qwe,b.createElementVNode("table",Ywe,[Xwe,b.createElementVNode("tbody",null,[(b.openBlock(!0),b.createElementBlock(b.Fragment,null,b.renderList(e.skillChecks,(l,c)=>(b.openBlock(),b.createElementBlock("tr",{key:c},[b.createElementVNode("td",null,b.toDisplayString(c),1),b.createElementVNode("td",null,b.toDisplayString(l.happened?"✅":"❌"),1),b.createElementVNode("td",null,b.toDisplayString(l.happened?l.succeeded?"✅":"❌":"NA"),1)]))),128))])]),Zwe,eke,b.createElementVNode("div",tke,null,512)])]),_:1},8,["onClose"])):b.createCommentVNode("",!0)])}const rke=la(Rwe,[["render",nke]]),oke=["src"],ike=["innerHTML"],ake=["innerHTML"],ske=b.defineComponent({__name:"notification-toast",setup(e){const t=vi(),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(oa)(a.icon),class:"notification-icon",style:b.normalizeStyle(r(a))},null,12,oke)):b.createCommentVNode("",!0),b.createElementVNode("span",{innerHTML:a.text,class:"notification-text"},null,8,ike),a.description?(b.openBlock(),b.createElementBlock("p",{key:1,innerHTML:a.description,class:"notification-description"},null,8,ake)):b.createCommentVNode("",!0)]))),128))]),_:1}))}}),a$e="";function kV(e,t=50,n={}){let r;const o=n.isImmediate??!1,i=n.callback??!1,a=n.maxWait;let s=Date.now(),l=[];function c(){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),l.forEach(({resolve:w})=>w(y)),l=[]}},v=o&&r===void 0;r!==void 0&&clearTimeout(r);const g=c();if(r=setTimeout(m,g),v){const y=e.apply(d,u);return i&&i(y),h(y)}l.push({resolve:h,reject:p})})};return f.cancel=function(u){r!==void 0&&clearTimeout(r),l.forEach(({reject:d})=>d(u)),l=[]},f}function pp(e){if(!e.listener)return console.warn("No input listener provided for navigation"),null;const t=b.ref(0),n=b.computed(()=>e.mode==="grid"?t.value%e.columns:0),r=b.ref([]);function o(){var $,x;return($=e.container)!=null&&$.value?e.container.value.children:(x=e.elements)!=null&&x.value?e.elements.value.filter(E=>E!==null):[]}function i(){r.value=o()}const a=b.computed(()=>c(t.value));function s($){return r.value?$>=0&&$<r.value.length:!1}function l($){const x=t.value;s($)&&(t.value=$,a.value&&(a.value.classList.add("selected"),c(x).classList.remove("selected"),e.onSelected&&e.onSelected($)))}function c($){return r.value?r.value[$]:null}function f(){r.value&&(t.value===0?e.loopForbidden||l(r.value.length-1):l(t.value-1))}function u(){r.value&&(t.value===r.value.length-1?e.loopForbidden||l(0):l(t.value+1))}function d(){if(!r.value)return;const $=e,x=t.value;!e.loopForbidden&&x<$.columns?l(r.value.length-1):l(t.value-e.columns)}function h(){if(!r.value)return;const $=e,x=t.value;!e.loopForbidden&&x>=r.value.length-$.columns?l(0):l(t.value+e.columns)}function p(){e.mode==="grid"?d():e.mode==="list"&&f()}function m(){e.mode==="grid"?h():e.mode==="list"&&(console.log("button down"),u())}function v(){(e.mode==="grid"||e.mode==="list")&&f()}function g(){(e.mode==="grid"||e.mode==="list")&&u()}function y(){e.onChosen&&e.onChosen(t.value)}b.onMounted(()=>{k()});function w(){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)}function k(){e.listener&&(i(),e.onlyVertical||(e.listener.actions.left={press:v},e.listener.actions.right={press:g}),e.onlyHorizontal||(e.listener.actions.up={press:p},e.listener.actions.down={press:m}),e.noChoosing||(e.listener.actions.continue={press:y}),l(0))}return b.onUnmounted(()=>{w()}),b.watch(()=>{var $;return($=e.elements)==null?void 0:$.value},$=>{$&&i()}),{selectedIndex:t,selectedElement:a,currentColumn:n,buttonDown:m,buttonUp:p,buttonLeft:v,buttonRight:g,selectUp:d,selectDown:h,selectPrevious:f,selectNext:u,select:l,disable:w,mount:k}}const lke={class:"used-save-slot flex flex-row justify-between items-center grow"},cke={class:"flex flex-col save-slot-number-container"},uke={class:"save-slot-number"},fke={class:"flex flex-col justify-center save-info"},dke={key:1,class:"save-name"},hke={class:"flex flex-col"},pke={key:0},mke={key:1},vke={key:2},gke=["onClick"],j_=b.defineComponent({__name:"save-slot-ui",props:{saveSlot:{},id:{},actions:{},selected:{type:Boolean},inputListener:{}},emits:["choice","cancel"],setup(e,{expose:t,emit:n}){var w;const r=e,o=b.ref(null),i=b.ref(null),a=b.ref(null);t({slotContainer:a});const s=b.ref(((w=r.saveSlot.saveData)==null?void 0:w.metadata.name)??"Empty Save"),l=b.ref(0),c=b.computed(()=>r.saveSlot.saveData!==null),f=b.computed(()=>r.saveSlot.saveData),u=b.computed(()=>wt().saves.mode),d=b.computed(()=>{const k=r.saveSlot.saveData;if(k&&k.screen.layers[0]){const $=dp(k.screen.layers[0]);if($)return{backgroundImage:`url(${hp($.background)})`}}return!1});function h(k){n("choice",k)}function p(k){return f.value?O0(f.value.main.playTime/1e3):"00:00:00"}function m(){f.value&&mpe(r.saveSlot.id,s.value)}function v(){const k=wt().saves.slots;let $="";const x=r.saveSlot.slotNumber;return x===0&&wt().saves.mode==="manual"?"AUTO":(k>=10&&x<10&&($+="0"),k>=100&&x<100&&($+="0"),$+x)}function g(){o.value=pp({mode:"list",container:i,listener:r.inputListener,onlyHorizontal:!0,onSelected:k=>{l.value=k},onChosen:k=>{h(k)}}),o.value.mount()}function y(){o.value.disable(),o.value=null}return b.watch(()=>r.selected,(k,$)=>{k&&!o.value&&g(),!k&&o.value&&y()}),b.onUnmounted(()=>{o.value&&y()}),(k,$)=>(b.openBlock(),b.createElementBlock("div",{class:"save-slot flex flex-row",ref_key:"slotContainer",ref:a},[b.createElementVNode("div",lke,[b.createElementVNode("div",cke,[b.createElementVNode("h1",uke,b.toDisplayString(v()),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",fke,[c.value?b.withDirectives((b.openBlock(),b.createElementBlock("input",{key:0,type:"text",class:"save-name","onUpdate:modelValue":$[0]||($[0]=x=>s.value=x),onInput:m},null,544)),[[b.vModelText,s.value]]):(b.openBlock(),b.createElementBlock("h3",dke,b.toDisplayString(s.value),1)),b.createElementVNode("div",hke,[f.value?(b.openBlock(),b.createElementBlock("p",pke,b.toDisplayString(new Date(f.value.metadata.saveDate).toLocaleString()),1)):b.createCommentVNode("",!0),f.value?(b.openBlock(),b.createElementBlock("p",mke,"Play time: "+b.toDisplayString(p(k.saveSlot)),1)):b.createCommentVNode("",!0),u.value==="game-slots"?(b.openBlock(),b.createElementBlock("p",vke,b.toDisplayString(k.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(k.actions,(x,E)=>(b.openBlock(),b.createElementBlock("button",{class:b.normalizeClass(["button",{selected:k.selected&&E===l.value}]),onClick:()=>h(E),key:E},[b.createElementVNode("h3",null,b.toDisplayString(x),1)],10,gke))),128))],512)])],512))}}),s$e="",yke=b.createElementVNode("h3",{class:"title"},"Confirmation",-1),S0=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=e,r=b.ref(zo().registerInputListener("yes-no",{cancel:{press:()=>{i(!1)}},continue:{press:()=>{i(!0)}}})),o=b.ref(null);pp({mode:"list",container:o,listener:r.value,onChosen:a=>{i(a===0)}});function i(a){a===!0&&n.onConfirm?n.onConfirm():a===!1&&n.onRefuse&&n.onRefuse(),t("choice",a)}return b.onMounted(()=>{}),b.onUnmounted(()=>{r.value&&zo().unregisterInputListener(r.value)}),(a,s)=>(b.openBlock(),b.createBlock(al,{onClose:s[2]||(s[2]=()=>i(!1)),containerCssClass:"yes-no-modal"},{header:b.withCtx(()=>[yke]),body:b.withCtx(()=>[b.createElementVNode("h3",null,b.toDisplayString(e.prompt),1),b.createElementVNode("div",{class:"flex justify-center",ref_key:"buttonsContainer",ref:o},[b.createElementVNode("button",{class:"button",onClick:s[0]||(s[0]=()=>i(!0))},"Yes"),b.createElementVNode("button",{class:"button",onClick:s[1]||(s[1]=()=>i(!1))},"No")],512)]),_:1}))}}),l$e="",bke={class:"title"},wke={key:0},kke={class:"saves-section"},xke=b.createElementVNode("h3",{class:"saves-section-title"},"Auto save",-1),_ke={class:"saves-section"},jke=b.createElementVNode("h3",{class:"saves-section-title"},"Manual Saves",-1),Ske={key:1,class:"saves-section"},Cke=b.createElementVNode("h3",{class:"saves-section-title"},"Save Slots",-1),$ke={class:"saves-container flex flex-col"},xV=b.defineComponent({__name:"save-slots",props:{mode:{}},emits:["chosen","close"],setup(e,{emit:t}){const n=e,r=b.ref(zo().registerInputListener("save-slots",{cancel:{press:()=>{E()}}})),o=b.ref(0),i=b.reactive([]),a=b.computed(()=>i.slice(0,1)),s=b.computed(()=>i.slice(1)),l=b.ref([]),c=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:j=>{o.value=j}});const h=pp({mode:"list",elements:u,listener:r.value,onlyVertical:!0,noChoosing:!0,onSelected:j=>{o.value=j}}),p=b.computed(()=>{const j=o.value;return d.value.length<j+1?null:d.value[j].id}),m=b.reactive(n.mode==="load"?["Load","Delete"]:["Choose"]),v=b.computed(()=>wt().saves.mode),g=b.reactive({prompt:"Are you sure you want to delete this save file?",saveToDelete:null,onConfirm:()=>{x(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:()=>{k(y.saveToOverwrite),y.saveToOverwrite=null},onRefuse:()=>{y.saveToOverwrite=null}});b.onBeforeMount(()=>{const C=Xs().slots;console.log(C),C.forEach((O,F)=>{i[F]=O})});function w(){console.log(c.value),u.value=v.value==="manual"?[...c.value.map(C=>C.slotContainer),...f.value.map(C=>C.slotContainer)]:l.value.map(C=>C.slotContainer);const j=v.value==="manual"?[...a.value,...s.value]:i;d.value=j.map(C=>({id:C.id}))}b.onMounted(()=>{w()}),b.onUnmounted(()=>{h.value&&(h.value.disable(),h.value=null),r.value&&zo().unregisterInputListener(r.value)});function k(j){t("chosen",{slotId:j})}function $(j){const C=M(j);if(C){if(wt().saves.mode==="manual"&&C.slotType==="auto"){Zt().alert("Sorry","Can't delete the auto save slot!");return}g.saveToDelete=j}}function x(j){ppe(j);const C=i.find(O=>O.id===j);C&&(C.saveData=null),w()}function E(){t("close")}function R(j,C){const O=m[C];O==="Load"?k(j):O==="Delete"?$(j):O==="Choose"&&(y.saveToOverwrite=j)}function M(j){return i.find(C=>C.id===j)}return(j,C)=>(b.openBlock(),b.createBlock(al,{onClose:E,containerCssClass:"save-modal",cantClose:!1},{header:b.withCtx(()=>[b.createElementVNode("h3",bke,b.toDisplayString(j.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",wke,[b.createElementVNode("div",kke,[xke,b.createVNode(b.TransitionGroup,{name:"list",tag:"div"},{default:b.withCtx(()=>[(b.openBlock(!0),b.createElementBlock(b.Fragment,null,b.renderList(a.value,O=>(b.openBlock(),b.createBlock(j_,{key:O.id,saveSlot:O,id:O.id,actions:m,onChoice:F=>R(O.id,F),inputListener:r.value,selected:p.value===O.id,ref_for:!0,ref_key:"autoSlotsElements",ref:c},null,8,["saveSlot","id","actions","onChoice","inputListener","selected"]))),128))]),_:1})]),b.createElementVNode("div",_ke,[jke,b.createVNode(b.TransitionGroup,{name:"list",tag:"div"},{default:b.withCtx(()=>[(b.openBlock(!0),b.createElementBlock(b.Fragment,null,b.renderList(s.value,O=>(b.openBlock(),b.createBlock(j_,{key:O.id,saveSlot:O,id:O.id,actions:m,onChoice:F=>R(O.id,F),inputListener:r.value,selected:p.value===O.id,ref_for:!0,ref_key:"manualSlotsElements",ref:f},null,8,["saveSlot","id","actions","onChoice","inputListener","selected"]))),128))]),_:1})])])):(b.openBlock(),b.createElementBlock("div",Ske,[Cke,b.createElementVNode("div",$ke,[b.createVNode(b.TransitionGroup,{name:"list",tag:"div"},{default:b.withCtx(()=>[(b.openBlock(!0),b.createElementBlock(b.Fragment,null,b.renderList(i,O=>(b.openBlock(),b.createBlock(j_,{key:O.id,saveSlot:O,id:O.id,actions:m,onChoice:F=>R(O.id,F),selected:p.value===O.id,inputListener:r.value,ref_for:!0,ref_key:"saveSlotsElements",ref:l},null,8,["saveSlot","id","actions","onChoice","selected","inputListener"]))),128))]),_:1})])])),g.saveToDelete?(b.openBlock(),b.createBlock(S0,{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(S0,{key:3,prompt:y.prompt,onRefuse:y.onRefuse,onConfirm:y.onConfirm},null,8,["prompt","onRefuse","onConfirm"])):b.createCommentVNode("",!0)]),_:1}))}}),c$e="",Tke=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 _V extends d2{setup(t=!1){const r=t?"keydown":"keyup",o=kV(i=>{Va.emit("debouncedKeydown",i)},10,{isImmediate:!0,maxWait:10});window.addEventListener("keydown",i=>{Va.emit("keydown",i)}),window.addEventListener(r,i=>{o(i)})}}const Va=new _V,jV=ao("startMenu",{state:()=>({buttons:[]}),actions:{addButtonsFromPlugins(){bn.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)})})}}}),Eke={id:"game-menu"},Oke={id:"game-header",class:"flex flex-col justify-between items-center"},Ake={id:"game-title-container"},Mke={id:"game-title-text"},Pke={class:"title"},Nke=b.defineComponent({__name:"StartMenu",setup(e){const t=b.ref(zo().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),l=b.ref(!1),c=b.ref(!1),f=b.ref(null),u=jV(),d=b.ref(!1),h=b.computed(()=>u.buttons),p=pp({mode:"list",container:r,listener:t.value,onChosen:O=>{m(n.value[O])}});function m(O){switch(O.id){case"continue":x();break;case"new-game":v();break;case"load-game":E();break;case"exit":Zt().exitGame();break;default:y(O);break}}async function v(){o.value&&wt().saves.mode==="manual"?c.value=!0:g()}async function g(){const O=Zt();if(s.value===null)if(wt().saves.mode==="manual"){const F=Ux();if(!F){Wt("No autosave found");return}s.value=F.id}else{const F=dpe();if(!F){Wt("No free slot found");return}s.value=F}c.value=!1,await O.startGame(s.value)}function y(O){const F=h.value.findIndex(L=>L.id===O.id),T=h.value[F];T.action&&T.action(),T.popupComponent&&(d.value=T)}function w(){d.value=!1}function k(){c.value=!1}async function $(){if(!s.value)return;const O=Bh(s.value);if(!O){Wt("No save file found");return}Zt().loadGame(O,s.value)}function x(){typeof a.value=="string"&&(s.value=a.value,$())}function E(){l.value=!0}function R({slotId:O}){const F=Bh(O);F&&F.saveData?(s.value=O,$()):v()}b.onMounted(()=>{const O=wt();O.audio.options.defaultMusic&&yo().playChannel("music",O.audio.options.defaultMusic,0);const F=Xs();F.slots.some(T=>T.saveData)&&(o.value=!0),(wt().saves.mode==="manual"||F.slots.some(T=>!T.saveData))&&(i.value=!0),F.lastSaveSlot&&Bh(F.lastSaveSlot)&&(a.value=F.lastSaveSlot),M(),f.value=Va.on("debouncedKeydown",T=>{T.key===" "&&g(),T.key==="c"&&x()}),b.nextTick(()=>{p.select(0)})});function M(){wt().menuButtons,a.value&&n.value.push(j({id:"continue",title:"Continue",cssClass:"continue-button"})),i.value&&n.value.push(j({id:"new-game",title:"New Game",cssClass:"start-button"})),o.value&&n.value.push(j({id:"load-game",title:"Load Game",cssClass:"continue-button"}));for(const O of h.value)n.value.push({id:O.id,title:O.text,cssClass:`${O.id}-start-menu-button`});n.value.push(j({id:"exit",title:"Exit",cssClass:"exit-button"}))}function j({id:O,title:F,cssClass:T}){const L=wt().menuButtons[O];if(L){let H=T;return L.cssClass&&(H=`${L.cssClass} ${T}`),{id:O,title:L.text??F,cssClass:H}}return{id:O,title:F,cssClass:T}}b.onUnmounted(()=>{t.value&&zo().unregisterInputListener(t.value),f.value&&Va.off("debouncedKeydown",f.value)});const C=b.computed(()=>wt().gameTitle);return(O,F)=>(b.openBlock(),b.createElementBlock("div",Eke,[l.value?(b.openBlock(),b.createBlock(xV,{key:0,mode:"load",onChosen:R,onClose:F[0]||(F[0]=T=>l.value=!1)})):b.createCommentVNode("",!0),c.value?(b.openBlock(),b.createBlock(S0,{key:1,prompt:"This will override your previous autosave, are you sure?",onConfirm:g,onRefuse:k})):b.createCommentVNode("",!0),b.createElementVNode("div",Oke,[b.createElementVNode("div",Ake,[b.createElementVNode("h1",Mke,b.toDisplayString(C.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,T=>(b.openBlock(),b.createBlock(Tke,{key:T.id,button:T,onClick:L=>m(T)},null,8,["button","onClick"]))),128))],512)]),d.value?(b.openBlock(),b.createBlock(b.Teleport,{key:2,to:"#app-container"},[b.createVNode(al,{onClose:w,class:b.normalizeClass(`start-menu-popup-${d.value.id}`)},{header:b.withCtx(()=>[b.createElementVNode("h3",Pke,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:w},null,32)):b.createCommentVNode("",!0)]),_:1},8,["class"])])):b.createCommentVNode("",!0)]))}}),u$e="",Ike={class:"title"},Dke=b.defineComponent({__name:"alert-modal",props:{title:{type:String,required:!1},text:{type:String,required:!1}},setup(e){return(t,n)=>(b.openBlock(),b.createBlock(al,{onClose:n[0]||(n[0]=r=>t.$emit("close")),containerCssClass:"yes-no-modal"},{header:b.withCtx(()=>[b.createElementVNode("h3",Ike,b.toDisplayString(e.title??"Alert"),1)]),body:b.withCtx(()=>[b.createElementVNode("h3",null,b.toDisplayString(e.text),1)]),_:1}))}}),f$e="";function S_(e){const t=f_().characters[e];return t||Wt(`Character ${e} not found`),t}function Rke(e,t){const n=S_(e);if(n&&(t||(t="default"),n.sprites)){const r=`${f_().config.imagesPath}${n.sprites[t]}`;return r||Wt(`Character ${e} pose ${t} not found`),r}}function C0(e){var t;return e?((t=S_(e))==null?void 0:t.style)||{}:{}}const Lke=b.defineComponent({props:{pictureUrl:String},methods:{getAssetUrl(e){return oa(e)}},computed:{...Kc(Pi,["layoutMode"]),boxStyle(){var i,a;const e=Pi(),t=wt().layout;let n=0,r=0;const o=t.portraits;if(this.layoutMode==="vertical"){const s=((i=o.offset)==null?void 0:i.portrait)??{right:0,bottom:0};n=20+s.right,r=e.dialogHeight+s.bottom}else{const s=((a=o.offset)==null?void 0:a.landscape)??{right:0,bottom:0},l=wt().dialogPanel.rightOffset??Qc.dialogPanel.rightOffset;n=b0()-10+s.right+l,r=200+s.bottom}return{right:`${n}px`,bottom:`${r}px`,width:`${t.portraits.width}px`,height:`${t.portraits.height}px`}}}}),d$e="",Bke=["src"];function Fke(e,t,n,r,o,i){return b.openBlock(),b.createElementBlock("div",{class:"dialog-picture override",style:b.normalizeStyle(e.boxStyle)},[b.createElementVNode("img",{src:e.getAssetUrl(e.pictureUrl),class:"picture override"},null,8,Bke)],4)}const Vke=la(Lke,[["render",Fke]]),zke=["innerHTML"],Uke=["innerHTML"],qke=["innerHTML"],Hke={key:1},Wke=["onClick","innerHTML"],Kke={key:1},Gke={key:2,class:"buttons-container"},Jke=b.defineComponent({__name:"dialog-box",props:{options:{},active:{type:Boolean},inputListener:{}},setup(e,{expose:t}){const n=e,r=b.ref(null),o=b.ref(""),i=b.ref(!1),a=b.ref(null),s=b.ref(null),l=b.ref(!1),c=b.ref(null),f=b.ref(null),u=b.ref(null),d=b.ref(null),h=b.ref(null);n.active&&(h.value=pp({mode:"list",container:r,listener:n.inputListener,onlyVertical:!0,onChosen:be=>{te.value&&A.value?k(A.value[be]):g(" ")}})),b.onMounted(()=>{C(),H(),l.value=!0}),b.onUnmounted(()=>{p(),L({unmounted:!0})});function p(){a.value&&(clearTimeout(a),a.value=null),m()}function m(){h.value&&(h.value.disable(),h.value=null)}function v(be){g(be.key)}function g(be){if(!te.value){l.value&&s&&be===" "&&L({pressedSpace:!0});return}if(te.value&&n.options.textField&&be==="Enter"&&R(),te.value&&!n.options.textField){let de=-1;switch(be){case" ":de=0;break;case"1":de=0;break;case"2":de=1;break;case"3":de=2;break;case"4":de=3;break;case"5":de=4;break;case"6":de=5;break;case"7":de=6;break;case"8":de=7;break}de!==-1&&A.value&&de<A.value.length?k(A.value[de]):de===0&&k(de)}}function y(){te.value||l.value&&s&&L({pressedSpace:!0})}function w(){i.value||k(0)}function k(be){$();let de;typeof be=="object"?de=be.originalIndex:de=be,Zt().playerAnswered(de)}function $(){p(),L({unmounted:!0}),i.value=!0}function x(be){const de={};return be.allowed||(de.pointerEvents="none",de.textDecoration="line-through"),de}function E(be){if(!be.allowed)return"strike-anim"}function R(){const be=o.value;Zt().playerAnswered(be)}function M(be,de){const Be=n.options.text.substring(be,de);return s.value.text+=Be,de}function j(be){const de=be[0];return s.value.text+=de,s.value.skippedChars+=de.length,de.length}function C(){if(!n.options.old)if(qn().playMode==="skip")O();else if(wt().dialogPanel.animateText){s.value={text:"",index:0,startTime:Date.now(),timer:null,skippedChars:0,tags:wpe(n.options.text),finished:!1};const be=s.value;be.timer=setInterval(()=>{T()},30)}else I.value&&(c.value=setTimeout(()=>{L()},(wt().dialogPanel.textSpeed??zg)*n.options.text.length))}function O(){qn().playMode==="skip"&&!n.options.old&&(I.value?f.value=setTimeout(()=>{L()},100):(qn().toggleSkip(),L({unmounted:!0})))}function F(){qn().playMode==="auto"&&!n.options.old&&I.value&&te&&w()}function T(){const be=s.value;if(!be)return;const de=be.index,Be=Date.now()-be.startTime;let ee=!1,Oe=Math.round(Be/(wt().dialogPanel.textSpeed??zg))+be.skippedChars;if(Oe>n.options.text.length&&(ee=!0,be.finished=!0,Oe=n.options.text.length),Oe!==be.index){let Le=de;for(;be.tags.length>0&&Oe>=be.tags[0].index;){Le=M(Le,be.tags[0].index);const Ce=j(be.tags.shift());Le+=Ce,Oe+=Ce}Le=M(Le,Oe),be.index=Le}ee&&L()}function L({unmounted:be,pressedSpace:de}={}){setTimeout(()=>{h.value&&h.value.select(0)},10),s.value&&(s.value.timer&&clearInterval(s.value.timer),s.value=null),c.value&&!de&&clearTimeout(c.value),f.value&&clearTimeout(f.value),u.value&&clearTimeout(u.value),!be&&!de&&qn().playMode!=="normal"&&I&&(u.value=setTimeout(()=>{w()},qn().playMode==="auto"?wt().dialogPanel.timeBetweenLines??Qc.dialogPanel.timeBetweenLines:0))}function H(){a.value=setTimeout(()=>{n.options.textField&&te.value&&d.value.focus()},10)}const z=b.computed(()=>n.options.title?" &nbsp;–&nbsp; ":"");b.computed(()=>C0(n.options.styleId));const V=b.computed(()=>{const be=C0(n.options.styleId),de={opacity:n.options.old?"0.7":"1"};return{...be.boxCss,...de}}),I=b.computed(()=>!A.value&&!n.options.textField),P=b.computed(()=>n.options.title?"dialog-box-followup":!1),N=b.computed(()=>{const be=C0(n.options.styleId);return{color:be.color,...be.nameCss}}),D=b.computed(()=>C0(n.options.styleId).textCss),S=b.computed(()=>s.value?s.value.text:n.options.text),A=b.computed(()=>{if(n.options.choices)return n.options.choices}),B=b.computed(()=>qn().playMode==="skip"),Q=b.computed(()=>qn().playMode==="auto"),te=b.computed(()=>n.active&&l.value&&!i.value&&!u.value&&!s.value&&n.options.interactive&&!ke.value),he=Zt(),ke=b.computed(()=>he.paused);return b.watch(()=>n.options,(be,de)=>{!de.old&&be.old&&s&&L({unmounted:!0})}),b.watch(B,(be,de)=>{be&&!de&&O()}),b.watch(Q,(be,de)=>{be&&!de&&F()}),t({keyboardEvent:v}),(be,de)=>{const Be=b.resolveDirective("visible");return b.openBlock(),b.createElementBlock("div",{class:b.normalizeClass(["dialog-box w-full override",P.value]),style:b.normalizeStyle(V.value)},[b.createElementVNode("div",{class:"dialog-content",onClick:y},[be.options.title?(b.openBlock(),b.createElementBlock("span",{key:0,class:"dialog-title override",style:b.normalizeStyle(N.value),innerHTML:be.options.title},null,12,zke)):b.createCommentVNode("",!0),b.createElementVNode("span",{class:"dialog-text dialog-separator override",style:b.normalizeStyle(D.value),innerHTML:z.value},null,12,Uke),b.createElementVNode("span",{class:b.normalizeClass(["dialog-text override",be.options.cssClass]),style:b.normalizeStyle(D.value),innerHTML:S.value},null,14,qke),be.options.old?b.createCommentVNode("",!0):b.withDirectives((b.openBlock(),b.createElementBlock("div",Hke,[A.value?(b.openBlock(),b.createElementBlock("div",{key:0,class:"dialog-choices",ref_key:"choicesDiv",ref:r},[(b.openBlock(!0),b.createElementBlock(b.Fragment,null,b.renderList(A.value,(ee,Oe)=>(b.openBlock(),b.createElementBlock("p",{key:Oe,style:b.normalizeStyle(x(ee)),class:b.normalizeClass([E(ee),"dialog-choice override"]),onClick:Le=>k(ee),innerHTML:`${Oe+1}. –  ${ee.choice}`},null,14,Wke))),128))],512)):be.options.textField?(b.openBlock(),b.createElementBlock("div",Kke,[b.withDirectives(b.createElementVNode("input",{type:"text",class:"label-input input",ref_key:"playerInput",ref:d,id:"player-input-field","onUpdate:modelValue":de[0]||(de[0]=ee=>o.value=ee)},null,512),[[b.vModelText,o.value]]),b.createElementVNode("button",{onClick:R,class:"button",id:"player-input-submit"}," Submit ")])):(b.openBlock(),b.createElementBlock("div",Gke,[b.createElementVNode("div",{onClick:de[1]||(de[1]=ee=>k(0)),ref:"continue",class:"interact-button button override"}," Continue ",512)]))])),[[Be,te.value]])])],6)}}}),h$e="",Qke=b.createElementVNode("div",{class:"anchor"},null,-1),Yke=b.defineComponent({__name:"game-dialog",props:{layoutMode:{},inGame:{type:Boolean},inputListener:{}},setup(e){const t=e,n=b.ref(Zt().inScript),r=b.ref(null),o=Pi(),i=an(),a=b.computed(()=>i.stack),s=qn(),l=b.computed(()=>s.dialog),c=b.ref(null),f=b.ref(null),u=b.ref(null),d=b.computed(()=>{let x="0px";const E=wt().layout.dialogBottomPadding;return typeof E=="number"?x=`${E}px`:typeof E=="string"&&(x=E),{paddingBottom:x}}),h=b.computed(()=>{if(l.value.length>0)return l.value[l.value.length-1]}),p=b.computed(()=>{if(h.value){const x=h.value.speaker;let E=h.value.pose;return x?(E||(E="idle"),Rke(x,E)):void 0}}),m=b.computed(()=>o.dialogWidth),v=b.computed(()=>Zt().inScript);b.watch(v,x=>{x?n.value=!0:qn().playMode!=="normal"?(qn().playMode==="skip"&&(qn().playMode="normal"),r.value=setTimeout(()=>{n.value=!1},500)):n.value=!1}),b.onMounted(()=>{t.inputListener.actions.autoPlay={press:()=>{qn().toggleAutoPlay()}},t.inputListener.actions.skip={press:()=>{qn().toggleSkip()}};const x=E=>{f.value&&f.value.keyboardEvent&&f.value.keyboardEvent(E)};x.value=Va.on("debouncedKeydown",x)}),b.onUnmounted(()=>{t.inputListener&&(delete t.inputListener.actions.autoPlay,delete t.inputListener.actions.skip),u.value&&Va.off("debouncedKeydown",u.value),r.value&&clearTimeout(r.value)});const g=b.computed(()=>{let x;const E=`${Pi().dialogHeight}px`,R={};if(Pi().overlayMode){R.position="absolute";const M=wt().dialogPanel.rightOffset??Qc.dialogPanel.rightOffset;R.right=`${M}px`;const j=wt().dialogPanel.bottomOffset??Qc.dialogPanel.bottomOffset;R.bottom=`${j}px`}return{...R,width:t.layoutMode==="horizontal"?`${m.value}px`:"100%",height:E,transform:x,transformOrigin:"right"}});function y(){qn().toggleAutoPlay()}function w(){qn().toggleSkip()}function k(x,E){const R=S_(x.speaker);let M=(R==null?void 0:R.name)??"Missing Character";return E>=1&&l.value[E-1].speaker===x.speaker&&(M=void 0),x.choices&&x.choices.forEach(j=>{j.choice=Zs(j.choice)}),{title:M??"",text:x.text,cssClass:x.cssClass,styleId:x.speaker,choices:x.choices,old:E<l.value.length-1,interactive:x.interactive,textField:x.textField}}function $(x){return x===s.dialog.length-1&&a.value.length>0}return b.watch(l.value,x=>{if(c.value){const E=c.value;E.scrollTop=E.scrollHeight+1e8}}),(x,E)=>(b.openBlock(),b.createElementBlock(b.Fragment,null,[b.createVNode(b.Transition,{name:"fade"},{default:b.withCtx(()=>[p.value&&b.unref(o).showDialog?(b.openBlock(),b.createBlock(Vke,{key:0,pictureUrl:p.value},null,8,["pictureUrl"])):b.createCommentVNode("",!0)]),_:1}),b.createVNode(b.Transition,{name:"dialog-transition"},{default:b.withCtx(()=>[x.inGame&&b.unref(o).showDialog?(b.openBlock(),b.createElementBlock("div",{key:0,class:"dialog override",ref_key:"dialogRef",ref:c,style:b.normalizeStyle(g.value)},[b.createVNode(b.TransitionGroup,{name:"list",tag:"div",class:"dialog-container w-full override",style:b.normalizeStyle(d.value)},{default:b.withCtx(()=>[(b.openBlock(!0),b.createElementBlock(b.Fragment,null,b.renderList(l.value,(R,M)=>(b.openBlock(),b.createBlock(Jke,{ref_for:!0,ref:j=>f.value=j,key:R.id,options:k(R,M),active:$(M),inputListener:x.inputListener},null,8,["options","active","inputListener"]))),128))]),_:1},8,["style"]),(b.openBlock(),b.createBlock(b.Teleport,{to:"#app"},[b.createElementVNode("div",{class:"auto-skip-buttons flex"},[b.createElementVNode("div",{class:"button menu-toggle-button auto-button auto",onClick:y}," Auto "),b.createElementVNode("div",{class:"button menu-toggle-button auto-button skip",onClick:w}," Skip ")])])),Qke],4)):b.createCommentVNode("",!0)]),_:1})],64))}}),p$e="",Xke=["id"],Zke=["src"],exe={class:"tab-title"},txe=b.defineComponent({__name:"tab-selector",props:{tab:{},active:{type:Boolean}},emits:["click"],setup(e,{emit:t}){const n=e,r=b.computed(()=>n.active?"tab-active":"tab-inactive");function o(){t("click")}return(i,a)=>(b.openBlock(),b.createElementBlock("div",{class:b.normalizeClass(["tab",r.value]),id:`tab-${i.tab.id}`,onClick:o},[b.createElementVNode("div",{class:b.normalizeClass(["tab-title-container",i.active?"active":""])},[i.tab.icon?(b.openBlock(),b.createElementBlock("img",{key:0,src:i.tab.icon,alt:"tab icon",class:"tab-icon"},null,8,Zke)):b.createCommentVNode("",!0),b.createElementVNode("span",exe,b.toDisplayString(i.tab.label),1)],2)],10,Xke))}}),m$e="",nxe={class:"tabs-controller"},rxe={key:0,class:"tabs-controller__tabs"},oxe={key:1,class:"tab-content"},ixe={key:2},axe=[b.createElementVNode("div",{class:"tab-content__empty"},[b.createElementVNode("p",null,"No tab selected")],-1)],sxe=b.defineComponent({__name:"TabsController",props:{tabs:{},defaultTab:{}},emits:["tab-change","close"],setup(e,{emit:t}){const n=e,r=b.ref(null),o=b.ref(n.defaultTab);function i(s){o.value=s,t("tab-change",s)}const a=b.computed(()=>n.tabs[o.value]);return b.onMounted(()=>{r.value=zo().registerInputListener("tabs-controller",{cancel:{press:()=>{t("close")}},previousTab:{press:()=>{o.value>0&&i(o.value-1)}},nextTab:{press:()=>{o.value<n.tabs.length-1&&(console.log(`Next tab ${o.value+1}`),i(o.value+1))}}})}),b.onUnmounted(()=>{r.value&&(zo().unregisterInputListener(r.value),r.value=null)}),(s,l)=>(b.openBlock(),b.createElementBlock("div",nxe,[s.tabs.length>1?(b.openBlock(),b.createElementBlock("div",rxe,[(b.openBlock(!0),b.createElementBlock(b.Fragment,null,b.renderList(s.tabs,(c,f)=>(b.openBlock(),b.createBlock(txe,{key:c.id,tab:c,active:f===o.value,onClick:()=>i(f),inputListener:r.value},null,8,["tab","active","onClick","inputListener"]))),128))])):b.createCommentVNode("",!0),a.value?(b.openBlock(),b.createElementBlock("div",oxe,[a.value?(b.openBlock(),b.createBlock(b.resolveDynamicComponent(a.value.component),{key:0,onClose:l[0]||(l[0]=c=>s.$emit("close"))},null,32)):b.createCommentVNode("",!0)])):(b.openBlock(),b.createElementBlock("div",ixe,axe))]))}}),g$e="",lxe={class:"menu-container"},cxe=["onClick","id"],uxe={class:"title"},fxe=b.defineComponent({__name:"menu-buttons",setup(e){const t=gi(),n=b.ref(null);b.onMounted(()=>{bn.callHook("onGameMounted")}),b.onUnmounted(()=>{n.value&&Va.off("keydown",n.value),bn.callHook("onGameUnmounted")});function r(f){gi().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 l(f){t.setActiveTab(f)}function c(){return s()}return(f,u)=>(b.openBlock(),b.createElementBlock("div",lxe,[(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,cxe))),128)),i.value?(b.openBlock(),b.createBlock(b.Teleport,{key:0,to:"#app-container"},[b.createVNode(al,{containerCssClass:{[i.value.cssClass]:!0,"menu-modal":!0},onClose:s},{header:b.withCtx(()=>{var d;return[b.createElementVNode("h3",uxe,b.toDisplayString(((d=b.unref(t).tab)==null?void 0:d.text)??i.value.label),1)]}),body:b.withCtx(()=>[b.createVNode(sxe,{onTabChange:l,onClose:c,tabs:a.value,defaultTab:i.value.activeTab},null,8,["tabs","defaultTab"])]),_:1},8,["containerCssClass"])])):b.createCommentVNode("",!0)]))}}),y$e="",dxe=["id"],hxe=["innerHTML"],pxe=b.defineComponent({__name:"screen-object",props:{screenObject:{},layerSelected:{type:Boolean},transitioning:{type:Boolean},activeInteractive:{}},setup(e){const t=e,n=ei();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(()=>{const s={};return o.value&&(s.selected=!0),n.isScreenObjectClickable(t.screenObject)?s.interactable=!0:s.disabled=!0,t.screenObject.cssClass&&(s[t.screenObject.cssClass]=!0),s}),a=b.computed(()=>{const s={};t.screenObject.opacity!==1&&(s.opacity=t.screenObject.opacity);let l=t.screenObject.x,c=t.screenObject.y,f=t.screenObject.width,u=t.screenObject.height;if(t.screenObject.anchor){const h=t.screenObject.anchor;l=t.screenObject.x-f*h.x,c=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:`${l}px`,top:`${c}px`,width:`${f}px`,height:`${u}px`};return Bge(t.screenObject)&&(d.backgroundImage=`url(${hp(t.screenObject.image)})`),d});return(s,l)=>{const c=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:l[0]||(l[0]=f=>r(s.screenObject)),style:b.normalizeStyle(a.value)},[b.createElementVNode("span",{innerHTML:t.screenObject.text?b.unref(Zs)(t.screenObject.text):void 0},null,8,hxe),(b.openBlock(!0),b.createElementBlock(b.Fragment,null,b.renderList(t.screenObject.children,f=>(b.openBlock(),b.createBlock(c,{transitioning:s.transitioning,key:f.id,screenObject:f},null,8,["transitioning","screenObject"]))),128))],14,dxe)}}}),b$e="",mxe=["id","innerHTML"],vxe=b.defineComponent({__name:"viewport-button",props:{id:{},layerSelected:{type:Boolean},transitioning:{type:Boolean},activeInteractive:{}},setup(e){const t=e,n=Ia();an();const r=b.computed(()=>n.getButtonState(t.id)),o=Jf(t.id),i=o.background?hp(o.background):null,a=b.computed(()=>{if(!t.layerSelected)return!1;const d=t.activeInteractive;return d.type==="button"&&d.id===t.id}),s=b.computed(()=>n.isButtonClickable(t.id)),l=b.computed(()=>{const d=o.text??"";return Zs(d)}),c=b.computed(()=>{const d={};return a.value&&(d.selected=!0),s.value?d.interactable=!0:(d.disabled=!0,r.value==="greyed"?d.greyed=!0:(r.value==="hidden"||r.value===!1)&&(d.hidden=!0)),o.cssClass&&(d[o.cssClass]=!0),d}),f=b.computed(()=>{const d={};o.position.width&&(d.width=`${o.position.width}px`),o.position.height&&(d.height=`${o.position.height}px`),o.background&&(d.backgroundImage=`url(${i})`);let h=o.position.left,p=o.position.top;return o.anchor&&(h=o.position.left-o.position.width*o.anchor.x,p=o.position.top-o.position.height*o.anchor.y),{...d,left:`${h}px`,top:`${p}px`}});function u(){n.clickOnButton(t.id)}return(d,h)=>(b.openBlock(),b.createElementBlock("div",{tabindex:"-1",class:b.normalizeClass(["viewport-button",c.value]),id:`viewport-button-${d.id}`,onClick:h[0]||(h[0]=p=>u()),style:b.normalizeStyle(f.value),innerHTML:l.value},null,14,mxe))}}),w$e="",gxe=["id"],C_=b.defineComponent({__name:"screen-layer",props:{layer:{},layerIndex:{},transitioning:{type:Boolean},activeInteractive:{}},setup(e){const t=e,n=Zt(),r=ei(),o=b.computed(()=>!!(t.activeInteractive&&t.activeInteractive.layer===t.layerIndex)),i=b.computed(()=>r.tree.filter(h=>h.layer===t.layerIndex)),a=b.computed(()=>wt().layout.backgrounds.width),s=b.computed(()=>wt().layout.backgrounds.height),l=b.computed(()=>t.layer),c=b.computed(()=>{const h=dp(l.value);return h||(console.log(l),Wt(`Screen ${l.value} doesn't have a config`)),h}),f=b.computed(()=>n.isInGame),u=b.computed(()=>c.value.buttons||[]),d=b.computed(()=>{let h=`url(${hp(c.value.background)})`;return c.value.background===Wx&&(h=void 0),{backgroundImage:h,width:`${a.value}px`,height:`${s.value}px`}});return(h,p)=>f.value?(b.openBlock(),b.createElementBlock("div",{key:0,class:"viewport-layer",id:`viewport-layer-${l.value}`,style:b.normalizeStyle(d.value)},[(b.openBlock(!0),b.createElementBlock(b.Fragment,null,b.renderList(u.value,m=>(b.openBlock(),b.createBlock(vxe,{key:m,id:m,layerSelected:o.value,transitioning:h.transitioning,activeInteractive:h.activeInteractive},null,8,["id","layerSelected","transitioning","activeInteractive"]))),128)),(b.openBlock(!0),b.createElementBlock(b.Fragment,null,b.renderList(i.value,m=>(b.openBlock(),b.createBlock(pxe,{key:m.id,screenObject:m,transitioning:h.transitioning,layerSelected:o.value,activeInteractive:h.activeInteractive},null,8,["screenObject","transitioning","layerSelected","activeInteractive"]))),128))],12,gxe)):b.createCommentVNode("",!0)}}),k$e="",yxe=b.defineComponent({__name:"NarratTransition",props:{name:{type:String,required:!0},duration:{type:Number,required:!0},delay:Number},emits:["complete"],setup(e,{emit:t}){const n=e,r=b.useSlots(),o=b.ref("start"),i=b.reactive({oldSlotClasses:{},oldSlotStyle:{},newSlotClasses:{},newSlotStyle:{}});return b.computed(()=>r.oldElement&&r.oldElement.length>0),b.computed(()=>r.newElement&&r.newElement.length>0),b.onMounted(async()=>{const a=`narrat-transition-${n.name}`;i.newSlotClasses={[`${a}-enter-from`]:!0,[`${a}-enter-active`]:!0},i.oldSlotStyle={transitionDuration:`${n.duration/1e3}s`},i.newSlotStyle={transitionDuration:`${n.duration/1e3}s`},i.oldSlotClasses={[`${a}-leave-active`]:!0},await ea(30),i.oldSlotClasses[`${a}-leave-to`]=!0,await ea(n.delay??0),delete i.newSlotClasses[`${a}-enter-from`],await ea(n.duration),delete i.newSlotClasses[`${a}-enter-active`],delete i.oldSlotClasses[`${a}-leave-active`],o.value="end",t("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))}}),x$e="";function SV(e,t,n){return e<t?t:e>n?n:e}const bxe=b.defineComponent({__name:"screens",props:{inputListener:{}},setup(e){const t=e,n=Pi(),r=Zt(),o=Ia(),i=ei(),a=b.ref(0),s=b.computed(()=>o.nonEmptyLayers),l=b.computed(()=>{const v=[];return s.value.reduce((g,y,w)=>{const $=dp(y.screen).buttons;if($)for(const E of $)o.isButtonClickable(E)&&g.push({id:E,type:"button",layer:w});const x=i.tree.filter(E=>E.layer===w);for(const E of x)i.isScreenObjectClickable(E)&&g.push({id:E.id,type:"screenObject",layer:w});return g},v)}),c=b.computed(()=>{if(l.value.length===0)return null;let v=a.value;return v>l.value.length-1&&(v=l.value.length-1),l.value[v]}),f=b.computed(()=>n.layoutMode),u=b.computed(()=>wt().layout.backgrounds.width),d=b.computed(()=>wt().layout.backgrounds.height),h=b.computed(()=>r.isInGame);function p(v){o.finishTransition(v)}const m=b.computed(()=>{const v=u.value,g=d.value;return f.value,{height:`${g}px`,width:`${v}px`}});return b.onMounted(()=>{b.nextTick(()=>{if(t.inputListener){const v=t.inputListener.actions;v.previousTab={press:()=>{a.value>0?a.value--:a.value=l.value.length-1,a.value=SV(a.value,0,l.value.length-1)}},v.left=v.previousTab,v.nextTab={press:()=>{a.value<l.value.length-1?a.value++:a.value=0,a.value=SV(a.value,0,l.value.length-1)}},v.right=v.nextTab,v.viewportSelect={press:()=>{if(c.value){const g=c.value;g.type==="button"?o.clickOnButton(g.id):g.type==="screenObject"&&i.clickObject(i.getObject(g.id))}}}}})}),b.onUnmounted(()=>{t.inputListener&&(delete t.inputListener.actions.previousTab,delete t.inputListener.actions.left,delete t.inputListener.actions.nextTab,delete t.inputListener.actions.right)}),(v,g)=>h.value?(b.openBlock(),b.createElementBlock("div",{key:0,class:"viewport",id:"narrat-viewport",style:b.normalizeStyle(m.value)},[(b.openBlock(!0),b.createElementBlock(b.Fragment,null,b.renderList(s.value,(y,w)=>(b.openBlock(),b.createElementBlock("div",{key:y.screen??"",class:"layer-container"},[y.transition?(b.openBlock(),b.createBlock(yxe,{key:0,name:y.transition.transition,duration:y.transition.duration,delay:y.transition.delay,onComplete:()=>p(w)},{oldElement:b.withCtx(()=>[y.transition.oldScreen?(b.openBlock(),b.createBlock(C_,{key:0,layer:y.transition.oldScreen,layerIndex:w,transitioning:!0},null,8,["layer","layerIndex"])):b.createCommentVNode("",!0)]),newElement:b.withCtx(()=>[y.screen?(b.openBlock(),b.createBlock(C_,{key:0,layer:y.screen,layerIndex:w,transitioning:!0},null,8,["layer","layerIndex"])):b.createCommentVNode("",!0)]),_:2},1032,["name","duration","delay","onComplete"])):y.screen?(b.openBlock(),b.createBlock(C_,{key:1,layer:y.screen,layerIndex:w,transitioning:!1,activeInteractive:c.value},null,8,["layer","layerIndex","activeInteractive"])):b.createCommentVNode("",!0)]))),128))],4)):b.createCommentVNode("",!0)}}),_$e="",wxe=b.defineComponent({data(){return{}},methods:{getStatImage(e){return oa(this.statsConfig[e].icon)}},computed:{...Kc(_s,["hudStats"]),...Kc(Pi,["layoutMode"]),statsConfig(){return wt().hudStats},stats(){return this.hudStats},hudStyle(){let e="0";return this.layoutMode==="horizontal"&&(e=`${b0()+(wt().dialogPanel.rightOffset??Qc.dialogPanel.rightOffset)}px`),{right:e}}}}),j$e="",kxe=["src"],xxe={class:"bold hud-text"};function _xe(e,t,n,r,o,i){return b.openBlock(),b.createElementBlock("div",{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,kxe),b.createElementVNode("span",xxe,b.toDisplayString(e.statsConfig[s].name),1),b.createTextVNode(": "),b.createElementVNode("span",null,b.toDisplayString(Math.floor(a.value*100)/100),1)]))),128))],4)}const jxe=la(wxe,[["render",_xe]]),Sxe={key:0,class:"auto-play-feedback-container"},Cxe=b.defineComponent({__name:"AutoPlayFeedback",setup(e){const t=qn(),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",Sxe,[b.createElementVNode("div",{class:b.normalizeClass(["auto-play-feedback",o.value])},b.toDisplayString(i.value),3)])):b.createCommentVNode("",!0)}}),S$e="",$xe=b.defineComponent({__name:"in-game",setup(e){const t=b.ref(null),n=Zt(),r=Pi(),o=b.computed(()=>r.layoutMode),i=b.computed(()=>n.saving),a=b.ref(null),s=qn(),l=b.ref(null),c=b.computed(()=>i.value&&!i.value.withPrompt||i.value&&a.value),f=b.computed(()=>{let p="row";return o.value==="vertical"&&(p="column"),{flexDirection:p}});function u(p){if(a.value=null,p===null){Zt().finishManualSave(p,!1);return}Zt().finishManualSave(p,!0)}function d(){a.value=!0}function h(){a.value=!1,n.finishManualSave(null,!1),a.value=null}return b.onBeforeMount(()=>{t.value=zo().registerInputListener("in-game",{system:{press:()=>{gi().openMenu("system")}},menu:{press:()=>{gi().openMenu("menu")}}})}),b.onMounted(()=>{l.value=Va.on("debouncedKeydown",p=>{Zt().debugMode||((p.key==="a"||p.key==="A")&&s.toggleAutoPlay(),(p.key==="s"||p.key==="S")&&s.toggleSkip())})}),b.onUnmounted(()=>{t.value&&zo().unregisterInputListener(t.value),l.value&&Va.off("debouncedKeydown",l.value)}),(p,m)=>(b.openBlock(),b.createElementBlock("div",{class:"game",style:b.normalizeStyle(f.value)},[b.createVNode(jxe),b.createVNode(fxe,{class:"menu-toggle"}),b.createVNode(bxe,{inputListener:t.value},null,8,["inputListener"]),b.unref(r).showDialog?(b.openBlock(),b.createBlock(Yke,{key:0,inGame:!0,layoutMode:o.value,inputListener:t.value},null,8,["layoutMode","inputListener"])):b.createCommentVNode("",!0),c.value?(b.openBlock(),b.createBlock(xV,{key:1,mode:"pick",onChosen:u,onClose:m[0]||(m[0]=()=>u(null))})):b.createCommentVNode("",!0),b.createVNode(Cxe),i.value&&i.value.withPrompt&&a.value===null?(b.openBlock(),b.createBlock(S0,{key:2,prompt:"Would you like to save the game?",onConfirm:d,onRefuse:h})):b.createCommentVNode("",!0)],4))}}),C$e="",Txe=b.defineComponent({props:{percentage:Number,step:String},methods:{loadingStyle(){return{width:`${this.percentage*60}vw`}}},computed:{}}),$$e="",Exe={id:"loading-bar"},Oxe={id:"loading-text"};function Axe(e,t,n,r,o,i){return b.openBlock(),b.createElementBlock("div",Exe,[b.createElementVNode("div",{id:"inner-loading-bar",style:b.normalizeStyle(e.loadingStyle())},null,4),b.createElementVNode("div",Oxe,[b.createElementVNode("h3",null,"Loading "+b.toDisplayString(Math.floor(e.percentage*100))+"% - "+b.toDisplayString(e.step),1)])])}const Mxe=la(Txe,[["render",Axe]]),Pxe="data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4KPCEtLSBHZW5lcmF0b3I6IEFkb2JlIElsbHVzdHJhdG9yIDE5LjAuMCwgU1ZHIEV4cG9ydCBQbHVnLUluIC4gU1ZHIFZlcnNpb246IDYuMDAgQnVpbGQgMCkgIC0tPgo8c3ZnIHZlcnNpb249IjEuMSIgaWQ9IlJhdCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgeD0iMHB4IiB5PSIwcHgiCgkgdmlld0JveD0iMCAwIDU5NS4zIDU5NS4zIiBzdHlsZT0iZW5hYmxlLWJhY2tncm91bmQ6bmV3IDAgMCA1OTUuMyA1OTUuMzsiIHhtbDpzcGFjZT0icHJlc2VydmUiPgo8c3R5bGUgdHlwZT0idGV4dC9jc3MiPgoJLnN0MHtmaWxsOiNFMjNCMzM7fQo8L3N0eWxlPgo8cGF0aCBpZD0iUmF0X1NoYXBlIiBjbGFzcz0ic3QwIiBkPSJNNTU2LjksODIuNWMtMTAuOC0yNC4zLTQ3LTU3LjEtNzEuMy02NS42Yy0yNC4zLTguNC02NC4xLTAuMy04OC43LDIyLjMKCWMtMjAsMTguNC0yNiwyOC4yLTI5LjEsMzdjLTIuMSw1LjktNC44LDEzLjUtNiwyMC45djBjLTAuNSw0LjEtNC41LDctOC42LDYuMWMtMTAuNC0yLjMtMjkuNS02LTQ0LjQtNi4zCgljLTEzLjctMC4yLTMwLjEsMy4yLTQwLjQsNS43Yy00LjUsMS4xLTguOC0yLjItOC44LTYuOGMtMC4xLTUuMy0xLjEtMTIuMy00LjgtMTkuNmMtOC41LTE2LjktMTkuNi0zMi42LTU3LjgtNDcuNAoJYy0zMS45LTEyLjQtNzUuMS05LjctMTAwLjgsMS44Yy0yOC4xLDEyLjYtNDIuNCwzNy45LTU0LDYxLjhjLTE0LjQsMjkuOC0xNC45LDgzLjYtNi40LDEwNGMxMi44LDMwLjcsMzUuOCw0Ny4yLDUyLjYsNTMKCWMxMS4zLDMuOCwyOC4yLDMuNywzOC4yLDMuM2M0LjItMC4yLDcuNywzLjMsNy41LDcuNWMtMC43LDEzLjYtMC45LDQxLjUsNyw2MS40YzcuNywxOS40LDI5LjcsNjIuMyw1MC43LDEwMS4yCgljMCwwLjEtMTQuNiwyLjktMzEuNCw2LjhjLTIzLjksNS41LTUyLjYsMTIuNy01NC4zLDEzLjdjLTMuNSwyLjEtMywxMC0yLjcsMTJjMC41LDMuNCw1LjMsOC4xLDYuOSw4LjNjMy45LDAuMywzMS4zLTcuNiw1NS43LTE0LjYKCWMxOC41LTUuMywzNC45LTkuMywzNS41LTguMmM1LjEsOS4zLDEwLDE4LDE0LjQsMjUuOGM1LjIsOS4xLDEwLjcsMTYuNCwxNC4xLDIzLjZjMS4xLDIuMy0xNi42LDUuOC0zMi41LDE0LjcKCWMtMTYuNCw5LjEtMjkuNywyMS0zMi4zLDI0Yy0xLjgsMi4xLTMsNi0xLjIsMTAuN2MxLjEsMi45LDEwLDUuNywxMi40LDUuMWM2LjgtMS43LDE2LjUtMTIuNSwzMy4xLTIxLjEKCWMxNi4zLTguNSwzMi45LTE0LjksMzMuOC0xMy42YzkuNywxNC4zLDE2LjksMjEuNiwyMi42LDMxLjJjOS44LDE2LjUsMjcuMyw0NS45LDQ2LjYsMzkuNWM2LjQtMi4xLDMxLjEtMzMuNiw1My4zLTY4LjYKCWMxLjMtMi4xLDE2LjEsMTEuMywzMC40LDIzLjJjMTMuOCwxMS40LDIyLjcsMjAuNiwyNy4xLDIxLjRjNS40LDEsMTQuMi03LjcsMTQuMS0xNC43Yy0wLjEtMi43LTE0LjMtMTMuOC0yOS4xLTI2LjIKCWMtMTQuNS0xMi4xLTMwLjEtMjIuOC0yOS4yLTI0LjNjNy42LTEyLDE0LjUtMjMuNywyMC4xLTMzLjljNC4zLTcuOCw4LjktMTYsMTMtMjQuN2MwLjYtMS4yLDE1LjksMywzMS40LDcuMWMxNS4zLDQsMjYuNywxMCwzMSw4CgljNi45LTMsMTEuNi0xMy44LDkuNC0xOC4zYy0xLjEtMi4zLTE3LTcuMy0zMy4yLTEyYy0xNC4yLTQuMS0yOC02LjUtMjcuNy03LjNjMTUuNS0zNCwyOC44LTY0LjgsMjcuNi02OS42CgljLTEuNy03LjEsMi42LTExLjksNy0zNi41YzMuMi0xOC4xLDQuNy00MC45LDUuMi01MS43YzAuMi0zLjUsMi44LTYuMyw2LjMtNi43YzMuMS0wLjMsNi45LTAuOSwxMC41LTEuOWM3LjgtMiwxOC42LTcuOCwzNi40LTIwLjYKCWMxNy45LTEyLjgsMzguNy00OS42LDQ0LjQtNjcuOFM1NjcuNiwxMDYuOCw1NTYuOSw4Mi41eiBNMjY1LjEsMzM2LjJjLTguMSw0LTEzLDctMjYuNCw5LjZjLTYuOSwxLjQtMjkuNC0wLjItNDAuNy00LjYKCWMtMTAuNS00LjEtMTkuOS03LjYtMzAtMTUuNHMtMTUuNy0xMy4yLTE1LjctMTUuM2MwLTQuNCw2LTkuNCwxMS05LjRjNS4xLDAsMTQuNSw5LjIsMjkuNywxNi42YzE0LjMsNywxNy45LDYuMSwyNS40LDcuMwoJYzIuOSwwLjUsNy43LDAuNiwxMC43LDAuNGMxNC4xLTEuMywyMS40LTUuOSwyNS4zLTguOGM0LTMsMTMuNy0xMi45LDE3LjItMTIuNWM4LDEsMTguOSwzLjQsMTguOSw3LjEKCUMyOTAuNCwzMTksMjczLjIsMzMyLjEsMjY1LjEsMzM2LjJ6IE0zMjAuOSw1MjEuNGMtNC4zLDMuNy0xNy43LDEzLjUtMjMuMywxMy41Yy0yLjgsMC03LjQtOC4yLTExLjUtMTYuOAoJYy00LjEtOC41LTkuMS0yMS4xLTkuMS0zMS42YzAtNC42LDYtNy40LDEzLjQtOS4yYzcuMi0xLjcsMjcuMy0xLjgsMjkuOS0xLjFjNi44LDEuNywxMi45LDIuMiwxMi43LDYuNGMtMC40LDEyLjctNywxOC45LTguMywyNC4zCglDMzIzLjQsNTEyLjMsMzIzLjQsNTE5LjIsMzIwLjksNTIxLjR6IE00MzEuMSwzMjAuM2MtOS4yLDcuNC0xMC42LDguMS0yNC45LDEzLjdjLTExLjMsNC40LTI4LjYsNS44LTQxLjYsMy42CgljLTEyLjItMi4xLTIyLjMtNC42LTI5LjUtMTAuMWMtOS43LTcuMy0xNi40LTE1LjEtMTYuNC0xOS44YzAtMy43LDYuNC00LjMsMTQuNS00LjljMy41LTAuMyw5LjMsNS45LDEzLjIsOS4yCgljOC4xLDYuOCwxNC44LDgsMjguOCw5LjljMi45LDAuNCw3LjgsMC40LDEwLjcsMC4xYzcuNS0wLjksMTItMC40LDI1LjgtOC4yYzIwLTExLjIsMTcuOC0xNC40LDI1LjEtMTIuNmMyLjIsMC42LDUuOCwxLjIsNS42LDUuNgoJQzQ0Mi40LDMwOSw0NDAuNSwzMTIuNyw0MzEuMSwzMjAuM3oiLz4KPC9zdmc+Cg==",Nxe={id:"engine-splash-screen",class:"flex justify-center items-center"},Ixe={id:"engine-splash-title"},Dxe=["src"],Rxe=b.defineComponent({__name:"engine-splash",emits:["finished"],setup(e,{emit:t}){const n=b.ref("hidden"),r=b.computed(()=>({transitionDuration:`${c.value}s`})),o=b.computed(()=>({invisible:n.value!=="appear"})),i=Zt(),a=b.computed(()=>{var d;return((d=wt().splashScreens)==null?void 0:d.engineSplashScreen)??{}}),s=b.computed(()=>typeof a.value.overrideText=="string"?a.value.overrideText:"Made with narrat engine"),l=b.computed(()=>a.value.overrideLogo??Pxe),c=b.computed(()=>typeof a.value.fadeDuration=="number"?a.value.fadeDuration:.8),f=b.computed(()=>typeof a.value.timeBeforeFadeout=="number"?a.value.timeBeforeFadeout:1.5);b.onMounted(async()=>{if(await ea(10),n.value="appear",a.value.skip||i.options.debug){u();return}await ea(c.value*1e3),await ea(f.value*1e3),n.value="disappear",await ea(c.value*1e3),u()});function u(){i.loading.loaded?t("finished"):i.listener.once("gameLoaded",()=>{t("finished")})}return(d,h)=>(b.openBlock(),b.createElementBlock("div",Nxe,[b.createElementVNode("div",{id:"engine-splash-header",class:b.normalizeClass(["flex justify-center flex-col items-center",o.value]),style:b.normalizeStyle(r.value)},[b.createElementVNode("h1",Ixe,b.toDisplayString(s.value),1),b.createElementVNode("img",{src:l.value,alt:"Narrat Logo",id:"engine-splash-logo"},null,8,Dxe),b.createVNode(Mxe,{percentage:b.unref(i).loading.percentage,step:b.unref(i).loading.step},null,8,["percentage","step"])],6)]))}}),T$e="",Lxe={id:"game-splash-screen",style:{height:"100%",padding:"20px"},class:"flex justify-center items-center"},Bxe={id:"game-splash-screen-header flex justify-center flex-col items-center",class:"flex justify-center flex-col items-center"},Fxe={class:"title",id:"game-splash-title"},Vxe=b.defineComponent({__name:"game-splash",setup(e){const t=b.ref(null),n=Zt(),r=b.computed(()=>{var l;return((l=wt().splashScreens)==null?void 0:l.gameSplashScreen)??{}}),o=b.computed(()=>typeof r.value.startButtonText=="string"?r.value.startButtonText:"Press to start"),i=b.computed(()=>n.loading.loaded),a=b.computed(()=>wt().gameTitle||"Narrat Game");function s(){n.flowState="menu"}return b.onMounted(()=>{t.value=zo().registerInputListener("game-splash",{continue:{press:()=>{s()}}}),n.options.debug&&s()}),b.onUnmounted(()=>{t.value&&zo().unregisterInputListener(t.value)}),(l,c)=>(b.openBlock(),b.createElementBlock("div",Lxe,[b.createElementVNode("div",Bxe,[b.createElementVNode("h1",Fxe,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)])]))}}),E$e="",zxe={key:0,class:"floating-tooltip-title"},Uxe=b.createElementVNode("hr",null,null,-1),qxe={class:"floating-tooltip-text"},Hxe=b.defineComponent({__name:"floating-tooltip",props:{title:{},text:{},width:{},x:{},y:{},screenMargin:{}},setup(e){const t=e,n=b.ref(150),r=b.ref(null),o=b.computed(()=>{const i=t.screenMargin??5,a={};let s=t.x-t.width/2;s=Math.min(s,window.innerWidth-t.width-i),s=Math.max(i,s),a.left=`${s}px`;let l=window.innerHeight-t.y;return l=Math.max(l,i),l=Math.min(l,window.innerHeight-n.value-i),a.bottom=`${l}px`,a.width=`${t.width}px`,a});return b.onMounted(()=>{r.value&&(n.value=r.value.clientHeight)}),(i,a)=>(b.openBlock(),b.createBlock(b.Transition,{name:"fade"},{default:b.withCtx(()=>[b.createElementVNode("div",{class:"floating-tooltip",style:b.normalizeStyle(o.value),ref_key:"element",ref:r},[i.title?(b.openBlock(),b.createElementBlock("div",zxe,[b.createTextVNode(b.toDisplayString(t.title)+" ",1),Uxe])):b.createCommentVNode("",!0),b.createElementVNode("div",qxe,b.toDisplayString(t.text),1)],4)]),_:1}))}}),O$e="",Wxe={class:"tooltips-ui"},Kxe=b.defineComponent({__name:"tooltips-ui",setup(e){const t=Bg().tooltip,n=b.computed(()=>({...t,screenMargin:fp().options.screenEdgesMinimumMargin??5}));return(r,o)=>(b.openBlock(),b.createElementBlock("div",Wxe,[b.unref(t)?(b.openBlock(),b.createBlock(Hxe,b.normalizeProps(b.mergeProps({key:0},n.value)),null,16)):b.createCommentVNode("",!0)]))}}),Gxe=b.defineComponent({setup(){const e=qn(),t=an(),n=Zt();return{dialog:b.computed(()=>e.dialog),stack:b.computed(()=>t.stack),flowState:b.computed(()=>n.flowState),alerts:b.computed(()=>n.alerts)}},$refs:{dialogContainer:HTMLInputElement},components:{DebugMenu:rke,NotificationToast:ske,StartMenu:Nke,AlertModal:Dke,InGame:$xe,EngineSplash:Rxe,GameSplash:Vxe,TooltipsUi:Kxe},data(){return{lineTitle:"title",lineText:"hello"}},props:{options:Object},async mounted(){bn.callHook("onAppMounted"),await Zt().engineLoading(),window.addEventListener("resize",kV(()=>{this.updateScreenSize()},100,{maxWait:200})),Va.setup(this.options.debug),setTimeout(()=>{this.updateScreenSize()},50)},computed:{...Kc(Pi,["screenWidth","screenHeight","layoutMode","gameWidth","gameHeight","gameScaleRatio","actualGameHeight"]),...Kc(an,["currentLine"]),appStyle(){return{transform:`scale(${this.gameScaleRatio}, ${this.gameScaleRatio})`,width:`${this.gameWidth}px`,height:`${this.actualGameHeight}px`}},appClass(){return gi().activeMenu?"app-blurred-by-modal":{}}},methods:{closeAlert(e){Zt().closeAlert(e)},engineSplashDone(){Zt().flowState="game-splash"},updateScreenSize(){Pi().updateScreenSize(window.innerWidth,window.innerHeight)}}}),A$e="";function Jxe(e,t,n,r,o,i){const a=b.resolveComponent("EngineSplash"),s=b.resolveComponent("GameSplash"),l=b.resolveComponent("StartMenu"),c=b.resolveComponent("InGame"),f=b.resolveComponent("DebugMenu"),u=b.resolveComponent("NotificationToast"),d=b.resolveComponent("AlertModal"),h=b.resolveComponent("TooltipsUi");return b.openBlock(),b.createElementBlock(b.Fragment,null,[b.createElementVNode("div",{id:"app-container",style:b.normalizeStyle(e.appStyle)},[b.createElementVNode("div",{id:"app",class:b.normalizeClass(e.appClass)},[e.flowState==="engine-splash"?(b.openBlock(),b.createBlock(a,{key:0,onFinished:e.engineSplashDone},null,8,["onFinished"])):(b.openBlock(),b.createBlock(b.Transition,{key:1,name:"screens-fade"},{default:b.withCtx(()=>[e.flowState==="game-splash"?(b.openBlock(),b.createBlock(s,{key:"1"})):e.flowState==="menu"?(b.openBlock(),b.createBlock(l,{key:"2"})):e.flowState==="playing"?(b.openBlock(),b.createBlock(c,{key:"3"})):b.createCommentVNode("",!0)]),_:1})),e.options.debug?(b.openBlock(),b.createBlock(f,{key:2})):b.createCommentVNode("",!0),b.createVNode(u),(b.openBlock(!0),b.createElementBlock(b.Fragment,null,b.renderList(e.alerts,p=>(b.openBlock(),b.createBlock(d,{key:p.id,title:p.title,text:p.text,onClose:()=>e.closeAlert(p.id)},null,8,["title","text","onClose"]))),128))],2)],4),b.createVNode(h)],64)}const Qxe=la(Gxe,[["render",Jxe]]);function St(e,t){console.error("Runtime error ========================="),console.error(`Command: ${e.commandType}`),console.error("Args: ",e.args),console.error("Options: ",e.options),Wt(`Runtime error at ${e.fileName}:${e.line} (${e.commandType}) ${e.code}. -
219
219
  <br />
220
220
  Error: ${t}`),console.error("============================")}function Yxe(e,...t){console.log(`[${e.fileName}:${e.line}] log: `,...t)}class Ue{constructor(t,n,r,o){ro(this,"keyword");ro(this,"runner");ro(this,"argTypes");ro(this,"parser");ro(this,"onPlayerAnswered");ro(this,"returnAfterPlayerAnswer");this.keyword=t,this.runner=r,this.argTypes=n,o?this.parser=o:this.parser=mp(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)=>{an().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 Ue(t.keyword,t.argTypes,t.runner,t.parser);return n.onPlayerAnswered=t.onPlayerAnswered,n.returnAfterPlayerAnswer=t.returnAfterPlayerAnswer??!1,n}}function mp(e,t){let n=[];if(t!=="any"){n=[];const r=t.reduce((o,i)=>(i.optional&&o++,i.type==="rest"&&(o=1/0),o),0);r>=1?n.push(t.length-r):n.push(t.length),n.push(t.length)}return(r,o)=>{const i={newLine:r.currentLine+1},a=o.command.args;return t!=="any"&&(a.length<n[0]||a.length>n[1])?(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):(o.command.commandType=e,t!=="any"&&o.command.args.forEach((s,l)=>{const c=t[l];!I9(s)&&!D9(s)&&(c.type==="any"||c.type==="rest"||typeof s===c.type||r.parserContext.error(r.line.line,`Command ${e}: Argument #${l+1} (${c.name}) should be a ${c.type}, but got type ${typeof s}: ${JSON.stringify(s)}`))}),{newLine:r.currentLine+1})}}const Xxe=new Ue("add_level",[{name:"skillKey",type:"string"},{name:"amount",type:"number"}],async e=>{let{skillKey:t,amount:n}=e.options;if((!t||!n)&&St(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}`)}Dr().incrementSkill(t,n)}),Zxe=Ue.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)&&St(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}`)}Dr().setSkillLevel(t,n)}}),e2e=new Ue("add_xp",[{name:"xpKey",type:"string"},{name:"xpToAdd",type:"number"}],async e=>{const{xpKey:t,xpToAdd:n}=e.options;(!t||!n)&&St(e,"add_xp command needs a skill id and a value as parameters"),Dr().addXp(t,n)}),t2e=new Ue("get_level",[{name:"skillKey",type:"string"}],async e=>{const{skillKey:t}=e.options;t||St(e,"get_level command needs a skill id as parameter");const n=Dr().getSkill(t);return n||St(e,`Skill ${t} not found`),n.level}),n2e=new Ue("get_xp",[{name:"xpKey",type:"string"}],async e=>{const{xpKey:t}=e.options;t||St(e,"get_xp command needs a skill id as parameter");const n=Dr().getSkillXp(t);return n||St(e,`XP ${t} not found`),n}),r2e=new Ue("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&&nV(t))n={...tV(t),id:t};else{const{skill:o,difficulty:i,mode:a}=e.options;if(!o||!i){St(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 N9(n).succeeded}),o2e=new Ue("get_skill_check",[{name:"skillCheckId",type:"string"}],async e=>Dr().getSkillCheck(e.options.skillCheckId)),i2e=new Ue("skill_check_result",[{name:"skillCheckId",type:"string"}],async e=>Dr().getSkillCheck(e.options.skillCheckId).succeeded),a2e=new Ue("reset_roll",[{name:"id",type:"string"}],async e=>Dr().resetSkillCheck(e.options.id)),s2e=new Ue("add_stat",[{name:"statKey",type:"string"},{name:"amountToAdd",type:"number"}],async e=>{const{statKey:t,amountToAdd:n}=e.options;(!t||typeof n!="number")&&St(e,"add_stat command needs a stat id and a value as parameters"),_s().addStat(t,n)}),l2e=new Ue("set_stat",[{name:"statKey",type:"string"},{name:"value",type:"number"}],async e=>{const{statKey:t,value:n}=e.options;(!t||typeof n!="number")&&St(e,"set_stat command needs a stat id and a value as parameters"),_s().setStat(t,n)}),c2e=new Ue("get_stat_value",[{name:"statKey",type:"string"}],async e=>{const{statKey:t}=e.options;return t||St(e,"get_stat_value command needs a stat id as parameter"),_s().getStatValue(t)}),u2e=Ue.FromOptions({keyword:"jump",argTypes:"any",runner:async e=>{(e.args.length<1||typeof e.args[0]!="string")&&St(e,"requires a label argument");const t=e.args[0],n=an(),r={branchData:bn.script[t],label:t,args:e.args.splice(1),currentIndex:0};if(!bn.script[t]){Wt(`Trying to jump but label ${t} not found`);return}return n.jumpTarget=r,Fg}}),f2e=Ue.FromOptions({keyword:"run",argTypes:"any",runner:async e=>{(e.args.length<1||typeof e.args[0]!="string")&&St(e,"run command needs a label to argument run");const t=e.args[0];return await an().runLabelFunction(t,...e.args.slice(1))}}),d2e=Ue.FromOptions({keyword:"var",argTypes:[{name:"name",type:"string"},{name:"value",type:"any"}],runner:async e=>{const{name:t,value:n}=e.options;an().addScopedVariable(t,n)}}),h2e=Ue.FromOptions({keyword:"return",argTypes:[{name:"value",type:"any"}],runner:async e=>{const{value:t}=e.options;return an().setReturnValue(t),Hx}}),p2e=Ue.FromOptions({keyword:"log",argTypes:"any",runner:async e=>{Yxe(e,...e.args)}}),m2e=Ue.FromOptions({keyword:"menu_return",argTypes:[],runner:async e=>(Zt().menuReturn(),Vg)}),v2e=Ue.FromOptions({keyword:"save",argTypes:[{name:"name",type:"string",optional:!0}],runner:async e=>{await Zt().manualSave({saveName:e.options.name})}}),g2e=Ue.FromOptions({keyword:"save_prompt",argTypes:[{name:"name",type:"string",optional:!0}],runner:async e=>{await Zt().manualSave({saveName:e.options.name,withPrompt:!0})}}),y2e=Ue.FromOptions({keyword:"reset_global_save",argTypes:[],runner:async e=>{await Zt().resetGlobalSave()}}),b2e=Ue.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 console.log(e.args),[...e.args.slice(1)];if(t==="Object")return{}}}),w2e=[{name:"mode",type:"string"},{name:"audio",type:"string"},{name:"channel",type:"number",optional:!0}],k2e=new Ue("play",w2e,async e=>{const t=yo(),{mode:n,audio:r,channel:o}=e.options,i=$0(e,n);i&&t.playChannel(i,r,o??0)}),x2e=new Ue("resume",[{name:"mode",type:"string"},{name:"channel",type:"number",optional:!0}],async e=>{const t=yo(),{mode:n,channel:r}=e.options,o=$0(e,n);o&&t.resumeChannel(o,r??0)}),_2e=new Ue("pause",[{name:"mode",type:"string"},{name:"channel",type:"number",optional:!0}],async e=>{const t=yo(),{mode:n,channel:r}=e.options,o=$0(e,n);o&&t.pauseChannel(o,r??0)}),j2e=new Ue("stop",[{name:"mode",type:"string"},{name:"channel",type:"number",optional:!0}],async e=>{const t=yo(),{mode:n,channel:r}=e.options,o=$0(e,n);o&&t.stopChannel(o,r??0)});function $0(e,t){return S2e(t)?t:(St(e,`${t} is not a valid audio mode.`),!1)}function S2e(e){return!!H7.includes(e)}const C2e=new Ue("set",[{name:"key",type:"string"},{name:"value",type:"any"}],async e=>{const t=Yf();iV(t,`$${e.options.key}`,e.options.value)}),$2e=new Ue("add",[{name:"key",type:"string"},{name:"value",type:"any"}],async e=>{const t=Yf();aV(t,`$${e.options.key}`,e.options.value)}),T2e=new Ue("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=Ia();if(!dp(e.options.screen)){St(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)}),E2e=new Ue("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=Ia();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)}),O2e=new Ue("set_button",[{name:"buttonId",type:"string"},{name:"state",type:"any"}],async e=>{const{buttonId:t,state:n}=e.options,r=Ia();if(!Jf(t)){St(e,`Button ${t} doesn't exist in the config`);return}r.changeButton(t,n)}),A2e=Ue.FromOptions({keyword:"talk",argTypes:[{name:"speaker",type:"string"},{name:"pose",type:"string"},{name:"text",type:"string"}],runner:async(e,t)=>{await Kx({speaker:e.options.speaker,pose:e.options.pose,cssClass:"talk-command",text:`"${e.options.text}"`,choices:t,interactive:!0})},returnAfterPlayerAnswer:!0}),M2e=Ue.FromOptions({keyword:"think",argTypes:[{name:"speaker",type:"string"},{name:"pose",type:"string"},{name:"text",type:"string"}],runner:async(e,t)=>{await Kx({speaker:e.options.speaker,pose:e.options.pose,cssClass:"think-command",text:`${e.options.text}`,choices:t,interactive:!0})},returnAfterPlayerAnswer:!0}),P2e=()=>{const e=mp("text",[]);return(t,n)=>{const r=e(t,n);return n.command.staticOptions={text:n.code.substring(1,n.code.length-1)},r}},N2e=Ue.FromOptions({keyword:"text",argTypes:[],runner:async(e,t)=>{await Kx({speaker:pi().gameCharacter,cssClass:"text-command",text:e.staticOptions.text,choices:t,interactive:!0})},parser:P2e(),returnAfterPlayerAnswer:!0}),I2e=new Ue("add_item",[{name:"id",type:"string"},{name:"amount",type:"number"}],async e=>{const{id:t,amount:n}=e.options;lo().add({id:t,amount:n})}),D2e=new Ue("remove_item",[{name:"id",type:"string"},{name:"amount",type:"number"}],async e=>{const{id:t,amount:n}=e.options;lo().remove({id:t,amount:n})}),R2e=new Ue("has_item?",[{name:"id",type:"string"},{name:"amount",type:"number",optional:!0}],async e=>{const{id:t,amount:n}=e.options;return lo().hasItem(t,n)}),L2e=new Ue("item_amount?",[{name:"id",type:"string"}],async e=>{const{id:t}=e.options;return lo().getItemAmount(t)}),B2e=new Ue("enable_interaction",[{name:"tag",type:"string"}],async e=>{const t=e.options.tag;lo().enableInteraction(t)}),F2e=new Ue("disable_interaction",[{name:"tag",type:"string"}],async e=>{const t=e.options.tag;lo().disableInteraction(t)}),V2e=new Ue("start_quest",[{name:"questId",type:"string"}],async e=>{const t=e.options.questId;Fo().startQuest(t)}),z2e=new Ue("start_objective",[{name:"questId",type:"string"},{name:"objectiveId",type:"string"}],async e=>{const{questId:t,objectiveId:n}=e.options;Fo().startObjective(t,n)}),U2e=new Ue("complete_objective",[{name:"questId",type:"string"},{name:"objectiveId",type:"string"}],async e=>{const{questId:t,objectiveId:n}=e.options;Fo().completeObjective(t,n)}),q2e=new Ue("complete_quest",[{name:"questId",type:"string"},{name:"ending",type:"string",optional:!0}],async e=>{const{questId:t,ending:n}=e.options;Fo().completeQuest(t,n)}),H2e=new Ue("quest_completed?",[{name:"questId",type:"string"}],async e=>{const{questId:t}=e.options;return Fo().isQuestCompleted(t)}),W2e=new Ue("objective_completed?",[{name:"questId",type:"string"},{name:"objectiveId",type:"string"}],async e=>{const{questId:t,objectiveId:n}=e.options;return Fo().isObjectiveCompleted(t,n)}),K2e=new Ue("quest_started?",[{name:"questId",type:"string"}],async e=>{const{questId:t}=e.options;return Fo().isQuestStarted(t)}),G2e=new Ue("objective_started?",[{name:"questId",type:"string"},{name:"objectiveId",type:"string"}],async e=>{const{questId:t,objectiveId:n}=e.options;return Fo().isObjectiveStarted(t,n)}),J2e=Ue.FromOptions({keyword:"wait",argTypes:[{name:"duration",type:"number"}],runner:async e=>{await ea(e.options.duration)}}),Q2e=new Ue("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;vi().addNotification(t,r,n)}),Y2e=new Ue("disable_notifications",[],async e=>{vi().disableNotifications()}),X2e=new Ue("enable_notifications",[],async e=>{vi().enableNotifications()}),Z2e=new Ue("clear_dialog",[],async e=>{qn().clearDialog()}),e_e=new Ue("if",[{name:"condition",type:"boolean"}],async e=>{const t=[];for(const o of e.staticOptions.elseifs){const i=o.condition,a=await Yg(i);t.push(a)}const n=pme(e,t),r=an();if(n){const o={branchData:{branch:n},currentIndex:0};return r.addAndRunBlock(o)}},(e,t)=>{let n=e.currentLine;mp("if",[{name:"condition",type:"string"}])(e,t);const{lines:o,currentLine:i,line:a}=e,s=t.command;let l,c=i,f=!1;const u=[];for(;!f;){c++;const d=mme(o,c);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:u2(e.parserContext,d,h[1])})}else d&&d.code==="else:"?l=e.processCommandsFunction(e.parserContext,d.branch,a):(f=!0,c--)}return s.staticOptions={success:e.processCommandsFunction(e.parserContext,a.branch,a),elseifs:u,failure:l},c++,n=c,{newLine:n}}),t_e=new Ue("==","any",async e=>{e.args.length<1&&St(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}),n_e=new Ue(">",[{name:"a",type:"any"},{name:"b",type:"any"}],async e=>{const{a:t,b:n}=e.options;return t>n}),r_e=new Ue("<",[{name:"a",type:"any"},{name:"b",type:"any"}],async e=>{const{a:t,b:n}=e.options;return t<n}),o_e=new Ue(">=",[{name:"a",type:"any"},{name:"b",type:"any"}],async e=>{const{a:t,b:n}=e.options;return t>=n}),i_e=new Ue("<=",[{name:"a",type:"any"},{name:"b",type:"any"}],async e=>{const{a:t,b:n}=e.options;return t<=n}),a_e=new Ue("!=",[{name:"a",type:"any"},{name:"b",type:"any"}],async e=>{const{a:t,b:n}=e.options;return t!=n}),s_e=new Ue("!",[{name:"a",type:"any"}],async e=>{const{a:t}=e.options;return!t}),l_e=new Ue("&&","any",async e=>{const t=e.args;return e.args.length<2&&St(e,"requires at least two arguments"),t.reduce((n,r)=>n&&r,!0)}),c_e=new Ue("||","any",async e=>(e.args.length<2&&St(e,"requires at least two arguments"),e.args.reduce((t,n)=>t||n,!1))),u_e=new Ue("?",[{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}),f_e=new Ue("+","any",async e=>(e.args.length<2&&St(e,"requires at least two arguments"),e.args.reduce((t,n)=>typeof n=="number"?t+n:(St(e,"requires all arguments to be numbers"),t),0))),d_e=new Ue("-","any",async e=>(e.args.length<2&&St(e,"requires at least two arguments"),e.args.slice(1).reduce((t,n)=>typeof n=="number"?t-n:(St(e,"requires all arguments to be numbers"),t),e.args[0]))),h_e=new Ue("neg",[{name:"a",type:"number"}],async e=>(e.args.length!==1&&St(e,"requires one argument"),-e.options.a)),p_e=new Ue("abs",[{name:"a",type:"number"}],async e=>(e.args.length!==1&&St(e,"requires one argument"),Math.abs(e.options.a))),m_e=new Ue("*","any",async e=>(e.args.length<2&&St(e,"requires at least two arguments"),e.args.reduce((t,n)=>typeof n=="number"?t*n:(St(e,"requires all arguments to be numbers"),t),1))),v_e=new Ue("/","any",async e=>{e.args.length<2&&St(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:(St(e,"requires all arguments to be numbers"),n),t)}),g_e=async e=>{const{prompt:t,choices:n}=e.staticOptions,r=[];for(const[,a]of n.entries()){const s=await Yg(a.prompt);r.push(s)}e.options.choiceResults=r;const o=r.map((a,s)=>{var f;let l=!0;return a.skillCheck&&(l=((f=a.skillCheck)==null?void 0:f.allowed)??!1),{choice:a.text,originalIndex:s,allowed:l}}).filter(a=>a.choice),i=await JB(t,o);return await k_e(e,i)};function y_e(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"?((!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 b_e=(e,t)=>{let n=e.currentLine;mp("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((l,c)=>(l.branch||e.parserContext.error(l.line,`Choice option doesn't have any branch to go to (${l.code})`),l=x_e(e.parserContext,l),y_e(e,l)));return o.staticOptions={prompt:e.processCommandsFunction(e.parserContext,[i],r)[0],choices:s},n++,{newLine:n}},w_e=Ue.FromOptions({keyword:"choice",argTypes:[],runner:g_e,parser:b_e}),k_e=async(e,t)=>{const n=t,r=an(),{choices:o}=e.staticOptions,i=o[n],a=e.options.choiceResults[n];let s=a.text,l;if(a.skillCheck?(s=null,N9(a.skillCheck.options).succeeded?l=i.skillBranches.success:l=i.skillBranches.failure):l=i.branch,s){const c={speaker:pi().playerCharacter,text:s,interactive:!1};qn().addDialog(c)}if(l){const c={currentIndex:0,branchData:{branch:l}};return await r.addAndRunBlock(c)}};function x_e(e,t){return{code:`choicePrompt ${t.code}`,indentation:t.indentation,line:t.line,branch:t.branch,expression:["choicePrompt",...t.expression]}}const __e=new Ue("choicePrompt","any",async e=>{const t=e.args;if(t[0]==="roll"){const n=t[1];let r={},o=2;nV(n)?r={...tV(n),id:n}:(r={id:n,skill:t[2],difficulty:t[3]},o=4);const i=t[o];o++;let a=!1,s=!1,l;t.length>o&&(t[o]==="if"?(s=!0,t.length<o+2&&St(e,'Missing condition argument after "if" in choice with a skill check'),l=t[o+1]):(a=t[o],t.length>o+1&&(o++,t[o]==="if"?(s=!0,t.length<o+2&&St(e,'Missing condition argument after "if" in choice with a skill check'),l=t[o+1]):St(e,`Invalid argument after skill check mode: ${t[6]}. The next argument can only be an if condition.`)))),a==="hideAfterRoll"&&(r.hideAfterRoll=!0),a==="repeatable"&&(r.repeatable=!0);const c=Dr().getSkillCheck(n);if(c.hidden||s&&!l)return{text:null};const f=!c.happened||c.happened&&c.succeeded||r.repeatable,{difficultyText:u}=xpe({skill:r.skill,skillCheckId:n,value:r.difficulty});return{text:`${u} ${i}`,skillCheck:{allowed:f,options:r}}}else if(t.length>1&&t[1]==="if"){const n=t[0];let r=!0;return t.length>2&&(r=t[2]),r?{text:n}:{text:null}}else return{text:t[0]}}),CV=Ue.FromOptions({keyword:"text_field",argTypes:[{name:"prompt",type:"string"}],returnAfterPlayerAnswer:!0,runner:async e=>{const t={speaker:pi().gameCharacter,text:e.options.prompt,textField:!0,interactive:!0};qn().addDialog(t)}});CV.onPlayerAnswered=async(e,t)=>(typeof t!="string"&&St(e,"The player's answer should be a string"),t);const j_e=Ue.FromOptions({keyword:"text_field_prompt",argTypes:[{name:"prompt",type:"string"}],runner:async e=>{const t={speaker:pi().gameCharacter,text:e.options.prompt,textField:!0,interactive:!0};qn().addDialog(t)}}),S_e=new Ue("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"?(St(e,"random command needs two numbers as parameters"),0):Math.floor(Math.random()*(n-t+1))+t}),C_e=new Ue("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"?(St(e,"random_float command needs two numbers as parameters"),0):Math.random()*(n-t)+t}),$_e=new Ue("random_from_args",[],async e=>{const t=e.args;return!t||!t.length?(St(e,"random_from_args command needs at least one argument"),0):t[Math.floor(Math.random()*t.length)]}),T_e=new Ue("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)]:(St(e,"random_from_array command needs an array as parameter"),0)}),E_e=new Ue("concat","any",async e=>(e.args.length<2&&St(e,"requires at least two arguments"),e.args.reduce((t,n)=>typeof n=="string"?`${t}${n}`:(St(e,"requires all arguments to be strings"),t),""))),O_e=new Ue("join","any",async e=>{const t=e.args[0];return e.args.length<3&&St(e,"requires at least 3 arguments"),e.args.slice(1).reduce((n,r)=>typeof r=="string"?`${n}${t}${r}`:(St(e,"requires all arguments to be strings"),n),"")}),A_e=Ue.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}}),M_e=Ue.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}}),P_e=Ue.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}}),N_e=Ue.FromOptions({keyword:"floor",argTypes:[{name:"value",type:"number"}],runner:async e=>{const{value:t}=e.options;return Math.floor(t)}}),I_e=Ue.FromOptions({keyword:"ceil",argTypes:[{name:"value",type:"number"}],runner:async e=>{const{value:t}=e.options;return Math.ceil(t)}}),D_e=Ue.FromOptions({keyword:"round",argTypes:[{name:"value",type:"number"}],runner:async e=>{const{value:t}=e.options;return Math.round(t)}}),R_e=Ue.FromOptions({keyword:"sqrt",argTypes:[{name:"value",type:"number"}],runner:async e=>{const{value:t}=e.options;return Math.sqrt(t)}}),L_e=Ue.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)}}),B_e=new Ue("create_sprite",[{name:"image",type:"string"},{name:"x",type:"number"},{name:"y",type:"number"},{name:"parent",type:"any",optional:!0}],async e=>{const t=ei(),{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=ei().getObject(i)),t.createSprite(a)}),F_e=new Ue("create_object",[{name:"x",type:"number"},{name:"y",type:"number"},{name:"parent",type:"any",optional:!0}],async e=>{const t=ei(),{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=ei().getObject(o)),t.createObject(i)}),V_e=new Ue("delete_sprite",[{name:"sprite",type:"any"}],async e=>ei().destroyObject(e.options.sprite)),z_e=Ue.FromOptions({keyword:"empty_sprites",argTypes:[{name:"layer",type:"number",optional:!0}],runner:async e=>{const t=ei(),{layer:n}=e.options;return typeof n=="number"?t.emptyLayer(n):t.emptyAllLayers()}}),U_e=Ue.FromOptions({keyword:"shuffle",argTypes:[{name:"array",type:"any"}],runner:async e=>{const t=e.options.array;if(!Array.isArray(t)){St(e,"requires an array argument");return}return lje(t),t}}),q_e=Ue.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)){St(e,"requires an array argument");return}return t.push(n),t}}),H_e=Ue.FromOptions({keyword:"pop",argTypes:[{name:"array",type:"any"}],runner:async e=>{const{array:t}=e.options;if(!Array.isArray(t)){St(e,"requires an array argument");return}return t.pop()}}),W_e=Ue.FromOptions({keyword:"shift",argTypes:[{name:"array",type:"any"}],runner:async e=>{const{array:t}=e.options;if(!Array.isArray(t)){St(e,"requires an array argument");return}return t.shift()}}),K_e=Ue.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)){St(e,"requires an array argument");return}return t.unshift(n),t}}),G_e=Ue.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)){St(e,"requires an array argument");return}if(typeof n<"u"&&typeof n!="string"){St(e,"array join string separator must be a string");return}return t.join(n),t}}),J_e=Ue.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)){St(e,"requires an array argument");return}for(const r of n)if(!Array.isArray(r)){St(e,"All concat arguments should be arrays");return}return t.concat(...n.slice(1))}}),Q_e=Ue.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)||St(e,"requires an array argument"),typeof n>"u"&&St(e,"requires a search element argument"),t.includes(n)}}),Y_e=Ue.FromOptions({keyword:"reverse",argTypes:[{name:"array",type:"any"}],runner:async e=>{const{array:t}=e.options;return Array.isArray(t)||St(e,"requires an array argument"),t.reverse(),t}}),X_e=Ue.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)||St(e,"requires an array argument"),typeof n!="number"&&St(e,"requires a start index argument"),typeof r<"u"&&typeof r!="number"&&St(e,"end index argument must be a number if present"),t.slice(n,r)}}),Z_e=Ue.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)||St(e,"requires an array argument"),typeof n!="number"&&St(e,"requires a start index argument"),typeof r<"u"&&typeof r!="number"&&St(e,"end index argument must be a number if present"),t.splice(n,r)}}),eje=Ue.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)||St(e,"requires an array argument");for(const[r,o]of t.entries())if(await an().runLabelFunction(n,o,r,t,...e.args.slice(2))===!0)return r;return-1}}),tje=Ue.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)||St(e,"requires an array argument");for(const[r,o]of t.entries())if(await an().runLabelFunction(n,o,r,t,...e.args.slice(2))===!0)return o;return null}}),nje=Ue.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)||St(e,"requires an array argument");const r=[];for(const[o,i]of t.entries())await an().runLabelFunction(n,i,o,t,...e.args.slice(2))===!0&&r.push(i);return r}}),rje=Ue.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)||St(e,"requires an array argument");const r=[];for(const[o,i]of t.entries()){const a=await an().runLabelFunction(n,i,o,t,...e.args.slice(2));r.push(a)}return r}}),oje=Ue.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)||St(e,"requires an array argument");let o=r;for(const[i,a]of t.entries())o=await an().runLabelFunction(n,o,a,i,t,...e.args.slice(3));return o}}),ije=Ue.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)||St(e,"requires an array argument");for(const[r,o]of t.entries())if(await an().runLabelFunction(n,o,r,t,...e.args.slice(2))===!0)return!0;return!1}}),aje=Ue.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)||St(e,"requires an array argument");for(const[r,o]of t.entries())if(await an().runLabelFunction(n,o,r,t,...e.args.slice(2))!==!0)return!1;return!0}}),sje=Ue.FromOptions({keyword:"array_entries",argTypes:[{name:"array",type:"any"}],runner:async e=>{const{array:t}=e.options;return Array.isArray(t)||St(e,"requires an array argument"),t.entries()}});function lje(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 cje=Ue.FromOptions({keyword:"load_data",argTypes:[{name:"url",type:"string"}],runner:async e=>{const{url:t}=e.options;return await Jg(h_(t))}}),uje=Ue.FromOptions({keyword:"change_player_character",argTypes:[{name:"character",type:"string"}],runner:async e=>{const{character:t}=e.options;pi().config.characters.config.playerCharacter=t}}),fje=Ue.FromOptions({keyword:"change_game_character",argTypes:[{name:"character",type:"string"}],runner:async e=>{const{character:t}=e.options;pi().config.characters.config.gameCharacter=t}}),dje=Ue.FromOptions({keyword:"time_now",argTypes:[],runner:async e=>Date.now()}),hje=Ue.FromOptions({keyword:"total_playtime",argTypes:[],runner:async e=>Zt().totalPlayTime}),pje=Ue.FromOptions({keyword:"session_playtime",argTypes:[],runner:async e=>Zt().sessionPlayTime}),mje=Ue.FromOptions({keyword:"to_days",argTypes:[{name:"time",type:"number"}],runner:async e=>Math.floor(e.options.time/864e5)}),vje=Ue.FromOptions({keyword:"to_hours",argTypes:[{name:"time",type:"number"}],runner:async e=>Math.floor(e.options.time/36e5)}),gje=Ue.FromOptions({keyword:"to_minutes",argTypes:[{name:"time",type:"number"}],runner:async e=>Math.floor(e.options.time/6e4)}),yje=Ue.FromOptions({keyword:"to_seconds",argTypes:[{name:"time",type:"number"}],runner:async e=>Math.floor(e.options.time/1e3)}),bje=new Ue("unlock_achievement",[{name:"id",type:"string"}],async e=>{const{id:t}=e.options;Yl().unlock(t)}),wje=new Ue("has_achievement?",[{name:"id",type:"string"}],async e=>{const{id:t}=e.options;return Yl().hasAchievement(t)}),kje=Ue.FromOptions({keyword:"get_setting",argTypes:[{name:"setting",type:"string"}],runner:async e=>{const{setting:t}=e.options;return t||St(e,"get_setting command needs a setting id"),Da().getSetting(t)}}),xje=Ue.FromOptions({keyword:"set_setting",argTypes:[{name:"setting",type:"string"},{name:"value",type:"any"}],runner:async e=>{const{setting:t,value:n}=e.options;t||St(e,"set_setting command needs a setting id"),Da().setSetting(t,n)}}),_je=Ue.FromOptions({keyword:"object_entries",argTypes:[{name:"obj",type:"any"}],runner:async e=>{const t=e.options.obj;return typeof t!="object"?(St(e,"Requires an object argument."),[]):Object.entries(t)}}),jje=Ue.FromOptions({keyword:"object_keys",argTypes:[{name:"obj",type:"any"}],runner:async e=>{const t=e.options.obj;return typeof t!="object"?(St(e,"Requires an object argument."),[]):Object.keys(t)}}),Sje=Ue.FromOptions({keyword:"object_values",argTypes:[{name:"obj",type:"any"}],runner:async e=>{const t=e.options.obj;return typeof t!="object"?(St(e,"Requires an object argument."),[]):Object.values(t)}}),Cje=Ue.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"?(St(e,"Requires an object argument."),!1):Object.hasOwn(t,n)}}),$je=Ue.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 St(e,"Requires an object argument."),!1;for(const r of t)await an().runLabelFunction(n,r,...e.args.slice(2))}}),Tje=Ue.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 St(e,"Requires an object argument."),!1;for(const r in t)await an().runLabelFunction(n,r,t[r],...e.args.slice(2))}});function Eje(e){e.addCommand(w_e),e.addCommand(__e),e.addCommand(e_e),e.addCommand(s2e),e.addCommand(l2e),e.addCommand(c2e),e.addCommand(Z2e),e.addCommand(Q2e),e.addCommand(Y2e),e.addCommand(X2e),e.addCommand(_2e),e.addCommand(k2e),e.addCommand(x2e),e.addCommand(j2e),e.addCommand(O2e),e.addCommand(T2e),e.addCommand(E2e),e.addCommand(B_e),e.addCommand(F_e),e.addCommand(V_e),e.addCommand(z_e),e.addCommand(J2e),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(l_e),e.addCommand(c_e),e.addCommand(u_e),e.addCommand(f_e),e.addCommand(d_e),e.addCommand(m_e),e.addCommand(v_e),e.addCommand(h_e),e.addCommand(p_e),e.addCommand($2e),e.addCommand(C2e),e.addCommand(N2e),e.addCommand(A2e),e.addCommand(M2e),e.addCommand(u2e),e.addCommand(f2e),e.addCommand(d2e),e.addCommand(h2e),e.addCommand(p2e),e.addCommand(m2e),e.addCommand(v2e),e.addCommand(y2e),e.addCommand(g2e),e.addCommand(b2e),e.addCommand(V2e),e.addCommand(z2e),e.addCommand(U2e),e.addCommand(q2e),e.addCommand(K2e),e.addCommand(G2e),e.addCommand(H2e),e.addCommand(W2e),e.addCommand(I2e),e.addCommand(D2e),e.addCommand(B2e),e.addCommand(F2e),e.addCommand(R2e),e.addCommand(L2e),e.addCommand(Xxe),e.addCommand(Zxe),e.addCommand(e2e),e.addCommand(r2e),e.addCommand(a2e),e.addCommand(o2e),e.addCommand(i2e),e.addCommand(t2e),e.addCommand(n2e),e.addCommand(CV),e.addCommand(j_e),e.addCommand(S_e),e.addCommand(C_e),e.addCommand($_e),e.addCommand(T_e),e.addCommand(E_e),e.addCommand(O_e),e.addCommand(A_e),e.addCommand(M_e),e.addCommand(P_e),e.addCommand(N_e),e.addCommand(D_e),e.addCommand(I_e),e.addCommand(R_e),e.addCommand(L_e),e.addCommand(U_e),e.addCommand(q_e),e.addCommand(H_e),e.addCommand(W_e),e.addCommand(K_e),e.addCommand(G_e),e.addCommand(J_e),e.addCommand(Q_e),e.addCommand(Y_e),e.addCommand(X_e),e.addCommand(Z_e),e.addCommand(eje),e.addCommand(tje),e.addCommand(nje),e.addCommand(rje),e.addCommand(oje),e.addCommand(ije),e.addCommand(aje),e.addCommand(sje),e.addCommand(jje),e.addCommand(Sje),e.addCommand(_je),e.addCommand(Cje),e.addCommand($je),e.addCommand(Tje),e.addCommand(cje),e.addCommand(uje),e.addCommand(fje),e.addCommand(dje),e.addCommand(hje),e.addCommand(pje),e.addCommand(mje),e.addCommand(vje),e.addCommand(gje),e.addCommand(yje),e.addCommand(bje),e.addCommand(wje),e.addCommand(xje),e.addCommand(kje)}const Oje=b.defineComponent({data(){return{muted:!1,volumes:[],modeNames:{master:"Master volume:",music:"Music:",ambiant:"Ambiant:",sound:"Sound effects:"}}},mounted(){const e=yo(),t=ws.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"?yo().setMasterVolume(n.value):yo().setModeVolume(e,n.value)},toggleMute(){this.muted?(ws.Howler.mute(!1),this.muted=!1):(ws.Howler.mute(!0),this.muted=!0)}}}),M$e="",Aje={class:"volume-controls"},Mje=b.createElementVNode("h3",{class:"subtitle"},"Volume",-1),Pje={for:"volume",class:"volume-label"},Nje=["onUpdate:modelValue","onChange"];function Ije(e,t,n,r,o,i){return b.openBlock(),b.createElementBlock("div",Aje,[Mje,(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",Pje,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":l=>e.volumes[s].volume=l,onChange:l=>e.changeVolume(a.mode,l)},null,40,Nje),[[b.vModelText,e.volumes[s].volume]])]))),128))])}const Dje=la(Oje,[["render",Ije]]),Rje={class:"settings-widget-container"},Lje=["for","id"],Bje=["id","name","min","max","step"],Fje=["id","name"],Vje=["id","name"],zje={class:"mx-8"},Uje={class:"text-left setting-description"},qje=b.createElementVNode("hr",{class:"h-px my-8 bg-gray-200 border-0 dark:bg-gray-700 setting-separator"},null,-1),Hje=b.defineComponent({__name:"setting-widget",props:{settingId:{}},setup(e){const t=e,n=Da(),r=b.computed(()=>n.getSetting(t.settingId)),o=b.ref(r.value),i=b.computed(()=>n.getSettingSchema(t.settingId));function a(s){let l=s;XB(i.value)&&(l=Math.round(l)),n.setSetting(t.settingId,l)}return b.watch(o,s=>{a(s)}),(s,l)=>(b.openBlock(),b.createElementBlock(b.Fragment,null,[b.createElementVNode("div",Rje,[b.createElementVNode("label",{for:s.settingId,class:"setting-label",id:`setting-label-${s.settingId}`},b.toDisplayString(i.value.name),9,Lje),b.unref(x0e)(i.value)||b.unref(XB)(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":l[0]||(l[0]=c=>o.value=c)},null,8,Bje)),[[b.vModelText,o.value]]):b.unref(_0e)(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":l[1]||(l[1]=c=>o.value=c)},null,8,Fje)),[[b.vModelCheckbox,o.value]]):b.unref(j0e)(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":l[2]||(l[2]=c=>o.value=c)},null,8,Vje)),[[b.vModelText,o.value]]):b.createCommentVNode("",!0),b.createElementVNode("span",zje,b.toDisplayString(o.value),1)]),b.createElementVNode("p",Uje,b.toDisplayString(i.value.description),1),qje],64))}}),P$e="",Wje={class:"container mx-auto settings-menu-container"},Kje=b.createElementVNode("h2",{class:"settings-menu-title subtitle text-center"},"Settings",-1),Gje=b.defineComponent({__name:"settings-menu",setup(e){const t=Da(),n=b.computed(()=>t.getAllSettingSchemas());return(r,o)=>(b.openBlock(),b.createElementBlock("div",Wje,[Kje,(b.openBlock(!0),b.createElementBlock(b.Fragment,null,b.renderList(n.value,(i,a)=>(b.openBlock(),b.createBlock(Hje,{settingId:a,key:a},null,8,["settingId"]))),128))]))}}),N$e="",Jje={class:"menu-content"},Qje=b.defineComponent({__name:"MainMenu",emits:["close"],setup(e,{emit:t}){function n(){window.close()}function r(){Zt().menuReturn(),o()}function o(){t("close")}function i(){const a=su(Zt().playTime.start,Zt().playTime.previousPlaytime);return O0(a/1e3)}return(a,s)=>(b.openBlock(),b.createElementBlock("div",Jje,[b.createElementVNode("h3",null,"Play time: "+b.toDisplayString(i()),1),b.createVNode(Dje),b.createElementVNode("button",{class:"button title quit-button",onClick:r}," Main Menu "),b.createElementVNode("button",{class:"button title quit-button",onClick:n},"Exit"),b.createVNode(Gje)]))}}),I$e="",Yje={class:"inventory-section-items"},Xje=["onClick"],Zje={class:"item-title"},eSe={class:"item-amount"},tSe=b.defineComponent({__name:"inventory-section",props:{items:{},title:{},id:{}},setup(e){const t=e;function n(o){return{backgroundImage:`url(${oa(ol(o).icon)})`}}function r(o){return ol(o).name}return(o,i)=>(b.openBlock(),b.createElementBlock("div",{class:b.normalizeClass(["inventory-section",`section-${t.id}`])},[b.createElementVNode("h3",null,b.toDisplayString(o.title),1),b.createElementVNode("div",Yje,[(b.openBlock(!0),b.createElementBlock(b.Fragment,null,b.renderList(o.items,a=>(b.openBlock(),b.createElementBlock("button",{onClick:()=>o.$emit("chosen",a.id),class:b.normalizeClass(["item-display",`item-${a.id}`]),style:b.normalizeStyle(n(a.id)),key:a.id},[b.createElementVNode("h3",Zje,b.toDisplayString(r(a.id)),1),b.createElementVNode("h3",eSe,b.toDisplayString(a.amount),1)],14,Xje))),128))])],2))}}),D$e="",nSe={class:"flex flex-row item-description-container"},rSe={class:"flex item-left"},oSe={class:"flex item-right"},iSe=b.createElementVNode("hr",{class:"hr-solid"},null,-1),aSe=b.defineComponent({__name:"item-details",props:{item:{}},emits:["close","use"],setup(e){const t=e,n=b.computed(()=>ol(t.item.id)),r=b.computed(()=>({backgroundImage:`url(${oa(n.value.icon)})`})),o=b.computed(()=>lo().canUseItem(t.item));return(i,a)=>(b.openBlock(),b.createElementBlock("div",null,[b.createElementVNode("div",nSe,[b.createElementVNode("div",rSe,[b.createElementVNode("div",{class:"item-display",style:b.normalizeStyle(r.value)},null,4)]),b.createElementVNode("div",oSe,[b.createElementVNode("h2",null,b.toDisplayString(n.value.name),1),iSe,b.createElementVNode("h3",null,"Amount: "+b.toDisplayString(i.item.amount),1),b.createElementVNode("p",null,b.toDisplayString(n.value.description),1),b.createElementVNode("button",{onClick:a[0]||(a[0]=s=>i.$emit("use")),class:b.normalizeClass(["button",o.value?"":"disabled"])}," Use ",2)])]),b.createElementVNode("button",{class:"button",onClick:a[1]||(a[1]=s=>i.$emit("close"))},b.toDisplayString("<--"))]))}}),R$e="",sSe=b.defineComponent({setup(){const e=lo(),t=qn(),n=b.computed(()=>e.items),r=b.computed(()=>t.currentDialog.choices);return{items:n,currentlyChoosing:r}},emits:["close"],data(){return{chosenId:!1}},mounted(){},methods:{close(){this.$emit("close")},clickItem(e){this.chosenId=e},closeItem(){this.chosenId=!1},useItem(){if(this.chosenItem&&this.canUseChosenItem&&this.chosenItemConf){const e=this.chosenItemConf.onUse;this.close(),Gc("onItemUsed"),e.action==="jump"?an().jumpToLabel(e.label):e.action==="run"?an().runThenGoBackToPreviousDialog(e.label,!0):Wt(`Unknown action ${e.action}`)}}},computed:{itemsToDisplay(){return Object.values(this.items).filter(e=>e.amount>0?!0:!!ol(e.id).showIfEmpty)},chosenItem(){return this.chosenId?this.items[this.chosenId]:null},canUseChosenItem(){return lo().canUseItem(this.chosenItem)},chosenItemConf(){return this.chosenId?this.itemConf[this.chosenId]:null},itemConf(){return wt().items.items},sections(){const e=wt().items.categories,t=[];return this.itemsToDisplay.reduce((r,o)=>{const i=ol(o.id).category??"default",a=e.find(l=>l.id===i);if(!a)return Wt(`Unknown category ${i}`),r;let s=r.find(l=>l.id===i);return s||(s={id:i,title:a.title,items:[]},r.push(s)),s.items.push(o),r},t)}},components:{InventorySection:tSe,ItemDetails:aSe}}),L$e="",lSe={key:0},cSe={key:2},uSe=[b.createElementVNode("h2",null,"The inventory is empty!",-1)];function fSe(e,t,n,r,o,i){const a=b.resolveComponent("InventorySection"),s=b.resolveComponent("ItemDetails");return!e.chosenItem&&Object.keys(e.itemsToDisplay).length>0?(b.openBlock(),b.createElementBlock("div",lSe,[(b.openBlock(!0),b.createElementBlock(b.Fragment,null,b.renderList(e.sections,l=>(b.openBlock(),b.createBlock(a,{key:l.id,items:l.items,title:l.title,id:l.id,onChosen:e.clickItem},null,8,["items","title","id","onChosen"]))),128))])):typeof e.chosenId=="string"?(b.openBlock(),b.createBlock(s,{key:1,item:e.items[e.chosenId],onUse:e.useItem,onClose:e.closeItem},null,8,["item","onUse","onClose"])):(b.openBlock(),b.createElementBlock("div",cSe,uSe))}const dSe=la(sSe,[["render",fSe]]),hSe=["id"],pSe={class:"obtained-status"},mSe={class:"achievement-title"},vSe={class:"achievement-description"},gSe=b.defineComponent({__name:"achievement-tile",props:{achievement:{}},setup(e){const t=e,n=Yl(),r=b.computed(()=>n.getExistingAchievement(t.achievement)),o=b.computed(()=>p_(t.achievement)),i=Qf().secretAchievements??{censorName:!0,censorDescription:!0},a=b.computed(()=>{const f=r.value.unlocked?o.value.icon:Qf().defaultAchievementIcon;return{backgroundImage:`url(${oa(f)})`}}),s=b.computed(()=>!o.value.secret||!i.censorName?o.value.name:"Hidden Achievement"),l=b.computed(()=>!o.value.secret||!i.censorDescription?o.value.description:"This achievement is hidden. Complete it to discover more."),c=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",pSe,b.toDisplayString(c.value),1),b.createElementVNode("h3",mSe,b.toDisplayString(s.value),1),b.createElementVNode("p",vSe,b.toDisplayString(l.value),1)],8,hSe))}}),F$e="",ySe={class:"achievements-section-achievements"},bSe=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",ySe,[(b.openBlock(!0),b.createElementBlock(b.Fragment,null,b.renderList(n.achievements,o=>(b.openBlock(),b.createBlock(gSe,{achievement:o.id,key:o.id},null,8,["achievement"]))),128))])],2))}}),V$e="",wSe=b.defineComponent({setup(){const e=Yl(),t=qn(),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 wt().achievements.achievements},sections(){const e=wt().achievements.categories,t=[];return this.achievementsToDisplay.reduce((r,o)=>{const i=p_(o.id).category??"default",a=e.find(l=>l.id===i);if(!a)return Wt(`Unknown category ${i}`),r;let s=r.find(l=>l.id===i);return s||(s={id:i,title:a.title,achievements:[]},r.push(s)),s.achievements.push(o),r},t)}},components:{AchievementsSection:bSe}}),z$e="",kSe={key:0},xSe={key:1},_Se=[b.createElementVNode("h2",null,"The achievements section is empty!",-1)];function jSe(e,t,n,r,o,i){const a=b.resolveComponent("AchievementsSection");return Object.keys(e.achievementsToDisplay).length>0?(b.openBlock(),b.createElementBlock("div",kSe,[(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",xSe,_Se))}const SSe=la(wSe,[["render",jSe]]),CSe={class:"quest-display"},$Se={class:"quest-title"},TSe={class:"quest-description"},ESe={key:0,class:"quest-objectives-container list-disc"},OSe=b.defineComponent({__name:"QuestDetails",props:{quest:{}},setup(e){const t=e,n=b.computed(()=>ou(t.quest.id));function r(s){return y0(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?t.quest.ending:n.value.description),a=b.computed(()=>Object.values(t.quest.objectives).filter(s=>s.state!=="hidden"));return(s,l)=>(b.openBlock(),b.createElementBlock("div",CSe,[b.createElementVNode("div",{class:b.normalizeClass(["quest-header",s.quest.state==="completed"?"quest-completed":"quest-in-progress"])},[b.createElementVNode("h3",$Se,b.toDisplayString(n.value.title)+" "+b.toDisplayString(o.value),1)],2),b.createElementVNode("p",TSe,b.toDisplayString(i.value),1),s.quest.state!=="completed"?(b.openBlock(),b.createElementBlock("ul",ESe,[(b.openBlock(!0),b.createElementBlock(b.Fragment,null,b.renderList(a.value,c=>(b.openBlock(),b.createElementBlock("li",{class:"quest-objective-display",key:c.id},[b.createElementVNode("p",{class:b.normalizeClass(["quest-objective-description",c.state==="completed"?"quest-objective-completed":"quest-objctive-in-progress"])},b.toDisplayString(r(c.id).description),3)]))),128))])):b.createCommentVNode("",!0)]))}}),q$e="",ASe={class:"quest-list-title"},MSe=b.defineComponent({__name:"QuestDisplay",props:{quest:{}},setup(e){const t=e,n=b.computed(()=>ou(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",ASe,b.toDisplayString(n.value.title),1)],2))}}),H$e="",PSe={key:0},NSe={key:0},ISe={key:1},DSe=b.defineComponent({__name:"quests-list-section",props:{quests:{},sectionId:{},title:{},fallbackText:{}},emits:["quest-selected"],setup(e,{emit:t}){const n=e,r=b.computed(()=>up().categories),o=b.computed(()=>{const i=[];return n.quests.reduce((s,l)=>{const c=ou(l.id).category??"default",f=r.value.find(d=>d.id===c);if(!f)return Wt(`Quest category ${c} not found in config`),s;let u=s.find(d=>d.category.id===c);return u||(u={category:f,quests:[]},s.push(u)),u.quests.push(l),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",PSe,[(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",NSe,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,l=>(b.openBlock(),b.createBlock(MSe,{key:l.id,quest:l,onClick:c=>i.$emit("quest-selected",l)},null,8,["quest","onClick"]))),128))],2)],2))),128))])):(b.openBlock(),b.createElementBlock("div",ISe,[b.createElementVNode("p",null,b.toDisplayString(i.fallbackText),1)]))],2))}}),W$e="",RSe=b.defineComponent({setup(){const e=Fo(),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 Pi().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:OSe,QuestsListSection:DSe}}),K$e="",LSe={class:"quests-list-container"},BSe={class:"quest-details"};function FSe(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",LSe,[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",BSe,[e.selectedQuest?(b.openBlock(),b.createBlock(s,{key:0,quest:e.selectedQuest},null,8,["quest"])):b.createCommentVNode("",!0)])],2)}const VSe=la(RSe,[["render",FSe]]),zSe=b.defineComponent({setup(){const e=Dr();return{skills:b.computed(()=>e.skills)}},data(){return{chosenSkill:!1}},mounted(){},methods:{getSkillStyle(e){return{backgroundImage:`url(${oa(this.skillConf[e].icon)})`}},getSkillName(e){return this.skillConf[e].name},clickSkill(e){this.chosenSkill=e},closeSkill(){this.chosenSkill=!1},xpBarWidth(e){return{width:`${Math.floor(e/this.xpPerLevel*100)}%`}}},computed:{skillsToDisplay(){const e={};for(const t in this.skills)this.skillConf[t].hidden&&this.skills[t].level<1||(e[t]=this.skills[t]);return e},skillConf(){return rl().skills},xpPerLevel(){return rl().skillOptions.xpPerLevel}}}),G$e="",USe={key:0,class:"skills-container"},qSe=["onClick"],HSe={class:"skill-title"},WSe={class:"skill-xp-container"},KSe={class:"skill-xp-text"},GSe={class:"skill-level"},JSe={key:1},QSe={class:"flex flex-row skill-description-container"},YSe={class:"flex skill-left"},XSe={class:"flex skill-right"},ZSe=b.createElementVNode("hr",{class:"hr-solid"},null,-1);function eCe(e,t,n,r,o,i){return e.chosenSkill?typeof e.chosenSkill=="string"?(b.openBlock(),b.createElementBlock("div",JSe,[b.createElementVNode("div",QSe,[b.createElementVNode("div",YSe,[b.createElementVNode("div",{class:"skill-display",style:b.normalizeStyle(e.getSkillStyle(e.chosenSkill))},null,4)]),b.createElementVNode("div",XSe,[b.createElementVNode("h2",null,b.toDisplayString(e.getSkillName(e.chosenSkill)),1),ZSe,b.createElementVNode("h3",null,"Level: "+b.toDisplayString(e.skills[e.chosenSkill].level),1),b.createElementVNode("p",null,b.toDisplayString(e.skillConf[e.chosenSkill].description),1)])]),b.createElementVNode("button",{class:"button",onClick:t[0]||(t[0]=(...a)=>e.closeSkill&&e.closeSkill(...a))},b.toDisplayString("<--"))])):b.createCommentVNode("",!0):(b.openBlock(),b.createElementBlock("div",USe,[(b.openBlock(!0),b.createElementBlock(b.Fragment,null,b.renderList(e.skillsToDisplay,a=>(b.openBlock(),b.createElementBlock("button",{onClick:()=>e.clickSkill(a.id),class:"skill-display",style:b.normalizeStyle(e.getSkillStyle(a.id)),key:a.id},[b.createElementVNode("h3",HSe,b.toDisplayString(e.getSkillName(a.id)),1),b.createElementVNode("div",WSe,[b.createElementVNode("div",{class:"skill-xp-bar",style:b.normalizeStyle(e.xpBarWidth(a.xp))},null,4),b.createElementVNode("h3",KSe,b.toDisplayString(a.xp)+" / "+b.toDisplayString(e.xpPerLevel)+" XP",1)]),b.createElementVNode("h3",GSe,b.toDisplayString(a.level),1)],12,qSe))),128))]))}const tCe=la(zSe,[["render",eCe]]);function nCe(e){e.component("MainMenu",Qje),e.component("InventoryUi",dSe),e.component("AchievementsUI",SSe),e.component("QuestsUi",VSe),e.component("SkillsWindow",tCe),gi().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:()=>gi().showSkills,component:"SkillsWindow"},{id:"inventory",cssId:"inventory-menu-button",text:"Items",condition:()=>gi().showInventory,component:"InventoryUi"},{id:"quests",cssId:"quests-menu-button",text:"Quests",condition:()=>gi().showQuests,component:"QuestsUi"},{id:"achievements",cssId:"achievements-menu-button",text:"Achievements",condition:()=>gi().showAchievements,component:"AchievementsUI"}],activeTab:0}}}function $V(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])}gi().addMenu(e,t)}function rCe(e,t,n){window.narrat.app.component(t.component,n),gi().addMenuOption(e,t)}function oCe(){for(const e of bn.plugins){if(e.customMenuButtons)for(const t of e.customMenuButtons)$V(t.config.id,t.config,t.components);if(e.customMenuTabs)for(const t of e.customMenuTabs)rCe(t.config.id,t.config,t.component)}}function iCe(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"}})}function aCe(e){if(!e||!e.default)return;const t=e.default;sCe(t)&&bn.addNarratScript(t)}function sCe(e){return typeof e=="object"&&e!==null&&typeof e.code=="string"&&typeof e.fileName=="string"&&typeof e.id=="string"}let rc;bn.callHook("onPageLoaded");async function lCe(e){_0.setup(),console.log("Starting narrat...");const t=Object.assign(t0e(),e),n=Zhe();rc=b.createApp(Qxe,{options:t}),iCe(rc),rc.use(n);const r=await Ube(t);pi().setConfig(r),Xs(),zo().setupInputs(),bn.pinia=n,Zt();const o={app:rc,vm:bn,handleHMR:aCe,jump:i=>{an().jumpToLabel(i)},getSave:()=>Xs()};return window.narrat=o,nCe(rc),oCe(),jV().addButtonsFromPlugins(),Zt().setOptions(t),Eje(bn),E0.setupDebugger(t.debug),console.log(`%c Narrat game engine v${Upe} - Built at ${qpe.toLocaleString()}`,"background: #222; color: #bada55"),bn.callHook("onNarratSetup"),rc.mount("#game-holder"),rc}function cCe(e,t){rc.component(e,t)}class uCe{constructor(){ro(this,"pluginId","narrat-plugin")}onPageLoaded(){}onNarratSetup(){}onAppMounted(){}onAssetsLoaded(){}onGameSetup(){}onGameStart(){}onGameMounted(){}onGameDismounted(){}}function fCe(e){bn.addPlugin(e)}function dCe(e){bn.addCommand(e)}ut.CommandPlugin=Ue,ut.ConfigInputSchema=ZB,ut.InputsListener=_V,ut.LogManager=T0,ut.ModalWindow=al,ut.NarratPlugin=uCe,ut.addCommand=dCe,ut.aspectRatioFit=QB,ut.audioConfig=$s,ut.buttonsConfig=u_,ut.charactersConfig=f_,ut.error=Wt,ut.findVariable=e9,ut.gameloop=_0,ut.generateParser=mp,ut.getAssetUrl=oa,ut.getButtonConfig=Jf,ut.getConfig=wt,ut.getDataUrl=h_,ut.getFile=l2,ut.getImageUrl=hp,ut.getItemConfig=ol,ut.getObjectiveConfig=y0,ut.getQuestConfig=ou,ut.getScreenConfig=dp,ut.getSkillConfig=d_,ut.getSplitConfigUrl=rV,ut.getWindow=qx,ut.inputEvents=Va,ut.itemsConfig=g0,ut.loadDataFile=Jg,ut.logManager=E0,ut.logger=ki,ut.processText=Zs,ut.questsConfig=up,ut.randomId=Pf,ut.registerComponent=cCe,ut.registerMenuButton=$V,ut.registerPlugin=fCe,ut.screensConfig=c_,ut.skillsConfig=rl,ut.startApp=lCe,ut.timeout=ea,ut.tooltipsConfig=fp,ut.useAchievements=Yl,ut.useAudio=yo,ut.useConfig=pi,ut.useDialogStore=qn,ut.useHud=_s,ut.useInputs=zo,ut.useInventory=lo,ut.useMain=Zt,ut.useMenu=gi,ut.useNotifications=vi,ut.useQuests=Fo,ut.useRenderingStore=Pi,ut.useScreenObjects=ei,ut.useScreens=Ia,ut.useSkills=Dr,ut.useTooltips=Bg,ut.useVM=an,ut.warning=Kh,Object.defineProperty(ut,Symbol.toStringTag,{value:"Module"})});
221
221
  //# sourceMappingURL=narrat.umd.js.map