narrat 2.6.0 → 2.6.1
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.
- package/dist/narrat.es.js +6 -5
- package/dist/narrat.es.js.map +1 -1
- package/dist/narrat.umd.js +3 -3
- package/dist/narrat.umd.js.map +1 -1
- package/package.json +1 -1
package/dist/narrat.umd.js
CHANGED
|
@@ -175,10 +175,10 @@ Only state can be modified.`);a[0]="$state",Hu=!1,r.set(o,a,r.state.value),Hu=!0
|
|
|
175
175
|
Found in store "${$.$id}".`),p&&o&&n.hydrate&&n.hydrate($.$state,p),l=!0,f=!0,$}function Ci(t,e,n){let r,i;const o=typeof e=="function";typeof t=="string"?(r=t,i=o?n:e):(i=t,r=t.id);function a(s,u){const l=b.getCurrentInstance();if(s=(process.env.NODE_ENV==="test"&&Ac&&Ac._testing?null:s)||l&&b.inject(Z8),s&&Ec(s),process.env.NODE_ENV!=="production"&&!Ac)throw new Error(`[\u{1F34D}]: getActivePinia was called with no active Pinia. Did you forget to install pinia?
|
|
176
176
|
const pinia = createPinia()
|
|
177
177
|
app.use(pinia)
|
|
178
|
-
This will fail in production.`);s=Ac,s._s.has(r)||(o?jy(r,e,i,s):h7(r,i,s),process.env.NODE_ENV!=="production"&&(a._pinia=s));const f=s._s.get(r);if(process.env.NODE_ENV!=="production"&&u){const c="__hot:"+r,d=o?jy(c,e,i,s,!0):h7(c,ho({},i),s,!0);u._hotUpdate(d),delete s.state.value[c],s._s.delete(c)}if(process.env.NODE_ENV!=="production"&&Ua&&l&&l.proxy&&!u){const c=l.proxy,d="_pStores"in c?c._pStores:c._pStores={};d[r]=f}return f}return a.$id=r,a}function da(t,e){return Array.isArray(e)?e.reduce((n,r)=>(n[r]=function(){return t(this.$pinia)[r]},n),{}):Object.keys(e).reduce((n,r)=>(n[r]=function(){const i=t(this.$pinia),o=e[r];return typeof o=="function"?o.call(this,i):i[o]},n),{})}const p7=["music","ambiant","sound"],v7=rK(p7),Cr=Ci("audio",{state:()=>{const t=new Map;for(const e in v7)t.set(e,{channels:[],options:{volume:1}});return{modes:t,masterVolume:1}},actions:{stopAll(){this.modes.forEach(t=>{t.channels.forEach((e,n)=>{e&&(this.actuallyStopChannel(e),t.channels[n]=null)})})},async stopChannel(t,e){const n=this.getAudioChannel(t,e);if(!!n){if(this.setAudioChannel(t,e,null),lt().audioOptions.musicFadeOutTime){const r=Uu(n.audio);r&&r.fade(r.volume(n.howlerId),0,lt().audioOptions.musicFadeOutTime*1e3,n.howlerId),await co(lt().audioOptions.musicFadeOutTime*1e3)}this.actuallyStopChannel(n)}},async pauseChannel(t,e){const n=this.getAudioChannel(t,e);if(!n)return;const r=Uu(n.audio);if(!r){bn(`Could not find audio ${n.audio}`);return}r.pause(n.howlerId)},async playChannel(t,e,n){const r=this.getAudioChannel(t,n);if(t==="sound")return this.actuallyPlayChannel(t,n,e);r&&r.audio!==e?await this.changeChannel(t,e,n):r&&r.audio===e||await this.actuallyPlayChannel(t,n,e)},async changeChannel(t,e,n){this.getAudioChannel(t,n)&&t!=="sound"&&await this.stopChannel(t,n),await this.actuallyPlayChannel(t,n,e)},actuallyStopChannel(t){IK(t.audio,t.howlerId)},getAudioChannel(t,e){return this.modes.get(t).channels[e]||null},setAudioChannel(t,e,n){this.modes.get(t).channels[e]=n},async actuallyPlayChannel(t,e,n){const r=Uu(n);if(!r){bn(`Could not find audio ${n}`);return}if(t!=="sound"){const i=r.play();r.volume(0,i),r.pause(i),this.setAudioChannel(t,e,{audio:n,howlerId:i}),await co(lt().audioOptions.musicFadeInDelay*1e3);const o=this.getAudioChannel(t,e);o!==null&&o.audio===n&&(r.play(i),r.fade(0,this.modeVolume(t),lt().audioOptions.musicFadeInTime*1e3,i))}else if(t==="sound"){const i=r.play();r.volume(this.modeVolume(t),i),this.setAudioChannel(t,e,{audio:n,howlerId:i})}},reloadAudio(t){for(const e in t.modes){if(e==="sound")continue;const n=e;this.modes.get(n).options=t.modes[n].options;for(const r in t.modes[n].channels){const i=t.modes[n].channels[r];i&&this.actuallyPlayChannel(n,Number(r),i.audio)}}},stopSound(t){const e=Uu(t);e&&e.stop()},generateSaveData(){const t={};for(const e in v7){const n=this.modes.get(e);t[e]={options:fi(n.options),channels:fi(n.channels).map(r=>r?{audio:r.audio}:null)}}return{modes:t,masterVolume:this.masterVolume}},loadSaveData(t){this.masterVolume=t.masterVolume},reset(){this.stopAll()},setModeVolume(t,e){const n=this.modes.get(t);n.options.volume=e;for(const r in n.channels){const i=n.channels[r];if(i){const o=Uu(i.audio);o&&o.volume(this.modeVolume(t),i.howlerId)}}},setMasterVolume(t){this.masterVolume=t,Wa.Howler.volume(t)},modeVolume(t){return this.masterVolume*this.modes.get(t).options.volume}}}),m7={};Wa.Howler.volume(.5);let _y={};async function MK(t){bo.log("Loading audio");const e=[];Wa.Howler.volume(t.audioOptions.volume);for(const n in t.music){const r={loop:!0,...t.music[n]};t.audio[n]=r,console.warn("Music config is deprecated, instead you can now add musics to the `audio` config as they behave the same as other sounds!")}for(const n in t.sound)t.audio[n]=t.sound[n];for(const n in t.audio){const r=t.audio[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!")),e.push(TK(n,t.audio[n]))}return t.audioTriggers&&(_y=t.audioTriggers),Promise.all(e)}function Bs(t){_y[t]&&Cr().playChannel("sound",_y[t],0)}async function TK(t,e){return new Promise((n,r)=>{bo.log(`Loading audio ${e.src}`);const i=new Wa.Howl({...e,src:Qa(e.src)});i.load(),m7[t]=i,n()})}function IK(t,e){const n=Uu(t);if(!n){bn(`Could not find music ${t}`);return}n.stop(e)}function Uu(t){return m7[t]}let Sy;function NK(t){Sy=t}function Cy(t){return Sy.characters[t]}function PK(t,e){const n=Cy(t);if(e||(e="default"),n.sprites)return`${Sy.config.imagesPath}${n.sprites[e]}`}function Gh(t){return t?Cy(t).style||{}:{}}const Ju={};async function LK(t){return Ju[t]?Ju[t]:g7(t,t)}async function DK(t){bo.log("Loading images");let e=0,n=0;const r=[],i=async(a,s)=>{n++;const u=await g7(a,s);return e++,console.log(`Loaded ${e} / ${n} images`),u},o=(a,s)=>{r.push(i(a,s))};for(const a in t.images){const s=t.images[a];o(a,s)}for(const a in t.screens){const s=t.screens[a];if(s.background&&!t.images[s.background]&&o(s.background,s.background),s.buttons)for(const u in s.buttons){const l=s.buttons[u];typeof l=="object"&&l.background&&!t.images[l.background]&&o(l.background,l.background)}}return Promise.all(r)}async function g7(t,e){if(Ju[t])return Ju[t];const n=new Promise((r,i)=>{bo.log(`Loading image ${t} at ${e}`);const o=new Image;o.onload=()=>{Ju[t]=o,bo.log(`Loaded image ${t} successfully`),r(o)},o.onerror=a=>{bn(`Failed to load image ${t} at ${e}`,a),i(a)},o.src=Qa(e)});return Ju[t]=n,n}function Oc(){return`${Date.now()}-${Math.floor(Math.random()*1e11)}-${Math.floor(Math.random()*1e11)}`}const y7="gameSave",Kh="###_--_~=:;_JUMP",$y="###_--_~=:;_RETURN",RK="###_--_~=:;_OK",Qh="###_--_~=:;_STOP";function BK(t){return t===Kh||t===$y||t===RK||t===Qh}const zK="2.6.0",FK=new Date("2022-08-09T18:06:15.795Z"),b7=(t,e)=>{const n={};for(const r in t)e(t[r])&&(n[r]=t[r]);return n},k7="1.4.0";let br;function w7(){if(br)return br;if(!br){let t=null;try{const e=localStorage.getItem(y7);e&&(t=JSON.parse(e)),t&&typeof t=="object"&&t.slots&&t.slots[0]&&t.slots[0].id||(t=null,localStorage.clear())}catch(e){Iy(`Save file deleted because it was either broken or an outdated format: ${e}`)}t?br=t:br=qK()}return VK(br),x7(br),Yh(),br}function VK(t){t.version}function qK(){const t={version:k7,slots:[]};return x7(t),t}function x7(t){var n;const e=(n=lt().saves.slots)!=null?n:10;t.slots.length<1&&(t.slots[0]={slotType:"auto",id:Oc(),saveData:null,slotNumber:0}),t.slots[0].slotType="auto";for(let r=1;r<e+1;r++)t.slots.length<=r&&(t.slots[r]={slotNumber:r,slotType:lt().saves.mode==="manual"?"manual":"auto",id:Oc(),saveData:null})}function j7(t,e){const n=UK(e);if(br.slots[n])br.slots[n].saveData=t;else{bn(`Tried to save to slot ${e} but it doesn't exist`);return}Yh()}function HK(t){br.lastSaveSlot=t}function Yh(){localStorage.setItem(y7,JSON.stringify(br))}function WK(){const t=br.slots.find(e=>!e.saveData);return t?t.id:!1}function UK(t){return br.slots.findIndex(e=>e.id===t)}function Mc(t){return br.slots.find(e=>e.id===t)}function Ay(){return br.slots.find(t=>t.slotType==="auto")}function JK(t){const e=br.slots.findIndex(n=>n.id===t);br.slots[e].saveData=null,Yh()}function GK(t,e){const n=Mc(t);n&&n.saveData&&(n.saveData.metadata.name=e),Yh()}function KK(){return{saveDate:new Date().toISOString(),name:"New Save"}}function Xh(t){return t.replace(/%{[^}]*}/g,e=>{const n=e.substr(2,e.length-3),r=tl(),[i,o]=Ky(r,n);return i[o]})}const _7=/\$\$"/,QK=t=>typeof t=="string"&&t.search(_7)===0,ti=Ci("dialog",{state:()=>({dialog:[]}),actions:{generateSaveData(){return{dialog:fi(this.dialog)}},loadSaveData(t){this.dialog=t.dialog},addDialog(t){var e;this.dialog.push({...t,interactive:(e=t.interactive)!=null?e:!1,id:Oc(),text:Xh(t.text)}),this.dialog.length>200&&this.dialog.shift()},clearDialog(){this.dialog.splice(0,this.dialog.length)},reset(){this.dialog=[]}},getters:{currentDialog(){return this.dialog[this.dialog.length-1]}}});function YK(t,e){return t-e*lt().skillChecks.skillMultiplier}function S7(t,e){const n=YK(t,e),r=lt().skillChecks;let i=!1,o=0,a=r.difficultyText[0][1];for(;!i;)r.difficultyText.length>o&&n>=r.difficultyText[o][0]?a=r.difficultyText[o][1]:i=!0,o++;return a}function XK({skill:t,skillCheckId:e,value:n}){const r=hr(),i=r.getSkillCheck(e),o=WI(t),a=r.skills[t].level,s=S7(n,a);let u=!0,l=`<span class='skill-check'>[<span class='skill-check-name'>${o.name}</span> - `;return i.happened?i.succeeded?l="":(u=!1,l+=` <span class='skill-check-difficulty'>${s}</span> - <span class='skill-check-failed'>FAILED</span>]</span>`):l+=` <span class='skill-check-difficulty'>${s}</span>]</span>`,{difficultyText:l,allowed:u}}function ZK(t,e){const n=hr(),r=WI(e.skill),i=S7(e.value,n.skills[e.skill].level);return`<span class='passive-skill-check skill-check'>[<span class='skill-check-name'>${r.name}</span> - <span class='skill-check-difficulty'>${i}</span> - ${t?'<span class="skill-check-success">Success</span>':'<span class="skill-check-failed">Failure</span>'}]</span>`}function eQ(t){const{skillChecks:e}=lt(),n=hr(),r=Math.floor(Math.random()*e.rollRange),i=n.skills[t].level*e.skillMultiplier,o=r+i;return bo.log(`[SKILL CHECK] Roll: ${o}. (Base roll: ${r}, modifier: ${i} - Skill level: ${n.skills[t].level})`),{roll:o,unmodifiedRoll:r}}function tQ(t){const{skills:e,skillChecks:n}=lt();let r=!0;const{roll:i}=eQ(t.skill);i<=n.failureChance-1&&(r=!1);const o=e[t.skill];return i<t.value&&(r=!1),bo.log(`[SKILL CHECK ${o.name}]: ${r?"\u2705":"\u274C"}`,`(${t.id}) - ${i}/${t.value}`),Bs(r?"onSkillCheckSuccess":"onSkillCheckFailure"),r}function C7(t){const e=hr(),n=e.getSkillCheck(t.id);if(n&&n.happened)return n;const r=tQ(t);return E7(ZK(r,t)),r?e.passSkillCheck(t.id,t.hideAfterRoll):e.failSkillCheck(t.id,t.hideAfterRoll),e.getSkillCheck(t.id)}function nQ(t){const e=t.options,n=t.staticOptions,r=!!e.condition;if(bo.log(r),r)return n.success;if(!r&&n.failure)return n.failure}function $7(t){return typeof t=="object"}function A7(t){return typeof t=="string"&&t.search(/\$/)===0}function E7(t){const e={speaker:"game",text:t,interactive:!1};ti().addDialog(e)}async function Ey(t){ti().addDialog(t)}function rQ(t,e){if(e<t.length)return t[e]}const O7=new d1;O7.setupDebugger(!1);const Ui=O7.logger;function iQ(t,e,n){const r={fileName:n,currentLine:0,error:(a,s)=>t(r,a,s),processCommandsFunction:Oy,indentSize:0};r.indentSize=hQ(r,e);const i=cQ(r,e);r.currentLine=0,Ui.log(i);const o={};for(const a of i){a.code.search(":")===-1&&r.error(a.line,"First indentation level should only be used to specify labels");const u=a.code.replace(":","").split(/ +/g),l=u[0],f=u.slice(1);a.branch||r.error(a.line,"This line should have a branch but doesn't"),o[l]={branch:Oy(r,a.branch,void 0),args:f}}return o}function Oy(t,e,n){const r=t.currentLine,i={processCommandsFunction:Oy,parserContext:t,lines:e,currentLine:0,line:e[0]},o=[];if(!e){let a=0;return n&&(a=n.line),t.error(a,"Processing of command failed because the current branch has no lines inside"),[]}for(;i.currentLine<e.length;){const a=e[i.currentLine];i.line=a;const s=M7(t,a,a.expression),u=qn.commands[s.command.operator];let l=u==null?void 0:u.parser;l||(l=qn.commands.text.parser),Ui.log(qn.commands.text);const{newLine:f}=l(i,s);i.currentLine=f,t.currentLine=r+f,o.push(s)}return o}function M7(t,e,n){Ui.log(n),typeof n[0]!="string"&&t.error(e.line,"Expression operator should be a string");const r={code:e.code,fileName:t.fileName,line:e.line,command:{staticOptions:{},commandType:n[0],operator:n[0],args:n.slice(1).map(a=>oQ(t,e,a)),options:{}}},i=n[0];if(!qn.commands[i]){const a=["else","success","failure"];!QK(i)&&!a.includes(i)&&t.error(e.line,`Unknown command ${i}`)}return r}function oQ(t,e,n){return Array.isArray(n)?M7(t,e,n):n}function aQ(t){return t==="true"?!0:t==="false"?!1:t==="undefined"?void 0:t===null?null:isNaN(Number(t))?t:Number(t)}function sQ(t,e){e.charAt(e.length-1)===":"&&(e=e.substr(0,e.length-1));const n=uQ(e),[r]=I7(t,n);return r}function uQ(t){const e=/(["'])(?:\\\1|.)*?\1/g,n=[];let r;for(;(r=e.exec(t))!=null;)n.push(r);let i=0,o=[];for(const a of n){const s=a.index;if(s>i){const l=t.substr(i,s-i),f=T7(l);o=[...o,...f]}const u=a[0].replace(/\\/g,"");o.push(`$$"${u.substring(1,u.length-1)}`),i=s+a[0].length}return o=[...o,...T7(t.substr(i))],o.push(")"),o}function T7(t){t=t.replace(/: *$/g,"");let e=t.split(" ").filter(n=>n);return e=e.reduce((n,r)=>[...n,...r.split(/(\(|\))/g)].filter(i=>i&&i),[]),e.map(n=>aQ(n))}function I7(t,e){Ui.log("===============");let n=[],r=0,i=N7(e)+r,o=My(e)+r;for(Ui.log(`Parsing expression: ${e}`),Ui.log(`Parenthesis start index: ${i} - end: ${o}`);i!==-1&&o>i;){n=[...n,...e.slice(r,i)];const u=e.slice(i+1);Ui.log(`Found a sub expression. Before: ${n} - After: ${u}`),r=i;const[l,f]=I7(t,u),c=r+f;n.push(l),r=c+1;const d=e.slice(r);Ui.log(`Sub expression came back: ${l} - rest of string: ${d}`),i=N7(d),i!==-1&&(i+=r),o=My(d),o!==-1&&(o+=r)}o!==-1&&Ui.log("Found parenthesis end before new opening parenthesis, close this expression");const a=My(e.slice(r))+r;if(a===-1)return t.error(t.currentLine,'Expression is not closed (missing ")" closing parenthesis)'),[n,a];const s=e.slice(r,a);return Ui.log(`End of expression: ${a} - ${s}`),Ui.log("==================="),n=[...n,...s],lQ(t,n),[n,a+1]}function lQ(t,e){e.length<1&&t.error(t.currentLine,"Expression is empty")}function N7(t){return t.findIndex(e=>e==="(")}function My(t){return t.findIndex(e=>e===")")}function cQ(t,e){const n=e.split(/\r?\n|$/).map(i=>{const o=i.search(/ *\/\//g);return o!==-1?i.substr(0,o):i});return P7(t,n,0,0).lines}function P7(t,e,n,r){let i=!0,o=n;const a=[];for(;i&&!(o>=e.length);){let s=e[o];if(s.search(/^\s*$/)!==-1)o++;else{const u=dQ(t,s);if(s=s.substring(u*t.indentSize),fQ(t,u,o),u<r)i=!1;else if(u>r){(a.length===0||u-r!==1)&&t.error(o,"Wrong double indentation");const l=P7(t,e,o,u);a[a.length-1].branch=l.lines,o=l.endLine}else{const l=sQ(t,s),f={code:s,indentation:u,line:o,expression:l};a.push(f),o++,t.currentLine=o}}}return{lines:a,endLine:o}}function fQ(t,e,n){e%1!==0&&t.error(n,`Indentation level of ${e} incorrect. Expected indentation of ${t.indentSize} spaces for this file.`)}function dQ(t,e){return e.search(/[^ ]/)/t.indentSize}function hQ(t,e){const n=/\n( *)/,r=e.match(n);return!r||r.length<2?(t.error(0,"Can't detect indentation level. Make sure you indent with at least 2 spaces and consistently"),0):(Ui.log(r),r[1].length)}const ln=Ci("vm",{state:()=>({stack:[],data:{},lastLabel:"main",script:{},labelStack:["main"],commandsWaitingForPlayerAnswer:[],hasJumped:!1}),actions:{generateSaveData(){return{lastLabel:this.lastLabel,data:this.data}},loadSaveData(t){this.lastLabel=t.lastLabel,this.data=t.data},setReturnValue(t){this.currentFrame.returnValue=t},waitForPlayerAnswer(t){this.commandsWaitingForPlayerAnswer.push(t)},popAnswerQueue(){return this.commandsWaitingForPlayerAnswer.pop()},addScopedVariable(t,e){this.currentFrame&&(this.currentFrame.scope[t]=e)},async loadScripts(t){const e=[];for(const a of t)e.push(HI(Ya(a)));const n=await Promise.all(e),r=Date.now();let i={};for(const a in n){const s=n[a];i={...i,...iQ((u,l,f)=>IQ(u,l,f),s,t[a])}}const o=Date.now();bo.log(`script parsed in ${o-r} ms`),this.setScript(i)},start(){this.setStack({currentIndex:0,branchData:{branch:this.script.main.branch},label:"main"}),this.setStack({currentIndex:0,branchData:{branch:this.script.main.branch},label:"main"})},setLastLabel(t){this.lastLabel=t},reset(){this.stack=[],this.data={},this.hasJumped=!0,this.setStack({currentIndex:0,branchData:{branch:this.script.main.branch},label:"main"})},setScript(t){this.script=t},overrideData(t){this.data=t},setStack(t){this.stack=[];const e=this.frameOptionsToFrame(t);this.lastLabel=t.label,this.stack.push(e)},frameOptionsToFrame(t){const e=t.branchData,n={...t,blocks:[],scope:{},returnValue:null};if(this.addBlock(n,{branchData:e,currentIndex:t.currentIndex}),t.scope&&(n.scope=t.scope),t.args&&t.branchData.args)for(const[r,i]of t.branchData.args.entries())t.args.length>r&&(n.scope[i]=t.args[r]);return n},addBlock(t,e){t.blocks.push(e)},async addAndRunBlock(t){const e=this.currentFrame;if(!e)throw new Error("No frame to add block to");return this.addBlock(e,t),await this.runBlock()},setData(t,e){const n=tl();JI(n,t,e)},addInstruction(t,e){const n=tl();GI(n,t,e)},addFrame(t){if(!t.label)if(this.currentFrame)t.label=this.currentFrame.label;else throw new Error("Tried to add a new frame but no label was passed and there is no current frame label");const e=this.frameOptionsToFrame(t);this.stack.push(e)},async addAndRunFrame(t){return await this.addFrame(t),await this.runFrame()},async runFrame(){if(!this.currentFrame)throw new Error("Tried to run a frame but there is no current frame");let e;for(;this.currentBlock;){const n=await this.runBlock();if(n===Kh||n===Qh)return this.cleanFrame(),n;if(n===$y)return this.cleanFrame()}return this.cleanFrame(),e},cleanFrame(){const t=this.currentFrame,{returnValue:e}=t;return this.stack.splice(this.stack.length-1,1),e},async runBlock(){const t=this.currentBlock;if(!t)throw new Error("Tried to run a block but there is no current block");let e;for(;this.currentLine;){if(e=await this.runLineOnly(),BK(e))return this.cleanBlock(),e;t.currentIndex++}return this.cleanBlock(),e},cleanBlock(){this.currentFrame.blocks.splice(this.currentFrame.blocks.length-1,1)},async runGame(){let t=await this.runFrame();for(;t===Kh;){const e=this.jumpTarget;if(!e){bn("Tried to jump but no target was set");return}this.hasJumped=!0,this.setStack(e),await Ft().autoSaveGame({}),t=await this.runFrame()}t!==Qh&&this.stack.length===0&&this.reachedEndOfScript()},async nextLineOnly(){return this.stack.length===0||this.isBlockFinished()?!1:(this.currentBlock.currentIndex++,!0)},isBlockFinished(){return!this.currentBlock||this.currentBlock&&this.currentBlock.currentIndex>=this.currentBlock.branchData.branch.length},reachedEndOfScript(){if(lt().gameFlow.labelToJumpOnScriptEnd&&this.lastLabel!==lt().gameFlow.labelToJumpOnScriptEnd){this.jumpToLabel(lt().gameFlow.labelToJumpOnScriptEnd);return}if(Ft().endingScript(),Ft().options.debug){const e=ti();lt().debugging.showScriptFinishedMessage&&e.addDialog({speaker:"game",text:"[DEBUG] Game Script is finished. This is the end of the game flow. This message only appears in debug mode."})}},async runLineOnly(){const t=this.currentLine;if(!t){bn("There is no line of script to run.");return}return Ft().startingScript(),await L7(t)},async runLabelFunction(t,...e){const n=this.script[t];if(!n){bn(`Tried to run a label that doesn't exist: ${t}`);return}const r={currentIndex:0,branchData:n,label:t,args:e};return this.addAndRunFrame(r)},runCustomFrame(t){this.addAndRunFrame(t)},async jumpToLabel(t,...e){const n=this.script[t];if(!n){bn(`Label ${t} doesn't exist. Is the file with this label added in the list of script files to load in the config?`);return}t!==this.lastLabel&&(this.hasJumped=!0),this.setLastLabel(t),this.setStack({currentIndex:0,branchData:n,args:e,label:t}),await Ft().autoSaveGame({}),this.runGame()},async runThenGoBackToPreviousDialog(t,...e){const n=ti(),r=n.dialog[n.dialog.length-1],i=await this.runLabelFunction(t,...e);return n.dialog.push(r),i}},getters:{currentFrame(t){return t.stack[t.stack.length-1]},scope(){var t,e;return(e=(t=this.currentFrame)==null?void 0:t.scope)!=null?e:{}},currentBlock(){const t=this.currentFrame;return t?t.blocks[t.blocks.length-1]:void 0},currentLine(){const t=this.currentBlock;if(t&&t.branchData.branch.length>t.currentIndex)return t.branchData.branch[t.currentIndex]},commandWaitingForAnswer(){if(this.commandsWaitingForPlayerAnswer.length>0)return this.commandsWaitingForPlayerAnswer[0]}}});class pQ{constructor(){Mi(this,"plugins",[]);Mi(this,"pinia");Mi(this,"commands",{})}addCommand(e){this.commands[e.keyword]=e}addPlugin(e){if(this.plugins.push(e),e.customCommands)for(const n of e.customCommands)this.addCommand(n)}callHook(e,...n){for(const r of this.plugins)typeof r[e]=="function"&&r[e](...n)}customStores(){const e=[];for(const n of this.plugins)if(n.customStores)for(const r in n.customStores)e.push([r,n.customStores[r](this.pinia)]);return e}}const qn=new pQ;async function L7(t,e){var r;const n=ln();try{return await Ty(t,e)}catch(i){console.error(i),console.error(t),bn(`Narrat script runtime error at <span class="error-filename">${t.fileName}:${t.line+1}</span>
|
|
178
|
+
This will fail in production.`);s=Ac,s._s.has(r)||(o?jy(r,e,i,s):h7(r,i,s),process.env.NODE_ENV!=="production"&&(a._pinia=s));const f=s._s.get(r);if(process.env.NODE_ENV!=="production"&&u){const c="__hot:"+r,d=o?jy(c,e,i,s,!0):h7(c,ho({},i),s,!0);u._hotUpdate(d),delete s.state.value[c],s._s.delete(c)}if(process.env.NODE_ENV!=="production"&&Ua&&l&&l.proxy&&!u){const c=l.proxy,d="_pStores"in c?c._pStores:c._pStores={};d[r]=f}return f}return a.$id=r,a}function da(t,e){return Array.isArray(e)?e.reduce((n,r)=>(n[r]=function(){return t(this.$pinia)[r]},n),{}):Object.keys(e).reduce((n,r)=>(n[r]=function(){const i=t(this.$pinia),o=e[r];return typeof o=="function"?o.call(this,i):i[o]},n),{})}const p7=["music","ambiant","sound"],v7=rK(p7),Cr=Ci("audio",{state:()=>{const t=new Map;for(const e in v7)t.set(e,{channels:[],options:{volume:1}});return{modes:t,masterVolume:1}},actions:{stopAll(){this.modes.forEach(t=>{t.channels.forEach((e,n)=>{e&&(this.actuallyStopChannel(e),t.channels[n]=null)})})},async stopChannel(t,e){const n=this.getAudioChannel(t,e);if(!!n){if(this.setAudioChannel(t,e,null),lt().audioOptions.musicFadeOutTime){const r=Uu(n.audio);r&&r.fade(r.volume(n.howlerId),0,lt().audioOptions.musicFadeOutTime*1e3,n.howlerId),await co(lt().audioOptions.musicFadeOutTime*1e3)}this.actuallyStopChannel(n)}},async pauseChannel(t,e){const n=this.getAudioChannel(t,e);if(!n)return;const r=Uu(n.audio);if(!r){bn(`Could not find audio ${n.audio}`);return}r.pause(n.howlerId)},async playChannel(t,e,n){const r=this.getAudioChannel(t,n);if(t==="sound")return this.actuallyPlayChannel(t,n,e);r&&r.audio!==e?await this.changeChannel(t,e,n):r&&r.audio===e||await this.actuallyPlayChannel(t,n,e)},async changeChannel(t,e,n){this.getAudioChannel(t,n)&&t!=="sound"&&await this.stopChannel(t,n),await this.actuallyPlayChannel(t,n,e)},actuallyStopChannel(t){IK(t.audio,t.howlerId)},getAudioChannel(t,e){return this.modes.get(t).channels[e]||null},setAudioChannel(t,e,n){this.modes.get(t).channels[e]=n},async actuallyPlayChannel(t,e,n){const r=Uu(n);if(!r){bn(`Could not find audio ${n}`);return}if(t!=="sound"){const i=r.play();r.volume(0,i),r.pause(i),this.setAudioChannel(t,e,{audio:n,howlerId:i}),await co(lt().audioOptions.musicFadeInDelay*1e3);const o=this.getAudioChannel(t,e);o!==null&&o.audio===n&&(r.play(i),r.fade(0,this.modeVolume(t),lt().audioOptions.musicFadeInTime*1e3,i))}else if(t==="sound"){const i=r.play();r.volume(this.modeVolume(t),i),this.setAudioChannel(t,e,{audio:n,howlerId:i})}},reloadAudio(t){for(const e in t.modes){if(e==="sound")continue;const n=e;this.modes.get(n).options=t.modes[n].options;for(const r in t.modes[n].channels){const i=t.modes[n].channels[r];i&&this.actuallyPlayChannel(n,Number(r),i.audio)}}},stopSound(t){const e=Uu(t);e&&e.stop()},generateSaveData(){const t={};for(const e in v7){const n=this.modes.get(e);t[e]={options:fi(n.options),channels:fi(n.channels).map(r=>r?{audio:r.audio}:null)}}return{modes:t,masterVolume:this.masterVolume}},loadSaveData(t){this.masterVolume=t.masterVolume},reset(){this.stopAll()},setModeVolume(t,e){const n=this.modes.get(t);n.options.volume=e;for(const r in n.channels){const i=n.channels[r];if(i){const o=Uu(i.audio);o&&o.volume(this.modeVolume(t),i.howlerId)}}},setMasterVolume(t){this.masterVolume=t,Wa.Howler.volume(t)},modeVolume(t){return this.masterVolume*this.modes.get(t).options.volume}}}),m7={};Wa.Howler.volume(.5);let _y={};async function MK(t){bo.log("Loading audio");const e=[];Wa.Howler.volume(t.audioOptions.volume);for(const n in t.music){const r={loop:!0,...t.music[n]};t.audio[n]=r,console.warn("Music config is deprecated, instead you can now add musics to the `audio` config as they behave the same as other sounds!")}for(const n in t.sound)t.audio[n]=t.sound[n];for(const n in t.audio){const r=t.audio[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!")),e.push(TK(n,t.audio[n]))}return t.audioTriggers&&(_y=t.audioTriggers),Promise.all(e)}function Bs(t){_y[t]&&Cr().playChannel("sound",_y[t],0)}async function TK(t,e){return new Promise((n,r)=>{bo.log(`Loading audio ${e.src}`);const i=new Wa.Howl({...e,src:Qa(e.src)});i.load(),m7[t]=i,n()})}function IK(t,e){const n=Uu(t);if(!n){bn(`Could not find music ${t}`);return}n.stop(e)}function Uu(t){return m7[t]}let Sy;function NK(t){Sy=t}function Cy(t){return Sy.characters[t]}function PK(t,e){const n=Cy(t);if(e||(e="default"),n.sprites)return`${Sy.config.imagesPath}${n.sprites[e]}`}function Gh(t){return t?Cy(t).style||{}:{}}const Ju={};async function LK(t){return Ju[t]?Ju[t]:g7(t,t)}async function DK(t){bo.log("Loading images");let e=0,n=0;const r=[],i=async(a,s)=>{n++;const u=await g7(a,s);return e++,console.log(`Loaded ${e} / ${n} images`),u},o=(a,s)=>{r.push(i(a,s))};for(const a in t.images){const s=t.images[a];o(a,s)}for(const a in t.screens){const s=t.screens[a];if(s.background&&!t.images[s.background]&&o(s.background,s.background),s.buttons)for(const u in s.buttons){const l=s.buttons[u];typeof l=="object"&&l.background&&!t.images[l.background]&&o(l.background,l.background)}}return Promise.all(r)}async function g7(t,e){if(Ju[t])return Ju[t];const n=new Promise((r,i)=>{bo.log(`Loading image ${t} at ${e}`);const o=new Image;o.onload=()=>{Ju[t]=o,bo.log(`Loaded image ${t} successfully`),r(o)},o.onerror=a=>{bn(`Failed to load image ${t} at ${e}`,a),i(a)},o.src=Qa(e)});return Ju[t]=n,n}function Oc(){return`${Date.now()}-${Math.floor(Math.random()*1e11)}-${Math.floor(Math.random()*1e11)}`}const y7="gameSave",Kh="###_--_~=:;_JUMP",$y="###_--_~=:;_RETURN",RK="###_--_~=:;_OK",Qh="###_--_~=:;_STOP";function BK(t){return t===Kh||t===$y||t===RK||t===Qh}const zK="2.6.1",FK=new Date("2022-08-09T18:14:43.504Z"),b7=(t,e)=>{const n={};for(const r in t)e(t[r])&&(n[r]=t[r]);return n},k7="1.4.0";let br;function w7(){if(br)return br;if(!br){let t=null;try{const e=localStorage.getItem(y7);e&&(t=JSON.parse(e)),t&&typeof t=="object"&&t.slots&&t.slots[0]&&t.slots[0].id||(t=null,localStorage.clear())}catch(e){Iy(`Save file deleted because it was either broken or an outdated format: ${e}`)}t?br=t:br=qK()}return VK(br),x7(br),Yh(),br}function VK(t){t.version}function qK(){const t={version:k7,slots:[]};return x7(t),t}function x7(t){var n;const e=(n=lt().saves.slots)!=null?n:10;t.slots.length<1&&(t.slots[0]={slotType:"auto",id:Oc(),saveData:null,slotNumber:0}),t.slots[0].slotType="auto";for(let r=1;r<e+1;r++)t.slots.length<=r&&(t.slots[r]={slotNumber:r,slotType:lt().saves.mode==="manual"?"manual":"auto",id:Oc(),saveData:null})}function j7(t,e){const n=UK(e);if(br.slots[n])br.slots[n].saveData=t;else{bn(`Tried to save to slot ${e} but it doesn't exist`);return}Yh()}function HK(t){br.lastSaveSlot=t}function Yh(){localStorage.setItem(y7,JSON.stringify(br))}function WK(){const t=br.slots.find(e=>!e.saveData);return t?t.id:!1}function UK(t){return br.slots.findIndex(e=>e.id===t)}function Mc(t){return br.slots.find(e=>e.id===t)}function Ay(){return br.slots.find(t=>t.slotType==="auto")}function JK(t){const e=br.slots.findIndex(n=>n.id===t);br.slots[e].saveData=null,Yh()}function GK(t,e){const n=Mc(t);n&&n.saveData&&(n.saveData.metadata.name=e),Yh()}function KK(){return{saveDate:new Date().toISOString(),name:"New Save"}}function Xh(t){return t.replace(/%{[^}]*}/g,e=>{const n=e.substr(2,e.length-3),r=tl(),[i,o]=Ky(r,n);return i[o]})}const _7=/\$\$"/,QK=t=>typeof t=="string"&&t.search(_7)===0,ti=Ci("dialog",{state:()=>({dialog:[]}),actions:{generateSaveData(){return{dialog:fi(this.dialog)}},loadSaveData(t){this.dialog=t.dialog},addDialog(t){var e;this.dialog.push({...t,interactive:(e=t.interactive)!=null?e:!1,id:Oc(),text:Xh(t.text)}),this.dialog.length>200&&this.dialog.shift()},clearDialog(){this.dialog.splice(0,this.dialog.length)},reset(){this.dialog=[]}},getters:{currentDialog(){return this.dialog[this.dialog.length-1]}}});function YK(t,e){return t-e*lt().skillChecks.skillMultiplier}function S7(t,e){const n=YK(t,e),r=lt().skillChecks;let i=!1,o=0,a=r.difficultyText[0][1];for(;!i;)r.difficultyText.length>o&&n>=r.difficultyText[o][0]?a=r.difficultyText[o][1]:i=!0,o++;return a}function XK({skill:t,skillCheckId:e,value:n}){const r=hr(),i=r.getSkillCheck(e),o=WI(t),a=r.skills[t].level,s=S7(n,a);let u=!0,l=`<span class='skill-check'>[<span class='skill-check-name'>${o.name}</span> - `;return i.happened?i.succeeded?l="":(u=!1,l+=` <span class='skill-check-difficulty'>${s}</span> - <span class='skill-check-failed'>FAILED</span>]</span>`):l+=` <span class='skill-check-difficulty'>${s}</span>]</span>`,{difficultyText:l,allowed:u}}function ZK(t,e){const n=hr(),r=WI(e.skill),i=S7(e.value,n.skills[e.skill].level);return`<span class='passive-skill-check skill-check'>[<span class='skill-check-name'>${r.name}</span> - <span class='skill-check-difficulty'>${i}</span> - ${t?'<span class="skill-check-success">Success</span>':'<span class="skill-check-failed">Failure</span>'}]</span>`}function eQ(t){const{skillChecks:e}=lt(),n=hr(),r=Math.floor(Math.random()*e.rollRange),i=n.skills[t].level*e.skillMultiplier,o=r+i;return bo.log(`[SKILL CHECK] Roll: ${o}. (Base roll: ${r}, modifier: ${i} - Skill level: ${n.skills[t].level})`),{roll:o,unmodifiedRoll:r}}function tQ(t){const{skills:e,skillChecks:n}=lt();let r=!0;const{roll:i}=eQ(t.skill);i<=n.failureChance-1&&(r=!1);const o=e[t.skill];return i<t.value&&(r=!1),bo.log(`[SKILL CHECK ${o.name}]: ${r?"\u2705":"\u274C"}`,`(${t.id}) - ${i}/${t.value}`),Bs(r?"onSkillCheckSuccess":"onSkillCheckFailure"),r}function C7(t){const e=hr(),n=e.getSkillCheck(t.id);if(n&&n.happened)return n;const r=tQ(t);return E7(ZK(r,t)),r?e.passSkillCheck(t.id,t.hideAfterRoll):e.failSkillCheck(t.id,t.hideAfterRoll),e.getSkillCheck(t.id)}function nQ(t){const e=t.options,n=t.staticOptions,r=!!e.condition;if(bo.log(r),r)return n.success;if(!r&&n.failure)return n.failure}function $7(t){return typeof t=="object"}function A7(t){return typeof t=="string"&&t.search(/\$/)===0}function E7(t){const e={speaker:"game",text:t,interactive:!1};ti().addDialog(e)}async function Ey(t){ti().addDialog(t)}function rQ(t,e){if(e<t.length)return t[e]}const O7=new d1;O7.setupDebugger(!1);const Ui=O7.logger;function iQ(t,e,n){const r={fileName:n,currentLine:0,error:(a,s)=>t(r,a,s),processCommandsFunction:Oy,indentSize:0};r.indentSize=hQ(r,e);const i=cQ(r,e);r.currentLine=0,Ui.log(i);const o={};for(const a of i){a.code.search(":")===-1&&r.error(a.line,"First indentation level should only be used to specify labels");const u=a.code.replace(":","").split(/ +/g),l=u[0],f=u.slice(1);a.branch||r.error(a.line,"This line should have a branch but doesn't"),o[l]={branch:Oy(r,a.branch,void 0),args:f}}return o}function Oy(t,e,n){const r=t.currentLine,i={processCommandsFunction:Oy,parserContext:t,lines:e,currentLine:0,line:e[0]},o=[];if(!e){let a=0;return n&&(a=n.line),t.error(a,"Processing of command failed because the current branch has no lines inside"),[]}for(;i.currentLine<e.length;){const a=e[i.currentLine];i.line=a;const s=M7(t,a,a.expression),u=qn.commands[s.command.operator];let l=u==null?void 0:u.parser;l||(l=qn.commands.text.parser),Ui.log(qn.commands.text);const{newLine:f}=l(i,s);i.currentLine=f,t.currentLine=r+f,o.push(s)}return o}function M7(t,e,n){Ui.log(n),typeof n[0]!="string"&&t.error(e.line,"Expression operator should be a string");const r={code:e.code,fileName:t.fileName,line:e.line,command:{staticOptions:{},commandType:n[0],operator:n[0],args:n.slice(1).map(a=>oQ(t,e,a)),options:{}}},i=n[0];if(!qn.commands[i]){const a=["else","success","failure"];!QK(i)&&!a.includes(i)&&t.error(e.line,`Unknown command ${i}`)}return r}function oQ(t,e,n){return Array.isArray(n)?M7(t,e,n):n}function aQ(t){return t==="true"?!0:t==="false"?!1:t==="undefined"?void 0:t===null?null:isNaN(Number(t))?t:Number(t)}function sQ(t,e){e.charAt(e.length-1)===":"&&(e=e.substr(0,e.length-1));const n=uQ(e),[r]=I7(t,n);return r}function uQ(t){const e=/(["'])(?:\\\1|.)*?\1/g,n=[];let r;for(;(r=e.exec(t))!=null;)n.push(r);let i=0,o=[];for(const a of n){const s=a.index;if(s>i){const l=t.substr(i,s-i),f=T7(l);o=[...o,...f]}const u=a[0].replace(/\\/g,"");o.push(`$$"${u.substring(1,u.length-1)}`),i=s+a[0].length}return o=[...o,...T7(t.substr(i))],o.push(")"),o}function T7(t){t=t.replace(/: *$/g,"");let e=t.split(" ").filter(n=>n);return e=e.reduce((n,r)=>[...n,...r.split(/(\(|\))/g)].filter(i=>i&&i),[]),e.map(n=>aQ(n))}function I7(t,e){Ui.log("===============");let n=[],r=0,i=N7(e)+r,o=My(e)+r;for(Ui.log(`Parsing expression: ${e}`),Ui.log(`Parenthesis start index: ${i} - end: ${o}`);i!==-1&&o>i;){n=[...n,...e.slice(r,i)];const u=e.slice(i+1);Ui.log(`Found a sub expression. Before: ${n} - After: ${u}`),r=i;const[l,f]=I7(t,u),c=r+f;n.push(l),r=c+1;const d=e.slice(r);Ui.log(`Sub expression came back: ${l} - rest of string: ${d}`),i=N7(d),i!==-1&&(i+=r),o=My(d),o!==-1&&(o+=r)}o!==-1&&Ui.log("Found parenthesis end before new opening parenthesis, close this expression");const a=My(e.slice(r))+r;if(a===-1)return t.error(t.currentLine,'Expression is not closed (missing ")" closing parenthesis)'),[n,a];const s=e.slice(r,a);return Ui.log(`End of expression: ${a} - ${s}`),Ui.log("==================="),n=[...n,...s],lQ(t,n),[n,a+1]}function lQ(t,e){e.length<1&&t.error(t.currentLine,"Expression is empty")}function N7(t){return t.findIndex(e=>e==="(")}function My(t){return t.findIndex(e=>e===")")}function cQ(t,e){const n=e.split(/\r?\n|$/).map(i=>{const o=i.search(/ *\/\//g);return o!==-1?i.substr(0,o):i});return P7(t,n,0,0).lines}function P7(t,e,n,r){let i=!0,o=n;const a=[];for(;i&&!(o>=e.length);){let s=e[o];if(s.search(/^\s*$/)!==-1)o++;else{const u=dQ(t,s);if(s=s.substring(u*t.indentSize),fQ(t,u,o),u<r)i=!1;else if(u>r){(a.length===0||u-r!==1)&&t.error(o,"Wrong double indentation");const l=P7(t,e,o,u);a[a.length-1].branch=l.lines,o=l.endLine}else{const l=sQ(t,s),f={code:s,indentation:u,line:o,expression:l};a.push(f),o++,t.currentLine=o}}}return{lines:a,endLine:o}}function fQ(t,e,n){e%1!==0&&t.error(n,`Indentation level of ${e} incorrect. Expected indentation of ${t.indentSize} spaces for this file.`)}function dQ(t,e){return e.search(/[^ ]/)/t.indentSize}function hQ(t,e){const n=/\n( *)/,r=e.match(n);return!r||r.length<2?(t.error(0,"Can't detect indentation level. Make sure you indent with at least 2 spaces and consistently"),0):(Ui.log(r),r[1].length)}const ln=Ci("vm",{state:()=>({stack:[],data:{},lastLabel:"main",script:{},labelStack:["main"],commandsWaitingForPlayerAnswer:[],hasJumped:!1}),actions:{generateSaveData(){return{lastLabel:this.lastLabel,data:this.data}},loadSaveData(t){this.lastLabel=t.lastLabel,this.data=t.data},setReturnValue(t){this.currentFrame.returnValue=t},waitForPlayerAnswer(t){this.commandsWaitingForPlayerAnswer.push(t)},popAnswerQueue(){return this.commandsWaitingForPlayerAnswer.pop()},addScopedVariable(t,e){this.currentFrame&&(this.currentFrame.scope[t]=e)},async loadScripts(t){const e=[];for(const a of t)e.push(HI(Ya(a)));const n=await Promise.all(e),r=Date.now();let i={};for(const a in n){const s=n[a];i={...i,...iQ((u,l,f)=>IQ(u,l,f),s,t[a])}}const o=Date.now();bo.log(`script parsed in ${o-r} ms`),this.setScript(i)},start(){this.setStack({currentIndex:0,branchData:{branch:this.script.main.branch},label:"main"}),this.setStack({currentIndex:0,branchData:{branch:this.script.main.branch},label:"main"})},setLastLabel(t){this.lastLabel=t},reset(){this.stack=[],this.data={},this.hasJumped=!0,this.setStack({currentIndex:0,branchData:{branch:this.script.main.branch},label:"main"})},setScript(t){this.script=t},overrideData(t){this.data=t},setStack(t){this.stack=[];const e=this.frameOptionsToFrame(t);this.lastLabel=t.label,this.stack.push(e)},frameOptionsToFrame(t){const e=t.branchData,n={...t,blocks:[],scope:{},returnValue:null};if(this.addBlock(n,{branchData:e,currentIndex:t.currentIndex}),t.scope&&(n.scope=t.scope),t.args&&t.branchData.args)for(const[r,i]of t.branchData.args.entries())t.args.length>r&&(n.scope[i]=t.args[r]);return n},addBlock(t,e){t.blocks.push(e)},async addAndRunBlock(t){const e=this.currentFrame;if(!e)throw new Error("No frame to add block to");return this.addBlock(e,t),await this.runBlock()},setData(t,e){const n=tl();JI(n,t,e)},addInstruction(t,e){const n=tl();GI(n,t,e)},addFrame(t){if(!t.label)if(this.currentFrame)t.label=this.currentFrame.label;else throw new Error("Tried to add a new frame but no label was passed and there is no current frame label");const e=this.frameOptionsToFrame(t);this.stack.push(e)},async addAndRunFrame(t){return await this.addFrame(t),await this.runFrame()},async runFrame(){if(!this.currentFrame)throw new Error("Tried to run a frame but there is no current frame");let e;for(;this.currentBlock;){const n=await this.runBlock();if(n===Kh||n===Qh)return this.cleanFrame(),n;if(n===$y)return this.cleanFrame()}return this.cleanFrame(),e},cleanFrame(){const t=this.currentFrame,{returnValue:e}=t;return this.stack.splice(this.stack.length-1,1),e},async runBlock(){const t=this.currentBlock;if(!t)throw new Error("Tried to run a block but there is no current block");let e;for(;this.currentLine;){if(e=await this.runLineOnly(),BK(e))return this.cleanBlock(),e;t.currentIndex++}return this.cleanBlock(),e},cleanBlock(){this.currentFrame.blocks.splice(this.currentFrame.blocks.length-1,1)},async runGame(){let t=await this.runFrame();for(;t===Kh;){const e=this.jumpTarget;if(!e){bn("Tried to jump but no target was set");return}this.hasJumped=!0,this.setStack(e),await Ft().autoSaveGame({}),t=await this.runFrame()}t!==Qh&&this.stack.length===0&&this.reachedEndOfScript()},async nextLineOnly(){return this.stack.length===0||this.isBlockFinished()?!1:(this.currentBlock.currentIndex++,!0)},isBlockFinished(){return!this.currentBlock||this.currentBlock&&this.currentBlock.currentIndex>=this.currentBlock.branchData.branch.length},reachedEndOfScript(){if(lt().gameFlow.labelToJumpOnScriptEnd&&this.lastLabel!==lt().gameFlow.labelToJumpOnScriptEnd){this.jumpToLabel(lt().gameFlow.labelToJumpOnScriptEnd);return}if(Ft().endingScript(),Ft().options.debug){const e=ti();lt().debugging.showScriptFinishedMessage&&e.addDialog({speaker:"game",text:"[DEBUG] Game Script is finished. This is the end of the game flow. This message only appears in debug mode."})}},async runLineOnly(){const t=this.currentLine;if(!t){bn("There is no line of script to run.");return}return Ft().startingScript(),await L7(t)},async runLabelFunction(t,...e){const n=this.script[t];if(!n){bn(`Tried to run a label that doesn't exist: ${t}`);return}const r={currentIndex:0,branchData:n,label:t,args:e};return this.addAndRunFrame(r)},runCustomFrame(t){this.addAndRunFrame(t)},async jumpToLabel(t,...e){const n=this.script[t];if(!n){bn(`Label ${t} doesn't exist. Is the file with this label added in the list of script files to load in the config?`);return}t!==this.lastLabel&&(this.hasJumped=!0),this.setLastLabel(t),this.setStack({currentIndex:0,branchData:n,args:e,label:t}),await Ft().autoSaveGame({}),this.runGame()},async runThenGoBackToPreviousDialog(t,...e){const n=ti(),r=n.dialog[n.dialog.length-1],i=await this.runLabelFunction(t,...e);return n.dialog.push(r),i}},getters:{currentFrame(t){return t.stack[t.stack.length-1]},scope(){var t,e;return(e=(t=this.currentFrame)==null?void 0:t.scope)!=null?e:{}},currentBlock(){const t=this.currentFrame;return t?t.blocks[t.blocks.length-1]:void 0},currentLine(){const t=this.currentBlock;if(t&&t.branchData.branch.length>t.currentIndex)return t.branchData.branch[t.currentIndex]},commandWaitingForAnswer(){if(this.commandsWaitingForPlayerAnswer.length>0)return this.commandsWaitingForPlayerAnswer[0]}}});class pQ{constructor(){Mi(this,"plugins",[]);Mi(this,"pinia");Mi(this,"commands",{})}addCommand(e){this.commands[e.keyword]=e}addPlugin(e){if(this.plugins.push(e),e.customCommands)for(const n of e.customCommands)this.addCommand(n)}callHook(e,...n){for(const r of this.plugins)typeof r[e]=="function"&&r[e](...n)}customStores(){const e=[];for(const n of this.plugins)if(n.customStores)for(const r in n.customStores)e.push([r,n.customStores[r](this.pinia)]);return e}}const qn=new pQ;async function L7(t,e){var r;const n=ln();try{return await Ty(t,e)}catch(i){console.error(i),console.error(t),bn(`Narrat script runtime error at <span class="error-filename">${t.fileName}:${t.line+1}</span>
|
|
179
179
|
<b>${i}</b>
|
|
180
180
|
Script: ${t.code}
|
|
181
|
-
Label: ${((r=n.currentFrame)==null?void 0:r.label)||"none"}`)}}async function vQ(t,e){const n=t.command,r=qn.commands[n.commandType];if(r){const i={args:[],options:{},operator:n.operator,staticOptions:n.staticOptions,code:t.code,commandType:n.commandType,fileName:t.fileName,line:t.line},o=r.argTypes;i.options={};for(const[a,s]of n.args.entries()){let u;if($7(s))u=await Ty(s,e);else if(typeof s=="string")if(s.search(_7)===0)u=s.substring(3);else if(A7(s)){const l=tl(),f=tZ(l,s.substring(1));if(f){const[c,d]=f;u=c[d]}else u=s}else u=s;else u=s;if(i.args.push(u),Array.isArray(o)&&o.length>a){const l=o[a];u!==null&&(i.options[l.name]=u)}}return i}else throw new Error(`${n.commandType} is not a valid command`)}async function Ty(t,e){const n=await vQ(t,e),r=qn.commands[n.commandType];if(r)return await r.run(n,e);throw new Error(`${n.commandType} is not a valid command`)}async function mQ(t){Bs("onPlayerAnswered");const e=ln(),n=e.popAnswerQueue(),r=e.currentLine;try{if(n){const i=qn.commands[n.commandType];if(i)return await i.processPlayerAnswer(n,t)}}catch(i){console.error(i),bn(`Error after player answer at ${r.fileName}:${r.line+1} (${r.code}<br /> - Error: ${i}`)}}var gQ=function(e){return yQ(e)&&!bQ(e)};function yQ(t){return!!t&&typeof t=="object"}function bQ(t){var e=Object.prototype.toString.call(t);return e==="[object RegExp]"||e==="[object Date]"||xQ(t)}var kQ=typeof Symbol=="function"&&Symbol.for,wQ=kQ?Symbol.for("react.element"):60103;function xQ(t){return t.$$typeof===wQ}function jQ(t){return Array.isArray(t)?[]:{}}function Tc(t,e){return e.clone!==!1&&e.isMergeableObject(t)?Gu(jQ(t),t,e):t}function _Q(t,e,n){return t.concat(e).map(function(r){return Tc(r,n)})}function SQ(t,e){if(!e.customMerge)return Gu;var n=e.customMerge(t);return typeof n=="function"?n:Gu}function CQ(t){return Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(t).filter(function(e){return t.propertyIsEnumerable(e)}):[]}function D7(t){return Object.keys(t).concat(CQ(t))}function R7(t,e){try{return e in t}catch{return!1}}function $Q(t,e){return R7(t,e)&&!(Object.hasOwnProperty.call(t,e)&&Object.propertyIsEnumerable.call(t,e))}function AQ(t,e,n){var r={};return n.isMergeableObject(t)&&D7(t).forEach(function(i){r[i]=Tc(t[i],n)}),D7(e).forEach(function(i){$Q(t,i)||(R7(t,i)&&n.isMergeableObject(e[i])?r[i]=SQ(i,n)(t[i],e[i],n):r[i]=Tc(e[i],n))}),r}function Gu(t,e,n){n=n||{},n.arrayMerge=n.arrayMerge||_Q,n.isMergeableObject=n.isMergeableObject||gQ,n.cloneUnlessOtherwiseSpecified=Tc;var r=Array.isArray(e),i=Array.isArray(t),o=r===i;return o?r?n.arrayMerge(t,e,n):AQ(t,e,n):Tc(e,n)}Gu.all=function(e,n){if(!Array.isArray(e))throw new Error("first argument should be an array");return e.reduce(function(r,i){return Gu(r,i,n)},{})};var EQ=Gu,Zh=EQ;const Uo=Ci("hud",{state:()=>({hudStats:{}}),actions:{setupHudStats(t){for(const e in t)this.hudStats[e]={value:t[e].startingValue}},setStat(t,e){this.hudStats[t].value=e},addStat(t,e){this.hudStats[t].value+=e},getStat(t){return this.hudStats[t]},getStatValue(t){return this.hudStats[t].value},generateSaveData(){return{hudStats:fi(this.hudStats)}},loadSaveData(t){this.hudStats=Zh(this.hudStats,t.hudStats)}}}),$i=Ci("notifications",{state:()=>({notifications:{},enabled:!0}),actions:{async addNotification(t){if(!this.enabled)return;t=Xh(t);const e=`${Date.now()}-${Math.random()*1e4}`;this.notifications[e]={text:t},lt().notifications.alsoPrintInDialogue&&E7(`[NOTIFICATION] ${t}`),await co(lt().notifications.timeOnScreen*1e3),this.deleteNotification(e)},deleteNotification(t){delete this.notifications[t]},disableNotifications(){this.enabled=!1;for(const t in this.notifications)this.deleteNotification(t)},enableNotifications(){this.enabled=!0}}}),kr=Ci("inventory",{state:()=>({items:{},interactionTags:{}}),actions:{generateSaveData(){return{items:fi(this.items),interactionTags:fi(this.interactionTags)}},loadSaveData(t){this.items={...this.items,...t.items},this.interactionTags={...t.interactionTags}},setupItems(t){Object.keys(t).forEach(e=>{this.items[e]={amount:0,id:e}})},hasItem(t,e){var n;return e||(e=1),((n=this.items[t])==null?void 0:n.amount)>=e},getExistingItem(t){return this.items[t]},getItemAmount(t){var e;return((e=this.getExistingItem(t))==null?void 0:e.amount)||0},add(t){const e=this.getExistingItem(t.id);e?e.amount+=t.amount:this.items[t.id]={...t},$i().addNotification(`Received item: ${UI(t.id).name} x ${t.amount}`)},enableInteraction(t){t||(t="default"),this.interactionTags[t]={blockedInteraction:!1}},disableInteraction(t){t||(t="default"),this.interactionTags[t]={blockedInteraction:!0}},onScriptStart(){const t=lt().interactionTags;Object.keys(t).forEach(e=>{t[e].onlyInteractOutsideOfScripts&&this.disableInteraction(e)})},onScriptEnd(){const t=lt().interactionTags;Object.keys(t).forEach(e=>{t[e].onlyInteractOutsideOfScripts&&this.enableInteraction(e)})},isInteractionTagBlocked(t){return t||(t="default"),this.interactionTags[t]?this.interactionTags[t].blockedInteraction:!1},remove(t){const e=this.getExistingItem(t.id);e&&(e.amount-=t.amount,$i().addNotification(`Lost item: ${UI(t.id).name} x ${t.amount}`),e.amount<=0&&this.deleteItem(t.id))},deleteItem(t){this.getExistingItem(t)&&(this.items[t].amount=0)}}}),zr=Ci("quests",{state:()=>({quests:{}}),actions:{getQuest(t){const e=this.quests[t];if(e)return e;{const n=`Quest ${t} doesn't exist!`;throw bn(n),new Error(n)}},getObjective(t,e){const n=this.getQuest(t);if(!n){const o=`Quest ${t} doesn't exist!`;throw bn(o),new Error(o)}const r=n.objectives[e];if(r)return r;const i=`Objective ${e} doesn't exist in quest ${t}!`;throw bn(i),new Error(i)},setupQuests(t){for(const e of Object.keys(t)){const n=t[e];this.quests[e]={id:e,state:"hidden",objectives:{}};for(const r of Object.keys(n.objectives)){const i=n.objectives[r];this.quests[e].objectives[r]={id:r,state:i.hidden?"hidden":"unlocked"}}}},startQuest(t){const e=this.getQuest(t);e?(e.state="unlocked",$i().addNotification(`Started quest: ${up(t).title}`)):bn(`Quest ${t} doesn't exist!`)},startObjective(t,e){const n=this.getObjective(t,e);n?(n.state="unlocked",$i().addNotification(`New quest objective: ${Gy(t,e).description}`)):bn(`Objective ${e} doesn't exist in quest ${t}!`)},completeObjective(t,e){const n=this.getObjective(t,e);n?(n.state="completed",$i().addNotification(`Completed quest objective: ${Gy(t,e).description}`)):bn(`Objective ${e} doesn't exist in quest ${t}!`)},completeQuest(t,e){const n=this.getQuest(t);n?(n.state="completed",n.ending=e,$i().addNotification(`Completed quest: ${up(t).title}`)):bn(`Quest ${t} doesn't exist!`)},isQuestCompleted(t){const e=this.getQuest(t);return e?e.state==="completed":!1},isObjectiveCompleted(t,e){const n=this.getObjective(t,e);return n?n.state==="completed":!1},isQuestStarted(t){const e=this.getQuest(t);return e&&e.state==="unlocked"},isObjectiveStarted(t,e){return this.getObjective(t,e).state==="unlocked"},removeQuest(t){delete this.quests[t]},generateSaveData(){return{quests:fi(this.quests)}},loadSaveData(t){this.quests=t.quests}}});function B7(t,e,n,r){const i=t/n,o=e/r;return Math.min(i,o)}const Ai=Ci("rendering",{state:()=>({screenHeight:window.innerHeight,screenWidth:window.innerWidth,layoutMode:"horizontal"}),actions:{updateScreenSize(t,e){this.screenHeight=e,this.screenWidth=t,t<lt().layout.verticalLayoutThreshold?this.layoutMode="vertical":this.layoutMode="horizontal"}},getters:{gameScaleRatio(t){return B7(this.screenWidth,this.screenHeight,this.gameWidth,this.gameHeight)},overlayMode(t){var e,n,r;return!!(((r=(n=(e=lt())==null?void 0:e.layout)==null?void 0:n.dialogPanel)==null?void 0:r.overlayMode)&&t.layoutMode==="horizontal")},gameWidth(){const t=lt();return this.layoutMode==="vertical"||this.overlayMode?t.layout.backgrounds.width:t.layout.backgrounds.width+t.layout.minTextWidth},gameHeight(){const t=lt();return this.layoutMode==="vertical",t.layout.backgrounds.height},dialogHeight(){return this.layoutMode==="vertical"?this.actualGameHeight-this.gameHeight:this.gameHeight},actualGameHeight(){let t=this.gameHeight;return this.layoutMode==="vertical"&&(t=this.screenHeight/this.gameScaleRatio),t},viewportRatio(t){if(this.layoutMode==="vertical"){const e=lt().layout.backgrounds;return t.screenWidth/e.width}return 1},viewportHeight(t){return lt().layout.backgrounds.height*this.viewportRatio},viewportWidth(t){return lt().layout.backgrounds.width*this.viewportRatio}}}),ep={};function OQ(t){var e;return(e=ep[t])!=null?e:{}}function z7(t,e,n){var s,u,l,f;const r=OQ(t.transition),i=(u=(s=t.duration)!=null?s:r.duration)!=null?u:500,o=(f=(l=t.delay)!=null?l:r.delay)!=null?f:0;return{...t,resolve:n,duration:i,delay:o,oldScreen:e}}const po=Ci("screens",{state:()=>({layers:[{screen:"default"}],buttons:{}}),actions:{setScreen(t,e,n){return new Promise(r=>{var s;const i=this.layers[e||0];let o;const a=(s=i==null?void 0:i.screen)!=null?s:null;if(a===t){r();return}n&&(o=z7(n,a,r)),this.layers[e||0]={screen:t,transition:o},o||r()})},finishTransition(t){const e=this.layers[t];if(!e)bn(`Tried to finish transition on layer ${t} but it doesn't exist`);else if(e.transition){const n=e.transition.resolve;delete e.transition,n()}},transitionScreen(t,e,n){return this.setScreen(t,n!=null?n:0,e)},emptyLayer(t,e){return new Promise(n=>{const r=this.layers[t];if(!r){Iy(`Tried to empty layer ${t} but it doesn't exist`);return}if(e){const i=r.screen,o=z7(e,i,n);r.transition=o}r.screen=null,e||n()})},setButtons(t){const{buttons:e,screens:n,images:r}=t;for(const i in e)this.buttons[i]={state:e[i].enabled};for(const i in n)if(n[i].buttons){const o=n[i];o.background&&r[o.background]&&(o.background=r[o.background]);for(const a in o.buttons){const s=o.buttons[a];typeof s=="object"&&(e[s.id]=s,o.buttons[a]=s.id,this.buttons[s.id]={state:s.enabled})}}},changeButton(t,e){this.buttons[t].state=e},generateSaveData(){return{layers:fi(this.layers).filter(t=>t).map(t=>{var e;return(e=t.screen)!=null?e:null}),buttons:fi(this.buttons)}},loadSaveData(t){this.layers=t.layers.map(e=>({screen:e})),this.buttons=Zh(this.buttons,t.buttons)}},getters:{nonEmptyLayers(t){return t.layers.filter(e=>e)}}});class F7{constructor(){Mi(this,"listeners",{})}on(e,n){return this.listeners[e]||this.addEventToMap(e),this.listeners[e].add(n),n}off(e,n){return this.listeners[e]&&this.listeners[e].delete(n),n}once(e,n){const r=(...i)=>{this.off(e,r),n(...i)};return this.on(e,r)}emit(e,...n){this.listeners[e]&&this.listeners[e].forEach(r=>r(...n))}clear(){Object.keys(this.listeners).forEach(e=>{delete this.listeners[e]})}addEventToMap(e){this.listeners[e]=new Set}}const Ja=Ci("menu",{state:()=>({buttons:[],modal:!1}),getters:{showSkills(){return Object.entries(lt().skills).length>0},showInventory(){return Object.entries(lt().items).length>0},showQuests(){return Object.entries(lt().quests).length>0},buttonsToShow(t){return t.buttons.map(e=>{const n=lt().menuButtons[e.id]||{};return{...e,...n}}).filter(e=>e.condition?e.condition():!0)}},actions:{setup(){},addMenuOption(t){this.buttons.push(t)},openModal(t){this.modal=t},closeModal(){this.modal=!1},toggleMenu(){this.modal?this.modal=!1:this.modal="menu"}}}),zs=Ci("sprites",{state:()=>({sprites:[]}),actions:{createSprite(t,e,n){const i={id:Oc(),x:e,y:n,anchor:{x:.5,y:.5},image:t,opacity:1,scale:1,layer:0,width:1,height:1};return this.sprites.push(i),LK(t).then(o=>{const a=this.getSprite(i.id);a&&(a.width=o.width,a.height=o.height)}),i},getSprite(t){return this.sprites.find(e=>e.id===t)},deleteSprite(t){const e=this.sprites.indexOf(t);if(e===-1){Iy(`Sprite ${t.id} not found in sprites store`);return}this.sprites.splice(e,1)},clickSprite(t){t.onClick&&ln().jumpToLabel(t.onClick)},generateSaveData(){return{sprites:fi(this.sprites)}},loadSaveData(t){this.sprites=t.sprites},reset(){this.sprites=[]}}});function MQ(){return{baseAssetsPath:"",baseDataPath:"",charactersPath:"data/characters.json",configPath:"data/config.json",logging:!1,debug:!1}}class TQ extends F7{}const Ft=Ci("main",{state:()=>({ready:!1,playing:!1,errors:[],playTime:{start:0,previousPlaytime:0},saveSlot:"",flowState:"engine-splash",modal:!1,paused:!1,options:{baseAssetsPath:"",baseDataPath:"",charactersPath:"data/characters.json",configPath:"data/config.json",logging:!1,debug:!1},loading:{step:"Loading",percentage:.1,loaded:!1},alerts:[],saving:null,listener:new TQ,inScript:!1}),actions:{async setup(){var n;const t=lt(),e=t.scripts;Cr().setMasterVolume((n=t.audioOptions.volume)!=null?n:1),await ln().loadScripts(e),Ja().setup();for(const[,r]of qn.customStores())if(r.setup){const i=r.setup();iK(i)&&await i}this.resetAllStores()},async engineLoading(){this.loading.step="Characters";const t=await pa(this.options.charactersPath);await NK(t),this.loading.percentage=.2,this.loading.step="Data",this.loading.percentage=.3,this.loading.step="Images",await DK(lt()),this.loading.percentage=.7,this.loading.step="Audio",await MK(lt()),qn.callHook("onAssetsLoaded"),this.loading.percentage=.95,this.loading.step="Starting...",await this.setup(),qn.callHook("onGameSetup"),this.loading.loaded=!0,this.listener.emit("gameLoaded")},async alert(t,e){return new Promise(n=>{this.alerts.push({title:t,text:e,resolver:n,id:Oc()})})},closeAlert(t){const e=this.alerts.findIndex(n=>n.id===t);e!==-1&&(this.alerts[e].resolver(),this.alerts.splice(e,1))},startingScript(){kr().onScriptStart(),this.inScript=!0},endingScript(){kr().onScriptEnd(),this.inScript=!1},startMachine(){Cr().stopAll(),Bs("onPressStart"),ln().start(),this.ready=!0,this.startPlaying(),qn.callHook("onGameStart"),this.setFlowState("playing")},setSaveSlot(t){this.saveSlot=t,HK(t)},async startGame(t){if(lt().saves.mode==="manual"){const e=Ay();e&&(t=e.id)}this.setSaveSlot(t),this.startMachine(),await this.autoSaveGame({slotId:t}),ln().runGame()},async loadGame(t,e){if(lt().saves.mode==="manual"){const n=Ay();n&&(e=n.id)}this.setSaveSlot(e),this.startMachine(),t.saveData&&(this.setLoadedData(t.saveData),Cr().reloadAudio(t.saveData.audio),ln().jumpToLabel(t.saveData.vm.lastLabel))},manualSave({saveName:t,withPrompt:e}){return new Promise(n=>{ln().hasJumped?this.saving={name:t,withPrompt:e,resolver:n}:n()})},finishManualSave(t,e){var n,r;if(!this.saving){bn("Trying to save but there is no saving request!");return}if(!e||!t){this.saving.resolver(),this.saving=null;return}this.saveData?(j7({...this.saveData,main:{...this.saveData.main,playTime:Wc(this.playTime.start,this.playTime.previousPlaytime)},metadata:{...this.saveData.metadata,name:(r=(n=this.saving)==null?void 0:n.name)!=null?r:"Manual Save",saveDate:new Date().toISOString()}},t.slotId),this.alert("Success","Game saved!")):bn("There was no data to save!"),this.saving.resolver(),this.saving=null},playerAnswered(t){mQ(t)},menuReturn(){this.reset(),this.setFlowState("menu"),lt().audioOptions.defaultMusic&&Cr().playChannel("music",lt().audioOptions.defaultMusic,0)},createError(t){this.errors.push({text:t,type:"error"})},createWarning(t){this.errors.push({text:t,type:"warning"})},clearErrors(){this.errors=[]},setFlowState(t){this.flowState=t},openModal(t){this.modal=t},closeModal(){this.modal=!1},toggleMenu(){this.modal?this.modal=!1:this.modal="menu"},pause(){this.paused=!0},unpause(){this.paused=!1},setOptions(t){this.options=t},startPlaying(){this.playing=!0,this.playTime.start=Date.now()},reset(){this.ready=!1,this.errors=[],this.modal=!1,this.paused=!1,ln().reset(),Cr().reset(),this.resetAllStores(),this.playing=!1,this.ready=!0},resetAllStores(){const t=po(),e=lt();zs().reset(),t.setButtons(e),hr().setupSkills(e.skills),Uo().setupHudStats(e.hudStats),kr().setupItems(e.items),zr().setupQuests(e.quests),qn.customStores().forEach(([a,s])=>{s.reset&&s.reset()})},generateSaveData(){return{playTime:Wc(this.playTime.start,this.playTime.previousPlaytime)}},loadSaveData(t){this.playTime.previousPlaytime=t.playTime},autoSaveGame({slotId:t,name:e}){const n=t!=null?t:this.saveSlot,r=Mc(n),i=KK();r&&r.saveData?i.name=r.saveData.metadata.name:i.name=e!=null?e:"Auto Save",lt().saves.mode==="manual"&&(i.name="Auto Save");const o=po(),a=hr(),s=ti(),u=ln(),l=Ft(),f=Uo(),c=Cr(),d=kr(),h={version:k7,screen:o.generateSaveData(),skills:a.generateSaveData(),dialog:s.generateSaveData(),vm:u.generateSaveData(),main:l.generateSaveData(),hud:f.generateSaveData(),audio:c.generateSaveData(),inventory:d.generateSaveData(),quests:zr().generateSaveData(),metadata:i,sprites:zs().generateSaveData()};qn.customStores().forEach(([p,v])=>{if(v.save){const m=v.save();m&&(h[p]=m)}}),this.saveData=h,j7(h,this.saveSlot)},setLoadedData(t){const e=po(),n=hr(),r=ti(),i=ln(),o=Ft(),a=Uo(),s=Cr(),u=kr();e.loadSaveData(t.screen),n.loadSaveData(t.skills),r.loadSaveData(t.dialog),i.loadSaveData(t.vm),o.loadSaveData(t.main),a.loadSaveData(t.hud),s.loadSaveData(t.audio),u.loadSaveData(t.inventory),zs().loadSaveData(t.sprites),zr().loadSaveData(t.quests),qn.customStores().forEach(([l,f])=>{f.load&&f.load(t[l])})},getAllStates(){return{main:this,screens:po(),skills:hr(),dialog:ti(),vm:ln(),hud:Uo(),audio:Cr(),rendering:Ai(),notifications:$i(),inventory:kr(),quests:zr(),sprites:zs()}},overrideStates(t){const e=this.getAllStates();for(const n in t){const r=t[n];Object.assign(e[n],r)}}},getters:{isInGame(t){return t.flowState==="playing"}}});function IQ(t,e,n){console.error(`Parser error: ${t.fileName}:${t.currentLine}`,n);const r=`[Parser Error] in <span class="error-filename">${t.fileName}:${e+1}</span> - <b>${n}</b>`;bn(r)}function bn(t,...e){const n=Ft();console.error(t,...e),t=t.replace(/[\r\n]/g,`
|
|
181
|
+
Label: ${((r=n.currentFrame)==null?void 0:r.label)||"none"}`)}}async function vQ(t,e){const n=t.command,r=qn.commands[n.commandType];if(r){const i={args:[],options:{},operator:n.operator,staticOptions:n.staticOptions,code:t.code,commandType:n.commandType,fileName:t.fileName,line:t.line},o=r.argTypes;i.options={};for(const[a,s]of n.args.entries()){let u;if($7(s))u=await Ty(s,e);else if(typeof s=="string")if(s.search(_7)===0)u=s.substring(3);else if(A7(s)){const l=tl(),f=tZ(l,s.substring(1));if(f){const[c,d]=f;u=c[d]}else u=s}else u=s;else u=s;if(i.args.push(u),Array.isArray(o)&&o.length>a){const l=o[a];u!==null&&(i.options[l.name]=u)}}return i}else throw new Error(`${n.commandType} is not a valid command`)}async function Ty(t,e){const n=await vQ(t,e),r=qn.commands[n.commandType];if(r)return await r.run(n,e);throw new Error(`${n.commandType} is not a valid command`)}async function mQ(t){Bs("onPlayerAnswered");const e=ln(),n=e.popAnswerQueue(),r=e.currentLine;try{if(n){const i=qn.commands[n.commandType];if(i)return await i.processPlayerAnswer(n,t)}}catch(i){console.error(i),bn(`Error after player answer at ${r.fileName}:${r.line+1} (${r.code}<br /> - Error: ${i}`)}}var gQ=function(e){return yQ(e)&&!bQ(e)};function yQ(t){return!!t&&typeof t=="object"}function bQ(t){var e=Object.prototype.toString.call(t);return e==="[object RegExp]"||e==="[object Date]"||xQ(t)}var kQ=typeof Symbol=="function"&&Symbol.for,wQ=kQ?Symbol.for("react.element"):60103;function xQ(t){return t.$$typeof===wQ}function jQ(t){return Array.isArray(t)?[]:{}}function Tc(t,e){return e.clone!==!1&&e.isMergeableObject(t)?Gu(jQ(t),t,e):t}function _Q(t,e,n){return t.concat(e).map(function(r){return Tc(r,n)})}function SQ(t,e){if(!e.customMerge)return Gu;var n=e.customMerge(t);return typeof n=="function"?n:Gu}function CQ(t){return Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(t).filter(function(e){return t.propertyIsEnumerable(e)}):[]}function D7(t){return Object.keys(t).concat(CQ(t))}function R7(t,e){try{return e in t}catch{return!1}}function $Q(t,e){return R7(t,e)&&!(Object.hasOwnProperty.call(t,e)&&Object.propertyIsEnumerable.call(t,e))}function AQ(t,e,n){var r={};return n.isMergeableObject(t)&&D7(t).forEach(function(i){r[i]=Tc(t[i],n)}),D7(e).forEach(function(i){$Q(t,i)||(R7(t,i)&&n.isMergeableObject(e[i])?r[i]=SQ(i,n)(t[i],e[i],n):r[i]=Tc(e[i],n))}),r}function Gu(t,e,n){n=n||{},n.arrayMerge=n.arrayMerge||_Q,n.isMergeableObject=n.isMergeableObject||gQ,n.cloneUnlessOtherwiseSpecified=Tc;var r=Array.isArray(e),i=Array.isArray(t),o=r===i;return o?r?n.arrayMerge(t,e,n):AQ(t,e,n):Tc(e,n)}Gu.all=function(e,n){if(!Array.isArray(e))throw new Error("first argument should be an array");return e.reduce(function(r,i){return Gu(r,i,n)},{})};var EQ=Gu,Zh=EQ;const Uo=Ci("hud",{state:()=>({hudStats:{}}),actions:{setupHudStats(t){for(const e in t)this.hudStats[e]={value:t[e].startingValue}},setStat(t,e){this.hudStats[t].value=e},addStat(t,e){this.hudStats[t].value+=e},getStat(t){return this.hudStats[t]},getStatValue(t){return this.hudStats[t].value},generateSaveData(){return{hudStats:fi(this.hudStats)}},loadSaveData(t){this.hudStats=Zh(this.hudStats,t.hudStats)}}}),$i=Ci("notifications",{state:()=>({notifications:{},enabled:!0}),actions:{async addNotification(t){if(!this.enabled)return;t=Xh(t);const e=`${Date.now()}-${Math.random()*1e4}`;this.notifications[e]={text:t},lt().notifications.alsoPrintInDialogue&&E7(`[NOTIFICATION] ${t}`),await co(lt().notifications.timeOnScreen*1e3),this.deleteNotification(e)},deleteNotification(t){delete this.notifications[t]},disableNotifications(){this.enabled=!1;for(const t in this.notifications)this.deleteNotification(t)},enableNotifications(){this.enabled=!0}}}),kr=Ci("inventory",{state:()=>({items:{},interactionTags:{}}),actions:{generateSaveData(){return{items:fi(this.items),interactionTags:fi(this.interactionTags)}},loadSaveData(t){this.items={...this.items,...t.items},this.interactionTags={...t.interactionTags}},setupItems(t){Object.keys(t).forEach(e=>{this.items[e]={amount:0,id:e}})},hasItem(t,e){var n;return e||(e=1),((n=this.items[t])==null?void 0:n.amount)>=e},getExistingItem(t){return this.items[t]},getItemAmount(t){var e;return((e=this.getExistingItem(t))==null?void 0:e.amount)||0},add(t){const e=this.getExistingItem(t.id);e?e.amount+=t.amount:this.items[t.id]={...t},$i().addNotification(`Received item: ${UI(t.id).name} x ${t.amount}`)},enableInteraction(t){t||(t="default"),this.interactionTags[t]={blockedInteraction:!1}},disableInteraction(t){t||(t="default"),this.interactionTags[t]={blockedInteraction:!0}},onScriptStart(){const t=lt().interactionTags;Object.keys(t).forEach(e=>{t[e].onlyInteractOutsideOfScripts&&this.disableInteraction(e)})},onScriptEnd(){const t=lt().interactionTags;Object.keys(t).forEach(e=>{t[e].onlyInteractOutsideOfScripts&&this.enableInteraction(e)})},isInteractionTagBlocked(t){return t||(t="default"),this.interactionTags[t]?this.interactionTags[t].blockedInteraction:!1},remove(t){const e=this.getExistingItem(t.id);e&&(e.amount-=t.amount,$i().addNotification(`Lost item: ${UI(t.id).name} x ${t.amount}`),e.amount<=0&&this.deleteItem(t.id))},deleteItem(t){this.getExistingItem(t)&&(this.items[t].amount=0)}}}),zr=Ci("quests",{state:()=>({quests:{}}),actions:{getQuest(t){const e=this.quests[t];if(e)return e;{const n=`Quest ${t} doesn't exist!`;throw bn(n),new Error(n)}},getObjective(t,e){const n=this.getQuest(t);if(!n){const o=`Quest ${t} doesn't exist!`;throw bn(o),new Error(o)}const r=n.objectives[e];if(r)return r;const i=`Objective ${e} doesn't exist in quest ${t}!`;throw bn(i),new Error(i)},setupQuests(t){for(const e of Object.keys(t)){const n=t[e];this.quests[e]={id:e,state:"hidden",objectives:{}};for(const r of Object.keys(n.objectives)){const i=n.objectives[r];this.quests[e].objectives[r]={id:r,state:i.hidden?"hidden":"unlocked"}}}},startQuest(t){const e=this.getQuest(t);e?(e.state="unlocked",$i().addNotification(`Started quest: ${up(t).title}`)):bn(`Quest ${t} doesn't exist!`)},startObjective(t,e){const n=this.getObjective(t,e);n?(n.state="unlocked",$i().addNotification(`New quest objective: ${Gy(t,e).description}`)):bn(`Objective ${e} doesn't exist in quest ${t}!`)},completeObjective(t,e){const n=this.getObjective(t,e);n?(n.state="completed",$i().addNotification(`Completed quest objective: ${Gy(t,e).description}`)):bn(`Objective ${e} doesn't exist in quest ${t}!`)},completeQuest(t,e){const n=this.getQuest(t);n?(n.state="completed",n.ending=e,$i().addNotification(`Completed quest: ${up(t).title}`)):bn(`Quest ${t} doesn't exist!`)},isQuestCompleted(t){const e=this.getQuest(t);return e?e.state==="completed":!1},isObjectiveCompleted(t,e){const n=this.getObjective(t,e);return n?n.state==="completed":!1},isQuestStarted(t){const e=this.getQuest(t);return e&&e.state==="unlocked"},isObjectiveStarted(t,e){return this.getObjective(t,e).state==="unlocked"},removeQuest(t){delete this.quests[t]},generateSaveData(){return{quests:fi(this.quests)}},loadSaveData(t){this.quests=t.quests}}});function B7(t,e,n,r){const i=t/n,o=e/r;return Math.min(i,o)}const Ai=Ci("rendering",{state:()=>({screenHeight:window.innerHeight,screenWidth:window.innerWidth,layoutMode:"horizontal"}),actions:{updateScreenSize(t,e){this.screenHeight=e,this.screenWidth=t,t<lt().layout.verticalLayoutThreshold?this.layoutMode="vertical":this.layoutMode="horizontal"}},getters:{gameScaleRatio(t){return B7(this.screenWidth,this.screenHeight,this.gameWidth,this.gameHeight)},overlayMode(t){var e,n,r;return!!(((r=(n=(e=lt())==null?void 0:e.layout)==null?void 0:n.dialogPanel)==null?void 0:r.overlayMode)&&t.layoutMode==="horizontal")},gameWidth(){const t=lt();return this.layoutMode==="vertical"||this.overlayMode?t.layout.backgrounds.width:t.layout.backgrounds.width+t.layout.minTextWidth},gameHeight(){const t=lt();return this.layoutMode==="vertical",t.layout.backgrounds.height},dialogHeight(){return this.layoutMode==="vertical"?this.actualGameHeight-this.gameHeight:this.gameHeight},actualGameHeight(){let t=this.gameHeight;return this.layoutMode==="vertical"&&(t=this.screenHeight/this.gameScaleRatio),t},viewportRatio(t){if(this.layoutMode==="vertical"){const e=lt().layout.backgrounds;return t.screenWidth/e.width}return 1},viewportHeight(t){return lt().layout.backgrounds.height*this.viewportRatio},viewportWidth(t){return lt().layout.backgrounds.width*this.viewportRatio}}}),ep={};function OQ(t){var e;return(e=ep[t])!=null?e:{}}function z7(t,e,n){var s,u,l,f;const r=OQ(t.transition),i=(u=(s=t.duration)!=null?s:r.duration)!=null?u:500,o=(f=(l=t.delay)!=null?l:r.delay)!=null?f:0;return{...t,resolve:n,duration:i,delay:o,oldScreen:e}}const po=Ci("screens",{state:()=>({layers:[{screen:"default"}],buttons:{}}),actions:{setScreen(t,e,n){return new Promise(r=>{var s;const i=this.layers[e||0];let o;const a=(s=i==null?void 0:i.screen)!=null?s:null;if(a===t){r();return}n&&(o=z7(n,a,r)),this.layers[e||0]={screen:t,transition:o},o||r()})},finishTransition(t){const e=this.layers[t];if(!e)bn(`Tried to finish transition on layer ${t} but it doesn't exist`);else if(e.transition){const n=e.transition.resolve;delete e.transition,n()}},transitionScreen(t,e,n){return this.setScreen(t,n!=null?n:0,e)},emptyLayer(t,e){return new Promise(n=>{const r=this.layers[t];if(!r){Iy(`Tried to empty layer ${t} but it doesn't exist`);return}if(e){const i=r.screen,o=z7(e,i,n);r.transition=o}r.screen=null,e||n()})},setButtons(t){const{buttons:e,screens:n,images:r}=t;for(const i in e)this.buttons[i]={state:e[i].enabled};for(const i in n)if(n[i].buttons){const o=n[i];o.background&&r[o.background]&&(o.background=r[o.background]);for(const a in o.buttons){const s=o.buttons[a];typeof s=="object"&&(e[s.id]=s,o.buttons[a]=s.id,this.buttons[s.id]={state:s.enabled})}}},changeButton(t,e){this.buttons[t].state=e},generateSaveData(){return{layers:fi(this.layers).filter(t=>t).map(t=>{var e;return(e=t.screen)!=null?e:null}),buttons:fi(this.buttons)}},loadSaveData(t){this.layers=t.layers.map(e=>({screen:e})),this.buttons=Zh(this.buttons,t.buttons)}},getters:{nonEmptyLayers(t){return t.layers.filter(e=>e)}}});class F7{constructor(){Mi(this,"listeners",{})}on(e,n){return this.listeners[e]||this.addEventToMap(e),this.listeners[e].add(n),n}off(e,n){return this.listeners[e]&&this.listeners[e].delete(n),n}once(e,n){const r=(...i)=>{this.off(e,r),n(...i)};return this.on(e,r)}emit(e,...n){this.listeners[e]&&this.listeners[e].forEach(r=>r(...n))}clear(){Object.keys(this.listeners).forEach(e=>{delete this.listeners[e]})}addEventToMap(e){this.listeners[e]=new Set}}const Ja=Ci("menu",{state:()=>({buttons:[],modal:!1}),getters:{showSkills(){return Object.entries(lt().skills).length>0},showInventory(){return Object.entries(lt().items).length>0},showQuests(){return Object.entries(lt().quests).length>0},buttonsToShow(t){return t.buttons.map(e=>{const n=lt().menuButtons[e.id]||{};return{...e,...n}}).filter(e=>e.condition?e.condition():!0)}},actions:{setup(){},addMenuOption(t){this.buttons.push(t)},openModal(t){this.modal=t},closeModal(){this.modal=!1},toggleMenu(){this.modal?this.modal=!1:this.modal="menu"}}}),zs=Ci("sprites",{state:()=>({sprites:[]}),actions:{createSprite(t,e,n){const i={id:Oc(),x:e,y:n,anchor:{x:.5,y:.5},image:t,opacity:1,scale:1,layer:0,width:1,height:1};return this.sprites.push(i),LK(t).then(o=>{const a=this.getSprite(i.id);a&&(a.width=o.width,a.height=o.height)}),i},getSprite(t){return this.sprites.find(e=>e.id===t)},deleteSprite(t){const e=this.sprites.indexOf(t);if(e===-1){Iy(`Sprite ${t.id} not found in sprites store`);return}this.sprites.splice(e,1)},clickSprite(t){t.onClick&&ln().jumpToLabel(t.onClick)},generateSaveData(){return{sprites:fi(this.sprites)}},loadSaveData(t){this.sprites=t.sprites},reset(){this.sprites=[]}}});function MQ(){return{baseAssetsPath:"",baseDataPath:"",charactersPath:"data/characters.json",configPath:"data/config.json",logging:!1,debug:!1}}class TQ extends F7{}const Ft=Ci("main",{state:()=>({ready:!1,playing:!1,errors:[],playTime:{start:0,previousPlaytime:0},saveSlot:"",flowState:"engine-splash",modal:!1,paused:!1,options:{baseAssetsPath:"",baseDataPath:"",charactersPath:"data/characters.json",configPath:"data/config.json",logging:!1,debug:!1},loading:{step:"Loading",percentage:.1,loaded:!1},alerts:[],saving:null,listener:new TQ,inScript:!1}),actions:{async setup(){var n;const t=lt(),e=t.scripts;Cr().setMasterVolume((n=t.audioOptions.volume)!=null?n:1),await ln().loadScripts(e),Ja().setup();for(const[,r]of qn.customStores())if(r.setup){const i=r.setup();iK(i)&&await i}this.resetAllStores()},async engineLoading(){this.loading.step="Characters";const t=await pa(this.options.charactersPath);await NK(t),this.loading.percentage=.2,this.loading.step="Data",this.loading.percentage=.3,this.loading.step="Images",await DK(lt()),this.loading.percentage=.7,this.loading.step="Audio",await MK(lt()),qn.callHook("onAssetsLoaded"),this.loading.percentage=.95,this.loading.step="Starting...",await this.setup(),qn.callHook("onGameSetup"),this.loading.loaded=!0,this.listener.emit("gameLoaded")},async alert(t,e){return new Promise(n=>{this.alerts.push({title:t,text:e,resolver:n,id:Oc()})})},closeAlert(t){const e=this.alerts.findIndex(n=>n.id===t);e!==-1&&(this.alerts[e].resolver(),this.alerts.splice(e,1))},startingScript(){kr().onScriptStart(),this.inScript=!0},endingScript(){kr().onScriptEnd(),this.inScript=!1},startMachine(){Cr().stopAll(),Bs("onPressStart"),ln().start(),this.ready=!0,this.startPlaying(),qn.callHook("onGameStart"),this.setFlowState("playing")},setSaveSlot(t){this.saveSlot=t,HK(t)},async startGame(t){if(lt().saves.mode==="manual"){const e=Ay();e&&(t=e.id)}this.setSaveSlot(t),this.startMachine(),ln().runGame()},async loadGame(t,e){if(lt().saves.mode==="manual"){const n=Ay();n&&(e=n.id)}this.setSaveSlot(e),this.startMachine(),t.saveData&&(this.setLoadedData(t.saveData),Cr().reloadAudio(t.saveData.audio),ln().jumpToLabel(t.saveData.vm.lastLabel))},manualSave({saveName:t,withPrompt:e}){return new Promise(n=>{ln().hasJumped?this.saving={name:t,withPrompt:e,resolver:n}:n()})},finishManualSave(t,e){var n,r;if(!this.saving){bn("Trying to save but there is no saving request!");return}if(!e||!t){this.saving.resolver(),this.saving=null;return}this.saveData?(j7({...this.saveData,main:{...this.saveData.main,playTime:Wc(this.playTime.start,this.playTime.previousPlaytime)},metadata:{...this.saveData.metadata,name:(r=(n=this.saving)==null?void 0:n.name)!=null?r:"Manual Save",saveDate:new Date().toISOString()}},t.slotId),this.alert("Success","Game saved!")):bn("There was no data to save!"),this.saving.resolver(),this.saving=null},playerAnswered(t){mQ(t)},menuReturn(){this.reset(),this.setFlowState("menu"),lt().audioOptions.defaultMusic&&Cr().playChannel("music",lt().audioOptions.defaultMusic,0)},createError(t){this.errors.push({text:t,type:"error"})},createWarning(t){this.errors.push({text:t,type:"warning"})},clearErrors(){this.errors=[]},setFlowState(t){this.flowState=t},openModal(t){this.modal=t},closeModal(){this.modal=!1},toggleMenu(){this.modal?this.modal=!1:this.modal="menu"},pause(){this.paused=!0},unpause(){this.paused=!1},setOptions(t){this.options=t},startPlaying(){this.playing=!0,this.playTime.start=Date.now()},reset(){this.ready=!1,this.errors=[],this.modal=!1,this.paused=!1,ln().reset(),Cr().reset(),this.resetAllStores(),this.playing=!1,this.ready=!0},resetAllStores(){const t=po(),e=lt();zs().reset(),t.setButtons(e),hr().setupSkills(e.skills),Uo().setupHudStats(e.hudStats),kr().setupItems(e.items),zr().setupQuests(e.quests),qn.customStores().forEach(([a,s])=>{s.reset&&s.reset()})},generateSaveData(){return{playTime:Wc(this.playTime.start,this.playTime.previousPlaytime)}},loadSaveData(t){this.playTime.previousPlaytime=t.playTime},autoSaveGame({slotId:t,name:e}){const n=t!=null?t:this.saveSlot,r=Mc(n),i=KK();r&&r.saveData?i.name=r.saveData.metadata.name:i.name=e!=null?e:"Auto Save",lt().saves.mode==="manual"&&(i.name="Auto Save");const o=po(),a=hr(),s=ti(),u=ln(),l=Ft(),f=Uo(),c=Cr(),d=kr(),h={version:k7,screen:o.generateSaveData(),skills:a.generateSaveData(),dialog:s.generateSaveData(),vm:u.generateSaveData(),main:l.generateSaveData(),hud:f.generateSaveData(),audio:c.generateSaveData(),inventory:d.generateSaveData(),quests:zr().generateSaveData(),metadata:i,sprites:zs().generateSaveData()};qn.customStores().forEach(([p,v])=>{if(v.save){const m=v.save();m&&(h[p]=m)}}),this.saveData=h,j7(h,this.saveSlot)},setLoadedData(t){const e=po(),n=hr(),r=ti(),i=ln(),o=Ft(),a=Uo(),s=Cr(),u=kr();e.loadSaveData(t.screen),n.loadSaveData(t.skills),r.loadSaveData(t.dialog),i.loadSaveData(t.vm),o.loadSaveData(t.main),a.loadSaveData(t.hud),s.loadSaveData(t.audio),u.loadSaveData(t.inventory),zs().loadSaveData(t.sprites),zr().loadSaveData(t.quests),qn.customStores().forEach(([l,f])=>{f.load&&f.load(t[l])})},getAllStates(){return{main:this,screens:po(),skills:hr(),dialog:ti(),vm:ln(),hud:Uo(),audio:Cr(),rendering:Ai(),notifications:$i(),inventory:kr(),quests:zr(),sprites:zs()}},overrideStates(t){const e=this.getAllStates();for(const n in t){const r=t[n];Object.assign(e[n],r)}}},getters:{isInGame(t){return t.flowState==="playing"}}});function IQ(t,e,n){console.error(`Parser error: ${t.fileName}:${t.currentLine}`,n);const r=`[Parser Error] in <span class="error-filename">${t.fileName}:${e+1}</span> - <b>${n}</b>`;bn(r)}function bn(t,...e){const n=Ft();console.error(t,...e),t=t.replace(/[\r\n]/g,`
|
|
182
182
|
<br />`),n.createError(`\u274C ${t}`)}function Iy(t,...e){const n=Ft();console.warn(t,...e),t=t.replace(/[\r\n]/g,`
|
|
183
183
|
<br />`),n.createWarning(`\u26A0\uFE0F ${t}`)}/*! js-yaml 4.1.0 https://github.com/nodeca/js-yaml @license MIT */function V7(t){return typeof t>"u"||t===null}function NQ(t){return typeof t=="object"&&t!==null}function PQ(t){return Array.isArray(t)?t:V7(t)?[]:[t]}function LQ(t,e){var n,r,i,o;if(e)for(o=Object.keys(e),n=0,r=o.length;n<r;n+=1)i=o[n],t[i]=e[i];return t}function DQ(t,e){var n="",r;for(r=0;r<e;r+=1)n+=t;return n}function RQ(t){return t===0&&Number.NEGATIVE_INFINITY===1/t}var BQ=V7,zQ=NQ,FQ=PQ,VQ=DQ,qQ=RQ,HQ=LQ,dr={isNothing:BQ,isObject:zQ,toArray:FQ,repeat:VQ,isNegativeZero:qQ,extend:HQ};function q7(t,e){var n="",r=t.reason||"(unknown reason)";return t.mark?(t.mark.name&&(n+='in "'+t.mark.name+'" '),n+="("+(t.mark.line+1)+":"+(t.mark.column+1)+")",!e&&t.mark.snippet&&(n+=`
|
|
184
184
|
|
|
@@ -211,7 +211,7 @@ This will fail in production.`);s=Ac,s._s.has(r)||(o?jy(r,e,i,s):h7(r,i,s),proce
|
|
|
211
211
|
`+t.slice(i,o),i=o+1),a=s;return u+=`
|
|
212
212
|
`,t.length-i>e&&a>i?u+=t.slice(i,a)+`
|
|
213
213
|
`+t.slice(a+1):u+=t.slice(i),u.slice(1)}function MX(t){for(var e="",n=0,r,i=0;i<t.length;n>=65536?i+=2:i++)n=Dc(t,i),r=Fr[n],!r&&Lc(n)?(e+=t[i],n>=65536&&(e+=t[i+1])):e+=r||xX(n);return e}function TX(t,e,n){var r="",i=t.tag,o,a,s;for(o=0,a=n.length;o<a;o+=1)s=n[o],t.replacer&&(s=t.replacer.call(n,String(o),s)),(ha(t,e,s,!1,!1)||typeof s>"u"&&ha(t,e,null,!1,!1))&&(r!==""&&(r+=","+(t.condenseFlow?"":" ")),r+=t.dump);t.tag=i,t.dump="["+r+"]"}function VI(t,e,n,r){var i="",o=t.tag,a,s,u;for(a=0,s=n.length;a<s;a+=1)u=n[a],t.replacer&&(u=t.replacer.call(n,String(a),u)),(ha(t,e+1,u,!0,!0,!1,!0)||typeof u>"u"&&ha(t,e+1,null,!0,!0,!1,!0))&&((!r||i!=="")&&(i+=Hy(t,e)),t.dump&&Nc===t.dump.charCodeAt(0)?i+="-":i+="- ",i+=t.dump);t.tag=o,t.dump=i||"[]"}function IX(t,e,n){var r="",i=t.tag,o=Object.keys(n),a,s,u,l,f;for(a=0,s=o.length;a<s;a+=1)f="",r!==""&&(f+=", "),t.condenseFlow&&(f+='"'),u=o[a],l=n[u],t.replacer&&(l=t.replacer.call(n,u,l)),ha(t,e,u,!1,!1)&&(t.dump.length>1024&&(f+="? "),f+=t.dump+(t.condenseFlow?'"':"")+":"+(t.condenseFlow?"":" "),ha(t,e,l,!1,!1)&&(f+=t.dump,r+=f));t.tag=i,t.dump="{"+r+"}"}function NX(t,e,n,r){var i="",o=t.tag,a=Object.keys(n),s,u,l,f,c,d;if(t.sortKeys===!0)a.sort();else if(typeof t.sortKeys=="function")a.sort(t.sortKeys);else if(t.sortKeys)throw new ni("sortKeys must be a boolean or a function");for(s=0,u=a.length;s<u;s+=1)d="",(!r||i!=="")&&(d+=Hy(t,e)),l=a[s],f=n[l],t.replacer&&(f=t.replacer.call(n,l,f)),ha(t,e+1,l,!0,!0,!0)&&(c=t.tag!==null&&t.tag!=="?"||t.dump&&t.dump.length>1024,c&&(t.dump&&Nc===t.dump.charCodeAt(0)?d+="?":d+="? "),d+=t.dump,c&&(d+=Hy(t,e)),ha(t,e+1,f,!0,c)&&(t.dump&&Nc===t.dump.charCodeAt(0)?d+=":":d+=": ",d+=t.dump,i+=d));t.tag=o,t.dump=i||"{}"}function qI(t,e,n){var r,i,o,a,s,u;for(i=n?t.explicitTypes:t.implicitTypes,o=0,a=i.length;o<a;o+=1)if(s=i[o],(s.instanceOf||s.predicate)&&(!s.instanceOf||typeof e=="object"&&e instanceof s.instanceOf)&&(!s.predicate||s.predicate(e))){if(n?s.multi&&s.representName?t.tag=s.representName(e):t.tag=s.tag:t.tag="?",s.represent){if(u=t.styleMap[s.tag]||s.defaultStyle,SI.call(s.represent)==="[object Function]")r=s.represent(e,u);else if(CI.call(s.represent,u))r=s.represent[u](e,u);else throw new ni("!<"+s.tag+'> tag resolver accepts not "'+u+'" style');t.dump=r}return!0}return!1}function ha(t,e,n,r,i,o,a){t.tag=null,t.dump=n,qI(t,n,!1)||qI(t,n,!0);var s=SI.call(t.dump),u=r,l;r&&(r=t.flowLevel<0||t.flowLevel>e);var f=s==="[object Object]"||s==="[object Array]",c,d;if(f&&(c=t.duplicates.indexOf(n),d=c!==-1),(t.tag!==null&&t.tag!=="?"||d||t.indent!==2&&e>0)&&(i=!1),d&&t.usedDuplicates[c])t.dump="*ref_"+c;else{if(f&&d&&!t.usedDuplicates[c]&&(t.usedDuplicates[c]=!0),s==="[object Object]")r&&Object.keys(t.dump).length!==0?(NX(t,e,t.dump,i),d&&(t.dump="&ref_"+c+t.dump)):(IX(t,e,t.dump),d&&(t.dump="&ref_"+c+" "+t.dump));else if(s==="[object Array]")r&&t.dump.length!==0?(t.noArrayIndent&&!a&&e>0?VI(t,e-1,t.dump,i):VI(t,e,t.dump,i),d&&(t.dump="&ref_"+c+t.dump)):(TX(t,e,t.dump),d&&(t.dump="&ref_"+c+" "+t.dump));else if(s==="[object String]")t.tag!=="?"&&EX(t,t.dump,e,o,u);else{if(s==="[object Undefined]")return!1;if(t.skipInvalid)return!1;throw new ni("unacceptable kind of an object to dump "+s)}t.tag!==null&&t.tag!=="?"&&(l=encodeURI(t.tag[0]==="!"?t.tag.slice(1):t.tag).replace(/!/g,"%21"),t.tag[0]==="!"?l="!"+l:l.slice(0,18)==="tag:yaml.org,2002:"?l="!!"+l.slice(18):l="!<"+l+">",t.dump=l+" "+t.dump)}return!0}function PX(t,e){var n=[],r=[],i,o;for(Uy(t,n,r),i=0,o=r.length;i<o;i+=1)e.duplicates.push(n[r[i]]);e.usedDuplicates=new Array(o)}function Uy(t,e,n){var r,i,o;if(t!==null&&typeof t=="object")if(i=e.indexOf(t),i!==-1)n.indexOf(i)===-1&&n.push(i);else if(e.push(t),Array.isArray(t))for(i=0,o=t.length;i<o;i+=1)Uy(t[i],e,n);else for(r=Object.keys(t),i=0,o=r.length;i<o;i+=1)Uy(t[r[i]],e,n)}function LX(t,e){e=e||{};var n=new _X(e);n.noRefs||PX(t,n);var r=t;return n.replacer&&(r=n.replacer.call({"":r},"",r)),ha(n,0,r,!0,!0)?n.dump+`
|
|
214
|
-
`:""}var DX=LX,RX={dump:DX};function Jy(t,e){return function(){throw new Error("Function yaml."+t+" is removed in js-yaml 4. Use yaml."+e+" instead, which is now safe by default.")}}var BX=$r,zX=W7,FX=K7,VX=eI,qX=tI,HX=Ry,WX=_I.load,UX=_I.loadAll,JX=RX.dump,GX=ni,KX={binary:aI,float:Z7,map:G7,null:Q7,pairs:uI,set:lI,timestamp:iI,bool:Y7,int:X7,merge:oI,omap:sI,seq:J7,str:U7},QX=Jy("safeLoad","load"),YX=Jy("safeLoadAll","loadAll"),XX=Jy("safeDump","dump"),ZX={Type:BX,Schema:zX,FAILSAFE_SCHEMA:FX,JSON_SCHEMA:VX,CORE_SCHEMA:qX,DEFAULT_SCHEMA:HX,load:WX,loadAll:UX,dump:JX,YAMLException:GX,types:KX,safeLoad:QX,safeLoadAll:YX,safeDump:XX};function HI(t){return new Promise((e,n)=>{const r=new XMLHttpRequest;r.onload=function(){r.status>=200&&r.status<300?e(r.responseText):(bn(`Failed to load file ${t}`,r.status),n(r.status))},r.open("GET",t),r.send()})}async function pa(t){try{const e=await HI(t);let n;if(t.endsWith(".json"))n=JSON.parse(e);else if(t.endsWith(".yaml"))n=ZX.load(e);else{const r=`Unsupported file type for data file ${t} (must be .json or .yaml)`;throw new Error(r)}if(!n)throw new Error(`Data loaded from ${t} is empty`);return n}catch(e){throw console.error(`Failed to load data file ${t}: ${e}`),e}}let Bt;async function eZ(t){Bt={...nK},t.baseAssetsPath&&(Bt.baseAssetsPath=t.baseAssetsPath),t.baseDataPath&&(Bt.baseDataPath=t.baseDataPath);const e=await pa(t.configPath);if(Bt={...Bt,...e},typeof Bt.screens=="string"){const n=await pa(Ya(Bt.screens));Bt.screens=n}if(typeof Bt.buttons=="string"){const n=await pa(Ya(Bt.buttons));Bt.buttons=n}if(typeof Bt.skills=="string"){const n=await pa(Ya(Bt.skills));Bt.skills=n.skills,Bt.skillOptions={...Bt.skillOptions,...n.options},Bt.skillChecks={...Bt.skillChecks,...n.skillChecks}}if(typeof Bt.scripts=="string"){const n=await pa(Ya(Bt.scripts));Bt.scripts=n}if(typeof Bt.audio=="string"){const n=await pa(Ya(Bt.audio));Bt.audio=n.files,Bt.audioOptions={...Bt.audioOptions,...n.options}}if(typeof Bt.items=="string"){const n=await pa(Ya(Bt.items));Bt.items=n}if(typeof Bt.quests=="string"){const n=await pa(Ya(Bt.quests));Bt.quests=n}if(Bt.transitions)for(const n in Bt.transitions)ep[n]?Object.assign(ep[n],Bt.transitions[n]):ep[n]=Bt.transitions[n]}function lt(){return Bt}function WI(t){const e=Bt.skills[t];return e||bn(`Skill config for skill ${t} doesn't exist`),e}function sp(t){return t.startsWith("http")?t:Bt.images[t]?Qa(Bt.images[t]):Qa(t)}function Qa(t){return t.startsWith("http")?t:Bt.baseAssetsPath?`${Bt.baseAssetsPath}${t}`:t}function Ya(t){return Bt.baseDataPath?`${Bt.baseDataPath}${t}`:t}function el(t){return Bt.buttons[t]}function UI(t){const e=Bt.items[t];return e||bn(`Item config for skill ${t} doesn't exist`),e}function up(t){return Bt.quests[t]}function Gy(t,e){return up(t).objectives[e]}function Ky(t,e){const n=e.split(".");let r=t;const i=n.length-1;let o=n[0],a=0;for(a=0;a<i;a++)o=n[a],r[o]||(r[o]={}),r=r[o];return o=n[a],[r,o]}function tZ(t,e){const n=e.split(".");let r=t;const i=n.length-1;let o=n[0],a=0;for(a=0;a<i;a++)o=n[a],r[o]||(r[o]={}),r=r[o];return o=n[a],typeof r[o]>"u"&&(r[o]=null),[r,o]}function JI(t,e,n){const[r,i]=Ky(t,e);r[i]=n}function GI(t,e,n){const[r,i]=Ky(t,e),o=r[i]||0;r[i]=n+o}function tl(){const t=ln(),e=hr(),n=po(),r=kr(),i=ln().scope,o={data:t.data,skills:e.skills,buttons:n.buttons,items:r.items,quests:zr().quests,stats:Uo().hudStats,scope:i,config:lt(),gameOptions:Ft().options};return new Proxy(o,{get:(s,u,l)=>{const f=ln().scope,c=ln().data;return typeof f[u]<"u"?f[u]:typeof c[u]<"u"?c[u]:Reflect.get(s,u,l)},set:(s,u,l,f)=>{const c=ln().scope,d=ln().data;if(typeof c[u]<"u")c[u]=l;else{if(typeof s[u]<"u")return Reflect.set(s,u,l,f);typeof l=="object"?d[u]={}:d[u]=l}return!0}})}function fi(t){if(typeof t=="object"){if(Array.isArray(t))return t.map(fi);{const e={};for(const n in t)e[n]=fi(t[n]);return e}}else return t}const hr=Ci("skills",{state:()=>({skillChecks:{},skills:{}}),actions:{setupSkillCheck(t,e){this.skillChecks[e]=t},passSkillCheck(t,e){this.skillChecks[t].happened=!0,this.skillChecks[t].succeeded=!0,e&&(this.skillChecks[t].hidden=!0)},failSkillCheck(t,e){this.skillChecks[t].happened=!0,this.skillChecks[t].succeeded=!1,e&&(this.skillChecks[t].hidden=!0)},generateSaveData(){return{skillChecks:fi(this.skillChecks),skills:fi(this.skills)}},getSkillCheck(t){return this.skillChecks[t]||this.setupSkillCheck(this.createSkillCheckState(),t),this.skillChecks[t]},createSkillCheckState(){return{happened:!1,succeeded:!1,hidden:!1}},loadSaveData(t){this.skillChecks=Zh(this.skillChecks,t.skillChecks),this.skills=Zh(this.skills,t.skills)},setupSkills(t){for(const e in t)this.skills[e]={id:e,level:t[e].startingLevel||0,xp:0}},getSkill(t){return this.skills[t]},getSkillLevel(t){return this.getSkill(t).level},getSkillXp(t){return this.getSkill(t).xp},addXp(t,e){const n=this.getSkill(t);n||bn(`Skill ${t} doesn't exist`),n.xp+=e,n.xp>=lt().skillOptions.xpPerLevel&&(n.xp=0,n.level++,this.levelledUp(t))},setSkillLevel(t,e){const n=this.getSkill(t);n||bn(`Skill ${t} doesn't exist`),n.level=e,this.levelledUp(t)},incrementSkill(t,e){this.getSkill(t).level+=e,this.levelledUp(t)},levelledUp(t){const e=lt().skills[t].name,n=this.skills[t].level;lt().skillOptions.notifyLevelUp&&$i().addNotification(`Your skill in ${e} is now level ${n}`)}}});let KI;const nZ=b.defineComponent({components:{Modal:Go},setup(){const t=hr(),e=b.computed(()=>t.skills),n=b.computed(()=>t.skillChecks);return{skills:e,skillChecks:n}},data(){return{showDebug:!1,jumping:!1,searchString:"",matches:[],matchCursor:0}},mounted(){window.addEventListener("keydown",t=>{if(this.jumping||(t.key==="d"&&this.toggle(),t.key==="j"&&this.jump()),t.key==="ArrowDown"&&(t.preventDefault(),this.matches.length>this.matchCursor+1?this.matchCursor+=1:this.matchCursor=0),t.key==="ArrowUp"&&(t.preventDefault(),this.matchCursor>0?this.matchCursor-=1:this.matchCursor=this.matches.length-1),t.key==="Escape"&&(this.finishJumping(),this.showDebug=!1),this.jumping&&t.key==="Enter"&&this.matchCursor<this.matches.length){const e=this.matches[this.matchCursor];ln().jumpToLabel(e),this.finishJumping()}})},methods:{finishJumping(){this.jumping=!1,this.matches=[],this.searchString=""},labelSelected(t){const e=t.target.value;ln().jumpToLabel(e),this.close()},close(){this.showDebug=!1},closeErrors(){Ft().clearErrors()},open(){this.showDebug=!0;const t=ln(),e=Ft(),n=zr(),r=kr(),i=hr();this.$nextTick(()=>{new H8({target:this.$refs.variablesViewer,props:{content:{text:void 0,json:{data:this.variables,quests:n.quests,items:r.items,skills:i.skills,skillChecks:i.skillChecks}},onChange:o=>{t.overrideData(o.json.data),n.quests=o.json.quests,r.items=o.json.items,i.skills=o.json.skills,i.skillChecks=o.json.skillChecks}}}),new H8({target:this.$refs.stateViewer,props:{content:{text:void 0,json:e.getAllStates()},onChange:o=>{e.overrideStates(o.json)}}})})},toggle(){this.showDebug?this.showDebug=!1:this.jumping?this.finishJumping():this.open()},jump(){KI=new Js(this.labels,{includeScore:!0}),this.jumping=!0,setTimeout(()=>{this.$nextTick(()=>{this.$refs.search.focus()})},10),this.matchCursor=0,this.matches=this.labels},getMatchResultStyle(t){if(t===this.matchCursor)return{background:"var(--light-background)"}},onSearchInput(){const t=this.searchString;console.log(t);const e=KI.search(t);this.matches=e.map(n=>n.item),this.matches.length>0&&this.matchCursor>this.matches.length-1&&(this.matchCursor=this.matches.length-1)},save(){Ft().autoSaveGame({})},wordCount(){const e=Object.values(this.script).reduce((n,r)=>(bo.log(n),n+this.countWordsInScriptBranch(r.branch)),0);alert(`You have ${e} words`)},countWordsInScriptLine(t){if(t.command.commandType==="talk"&&typeof t.command.args[2]=="string")return this.countWordsInString(t.command.args[2]);if(t.command.commandType==="text")return this.countWordsInString(t.code);if(t.command.commandType==="choice"){const e=t.command.staticOptions;let n=this.countWordsInScriptLine(e.prompt);return n+=e.choices.reduce((i,o)=>i+this.countWordsInString(o.prompt.code),0),e.choices.reduce((i,o)=>o.branch?i+this.countWordsInScriptBranch(o.branch):i,n)}if(t.command.commandType==="if"){const e=t.command.staticOptions;return[e.success,e.failure].reduce((r,i)=>i?r+this.countWordsInScriptBranch(i):r,0)}return 0},countWordsInString(t){return t.split(" ").length},countWordsInScriptBranch(t){return t.reduce((e,n)=>n?e+this.countWordsInScriptLine(n):e,0)},getPlayTimeString(){const t=Wc(this.playTime.start,this.playTime.previousPlaytime);return gp(t/1e3)}},computed:{...da(ln,["script","data"]),...da(Ft,["playTime","errors","playing","flowState"]),labels(){const t=this.script;return Object.keys(t).sort()},variables(){return this.data}}}),hie="",rZ={class:"debug-menu"},iZ={key:0,class:"debug-info"},oZ=[b.createElementVNode("h3",null,"Debug mode is ON",-1),b.createElementVNode("ul",null,[b.createElementVNode("li",null,[b.createElementVNode("b",null,"j"),b.createTextVNode(": Quick Label Jump")]),b.createElementVNode("li",null,[b.createElementVNode("b",null,"d"),b.createTextVNode(": Debug Menu")]),b.createElementVNode("li",null,[b.createElementVNode("b",null,"Escape"),b.createTextVNode(": Toggle Menu")])],-1)],aZ=b.createElementVNode("h3",{class:"title"},"Jump to label",-1),sZ={key:0,class:"search-results"},uZ={key:1},lZ=[b.createElementVNode("h3",null,"No matches found",-1)],cZ=b.createElementVNode("h3",{class:"title"},"Error(s)",-1),fZ=b.createTextVNode(" There are errors in your dialogue scripts. Open the developer console for more details. "),dZ=["innerHTML"],hZ=b.createElementVNode("h3",{class:"title"},"Debug Menu!",-1),pZ={class:"container"},vZ=b.createTextVNode(" Hello this is the debug menu. "),mZ=b.createElementVNode("option",{class:"option",selected:"",disabled:""},"Jump to a label",-1),gZ=["value"],yZ={class:"grid grid-cols-3 gap-4"},bZ=b.createElementVNode("h2",null,"Variables Editor",-1),kZ={ref:"variablesViewer"},wZ=b.createElementVNode("h2",null,"Skill Checks",-1),xZ={class:"table-auto"},jZ=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),_Z=b.createElementVNode("h2",null,"App State editor (entire app and engine",-1),SZ=b.createElementVNode("h3",{style:{color:"pink"}}," Use for debugging, editing some of those things can cause issues ",-1),CZ={ref:"stateViewer"};function $Z(t,e,n,r,i,o){const a=b.resolveComponent("modal");return b.openBlock(),b.createElementBlock("div",rZ,[b.createElementVNode("button",{onClick:e[0]||(e[0]=(...s)=>t.open&&t.open(...s)),class:"button debug-button"},"Debug Menu"),!t.playing&&t.flowState==="menu"?(b.openBlock(),b.createElementBlock("div",iZ,oZ)):b.createCommentVNode("",!0),t.jumping?(b.openBlock(),b.createBlock(a,{key:1,onClose:t.finishJumping,containerCssClass:"jump-menu-container"},{header:b.withCtx(()=>[aZ]),body:b.withCtx(()=>[b.withDirectives(b.createElementVNode("input",{type:"text",class:"label-input input",ref:"search","onUpdate:modelValue":e[1]||(e[1]=s=>t.searchString=s),onInput:e[2]||(e[2]=(...s)=>t.onSearchInput&&t.onSearchInput(...s))},null,544),[[b.vModelText,t.searchString]]),t.matches.length>0?(b.openBlock(),b.createElementBlock("div",sZ,[(b.openBlock(!0),b.createElementBlock(b.Fragment,null,b.renderList(t.matches,(s,u)=>(b.openBlock(),b.createElementBlock("div",{class:"search-result",style:b.normalizeStyle(t.getMatchResultStyle(u)),key:u},b.toDisplayString(s),5))),128))])):(b.openBlock(),b.createElementBlock("div",uZ,lZ))]),_:1},8,["onClose"])):b.createCommentVNode("",!0),t.errors.length>0?(b.openBlock(),b.createBlock(a,{key:2,onClose:t.closeErrors,containerCssClass:"debug-menu-container"},{header:b.withCtx(()=>[cZ]),body:b.withCtx(()=>[fZ,b.createElementVNode("ul",null,[(b.openBlock(!0),b.createElementBlock(b.Fragment,null,b.renderList(t.errors,(s,u)=>(b.openBlock(),b.createElementBlock("li",{key:u,class:b.normalizeClass(["error-message list-disc",s.type==="error"?"error":"warning"]),innerHTML:s.text},null,10,dZ))),128))])]),_:1},8,["onClose"])):b.createCommentVNode("",!0),t.showDebug?(b.openBlock(),b.createBlock(a,{key:3,onClose:t.close,containerCssClass:"debug-menu-container"},{header:b.withCtx(()=>[hZ]),body:b.withCtx(()=>[b.createElementVNode("div",pZ,[vZ,b.createElementVNode("select",{class:"select",name:"label-selector",onChange:e[3]||(e[3]=s=>t.labelSelected(s))},[mZ,(b.openBlock(!0),b.createElementBlock(b.Fragment,null,b.renderList(t.labels,s=>(b.openBlock(),b.createElementBlock("option",{class:"option",value:s,key:s},b.toDisplayString(s),9,gZ))),128))],32),b.createElementVNode("div",yZ,[b.createElementVNode("button",{onClick:e[4]||(e[4]=(...s)=>t.wordCount&&t.wordCount(...s)),class:"button"},"Word Count"),b.createElementVNode("button",{onClick:e[5]||(e[5]=(...s)=>t.save&&t.save(...s)),class:"button"},"Save Game")]),b.createElementVNode("h3",null,"Play time: "+b.toDisplayString(t.getPlayTimeString()),1),bZ,b.createElementVNode("div",kZ,null,512),wZ,b.createElementVNode("table",xZ,[jZ,b.createElementVNode("tbody",null,[(b.openBlock(!0),b.createElementBlock(b.Fragment,null,b.renderList(t.skillChecks,(s,u)=>(b.openBlock(),b.createElementBlock("tr",{key:u},[b.createElementVNode("td",null,b.toDisplayString(u),1),b.createElementVNode("td",null,b.toDisplayString(s.happened?"\u2705":"\u274C"),1),b.createElementVNode("td",null,b.toDisplayString(s.happened?s.succeeded?"\u2705":"\u274C":"NA"),1)]))),128))])]),_Z,SZ,b.createElementVNode("div",CZ,null,512)])]),_:1},8,["onClose"])):b.createCommentVNode("",!0)])}const AZ=di(nZ,[["render",$Z]]),EZ=b.defineComponent({computed:{...da($i,["notifications"])}}),gie="",OZ=["innerHTML"];function MZ(t,e,n,r,i,o){return 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(t.notifications,(a,s)=>(b.openBlock(),b.createElementBlock("div",{class:"notification",key:s},[b.createElementVNode("h3",{innerHTML:a.text},null,8,OZ)]))),128))]),_:1})}const TZ=di(EZ,[["render",MZ]]);function QI(t,e=50,n={}){var c,d;let r;const i=(c=n.isImmediate)!=null?c:!1,o=(d=n.callback)!=null?d:!1,a=n.maxWait;let s=Date.now(),u=[];function l(){if(a!==void 0){const h=Date.now()-s;if(h+e>=a)return a-h}return e}const f=function(...h){const p=this;return new Promise((v,m)=>{const g=function(){if(r=void 0,s=Date.now(),!i){const w=t.apply(p,h);o&&o(w),u.forEach(({resolve:x})=>x(w)),u=[]}},y=i&&r===void 0;r!==void 0&&clearTimeout(r);const k=l();if(r=setTimeout(g,k),y){const w=t.apply(p,h);return o&&o(w),v(w)}u.push({resolve:v,reject:m})})};return f.cancel=function(h){r!==void 0&&clearTimeout(r),u.forEach(({reject:p})=>p(h)),u=[]},f}const IZ={class:"save-slot flex flex-row"},NZ={class:"used-save-slot flex flex-row justify-between items-center grow"},PZ={class:"flex flex-col save-slot-number-container"},LZ={class:"save-slot-number"},DZ={class:"flex flex-col justify-center save-info"},RZ={key:1,class:"save-name"},BZ={class:"flex flex-col"},zZ={key:0},FZ={key:1},VZ={key:2},qZ={class:"flex flex-row"},HZ=["onClick"],Qy=b.defineComponent({__name:"save-slot-ui",props:{saveSlot:{type:Object,required:!0},id:{type:String,required:!0},actions:{type:Array,required:!0}},emits:["choice"],setup(t,{emit:e}){var d,h;const n=t,r=b.ref((h=(d=n.saveSlot.saveData)==null?void 0:d.metadata.name)!=null?h:"Empty Save"),i=b.computed(()=>n.saveSlot.saveData!==null),o=b.computed(()=>n.saveSlot.saveData),a=b.computed(()=>lt().saves.mode),s=b.computed(()=>{const p=n.saveSlot.saveData;if(p&&p.screen.layers[0]){const v=lt().screens[p.screen.layers[0]];if(v)return{backgroundImage:`url(${sp(v.background)})`}}return!1});function u(p){e("choice",p)}function l(p){return o.value?gp(o.value.main.playTime/1e3):"00:00:00"}function f(){o.value&&GK(n.saveSlot.id,r.value)}function c(){const p=lt().saves.slots;let v="";const m=n.saveSlot.slotNumber;return m===0&<().saves.mode==="manual"?"AUTO":(p>=10&&m<10&&(v+="0"),p>=100&&m<100&&(v+="0"),v+m)}return(p,v)=>(b.openBlock(),b.createElementBlock("div",IZ,[b.createElementVNode("div",NZ,[b.createElementVNode("div",PZ,[b.createElementVNode("h1",LZ,b.toDisplayString(c()),1)]),b.unref(s)?(b.openBlock(),b.createElementBlock("div",{key:0,class:"save-slot-screenshot",style:b.normalizeStyle(b.unref(s))},null,4)):b.createCommentVNode("",!0),b.createElementVNode("div",DZ,[b.unref(i)?b.withDirectives((b.openBlock(),b.createElementBlock("input",{key:0,type:"text",class:"save-name","onUpdate:modelValue":v[0]||(v[0]=m=>r.value=m),onInput:f},null,544)),[[b.vModelText,r.value]]):(b.openBlock(),b.createElementBlock("h3",RZ,b.toDisplayString(r.value),1)),b.createElementVNode("div",BZ,[b.unref(o)?(b.openBlock(),b.createElementBlock("p",zZ,b.toDisplayString(new Date(b.unref(o).metadata.saveDate).toLocaleString()),1)):b.createCommentVNode("",!0),b.unref(o)?(b.openBlock(),b.createElementBlock("p",FZ,"Play time: "+b.toDisplayString(l(t.saveSlot)),1)):b.createCommentVNode("",!0),b.unref(a)==="game-slots"?(b.openBlock(),b.createElementBlock("p",VZ,b.toDisplayString(t.saveSlot.slotType==="auto"?"Auto Save":"Manual Save"),1)):b.createCommentVNode("",!0)])]),b.createElementVNode("div",qZ,[(b.openBlock(!0),b.createElementBlock(b.Fragment,null,b.renderList(t.actions,(m,g)=>(b.openBlock(),b.createElementBlock("button",{class:"button",onClick:()=>u(g),key:g},[b.createElementVNode("h3",null,b.toDisplayString(m),1)],8,HZ))),128))])])]))}}),yie="",WZ=b.createElementVNode("h3",{class:"title"},"Confirmation",-1),UZ={class:"flex justify-center"},lp=b.defineComponent({__name:"yes-no",props:{prompt:{type:String,required:!0},onConfirm:{type:Function,required:!1},onRefuse:{type:Function,required:!1}},emits:["choice"],setup(t,{emit:e}){const n=t;function r(i){i===!0&&n.onConfirm?n.onConfirm():i===!1&&n.onRefuse&&n.onRefuse(),e("choice",i)}return(i,o)=>(b.openBlock(),b.createBlock(Go,{onClose:o[2]||(o[2]=()=>r(!1)),containerCssClass:"yes-no-modal"},{header:b.withCtx(()=>[WZ]),body:b.withCtx(()=>[b.createElementVNode("h3",null,b.toDisplayString(t.prompt),1),b.createElementVNode("div",UZ,[b.createElementVNode("button",{class:"button",onClick:o[0]||(o[0]=()=>r(!0))},"Yes"),b.createElementVNode("button",{class:"button",onClick:o[1]||(o[1]=()=>r(!1))},"No")])]),_:1}))}}),bie="",JZ={class:"title"},GZ={key:0},KZ={class:"saves-section"},QZ=b.createElementVNode("h3",{class:"saves-section-title"},"Auto save",-1),YZ={class:"saves-section"},XZ=b.createElementVNode("h3",{class:"saves-section-title"},"Manual Saves",-1),ZZ={key:1,class:"saves-section"},eee=b.createElementVNode("h3",{class:"saves-section-title"},"Save Slots",-1),tee={class:"saves-container flex flex-col"},YI=b.defineComponent({__name:"save-slots",props:{mode:{type:String,required:!0}},emits:["chosen","close"],setup(t,{emit:e}){const n=t,r=b.reactive([]),i=b.computed(()=>r.slice(0,1)),o=b.computed(()=>r.slice(1)),a=b.reactive(n.mode==="load"?["Load","Delete"]:["Choose"]),s=b.computed(()=>lt().saves.mode),u=b.reactive({prompt:"Are you sure you want to delete this save file?",saveToDelete:null,onConfirm:()=>{d(u.saveToDelete),u.saveToDelete=null},onRefuse:()=>{u.saveToDelete=null}}),l=b.reactive({prompt:"Are you sure you want to overwrite this save file?",saveToOverwrite:null,onConfirm:()=>{f(l.saveToOverwrite),l.saveToOverwrite=null},onRefuse:()=>{l.saveToOverwrite=null}});b.onMounted(()=>{const g=w7().slots;console.log(g),g.forEach((y,k)=>{r[k]=y})});function f(m){e("chosen",{slotId:m})}function c(m){const g=v(m);if(g){if(lt().saves.mode==="manual"&&g.slotType==="auto"){Ft().alert("Sorry","Can't delete the auto save slot!");return}u.saveToDelete=m}}function d(m){JK(m);const g=r.find(y=>y.id===m);g&&(g.saveData=null)}function h(){e("close")}function p(m,g){const y=a[g];y==="Load"?f(m):y==="Delete"?c(m):y==="Choose"&&(l.saveToOverwrite=m)}function v(m){return r.find(g=>g.id===m)}return(m,g)=>(b.openBlock(),b.createBlock(Go,{onClose:h,containerCssClass:"save-modal",cantClose:!1},{header:b.withCtx(()=>[b.createElementVNode("h3",JZ,b.toDisplayString(t.mode==="load"?"Choose a save to load":"Pick a slot to save the game"),1)]),body:b.withCtx(()=>[b.unref(s)==="manual"?(b.openBlock(),b.createElementBlock("div",GZ,[b.createElementVNode("div",KZ,[QZ,b.createVNode(b.TransitionGroup,{name:"list",tag:"div"},{default:b.withCtx(()=>[(b.openBlock(!0),b.createElementBlock(b.Fragment,null,b.renderList(b.unref(i),y=>(b.openBlock(),b.createBlock(Qy,{key:y.id,saveSlot:y,id:y.id,actions:a,onChoice:k=>p(y.id,k)},null,8,["saveSlot","id","actions","onChoice"]))),128))]),_:1})]),b.createElementVNode("div",YZ,[XZ,b.createVNode(b.TransitionGroup,{name:"list",tag:"div"},{default:b.withCtx(()=>[(b.openBlock(!0),b.createElementBlock(b.Fragment,null,b.renderList(b.unref(o),y=>(b.openBlock(),b.createBlock(Qy,{key:y.id,saveSlot:y,id:y.id,actions:y.saveData?a:[],onChoice:k=>p(y.id,k)},null,8,["saveSlot","id","actions","onChoice"]))),128))]),_:1})])])):(b.openBlock(),b.createElementBlock("div",ZZ,[eee,b.createElementVNode("div",tee,[b.createVNode(b.TransitionGroup,{name:"list",tag:"div"},{default:b.withCtx(()=>[(b.openBlock(!0),b.createElementBlock(b.Fragment,null,b.renderList(r,y=>(b.openBlock(),b.createBlock(Qy,{key:y.id,saveSlot:y,id:y.id,actions:y.saveData?a:[],onChoice:k=>p(y.id,k)},null,8,["saveSlot","id","actions","onChoice"]))),128))]),_:1})])])),u.saveToDelete?(b.openBlock(),b.createBlock(lp,{key:2,prompt:u.prompt,onRefuse:u.onRefuse,onConfirm:u.onConfirm},null,8,["prompt","onRefuse","onConfirm"])):b.createCommentVNode("",!0),l.saveToOverwrite?(b.openBlock(),b.createBlock(lp,{key:3,prompt:l.prompt,onRefuse:l.onRefuse,onConfirm:l.onConfirm},null,8,["prompt","onRefuse","onConfirm"])):b.createCommentVNode("",!0)]),_:1}))}}),kie="",nee={id:"game-menu"},ree={id:"game-header",class:"flex flex-col justify-between items-center"},iee={id:"game-title-container"},oee={id:"game-title-text"},aee={class:"flex flex-col start-menu-buttons-container"},see=b.defineComponent({__name:"StartMenu",setup(t){const e=b.ref(!1),n=b.ref(!1),r=b.ref(null),i=b.ref(null),o=b.ref(!1),a=b.ref(!1);async function s(){e.value&<().saves.mode==="manual"?a.value=!0:u()}async function u(){const v=Ft();if(i.value===null)if(lt().saves.mode==="manual"){const m=Ay();if(!m){bn("No autosave found");return}i.value=m.id}else{const m=WK();if(!m){bn("No free slot found");return}i.value=m}a.value=!1,await v.startGame(i.value)}function l(){a.value=!1}async function f(){if(!i.value)return;const v=Mc(i.value);if(!v){bn("No save file found");return}Ft().loadGame(v,i.value)}function c(){typeof r.value=="string"&&(i.value=r.value,f())}function d(){o.value=!0}function h({slotId:v}){i.value=v,Mc(v)?f():s()}b.onMounted(()=>{const v=lt();v.audioOptions.defaultMusic&&Cr().playChannel("music",v.audioOptions.defaultMusic,0);const m=w7();m.slots.some(g=>g.saveData)&&(e.value=!0),(lt().saves.mode==="manual"||m.slots.some(g=>!g.saveData))&&(n.value=!0),m.lastSaveSlot&&Mc(m.lastSaveSlot)&&(r.value=m.lastSaveSlot)});const p=b.computed(()=>lt().gameTitle);return(v,m)=>(b.openBlock(),b.createElementBlock("div",nee,[o.value?(b.openBlock(),b.createBlock(YI,{key:0,mode:"load",onChosen:h,onClose:m[0]||(m[0]=g=>o.value=!1)})):b.createCommentVNode("",!0),a.value?(b.openBlock(),b.createBlock(lp,{key:1,prompt:"This will override your previous autosave, are you sure?",onConfirm:u,onRefuse:l})):b.createCommentVNode("",!0),b.createElementVNode("div",ree,[b.createElementVNode("div",iee,[b.createElementVNode("h1",oee,b.toDisplayString(b.unref(p)),1)]),b.createElementVNode("div",aee,[r.value?(b.openBlock(),b.createElementBlock("button",{key:0,class:"button menu-button main-menu-button large continue-button override",onClick:c}," Continue ")):b.createCommentVNode("",!0),n.value?(b.openBlock(),b.createElementBlock("button",{key:1,class:"button menu-button main-menu-button large start-button override",onClick:s}," New Game ")):b.createCommentVNode("",!0),e.value?(b.openBlock(),b.createElementBlock("button",{key:2,class:"button menu-button main-menu-button large continue-button override",onClick:d}," Load Game ")):b.createCommentVNode("",!0)])])]))}}),wie="";class uee extends F7{setup(e=!1){const r=e?"keydown":"keyup",i=QI(o=>{Xa.emit("debouncedKeydown",o)},10,{isImmediate:!0,maxWait:10});window.addEventListener("keydown",o=>{Xa.emit("keydown",o)}),window.addEventListener(r,o=>{i(o)})}}const Xa=new uee,lee={class:"title"},cee=b.defineComponent({__name:"alert-modal",props:{title:{type:String,required:!1},text:{type:String,required:!1}},setup(t){return(e,n)=>(b.openBlock(),b.createBlock(Go,{onClose:n[0]||(n[0]=r=>e.$emit("close")),containerCssClass:"yes-no-modal"},{header:b.withCtx(()=>{var r;return[b.createElementVNode("h3",lee,b.toDisplayString((r=t.title)!=null?r:"Alert"),1)]}),body:b.withCtx(()=>[b.createElementVNode("h3",null,b.toDisplayString(t.text),1)]),_:1}))}}),xie="",fee=b.defineComponent({props:{pictureUrl:String},methods:{getAssetUrl(t){return Qa(t)}},computed:{...da(Ai,["layoutMode"]),boxStyle(){var o,a,s,u,l,f;const t=Ai(),e=lt().layout;let n=0,r=0;const i=e.portraits;if(this.layoutMode==="vertical"){const c=(a=(o=i.offset)==null?void 0:o.portrait)!=null?a:{right:0,bottom:0};n=20+c.right,r=t.dialogHeight+c.bottom}else{const c=(u=(s=i.offset)==null?void 0:s.landscape)!=null?u:{right:0,bottom:0},d=(f=(l=e.dialogPanel)==null?void 0:l.rightOffset)!=null?f:0;n=e.minTextWidth-10+c.right+d,r=200+c.bottom}return{right:`${n}px`,bottom:`${r}px`,width:`${e.portraits.width}px`,height:`${e.portraits.height}px`}}}}),jie="",dee=["src"];function hee(t,e,n,r,i,o){return b.openBlock(),b.createElementBlock("div",{class:"dialog-picture override",style:b.normalizeStyle(t.boxStyle)},[b.createElementVNode("img",{src:t.getAssetUrl(t.pictureUrl),class:"picture override"},null,8,dee)],4)}const pee=di(fee,[["render",hee]]),vee=b.defineComponent({data(){return{playerText:"",passed:!1,listener:null,timeout:null}},props:{options:{type:Object,required:!0},active:Boolean},mounted(){if(this.canInteract){const t=e=>{if(this.canInteract&&this.options.textField&&e.key==="Enter"&&this.submitText(),this.canInteract&&!this.options.textField){let n=-1;switch(e.key){case" ":n=0;break;case"1":n=0;break;case"2":n=1;break;case"3":n=2;break;case"4":n=3;break;case"5":n=4;break;case"6":n=5;break;case"7":n=6;break;case"8":n=7;break}n!==-1&&(this.choices&&n<this.choices.length?this.chooseOption(this.choices[n]):this.chooseOption(n))}};this.listener=Xa.on("debouncedKeydown",t),this.timeout=setTimeout(()=>{this.options.textField&&this.$refs.playerInput.focus()},10)}},unmounted(){this.clearListeners()},computed:{...da(Ft,["paused"]),preText(){return this.options.title?" \u2013 ":""},style(){return Gh(this.options.styleId)},dialogBoxStyle(){const t=Gh(this.options.styleId),e={opacity:this.options.old?"0.7":"1"};return{...t.boxCss,...e}},dialogBoxClass(){return this.options.title?!1:"dialog-box-followup"},titleStyle(){const t=Gh(this.options.styleId);return{color:t.color,...t.nameCss}},textStyle(){return Gh(this.options.styleId).textCss},choices(){if(this.options.choices)return this.options.choices},canInteract(){return this.active&&!this.passed&&this.options.interactive&&!this.paused}},methods:{clearListeners(){this.listener&&(Xa.off("keydown",this.listener),this.listener=null),this.timeout&&(clearTimeout(this.timeout),this.timeout=null)},chooseOption(t){this.finishLine();let e;typeof t=="object"?e=t.originalIndex:e=t,Ft().playerAnswered(e)},finishLine(){this.clearListeners(),this.passed=!0},dialogStyle(t){const e={};return t.allowed||(e.pointerEvents="none",e.textDecoration="line-through"),e},dialogClass(t){if(!t.allowed)return"strike-anim"},submitText(){const t=this.playerText;Ft().playerAnswered(t)}}}),_ie="",mee={class:"dialog-content"},gee=["innerHTML"],yee=["innerHTML"],bee=["innerHTML"],kee={key:1,class:"dialog-choices"},wee=["onClick","innerHTML"],xee={key:2},jee={key:3,class:"buttons-container"};function _ee(t,e,n,r,i,o){return b.openBlock(),b.createElementBlock("div",{class:b.normalizeClass(["dialog-box w-full override",t.dialogBoxClass]),style:b.normalizeStyle(t.dialogBoxStyle)},[b.createElementVNode("div",mee,[t.options.title?(b.openBlock(),b.createElementBlock("span",{key:0,class:"dialog-title override",style:b.normalizeStyle(t.titleStyle),innerHTML:t.options.title},null,12,gee)):b.createCommentVNode("",!0),b.createElementVNode("span",{class:"dialog-text dialog-separator override",style:b.normalizeStyle(t.textStyle),innerHTML:t.preText},null,12,yee),b.createElementVNode("span",{class:b.normalizeClass(["dialog-text override",t.options.cssClass]),style:b.normalizeStyle(t.textStyle),innerHTML:t.options.text},null,14,bee),t.canInteract&&t.choices?(b.openBlock(),b.createElementBlock("div",kee,[(b.openBlock(!0),b.createElementBlock(b.Fragment,null,b.renderList(t.choices,(a,s)=>(b.openBlock(),b.createElementBlock("p",{key:s,style:b.normalizeStyle(t.dialogStyle(a)),class:b.normalizeClass([t.dialogClass(a),"dialog-choice override"]),onClick:u=>t.chooseOption(a),ref_for:!0,ref:"choices",innerHTML:`${s+1}. \u2013\xA0 ${a.choice}`},null,14,wee))),128))])):t.canInteract&&t.options.textField?(b.openBlock(),b.createElementBlock("div",xee,[b.withDirectives(b.createElementVNode("input",{type:"text",class:"label-input input",ref:"playerInput",id:"player-input-field","onUpdate:modelValue":e[0]||(e[0]=a=>t.playerText=a)},null,512),[[b.vModelText,t.playerText]]),b.createElementVNode("button",{onClick:e[1]||(e[1]=(...a)=>t.submitText&&t.submitText(...a)),class:"button",id:"player-input-submit"}," Submit ")])):t.canInteract?(b.openBlock(),b.createElementBlock("div",jee,[b.createElementVNode("div",{onClick:e[2]||(e[2]=a=>t.chooseOption(0)),ref:"continue",class:"interact-button button override"}," Continue ",512)])):b.createCommentVNode("",!0)])],6)}const See=di(vee,[["render",_ee]]),Cee=b.createElementVNode("div",{class:"anchor"},null,-1),$ee=b.defineComponent({__name:"game-dialog",props:{layoutMode:String,inGame:Boolean},setup(t){const e=t,n=ln(),r=b.computed(()=>n.stack),i=ti(),o=b.computed(()=>i.dialog),a=b.ref(null),s=b.computed(()=>e.layoutMode==="vertical"?{}:{paddingBottom:`${lt().layout.dialogBottomPadding}px`}),u=b.computed(()=>{if(o.value.length>0)return o.value[o.value.length-1]}),l=b.computed(()=>{if(u.value)return PK(u.value.speaker,u.value.pose)}),f=b.computed(()=>lt().layout.minTextWidth),c=b.computed(()=>!Ai().overlayMode||Ai().layoutMode==="vertical"?!0:Ft().inScript),d=b.computed(()=>{var y,k;let v;const m=`${Ai().dialogHeight}px`,g={};if(Ai().overlayMode){g.position="absolute";const w=(k=(y=lt().layout.dialogPanel)==null?void 0:y.rightOffset)!=null?k:0;g.right=`${w}px`}return{...g,width:e.layoutMode==="horizontal"?`${f.value}px`:"100%",height:m,transform:v,transformOrigin:"right"}});function h(v,m){let y=Cy(v.speaker).name;return m>=1&&o.value[m-1].speaker===v.speaker&&(y=void 0),v.choices&&v.choices.forEach(k=>{k.choice=Xh(k.choice)}),{title:y!=null?y:"",text:v.text,cssClass:v.cssClass,styleId:v.speaker,choices:v.choices,old:m<o.value.length-1,interactive:v.interactive,textField:v.textField}}function p(v){return v===i.dialog.length-1&&r.value.length>0}return b.watch(o.value,v=>{if(a.value){const m=a.value;m.scrollTop=m.scrollHeight+1e8}}),(v,m)=>(b.openBlock(),b.createElementBlock(b.Fragment,null,[b.createVNode(b.Transition,{name:"fade"},{default:b.withCtx(()=>[b.unref(l)?(b.openBlock(),b.createBlock(pee,{key:0,pictureUrl:b.unref(l)},null,8,["pictureUrl"])):b.createCommentVNode("",!0)]),_:1}),b.createVNode(b.Transition,{name:"dialog-transition"},{default:b.withCtx(()=>[t.inGame&&b.unref(c)?(b.openBlock(),b.createElementBlock("div",{key:0,class:"dialog override card-5",ref_key:"dialogRef",ref:a,style:b.normalizeStyle(b.unref(d))},[b.createVNode(b.TransitionGroup,{name:"list",tag:"div",class:"dialog-container w-full override",style:b.normalizeStyle(b.unref(s))},{default:b.withCtx(()=>[(b.openBlock(!0),b.createElementBlock(b.Fragment,null,b.renderList(b.unref(o),(g,y)=>(b.openBlock(),b.createBlock(See,{key:g.id,options:h(g,y),active:p(y)},null,8,["options","active"]))),128))]),_:1},8,["style"]),Cee],4)):b.createCommentVNode("",!0)]),_:1})],64))}}),Sie="",Aee={class:"menu-container"},Eee=["onClick","id"],Oee=b.defineComponent({__name:"menu-buttons",setup(t){const e=Ft(),n=b.ref(null);b.onMounted(()=>{n.value=Xa.on("keydown",s=>{s.key==="Escape"&&Ft().toggleMenu()}),qn.callHook("onGameMounted")}),b.onUnmounted(()=>{Xa.off("keydown",n.value),qn.callHook("onGameUnmounted")});function r(s){s.onClick?s.onClick():Ft().openModal(s.id)}const i=b.computed(()=>Ja().buttonsToShow),o=b.computed(()=>Ft().modal),a=b.computed(()=>{if(o.value){const s=Ja().buttons.find(u=>u.id===o.value);if(s)return s.component}return!1});return(s,u)=>(b.openBlock(),b.createElementBlock("div",Aee,[(b.openBlock(!0),b.createElementBlock(b.Fragment,null,b.renderList(b.unref(i),l=>{var f;return b.openBlock(),b.createElementBlock("button",{key:l.id,onClick:c=>r(l),id:(f=l.cssId)!=null?f:`${l.id}-menu-button`,class:"button menu-toggle-button"},b.toDisplayString(l.text),9,Eee)}),128)),b.unref(o)?(b.openBlock(),b.createBlock(b.Teleport,{key:0,to:"#app-container"},[(b.openBlock(),b.createBlock(b.resolveDynamicComponent(b.unref(a)),{onClose:u[0]||(u[0]=()=>b.unref(e).closeModal())},null,32))])):b.createCommentVNode("",!0)]))}}),Cie="",Mee=["id"],Tee=["id","onClick","innerHTML"],Iee=["id","onClick"],Yy=b.defineComponent({__name:"screen-layer",props:{layer:String,transitioning:{type:Boolean,default:!1}},setup(t){const e=t,n=ln(),r=Ft(),i=po(),o=zs(),a=b.computed(()=>o.sprites),s=b.computed(()=>lt().layout.backgrounds.width),u=b.computed(()=>lt().layout.backgrounds.height),l=b.computed(()=>e.layer),f=b.computed(()=>i.buttons),c=b.computed(()=>{const j=lt().screens[l.value];if(!j)throw new Error(`Screen ${l.value} doesn't have a config`);return j}),d=b.computed(()=>r.isInGame),h=b.computed(()=>c.value.buttons||[]);function p(j){const _=el(j).background;if(!!_)return sp(_)}function v(j){const S=el(j),_=f.value[j],R=S.tag||"default",O=_.state;return O===!0&&kr().isInteractionTagBlocked(R)?"greyed":O}function m(j){const S=v(j);return S==="hidden"||S==="greyed"||S===!1}function g(j){const S=v(j),_={};S===!0?_.interactable=!0:(_.disabled=!0,S==="greyed"?_.greyed=!0:(S==="hidden"||S===!1)&&(_.hidden=!0));const R=el(j);return R.cssClass&&(_[R.cssClass]=!0),_}function y(j){const S=el(j),_={};v(j),S.position.width&&(_.width=`${S.position.width}px`),S.position.height&&(_.height=`${S.position.height}px`),S.background&&(_.backgroundImage=`url(${p(j)})`);let R=S.position.left,O=S.position.top;return S.anchor&&(R=S.position.left-S.position.width*S.anchor.x,O=S.position.top-S.position.height*S.anchor.y),{..._,left:`${R}px`,top:`${O}px`}}function k(j){if(m(j)||e.transitioning)return;const S=el(j);if(f.value[j].state===!0){Bs("onButtonClicked");const R=S.action;S.actionType==="run"?n.runLabelFunction(R):n.jumpToLabel(R)}}function w(j){var R;const _=(R=el(j).text)!=null?R:"";return Xh(_)}const x=b.computed(()=>({backgroundImage:`url(${sp(c.value.background)})`,width:`${s.value}px`,height:`${u.value}px`}));function A(j){e.transitioning||j.onClick&&(Bs("onSpriteClicked"),n.runLabelFunction(j.onClick))}function $(j){const S={};return j.onClick?S.interactable=!0:S.disabled=!0,j.cssClass&&(S[j.cssClass]=!0),S}function N(j){const S={};j.opacity!==1&&(S.opacity=j.opacity);let _=j.x,R=j.y;if(j.anchor){const F=j.anchor;_=j.x-j.width*F.x,R=j.y-j.height*F.y,S.transformOrigin=`${F.x*100}% ${F.y*100}%`}let O=j.width,E=j.height;return j.scale&&(O=O*j.scale,E=E*j.scale),{...S,left:`${_}px`,top:`${R}px`,backgroundImage:`url(${sp(j.image)})`,width:`${O}px`,height:`${E}px`}}return(j,S)=>b.unref(d)?(b.openBlock(),b.createElementBlock("div",{key:0,class:"viewport-layer",id:`viewport-layer-${b.unref(l)}`,style:b.normalizeStyle(b.unref(x))},[(b.openBlock(!0),b.createElementBlock(b.Fragment,null,b.renderList(b.unref(h),(_,R)=>(b.openBlock(),b.createElementBlock("div",{key:R,tabindex:"-1",class:b.normalizeClass(["viewport-button",g(_)]),id:`viewport-button-${_}`,onClick:O=>k(_),style:b.normalizeStyle(y(_)),innerHTML:w(_)},null,14,Tee))),128)),(b.openBlock(!0),b.createElementBlock(b.Fragment,null,b.renderList(b.unref(a),_=>(b.openBlock(),b.createElementBlock("div",{key:_.id,tabindex:"-1",class:b.normalizeClass(["viewport-sprite",$(_)]),id:`viewport-sprite-${_.id}`,onClick:R=>A(_),style:b.normalizeStyle(N(_))},null,14,Iee))),128))],12,Mee)):b.createCommentVNode("",!0)}}),$ie="",Nee=b.defineComponent({__name:"NarratTransition",props:{name:{type:String,required:!0},duration:{type:Number,required:!0},delay:Number},emits:["complete"],setup(t,{emit:e}){const n=t,r=b.useSlots(),i=b.ref("start"),o=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()=>{var s;const a=`narrat-transition-${n.name}`;o.newSlotClasses={[`${a}-enter-from`]:!0,[`${a}-enter-active`]:!0},o.oldSlotStyle={transitionDuration:`${n.duration/1e3}s`},o.newSlotStyle={transitionDuration:`${n.duration/1e3}s`},o.oldSlotClasses={[`${a}-leave-active`]:!0},await co(30),o.oldSlotClasses[`${a}-leave-to`]=!0,await co((s=n.delay)!=null?s:0),delete o.newSlotClasses[`${a}-enter-from`],await co(n.duration),delete o.newSlotClasses[`${a}-enter-active`],delete o.oldSlotClasses[`${a}-leave-active`],i.value="end",e("complete")}),(a,s)=>(b.openBlock(),b.createElementBlock(b.Fragment,null,[i.value!=="end"?(b.openBlock(),b.createElementBlock("div",{key:0,class:b.normalizeClass(["transition-holder",o.oldSlotClasses]),style:b.normalizeStyle(o.oldSlotStyle)},[b.renderSlot(a.$slots,"oldElement")],6)):b.createCommentVNode("",!0),b.createElementVNode("div",{class:b.normalizeClass(["transition-holder",o.newSlotClasses]),style:b.normalizeStyle(o.newSlotStyle)},[b.renderSlot(a.$slots,"newElement")],6)],64))}}),Aie="",Pee=b.defineComponent({__name:"screens",setup(t){const e=Ai(),n=Ft(),r=po(),i=b.computed(()=>r.nonEmptyLayers),o=b.computed(()=>e.layoutMode),a=b.computed(()=>lt().layout.backgrounds.width),s=b.computed(()=>lt().layout.backgrounds.height),u=b.computed(()=>n.isInGame);function l(c){r.finishTransition(c)}const f=b.computed(()=>{const c=a.value,d=s.value;return o.value,{height:`${d}px`,width:`${c}px`}});return(c,d)=>b.unref(u)?(b.openBlock(),b.createElementBlock("div",{key:0,class:"viewport",id:"narrat-viewport",style:b.normalizeStyle(b.unref(f))},[(b.openBlock(!0),b.createElementBlock(b.Fragment,null,b.renderList(b.unref(i),(h,p)=>(b.openBlock(),b.createElementBlock("div",{key:p,class:"layer-container"},[h.transition?(b.openBlock(),b.createBlock(Nee,{key:0,name:h.transition.transition,duration:h.transition.duration,delay:h.transition.delay,onComplete:()=>l(p)},{oldElement:b.withCtx(()=>[h.transition.oldScreen?(b.openBlock(),b.createBlock(Yy,{key:0,layer:h.transition.oldScreen,transitioning:!0},null,8,["layer"])):b.createCommentVNode("",!0)]),newElement:b.withCtx(()=>[h.screen?(b.openBlock(),b.createBlock(Yy,{key:0,layer:h.screen,transitioning:!0},null,8,["layer"])):b.createCommentVNode("",!0)]),_:2},1032,["name","duration","delay","onComplete"])):h.screen?(b.openBlock(),b.createBlock(Yy,{key:1,layer:h.screen},null,8,["layer"])):b.createCommentVNode("",!0)]))),128))],4)):b.createCommentVNode("",!0)}}),Eie="",Lee=b.defineComponent({data(){return{}},methods:{getStatImage(t){return Qa(this.statsConfig[t].icon)}},computed:{...da(Uo,["hudStats"]),...da(Ai,["layoutMode"]),statsConfig(){return lt().hudStats},stats(){return this.hudStats},hudStyle(){let t="0";return this.layoutMode==="horizontal"&&(t=`${lt().layout.minTextWidth}px`),{right:t}}}}),Oie="",Dee=["src"],Ree={class:"bold hud-text"},Bee=b.createTextVNode(": ");function zee(t,e,n,r,i,o){return b.openBlock(),b.createElementBlock("div",{class:"hud",style:b.normalizeStyle(t.hudStyle)},[(b.openBlock(!0),b.createElementBlock(b.Fragment,null,b.renderList(t.stats,(a,s)=>(b.openBlock(),b.createElementBlock("div",{key:s,class:"hud-stat"},[b.createElementVNode("img",{class:"hud-icon",src:t.getStatImage(s)},null,8,Dee),b.createElementVNode("span",Ree,b.toDisplayString(t.statsConfig[s].name),1),Bee,b.createElementVNode("span",null,b.toDisplayString(Math.floor(a.value*100)/100),1)]))),128))],4)}const Fee=di(Lee,[["render",zee]]),Vee=b.defineComponent({__name:"in-game",setup(t){const e=Ft(),n=Ai(),r=b.computed(()=>n.layoutMode),i=b.computed(()=>e.saving),o=b.ref(null),a=b.computed(()=>i.value&&!i.value.withPrompt||i.value&&o.value),s=b.computed(()=>{let c="row";return r.value==="vertical"&&(c="column"),{flexDirection:c}});function u(c){if(o.value=null,c===null){Ft().finishManualSave(c,!1);return}Ft().finishManualSave(c,!0)}function l(){o.value=!0}function f(){o.value=!1,e.finishManualSave(null,!1),o.value=null}return(c,d)=>(b.openBlock(),b.createElementBlock("div",{class:"game",style:b.normalizeStyle(b.unref(s))},[b.createVNode(Fee),b.createVNode(Oee,{class:"menu-toggle"}),b.createVNode(Pee),b.createVNode($ee,{inGame:!0,layoutMode:b.unref(r)},null,8,["layoutMode"]),b.unref(a)?(b.openBlock(),b.createBlock(YI,{key:0,mode:"pick",onChosen:u,onClose:d[0]||(d[0]=()=>u(null))})):b.createCommentVNode("",!0),b.unref(i)&&b.unref(i).withPrompt&&o.value===null?(b.openBlock(),b.createBlock(lp,{key:1,prompt:"Would you like to save the game?",onConfirm:l,onRefuse:f})):b.createCommentVNode("",!0)],4))}}),Mie="",qee=b.defineComponent({props:{percentage:Number,step:String},methods:{loadingStyle(){return{width:`${this.percentage*60}vw`}}},computed:{}}),Tie="",Hee={id:"loading-bar"},Wee={id:"loading-text"};function Uee(t,e,n,r,i,o){return b.openBlock(),b.createElementBlock("div",Hee,[b.createElementVNode("div",{id:"inner-loading-bar",style:b.normalizeStyle(t.loadingStyle())},null,4),b.createElementVNode("div",Wee,[b.createElementVNode("h3",null,"Loading "+b.toDisplayString(Math.floor(t.percentage*100))+"% - "+b.toDisplayString(t.step),1)])])}const Jee=di(qee,[["render",Uee]]),Gee="data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4KPCEtLSBHZW5lcmF0b3I6IEFkb2JlIElsbHVzdHJhdG9yIDE5LjAuMCwgU1ZHIEV4cG9ydCBQbHVnLUluIC4gU1ZHIFZlcnNpb246IDYuMDAgQnVpbGQgMCkgIC0tPgo8c3ZnIHZlcnNpb249IjEuMSIgaWQ9IlJhdCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgeD0iMHB4IiB5PSIwcHgiCgkgdmlld0JveD0iMCAwIDU5NS4zIDU5NS4zIiBzdHlsZT0iZW5hYmxlLWJhY2tncm91bmQ6bmV3IDAgMCA1OTUuMyA1OTUuMzsiIHhtbDpzcGFjZT0icHJlc2VydmUiPgo8c3R5bGUgdHlwZT0idGV4dC9jc3MiPgoJLnN0MHtmaWxsOiNFMjNCMzM7fQo8L3N0eWxlPgo8cGF0aCBpZD0iUmF0X1NoYXBlIiBjbGFzcz0ic3QwIiBkPSJNNTU2LjksODIuNWMtMTAuOC0yNC4zLTQ3LTU3LjEtNzEuMy02NS42Yy0yNC4zLTguNC02NC4xLTAuMy04OC43LDIyLjMKCWMtMjAsMTguNC0yNiwyOC4yLTI5LjEsMzdjLTIuMSw1LjktNC44LDEzLjUtNiwyMC45djBjLTAuNSw0LjEtNC41LDctOC42LDYuMWMtMTAuNC0yLjMtMjkuNS02LTQ0LjQtNi4zCgljLTEzLjctMC4yLTMwLjEsMy4yLTQwLjQsNS43Yy00LjUsMS4xLTguOC0yLjItOC44LTYuOGMtMC4xLTUuMy0xLjEtMTIuMy00LjgtMTkuNmMtOC41LTE2LjktMTkuNi0zMi42LTU3LjgtNDcuNAoJYy0zMS45LTEyLjQtNzUuMS05LjctMTAwLjgsMS44Yy0yOC4xLDEyLjYtNDIuNCwzNy45LTU0LDYxLjhjLTE0LjQsMjkuOC0xNC45LDgzLjYtNi40LDEwNGMxMi44LDMwLjcsMzUuOCw0Ny4yLDUyLjYsNTMKCWMxMS4zLDMuOCwyOC4yLDMuNywzOC4yLDMuM2M0LjItMC4yLDcuNywzLjMsNy41LDcuNWMtMC43LDEzLjYtMC45LDQxLjUsNyw2MS40YzcuNywxOS40LDI5LjcsNjIuMyw1MC43LDEwMS4yCgljMCwwLjEtMTQuNiwyLjktMzEuNCw2LjhjLTIzLjksNS41LTUyLjYsMTIuNy01NC4zLDEzLjdjLTMuNSwyLjEtMywxMC0yLjcsMTJjMC41LDMuNCw1LjMsOC4xLDYuOSw4LjNjMy45LDAuMywzMS4zLTcuNiw1NS43LTE0LjYKCWMxOC41LTUuMywzNC45LTkuMywzNS41LTguMmM1LjEsOS4zLDEwLDE4LDE0LjQsMjUuOGM1LjIsOS4xLDEwLjcsMTYuNCwxNC4xLDIzLjZjMS4xLDIuMy0xNi42LDUuOC0zMi41LDE0LjcKCWMtMTYuNCw5LjEtMjkuNywyMS0zMi4zLDI0Yy0xLjgsMi4xLTMsNi0xLjIsMTAuN2MxLjEsMi45LDEwLDUuNywxMi40LDUuMWM2LjgtMS43LDE2LjUtMTIuNSwzMy4xLTIxLjEKCWMxNi4zLTguNSwzMi45LTE0LjksMzMuOC0xMy42YzkuNywxNC4zLDE2LjksMjEuNiwyMi42LDMxLjJjOS44LDE2LjUsMjcuMyw0NS45LDQ2LjYsMzkuNWM2LjQtMi4xLDMxLjEtMzMuNiw1My4zLTY4LjYKCWMxLjMtMi4xLDE2LjEsMTEuMywzMC40LDIzLjJjMTMuOCwxMS40LDIyLjcsMjAuNiwyNy4xLDIxLjRjNS40LDEsMTQuMi03LjcsMTQuMS0xNC43Yy0wLjEtMi43LTE0LjMtMTMuOC0yOS4xLTI2LjIKCWMtMTQuNS0xMi4xLTMwLjEtMjIuOC0yOS4yLTI0LjNjNy42LTEyLDE0LjUtMjMuNywyMC4xLTMzLjljNC4zLTcuOCw4LjktMTYsMTMtMjQuN2MwLjYtMS4yLDE1LjksMywzMS40LDcuMWMxNS4zLDQsMjYuNywxMCwzMSw4CgljNi45LTMsMTEuNi0xMy44LDkuNC0xOC4zYy0xLjEtMi4zLTE3LTcuMy0zMy4yLTEyYy0xNC4yLTQuMS0yOC02LjUtMjcuNy03LjNjMTUuNS0zNCwyOC44LTY0LjgsMjcuNi02OS42CgljLTEuNy03LjEsMi42LTExLjksNy0zNi41YzMuMi0xOC4xLDQuNy00MC45LDUuMi01MS43YzAuMi0zLjUsMi44LTYuMyw2LjMtNi43YzMuMS0wLjMsNi45LTAuOSwxMC41LTEuOWM3LjgtMiwxOC42LTcuOCwzNi40LTIwLjYKCWMxNy45LTEyLjgsMzguNy00OS42LDQ0LjQtNjcuOFM1NjcuNiwxMDYuOCw1NTYuOSw4Mi41eiBNMjY1LjEsMzM2LjJjLTguMSw0LTEzLDctMjYuNCw5LjZjLTYuOSwxLjQtMjkuNC0wLjItNDAuNy00LjYKCWMtMTAuNS00LjEtMTkuOS03LjYtMzAtMTUuNHMtMTUuNy0xMy4yLTE1LjctMTUuM2MwLTQuNCw2LTkuNCwxMS05LjRjNS4xLDAsMTQuNSw5LjIsMjkuNywxNi42YzE0LjMsNywxNy45LDYuMSwyNS40LDcuMwoJYzIuOSwwLjUsNy43LDAuNiwxMC43LDAuNGMxNC4xLTEuMywyMS40LTUuOSwyNS4zLTguOGM0LTMsMTMuNy0xMi45LDE3LjItMTIuNWM4LDEsMTguOSwzLjQsMTguOSw3LjEKCUMyOTAuNCwzMTksMjczLjIsMzMyLjEsMjY1LjEsMzM2LjJ6IE0zMjAuOSw1MjEuNGMtNC4zLDMuNy0xNy43LDEzLjUtMjMuMywxMy41Yy0yLjgsMC03LjQtOC4yLTExLjUtMTYuOAoJYy00LjEtOC41LTkuMS0yMS4xLTkuMS0zMS42YzAtNC42LDYtNy40LDEzLjQtOS4yYzcuMi0xLjcsMjcuMy0xLjgsMjkuOS0xLjFjNi44LDEuNywxMi45LDIuMiwxMi43LDYuNGMtMC40LDEyLjctNywxOC45LTguMywyNC4zCglDMzIzLjQsNTEyLjMsMzIzLjQsNTE5LjIsMzIwLjksNTIxLjR6IE00MzEuMSwzMjAuM2MtOS4yLDcuNC0xMC42LDguMS0yNC45LDEzLjdjLTExLjMsNC40LTI4LjYsNS44LTQxLjYsMy42CgljLTEyLjItMi4xLTIyLjMtNC42LTI5LjUtMTAuMWMtOS43LTcuMy0xNi40LTE1LjEtMTYuNC0xOS44YzAtMy43LDYuNC00LjMsMTQuNS00LjljMy41LTAuMyw5LjMsNS45LDEzLjIsOS4yCgljOC4xLDYuOCwxNC44LDgsMjguOCw5LjljMi45LDAuNCw3LjgsMC40LDEwLjcsMC4xYzcuNS0wLjksMTItMC40LDI1LjgtOC4yYzIwLTExLjIsMTcuOC0xNC40LDI1LjEtMTIuNmMyLjIsMC42LDUuOCwxLjIsNS42LDUuNgoJQzQ0Mi40LDMwOSw0NDAuNSwzMTIuNyw0MzEuMSwzMjAuM3oiLz4KPC9zdmc+Cg==",Kee={id:"engine-splash-screen",class:"flex justify-center items-center"},Qee={id:"engine-splash-title"},Yee=["src"],Xee=b.defineComponent({__name:"engine-splash",emits:["finished"],setup(t,{emit:e}){const n=b.ref("hidden"),r=b.computed(()=>({transitionDuration:`${l.value}s`})),i=b.computed(()=>({invisible:n.value!=="appear"})),o=Ft(),a=b.computed(()=>{var d,h;return(h=(d=lt().splashScreens)==null?void 0:d.engineSplashScreen)!=null?h:{}}),s=b.computed(()=>typeof a.value.overrideText=="string"?a.value.overrideText:"Made with narrat engine"),u=b.computed(()=>{var d;return(d=a.value.overrideLogo)!=null?d:Gee}),l=b.computed(()=>typeof a.value.fadeDuration=="number"?a.value.fadeDuration:2),f=b.computed(()=>typeof a.value.timeBeforeFadeout=="number"?a.value.timeBeforeFadeout:3);b.onMounted(async()=>{if(await co(10),n.value="appear",a.value.skip||o.options.debug){c();return}await co(l.value*1e3),await co(f.value*1e3),n.value="disappear",await co(l.value*1e3),c()});function c(){o.loading.loaded?e("finished"):o.listener.once("gameLoaded",()=>{e("finished")})}return(d,h)=>(b.openBlock(),b.createElementBlock("div",Kee,[b.createElementVNode("div",{id:"engine-splash-header",class:b.normalizeClass(["flex justify-center flex-col items-center",b.unref(i)]),style:b.normalizeStyle(b.unref(r))},[b.createElementVNode("h1",Qee,b.toDisplayString(b.unref(s)),1),b.createElementVNode("img",{src:b.unref(u),alt:"Narrat Logo",id:"engine-splash-logo"},null,8,Yee),b.createVNode(Jee,{percentage:b.unref(o).loading.percentage,step:b.unref(o).loading.step},null,8,["percentage","step"])],6)]))}}),Iie="",Zee={id:"game-splash-screen",style:{height:"100%",padding:"20px"},class:"flex justify-center items-center"},ete={id:"game-splash-screen-header flex justify-center flex-col items-center",class:"flex justify-center flex-col items-center"},tte={class:"title",id:"game-splash-title"},nte=b.defineComponent({__name:"game-splash",setup(t){const e=Ft(),n=b.computed(()=>{var s,u;return(u=(s=lt().splashScreens)==null?void 0:s.gameSplashScreen)!=null?u:{}}),r=b.computed(()=>typeof n.value.startButtonText=="string"?n.value.startButtonText:"Press to start"),i=b.computed(()=>e.loading.loaded),o=b.computed(()=>lt().gameTitle||"Narrat Game");function a(){e.flowState="menu"}return b.onMounted(()=>{e.options.debug&&a()}),(s,u)=>(b.openBlock(),b.createElementBlock("div",Zee,[b.createElementVNode("div",ete,[b.createElementVNode("h1",tte,b.toDisplayString(b.unref(o)),1),b.unref(i)?(b.openBlock(),b.createElementBlock("button",{key:0,class:"button menu-button main-menu-button large splash-start-button override",onClick:a},b.toDisplayString(b.unref(r)),1)):b.createCommentVNode("",!0)])]))}}),Nie="",rte=b.defineComponent({setup(){const t=ti(),e=ln(),n=Ft();return{dialog:b.computed(()=>t.dialog),stack:b.computed(()=>e.stack),modal:b.computed(()=>n.modal),flowState:b.computed(()=>n.flowState),alerts:b.computed(()=>n.alerts)}},$refs:{dialogContainer:HTMLInputElement},inject:["mq"],components:{DebugMenu:AZ,NotificationToast:TZ,StartMenu:see,AlertModal:cee,InGame:Vee,EngineSplash:Xee,GameSplash:nte},data(){return{lineTitle:"title",lineText:"hello"}},props:{options:Object},async mounted(){qn.callHook("onAppMounted"),await Ft().engineLoading(),window.addEventListener("resize",QI(()=>{this.updateScreenSize()},100,{maxWait:200})),Xa.setup(this.options.debug),setTimeout(()=>{this.updateScreenSize()},50)},computed:{...da(Ai,["screenWidth","screenHeight","layoutMode","gameWidth","gameHeight","gameScaleRatio","actualGameHeight"]),...da(ln,["currentLine"]),appStyle(){return{transform:`scale(${this.gameScaleRatio}, ${this.gameScaleRatio})`,width:`${this.gameWidth}px`,height:`${this.actualGameHeight}px`}},appClass(){return Ft().modal?"app-blurred-by-modal":{}}},methods:{closeAlert(t){Ft().closeAlert(t)},engineSplashDone(){Ft().flowState="game-splash"},updateScreenSize(){Ai().updateScreenSize(window.innerWidth,window.innerHeight)}}}),Pie="";function ite(t,e,n,r,i,o){const a=b.resolveComponent("EngineSplash"),s=b.resolveComponent("GameSplash"),u=b.resolveComponent("StartMenu"),l=b.resolveComponent("InGame"),f=b.resolveComponent("DebugMenu"),c=b.resolveComponent("NotificationToast"),d=b.resolveComponent("AlertModal");return b.openBlock(),b.createElementBlock("div",{id:"app-container",style:b.normalizeStyle(t.appStyle)},[b.createElementVNode("div",{id:"app",class:b.normalizeClass(t.appClass)},[t.flowState==="engine-splash"?(b.openBlock(),b.createBlock(a,{key:0,onFinished:t.engineSplashDone},null,8,["onFinished"])):(b.openBlock(),b.createBlock(b.Transition,{key:1,name:"screens-fade"},{default:b.withCtx(()=>[t.flowState==="game-splash"?(b.openBlock(),b.createBlock(s,{key:"1"})):t.flowState==="menu"?(b.openBlock(),b.createBlock(u,{key:"2"})):t.flowState==="playing"?(b.openBlock(),b.createBlock(l,{key:"3"})):b.createCommentVNode("",!0)]),_:1})),t.options.debug?(b.openBlock(),b.createBlock(f,{key:2})):b.createCommentVNode("",!0),b.createVNode(c),(b.openBlock(!0),b.createElementBlock(b.Fragment,null,b.renderList(t.alerts,h=>(b.openBlock(),b.createBlock(d,{key:h.id,title:h.title,text:h.text,onClose:()=>t.closeAlert(h.id)},null,8,["title","text","onClose"]))),128))],2)],4)}const ote=di(rte,[["render",ite]]);function gn(t,e){console.error("Runtime error ========================="),console.error(`Command: ${t.commandType}`),console.error("Args: ",t.args),console.error("Options: ",t.options),bn(`Runtime error at ${t.fileName}:${t.line} (${t.commandType}) ${t.code}. -
|
|
214
|
+
`:""}var DX=LX,RX={dump:DX};function Jy(t,e){return function(){throw new Error("Function yaml."+t+" is removed in js-yaml 4. Use yaml."+e+" instead, which is now safe by default.")}}var BX=$r,zX=W7,FX=K7,VX=eI,qX=tI,HX=Ry,WX=_I.load,UX=_I.loadAll,JX=RX.dump,GX=ni,KX={binary:aI,float:Z7,map:G7,null:Q7,pairs:uI,set:lI,timestamp:iI,bool:Y7,int:X7,merge:oI,omap:sI,seq:J7,str:U7},QX=Jy("safeLoad","load"),YX=Jy("safeLoadAll","loadAll"),XX=Jy("safeDump","dump"),ZX={Type:BX,Schema:zX,FAILSAFE_SCHEMA:FX,JSON_SCHEMA:VX,CORE_SCHEMA:qX,DEFAULT_SCHEMA:HX,load:WX,loadAll:UX,dump:JX,YAMLException:GX,types:KX,safeLoad:QX,safeLoadAll:YX,safeDump:XX};function HI(t){return new Promise((e,n)=>{const r=new XMLHttpRequest;r.onload=function(){r.status>=200&&r.status<300?e(r.responseText):(bn(`Failed to load file ${t}`,r.status),n(r.status))},r.open("GET",t),r.send()})}async function pa(t){try{const e=await HI(t);let n;if(t.endsWith(".json"))n=JSON.parse(e);else if(t.endsWith(".yaml"))n=ZX.load(e);else{const r=`Unsupported file type for data file ${t} (must be .json or .yaml)`;throw new Error(r)}if(!n)throw new Error(`Data loaded from ${t} is empty`);return n}catch(e){throw console.error(`Failed to load data file ${t}: ${e}`),e}}let Bt;async function eZ(t){Bt={...nK},t.baseAssetsPath&&(Bt.baseAssetsPath=t.baseAssetsPath),t.baseDataPath&&(Bt.baseDataPath=t.baseDataPath);const e=await pa(t.configPath);if(Bt={...Bt,...e},typeof Bt.screens=="string"){const n=await pa(Ya(Bt.screens));Bt.screens=n}if(typeof Bt.buttons=="string"){const n=await pa(Ya(Bt.buttons));Bt.buttons=n}if(typeof Bt.skills=="string"){const n=await pa(Ya(Bt.skills));Bt.skills=n.skills,Bt.skillOptions={...Bt.skillOptions,...n.options},Bt.skillChecks={...Bt.skillChecks,...n.skillChecks}}if(typeof Bt.scripts=="string"){const n=await pa(Ya(Bt.scripts));Bt.scripts=n}if(typeof Bt.audio=="string"){const n=await pa(Ya(Bt.audio));Bt.audio=n.files,Bt.audioOptions={...Bt.audioOptions,...n.options}}if(typeof Bt.items=="string"){const n=await pa(Ya(Bt.items));Bt.items=n}if(typeof Bt.quests=="string"){const n=await pa(Ya(Bt.quests));Bt.quests=n}if(Bt.transitions)for(const n in Bt.transitions)ep[n]?Object.assign(ep[n],Bt.transitions[n]):ep[n]=Bt.transitions[n]}function lt(){return Bt}function WI(t){const e=Bt.skills[t];return e||bn(`Skill config for skill ${t} doesn't exist`),e}function sp(t){return t.startsWith("http")?t:Bt.images[t]?Qa(Bt.images[t]):Qa(t)}function Qa(t){return t.startsWith("http")?t:Bt.baseAssetsPath?`${Bt.baseAssetsPath}${t}`:t}function Ya(t){return Bt.baseDataPath?`${Bt.baseDataPath}${t}`:t}function el(t){return Bt.buttons[t]}function UI(t){const e=Bt.items[t];return e||bn(`Item config for skill ${t} doesn't exist`),e}function up(t){return Bt.quests[t]}function Gy(t,e){return up(t).objectives[e]}function Ky(t,e){const n=e.split(".");let r=t;const i=n.length-1;let o=n[0],a=0;for(a=0;a<i;a++)o=n[a],r[o]||(r[o]={}),r=r[o];return o=n[a],[r,o]}function tZ(t,e){const n=e.split(".");let r=t;const i=n.length-1;let o=n[0],a=0;for(a=0;a<i;a++)o=n[a],r[o]||(r[o]={}),r=r[o];return o=n[a],typeof r[o]>"u"&&(r[o]=null),[r,o]}function JI(t,e,n){const[r,i]=Ky(t,e);r[i]=n}function GI(t,e,n){const[r,i]=Ky(t,e),o=r[i]||0;r[i]=n+o}function tl(){const t=ln(),e=hr(),n=po(),r=kr(),i=ln().scope,o={data:t.data,skills:e.skills,buttons:n.buttons,items:r.items,quests:zr().quests,stats:Uo().hudStats,scope:i,config:lt(),gameOptions:Ft().options};return new Proxy(o,{get:(s,u,l)=>{const f=ln().scope,c=ln().data;return typeof f[u]<"u"?f[u]:typeof c[u]<"u"?c[u]:Reflect.get(s,u,l)},set:(s,u,l,f)=>{const c=ln().scope,d=ln().data;if(typeof c[u]<"u")c[u]=l;else{if(typeof s[u]<"u")return Reflect.set(s,u,l,f);typeof l=="object"?d[u]={}:d[u]=l}return!0}})}function fi(t){if(typeof t=="object"){if(Array.isArray(t))return t.map(fi);{const e={};for(const n in t)e[n]=fi(t[n]);return e}}else return t}const hr=Ci("skills",{state:()=>({skillChecks:{},skills:{}}),actions:{setupSkillCheck(t,e){this.skillChecks[e]=t},passSkillCheck(t,e){this.skillChecks[t].happened=!0,this.skillChecks[t].succeeded=!0,e&&(this.skillChecks[t].hidden=!0)},failSkillCheck(t,e){this.skillChecks[t].happened=!0,this.skillChecks[t].succeeded=!1,e&&(this.skillChecks[t].hidden=!0)},generateSaveData(){return{skillChecks:fi(this.skillChecks),skills:fi(this.skills)}},getSkillCheck(t){return this.skillChecks[t]||this.setupSkillCheck(this.createSkillCheckState(),t),this.skillChecks[t]},createSkillCheckState(){return{happened:!1,succeeded:!1,hidden:!1}},loadSaveData(t){this.skillChecks=Zh(this.skillChecks,t.skillChecks),this.skills=Zh(this.skills,t.skills)},setupSkills(t){for(const e in t)this.skills[e]={id:e,level:t[e].startingLevel||0,xp:0}},getSkill(t){return this.skills[t]},getSkillLevel(t){return this.getSkill(t).level},getSkillXp(t){return this.getSkill(t).xp},addXp(t,e){const n=this.getSkill(t);n||bn(`Skill ${t} doesn't exist`),n.xp+=e,n.xp>=lt().skillOptions.xpPerLevel&&(n.xp=0,n.level++,this.levelledUp(t))},setSkillLevel(t,e){const n=this.getSkill(t);n||bn(`Skill ${t} doesn't exist`),n.level=e,this.levelledUp(t)},incrementSkill(t,e){this.getSkill(t).level+=e,this.levelledUp(t)},levelledUp(t){const e=lt().skills[t].name,n=this.skills[t].level;lt().skillOptions.notifyLevelUp&&$i().addNotification(`Your skill in ${e} is now level ${n}`)}}});let KI;const nZ=b.defineComponent({components:{Modal:Go},setup(){const t=hr(),e=b.computed(()=>t.skills),n=b.computed(()=>t.skillChecks);return{skills:e,skillChecks:n}},data(){return{showDebug:!1,jumping:!1,searchString:"",matches:[],matchCursor:0}},mounted(){window.addEventListener("keydown",t=>{if(this.jumping||(t.key==="d"&&this.toggle(),t.key==="j"&&this.jump()),t.key==="ArrowDown"&&(t.preventDefault(),this.matches.length>this.matchCursor+1?this.matchCursor+=1:this.matchCursor=0),t.key==="ArrowUp"&&(t.preventDefault(),this.matchCursor>0?this.matchCursor-=1:this.matchCursor=this.matches.length-1),t.key==="Escape"&&(this.finishJumping(),this.showDebug=!1),this.jumping&&t.key==="Enter"&&this.matchCursor<this.matches.length){const e=this.matches[this.matchCursor];ln().jumpToLabel(e),this.finishJumping()}})},methods:{finishJumping(){this.jumping=!1,this.matches=[],this.searchString=""},labelSelected(t){const e=t.target.value;ln().jumpToLabel(e),this.close()},close(){this.showDebug=!1},closeErrors(){Ft().clearErrors()},open(){this.showDebug=!0;const t=ln(),e=Ft(),n=zr(),r=kr(),i=hr();this.$nextTick(()=>{new H8({target:this.$refs.variablesViewer,props:{content:{text:void 0,json:{data:this.variables,quests:n.quests,items:r.items,skills:i.skills,skillChecks:i.skillChecks}},onChange:o=>{t.overrideData(o.json.data),n.quests=o.json.quests,r.items=o.json.items,i.skills=o.json.skills,i.skillChecks=o.json.skillChecks}}}),new H8({target:this.$refs.stateViewer,props:{content:{text:void 0,json:e.getAllStates()},onChange:o=>{e.overrideStates(o.json)}}})})},toggle(){this.showDebug?this.showDebug=!1:this.jumping?this.finishJumping():this.open()},jump(){KI=new Js(this.labels,{includeScore:!0}),this.jumping=!0,setTimeout(()=>{this.$nextTick(()=>{this.$refs.search.focus()})},10),this.matchCursor=0,this.matches=this.labels},getMatchResultStyle(t){if(t===this.matchCursor)return{background:"var(--light-background)"}},onSearchInput(){const t=this.searchString;console.log(t);const e=KI.search(t);this.matches=e.map(n=>n.item),this.matches.length>0&&this.matchCursor>this.matches.length-1&&(this.matchCursor=this.matches.length-1)},save(){Ft().autoSaveGame({})},wordCount(){const e=Object.values(this.script).reduce((n,r)=>(bo.log(n),n+this.countWordsInScriptBranch(r.branch)),0);alert(`You have ${e} words`)},countWordsInScriptLine(t){if(t.command.commandType==="talk"&&typeof t.command.args[2]=="string")return this.countWordsInString(t.command.args[2]);if(t.command.commandType==="text")return this.countWordsInString(t.code);if(t.command.commandType==="choice"){const e=t.command.staticOptions;let n=this.countWordsInScriptLine(e.prompt);return n+=e.choices.reduce((i,o)=>i+this.countWordsInString(o.prompt.code),0),e.choices.reduce((i,o)=>o.branch?i+this.countWordsInScriptBranch(o.branch):i,n)}if(t.command.commandType==="if"){const e=t.command.staticOptions;return[e.success,e.failure].reduce((r,i)=>i?r+this.countWordsInScriptBranch(i):r,0)}return 0},countWordsInString(t){return t.split(" ").length},countWordsInScriptBranch(t){return t.reduce((e,n)=>n?e+this.countWordsInScriptLine(n):e,0)},getPlayTimeString(){const t=Wc(this.playTime.start,this.playTime.previousPlaytime);return gp(t/1e3)}},computed:{...da(ln,["script","data"]),...da(Ft,["playTime","errors","playing","flowState"]),labels(){const t=this.script;return Object.keys(t).sort()},variables(){return this.data}}}),hie="",rZ={class:"debug-menu"},iZ={key:0,class:"debug-info"},oZ=[b.createElementVNode("h3",null,"Debug mode is ON",-1),b.createElementVNode("ul",null,[b.createElementVNode("li",null,[b.createElementVNode("b",null,"j"),b.createTextVNode(": Quick Label Jump")]),b.createElementVNode("li",null,[b.createElementVNode("b",null,"d"),b.createTextVNode(": Debug Menu")]),b.createElementVNode("li",null,[b.createElementVNode("b",null,"Escape"),b.createTextVNode(": Toggle Menu")])],-1)],aZ=b.createElementVNode("h3",{class:"title"},"Jump to label",-1),sZ={key:0,class:"search-results"},uZ={key:1},lZ=[b.createElementVNode("h3",null,"No matches found",-1)],cZ=b.createElementVNode("h3",{class:"title"},"Error(s)",-1),fZ=b.createTextVNode(" There are errors in your dialogue scripts. Open the developer console for more details. "),dZ=["innerHTML"],hZ=b.createElementVNode("h3",{class:"title"},"Debug Menu!",-1),pZ={class:"container"},vZ=b.createTextVNode(" Hello this is the debug menu. "),mZ=b.createElementVNode("option",{class:"option",selected:"",disabled:""},"Jump to a label",-1),gZ=["value"],yZ={class:"grid grid-cols-3 gap-4"},bZ=b.createElementVNode("h2",null,"Variables Editor",-1),kZ={ref:"variablesViewer"},wZ=b.createElementVNode("h2",null,"Skill Checks",-1),xZ={class:"table-auto"},jZ=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),_Z=b.createElementVNode("h2",null,"App State editor (entire app and engine",-1),SZ=b.createElementVNode("h3",{style:{color:"pink"}}," Use for debugging, editing some of those things can cause issues ",-1),CZ={ref:"stateViewer"};function $Z(t,e,n,r,i,o){const a=b.resolveComponent("modal");return b.openBlock(),b.createElementBlock("div",rZ,[b.createElementVNode("button",{onClick:e[0]||(e[0]=(...s)=>t.open&&t.open(...s)),class:"button debug-button"},"Debug Menu"),!t.playing&&t.flowState==="menu"?(b.openBlock(),b.createElementBlock("div",iZ,oZ)):b.createCommentVNode("",!0),t.jumping?(b.openBlock(),b.createBlock(a,{key:1,onClose:t.finishJumping,containerCssClass:"jump-menu-container"},{header:b.withCtx(()=>[aZ]),body:b.withCtx(()=>[b.withDirectives(b.createElementVNode("input",{type:"text",class:"label-input input",ref:"search","onUpdate:modelValue":e[1]||(e[1]=s=>t.searchString=s),onInput:e[2]||(e[2]=(...s)=>t.onSearchInput&&t.onSearchInput(...s))},null,544),[[b.vModelText,t.searchString]]),t.matches.length>0?(b.openBlock(),b.createElementBlock("div",sZ,[(b.openBlock(!0),b.createElementBlock(b.Fragment,null,b.renderList(t.matches,(s,u)=>(b.openBlock(),b.createElementBlock("div",{class:"search-result",style:b.normalizeStyle(t.getMatchResultStyle(u)),key:u},b.toDisplayString(s),5))),128))])):(b.openBlock(),b.createElementBlock("div",uZ,lZ))]),_:1},8,["onClose"])):b.createCommentVNode("",!0),t.errors.length>0?(b.openBlock(),b.createBlock(a,{key:2,onClose:t.closeErrors,containerCssClass:"debug-menu-container"},{header:b.withCtx(()=>[cZ]),body:b.withCtx(()=>[fZ,b.createElementVNode("ul",null,[(b.openBlock(!0),b.createElementBlock(b.Fragment,null,b.renderList(t.errors,(s,u)=>(b.openBlock(),b.createElementBlock("li",{key:u,class:b.normalizeClass(["error-message list-disc",s.type==="error"?"error":"warning"]),innerHTML:s.text},null,10,dZ))),128))])]),_:1},8,["onClose"])):b.createCommentVNode("",!0),t.showDebug?(b.openBlock(),b.createBlock(a,{key:3,onClose:t.close,containerCssClass:"debug-menu-container"},{header:b.withCtx(()=>[hZ]),body:b.withCtx(()=>[b.createElementVNode("div",pZ,[vZ,b.createElementVNode("select",{class:"select",name:"label-selector",onChange:e[3]||(e[3]=s=>t.labelSelected(s))},[mZ,(b.openBlock(!0),b.createElementBlock(b.Fragment,null,b.renderList(t.labels,s=>(b.openBlock(),b.createElementBlock("option",{class:"option",value:s,key:s},b.toDisplayString(s),9,gZ))),128))],32),b.createElementVNode("div",yZ,[b.createElementVNode("button",{onClick:e[4]||(e[4]=(...s)=>t.wordCount&&t.wordCount(...s)),class:"button"},"Word Count"),b.createElementVNode("button",{onClick:e[5]||(e[5]=(...s)=>t.save&&t.save(...s)),class:"button"},"Save Game")]),b.createElementVNode("h3",null,"Play time: "+b.toDisplayString(t.getPlayTimeString()),1),bZ,b.createElementVNode("div",kZ,null,512),wZ,b.createElementVNode("table",xZ,[jZ,b.createElementVNode("tbody",null,[(b.openBlock(!0),b.createElementBlock(b.Fragment,null,b.renderList(t.skillChecks,(s,u)=>(b.openBlock(),b.createElementBlock("tr",{key:u},[b.createElementVNode("td",null,b.toDisplayString(u),1),b.createElementVNode("td",null,b.toDisplayString(s.happened?"\u2705":"\u274C"),1),b.createElementVNode("td",null,b.toDisplayString(s.happened?s.succeeded?"\u2705":"\u274C":"NA"),1)]))),128))])]),_Z,SZ,b.createElementVNode("div",CZ,null,512)])]),_:1},8,["onClose"])):b.createCommentVNode("",!0)])}const AZ=di(nZ,[["render",$Z]]),EZ=b.defineComponent({computed:{...da($i,["notifications"])}}),gie="",OZ=["innerHTML"];function MZ(t,e,n,r,i,o){return 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(t.notifications,(a,s)=>(b.openBlock(),b.createElementBlock("div",{class:"notification",key:s},[b.createElementVNode("h3",{innerHTML:a.text},null,8,OZ)]))),128))]),_:1})}const TZ=di(EZ,[["render",MZ]]);function QI(t,e=50,n={}){var c,d;let r;const i=(c=n.isImmediate)!=null?c:!1,o=(d=n.callback)!=null?d:!1,a=n.maxWait;let s=Date.now(),u=[];function l(){if(a!==void 0){const h=Date.now()-s;if(h+e>=a)return a-h}return e}const f=function(...h){const p=this;return new Promise((v,m)=>{const g=function(){if(r=void 0,s=Date.now(),!i){const w=t.apply(p,h);o&&o(w),u.forEach(({resolve:x})=>x(w)),u=[]}},y=i&&r===void 0;r!==void 0&&clearTimeout(r);const k=l();if(r=setTimeout(g,k),y){const w=t.apply(p,h);return o&&o(w),v(w)}u.push({resolve:v,reject:m})})};return f.cancel=function(h){r!==void 0&&clearTimeout(r),u.forEach(({reject:p})=>p(h)),u=[]},f}const IZ={class:"save-slot flex flex-row"},NZ={class:"used-save-slot flex flex-row justify-between items-center grow"},PZ={class:"flex flex-col save-slot-number-container"},LZ={class:"save-slot-number"},DZ={class:"flex flex-col justify-center save-info"},RZ={key:1,class:"save-name"},BZ={class:"flex flex-col"},zZ={key:0},FZ={key:1},VZ={key:2},qZ={class:"flex flex-row"},HZ=["onClick"],Qy=b.defineComponent({__name:"save-slot-ui",props:{saveSlot:{type:Object,required:!0},id:{type:String,required:!0},actions:{type:Array,required:!0}},emits:["choice"],setup(t,{emit:e}){var d,h;const n=t,r=b.ref((h=(d=n.saveSlot.saveData)==null?void 0:d.metadata.name)!=null?h:"Empty Save"),i=b.computed(()=>n.saveSlot.saveData!==null),o=b.computed(()=>n.saveSlot.saveData),a=b.computed(()=>lt().saves.mode),s=b.computed(()=>{const p=n.saveSlot.saveData;if(p&&p.screen.layers[0]){const v=lt().screens[p.screen.layers[0]];if(v)return{backgroundImage:`url(${sp(v.background)})`}}return!1});function u(p){e("choice",p)}function l(p){return o.value?gp(o.value.main.playTime/1e3):"00:00:00"}function f(){o.value&&GK(n.saveSlot.id,r.value)}function c(){const p=lt().saves.slots;let v="";const m=n.saveSlot.slotNumber;return m===0&<().saves.mode==="manual"?"AUTO":(p>=10&&m<10&&(v+="0"),p>=100&&m<100&&(v+="0"),v+m)}return(p,v)=>(b.openBlock(),b.createElementBlock("div",IZ,[b.createElementVNode("div",NZ,[b.createElementVNode("div",PZ,[b.createElementVNode("h1",LZ,b.toDisplayString(c()),1)]),b.unref(s)?(b.openBlock(),b.createElementBlock("div",{key:0,class:"save-slot-screenshot",style:b.normalizeStyle(b.unref(s))},null,4)):b.createCommentVNode("",!0),b.createElementVNode("div",DZ,[b.unref(i)?b.withDirectives((b.openBlock(),b.createElementBlock("input",{key:0,type:"text",class:"save-name","onUpdate:modelValue":v[0]||(v[0]=m=>r.value=m),onInput:f},null,544)),[[b.vModelText,r.value]]):(b.openBlock(),b.createElementBlock("h3",RZ,b.toDisplayString(r.value),1)),b.createElementVNode("div",BZ,[b.unref(o)?(b.openBlock(),b.createElementBlock("p",zZ,b.toDisplayString(new Date(b.unref(o).metadata.saveDate).toLocaleString()),1)):b.createCommentVNode("",!0),b.unref(o)?(b.openBlock(),b.createElementBlock("p",FZ,"Play time: "+b.toDisplayString(l(t.saveSlot)),1)):b.createCommentVNode("",!0),b.unref(a)==="game-slots"?(b.openBlock(),b.createElementBlock("p",VZ,b.toDisplayString(t.saveSlot.slotType==="auto"?"Auto Save":"Manual Save"),1)):b.createCommentVNode("",!0)])]),b.createElementVNode("div",qZ,[(b.openBlock(!0),b.createElementBlock(b.Fragment,null,b.renderList(t.actions,(m,g)=>(b.openBlock(),b.createElementBlock("button",{class:"button",onClick:()=>u(g),key:g},[b.createElementVNode("h3",null,b.toDisplayString(m),1)],8,HZ))),128))])])]))}}),yie="",WZ=b.createElementVNode("h3",{class:"title"},"Confirmation",-1),UZ={class:"flex justify-center"},lp=b.defineComponent({__name:"yes-no",props:{prompt:{type:String,required:!0},onConfirm:{type:Function,required:!1},onRefuse:{type:Function,required:!1}},emits:["choice"],setup(t,{emit:e}){const n=t;function r(i){i===!0&&n.onConfirm?n.onConfirm():i===!1&&n.onRefuse&&n.onRefuse(),e("choice",i)}return(i,o)=>(b.openBlock(),b.createBlock(Go,{onClose:o[2]||(o[2]=()=>r(!1)),containerCssClass:"yes-no-modal"},{header:b.withCtx(()=>[WZ]),body:b.withCtx(()=>[b.createElementVNode("h3",null,b.toDisplayString(t.prompt),1),b.createElementVNode("div",UZ,[b.createElementVNode("button",{class:"button",onClick:o[0]||(o[0]=()=>r(!0))},"Yes"),b.createElementVNode("button",{class:"button",onClick:o[1]||(o[1]=()=>r(!1))},"No")])]),_:1}))}}),bie="",JZ={class:"title"},GZ={key:0},KZ={class:"saves-section"},QZ=b.createElementVNode("h3",{class:"saves-section-title"},"Auto save",-1),YZ={class:"saves-section"},XZ=b.createElementVNode("h3",{class:"saves-section-title"},"Manual Saves",-1),ZZ={key:1,class:"saves-section"},eee=b.createElementVNode("h3",{class:"saves-section-title"},"Save Slots",-1),tee={class:"saves-container flex flex-col"},YI=b.defineComponent({__name:"save-slots",props:{mode:{type:String,required:!0}},emits:["chosen","close"],setup(t,{emit:e}){const n=t,r=b.reactive([]),i=b.computed(()=>r.slice(0,1)),o=b.computed(()=>r.slice(1)),a=b.reactive(n.mode==="load"?["Load","Delete"]:["Choose"]),s=b.computed(()=>lt().saves.mode),u=b.reactive({prompt:"Are you sure you want to delete this save file?",saveToDelete:null,onConfirm:()=>{d(u.saveToDelete),u.saveToDelete=null},onRefuse:()=>{u.saveToDelete=null}}),l=b.reactive({prompt:"Are you sure you want to overwrite this save file?",saveToOverwrite:null,onConfirm:()=>{f(l.saveToOverwrite),l.saveToOverwrite=null},onRefuse:()=>{l.saveToOverwrite=null}});b.onMounted(()=>{const g=w7().slots;console.log(g),g.forEach((y,k)=>{r[k]=y})});function f(m){e("chosen",{slotId:m})}function c(m){const g=v(m);if(g){if(lt().saves.mode==="manual"&&g.slotType==="auto"){Ft().alert("Sorry","Can't delete the auto save slot!");return}u.saveToDelete=m}}function d(m){JK(m);const g=r.find(y=>y.id===m);g&&(g.saveData=null)}function h(){e("close")}function p(m,g){const y=a[g];y==="Load"?f(m):y==="Delete"?c(m):y==="Choose"&&(l.saveToOverwrite=m)}function v(m){return r.find(g=>g.id===m)}return(m,g)=>(b.openBlock(),b.createBlock(Go,{onClose:h,containerCssClass:"save-modal",cantClose:!1},{header:b.withCtx(()=>[b.createElementVNode("h3",JZ,b.toDisplayString(t.mode==="load"?"Choose a save to load":"Pick a slot to save the game"),1)]),body:b.withCtx(()=>[b.unref(s)==="manual"?(b.openBlock(),b.createElementBlock("div",GZ,[b.createElementVNode("div",KZ,[QZ,b.createVNode(b.TransitionGroup,{name:"list",tag:"div"},{default:b.withCtx(()=>[(b.openBlock(!0),b.createElementBlock(b.Fragment,null,b.renderList(b.unref(i),y=>(b.openBlock(),b.createBlock(Qy,{key:y.id,saveSlot:y,id:y.id,actions:a,onChoice:k=>p(y.id,k)},null,8,["saveSlot","id","actions","onChoice"]))),128))]),_:1})]),b.createElementVNode("div",YZ,[XZ,b.createVNode(b.TransitionGroup,{name:"list",tag:"div"},{default:b.withCtx(()=>[(b.openBlock(!0),b.createElementBlock(b.Fragment,null,b.renderList(b.unref(o),y=>(b.openBlock(),b.createBlock(Qy,{key:y.id,saveSlot:y,id:y.id,actions:a,onChoice:k=>p(y.id,k)},null,8,["saveSlot","id","actions","onChoice"]))),128))]),_:1})])])):(b.openBlock(),b.createElementBlock("div",ZZ,[eee,b.createElementVNode("div",tee,[b.createVNode(b.TransitionGroup,{name:"list",tag:"div"},{default:b.withCtx(()=>[(b.openBlock(!0),b.createElementBlock(b.Fragment,null,b.renderList(r,y=>(b.openBlock(),b.createBlock(Qy,{key:y.id,saveSlot:y,id:y.id,actions:a,onChoice:k=>p(y.id,k)},null,8,["saveSlot","id","actions","onChoice"]))),128))]),_:1})])])),u.saveToDelete?(b.openBlock(),b.createBlock(lp,{key:2,prompt:u.prompt,onRefuse:u.onRefuse,onConfirm:u.onConfirm},null,8,["prompt","onRefuse","onConfirm"])):b.createCommentVNode("",!0),l.saveToOverwrite?(b.openBlock(),b.createBlock(lp,{key:3,prompt:l.prompt,onRefuse:l.onRefuse,onConfirm:l.onConfirm},null,8,["prompt","onRefuse","onConfirm"])):b.createCommentVNode("",!0)]),_:1}))}}),kie="",nee={id:"game-menu"},ree={id:"game-header",class:"flex flex-col justify-between items-center"},iee={id:"game-title-container"},oee={id:"game-title-text"},aee={class:"flex flex-col start-menu-buttons-container"},see=b.defineComponent({__name:"StartMenu",setup(t){const e=b.ref(!1),n=b.ref(!1),r=b.ref(null),i=b.ref(null),o=b.ref(!1),a=b.ref(!1);async function s(){e.value&<().saves.mode==="manual"?a.value=!0:u()}async function u(){const v=Ft();if(i.value===null)if(lt().saves.mode==="manual"){const m=Ay();if(!m){bn("No autosave found");return}i.value=m.id}else{const m=WK();if(!m){bn("No free slot found");return}i.value=m}a.value=!1,await v.startGame(i.value)}function l(){a.value=!1}async function f(){if(!i.value)return;const v=Mc(i.value);if(!v){bn("No save file found");return}Ft().loadGame(v,i.value)}function c(){typeof r.value=="string"&&(i.value=r.value,f())}function d(){o.value=!0}function h({slotId:v}){const m=Mc(v);m&&m.saveData?(i.value=v,f()):s()}b.onMounted(()=>{const v=lt();v.audioOptions.defaultMusic&&Cr().playChannel("music",v.audioOptions.defaultMusic,0);const m=w7();m.slots.some(g=>g.saveData)&&(e.value=!0),(lt().saves.mode==="manual"||m.slots.some(g=>!g.saveData))&&(n.value=!0),m.lastSaveSlot&&Mc(m.lastSaveSlot)&&(r.value=m.lastSaveSlot)});const p=b.computed(()=>lt().gameTitle);return(v,m)=>(b.openBlock(),b.createElementBlock("div",nee,[o.value?(b.openBlock(),b.createBlock(YI,{key:0,mode:"load",onChosen:h,onClose:m[0]||(m[0]=g=>o.value=!1)})):b.createCommentVNode("",!0),a.value?(b.openBlock(),b.createBlock(lp,{key:1,prompt:"This will override your previous autosave, are you sure?",onConfirm:u,onRefuse:l})):b.createCommentVNode("",!0),b.createElementVNode("div",ree,[b.createElementVNode("div",iee,[b.createElementVNode("h1",oee,b.toDisplayString(b.unref(p)),1)]),b.createElementVNode("div",aee,[r.value?(b.openBlock(),b.createElementBlock("button",{key:0,class:"button menu-button main-menu-button large continue-button override",onClick:c}," Continue ")):b.createCommentVNode("",!0),n.value?(b.openBlock(),b.createElementBlock("button",{key:1,class:"button menu-button main-menu-button large start-button override",onClick:s}," New Game ")):b.createCommentVNode("",!0),e.value?(b.openBlock(),b.createElementBlock("button",{key:2,class:"button menu-button main-menu-button large continue-button override",onClick:d}," Load Game ")):b.createCommentVNode("",!0)])])]))}}),wie="";class uee extends F7{setup(e=!1){const r=e?"keydown":"keyup",i=QI(o=>{Xa.emit("debouncedKeydown",o)},10,{isImmediate:!0,maxWait:10});window.addEventListener("keydown",o=>{Xa.emit("keydown",o)}),window.addEventListener(r,o=>{i(o)})}}const Xa=new uee,lee={class:"title"},cee=b.defineComponent({__name:"alert-modal",props:{title:{type:String,required:!1},text:{type:String,required:!1}},setup(t){return(e,n)=>(b.openBlock(),b.createBlock(Go,{onClose:n[0]||(n[0]=r=>e.$emit("close")),containerCssClass:"yes-no-modal"},{header:b.withCtx(()=>{var r;return[b.createElementVNode("h3",lee,b.toDisplayString((r=t.title)!=null?r:"Alert"),1)]}),body:b.withCtx(()=>[b.createElementVNode("h3",null,b.toDisplayString(t.text),1)]),_:1}))}}),xie="",fee=b.defineComponent({props:{pictureUrl:String},methods:{getAssetUrl(t){return Qa(t)}},computed:{...da(Ai,["layoutMode"]),boxStyle(){var o,a,s,u,l,f;const t=Ai(),e=lt().layout;let n=0,r=0;const i=e.portraits;if(this.layoutMode==="vertical"){const c=(a=(o=i.offset)==null?void 0:o.portrait)!=null?a:{right:0,bottom:0};n=20+c.right,r=t.dialogHeight+c.bottom}else{const c=(u=(s=i.offset)==null?void 0:s.landscape)!=null?u:{right:0,bottom:0},d=(f=(l=e.dialogPanel)==null?void 0:l.rightOffset)!=null?f:0;n=e.minTextWidth-10+c.right+d,r=200+c.bottom}return{right:`${n}px`,bottom:`${r}px`,width:`${e.portraits.width}px`,height:`${e.portraits.height}px`}}}}),jie="",dee=["src"];function hee(t,e,n,r,i,o){return b.openBlock(),b.createElementBlock("div",{class:"dialog-picture override",style:b.normalizeStyle(t.boxStyle)},[b.createElementVNode("img",{src:t.getAssetUrl(t.pictureUrl),class:"picture override"},null,8,dee)],4)}const pee=di(fee,[["render",hee]]),vee=b.defineComponent({data(){return{playerText:"",passed:!1,listener:null,timeout:null}},props:{options:{type:Object,required:!0},active:Boolean},mounted(){if(this.canInteract){const t=e=>{if(this.canInteract&&this.options.textField&&e.key==="Enter"&&this.submitText(),this.canInteract&&!this.options.textField){let n=-1;switch(e.key){case" ":n=0;break;case"1":n=0;break;case"2":n=1;break;case"3":n=2;break;case"4":n=3;break;case"5":n=4;break;case"6":n=5;break;case"7":n=6;break;case"8":n=7;break}n!==-1&&(this.choices&&n<this.choices.length?this.chooseOption(this.choices[n]):this.chooseOption(n))}};this.listener=Xa.on("debouncedKeydown",t),this.timeout=setTimeout(()=>{this.options.textField&&this.$refs.playerInput.focus()},10)}},unmounted(){this.clearListeners()},computed:{...da(Ft,["paused"]),preText(){return this.options.title?" \u2013 ":""},style(){return Gh(this.options.styleId)},dialogBoxStyle(){const t=Gh(this.options.styleId),e={opacity:this.options.old?"0.7":"1"};return{...t.boxCss,...e}},dialogBoxClass(){return this.options.title?!1:"dialog-box-followup"},titleStyle(){const t=Gh(this.options.styleId);return{color:t.color,...t.nameCss}},textStyle(){return Gh(this.options.styleId).textCss},choices(){if(this.options.choices)return this.options.choices},canInteract(){return this.active&&!this.passed&&this.options.interactive&&!this.paused}},methods:{clearListeners(){this.listener&&(Xa.off("keydown",this.listener),this.listener=null),this.timeout&&(clearTimeout(this.timeout),this.timeout=null)},chooseOption(t){this.finishLine();let e;typeof t=="object"?e=t.originalIndex:e=t,Ft().playerAnswered(e)},finishLine(){this.clearListeners(),this.passed=!0},dialogStyle(t){const e={};return t.allowed||(e.pointerEvents="none",e.textDecoration="line-through"),e},dialogClass(t){if(!t.allowed)return"strike-anim"},submitText(){const t=this.playerText;Ft().playerAnswered(t)}}}),_ie="",mee={class:"dialog-content"},gee=["innerHTML"],yee=["innerHTML"],bee=["innerHTML"],kee={key:1,class:"dialog-choices"},wee=["onClick","innerHTML"],xee={key:2},jee={key:3,class:"buttons-container"};function _ee(t,e,n,r,i,o){return b.openBlock(),b.createElementBlock("div",{class:b.normalizeClass(["dialog-box w-full override",t.dialogBoxClass]),style:b.normalizeStyle(t.dialogBoxStyle)},[b.createElementVNode("div",mee,[t.options.title?(b.openBlock(),b.createElementBlock("span",{key:0,class:"dialog-title override",style:b.normalizeStyle(t.titleStyle),innerHTML:t.options.title},null,12,gee)):b.createCommentVNode("",!0),b.createElementVNode("span",{class:"dialog-text dialog-separator override",style:b.normalizeStyle(t.textStyle),innerHTML:t.preText},null,12,yee),b.createElementVNode("span",{class:b.normalizeClass(["dialog-text override",t.options.cssClass]),style:b.normalizeStyle(t.textStyle),innerHTML:t.options.text},null,14,bee),t.canInteract&&t.choices?(b.openBlock(),b.createElementBlock("div",kee,[(b.openBlock(!0),b.createElementBlock(b.Fragment,null,b.renderList(t.choices,(a,s)=>(b.openBlock(),b.createElementBlock("p",{key:s,style:b.normalizeStyle(t.dialogStyle(a)),class:b.normalizeClass([t.dialogClass(a),"dialog-choice override"]),onClick:u=>t.chooseOption(a),ref_for:!0,ref:"choices",innerHTML:`${s+1}. \u2013\xA0 ${a.choice}`},null,14,wee))),128))])):t.canInteract&&t.options.textField?(b.openBlock(),b.createElementBlock("div",xee,[b.withDirectives(b.createElementVNode("input",{type:"text",class:"label-input input",ref:"playerInput",id:"player-input-field","onUpdate:modelValue":e[0]||(e[0]=a=>t.playerText=a)},null,512),[[b.vModelText,t.playerText]]),b.createElementVNode("button",{onClick:e[1]||(e[1]=(...a)=>t.submitText&&t.submitText(...a)),class:"button",id:"player-input-submit"}," Submit ")])):t.canInteract?(b.openBlock(),b.createElementBlock("div",jee,[b.createElementVNode("div",{onClick:e[2]||(e[2]=a=>t.chooseOption(0)),ref:"continue",class:"interact-button button override"}," Continue ",512)])):b.createCommentVNode("",!0)])],6)}const See=di(vee,[["render",_ee]]),Cee=b.createElementVNode("div",{class:"anchor"},null,-1),$ee=b.defineComponent({__name:"game-dialog",props:{layoutMode:String,inGame:Boolean},setup(t){const e=t,n=ln(),r=b.computed(()=>n.stack),i=ti(),o=b.computed(()=>i.dialog),a=b.ref(null),s=b.computed(()=>e.layoutMode==="vertical"?{}:{paddingBottom:`${lt().layout.dialogBottomPadding}px`}),u=b.computed(()=>{if(o.value.length>0)return o.value[o.value.length-1]}),l=b.computed(()=>{if(u.value)return PK(u.value.speaker,u.value.pose)}),f=b.computed(()=>lt().layout.minTextWidth),c=b.computed(()=>!Ai().overlayMode||Ai().layoutMode==="vertical"?!0:Ft().inScript),d=b.computed(()=>{var y,k;let v;const m=`${Ai().dialogHeight}px`,g={};if(Ai().overlayMode){g.position="absolute";const w=(k=(y=lt().layout.dialogPanel)==null?void 0:y.rightOffset)!=null?k:0;g.right=`${w}px`}return{...g,width:e.layoutMode==="horizontal"?`${f.value}px`:"100%",height:m,transform:v,transformOrigin:"right"}});function h(v,m){let y=Cy(v.speaker).name;return m>=1&&o.value[m-1].speaker===v.speaker&&(y=void 0),v.choices&&v.choices.forEach(k=>{k.choice=Xh(k.choice)}),{title:y!=null?y:"",text:v.text,cssClass:v.cssClass,styleId:v.speaker,choices:v.choices,old:m<o.value.length-1,interactive:v.interactive,textField:v.textField}}function p(v){return v===i.dialog.length-1&&r.value.length>0}return b.watch(o.value,v=>{if(a.value){const m=a.value;m.scrollTop=m.scrollHeight+1e8}}),(v,m)=>(b.openBlock(),b.createElementBlock(b.Fragment,null,[b.createVNode(b.Transition,{name:"fade"},{default:b.withCtx(()=>[b.unref(l)?(b.openBlock(),b.createBlock(pee,{key:0,pictureUrl:b.unref(l)},null,8,["pictureUrl"])):b.createCommentVNode("",!0)]),_:1}),b.createVNode(b.Transition,{name:"dialog-transition"},{default:b.withCtx(()=>[t.inGame&&b.unref(c)?(b.openBlock(),b.createElementBlock("div",{key:0,class:"dialog override card-5",ref_key:"dialogRef",ref:a,style:b.normalizeStyle(b.unref(d))},[b.createVNode(b.TransitionGroup,{name:"list",tag:"div",class:"dialog-container w-full override",style:b.normalizeStyle(b.unref(s))},{default:b.withCtx(()=>[(b.openBlock(!0),b.createElementBlock(b.Fragment,null,b.renderList(b.unref(o),(g,y)=>(b.openBlock(),b.createBlock(See,{key:g.id,options:h(g,y),active:p(y)},null,8,["options","active"]))),128))]),_:1},8,["style"]),Cee],4)):b.createCommentVNode("",!0)]),_:1})],64))}}),Sie="",Aee={class:"menu-container"},Eee=["onClick","id"],Oee=b.defineComponent({__name:"menu-buttons",setup(t){const e=Ft(),n=b.ref(null);b.onMounted(()=>{n.value=Xa.on("keydown",s=>{s.key==="Escape"&&Ft().toggleMenu()}),qn.callHook("onGameMounted")}),b.onUnmounted(()=>{Xa.off("keydown",n.value),qn.callHook("onGameUnmounted")});function r(s){s.onClick?s.onClick():Ft().openModal(s.id)}const i=b.computed(()=>Ja().buttonsToShow),o=b.computed(()=>Ft().modal),a=b.computed(()=>{if(o.value){const s=Ja().buttons.find(u=>u.id===o.value);if(s)return s.component}return!1});return(s,u)=>(b.openBlock(),b.createElementBlock("div",Aee,[(b.openBlock(!0),b.createElementBlock(b.Fragment,null,b.renderList(b.unref(i),l=>{var f;return b.openBlock(),b.createElementBlock("button",{key:l.id,onClick:c=>r(l),id:(f=l.cssId)!=null?f:`${l.id}-menu-button`,class:"button menu-toggle-button"},b.toDisplayString(l.text),9,Eee)}),128)),b.unref(o)?(b.openBlock(),b.createBlock(b.Teleport,{key:0,to:"#app-container"},[(b.openBlock(),b.createBlock(b.resolveDynamicComponent(b.unref(a)),{onClose:u[0]||(u[0]=()=>b.unref(e).closeModal())},null,32))])):b.createCommentVNode("",!0)]))}}),Cie="",Mee=["id"],Tee=["id","onClick","innerHTML"],Iee=["id","onClick"],Yy=b.defineComponent({__name:"screen-layer",props:{layer:String,transitioning:{type:Boolean,default:!1}},setup(t){const e=t,n=ln(),r=Ft(),i=po(),o=zs(),a=b.computed(()=>o.sprites),s=b.computed(()=>lt().layout.backgrounds.width),u=b.computed(()=>lt().layout.backgrounds.height),l=b.computed(()=>e.layer),f=b.computed(()=>i.buttons),c=b.computed(()=>{const j=lt().screens[l.value];if(!j)throw new Error(`Screen ${l.value} doesn't have a config`);return j}),d=b.computed(()=>r.isInGame),h=b.computed(()=>c.value.buttons||[]);function p(j){const _=el(j).background;if(!!_)return sp(_)}function v(j){const S=el(j),_=f.value[j],R=S.tag||"default",O=_.state;return O===!0&&kr().isInteractionTagBlocked(R)?"greyed":O}function m(j){const S=v(j);return S==="hidden"||S==="greyed"||S===!1}function g(j){const S=v(j),_={};S===!0?_.interactable=!0:(_.disabled=!0,S==="greyed"?_.greyed=!0:(S==="hidden"||S===!1)&&(_.hidden=!0));const R=el(j);return R.cssClass&&(_[R.cssClass]=!0),_}function y(j){const S=el(j),_={};v(j),S.position.width&&(_.width=`${S.position.width}px`),S.position.height&&(_.height=`${S.position.height}px`),S.background&&(_.backgroundImage=`url(${p(j)})`);let R=S.position.left,O=S.position.top;return S.anchor&&(R=S.position.left-S.position.width*S.anchor.x,O=S.position.top-S.position.height*S.anchor.y),{..._,left:`${R}px`,top:`${O}px`}}function k(j){if(m(j)||e.transitioning)return;const S=el(j);if(f.value[j].state===!0){Bs("onButtonClicked");const R=S.action;S.actionType==="run"?n.runLabelFunction(R):n.jumpToLabel(R)}}function w(j){var R;const _=(R=el(j).text)!=null?R:"";return Xh(_)}const x=b.computed(()=>({backgroundImage:`url(${sp(c.value.background)})`,width:`${s.value}px`,height:`${u.value}px`}));function A(j){e.transitioning||j.onClick&&(Bs("onSpriteClicked"),n.runLabelFunction(j.onClick))}function $(j){const S={};return j.onClick?S.interactable=!0:S.disabled=!0,j.cssClass&&(S[j.cssClass]=!0),S}function N(j){const S={};j.opacity!==1&&(S.opacity=j.opacity);let _=j.x,R=j.y;if(j.anchor){const F=j.anchor;_=j.x-j.width*F.x,R=j.y-j.height*F.y,S.transformOrigin=`${F.x*100}% ${F.y*100}%`}let O=j.width,E=j.height;return j.scale&&(O=O*j.scale,E=E*j.scale),{...S,left:`${_}px`,top:`${R}px`,backgroundImage:`url(${sp(j.image)})`,width:`${O}px`,height:`${E}px`}}return(j,S)=>b.unref(d)?(b.openBlock(),b.createElementBlock("div",{key:0,class:"viewport-layer",id:`viewport-layer-${b.unref(l)}`,style:b.normalizeStyle(b.unref(x))},[(b.openBlock(!0),b.createElementBlock(b.Fragment,null,b.renderList(b.unref(h),(_,R)=>(b.openBlock(),b.createElementBlock("div",{key:R,tabindex:"-1",class:b.normalizeClass(["viewport-button",g(_)]),id:`viewport-button-${_}`,onClick:O=>k(_),style:b.normalizeStyle(y(_)),innerHTML:w(_)},null,14,Tee))),128)),(b.openBlock(!0),b.createElementBlock(b.Fragment,null,b.renderList(b.unref(a),_=>(b.openBlock(),b.createElementBlock("div",{key:_.id,tabindex:"-1",class:b.normalizeClass(["viewport-sprite",$(_)]),id:`viewport-sprite-${_.id}`,onClick:R=>A(_),style:b.normalizeStyle(N(_))},null,14,Iee))),128))],12,Mee)):b.createCommentVNode("",!0)}}),$ie="",Nee=b.defineComponent({__name:"NarratTransition",props:{name:{type:String,required:!0},duration:{type:Number,required:!0},delay:Number},emits:["complete"],setup(t,{emit:e}){const n=t,r=b.useSlots(),i=b.ref("start"),o=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()=>{var s;const a=`narrat-transition-${n.name}`;o.newSlotClasses={[`${a}-enter-from`]:!0,[`${a}-enter-active`]:!0},o.oldSlotStyle={transitionDuration:`${n.duration/1e3}s`},o.newSlotStyle={transitionDuration:`${n.duration/1e3}s`},o.oldSlotClasses={[`${a}-leave-active`]:!0},await co(30),o.oldSlotClasses[`${a}-leave-to`]=!0,await co((s=n.delay)!=null?s:0),delete o.newSlotClasses[`${a}-enter-from`],await co(n.duration),delete o.newSlotClasses[`${a}-enter-active`],delete o.oldSlotClasses[`${a}-leave-active`],i.value="end",e("complete")}),(a,s)=>(b.openBlock(),b.createElementBlock(b.Fragment,null,[i.value!=="end"?(b.openBlock(),b.createElementBlock("div",{key:0,class:b.normalizeClass(["transition-holder",o.oldSlotClasses]),style:b.normalizeStyle(o.oldSlotStyle)},[b.renderSlot(a.$slots,"oldElement")],6)):b.createCommentVNode("",!0),b.createElementVNode("div",{class:b.normalizeClass(["transition-holder",o.newSlotClasses]),style:b.normalizeStyle(o.newSlotStyle)},[b.renderSlot(a.$slots,"newElement")],6)],64))}}),Aie="",Pee=b.defineComponent({__name:"screens",setup(t){const e=Ai(),n=Ft(),r=po(),i=b.computed(()=>r.nonEmptyLayers),o=b.computed(()=>e.layoutMode),a=b.computed(()=>lt().layout.backgrounds.width),s=b.computed(()=>lt().layout.backgrounds.height),u=b.computed(()=>n.isInGame);function l(c){r.finishTransition(c)}const f=b.computed(()=>{const c=a.value,d=s.value;return o.value,{height:`${d}px`,width:`${c}px`}});return(c,d)=>b.unref(u)?(b.openBlock(),b.createElementBlock("div",{key:0,class:"viewport",id:"narrat-viewport",style:b.normalizeStyle(b.unref(f))},[(b.openBlock(!0),b.createElementBlock(b.Fragment,null,b.renderList(b.unref(i),(h,p)=>(b.openBlock(),b.createElementBlock("div",{key:p,class:"layer-container"},[h.transition?(b.openBlock(),b.createBlock(Nee,{key:0,name:h.transition.transition,duration:h.transition.duration,delay:h.transition.delay,onComplete:()=>l(p)},{oldElement:b.withCtx(()=>[h.transition.oldScreen?(b.openBlock(),b.createBlock(Yy,{key:0,layer:h.transition.oldScreen,transitioning:!0},null,8,["layer"])):b.createCommentVNode("",!0)]),newElement:b.withCtx(()=>[h.screen?(b.openBlock(),b.createBlock(Yy,{key:0,layer:h.screen,transitioning:!0},null,8,["layer"])):b.createCommentVNode("",!0)]),_:2},1032,["name","duration","delay","onComplete"])):h.screen?(b.openBlock(),b.createBlock(Yy,{key:1,layer:h.screen},null,8,["layer"])):b.createCommentVNode("",!0)]))),128))],4)):b.createCommentVNode("",!0)}}),Eie="",Lee=b.defineComponent({data(){return{}},methods:{getStatImage(t){return Qa(this.statsConfig[t].icon)}},computed:{...da(Uo,["hudStats"]),...da(Ai,["layoutMode"]),statsConfig(){return lt().hudStats},stats(){return this.hudStats},hudStyle(){let t="0";return this.layoutMode==="horizontal"&&(t=`${lt().layout.minTextWidth}px`),{right:t}}}}),Oie="",Dee=["src"],Ree={class:"bold hud-text"},Bee=b.createTextVNode(": ");function zee(t,e,n,r,i,o){return b.openBlock(),b.createElementBlock("div",{class:"hud",style:b.normalizeStyle(t.hudStyle)},[(b.openBlock(!0),b.createElementBlock(b.Fragment,null,b.renderList(t.stats,(a,s)=>(b.openBlock(),b.createElementBlock("div",{key:s,class:"hud-stat"},[b.createElementVNode("img",{class:"hud-icon",src:t.getStatImage(s)},null,8,Dee),b.createElementVNode("span",Ree,b.toDisplayString(t.statsConfig[s].name),1),Bee,b.createElementVNode("span",null,b.toDisplayString(Math.floor(a.value*100)/100),1)]))),128))],4)}const Fee=di(Lee,[["render",zee]]),Vee=b.defineComponent({__name:"in-game",setup(t){const e=Ft(),n=Ai(),r=b.computed(()=>n.layoutMode),i=b.computed(()=>e.saving),o=b.ref(null),a=b.computed(()=>i.value&&!i.value.withPrompt||i.value&&o.value),s=b.computed(()=>{let c="row";return r.value==="vertical"&&(c="column"),{flexDirection:c}});function u(c){if(o.value=null,c===null){Ft().finishManualSave(c,!1);return}Ft().finishManualSave(c,!0)}function l(){o.value=!0}function f(){o.value=!1,e.finishManualSave(null,!1),o.value=null}return(c,d)=>(b.openBlock(),b.createElementBlock("div",{class:"game",style:b.normalizeStyle(b.unref(s))},[b.createVNode(Fee),b.createVNode(Oee,{class:"menu-toggle"}),b.createVNode(Pee),b.createVNode($ee,{inGame:!0,layoutMode:b.unref(r)},null,8,["layoutMode"]),b.unref(a)?(b.openBlock(),b.createBlock(YI,{key:0,mode:"pick",onChosen:u,onClose:d[0]||(d[0]=()=>u(null))})):b.createCommentVNode("",!0),b.unref(i)&&b.unref(i).withPrompt&&o.value===null?(b.openBlock(),b.createBlock(lp,{key:1,prompt:"Would you like to save the game?",onConfirm:l,onRefuse:f})):b.createCommentVNode("",!0)],4))}}),Mie="",qee=b.defineComponent({props:{percentage:Number,step:String},methods:{loadingStyle(){return{width:`${this.percentage*60}vw`}}},computed:{}}),Tie="",Hee={id:"loading-bar"},Wee={id:"loading-text"};function Uee(t,e,n,r,i,o){return b.openBlock(),b.createElementBlock("div",Hee,[b.createElementVNode("div",{id:"inner-loading-bar",style:b.normalizeStyle(t.loadingStyle())},null,4),b.createElementVNode("div",Wee,[b.createElementVNode("h3",null,"Loading "+b.toDisplayString(Math.floor(t.percentage*100))+"% - "+b.toDisplayString(t.step),1)])])}const Jee=di(qee,[["render",Uee]]),Gee="data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4KPCEtLSBHZW5lcmF0b3I6IEFkb2JlIElsbHVzdHJhdG9yIDE5LjAuMCwgU1ZHIEV4cG9ydCBQbHVnLUluIC4gU1ZHIFZlcnNpb246IDYuMDAgQnVpbGQgMCkgIC0tPgo8c3ZnIHZlcnNpb249IjEuMSIgaWQ9IlJhdCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgeD0iMHB4IiB5PSIwcHgiCgkgdmlld0JveD0iMCAwIDU5NS4zIDU5NS4zIiBzdHlsZT0iZW5hYmxlLWJhY2tncm91bmQ6bmV3IDAgMCA1OTUuMyA1OTUuMzsiIHhtbDpzcGFjZT0icHJlc2VydmUiPgo8c3R5bGUgdHlwZT0idGV4dC9jc3MiPgoJLnN0MHtmaWxsOiNFMjNCMzM7fQo8L3N0eWxlPgo8cGF0aCBpZD0iUmF0X1NoYXBlIiBjbGFzcz0ic3QwIiBkPSJNNTU2LjksODIuNWMtMTAuOC0yNC4zLTQ3LTU3LjEtNzEuMy02NS42Yy0yNC4zLTguNC02NC4xLTAuMy04OC43LDIyLjMKCWMtMjAsMTguNC0yNiwyOC4yLTI5LjEsMzdjLTIuMSw1LjktNC44LDEzLjUtNiwyMC45djBjLTAuNSw0LjEtNC41LDctOC42LDYuMWMtMTAuNC0yLjMtMjkuNS02LTQ0LjQtNi4zCgljLTEzLjctMC4yLTMwLjEsMy4yLTQwLjQsNS43Yy00LjUsMS4xLTguOC0yLjItOC44LTYuOGMtMC4xLTUuMy0xLjEtMTIuMy00LjgtMTkuNmMtOC41LTE2LjktMTkuNi0zMi42LTU3LjgtNDcuNAoJYy0zMS45LTEyLjQtNzUuMS05LjctMTAwLjgsMS44Yy0yOC4xLDEyLjYtNDIuNCwzNy45LTU0LDYxLjhjLTE0LjQsMjkuOC0xNC45LDgzLjYtNi40LDEwNGMxMi44LDMwLjcsMzUuOCw0Ny4yLDUyLjYsNTMKCWMxMS4zLDMuOCwyOC4yLDMuNywzOC4yLDMuM2M0LjItMC4yLDcuNywzLjMsNy41LDcuNWMtMC43LDEzLjYtMC45LDQxLjUsNyw2MS40YzcuNywxOS40LDI5LjcsNjIuMyw1MC43LDEwMS4yCgljMCwwLjEtMTQuNiwyLjktMzEuNCw2LjhjLTIzLjksNS41LTUyLjYsMTIuNy01NC4zLDEzLjdjLTMuNSwyLjEtMywxMC0yLjcsMTJjMC41LDMuNCw1LjMsOC4xLDYuOSw4LjNjMy45LDAuMywzMS4zLTcuNiw1NS43LTE0LjYKCWMxOC41LTUuMywzNC45LTkuMywzNS41LTguMmM1LjEsOS4zLDEwLDE4LDE0LjQsMjUuOGM1LjIsOS4xLDEwLjcsMTYuNCwxNC4xLDIzLjZjMS4xLDIuMy0xNi42LDUuOC0zMi41LDE0LjcKCWMtMTYuNCw5LjEtMjkuNywyMS0zMi4zLDI0Yy0xLjgsMi4xLTMsNi0xLjIsMTAuN2MxLjEsMi45LDEwLDUuNywxMi40LDUuMWM2LjgtMS43LDE2LjUtMTIuNSwzMy4xLTIxLjEKCWMxNi4zLTguNSwzMi45LTE0LjksMzMuOC0xMy42YzkuNywxNC4zLDE2LjksMjEuNiwyMi42LDMxLjJjOS44LDE2LjUsMjcuMyw0NS45LDQ2LjYsMzkuNWM2LjQtMi4xLDMxLjEtMzMuNiw1My4zLTY4LjYKCWMxLjMtMi4xLDE2LjEsMTEuMywzMC40LDIzLjJjMTMuOCwxMS40LDIyLjcsMjAuNiwyNy4xLDIxLjRjNS40LDEsMTQuMi03LjcsMTQuMS0xNC43Yy0wLjEtMi43LTE0LjMtMTMuOC0yOS4xLTI2LjIKCWMtMTQuNS0xMi4xLTMwLjEtMjIuOC0yOS4yLTI0LjNjNy42LTEyLDE0LjUtMjMuNywyMC4xLTMzLjljNC4zLTcuOCw4LjktMTYsMTMtMjQuN2MwLjYtMS4yLDE1LjksMywzMS40LDcuMWMxNS4zLDQsMjYuNywxMCwzMSw4CgljNi45LTMsMTEuNi0xMy44LDkuNC0xOC4zYy0xLjEtMi4zLTE3LTcuMy0zMy4yLTEyYy0xNC4yLTQuMS0yOC02LjUtMjcuNy03LjNjMTUuNS0zNCwyOC44LTY0LjgsMjcuNi02OS42CgljLTEuNy03LjEsMi42LTExLjksNy0zNi41YzMuMi0xOC4xLDQuNy00MC45LDUuMi01MS43YzAuMi0zLjUsMi44LTYuMyw2LjMtNi43YzMuMS0wLjMsNi45LTAuOSwxMC41LTEuOWM3LjgtMiwxOC42LTcuOCwzNi40LTIwLjYKCWMxNy45LTEyLjgsMzguNy00OS42LDQ0LjQtNjcuOFM1NjcuNiwxMDYuOCw1NTYuOSw4Mi41eiBNMjY1LjEsMzM2LjJjLTguMSw0LTEzLDctMjYuNCw5LjZjLTYuOSwxLjQtMjkuNC0wLjItNDAuNy00LjYKCWMtMTAuNS00LjEtMTkuOS03LjYtMzAtMTUuNHMtMTUuNy0xMy4yLTE1LjctMTUuM2MwLTQuNCw2LTkuNCwxMS05LjRjNS4xLDAsMTQuNSw5LjIsMjkuNywxNi42YzE0LjMsNywxNy45LDYuMSwyNS40LDcuMwoJYzIuOSwwLjUsNy43LDAuNiwxMC43LDAuNGMxNC4xLTEuMywyMS40LTUuOSwyNS4zLTguOGM0LTMsMTMuNy0xMi45LDE3LjItMTIuNWM4LDEsMTguOSwzLjQsMTguOSw3LjEKCUMyOTAuNCwzMTksMjczLjIsMzMyLjEsMjY1LjEsMzM2LjJ6IE0zMjAuOSw1MjEuNGMtNC4zLDMuNy0xNy43LDEzLjUtMjMuMywxMy41Yy0yLjgsMC03LjQtOC4yLTExLjUtMTYuOAoJYy00LjEtOC41LTkuMS0yMS4xLTkuMS0zMS42YzAtNC42LDYtNy40LDEzLjQtOS4yYzcuMi0xLjcsMjcuMy0xLjgsMjkuOS0xLjFjNi44LDEuNywxMi45LDIuMiwxMi43LDYuNGMtMC40LDEyLjctNywxOC45LTguMywyNC4zCglDMzIzLjQsNTEyLjMsMzIzLjQsNTE5LjIsMzIwLjksNTIxLjR6IE00MzEuMSwzMjAuM2MtOS4yLDcuNC0xMC42LDguMS0yNC45LDEzLjdjLTExLjMsNC40LTI4LjYsNS44LTQxLjYsMy42CgljLTEyLjItMi4xLTIyLjMtNC42LTI5LjUtMTAuMWMtOS43LTcuMy0xNi40LTE1LjEtMTYuNC0xOS44YzAtMy43LDYuNC00LjMsMTQuNS00LjljMy41LTAuMyw5LjMsNS45LDEzLjIsOS4yCgljOC4xLDYuOCwxNC44LDgsMjguOCw5LjljMi45LDAuNCw3LjgsMC40LDEwLjcsMC4xYzcuNS0wLjksMTItMC40LDI1LjgtOC4yYzIwLTExLjIsMTcuOC0xNC40LDI1LjEtMTIuNmMyLjIsMC42LDUuOCwxLjIsNS42LDUuNgoJQzQ0Mi40LDMwOSw0NDAuNSwzMTIuNyw0MzEuMSwzMjAuM3oiLz4KPC9zdmc+Cg==",Kee={id:"engine-splash-screen",class:"flex justify-center items-center"},Qee={id:"engine-splash-title"},Yee=["src"],Xee=b.defineComponent({__name:"engine-splash",emits:["finished"],setup(t,{emit:e}){const n=b.ref("hidden"),r=b.computed(()=>({transitionDuration:`${l.value}s`})),i=b.computed(()=>({invisible:n.value!=="appear"})),o=Ft(),a=b.computed(()=>{var d,h;return(h=(d=lt().splashScreens)==null?void 0:d.engineSplashScreen)!=null?h:{}}),s=b.computed(()=>typeof a.value.overrideText=="string"?a.value.overrideText:"Made with narrat engine"),u=b.computed(()=>{var d;return(d=a.value.overrideLogo)!=null?d:Gee}),l=b.computed(()=>typeof a.value.fadeDuration=="number"?a.value.fadeDuration:2),f=b.computed(()=>typeof a.value.timeBeforeFadeout=="number"?a.value.timeBeforeFadeout:3);b.onMounted(async()=>{if(await co(10),n.value="appear",a.value.skip||o.options.debug){c();return}await co(l.value*1e3),await co(f.value*1e3),n.value="disappear",await co(l.value*1e3),c()});function c(){o.loading.loaded?e("finished"):o.listener.once("gameLoaded",()=>{e("finished")})}return(d,h)=>(b.openBlock(),b.createElementBlock("div",Kee,[b.createElementVNode("div",{id:"engine-splash-header",class:b.normalizeClass(["flex justify-center flex-col items-center",b.unref(i)]),style:b.normalizeStyle(b.unref(r))},[b.createElementVNode("h1",Qee,b.toDisplayString(b.unref(s)),1),b.createElementVNode("img",{src:b.unref(u),alt:"Narrat Logo",id:"engine-splash-logo"},null,8,Yee),b.createVNode(Jee,{percentage:b.unref(o).loading.percentage,step:b.unref(o).loading.step},null,8,["percentage","step"])],6)]))}}),Iie="",Zee={id:"game-splash-screen",style:{height:"100%",padding:"20px"},class:"flex justify-center items-center"},ete={id:"game-splash-screen-header flex justify-center flex-col items-center",class:"flex justify-center flex-col items-center"},tte={class:"title",id:"game-splash-title"},nte=b.defineComponent({__name:"game-splash",setup(t){const e=Ft(),n=b.computed(()=>{var s,u;return(u=(s=lt().splashScreens)==null?void 0:s.gameSplashScreen)!=null?u:{}}),r=b.computed(()=>typeof n.value.startButtonText=="string"?n.value.startButtonText:"Press to start"),i=b.computed(()=>e.loading.loaded),o=b.computed(()=>lt().gameTitle||"Narrat Game");function a(){e.flowState="menu"}return b.onMounted(()=>{e.options.debug&&a()}),(s,u)=>(b.openBlock(),b.createElementBlock("div",Zee,[b.createElementVNode("div",ete,[b.createElementVNode("h1",tte,b.toDisplayString(b.unref(o)),1),b.unref(i)?(b.openBlock(),b.createElementBlock("button",{key:0,class:"button menu-button main-menu-button large splash-start-button override",onClick:a},b.toDisplayString(b.unref(r)),1)):b.createCommentVNode("",!0)])]))}}),Nie="",rte=b.defineComponent({setup(){const t=ti(),e=ln(),n=Ft();return{dialog:b.computed(()=>t.dialog),stack:b.computed(()=>e.stack),modal:b.computed(()=>n.modal),flowState:b.computed(()=>n.flowState),alerts:b.computed(()=>n.alerts)}},$refs:{dialogContainer:HTMLInputElement},inject:["mq"],components:{DebugMenu:AZ,NotificationToast:TZ,StartMenu:see,AlertModal:cee,InGame:Vee,EngineSplash:Xee,GameSplash:nte},data(){return{lineTitle:"title",lineText:"hello"}},props:{options:Object},async mounted(){qn.callHook("onAppMounted"),await Ft().engineLoading(),window.addEventListener("resize",QI(()=>{this.updateScreenSize()},100,{maxWait:200})),Xa.setup(this.options.debug),setTimeout(()=>{this.updateScreenSize()},50)},computed:{...da(Ai,["screenWidth","screenHeight","layoutMode","gameWidth","gameHeight","gameScaleRatio","actualGameHeight"]),...da(ln,["currentLine"]),appStyle(){return{transform:`scale(${this.gameScaleRatio}, ${this.gameScaleRatio})`,width:`${this.gameWidth}px`,height:`${this.actualGameHeight}px`}},appClass(){return Ft().modal?"app-blurred-by-modal":{}}},methods:{closeAlert(t){Ft().closeAlert(t)},engineSplashDone(){Ft().flowState="game-splash"},updateScreenSize(){Ai().updateScreenSize(window.innerWidth,window.innerHeight)}}}),Pie="";function ite(t,e,n,r,i,o){const a=b.resolveComponent("EngineSplash"),s=b.resolveComponent("GameSplash"),u=b.resolveComponent("StartMenu"),l=b.resolveComponent("InGame"),f=b.resolveComponent("DebugMenu"),c=b.resolveComponent("NotificationToast"),d=b.resolveComponent("AlertModal");return b.openBlock(),b.createElementBlock("div",{id:"app-container",style:b.normalizeStyle(t.appStyle)},[b.createElementVNode("div",{id:"app",class:b.normalizeClass(t.appClass)},[t.flowState==="engine-splash"?(b.openBlock(),b.createBlock(a,{key:0,onFinished:t.engineSplashDone},null,8,["onFinished"])):(b.openBlock(),b.createBlock(b.Transition,{key:1,name:"screens-fade"},{default:b.withCtx(()=>[t.flowState==="game-splash"?(b.openBlock(),b.createBlock(s,{key:"1"})):t.flowState==="menu"?(b.openBlock(),b.createBlock(u,{key:"2"})):t.flowState==="playing"?(b.openBlock(),b.createBlock(l,{key:"3"})):b.createCommentVNode("",!0)]),_:1})),t.options.debug?(b.openBlock(),b.createBlock(f,{key:2})):b.createCommentVNode("",!0),b.createVNode(c),(b.openBlock(!0),b.createElementBlock(b.Fragment,null,b.renderList(t.alerts,h=>(b.openBlock(),b.createBlock(d,{key:h.id,title:h.title,text:h.text,onClose:()=>t.closeAlert(h.id)},null,8,["title","text","onClose"]))),128))],2)],4)}const ote=di(rte,[["render",ite]]);function gn(t,e){console.error("Runtime error ========================="),console.error(`Command: ${t.commandType}`),console.error("Args: ",t.args),console.error("Options: ",t.options),bn(`Runtime error at ${t.fileName}:${t.line} (${t.commandType}) ${t.code}. -
|
|
215
215
|
<br />
|
|
216
216
|
Error: ${e}`),console.error("============================")}function ate(t,...e){console.log(`[${t.fileName}:${t.line}] log: `,...e)}class Ye{constructor(e,n,r,i){Mi(this,"keyword");Mi(this,"runner");Mi(this,"argTypes");Mi(this,"parser");Mi(this,"onPlayerAnswered");Mi(this,"returnAfterPlayerAnswer");this.keyword=e,this.runner=r,this.argTypes=n,i?this.parser=i:this.parser=Rc(this.keyword,this.argTypes),this.returnAfterPlayerAnswer=!1}async run(e,n){let r=await this.runner(e,n);return this.returnAfterPlayerAnswer&&(r=await new Promise((i,o)=>{ln().waitForPlayerAnswer(e),e.finishCommand=i})),r}async processPlayerAnswer(e,n){let r=n;return this.onPlayerAnswered&&(r=await this.onPlayerAnswered(e,n)),this.returnAfterPlayerAnswer&&e.finishCommand&&e.finishCommand(r),r}static FromOptions(e){var r;const n=new Ye(e.keyword,e.argTypes,e.runner,e.parser);return n.onPlayerAnswered=e.onPlayerAnswered,n.returnAfterPlayerAnswer=(r=e.returnAfterPlayerAnswer)!=null?r:!1,n}}function Rc(t,e){let n=[];if(e!=="any"){n=[];const r=e.reduce((i,o)=>o.optional?i+1:i,0);r>=1?n.push(e.length-r):n.push(e.length),n.push(e.length)}return(r,i)=>{const o={newLine:r.currentLine+1},a=i.command.args;return e!=="any"&&(a.length<n[0]||a.length>n[1])?(console.log("Error details"),console.log(i.command),console.log(a),r.parserContext.error(r.line.line,`Command ${t}: Expected ${n.join(" to ")} arguments but got ${a.length}`),o):(i.command.commandType=t,e!=="any"&&i.command.args.forEach((s,u)=>{const l=e[u];!$7(s)&&!A7(s)&&(l.type==="any"||typeof s===l.type||r.parserContext.error(r.line.line,`Command ${t}: Argument #${u+1} (${l.name}) should be a ${l.type}, but got type ${typeof s}: ${JSON.stringify(s)}`))}),{newLine:r.currentLine+1})}}const ste=new Ye("add_level",[{name:"skillKey",type:"string"},{name:"amount",type:"number"}],async t=>{let{skillKey:e,amount:n}=t.options;if((!e||!n)&&gn(t,"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}`)}hr().incrementSkill(e,n)}),ute=Ye.FromOptions({keyword:"set_level",argTypes:[{name:"skill",type:"string"},{name:"level",type:"number"}],runner:async t=>{let{skill:e,level:n}=t.options;if((!e||!n)&&gn(t,"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}`)}hr().setSkillLevel(e,n)}}),lte=new Ye("add_xp",[{name:"xpKey",type:"string"},{name:"xpToAdd",type:"number"}],async t=>{const{xpKey:e,xpToAdd:n}=t.options;(!e||!n)&&gn(t,"add_xp command needs a skill id and a value as parameters"),hr().addXp(e,n)}),cte=new Ye("get_level",[{name:"skillKey",type:"string"}],async t=>{const{skillKey:e}=t.options;e||gn(t,"get_level command needs a skill id as parameter");const n=hr().getSkill(e);return n||gn(t,`Skill ${e} not found`),n.level}),fte=new Ye("get_xp",[{name:"xpKey",type:"string"}],async t=>{const{xpKey:e}=t.options;e||gn(t,"get_xp command needs a skill id as parameter");const n=hr().getSkillXp(e);return n||gn(t,`XP ${e} not found`),n}),dte=new Ye("roll",[{name:"id",type:"string"},{name:"skill",type:"string"},{name:"value",type:"number"},{name:"hideAfterRoll",type:"boolean",optional:!0}],async t=>{const{id:e,skill:n,value:r,hideAfterRoll:i}=t.options;return C7({id:e,skill:n,value:r,hideAfterRoll:i}).succeeded}),hte=new Ye("add_stat",[{name:"statKey",type:"string"},{name:"amountToAdd",type:"number"}],async t=>{const{statKey:e,amountToAdd:n}=t.options;(!e||typeof n!="number")&&gn(t,"add_stat command needs a stat id and a value as parameters"),Uo().addStat(e,n)}),pte=new Ye("set_stat",[{name:"statKey",type:"string"},{name:"value",type:"number"}],async t=>{const{statKey:e,value:n}=t.options;(!e||typeof n!="number")&&gn(t,"set_stat command needs a stat id and a value as parameters"),Uo().setStat(e,n)}),vte=new Ye("get_stat_value",[{name:"statKey",type:"string"}],async t=>{const{statKey:e}=t.options;return e||gn(t,"get_stat_value command needs a stat id as parameter"),Uo().getStatValue(e)}),mte=Ye.FromOptions({keyword:"jump",argTypes:"any",runner:async t=>{(t.args.length<1||typeof t.args[0]!="string")&&gn(t,"requires a label argument");const e=t.args[0],n=ln(),r={branchData:n.script[e],label:e,args:t.args.splice(1),currentIndex:0};if(!n.script[e]){bn(`Trying to jump but label ${e} not found`);return}return n.jumpTarget=r,Kh}}),gte=Ye.FromOptions({keyword:"run",argTypes:"any",runner:async t=>{(t.args.length<1||typeof t.args[0]!="string")&&gn(t,"run command needs a label to argument run");const e=t.args[0];return await ln().runLabelFunction(e,...t.args.slice(1))}}),yte=Ye.FromOptions({keyword:"var",argTypes:[{name:"name",type:"string"},{name:"value",type:"any"}],runner:async t=>{const{name:e,value:n}=t.options;ln().addScopedVariable(e,n)}}),bte=Ye.FromOptions({keyword:"return",argTypes:[{name:"value",type:"any"}],runner:async t=>{const{value:e}=t.options;return ln().setReturnValue(e),$y}}),kte=Ye.FromOptions({keyword:"log",argTypes:"any",runner:async t=>{ate(t,...t.args)}}),wte=Ye.FromOptions({keyword:"menu_return",argTypes:[],runner:async t=>(Ft().menuReturn(),Qh)}),xte=Ye.FromOptions({keyword:"save",argTypes:[{name:"name",type:"string",optional:!0}],runner:async t=>{await Ft().manualSave({saveName:t.options.name})}}),jte=Ye.FromOptions({keyword:"save_prompt",argTypes:[{name:"name",type:"string",optional:!0}],runner:async t=>{await Ft().manualSave({saveName:t.options.name,withPrompt:!0})}}),_te=[{name:"mode",type:"string"},{name:"audio",type:"string"},{name:"channel",type:"number",optional:!0}],Ste=new Ye("play",_te,async t=>{const e=Cr(),{mode:n,audio:r,channel:i}=t.options,o=Xy(t,n);o&&e.playChannel(o,r,i!=null?i:0)}),Cte=new Ye("pause",[{name:"mode",type:"string"},{name:"channel",type:"number",optional:!0}],async t=>{const e=Cr(),{mode:n,channel:r}=t.options,i=Xy(t,n);i&&e.pauseChannel(i,r!=null?r:0)}),$te=new Ye("stop",[{name:"mode",type:"string"},{name:"channel",type:"number",optional:!0}],async t=>{const e=Cr(),{mode:n,channel:r}=t.options,i=Xy(t,n);i&&e.stopChannel(i,r!=null?r:0)});function Xy(t,e){return Ate(e)?e:(gn(t,`${e} is not a valid audio mode.`),!1)}function Ate(t){return!!p7.includes(t)}const Ete=new Ye("set",[{name:"key",type:"string"},{name:"value",type:"any"}],async t=>{const e=tl();JI(e,t.options.key,t.options.value)}),Ote=new Ye("add",[{name:"key",type:"string"},{name:"value",type:"any"}],async t=>{const e=tl();GI(e,t.options.key,t.options.value)}),Mte=new Ye("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 t=>{var n;const e=po();return t.options.transitionName?e.transitionScreen(t.options.screen,{transition:t.options.transitionName,duration:t.options.transitionDuration,delay:t.options.transitionDelay},t.options.layer):e.setScreen(t.options.screen,(n=t.options.layer)!=null?n:0)}),Tte=new Ye("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 t=>{const e=po();return t.options.transitionName?e.emptyLayer(t.options.layer,{transition:t.options.transitionName,duration:t.options.transitionDuration,delay:t.options.transitionDelay}):e.emptyLayer(t.options.layer)}),Ite=new Ye("set_button",[{name:"buttonId",type:"string"},{name:"state",type:"any"}],async t=>{const{buttonId:e,state:n}=t.options;po().changeButton(e,n)}),Nte=Ye.FromOptions({keyword:"talk",argTypes:[{name:"speaker",type:"string"},{name:"pose",type:"string"},{name:"text",type:"string"}],runner:async(t,e)=>{await Ey({speaker:t.options.speaker,pose:t.options.pose,cssClass:"talk-command",text:`"${t.options.text}"`,choices:e,interactive:!0})},returnAfterPlayerAnswer:!0}),Pte=Ye.FromOptions({keyword:"think",argTypes:[{name:"speaker",type:"string"},{name:"pose",type:"string"},{name:"text",type:"string"}],runner:async(t,e)=>{await Ey({speaker:t.options.speaker,pose:t.options.pose,cssClass:"think-command",text:`${t.options.text}`,choices:e,interactive:!0})},returnAfterPlayerAnswer:!0}),Lte=()=>{const t=Rc("text",[]);return(e,n)=>{const r=t(e,n);return n.command.staticOptions={text:n.code.substring(1,n.code.length-1)},r}},Dte=Ye.FromOptions({keyword:"text",argTypes:[],runner:async(t,e)=>{await Ey({speaker:"game",cssClass:"text-command",text:t.staticOptions.text,choices:e,interactive:!0})},parser:Lte(),returnAfterPlayerAnswer:!0}),Rte=new Ye("add_item",[{name:"id",type:"string"},{name:"amount",type:"number"}],async t=>{const{id:e,amount:n}=t.options;kr().add({id:e,amount:n})}),Bte=new Ye("remove_item",[{name:"id",type:"string"},{name:"amount",type:"number"}],async t=>{const{id:e,amount:n}=t.options;kr().remove({id:e,amount:n})}),zte=new Ye("has_item?",[{name:"id",type:"string"},{name:"amount",type:"number",optional:!0}],async t=>{const{id:e,amount:n}=t.options;return kr().hasItem(e,n)}),Fte=new Ye("item_amount?",[{name:"id",type:"string"}],async t=>{const{id:e}=t.options;return kr().getItemAmount(e)}),Vte=new Ye("enable_interaction",[{name:"tag",type:"string"}],async t=>{const e=t.options.tag;kr().enableInteraction(e)}),qte=new Ye("disable_interaction",[{name:"tag",type:"string"}],async t=>{const e=t.options.tag;kr().disableInteraction(e)}),Hte=new Ye("start_quest",[{name:"questId",type:"string"}],async t=>{const e=t.options.questId;zr().startQuest(e)}),Wte=new Ye("start_objective",[{name:"questId",type:"string"},{name:"objectiveId",type:"string"}],async t=>{const{questId:e,objectiveId:n}=t.options;zr().startObjective(e,n)}),Ute=new Ye("complete_objective",[{name:"questId",type:"string"},{name:"objectiveId",type:"string"}],async t=>{const{questId:e,objectiveId:n}=t.options;zr().completeObjective(e,n)}),Jte=new Ye("complete_quest",[{name:"questId",type:"string"},{name:"ending",type:"string",optional:!0}],async t=>{const{questId:e,ending:n}=t.options;zr().completeQuest(e,n)}),Gte=new Ye("quest_completed?",[{name:"questId",type:"string"}],async t=>{const{questId:e}=t.options;return zr().isQuestCompleted(e)}),Kte=new Ye("objective_completed?",[{name:"questId",type:"string"},{name:"objectiveId",type:"string"}],async t=>{const{questId:e,objectiveId:n}=t.options;return zr().isObjectiveCompleted(e,n)}),Qte=new Ye("quest_started?",[{name:"questId",type:"string"}],async t=>{const{questId:e}=t.options;return zr().isQuestStarted(e)}),Yte=new Ye("objective_started?",[{name:"questId",type:"string"},{name:"objectiveId",type:"string"}],async t=>{const{questId:e,objectiveId:n}=t.options;return zr().isObjectiveStarted(e,n)}),Xte=Ye.FromOptions({keyword:"wait",argTypes:[{name:"duration",type:"number"}],runner:async t=>{await co(t.options.duration)}}),Zte=new Ye("notify",[{name:"text",type:"string"}],async t=>{const{text:e}=t.options;$i().addNotification(e)}),ene=new Ye("disable_notifications",[],async t=>{$i().disableNotifications()}),tne=new Ye("enable_notifications",[],async t=>{$i().enableNotifications()}),nne=new Ye("clear_dialog",[],async t=>{ti().clearDialog()}),rne=new Ye("if",[{name:"condition",type:"boolean"}],async t=>{const e=nQ(t),n=ln();if(e){const r={branchData:{branch:e},currentIndex:0};return n.addAndRunBlock(r)}},(t,e)=>{let n=t.currentLine;Rc("if",[{name:"condition",type:"string"}])(t,e);const{lines:i,currentLine:o,line:a}=t,s=e.command;let u;const l=rQ(i,o+1);return l&&l.code==="else:"&&(u=t.processCommandsFunction(t.parserContext,l.branch,a),n++),s.staticOptions={success:t.processCommandsFunction(t.parserContext,a.branch,a),failure:u},n++,{newLine:n}}),ine=new Ye("==","any",async t=>{t.args.length<2&&gn(t,"requires at least two arguments");let e=t.args[0],n=!0;for(const r of t.args)if(r!=e){n=!1;break}else e=r;return n}),one=new Ye(">",[{name:"a",type:"any"},{name:"b",type:"any"}],async t=>{const{a:e,b:n}=t.options;return e>n}),ane=new Ye("<",[{name:"a",type:"any"},{name:"b",type:"any"}],async t=>{const{a:e,b:n}=t.options;return e<n}),sne=new Ye(">=",[{name:"a",type:"any"},{name:"b",type:"any"}],async t=>{const{a:e,b:n}=t.options;return e>=n}),une=new Ye("<=",[{name:"a",type:"any"},{name:"b",type:"any"}],async t=>{const{a:e,b:n}=t.options;return e<=n}),lne=new Ye("!=",[{name:"a",type:"any"},{name:"b",type:"any"}],async t=>{const{a:e,b:n}=t.options;return e!=n}),cne=new Ye("!",[{name:"a",type:"any"}],async t=>{const{a:e}=t.options;return!e}),fne=new Ye("&&","any",async t=>{const e=t.args;return t.args.length<2&&gn(t,"requires at least two arguments"),e.reduce((n,r)=>n&&r,!0)}),dne=new Ye("||","any",async t=>(t.args.length<2&&gn(t,"requires at least two arguments"),t.args.reduce((e,n)=>e||n,!1))),hne=new Ye("?",[{name:"a",type:"any"},{name:"b",type:"any"},{name:"c",type:"any"}],async t=>{const{a:e,b:n,c:r}=t.options;return e?n:r}),pne=new Ye("+","any",async t=>(t.args.length<2&&gn(t,"requires at least two arguments"),t.args.reduce((e,n)=>typeof n=="number"?e+n:(gn(t,"requires all arguments to be numbers"),e),0))),vne=new Ye("-","any",async t=>(t.args.length<2&&gn(t,"requires at least two arguments"),t.args.slice(1).reduce((e,n)=>typeof n=="number"?e-n:(gn(t,"requires all arguments to be numbers"),e),t.args[0]))),mne=new Ye("neg",[{name:"a",type:"number"}],async t=>(t.args.length!==1&&gn(t,"requires one argument"),-t.options.a)),gne=new Ye("abs",[{name:"a",type:"number"}],async t=>(t.args.length!==1&&gn(t,"requires one argument"),Math.abs(t.options.a))),yne=new Ye("*","any",async t=>(t.args.length<2&&gn(t,"requires at least two arguments"),t.args.reduce((e,n)=>typeof n=="number"?e*n:(gn(t,"requires all arguments to be numbers"),e),1))),bne=new Ye("/","any",async t=>{t.args.length<2&&gn(t,"requires at least two arguments");const e=t.args[0]/t.args[1];return t.args.slice(2).reduce((n,r)=>typeof r=="number"?n/r:(gn(t,"requires all arguments to be numbers"),n),e)}),kne=async t=>{const{prompt:e,choices:n}=t.staticOptions,r=[];for(const[,a]of n.entries()){const s=await Ty(a.prompt);r.push(s)}t.options.choiceResults=r;const i=r.map((a,s)=>{var f,c;let u=!0;return a.skillCheck&&(u=(c=(f=a.skillCheck)==null?void 0:f.allowed)!=null?c:!1),{choice:a.text,originalIndex:s,allowed:u}}).filter(a=>a.choice),o=await L7(e,i);return await _ne(t,o)};function wne(t,e){e.branch||t.parserContext.error(e.line,`Choice option doesn't have any branch to go to (${e.code} - ${e.line})`);let n,r;const i=e.branch;return e.expression[1]==="roll"?((!i[0].branch||!i[1].branch)&&t.parserContext.error(e.line,`Choice option with a skill roll needs success and failure branches (${e.code} - ${e.line})`),n={success:t.processCommandsFunction(t.parserContext,i[0].branch,e),failure:t.processCommandsFunction(t.parserContext,i[1].branch,e)}):r=t.processCommandsFunction(t.parserContext,i,e),{prompt:t.processCommandsFunction(t.parserContext,[e],e)[0],branch:r,skillBranches:n}}const xne=(t,e)=>{let n=t.currentLine;Rc("choice",[]);const{line:r}=t,i=e.command;(!r.branch||r.branch.length<2)&&t.parserContext.error(r.line,"Choice menu needs to have at least one option");const o=r.branch[0];o||t.parserContext.error(t.line.line,"Choice prompt is missing ");const s=r.branch.slice(1).map((u,l)=>(u.branch||t.parserContext.error(u.line,`Choice option doesn't have any branch to go to (${u.code})`),u=Sne(t.parserContext,u),wne(t,u)));return i.staticOptions={prompt:t.processCommandsFunction(t.parserContext,[o],r)[0],choices:s},n++,{newLine:n}},jne=Ye.FromOptions({keyword:"choice",argTypes:[],runner:kne,parser:xne}),_ne=async(t,e)=>{const n=e,r=ln(),{choices:i}=t.staticOptions,o=i[n],a=t.options.choiceResults[n];let s=a.text,u;if(a.skillCheck?(s=null,C7({skill:a.skillCheck.skillId,value:a.skillCheck.difficulty,id:a.skillCheck.skillCheckId,hideAfterRoll:a.skillCheck.hideAfterRoll}).succeeded?u=o.skillBranches.success:u=o.skillBranches.failure):u=o.branch,s){const l={speaker:"player",text:s,interactive:!1};ti().addDialog(l)}if(u){const l={currentIndex:0,branchData:{branch:u}};return await r.addAndRunBlock(l)}};function Sne(t,e){return{code:`choicePrompt ${e.code}`,indentation:e.indentation,line:e.line,branch:e.branch,expression:["choicePrompt",...e.expression]}}const Cne=new Ye("choicePrompt","any",async t=>{const e=t.args;if(e[0]==="roll"){const n=e[1],r=e[2],i=e[3],o=e[4],a=e.length>5?e[5]:!1,s=hr().getSkillCheck(n);if(s.hidden)return{text:null};const u=s.happened&&!s.succeeded,{difficultyText:l}=XK({skill:r,skillCheckId:n,value:i});return{text:`${l} ${o}`,skillCheck:{allowed:!u,skillId:r,skillCheckId:n,difficulty:i,hideAfterRoll:a}}}else if(e.length>1&&e[1]==="if"){const n=e[0];let r=!0;return e.length>2&&(r=e[2]),r?{text:n}:{text:null}}else return{text:e[0]}}),XI=Ye.FromOptions({keyword:"text_field",argTypes:[{name:"prompt",type:"string"}],returnAfterPlayerAnswer:!0,runner:async t=>{const e={speaker:"game",text:t.options.prompt,textField:!0,interactive:!0};ti().addDialog(e)}});XI.onPlayerAnswered=async(t,e)=>(typeof e!="string"&&gn(t,"The player's answer should be a string"),e);const $ne=Ye.FromOptions({keyword:"text_field_prompt",argTypes:[{name:"prompt",type:"string"}],runner:async t=>{const e={speaker:"game",text:t.options.prompt,textField:!0,interactive:!0};ti().addDialog(e)}}),Ane=new Ye("random",[{name:"a",type:"number"},{name:"b",type:"number"}],async t=>{const{a:e,b:n}=t.options;return typeof e!="number"||typeof n!="number"?(gn(t,"random command needs two numbers as parameters"),0):Math.floor(Math.random()*(n-e+1))+e}),Ene=new Ye("random_float",[{name:"a",type:"number"},{name:"b",type:"number"}],async t=>{const{a:e,b:n}=t.options;return typeof e!="number"||typeof n!="number"?(gn(t,"random_float command needs two numbers as parameters"),0):Math.random()*(n-e)+e}),One=new Ye("random_from_args",[],async t=>{const e=t.args;return!e||!e.length?(gn(t,"random_from_args command needs at least one argument"),0):e[Math.floor(Math.random()*e.length)]}),Mne=new Ye("concat","any",async t=>(t.args.length<2&&gn(t,"requires at least two arguments"),t.args.reduce((e,n)=>typeof n=="string"?`${e}${n}`:(gn(t,"requires all arguments to be strings"),e),""))),Tne=new Ye("join","any",async t=>{const e=t.args[0];return t.args.length<3&&gn(t,"requires at least 3 arguments"),t.args.slice(1).reduce((n,r)=>typeof r=="string"?`${n}${e}${r}`:(gn(t,"requires all arguments to be strings"),n),"")}),Ine=Ye.FromOptions({keyword:"min",argTypes:[{name:"min",type:"number"},{name:"value",type:"number"}],runner:async t=>{const{min:e,value:n}=t.options;return n<e?n:e}}),Nne=Ye.FromOptions({keyword:"max",argTypes:[{name:"max",type:"number"},{name:"value",type:"number"}],runner:async t=>{const{max:e,value:n}=t.options;return n>e?n:e}}),Pne=Ye.FromOptions({keyword:"clamp",argTypes:[{name:"min",type:"number"},{name:"max",type:"number"},{name:"value",type:"number"}],runner:async t=>{const{min:e,max:n,value:r}=t.options;return r<e?e:r>n?n:r}}),Lne=Ye.FromOptions({keyword:"floor",argTypes:[{name:"value",type:"number"}],runner:async t=>{const{value:e}=t.options;return Math.floor(e)}}),Dne=Ye.FromOptions({keyword:"ceil",argTypes:[{name:"value",type:"number"}],runner:async t=>{const{value:e}=t.options;return Math.ceil(e)}}),Rne=Ye.FromOptions({keyword:"round",argTypes:[{name:"value",type:"number"}],runner:async t=>{const{value:e}=t.options;return Math.round(e)}}),Bne=Ye.FromOptions({keyword:"sqrt",argTypes:[{name:"value",type:"number"}],runner:async t=>{const{value:e}=t.options;return Math.sqrt(e)}}),zne=Ye.FromOptions({keyword:"^",argTypes:[{name:"base",type:"number"},{name:"exponent",type:"number"}],runner:async t=>{const{base:e,exponent:n}=t.options;return Math.pow(e,n)}}),Fne=new Ye("create_sprite",[{name:"image",type:"string"},{name:"x",type:"number"},{name:"y",type:"number"}],async t=>zs().createSprite(t.options.image,t.options.x,t.options.y)),Vne=new Ye("delete_sprite",[{name:"sprite",type:"any"}],async t=>zs().deleteSprite(t.options.sprite));function qne(t){t.addCommand(jne),t.addCommand(Cne),t.addCommand(rne),t.addCommand(hte),t.addCommand(pte),t.addCommand(vte),t.addCommand(nne),t.addCommand(Zte),t.addCommand(ene),t.addCommand(tne),t.addCommand(Cte),t.addCommand(Ste),t.addCommand($te),t.addCommand(Ite),t.addCommand(Mte),t.addCommand(Tte),t.addCommand(Fne),t.addCommand(Vne),t.addCommand(Xte),t.addCommand(ine),t.addCommand(one),t.addCommand(ane),t.addCommand(sne),t.addCommand(une),t.addCommand(lne),t.addCommand(cne),t.addCommand(fne),t.addCommand(dne),t.addCommand(hne),t.addCommand(pne),t.addCommand(vne),t.addCommand(yne),t.addCommand(bne),t.addCommand(mne),t.addCommand(gne),t.addCommand(Ote),t.addCommand(Ete),t.addCommand(Dte),t.addCommand(Nte),t.addCommand(Pte),t.addCommand(mte),t.addCommand(gte),t.addCommand(yte),t.addCommand(bte),t.addCommand(kte),t.addCommand(wte),t.addCommand(xte),t.addCommand(jte),t.addCommand(Hte),t.addCommand(Wte),t.addCommand(Ute),t.addCommand(Jte),t.addCommand(Qte),t.addCommand(Yte),t.addCommand(Gte),t.addCommand(Kte),t.addCommand(Rte),t.addCommand(Bte),t.addCommand(Vte),t.addCommand(qte),t.addCommand(zte),t.addCommand(Fte),t.addCommand(ste),t.addCommand(ute),t.addCommand(lte),t.addCommand(dte),t.addCommand(cte),t.addCommand(fte),t.addCommand(XI),t.addCommand($ne),t.addCommand(Ane),t.addCommand(Ene),t.addCommand(One),t.addCommand(Mne),t.addCommand(Tne),t.addCommand(Ine),t.addCommand(Nne),t.addCommand(Pne),t.addCommand(Lne),t.addCommand(Rne),t.addCommand(Dne),t.addCommand(Bne),t.addCommand(zne)}const Hne=b.defineComponent({data(){return{muted:!1,volumes:[],modeNames:{master:"Master volume:",music:"Music:",ambiant:"Ambiant:",sound:"Sound effects:"}}},mounted(){const t=Cr(),e=Wa.Howler.volume();this.volumes.push({mode:"master",volume:e}),t.modes.forEach((n,r)=>{this.volumes.push({mode:r,volume:t.modes.get(r).options.volume})})},methods:{changeVolume(t,e){const n=e.target;t==="master"?Cr().setMasterVolume(n.value):Cr().setModeVolume(t,n.value)},toggleMute(){this.muted?(Wa.Howler.mute(!1),this.muted=!1):(Wa.Howler.mute(!0),this.muted=!0)}}}),Lie="",Wne={class:"volume-controls"},Une=b.createElementVNode("h3",{class:"subtitle"},"Volume",-1),Jne={for:"volume",class:"volume-label"},Gne=["onUpdate:modelValue","onChange"];function Kne(t,e,n,r,i,o){return b.openBlock(),b.createElementBlock("div",Wne,[Une,(b.openBlock(!0),b.createElementBlock(b.Fragment,null,b.renderList(t.volumes,(a,s)=>(b.openBlock(),b.createElementBlock("div",{class:"volume-control",key:a.mode},[b.createElementVNode("label",Jne,b.toDisplayString(t.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":u=>t.volumes[s].volume=u,onChange:u=>t.changeVolume(a.mode,u)},null,40,Gne),[[b.vModelText,t.volumes[s].volume]])]))),128))])}const Qne=di(Hne,[["render",Kne]]),Yne=b.defineComponent({components:{Modal:Go,VolumeControls:Qne},data(){return{}},mounted(){},methods:{quit(){window.close()},mainMenu(){Ft().menuReturn(),this.closeMenu()},closeMenu(){this.$emit("close")},getPlayTimeString(){const t=Wc(Ft().playTime.start,Ft().playTime.previousPlaytime);return gp(t/1e3)}}}),Die="",Xne=b.createElementVNode("h3",{class:"title"},"Menu",-1),Zne={class:"menu-content"};function ere(t,e,n,r,i,o){const a=b.resolveComponent("VolumeControls"),s=b.resolveComponent("modal");return b.openBlock(),b.createBlock(s,{class:"menu",onClose:e[2]||(e[2]=u=>t.$emit("close")),containerCssClass:"main-menu-modal"},{header:b.withCtx(()=>[Xne]),body:b.withCtx(()=>[b.createElementVNode("div",Zne,[b.createElementVNode("h3",null,"Play time: "+b.toDisplayString(t.getPlayTimeString()),1),b.createVNode(a),b.createElementVNode("button",{class:"button title quit-button",onClick:e[0]||(e[0]=(...u)=>t.mainMenu&&t.mainMenu(...u))}," Main Menu "),b.createElementVNode("button",{class:"button title quit-button",onClick:e[1]||(e[1]=(...u)=>t.quit&&t.quit(...u))},"Exit")])]),_:1})}const tre=di(Yne,[["render",ere]]),nre=b.defineComponent({setup(){const t=kr(),e=ti(),n=b.computed(()=>t.items),r=b.computed(()=>e.currentDialog.choices);return{items:n,currentlyChoosing:r}},components:{Modal:Go},data(){return{chosenId:!1}},mounted(){},methods:{close(){this.$emit("close")},getItemStyle(t){return{backgroundImage:`url(${Qa(this.itemConf[t].icon)})`}},getItemName(t){return this.itemConf[t].name},getItemConf(t){return this.itemConf[t]},clickItem(t){this.chosenId=t},closeItem(){this.chosenId=!1},useItem(){if(this.chosenItem&&this.canUseChosenItem&&this.chosenItemConf){const t=this.chosenItemConf.onUse;this.close(),Bs("onItemUsed"),t.action==="jump"?ln().jumpToLabel(t.label):t.action==="run"?ln().runThenGoBackToPreviousDialog(t.label,!0):bn(`Unknown action ${t.action}`)}},canUseItem(t){const e=this.itemConf[t.id];return!!(e&&e.onUse&&!kr().isInteractionTagBlocked(e.tag)&&!this.currentlyChoosing)}},computed:{itemsToDisplay(){const t={};for(const e in this.items)this.items[e].amount>0&&(t[e]=this.items[e]);return t},chosenItem(){return this.chosenId?this.items[this.chosenId]:null},canUseChosenItem(){return this.canUseItem(this.chosenItem)},chosenItemConf(){return this.chosenId?this.itemConf[this.chosenId]:null},itemConf(){return lt().items}}}),Rie="",rre=b.createElementVNode("h3",{class:"title"},"Inventory",-1),ire={key:0,class:"inventory-container"},ore=["onClick"],are={class:"item-title"},sre={class:"item-amount"},ure={key:1},lre={class:"flex flex-row item-description-container"},cre={class:"flex item-left"},fre={class:"flex item-right"},dre=b.createElementVNode("hr",{class:"hr-solid"},null,-1),hre={key:2},pre=[b.createElementVNode("h2",null,"The inventory is empty!",-1)];function vre(t,e,n,r,i,o){const a=b.resolveComponent("modal");return b.openBlock(),b.createBlock(a,{class:"menu",onClose:t.close,containerCssClass:"inventory-modal"},{header:b.withCtx(()=>[rre]),body:b.withCtx(()=>[!t.chosenItem&&Object.keys(t.itemsToDisplay).length>0?(b.openBlock(),b.createElementBlock("div",ire,[(b.openBlock(!0),b.createElementBlock(b.Fragment,null,b.renderList(t.itemsToDisplay,s=>(b.openBlock(),b.createElementBlock("button",{onClick:()=>t.clickItem(s.id),class:"item-display",style:b.normalizeStyle(t.getItemStyle(s.id)),key:s.id},[b.createElementVNode("h3",are,b.toDisplayString(t.getItemName(s.id)),1),b.createElementVNode("h3",sre,b.toDisplayString(s.amount),1)],12,ore))),128))])):typeof t.chosenId=="string"?(b.openBlock(),b.createElementBlock("div",ure,[b.createElementVNode("div",lre,[b.createElementVNode("div",cre,[b.createElementVNode("div",{class:"item-display",style:b.normalizeStyle(t.getItemStyle(t.chosenId))},null,4)]),b.createElementVNode("div",fre,[b.createElementVNode("h2",null,b.toDisplayString(t.getItemName(t.chosenId)),1),dre,b.createElementVNode("h3",null,"Amount: "+b.toDisplayString(t.chosenItem.amount),1),b.createElementVNode("p",null,b.toDisplayString(t.chosenItemConf.description),1),b.createElementVNode("button",{onClick:e[0]||(e[0]=(...s)=>t.useItem&&t.useItem(...s)),class:b.normalizeClass(["button",t.canUseChosenItem?"":"disabled"])}," Use ",2)])]),b.createElementVNode("button",{class:"button",onClick:e[1]||(e[1]=(...s)=>t.closeItem&&t.closeItem(...s))},b.toDisplayString("<--"))])):(b.openBlock(),b.createElementBlock("div",hre,pre))]),_:1},8,["onClose"])}const mre=di(nre,[["render",vre]]),gre=b.defineComponent({setup(){const t=zr();return{quests:b.computed(()=>t.quests)}},computed:{questsToDisplay(){return b7(this.quests,t=>t.state!=="hidden")}},methods:{close(){this.$emit("close")},getQuestData(t){return up(t)},getObjectiveData(t,e){return Gy(t,e)},getDisplayTextForQuestState(t){switch(t.state){case"hidden":return" Hidden";case"unlocked":return"";case"completed":return" (Completed)";default:return" Unknown"}},getQuestDescription(t){return t.ending?t.ending:this.getQuestData(t.id).description},getAvailableObjectives(t){return b7(t.objectives,e=>e.state!=="hidden")}},components:{Modal:Go}}),zie="",yre=b.createElementVNode("h3",{class:"title"},"Quests",-1),bre={key:0,class:"quests-container"},kre={class:"quest-title"},wre={class:"quest-description"},xre={key:0,class:"quest-objectives-container list-disc"},jre={key:1,class:"menu-container"},_re=[b.createElementVNode("h2",{class:"title"},"There are no quests!",-1)];function Sre(t,e,n,r,i,o){const a=b.resolveComponent("modal");return b.openBlock(),b.createBlock(a,{class:"quests",onClose:t.close,containerCssClass:"quests-modal"},{header:b.withCtx(()=>[yre]),body:b.withCtx(()=>[Object.keys(t.questsToDisplay).length>0?(b.openBlock(),b.createElementBlock("div",bre,[(b.openBlock(!0),b.createElementBlock(b.Fragment,null,b.renderList(t.questsToDisplay,s=>(b.openBlock(),b.createElementBlock("div",{class:"quest-display",key:s.id},[b.createElementVNode("div",{class:b.normalizeClass(["quest-header",s.state==="completed"?"quest-completed":"quest-in-progress"])},[b.createElementVNode("h3",kre,b.toDisplayString(t.getQuestData(s.id).title)+" "+b.toDisplayString(t.getDisplayTextForQuestState(s)),1)],2),b.createElementVNode("p",wre,b.toDisplayString(t.getQuestDescription(s)),1),s.state!=="completed"?(b.openBlock(),b.createElementBlock("ul",xre,[(b.openBlock(!0),b.createElementBlock(b.Fragment,null,b.renderList(t.getAvailableObjectives(s),u=>(b.openBlock(),b.createElementBlock("li",{class:"quest-objective-display",key:u.id},[b.createElementVNode("p",{class:b.normalizeClass(["quest-objective-description",u.state==="completed"?"quest-objective-completed":"quest-objctive-in-progress"])},b.toDisplayString(t.getObjectiveData(s.id,u.id).description),3)]))),128))])):b.createCommentVNode("",!0)]))),128))])):(b.openBlock(),b.createElementBlock("div",jre,_re))]),_:1},8,["onClose"])}const Cre=di(gre,[["render",Sre]]),$re=b.defineComponent({setup(){const t=hr();return{skills:b.computed(()=>t.skills)}},components:{Modal:Go},data(){return{chosenSkill:!1}},mounted(){},methods:{getSkillStyle(t){return{backgroundImage:`url(${Qa(this.skillConf[t].icon)})`}},getSkillName(t){return this.skillConf[t].name},clickSkill(t){this.chosenSkill=t},closeSkill(){this.chosenSkill=!1},xpBarWidth(t){return{width:`${Math.floor(t/this.xpPerLevel*100)}%`}}},computed:{skillsToDisplay(){const t={};for(const e in this.skills)this.skillConf[e].hidden&&this.skills[e].level<1||(t[e]=this.skills[e]);return t},skillConf(){return lt().skills},xpPerLevel(){return lt().skillOptions.xpPerLevel}}}),Vie="",Are=b.createElementVNode("h3",{class:"title"},"Skills",-1),Ere={key:0,class:"skills-container"},Ore=["onClick"],Mre={class:"skill-title"},Tre={class:"skill-xp-container"},Ire={class:"skill-xp-text"},Nre={class:"skill-level"},Pre={key:1},Lre={class:"flex flex-row skill-description-container"},Dre={class:"flex skill-left"},Rre={class:"flex skill-right"},Bre=b.createElementVNode("hr",{class:"hr-solid"},null,-1);function zre(t,e,n,r,i,o){const a=b.resolveComponent("modal");return b.openBlock(),b.createBlock(a,{class:"menu",onClose:e[1]||(e[1]=s=>t.$emit("close")),containerCssClass:"skills-modal"},{header:b.withCtx(()=>[Are]),body:b.withCtx(()=>[t.chosenSkill?typeof t.chosenSkill=="string"?(b.openBlock(),b.createElementBlock("div",Pre,[b.createElementVNode("div",Lre,[b.createElementVNode("div",Dre,[b.createElementVNode("div",{class:"skill-display",style:b.normalizeStyle(t.getSkillStyle(t.chosenSkill))},null,4)]),b.createElementVNode("div",Rre,[b.createElementVNode("h2",null,b.toDisplayString(t.getSkillName(t.chosenSkill)),1),Bre,b.createElementVNode("h3",null,"Level: "+b.toDisplayString(t.skills[t.chosenSkill].level),1),b.createElementVNode("p",null,b.toDisplayString(t.skillConf[t.chosenSkill].description),1)])]),b.createElementVNode("button",{class:"button",onClick:e[0]||(e[0]=(...s)=>t.closeSkill&&t.closeSkill(...s))},b.toDisplayString("<--"))])):b.createCommentVNode("",!0):(b.openBlock(),b.createElementBlock("div",Ere,[(b.openBlock(!0),b.createElementBlock(b.Fragment,null,b.renderList(t.skillsToDisplay,s=>(b.openBlock(),b.createElementBlock("button",{onClick:()=>t.clickSkill(s.id),class:"skill-display",style:b.normalizeStyle(t.getSkillStyle(s.id)),key:s.id},[b.createElementVNode("h3",Mre,b.toDisplayString(t.getSkillName(s.id)),1),b.createElementVNode("div",Tre,[b.createElementVNode("div",{class:"skill-xp-bar",style:b.normalizeStyle(t.xpBarWidth(s.xp))},null,4),b.createElementVNode("h3",Ire,b.toDisplayString(s.xp)+" / "+b.toDisplayString(t.xpPerLevel)+" XP",1)]),b.createElementVNode("h3",Nre,b.toDisplayString(s.level),1)],12,Ore))),128))]))]),_:1})}const Fre=di($re,[["render",zre]]);function Vre(t){t.component("MainMenu",tre),t.component("InventoryUi",mre),t.component("QuestsUi",Cre),t.component("SkillsWindow",Fre),Ja().buttons=[{id:"menu",cssId:"menu-button",text:"Menu",component:"MainMenu"},{id:"skills",cssId:"skills-menu-button",text:"Skills",condition:()=>Ja().showSkills,component:"SkillsWindow"},{id:"inventory",cssId:"inventory-menu-button",text:"Items",condition:()=>Ja().showInventory,component:"InventoryUi"},{id:"quests",cssId:"quests-menu-button",text:"Quests",condition:()=>Ja().showQuests,component:"QuestsUi"}]}function ZI(t,e){window.narrat.app.component(t.component,e),Ja().addMenuOption(t)}function qre(){for(const t of qn.plugins)if(t.customMenuButtons)for(const e of t.customMenuButtons)ZI(e.config,e.component)}let Za;qn.callHook("onPageLoaded");async function Hre(t,e){console.log("Starting narrat...");const n=Object.assign(MQ(),t);e&&(console.warn("Deprecation warning: startApp now only takes one object with config rather than two. You can move the values in the second parameter of startApp into the first one."),Object.assign(n,e)),await eZ(n);const r=AK();Za=b.createApp(ote,{options:n}),Za.use(r),qn.pinia=r,Ft();const i={app:Za,vm:qn,jump:o=>{ln().jumpToLabel(o)}};return window.narrat=i,Vre(Za),qre(),Ft().setOptions(n),Za.use(bN,{breakpoints:{s:0,m:800,l:1200}}),qne(qn),h1.setupDebugger(n.debug),console.log(`%c Narrat game engine v${zK} - Built at ${FK.toLocaleString()}`,"background: #222; color: #bada55"),qn.callHook("onNarratSetup"),Za.mount("#game-holder"),Za}function Wre(t,e){Za.component(t,e)}class Ure{onPageLoaded(){}onNarratSetup(){}onAppMounted(){}onAssetsLoaded(){}onGameSetup(){}onGameStart(){}onGameMounted(){}onGameDismounted(){}}function Jre(t){qn.addPlugin(t)}function Gre(t){qn.addCommand(t)}It.CommandPlugin=Ye,It.ModalWindow=Go,It.NarratPlugin=Ure,It.addCommand=Gre,It.aspectRatioFit=B7,It.generateParser=Rc,It.getConfig=lt,It.inputEvents=Xa,It.registerComponent=Wre,It.registerMenuButton=ZI,It.registerPlugin=Jre,It.startApp=Hre,It.useAudio=Cr,It.useDialogStore=ti,It.useHud=Uo,It.useInventory=kr,It.useMain=Ft,It.useNotifications=$i,It.useQuests=zr,It.useRenderingStore=Ai,It.useScreens=po,It.useSkills=hr,It.useVM=ln,Object.defineProperties(It,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
|
217
217
|
//# sourceMappingURL=narrat.umd.js.map
|