narrat 2.2.18 → 2.2.19

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.
@@ -179,7 +179,7 @@ This will fail in production.`);s=nc,s._s.has(r)||(o?H0(r,e,i,s):x7(r,i,s),proce
179
179
  <b>${i}</b>
180
180
  Script: ${t.code}
181
181
  Label: ${((r=n.currentFrame)==null?void 0:r.label)||"none"}`)}}async function TG(t,e){const n=t.command,r=lr.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(G7(s))u=await ny(s,e);else if(typeof s=="string")if(s.search(W7)===0)u=s.substring(3);else if(K7(s)){const l=Ou(),f=xG(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 ny(t,e){const n=await TG(t,e),r=lr.commands[n.commandType];if(r)return await r.run(n,e);throw new Error(`${n.commandType} is not a valid command`)}async function PG(t){wh("onPlayerAnswered");const e=dn(),n=e.popAnswerQueue(),r=e.currentLine;try{if(n){const i=lr.commands[n.commandType];if(i)return await i.processPlayerAnswer(n,t)}}catch(i){console.error(i),Sn(`Error after player answer at ${r.fileName}:${r.line+1} (${r.code}<br /> - Error: ${i}`)}}const ks=io("rendering",{state:()=>({screenHeight:window.innerHeight,screenWidth:window.innerWidth,canvasWidth:window.innerWidth,canvasHeight:window.innerHeight,renderRatio:1,topOffset:0,leftOffset:0,layoutMode:"horizontal"}),actions:{updateScreenSize(t,e,n){this.screenHeight=e,this.screenWidth=t,this.renderRatio=1,this.topOffset=0,this.leftOffset=0,t<ft().layout.verticalLayoutThreshold?this.layoutMode="vertical":this.layoutMode="horizontal"}}});class X7{constructor(){Ri(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}}function IG(){return{baseAssetsPath:"",baseDataPath:"",charactersPath:"data/characters.json",configPath:"data/config.json",logging:!1,debug:!1}}class NG extends X7{}const Gt=io("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 NG}),actions:{async setup(){var n;const t=ft(),e=t.scripts;Ir().setMasterVolume((n=t.audioOptions.volume)!=null?n:1),await dn().loadScripts(e),this.resetAllStores()},async engineLoading(){this.loading.step="Characters";const t=await L0(this.options.charactersPath);await zJ(JSON.parse(t)),this.loading.percentage=.2,this.loading.step="Data",this.loading.percentage=.3,this.loading.step="Images",await FJ(ft()),this.loading.percentage=.7,this.loading.step="Audio",await DJ(ft()),lr.callHook("onAssetsLoaded"),this.loading.percentage=.95,this.loading.step="Starting...",await this.setup(),lr.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:ic()})})},closeAlert(t){const e=this.alerts.findIndex(n=>n.id===t);e!==-1&&(this.alerts[e].resolver(),this.alerts.splice(e,1))},startMachine(){Ir().stopAll(),wh("onPressStart"),dn().start(),this.ready=!0,this.startPlaying(),lr.callHook("onGameStart"),this.setFlowState("playing")},setSaveSlot(t){this.saveSlot=t,JJ(t)},async startGame(t){if(ft().saves.mode==="manual"){const e=P7();e&&(t=e.metadata.id)}this.setSaveSlot(t),this.startMachine(),await this.autoSaveGame({slotId:t}),dn().runGame()},async loadGame(t,e){if(this.setSaveSlot(e),this.startMachine(),t&&(this.setLoadedData(t),Ir().reloadAudio(t.audio),dn().jumpToLabel(t.vm.lastLabel)),ft().saves.mode==="manual"){const n=P7();n&&this.setSaveSlot(n.metadata.id)}},manualSave({saveName:t,withPrompt:e}){return new Promise(n=>{dn().hasJumped?this.saving={name:t,withPrompt:e,resolver:n}:n()})},finishManualSave(t,e){var n,r;if(!this.saving){Sn("Trying to save but there is no saving request!");return}if(!e||!t){this.saving.resolver(),this.saving=null;return}this.saveData?(M7({...this.saveData,main:{...this.saveData.main,playTime:mc(this.playTime.start,this.playTime.previousPlaytime)},metadata:{...this.saveData.metadata,id:t.slotId,name:(r=(n=this.saving)==null?void 0:n.name)!=null?r:`Manual Save #${oc().slotsCounter+1}`,slotType:"manual",saveDate:new Date().toISOString(),createdCounter:oc().slotsCounter+1}},t.slotId),this.alert("Success","Game saved!")):Sn("There was no data to save!"),this.saving.resolver(),this.saving=null},playerAnswered(t){PG(t)},menuReturn(){this.reset(),this.setFlowState("menu"),ft().audioOptions.defaultMusic&&Ir().playChannel("music",ft().audioOptions.defaultMusic,0)},createError(t){this.errors.push({text:t})},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,dn().reset(),Ir().reset(),this.resetAllStores(),this.playing=!1,this.ready=!0},resetAllStores(){const t=Do(),e=ft();t.setButtons(e),pr().setupSkills(e.skills),ta().setupHudStats(e.hudStats),kr().setupItems(e.items),Kr().setupQuests(e.quests)},generateSaveData(){return{playTime:mc(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=Ch(n),i=XJ();r?(i.name=r.metadata.name,i.slotType=r.metadata.slotType):i.name=e!=null?e:`Autosave ${oc().slotsCounter+1}`,ft().saves.mode==="manual"&&(i.name="Autosave",i.createdCounter=0),i.id=n;const o=Do(),a=pr(),s=ii(),u=dn(),l=Gt(),f=ta(),c=Ir(),d=kr(),h={version:UJ,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:Kr().generateSaveData(),metadata:i};this.saveData=h,M7(h,this.saveSlot)},setLoadedData(t){const e=Do(),n=pr(),r=ii(),i=dn(),o=Gt(),a=ta(),s=Ir(),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),Kr().loadSaveData(t.quests)},getAllStates(){return{main:this,screens:Do(),skills:pr(),dialog:ii(),vm:dn(),hud:ta(),audio:Ir(),rendering:ks(),notifications:Ii(),inventory:kr(),quests:Kr()}},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 LG(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>`;Sn(r)}function Sn(t,...e){const n=Gt();console.error(t,...e),t=t.replace(/[\r\n]/g,`
182
- <br />`),n.createError(`\u274C ${t}`)}const pr=io("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:this.skillChecks,skills: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=$h(this.skillChecks,t.skillChecks),this.skills=$h(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||Sn(`Skill ${t} doesn't exist`),n.xp+=e,n.xp>=ft().skillOptions.xpPerLevel&&(n.xp=0,n.level++,this.levelledUp(t))},setSkillLevel(t,e){const n=this.getSkill(t);n||Sn(`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=ft().skills[t].name,n=this.skills[t].level;ft().skillOptions.notifyLevelUp&&Ii().addNotification(`Your skill in ${e} is now level ${n}`)}}});let Z7;const DG=w.defineComponent({components:{Modal:ra},setup(){const t=pr(),e=w.computed(()=>t.skills),n=w.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];dn().jumpToLabel(e),this.finishJumping()}})},methods:{finishJumping(){this.jumping=!1,this.matches=[],this.searchString=""},labelSelected(t){const e=t.target.value;dn().jumpToLabel(e),this.close()},close(){this.showDebug=!1},closeErrors(){Gt().clearErrors()},open(){this.showDebug=!0;const t=dn(),e=Gt(),n=Kr(),r=kr(),i=pr();this.$nextTick(()=>{new QT({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 QT({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(){Z7=new Cs(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=Z7.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(){Gt().autoSaveGame({})},wordCount(){const e=Object.values(this.script).reduce((n,r)=>(Bi.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=mc(this.playTime.start,this.playTime.previousPlaytime);return Lh(t/1e3)}},computed:{...Lo(dn,["script","data"]),...Lo(Gt,["playTime","errors","playing","flowState"]),labels(){const t=this.script;return Object.keys(t).sort()},variables(){return this.data}}}),TZ="",RG={class:"debug-menu"},BG={key:0,class:"debug-info"},zG=[w.createElementVNode("h3",null,"Debug mode is ON",-1),w.createElementVNode("ul",null,[w.createElementVNode("li",null,[w.createElementVNode("b",null,"j"),w.createTextVNode(": Quick Label Jump")]),w.createElementVNode("li",null,[w.createElementVNode("b",null,"d"),w.createTextVNode(": Debug Menu")]),w.createElementVNode("li",null,[w.createElementVNode("b",null,"Escape"),w.createTextVNode(": Toggle Menu")])],-1)],VG=w.createElementVNode("h3",{class:"title"},"Jump to label",-1),FG={key:0,class:"search-results"},qG={key:1},HG=[w.createElementVNode("h3",null,"No matches found",-1)],WG=w.createElementVNode("h3",{class:"title"},"Error(s)",-1),UG=w.createTextVNode(" There are errors in your dialogue scripts. Open the developer console for more details. "),JG=["innerHTML"],GG=w.createElementVNode("h3",{class:"title"},"Debug Menu!",-1),KG={class:"container"},QG=w.createTextVNode(" Hello this is the debug menu. "),YG=w.createElementVNode("option",{class:"option",selected:"",disabled:""},"Jump to a label",-1),XG=["value"],ZG={class:"grid grid-cols-3 gap-4"},eK=w.createElementVNode("h2",null,"Variables Editor",-1),tK={ref:"variablesViewer"},nK=w.createElementVNode("h2",null,"Skill Checks",-1),rK={class:"table-auto"},iK=w.createElementVNode("thead",null,[w.createElementVNode("tr",null,[w.createElementVNode("th",null,"Skill Check"),w.createElementVNode("th",null,"Happened"),w.createElementVNode("th",null,"Succeeded")])],-1),oK=w.createElementVNode("h2",null,"App State editor (entire app and engine",-1),aK=w.createElementVNode("h3",{style:{color:"pink"}}," Use for debugging, editing some of those things can cause issues ",-1),sK={ref:"stateViewer"};function uK(t,e,n,r,i,o){const a=w.resolveComponent("modal");return w.openBlock(),w.createElementBlock("div",RG,[w.createElementVNode("button",{onClick:e[0]||(e[0]=(...s)=>t.open&&t.open(...s)),class:"button debug-button"},"Debug Menu"),!t.playing&&t.flowState==="menu"?(w.openBlock(),w.createElementBlock("div",BG,zG)):w.createCommentVNode("",!0),t.jumping?(w.openBlock(),w.createBlock(a,{key:1,onClose:t.finishJumping,containerCssClass:"jump-menu-container"},{header:w.withCtx(()=>[VG]),body:w.withCtx(()=>[w.withDirectives(w.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),[[w.vModelText,t.searchString]]),t.matches.length>0?(w.openBlock(),w.createElementBlock("div",FG,[(w.openBlock(!0),w.createElementBlock(w.Fragment,null,w.renderList(t.matches,(s,u)=>(w.openBlock(),w.createElementBlock("div",{class:"search-result",style:w.normalizeStyle(t.getMatchResultStyle(u)),key:u},w.toDisplayString(s),5))),128))])):(w.openBlock(),w.createElementBlock("div",qG,HG))]),_:1},8,["onClose"])):w.createCommentVNode("",!0),t.errors.length>0?(w.openBlock(),w.createBlock(a,{key:2,onClose:t.closeErrors,containerCssClass:"debug-menu-container"},{header:w.withCtx(()=>[WG]),body:w.withCtx(()=>[UG,w.createElementVNode("ul",null,[(w.openBlock(!0),w.createElementBlock(w.Fragment,null,w.renderList(t.errors,(s,u)=>(w.openBlock(),w.createElementBlock("li",{key:u,class:"error-message list-disc",innerHTML:s.text},null,8,JG))),128))])]),_:1},8,["onClose"])):w.createCommentVNode("",!0),t.showDebug?(w.openBlock(),w.createBlock(a,{key:3,onClose:t.close,containerCssClass:"debug-menu-container"},{header:w.withCtx(()=>[GG]),body:w.withCtx(()=>[w.createElementVNode("div",KG,[QG,w.createElementVNode("select",{class:"select",name:"label-selector",onChange:e[3]||(e[3]=s=>t.labelSelected(s))},[YG,(w.openBlock(!0),w.createElementBlock(w.Fragment,null,w.renderList(t.labels,s=>(w.openBlock(),w.createElementBlock("option",{class:"option",value:s,key:s},w.toDisplayString(s),9,XG))),128))],32),w.createElementVNode("div",ZG,[w.createElementVNode("button",{onClick:e[4]||(e[4]=(...s)=>t.wordCount&&t.wordCount(...s)),class:"button"},"Word Count"),w.createElementVNode("button",{onClick:e[5]||(e[5]=(...s)=>t.save&&t.save(...s)),class:"button"},"Save Game")]),w.createElementVNode("h3",null,"Play time: "+w.toDisplayString(t.getPlayTimeString()),1),eK,w.createElementVNode("div",tK,null,512),nK,w.createElementVNode("table",rK,[iK,w.createElementVNode("tbody",null,[(w.openBlock(!0),w.createElementBlock(w.Fragment,null,w.renderList(t.skillChecks,(s,u)=>(w.openBlock(),w.createElementBlock("tr",{key:u},[w.createElementVNode("td",null,w.toDisplayString(u),1),w.createElementVNode("td",null,w.toDisplayString(s.happened?"\u2705":"\u274C"),1),w.createElementVNode("td",null,w.toDisplayString(s.happened?s.succeeded?"\u2705":"\u274C":"NA"),1)]))),128))])]),oK,aK,w.createElementVNode("div",sK,null,512)])]),_:1},8,["onClose"])):w.createCommentVNode("",!0)])}const lK=Yr(DG,[["render",uK]]),cK=w.defineComponent({data(){},methods:{},computed:{...Lo(Ii,["notifications"])}}),LZ="",fK=["innerHTML"];function dK(t,e,n,r,i,o){return w.openBlock(),w.createBlock(w.TransitionGroup,{name:"notification",tag:"div",class:"notifications-holder"},{default:w.withCtx(()=>[(w.openBlock(!0),w.createElementBlock(w.Fragment,null,w.renderList(t.notifications,(a,s)=>(w.openBlock(),w.createElementBlock("div",{class:"notification",key:s},[w.createElementVNode("h3",{innerHTML:a.text},null,8,fK)]))),128))]),_:1})}const hK=Yr(cK,[["render",dK]]);function e8(t,e,n,r){const i=t/n,o=e/r;return Math.min(i,o)}function t8(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 k=t.apply(p,h);o&&o(k),u.forEach(({resolve:x})=>x(k)),u=[]}},y=i&&r===void 0;r!==void 0&&clearTimeout(r);const b=l();if(r=setTimeout(g,b),y){const k=t.apply(p,h);return o&&o(k),v(k)}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 pK={class:"save-slot flex flex-row"},vK={class:"used-save-slot flex flex-row justify-between items-center grow"},mK={class:"flex flex-col"},gK={class:"flex flex-col"},yK={class:"flex flex-row"},bK=["onClick"],kK=w.defineComponent({__name:"save-slot",props:{saveSlot:{type:Object,required:!0},id:{type:String,required:!0},actions:{type:Array,required:!0}},emits:["choice"],setup(t,{emit:e}){const n=t,r=w.ref(n.saveSlot.metadata.name);function i(s){e("choice",s)}function o(s){return Lh(s.main.playTime/1e3)}function a(){QJ(n.saveSlot.metadata.id,r.value)}return(s,u)=>(w.openBlock(),w.createElementBlock("div",pK,[w.createElementVNode("div",vK,[w.createElementVNode("div",mK,[w.withDirectives(w.createElementVNode("input",{type:"text",class:"save-name","onUpdate:modelValue":u[0]||(u[0]=l=>r.value=l),onInput:a},null,544),[[w.vModelText,r.value]]),w.createElementVNode("div",gK,[w.createElementVNode("p",null,"Play time: "+w.toDisplayString(o(t.saveSlot)),1),w.createElementVNode("p",null," Last save: "+w.toDisplayString(new Date(t.saveSlot.metadata.saveDate).toLocaleString()),1),w.createElementVNode("p",null,w.toDisplayString(t.saveSlot.metadata.slotType==="auto"?"Auto Save":"Manual Save"),1)])]),w.createElementVNode("div",yK,[(w.openBlock(!0),w.createElementBlock(w.Fragment,null,w.renderList(t.actions,(l,f)=>(w.openBlock(),w.createElementBlock("button",{class:"button",onClick:()=>i(f),key:f},[w.createElementVNode("h3",null,w.toDisplayString(l),1)],8,bK))),128))])])]))}}),DZ="",wK=w.createElementVNode("h3",{class:"title"},"Confirmation",-1),xK={class:"flex justify-center"},Oh=w.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)=>(w.openBlock(),w.createBlock(ra,{onClose:o[2]||(o[2]=()=>r(!1)),containerCssClass:"yes-no-modal"},{header:w.withCtx(()=>[wK]),body:w.withCtx(()=>[w.createElementVNode("h3",null,w.toDisplayString(t.prompt),1),w.createElementVNode("div",xK,[w.createElementVNode("button",{class:"button",onClick:o[0]||(o[0]=()=>r(!0))},"Yes"),w.createElementVNode("button",{class:"button",onClick:o[1]||(o[1]=()=>r(!1))},"No")])]),_:1}))}}),RZ="",jK={class:"title"},_K={class:"saves-container flex flex-col"},n8=w.defineComponent({__name:"save-slots",props:{mode:{type:String,required:!0}},emits:["chosen","close"],setup(t,{emit:e}){const n=t,r=w.reactive([]),i=w.reactive(n.mode==="load"?["Load","Delete"]:["Choose"]),o=w.reactive({prompt:"Are you sure you want to delete this save file?",saveToDelete:null,onConfirm:()=>{f(o.saveToDelete),o.saveToDelete=null},onRefuse:()=>{o.saveToDelete=null}}),a=w.reactive({prompt:"Are you sure you want to overwrite this save file?",saveToOverwrite:null,onConfirm:()=>{u(a.saveToOverwrite),a.saveToOverwrite=null},onRefuse:()=>{a.saveToOverwrite=null}});w.onMounted(()=>{let p=oc().slots.sort((v,m)=>new Date(m.metadata.saveDate).getTime()-new Date(v.metadata.saveDate).getTime());n.mode==="pick"&&(p=p.filter(v=>v.metadata.slotType!=="auto")),console.log(p),p.forEach((v,m)=>{r[m]=v})});function s(){const p=T7();u(p)}function u(p){const v={saveData:h(p),slotId:p};e("chosen",v)}function l(p){const v=h(p);if(v){if(ft().saves.mode==="manual"&&v.metadata.slotType==="auto"){Gt().alert("Sorry","Can't delete the auto save slot!");return}o.saveToDelete=p}}function f(p){KJ(p);const v=r.findIndex(m=>m.metadata.id===p);r.splice(v,1)}function c(){n.mode!=="pick"&&e("close")}function d(p,v){const m=i[v];m==="Load"?u(p):m==="Delete"?l(p):m==="Choose"&&(a.saveToOverwrite=p)}function h(p){return r.find(v=>v.metadata.id===p)}return(p,v)=>(w.openBlock(),w.createBlock(ra,{onClose:c,containerCssClass:"save-modal",cantClose:n.mode==="pick"},{header:w.withCtx(()=>[w.createElementVNode("h3",jK,w.toDisplayString(t.mode==="load"?"Choose a save to load":"Pick a slot to save the game"),1)]),body:w.withCtx(()=>[w.createElementVNode("div",{class:"flex justify-center"},[w.createElementVNode("button",{class:"button",onClick:s},"Create a new save")]),w.createElementVNode("div",_K,[w.createVNode(w.TransitionGroup,{name:"list",tag:"div"},{default:w.withCtx(()=>[(w.openBlock(!0),w.createElementBlock(w.Fragment,null,w.renderList(r,m=>(w.openBlock(),w.createBlock(kK,{key:m.metadata.id,saveSlot:m,id:m.metadata.id,actions:i,onChoice:g=>d(m.metadata.id,g)},null,8,["saveSlot","id","actions","onChoice"]))),128))]),_:1})]),o.saveToDelete?(w.openBlock(),w.createBlock(Oh,{key:0,prompt:o.prompt,onRefuse:o.onRefuse,onConfirm:o.onConfirm},null,8,["prompt","onRefuse","onConfirm"])):w.createCommentVNode("",!0),a.saveToOverwrite?(w.openBlock(),w.createBlock(Oh,{key:1,prompt:a.prompt,onRefuse:a.onRefuse,onConfirm:a.onConfirm},null,8,["prompt","onRefuse","onConfirm"])):w.createCommentVNode("",!0)]),_:1},8,["cantClose"]))}}),BZ="",SK={id:"game-menu"},CK={id:"game-header",class:"flex flex-col justify-between items-center"},$K={id:"game-title-container"},OK={id:"game-title-text"},EK={class:"flex flex-col start-menu-buttons-container"},AK=w.defineComponent({__name:"StartMenu",setup(t){const e=w.ref(!1),n=w.ref(null),r=w.ref(null),i=w.ref(!1),o=w.ref(!1);async function a(){e.value&&ft().saves.mode==="manual"?o.value=!0:s()}async function s(){const p=Gt();r.value===null&&(r.value=T7()),o.value=!1,await p.startGame(r.value)}function u(){o.value=!1}async function l(){if(!r.value)return;const p=Ch(r.value);if(!p){Sn("No save file found");return}Gt().loadGame(p,r.value)}function f(){typeof n.value=="string"&&(r.value=n.value,l())}function c(){i.value=!0}function d({saveData:p,slotId:v}){r.value=v,p?l():a()}w.onMounted(()=>{const p=ft();p.audioOptions.defaultMusic&&Ir().playChannel("music",p.audioOptions.defaultMusic,0);const v=oc();v.slots.length>0&&(e.value=!0),v.lastSaveSlot&&Ch(v.lastSaveSlot)&&(n.value=v.lastSaveSlot)});const h=w.computed(()=>ft().gameTitle);return(p,v)=>(w.openBlock(),w.createElementBlock("div",SK,[i.value?(w.openBlock(),w.createBlock(n8,{key:0,mode:"load",onChosen:d,onClose:v[0]||(v[0]=m=>i.value=!1)})):w.createCommentVNode("",!0),o.value?(w.openBlock(),w.createBlock(Oh,{key:1,prompt:"This will override your previous autosave, are you sure?",onConfirm:s,onRefuse:u})):w.createCommentVNode("",!0),w.createElementVNode("div",CK,[w.createElementVNode("div",$K,[w.createElementVNode("h1",OK,w.toDisplayString(w.unref(h)),1)]),w.createElementVNode("div",EK,[n.value?(w.openBlock(),w.createElementBlock("button",{key:0,class:"button menu-button main-menu-button large continue-button override",onClick:f}," Continue ")):w.createCommentVNode("",!0),w.createElementVNode("button",{class:"button menu-button main-menu-button large start-button override",onClick:a}," New Game "),e.value?(w.openBlock(),w.createElementBlock("button",{key:1,class:"button menu-button main-menu-button large continue-button override",onClick:c}," Load Game ")):w.createCommentVNode("",!0)])])]))}}),zZ="";class MK extends X7{setup(e=!1){const r=e?"keydown":"keyup",i=t8(o=>{sc.emit("debouncedKeydown",o)},10,{isImmediate:!0,maxWait:10});window.addEventListener("keydown",o=>{sc.emit("keydown",o)}),window.addEventListener(r,o=>{i(o)})}}const sc=new MK,TK={class:"title"},PK=w.defineComponent({__name:"alert-modal",props:{title:{type:String,required:!1},text:{type:String,required:!1}},setup(t){return(e,n)=>(w.openBlock(),w.createBlock(ra,{onClose:n[0]||(n[0]=r=>e.$emit("close")),containerCssClass:"yes-no-modal"},{header:w.withCtx(()=>{var r;return[w.createElementVNode("h3",TK,w.toDisplayString((r=t.title)!=null?r:"Alert"),1)]}),body:w.withCtx(()=>[w.createElementVNode("h3",null,w.toDisplayString(t.text),1)]),_:1}))}}),VZ="",IK=w.defineComponent({setup(){const t=kr(),e=ii(),n=w.computed(()=>t.items),r=w.computed(()=>e.currentDialog.choices);return{items:n,currentlyChoosing:r}},components:{Modal:ra},data(){return{chosenId:!1}},mounted(){},methods:{close(){this.$emit("close")},getItemStyle(t){return{backgroundImage:`url(${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(),t.action==="jump"?dn().jumpToLabel(t.label):t.action==="run"?dn().runThenGoBackToPreviousDialog(t.label,!0):Sn(`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 ft().items}}}),FZ="",NK=w.createElementVNode("h3",{class:"title"},"Inventory",-1),LK={key:0,class:"inventory-container"},DK=["onClick"],RK={class:"item-title"},BK={class:"item-amount"},zK={key:1},VK={class:"flex flex-row item-description-container"},FK={class:"flex item-left"},qK={class:"flex item-right"},HK=w.createElementVNode("hr",{class:"hr-solid"},null,-1),WK={key:2},UK=[w.createElementVNode("h2",null,"The inventory is empty!",-1)];function JK(t,e,n,r,i,o){const a=w.resolveComponent("modal");return w.openBlock(),w.createBlock(a,{class:"menu",onClose:t.close,containerCssClass:"inventory-modal"},{header:w.withCtx(()=>[NK]),body:w.withCtx(()=>[!t.chosenItem&&Object.keys(t.itemsToDisplay).length>0?(w.openBlock(),w.createElementBlock("div",LK,[(w.openBlock(!0),w.createElementBlock(w.Fragment,null,w.renderList(t.itemsToDisplay,s=>(w.openBlock(),w.createElementBlock("button",{onClick:()=>t.clickItem(s.id),class:"item-display",style:w.normalizeStyle(t.getItemStyle(s.id)),key:s.id},[w.createElementVNode("h3",RK,w.toDisplayString(t.getItemName(s.id)),1),w.createElementVNode("h3",BK,w.toDisplayString(s.amount),1)],12,DK))),128))])):typeof t.chosenId=="string"?(w.openBlock(),w.createElementBlock("div",zK,[w.createElementVNode("div",VK,[w.createElementVNode("div",FK,[w.createElementVNode("div",{class:"item-display",style:w.normalizeStyle(t.getItemStyle(t.chosenId))},null,4)]),w.createElementVNode("div",qK,[w.createElementVNode("h2",null,w.toDisplayString(t.getItemName(t.chosenId)),1),HK,w.createElementVNode("h3",null,"Amount: "+w.toDisplayString(t.chosenItem.amount),1),w.createElementVNode("p",null,w.toDisplayString(t.chosenItemConf.description),1),w.createElementVNode("button",{onClick:e[0]||(e[0]=(...s)=>t.useItem&&t.useItem(...s)),class:w.normalizeClass(["button",t.canUseChosenItem?"":"disabled"])}," Use ",2)])]),w.createElementVNode("button",{class:"button",onClick:e[1]||(e[1]=(...s)=>t.closeItem&&t.closeItem(...s))},w.toDisplayString("<--"))])):(w.openBlock(),w.createElementBlock("div",WK,UK))]),_:1},8,["onClose"])}const GK=Yr(IK,[["render",JK]]),KK=w.defineComponent({props:{pictureUrl:String},methods:{getAssetUrl(t){return xu(t)}},computed:{...Lo(ks,["layoutMode"]),boxStyle(){const t=ft().layout;let e=0,n=0;return this.layoutMode==="vertical"?(e="50%",n=`${t.mobileDialogHeightPercentage-5}%`):(e=`${t.minTextWidth-10}px`,n="20%"),{right:e,bottom:n,width:`${t.portraits.width}px`,height:`${t.portraits.height}px`}}}}),HZ="",QK=["src"];function YK(t,e,n,r,i,o){return w.openBlock(),w.createElementBlock("div",{class:"dialog-picture override",style:w.normalizeStyle(t.boxStyle)},[w.createElementVNode("img",{src:t.getAssetUrl(t.pictureUrl),class:"picture override"},null,8,QK)],4)}const XK=Yr(KK,[["render",YK]]),ZK=w.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=sc.on("debouncedKeydown",t),this.timeout=setTimeout(()=>{this.options.textField&&this.$refs.playerInput.focus()},10)}},unmounted(){this.clearListeners()},computed:{...Lo(Gt,["paused"]),preText(){return this.options.title?" &nbsp;\u2013&nbsp; ":""},style(){return xh(this.options.styleId)},dialogBoxStyle(){const t=xh(this.options.styleId),e={opacity:this.options.old?"0.7":"1"};return this.options.title||(e.marginTop="-20px"),{...t.boxCss,...e}},titleStyle(){const t=xh(this.options.styleId);return{color:t.color,...t.nameCss}},textStyle(){return xh(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&&(sc.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,Gt().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;Gt().playerAnswered(t)}}}),WZ="",eQ={class:"dialog-content"},tQ=["innerHTML"],nQ=["innerHTML"],rQ=["innerHTML"],iQ={key:1,class:"dialog-choices"},oQ=["onClick","innerHTML"],aQ={key:2},sQ={key:3,class:"buttons-container"};function uQ(t,e,n,r,i,o){return w.openBlock(),w.createElementBlock("div",{class:"dialog-box w-full override",style:w.normalizeStyle(t.dialogBoxStyle)},[w.createElementVNode("div",eQ,[t.options.title?(w.openBlock(),w.createElementBlock("span",{key:0,class:"dialog-title override",style:w.normalizeStyle(t.titleStyle),innerHTML:t.options.title},null,12,tQ)):w.createCommentVNode("",!0),w.createElementVNode("span",{class:"dialog-text dialog-separator override",style:w.normalizeStyle(t.textStyle),innerHTML:t.preText},null,12,nQ),w.createElementVNode("span",{class:w.normalizeClass(["dialog-text override",t.options.cssClass]),style:w.normalizeStyle(t.textStyle),innerHTML:t.options.text},null,14,rQ),t.canInteract&&t.choices?(w.openBlock(),w.createElementBlock("div",iQ,[(w.openBlock(!0),w.createElementBlock(w.Fragment,null,w.renderList(t.choices,(a,s)=>(w.openBlock(),w.createElementBlock("p",{key:s,style:w.normalizeStyle(t.dialogStyle(a)),class:w.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,oQ))),128))])):t.canInteract&&t.options.textField?(w.openBlock(),w.createElementBlock("div",aQ,[w.withDirectives(w.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),[[w.vModelText,t.playerText]]),w.createElementVNode("button",{onClick:e[1]||(e[1]=(...a)=>t.submitText&&t.submitText(...a)),class:"button",id:"player-input-submit"}," Submit ")])):t.canInteract?(w.openBlock(),w.createElementBlock("div",sQ,[w.createElementVNode("div",{onClick:e[2]||(e[2]=a=>t.chooseOption(0)),ref:"continue",class:"interact-button button override"}," Continue ",512)])):w.createCommentVNode("",!0)])],4)}const lQ=Yr(ZK,[["render",uQ]]),cQ=w.createElementVNode("div",{class:"anchor"},null,-1),fQ=w.defineComponent({__name:"game-dialog",props:{layoutMode:String,inGame:Boolean},setup(t){const e=t,n=dn(),r=w.computed(()=>n.stack),i=ii(),o=w.computed(()=>i.dialog),a=w.ref(null),s=w.computed(()=>e.layoutMode==="vertical"?{}:{paddingBottom:`${ft().layout.dialogBottomPadding}px`}),u=w.computed(()=>{if(o.value.length>0)return o.value[o.value.length-1]}),l=w.computed(()=>{if(u.value)return VJ(u.value.speaker,u.value.pose)}),f=w.computed(()=>ft().layout.minTextWidth),c=w.computed(()=>{let p;const v="100%";return e.layoutMode,{width:e.layoutMode==="horizontal"?`${f.value}px`:"100%",height:v,transform:p,transformOrigin:"right"}});function d(p,v){let g=G0(p.speaker).name;return v>=1&&o.value[v-1].speaker===p.speaker&&(g=void 0),p.choices&&p.choices.forEach(y=>{y.choice=ey(y.choice)}),{title:g!=null?g:"",text:p.text,cssClass:p.cssClass,styleId:p.speaker,choices:p.choices,old:v<o.value.length-1,interactive:p.interactive,textField:p.textField}}function h(p){return p===i.dialog.length-1&&r.value.length>0}return w.watch(o.value,p=>{if(a.value){const v=a.value;v.scrollTop=v.scrollHeight+1e8}}),(p,v)=>(w.openBlock(),w.createElementBlock(w.Fragment,null,[w.createVNode(w.Transition,{name:"fade"},{default:w.withCtx(()=>[w.unref(l)?(w.openBlock(),w.createBlock(XK,{key:0,pictureUrl:w.unref(l)},null,8,["pictureUrl"])):w.createCommentVNode("",!0)]),_:1}),t.inGame?(w.openBlock(),w.createElementBlock("div",{key:0,class:"dialog override",ref_key:"dialogRef",ref:a,style:w.normalizeStyle(w.unref(c))},[w.createVNode(w.TransitionGroup,{name:"list",tag:"div",class:"dialog-container w-full override",style:w.normalizeStyle(w.unref(s))},{default:w.withCtx(()=>[(w.openBlock(!0),w.createElementBlock(w.Fragment,null,w.renderList(w.unref(o),(m,g)=>(w.openBlock(),w.createBlock(lQ,{key:m.id,options:d(m,g),active:h(g)},null,8,["options","active"]))),128))]),_:1},8,["style"]),cQ],4)):w.createCommentVNode("",!0)],64))}}),UZ="",dQ=w.defineComponent({setup(){const t=Kr();return{quests:w.computed(()=>t.quests)}},computed:{questsToDisplay(){return A7(this.quests,t=>t.state!=="hidden")}},methods:{close(){this.$emit("close")},getQuestData(t){return vh(t)},getObjectiveData(t,e){return D0(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 A7(t.objectives,e=>e.state!=="hidden")}},components:{Modal:ra}}),JZ="",hQ=w.createElementVNode("h3",{class:"title"},"Quests",-1),pQ={key:0,class:"quests-container"},vQ={class:"quest-title"},mQ={class:"quest-description"},gQ={key:0,class:"quest-objectives-container list-disc"},yQ={key:1,class:"menu-container"},bQ=[w.createElementVNode("h2",{class:"title"},"There are no quests!",-1)];function kQ(t,e,n,r,i,o){const a=w.resolveComponent("modal");return w.openBlock(),w.createBlock(a,{class:"quests",onClose:t.close,containerCssClass:"quests-modal"},{header:w.withCtx(()=>[hQ]),body:w.withCtx(()=>[Object.keys(t.questsToDisplay).length>0?(w.openBlock(),w.createElementBlock("div",pQ,[(w.openBlock(!0),w.createElementBlock(w.Fragment,null,w.renderList(t.questsToDisplay,s=>(w.openBlock(),w.createElementBlock("div",{class:"quest-display",key:s.id},[w.createElementVNode("div",{class:w.normalizeClass(["quest-header",s.state==="completed"?"quest-completed":"quest-in-progress"])},[w.createElementVNode("h3",vQ,w.toDisplayString(t.getQuestData(s.id).title)+" "+w.toDisplayString(t.getDisplayTextForQuestState(s)),1)],2),w.createElementVNode("p",mQ,w.toDisplayString(t.getQuestDescription(s)),1),s.state!=="completed"?(w.openBlock(),w.createElementBlock("ul",gQ,[(w.openBlock(!0),w.createElementBlock(w.Fragment,null,w.renderList(t.getAvailableObjectives(s),u=>(w.openBlock(),w.createElementBlock("li",{class:"quest-objective-display",key:u.id},[w.createElementVNode("p",{class:w.normalizeClass(["quest-objective-description",u.state==="completed"?"quest-objective-completed":"quest-objctive-in-progress"])},w.toDisplayString(t.getObjectiveData(s.id,u.id).description),3)]))),128))])):w.createCommentVNode("",!0)]))),128))])):(w.openBlock(),w.createElementBlock("div",yQ,bQ))]),_:1},8,["onClose"])}const wQ=Yr(dQ,[["render",kQ]]),xQ=w.defineComponent({data(){return{buttons:[{id:"menu",cssId:"menu-button",text:"Menu"},{id:"skills",cssId:"skills-menu-button",text:"Skills",condition:()=>this.showSkills},{id:"inventory",cssId:"inventory-menu-button",text:"Items",condition:()=>this.showInventory},{id:"quests",cssId:"quests-menu-button",text:"Quests",condition:()=>this.showQuests}],activeMenu:!1}},mounted(){document.addEventListener("keydown",t=>{t.key==="Escape"&&this.toggleMenu()}),lr.callHook("onGameMounted")},unmounted(){lr.callHook("onGameUnmounted")},methods:{buttonClick(t){t.onClick?t.onClick():Gt().openModal(t.id)},openMenu(){Gt().openModal("menu")},openSkills(){Gt().openModal("skills")},openInventory(){Gt().openModal("inventory")},openQuests(){Gt().openModal("quests")},closeMenu(){Gt().closeModal()},toggleMenu(){Gt().toggleMenu()}},computed:{buttonsToShow(){return this.buttons.map(t=>{const e=ft().menuButtons[t.id]||{};return{...t,...e}}).filter(t=>t.condition?t.condition():!0)},showSkills(){return Object.entries(ft().skills).length>0},showInventory(){return Object.entries(ft().items).length>0},showQuests(){return Object.entries(ft().quests).length>0}}}),KZ="",jQ={class:"menu-container"},_Q=["onClick","id"];function SQ(t,e,n,r,i,o){return w.openBlock(),w.createElementBlock("div",jQ,[(w.openBlock(!0),w.createElementBlock(w.Fragment,null,w.renderList(t.buttonsToShow,a=>(w.openBlock(),w.createElementBlock("button",{key:a.id,onClick:s=>t.buttonClick(a),id:a.cssId,class:"button menu-toggle-button"},w.toDisplayString(a.text),9,_Q))),128))])}const CQ=Yr(xQ,[["render",SQ]]),$Q=["id"],OQ=["id","onClick"],ry=w.defineComponent({__name:"screen-layer",props:{layer:String,transitioning:{type:Boolean,default:!1}},setup(t){const e=t,n=dn(),r=Gt(),i=Do(),o=w.computed(()=>ft().layout.backgrounds.width),a=w.computed(()=>ft().layout.backgrounds.height),s=w.computed(()=>e.layer),u=w.computed(()=>i.buttons),l=w.computed(()=>{const b=ft().screens[s.value];if(!b)throw new Error(`Screen ${s.value} doesn't have a config`);return b}),f=w.computed(()=>l.value.buttons||[]),c=w.computed(()=>r.isInGame);function d(b){const x=tc(b).background;if(!!x)return r7(x)}function h(b){const k=tc(b),x=u.value[b],$=k.tag||"default",S=x.state;return S===!0&&kr().isInteractionTagBlocked($)?"greyed":S}function p(b){const k=h(b);return k==="hidden"||k==="greyed"||k===!1}function v(b){const k=h(b),x={};return k===!0?x.interactable=!0:(x.disabled=!0,k==="greyed"?x.greyed=!0:(k==="hidden"||k===!1)&&(x.hidden=!0)),x}function m(b){const k=tc(b),x={};h(b),k.position.width&&(x.width=`${k.position.width}px`),k.position.height&&(x.height=`${k.position.height}px`),k.background&&(x.backgroundImage=`url(${d(b)})`);let $=k.position.left,S=k.position.top;return k.anchor&&($=k.position.left-k.position.width*k.anchor.x,S=k.position.top-k.position.height*k.anchor.y),{...x,left:`${$}px`,top:`${S}px`}}function g(b){if(p(b)||e.transitioning)return;const k=tc(b);if(u.value[b].state===!0){const $=k.action;k.actionType==="run"?n.runLabelFunction($):n.jumpToLabel($)}}const y=w.computed(()=>({backgroundImage:`url(${r7(l.value.background)})`,width:`${o.value}px`,height:`${a.value}px`}));return(b,k)=>w.unref(c)?(w.openBlock(),w.createElementBlock("div",{key:0,class:"viewport-layer",id:`viewport-layer-${w.unref(s)}`,style:w.normalizeStyle(w.unref(y))},[(w.openBlock(!0),w.createElementBlock(w.Fragment,null,w.renderList(w.unref(f),(x,$)=>(w.openBlock(),w.createElementBlock("div",{key:$,tabindex:"-1",class:w.normalizeClass(["viewport-button",v(x)]),id:`viewport-button-${x}`,onClick:S=>g(x),style:w.normalizeStyle(m(x))},w.toDisplayString(w.unref(tc)(x).text),15,OQ))),128))],12,$Q)):w.createCommentVNode("",!0)}}),QZ="",EQ=w.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=w.ref("start"),i=w.reactive({oldSlotClasses:{},oldSlotStyle:{},newSlotClasses:{},newSlotStyle:{}});return w.onMounted(async()=>{var a;const o=`narrat-transition-${n.name}`;i.newSlotClasses={[`${o}-enter-from`]:!0,[`${o}-enter-active`]:!0},i.oldSlotStyle={transitionDuration:`${n.duration/1e3}s`},i.newSlotStyle={transitionDuration:`${n.duration/1e3}s`},i.oldSlotClasses={[`${o}-leave-active`]:!0},await to(30),i.oldSlotClasses[`${o}-leave-to`]=!0,await to((a=n.delay)!=null?a:0),delete i.newSlotClasses[`${o}-enter-from`],await to(n.duration),delete i.newSlotClasses[`${o}-enter-active`],delete i.oldSlotClasses[`${o}-leave-active`],r.value="end",e("complete")}),(o,a)=>(w.openBlock(),w.createElementBlock(w.Fragment,null,[r.value!=="end"?(w.openBlock(),w.createElementBlock("div",{key:0,class:w.normalizeClass(["transition-holder",i.oldSlotClasses]),style:w.normalizeStyle(i.oldSlotStyle)},[w.renderSlot(o.$slots,"oldElement",{class:w.normalizeClass(i.oldSlotClasses)})],6)):w.createCommentVNode("",!0),w.createElementVNode("div",{class:w.normalizeClass(["transition-holder",i.newSlotClasses]),style:w.normalizeStyle(i.newSlotStyle)},[w.renderSlot(o.$slots,"newElement")],6)],64))}}),YZ="",AQ=w.defineComponent({__name:"screens",setup(t){const e=ks(),n=Gt(),r=Do(),i=w.computed(()=>r.layers.filter(c=>c)),o=w.computed(()=>e.layoutMode),a=w.computed(()=>ft().layout.backgrounds.width),s=w.computed(()=>ft().layout.backgrounds.height),u=w.computed(()=>n.isInGame);function l(c){r.finishTransition(c)}const f=w.computed(()=>{const c=`${a.value}px`;let d=`${s.value}px`;return o.value==="vertical"&&(d=`${100-ft().layout.mobileDialogHeightPercentage}%`),{height:d,width:c}});return(c,d)=>w.unref(u)?(w.openBlock(),w.createElementBlock("div",{key:0,class:"viewport",id:"narrat-viewport",style:w.normalizeStyle(w.unref(f))},[(w.openBlock(!0),w.createElementBlock(w.Fragment,null,w.renderList(w.unref(i),(h,p)=>(w.openBlock(),w.createElementBlock("div",{key:p,class:"layer-container"},[h.transition?(w.openBlock(),w.createBlock(EQ,{key:0,name:h.transition.transition,duration:h.transition.duration,delay:h.transition.delay,onComplete:()=>l(p)},{oldElement:w.withCtx(()=>[w.createVNode(ry,{layer:h.transition.oldScreen,transitioning:!0},null,8,["layer"])]),newElement:w.withCtx(()=>[w.createVNode(ry,{layer:h.screen,transitioning:!0},null,8,["layer"])]),_:2},1032,["name","duration","delay","onComplete"])):(w.openBlock(),w.createBlock(ry,{key:1,layer:h.screen},null,8,["layer"]))]))),128))],4)):w.createCommentVNode("",!0)}}),XZ="",MQ=w.defineComponent({setup(){const t=pr();return{skills:w.computed(()=>t.skills)}},components:{Modal:ra},data(){return{chosenSkill:!1}},mounted(){},methods:{getSkillStyle(t){return{backgroundImage:`url(${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 ft().skills},xpPerLevel(){return ft().skillOptions.xpPerLevel}}}),ZZ="",TQ=w.createElementVNode("h3",{class:"title"},"Skills",-1),PQ={key:0,class:"skills-container"},IQ=["onClick"],NQ={class:"skill-title"},LQ={class:"skill-xp-container"},DQ={class:"skill-xp-text"},RQ={class:"skill-level"},BQ={key:1},zQ={class:"flex flex-row skill-description-container"},VQ={class:"flex skill-left"},FQ={class:"flex skill-right"},qQ=w.createElementVNode("hr",{class:"hr-solid"},null,-1);function HQ(t,e,n,r,i,o){const a=w.resolveComponent("modal");return w.openBlock(),w.createBlock(a,{class:"menu",onClose:e[1]||(e[1]=s=>t.$emit("close")),containerCssClass:"skills-modal"},{header:w.withCtx(()=>[TQ]),body:w.withCtx(()=>[t.chosenSkill?typeof t.chosenSkill=="string"?(w.openBlock(),w.createElementBlock("div",BQ,[w.createElementVNode("div",zQ,[w.createElementVNode("div",VQ,[w.createElementVNode("div",{class:"skill-display",style:w.normalizeStyle(t.getSkillStyle(t.chosenSkill))},null,4)]),w.createElementVNode("div",FQ,[w.createElementVNode("h2",null,w.toDisplayString(t.getSkillName(t.chosenSkill)),1),qQ,w.createElementVNode("h3",null,"Level: "+w.toDisplayString(t.skills[t.chosenSkill].level),1),w.createElementVNode("p",null,w.toDisplayString(t.skillConf[t.chosenSkill].description),1)])]),w.createElementVNode("button",{class:"button",onClick:e[0]||(e[0]=(...s)=>t.closeSkill&&t.closeSkill(...s))},w.toDisplayString("<--"))])):w.createCommentVNode("",!0):(w.openBlock(),w.createElementBlock("div",PQ,[(w.openBlock(!0),w.createElementBlock(w.Fragment,null,w.renderList(t.skillsToDisplay,s=>(w.openBlock(),w.createElementBlock("button",{onClick:()=>t.clickSkill(s.id),class:"skill-display",style:w.normalizeStyle(t.getSkillStyle(s.id)),key:s.id},[w.createElementVNode("h3",NQ,w.toDisplayString(t.getSkillName(s.id)),1),w.createElementVNode("div",LQ,[w.createElementVNode("div",{class:"skill-xp-bar",style:w.normalizeStyle(t.xpBarWidth(s.xp))},null,4),w.createElementVNode("h3",DQ,w.toDisplayString(s.xp)+" / "+w.toDisplayString(t.xpPerLevel)+" XP",1)]),w.createElementVNode("h3",RQ,w.toDisplayString(s.level),1)],12,IQ))),128))]))]),_:1})}const WQ=Yr(MQ,[["render",HQ]]),UQ=w.defineComponent({data(){return{muted:!1,volumes:[],modeNames:{master:"Master volume:",music:"Music:",ambiant:"Ambiant:",sound:"Sound effects:"}}},mounted(){const t=Ir(),e=Pa.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"?Ir().setMasterVolume(n.value):Ir().setModeVolume(t,n.value)},toggleMute(){this.muted?(Pa.Howler.mute(!1),this.muted=!1):(Pa.Howler.mute(!0),this.muted=!0)}}}),eee="",JQ={class:"volume-controls"},GQ=w.createElementVNode("h3",{class:"subtitle"},"Volume",-1),KQ={for:"volume",class:"volume-label"},QQ=["onUpdate:modelValue","onChange"];function YQ(t,e,n,r,i,o){return w.openBlock(),w.createElementBlock("div",JQ,[GQ,(w.openBlock(!0),w.createElementBlock(w.Fragment,null,w.renderList(t.volumes,(a,s)=>(w.openBlock(),w.createElementBlock("div",{class:"volume-control",key:a.mode},[w.createElementVNode("label",KQ,w.toDisplayString(t.modeNames[a.mode]),1),w.withDirectives(w.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,QQ),[[w.vModelText,t.volumes[s].volume]])]))),128))])}const XQ=Yr(UQ,[["render",YQ]]),ZQ=w.defineComponent({components:{Modal:ra,VolumeControls:XQ},data(){return{}},mounted(){},methods:{quit(){window.close()},mainMenu(){Gt().menuReturn(),this.closeMenu()},closeMenu(){this.$emit("close")},getPlayTimeString(){const t=mc(this.playTime.start,this.playTime.previousPlaytime);return Lh(t/1e3)}},computed:{...Lo(Gt,["playTime"])}}),tee="",eY=w.createElementVNode("h3",{class:"title"},"Menu",-1),tY={class:"menu-content"};function nY(t,e,n,r,i,o){const a=w.resolveComponent("VolumeControls"),s=w.resolveComponent("modal");return w.openBlock(),w.createBlock(s,{class:"menu",onClose:e[2]||(e[2]=u=>t.$emit("close")),containerCssClass:"main-menu-modal"},{header:w.withCtx(()=>[eY]),body:w.withCtx(()=>[w.createElementVNode("div",tY,[w.createElementVNode("h3",null,"Play time: "+w.toDisplayString(t.getPlayTimeString()),1),w.createVNode(a),w.createElementVNode("button",{class:"button title quit-button",onClick:e[0]||(e[0]=(...u)=>t.mainMenu&&t.mainMenu(...u))}," Main Menu "),w.createElementVNode("button",{class:"button title quit-button",onClick:e[1]||(e[1]=(...u)=>t.quit&&t.quit(...u))},"Exit")])]),_:1})}const rY=Yr(ZQ,[["render",nY]]),iY=w.defineComponent({data(){return{}},methods:{getStatImage(t){return xu(this.statsConfig[t].icon)}},computed:{...Lo(ta,["hudStats"]),...Lo(ks,["layoutMode"]),statsConfig(){return ft().hudStats},stats(){return this.hudStats},hudStyle(){let t="0";return this.layoutMode==="horizontal"&&(t=`${ft().layout.minTextWidth}px`),{right:t}}}}),nee="",oY=["src"],aY={class:"bold hud-text"},sY=w.createTextVNode(": ");function uY(t,e,n,r,i,o){return w.openBlock(),w.createElementBlock("div",{class:"hud",style:w.normalizeStyle(t.hudStyle)},[(w.openBlock(!0),w.createElementBlock(w.Fragment,null,w.renderList(t.stats,(a,s)=>(w.openBlock(),w.createElementBlock("div",{key:s,class:"hud-stat"},[w.createElementVNode("img",{class:"hud-icon",src:t.getStatImage(s)},null,8,oY),w.createElementVNode("span",aY,w.toDisplayString(t.statsConfig[s].name),1),sY,w.createElementVNode("span",null,w.toDisplayString(Math.floor(a.value*100)/100),1)]))),128))],4)}const lY=Yr(iY,[["render",uY]]),cY=w.defineComponent({__name:"in-game",setup(t){const e=Gt(),n=ks(),r=w.computed(()=>e.modal),i=w.computed(()=>n.layoutMode),o=w.computed(()=>e.saving),a=w.ref(null),s=w.computed(()=>o.value&&!o.value.withPrompt||o.value&&a.value);function u(){Gt().closeModal()}const l=w.computed(()=>{let h="row";return i.value==="vertical"&&(h="column"),{flexDirection:h}});function f(h){if(a.value=null,h===null){Gt().finishManualSave(h,!1);return}Gt().finishManualSave(h,!0)}function c(){a.value=!0}function d(){a.value=!1,e.finishManualSave(null,!1),a.value=null}return(h,p)=>(w.openBlock(),w.createElementBlock("div",{class:"game",style:w.normalizeStyle(w.unref(l))},[w.createVNode(lY),w.createVNode(CQ,{class:"menu-toggle"}),w.unref(r)==="skills"?(w.openBlock(),w.createBlock(WQ,{key:0,onClose:u})):w.createCommentVNode("",!0),w.unref(r)==="inventory"?(w.openBlock(),w.createBlock(GK,{key:1,onClose:u})):w.createCommentVNode("",!0),w.unref(r)==="quests"?(w.openBlock(),w.createBlock(wQ,{key:2,onClose:u})):w.createCommentVNode("",!0),w.unref(r)==="menu"?(w.openBlock(),w.createBlock(rY,{key:3,onClose:u})):w.createCommentVNode("",!0),w.createVNode(AQ),w.createVNode(fQ,{inGame:!0,layoutMode:w.unref(i)},null,8,["layoutMode"]),w.unref(s)?(w.openBlock(),w.createBlock(n8,{key:4,mode:"pick",onChosen:f,onClose:p[0]||(p[0]=()=>f(null))})):w.createCommentVNode("",!0),w.unref(o)&&w.unref(o).withPrompt&&a.value===null?(w.openBlock(),w.createBlock(Oh,{key:5,prompt:"Would you like to save the game?",onConfirm:c,onRefuse:d})):w.createCommentVNode("",!0)],4))}}),ree="",fY=w.defineComponent({props:{percentage:Number,step:String},methods:{loadingStyle(){return{width:`${this.percentage*60}vw`}}},computed:{}}),iee="",dY={id:"loading-bar"},hY={id:"loading-text"};function pY(t,e,n,r,i,o){return w.openBlock(),w.createElementBlock("div",dY,[w.createElementVNode("div",{id:"inner-loading-bar",style:w.normalizeStyle(t.loadingStyle())},null,4),w.createElementVNode("div",hY,[w.createElementVNode("h3",null,"Loading "+w.toDisplayString(Math.floor(t.percentage*100))+"% - "+w.toDisplayString(t.step),1)])])}const vY=Yr(fY,[["render",pY]]),mY="data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4NCjwhLS0gR2VuZXJhdG9yOiBBZG9iZSBJbGx1c3RyYXRvciAxOS4wLjAsIFNWRyBFeHBvcnQgUGx1Zy1JbiAuIFNWRyBWZXJzaW9uOiA2LjAwIEJ1aWxkIDApICAtLT4NCjxzdmcgdmVyc2lvbj0iMS4xIiBpZD0iUmF0IiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB4PSIwcHgiIHk9IjBweCINCgkgdmlld0JveD0iMCAwIDU5NS4zIDU5NS4zIiBzdHlsZT0iZW5hYmxlLWJhY2tncm91bmQ6bmV3IDAgMCA1OTUuMyA1OTUuMzsiIHhtbDpzcGFjZT0icHJlc2VydmUiPg0KPHN0eWxlIHR5cGU9InRleHQvY3NzIj4NCgkuc3Qwe2ZpbGw6I0UyM0IzMzt9DQo8L3N0eWxlPg0KPHBhdGggaWQ9IlJhdF9TaGFwZSIgY2xhc3M9InN0MCIgZD0iTTU1Ni45LDgyLjVjLTEwLjgtMjQuMy00Ny01Ny4xLTcxLjMtNjUuNmMtMjQuMy04LjQtNjQuMS0wLjMtODguNywyMi4zDQoJYy0yMCwxOC40LTI2LDI4LjItMjkuMSwzN2MtMi4xLDUuOS00LjgsMTMuNS02LDIwLjl2MGMtMC41LDQuMS00LjUsNy04LjYsNi4xYy0xMC40LTIuMy0yOS41LTYtNDQuNC02LjMNCgljLTEzLjctMC4yLTMwLjEsMy4yLTQwLjQsNS43Yy00LjUsMS4xLTguOC0yLjItOC44LTYuOGMtMC4xLTUuMy0xLjEtMTIuMy00LjgtMTkuNmMtOC41LTE2LjktMTkuNi0zMi42LTU3LjgtNDcuNA0KCWMtMzEuOS0xMi40LTc1LjEtOS43LTEwMC44LDEuOGMtMjguMSwxMi42LTQyLjQsMzcuOS01NCw2MS44Yy0xNC40LDI5LjgtMTQuOSw4My42LTYuNCwxMDRjMTIuOCwzMC43LDM1LjgsNDcuMiw1Mi42LDUzDQoJYzExLjMsMy44LDI4LjIsMy43LDM4LjIsMy4zYzQuMi0wLjIsNy43LDMuMyw3LjUsNy41Yy0wLjcsMTMuNi0wLjksNDEuNSw3LDYxLjRjNy43LDE5LjQsMjkuNyw2Mi4zLDUwLjcsMTAxLjINCgljMCwwLjEtMTQuNiwyLjktMzEuNCw2LjhjLTIzLjksNS41LTUyLjYsMTIuNy01NC4zLDEzLjdjLTMuNSwyLjEtMywxMC0yLjcsMTJjMC41LDMuNCw1LjMsOC4xLDYuOSw4LjNjMy45LDAuMywzMS4zLTcuNiw1NS43LTE0LjYNCgljMTguNS01LjMsMzQuOS05LjMsMzUuNS04LjJjNS4xLDkuMywxMCwxOCwxNC40LDI1LjhjNS4yLDkuMSwxMC43LDE2LjQsMTQuMSwyMy42YzEuMSwyLjMtMTYuNiw1LjgtMzIuNSwxNC43DQoJYy0xNi40LDkuMS0yOS43LDIxLTMyLjMsMjRjLTEuOCwyLjEtMyw2LTEuMiwxMC43YzEuMSwyLjksMTAsNS43LDEyLjQsNS4xYzYuOC0xLjcsMTYuNS0xMi41LDMzLjEtMjEuMQ0KCWMxNi4zLTguNSwzMi45LTE0LjksMzMuOC0xMy42YzkuNywxNC4zLDE2LjksMjEuNiwyMi42LDMxLjJjOS44LDE2LjUsMjcuMyw0NS45LDQ2LjYsMzkuNWM2LjQtMi4xLDMxLjEtMzMuNiw1My4zLTY4LjYNCgljMS4zLTIuMSwxNi4xLDExLjMsMzAuNCwyMy4yYzEzLjgsMTEuNCwyMi43LDIwLjYsMjcuMSwyMS40YzUuNCwxLDE0LjItNy43LDE0LjEtMTQuN2MtMC4xLTIuNy0xNC4zLTEzLjgtMjkuMS0yNi4yDQoJYy0xNC41LTEyLjEtMzAuMS0yMi44LTI5LjItMjQuM2M3LjYtMTIsMTQuNS0yMy43LDIwLjEtMzMuOWM0LjMtNy44LDguOS0xNiwxMy0yNC43YzAuNi0xLjIsMTUuOSwzLDMxLjQsNy4xYzE1LjMsNCwyNi43LDEwLDMxLDgNCgljNi45LTMsMTEuNi0xMy44LDkuNC0xOC4zYy0xLjEtMi4zLTE3LTcuMy0zMy4yLTEyYy0xNC4yLTQuMS0yOC02LjUtMjcuNy03LjNjMTUuNS0zNCwyOC44LTY0LjgsMjcuNi02OS42DQoJYy0xLjctNy4xLDIuNi0xMS45LDctMzYuNWMzLjItMTguMSw0LjctNDAuOSw1LjItNTEuN2MwLjItMy41LDIuOC02LjMsNi4zLTYuN2MzLjEtMC4zLDYuOS0wLjksMTAuNS0xLjljNy44LTIsMTguNi03LjgsMzYuNC0yMC42DQoJYzE3LjktMTIuOCwzOC43LTQ5LjYsNDQuNC02Ny44UzU2Ny42LDEwNi44LDU1Ni45LDgyLjV6IE0yNjUuMSwzMzYuMmMtOC4xLDQtMTMsNy0yNi40LDkuNmMtNi45LDEuNC0yOS40LTAuMi00MC43LTQuNg0KCWMtMTAuNS00LjEtMTkuOS03LjYtMzAtMTUuNHMtMTUuNy0xMy4yLTE1LjctMTUuM2MwLTQuNCw2LTkuNCwxMS05LjRjNS4xLDAsMTQuNSw5LjIsMjkuNywxNi42YzE0LjMsNywxNy45LDYuMSwyNS40LDcuMw0KCWMyLjksMC41LDcuNywwLjYsMTAuNywwLjRjMTQuMS0xLjMsMjEuNC01LjksMjUuMy04LjhjNC0zLDEzLjctMTIuOSwxNy4yLTEyLjVjOCwxLDE4LjksMy40LDE4LjksNy4xDQoJQzI5MC40LDMxOSwyNzMuMiwzMzIuMSwyNjUuMSwzMzYuMnogTTMyMC45LDUyMS40Yy00LjMsMy43LTE3LjcsMTMuNS0yMy4zLDEzLjVjLTIuOCwwLTcuNC04LjItMTEuNS0xNi44DQoJYy00LjEtOC41LTkuMS0yMS4xLTkuMS0zMS42YzAtNC42LDYtNy40LDEzLjQtOS4yYzcuMi0xLjcsMjcuMy0xLjgsMjkuOS0xLjFjNi44LDEuNywxMi45LDIuMiwxMi43LDYuNGMtMC40LDEyLjctNywxOC45LTguMywyNC4zDQoJQzMyMy40LDUxMi4zLDMyMy40LDUxOS4yLDMyMC45LDUyMS40eiBNNDMxLjEsMzIwLjNjLTkuMiw3LjQtMTAuNiw4LjEtMjQuOSwxMy43Yy0xMS4zLDQuNC0yOC42LDUuOC00MS42LDMuNg0KCWMtMTIuMi0yLjEtMjIuMy00LjYtMjkuNS0xMC4xYy05LjctNy4zLTE2LjQtMTUuMS0xNi40LTE5LjhjMC0zLjcsNi40LTQuMywxNC41LTQuOWMzLjUtMC4zLDkuMyw1LjksMTMuMiw5LjINCgljOC4xLDYuOCwxNC44LDgsMjguOCw5LjljMi45LDAuNCw3LjgsMC40LDEwLjcsMC4xYzcuNS0wLjksMTItMC40LDI1LjgtOC4yYzIwLTExLjIsMTcuOC0xNC40LDI1LjEtMTIuNmMyLjIsMC42LDUuOCwxLjIsNS42LDUuNg0KCUM0NDIuNCwzMDksNDQwLjUsMzEyLjcsNDMxLjEsMzIwLjN6Ii8+DQo8L3N2Zz4NCg==",gY={id:"engine-splash-screen",class:"flex justify-center items-center"},yY={id:"engine-splash-title"},bY=["src"],kY=w.defineComponent({__name:"engine-splash",emits:["finished"],setup(t,{emit:e}){const n=w.ref("hidden"),r=w.computed(()=>({transitionDuration:`${l.value}s`})),i=w.computed(()=>({invisible:n.value!=="appear"})),o=Gt(),a=w.computed(()=>{var c,d;return(d=(c=ft().splashScreens)==null?void 0:c.engineSplashScreen)!=null?d:{}}),s=w.computed(()=>typeof a.value.overrideText=="string"?a.value.overrideText:"Made with narrat engine"),u=w.computed(()=>{var c;return(c=a.value.overrideLogo)!=null?c:mY}),l=w.computed(()=>typeof a.value.fadeDuration=="number"?a.value.fadeDuration:2),f=w.computed(()=>typeof a.value.timeBeforeFadeout=="number"?a.value.timeBeforeFadeout:3);return w.onMounted(async()=>{if(a.value.skip||o.options.debug){e("finished");return}await to(10),n.value="appear",await to(l.value*1e3),await to(f.value*1e3),n.value="disappear",await to(l.value*1e3),o.loading.loaded?e("finished"):o.listener.once("gameLoaded",()=>{e("finished")})}),(c,d)=>(w.openBlock(),w.createElementBlock("div",gY,[w.createElementVNode("div",{id:"engine-splash-header",class:w.normalizeClass(["flex justify-center flex-col items-center",w.unref(i)]),style:w.normalizeStyle(w.unref(r))},[w.createElementVNode("h1",yY,w.toDisplayString(w.unref(s)),1),w.createElementVNode("img",{src:w.unref(u),alt:"Narrat Logo",id:"engine-splash-logo"},null,8,bY),w.createVNode(vY,{percentage:w.unref(o).loading.percentage,step:w.unref(o).loading.step},null,8,["percentage","step"])],6)]))}}),oee="",wY={id:"game-splash-screen",style:{height:"100%",padding:"20px"},class:"flex justify-center items-center"},xY={id:"game-splash-screen-header flex justify-center flex-col items-center",class:"flex justify-center flex-col items-center"},jY={class:"title",id:"game-splash-title"},_Y=w.defineComponent({__name:"game-splash",setup(t){const e=Gt(),n=w.computed(()=>{var s,u;return(u=(s=ft().splashScreens)==null?void 0:s.gameSplashScreen)!=null?u:{}}),r=w.computed(()=>typeof n.value.startButtonText=="string"?n.value.startButtonText:"Press to start"),i=w.computed(()=>e.loading.loaded),o=w.computed(()=>ft().gameTitle||"Narrat Game");function a(){e.flowState="menu"}return w.onMounted(()=>{e.options.debug&&a()}),(s,u)=>(w.openBlock(),w.createElementBlock("div",wY,[w.createElementVNode("div",xY,[w.createElementVNode("h1",jY,w.toDisplayString(w.unref(o)),1),w.unref(i)?(w.openBlock(),w.createElementBlock("button",{key:0,class:"button menu-button main-menu-button large splash-start-button override",onClick:a},w.toDisplayString(w.unref(r)),1)):w.createCommentVNode("",!0)])]))}}),aee="",SY=w.defineComponent({setup(){const t=ii(),e=dn(),n=Gt();return{dialog:w.computed(()=>t.dialog),stack:w.computed(()=>e.stack),modal:w.computed(()=>n.modal),flowState:w.computed(()=>n.flowState),alerts:w.computed(()=>n.alerts)}},$refs:{dialogContainer:HTMLInputElement},inject:["mq"],components:{DebugMenu:lK,NotificationToast:hK,StartMenu:AK,AlertModal:PK,InGame:cY,EngineSplash:kY,GameSplash:_Y},data(){return{lineTitle:"title",lineText:"hello"}},props:{options:Object},async mounted(){lr.callHook("onAppMounted"),await Gt().engineLoading(),window.addEventListener("resize",t8(()=>{this.updateScreenSize()},100,{maxWait:200})),sc.setup(this.options.debug),setTimeout(()=>{this.updateScreenSize()},50)},computed:{...Lo(ks,["screenWidth","screenHeight","canvasWidth","canvasHeight","topOffset","leftOffset","layoutMode"]),...Lo(dn,["currentLine"]),backgroundStyle(){let t;return this.layoutMode==="vertical"&&(t=`${100-ft().layout.mobileDialogHeightPercentage}%`),{backgroundColor:"red",height:t}},layoutWidth(){return ft().layout.backgrounds.width},layoutHeight(){return ft().layout.backgrounds.height},backgroundSize(){return{width:this.canvasWidth,height:this.canvasHeight,top:this.topOffset,left:this.leftOffset}},gameWidth(){const t=ft();return this.layoutMode==="vertical"?window.innerWidth:t.layout.backgrounds.width+t.layout.minTextWidth},gameHeight(){const t=ft();return this.layoutMode==="vertical"?window.innerHeight:t.layout.backgrounds.height},appStyle(){const t=ft();if(this.screenWidth&&this.screenHeight&&t&&this.layoutMode==="horizontal"){const e=e8(this.screenWidth,this.screenHeight,this.gameWidth,this.gameHeight);return{transform:`scale(${e}, ${e})`,width:`${this.gameWidth}px`,height:`${this.gameHeight}px`}}return{}},gameStyle(){let t="row";return this.layoutMode==="vertical"&&(t="column"),{flexDirection:t}},screenRatio(){const t=ft(),e=t.layout.minTextWidth+t.layout.backgrounds.width;return this.screenWidth/e}},methods:{closeAlert(t){Gt().closeAlert(t)},engineSplashDone(){Gt().flowState="game-splash"},updateScreenSize(){ks().updateScreenSize(window.innerWidth,window.innerHeight,this.layoutMode==="horizontal"?ft().layout.minTextWidth*this.screenRatio:0)}}}),see="";function CY(t,e,n,r,i,o){const a=w.resolveComponent("EngineSplash"),s=w.resolveComponent("GameSplash"),u=w.resolveComponent("StartMenu"),l=w.resolveComponent("InGame"),f=w.resolveComponent("DebugMenu"),c=w.resolveComponent("NotificationToast"),d=w.resolveComponent("AlertModal");return w.openBlock(),w.createElementBlock("div",{id:"app",style:w.normalizeStyle(t.appStyle)},[t.flowState==="engine-splash"?(w.openBlock(),w.createBlock(a,{key:0,onFinished:t.engineSplashDone},null,8,["onFinished"])):(w.openBlock(),w.createBlock(w.Transition,{key:1,name:"screens-fade"},{default:w.withCtx(()=>[t.flowState==="game-splash"?(w.openBlock(),w.createBlock(s,{key:"1"})):t.flowState==="menu"?(w.openBlock(),w.createBlock(u,{key:"2"})):t.flowState==="playing"?(w.openBlock(),w.createBlock(l,{key:"3"})):w.createCommentVNode("",!0)]),_:1})),t.options.debug?(w.openBlock(),w.createBlock(f,{key:2})):w.createCommentVNode("",!0),w.createVNode(c),(w.openBlock(!0),w.createElementBlock(w.Fragment,null,w.renderList(t.alerts,h=>(w.openBlock(),w.createBlock(d,{key:h.id,title:h.title,text:h.text,onClose:()=>t.closeAlert(h.id)},null,8,["title","text","onClose"]))),128))],4)}const $Y=Yr(SY,[["render",CY]]);function vn(t,e){console.error("Runtime error ========================="),console.error(`Command: ${t.commandType}`),console.error("Args: ",t.args),console.error("Options: ",t.options),Sn(`Runtime error at ${t.fileName}:${t.line} (${t.commandType}) ${t.code}. -
182
+ <br />`),n.createError(`\u274C ${t}`)}const pr=io("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:this.skillChecks,skills: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=$h(this.skillChecks,t.skillChecks),this.skills=$h(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||Sn(`Skill ${t} doesn't exist`),n.xp+=e,n.xp>=ft().skillOptions.xpPerLevel&&(n.xp=0,n.level++,this.levelledUp(t))},setSkillLevel(t,e){const n=this.getSkill(t);n||Sn(`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=ft().skills[t].name,n=this.skills[t].level;ft().skillOptions.notifyLevelUp&&Ii().addNotification(`Your skill in ${e} is now level ${n}`)}}});let Z7;const DG=w.defineComponent({components:{Modal:ra},setup(){const t=pr(),e=w.computed(()=>t.skills),n=w.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];dn().jumpToLabel(e),this.finishJumping()}})},methods:{finishJumping(){this.jumping=!1,this.matches=[],this.searchString=""},labelSelected(t){const e=t.target.value;dn().jumpToLabel(e),this.close()},close(){this.showDebug=!1},closeErrors(){Gt().clearErrors()},open(){this.showDebug=!0;const t=dn(),e=Gt(),n=Kr(),r=kr(),i=pr();this.$nextTick(()=>{new QT({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 QT({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(){Z7=new Cs(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=Z7.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(){Gt().autoSaveGame({})},wordCount(){const e=Object.values(this.script).reduce((n,r)=>(Bi.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=mc(this.playTime.start,this.playTime.previousPlaytime);return Lh(t/1e3)}},computed:{...Lo(dn,["script","data"]),...Lo(Gt,["playTime","errors","playing","flowState"]),labels(){const t=this.script;return Object.keys(t).sort()},variables(){return this.data}}}),TZ="",RG={class:"debug-menu"},BG={key:0,class:"debug-info"},zG=[w.createElementVNode("h3",null,"Debug mode is ON",-1),w.createElementVNode("ul",null,[w.createElementVNode("li",null,[w.createElementVNode("b",null,"j"),w.createTextVNode(": Quick Label Jump")]),w.createElementVNode("li",null,[w.createElementVNode("b",null,"d"),w.createTextVNode(": Debug Menu")]),w.createElementVNode("li",null,[w.createElementVNode("b",null,"Escape"),w.createTextVNode(": Toggle Menu")])],-1)],VG=w.createElementVNode("h3",{class:"title"},"Jump to label",-1),FG={key:0,class:"search-results"},qG={key:1},HG=[w.createElementVNode("h3",null,"No matches found",-1)],WG=w.createElementVNode("h3",{class:"title"},"Error(s)",-1),UG=w.createTextVNode(" There are errors in your dialogue scripts. Open the developer console for more details. "),JG=["innerHTML"],GG=w.createElementVNode("h3",{class:"title"},"Debug Menu!",-1),KG={class:"container"},QG=w.createTextVNode(" Hello this is the debug menu. "),YG=w.createElementVNode("option",{class:"option",selected:"",disabled:""},"Jump to a label",-1),XG=["value"],ZG={class:"grid grid-cols-3 gap-4"},eK=w.createElementVNode("h2",null,"Variables Editor",-1),tK={ref:"variablesViewer"},nK=w.createElementVNode("h2",null,"Skill Checks",-1),rK={class:"table-auto"},iK=w.createElementVNode("thead",null,[w.createElementVNode("tr",null,[w.createElementVNode("th",null,"Skill Check"),w.createElementVNode("th",null,"Happened"),w.createElementVNode("th",null,"Succeeded")])],-1),oK=w.createElementVNode("h2",null,"App State editor (entire app and engine",-1),aK=w.createElementVNode("h3",{style:{color:"pink"}}," Use for debugging, editing some of those things can cause issues ",-1),sK={ref:"stateViewer"};function uK(t,e,n,r,i,o){const a=w.resolveComponent("modal");return w.openBlock(),w.createElementBlock("div",RG,[w.createElementVNode("button",{onClick:e[0]||(e[0]=(...s)=>t.open&&t.open(...s)),class:"button debug-button"},"Debug Menu"),!t.playing&&t.flowState==="menu"?(w.openBlock(),w.createElementBlock("div",BG,zG)):w.createCommentVNode("",!0),t.jumping?(w.openBlock(),w.createBlock(a,{key:1,onClose:t.finishJumping,containerCssClass:"jump-menu-container"},{header:w.withCtx(()=>[VG]),body:w.withCtx(()=>[w.withDirectives(w.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),[[w.vModelText,t.searchString]]),t.matches.length>0?(w.openBlock(),w.createElementBlock("div",FG,[(w.openBlock(!0),w.createElementBlock(w.Fragment,null,w.renderList(t.matches,(s,u)=>(w.openBlock(),w.createElementBlock("div",{class:"search-result",style:w.normalizeStyle(t.getMatchResultStyle(u)),key:u},w.toDisplayString(s),5))),128))])):(w.openBlock(),w.createElementBlock("div",qG,HG))]),_:1},8,["onClose"])):w.createCommentVNode("",!0),t.errors.length>0?(w.openBlock(),w.createBlock(a,{key:2,onClose:t.closeErrors,containerCssClass:"debug-menu-container"},{header:w.withCtx(()=>[WG]),body:w.withCtx(()=>[UG,w.createElementVNode("ul",null,[(w.openBlock(!0),w.createElementBlock(w.Fragment,null,w.renderList(t.errors,(s,u)=>(w.openBlock(),w.createElementBlock("li",{key:u,class:"error-message list-disc",innerHTML:s.text},null,8,JG))),128))])]),_:1},8,["onClose"])):w.createCommentVNode("",!0),t.showDebug?(w.openBlock(),w.createBlock(a,{key:3,onClose:t.close,containerCssClass:"debug-menu-container"},{header:w.withCtx(()=>[GG]),body:w.withCtx(()=>[w.createElementVNode("div",KG,[QG,w.createElementVNode("select",{class:"select",name:"label-selector",onChange:e[3]||(e[3]=s=>t.labelSelected(s))},[YG,(w.openBlock(!0),w.createElementBlock(w.Fragment,null,w.renderList(t.labels,s=>(w.openBlock(),w.createElementBlock("option",{class:"option",value:s,key:s},w.toDisplayString(s),9,XG))),128))],32),w.createElementVNode("div",ZG,[w.createElementVNode("button",{onClick:e[4]||(e[4]=(...s)=>t.wordCount&&t.wordCount(...s)),class:"button"},"Word Count"),w.createElementVNode("button",{onClick:e[5]||(e[5]=(...s)=>t.save&&t.save(...s)),class:"button"},"Save Game")]),w.createElementVNode("h3",null,"Play time: "+w.toDisplayString(t.getPlayTimeString()),1),eK,w.createElementVNode("div",tK,null,512),nK,w.createElementVNode("table",rK,[iK,w.createElementVNode("tbody",null,[(w.openBlock(!0),w.createElementBlock(w.Fragment,null,w.renderList(t.skillChecks,(s,u)=>(w.openBlock(),w.createElementBlock("tr",{key:u},[w.createElementVNode("td",null,w.toDisplayString(u),1),w.createElementVNode("td",null,w.toDisplayString(s.happened?"\u2705":"\u274C"),1),w.createElementVNode("td",null,w.toDisplayString(s.happened?s.succeeded?"\u2705":"\u274C":"NA"),1)]))),128))])]),oK,aK,w.createElementVNode("div",sK,null,512)])]),_:1},8,["onClose"])):w.createCommentVNode("",!0)])}const lK=Yr(DG,[["render",uK]]),cK=w.defineComponent({data(){},methods:{},computed:{...Lo(Ii,["notifications"])}}),LZ="",fK=["innerHTML"];function dK(t,e,n,r,i,o){return w.openBlock(),w.createBlock(w.TransitionGroup,{name:"notification",tag:"div",class:"notifications-holder"},{default:w.withCtx(()=>[(w.openBlock(!0),w.createElementBlock(w.Fragment,null,w.renderList(t.notifications,(a,s)=>(w.openBlock(),w.createElementBlock("div",{class:"notification",key:s},[w.createElementVNode("h3",{innerHTML:a.text},null,8,fK)]))),128))]),_:1})}const hK=Yr(cK,[["render",dK]]);function e8(t,e,n,r){const i=t/n,o=e/r;return Math.min(i,o)}function t8(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 k=t.apply(p,h);o&&o(k),u.forEach(({resolve:x})=>x(k)),u=[]}},y=i&&r===void 0;r!==void 0&&clearTimeout(r);const b=l();if(r=setTimeout(g,b),y){const k=t.apply(p,h);return o&&o(k),v(k)}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 pK={class:"save-slot flex flex-row"},vK={class:"used-save-slot flex flex-row justify-between items-center grow"},mK={class:"flex flex-col"},gK={class:"flex flex-col"},yK={class:"flex flex-row"},bK=["onClick"],kK=w.defineComponent({__name:"save-slot",props:{saveSlot:{type:Object,required:!0},id:{type:String,required:!0},actions:{type:Array,required:!0}},emits:["choice"],setup(t,{emit:e}){const n=t,r=w.ref(n.saveSlot.metadata.name);function i(s){e("choice",s)}function o(s){return Lh(s.main.playTime/1e3)}function a(){QJ(n.saveSlot.metadata.id,r.value)}return(s,u)=>(w.openBlock(),w.createElementBlock("div",pK,[w.createElementVNode("div",vK,[w.createElementVNode("div",mK,[w.withDirectives(w.createElementVNode("input",{type:"text",class:"save-name","onUpdate:modelValue":u[0]||(u[0]=l=>r.value=l),onInput:a},null,544),[[w.vModelText,r.value]]),w.createElementVNode("div",gK,[w.createElementVNode("p",null,"Play time: "+w.toDisplayString(o(t.saveSlot)),1),w.createElementVNode("p",null," Last save: "+w.toDisplayString(new Date(t.saveSlot.metadata.saveDate).toLocaleString()),1),w.createElementVNode("p",null,w.toDisplayString(t.saveSlot.metadata.slotType==="auto"?"Auto Save":"Manual Save"),1)])]),w.createElementVNode("div",yK,[(w.openBlock(!0),w.createElementBlock(w.Fragment,null,w.renderList(t.actions,(l,f)=>(w.openBlock(),w.createElementBlock("button",{class:"button",onClick:()=>i(f),key:f},[w.createElementVNode("h3",null,w.toDisplayString(l),1)],8,bK))),128))])])]))}}),DZ="",wK=w.createElementVNode("h3",{class:"title"},"Confirmation",-1),xK={class:"flex justify-center"},Oh=w.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)=>(w.openBlock(),w.createBlock(ra,{onClose:o[2]||(o[2]=()=>r(!1)),containerCssClass:"yes-no-modal"},{header:w.withCtx(()=>[wK]),body:w.withCtx(()=>[w.createElementVNode("h3",null,w.toDisplayString(t.prompt),1),w.createElementVNode("div",xK,[w.createElementVNode("button",{class:"button",onClick:o[0]||(o[0]=()=>r(!0))},"Yes"),w.createElementVNode("button",{class:"button",onClick:o[1]||(o[1]=()=>r(!1))},"No")])]),_:1}))}}),RZ="",jK={class:"title"},_K={class:"saves-container flex flex-col"},n8=w.defineComponent({__name:"save-slots",props:{mode:{type:String,required:!0}},emits:["chosen","close"],setup(t,{emit:e}){const n=t,r=w.reactive([]),i=w.reactive(n.mode==="load"?["Load","Delete"]:["Choose"]),o=w.reactive({prompt:"Are you sure you want to delete this save file?",saveToDelete:null,onConfirm:()=>{f(o.saveToDelete),o.saveToDelete=null},onRefuse:()=>{o.saveToDelete=null}}),a=w.reactive({prompt:"Are you sure you want to overwrite this save file?",saveToOverwrite:null,onConfirm:()=>{u(a.saveToOverwrite),a.saveToOverwrite=null},onRefuse:()=>{a.saveToOverwrite=null}});w.onMounted(()=>{let p=oc().slots.sort((v,m)=>new Date(m.metadata.saveDate).getTime()-new Date(v.metadata.saveDate).getTime());n.mode==="pick"&&(p=p.filter(v=>v.metadata.slotType!=="auto")),console.log(p),p.forEach((v,m)=>{r[m]=v})});function s(){const p=T7();u(p)}function u(p){const v={saveData:h(p),slotId:p};e("chosen",v)}function l(p){const v=h(p);if(v){if(ft().saves.mode==="manual"&&v.metadata.slotType==="auto"){Gt().alert("Sorry","Can't delete the auto save slot!");return}o.saveToDelete=p}}function f(p){KJ(p);const v=r.findIndex(m=>m.metadata.id===p);r.splice(v,1)}function c(){n.mode!=="pick"&&e("close")}function d(p,v){const m=i[v];m==="Load"?u(p):m==="Delete"?l(p):m==="Choose"&&(a.saveToOverwrite=p)}function h(p){return r.find(v=>v.metadata.id===p)}return(p,v)=>(w.openBlock(),w.createBlock(ra,{onClose:c,containerCssClass:"save-modal",cantClose:n.mode==="pick"},{header:w.withCtx(()=>[w.createElementVNode("h3",jK,w.toDisplayString(t.mode==="load"?"Choose a save to load":"Pick a slot to save the game"),1)]),body:w.withCtx(()=>[w.createElementVNode("div",{class:"flex justify-center"},[w.createElementVNode("button",{class:"button",onClick:s},"Create a new save")]),w.createElementVNode("div",_K,[w.createVNode(w.TransitionGroup,{name:"list",tag:"div"},{default:w.withCtx(()=>[(w.openBlock(!0),w.createElementBlock(w.Fragment,null,w.renderList(r,m=>(w.openBlock(),w.createBlock(kK,{key:m.metadata.id,saveSlot:m,id:m.metadata.id,actions:i,onChoice:g=>d(m.metadata.id,g)},null,8,["saveSlot","id","actions","onChoice"]))),128))]),_:1})]),o.saveToDelete?(w.openBlock(),w.createBlock(Oh,{key:0,prompt:o.prompt,onRefuse:o.onRefuse,onConfirm:o.onConfirm},null,8,["prompt","onRefuse","onConfirm"])):w.createCommentVNode("",!0),a.saveToOverwrite?(w.openBlock(),w.createBlock(Oh,{key:1,prompt:a.prompt,onRefuse:a.onRefuse,onConfirm:a.onConfirm},null,8,["prompt","onRefuse","onConfirm"])):w.createCommentVNode("",!0)]),_:1},8,["cantClose"]))}}),BZ="",SK={id:"game-menu"},CK={id:"game-header",class:"flex flex-col justify-between items-center"},$K={id:"game-title-container"},OK={id:"game-title-text"},EK={class:"flex flex-col start-menu-buttons-container"},AK=w.defineComponent({__name:"StartMenu",setup(t){const e=w.ref(!1),n=w.ref(null),r=w.ref(null),i=w.ref(!1),o=w.ref(!1);async function a(){e.value&&ft().saves.mode==="manual"?o.value=!0:s()}async function s(){const p=Gt();r.value===null&&(r.value=T7()),o.value=!1,await p.startGame(r.value)}function u(){o.value=!1}async function l(){if(!r.value)return;const p=Ch(r.value);if(!p){Sn("No save file found");return}Gt().loadGame(p,r.value)}function f(){typeof n.value=="string"&&(r.value=n.value,l())}function c(){i.value=!0}function d({saveData:p,slotId:v}){r.value=v,p?l():a()}w.onMounted(()=>{const p=ft();p.audioOptions.defaultMusic&&Ir().playChannel("music",p.audioOptions.defaultMusic,0);const v=oc();v.slots.length>0&&(e.value=!0),v.lastSaveSlot&&Ch(v.lastSaveSlot)&&(n.value=v.lastSaveSlot)});const h=w.computed(()=>ft().gameTitle);return(p,v)=>(w.openBlock(),w.createElementBlock("div",SK,[i.value?(w.openBlock(),w.createBlock(n8,{key:0,mode:"load",onChosen:d,onClose:v[0]||(v[0]=m=>i.value=!1)})):w.createCommentVNode("",!0),o.value?(w.openBlock(),w.createBlock(Oh,{key:1,prompt:"This will override your previous autosave, are you sure?",onConfirm:s,onRefuse:u})):w.createCommentVNode("",!0),w.createElementVNode("div",CK,[w.createElementVNode("div",$K,[w.createElementVNode("h1",OK,w.toDisplayString(w.unref(h)),1)]),w.createElementVNode("div",EK,[n.value?(w.openBlock(),w.createElementBlock("button",{key:0,class:"button menu-button main-menu-button large continue-button override",onClick:f}," Continue ")):w.createCommentVNode("",!0),w.createElementVNode("button",{class:"button menu-button main-menu-button large start-button override",onClick:a}," New Game "),e.value?(w.openBlock(),w.createElementBlock("button",{key:1,class:"button menu-button main-menu-button large continue-button override",onClick:c}," Load Game ")):w.createCommentVNode("",!0)])])]))}}),zZ="";class MK extends X7{setup(e=!1){const r=e?"keydown":"keyup",i=t8(o=>{sc.emit("debouncedKeydown",o)},10,{isImmediate:!0,maxWait:10});window.addEventListener("keydown",o=>{sc.emit("keydown",o)}),window.addEventListener(r,o=>{i(o)})}}const sc=new MK,TK={class:"title"},PK=w.defineComponent({__name:"alert-modal",props:{title:{type:String,required:!1},text:{type:String,required:!1}},setup(t){return(e,n)=>(w.openBlock(),w.createBlock(ra,{onClose:n[0]||(n[0]=r=>e.$emit("close")),containerCssClass:"yes-no-modal"},{header:w.withCtx(()=>{var r;return[w.createElementVNode("h3",TK,w.toDisplayString((r=t.title)!=null?r:"Alert"),1)]}),body:w.withCtx(()=>[w.createElementVNode("h3",null,w.toDisplayString(t.text),1)]),_:1}))}}),VZ="",IK=w.defineComponent({setup(){const t=kr(),e=ii(),n=w.computed(()=>t.items),r=w.computed(()=>e.currentDialog.choices);return{items:n,currentlyChoosing:r}},components:{Modal:ra},data(){return{chosenId:!1}},mounted(){},methods:{close(){this.$emit("close")},getItemStyle(t){return{backgroundImage:`url(${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(),t.action==="jump"?dn().jumpToLabel(t.label):t.action==="run"?dn().runThenGoBackToPreviousDialog(t.label,!0):Sn(`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 ft().items}}}),FZ="",NK=w.createElementVNode("h3",{class:"title"},"Inventory",-1),LK={key:0,class:"inventory-container"},DK=["onClick"],RK={class:"item-title"},BK={class:"item-amount"},zK={key:1},VK={class:"flex flex-row item-description-container"},FK={class:"flex item-left"},qK={class:"flex item-right"},HK=w.createElementVNode("hr",{class:"hr-solid"},null,-1),WK={key:2},UK=[w.createElementVNode("h2",null,"The inventory is empty!",-1)];function JK(t,e,n,r,i,o){const a=w.resolveComponent("modal");return w.openBlock(),w.createBlock(a,{class:"menu",onClose:t.close,containerCssClass:"inventory-modal"},{header:w.withCtx(()=>[NK]),body:w.withCtx(()=>[!t.chosenItem&&Object.keys(t.itemsToDisplay).length>0?(w.openBlock(),w.createElementBlock("div",LK,[(w.openBlock(!0),w.createElementBlock(w.Fragment,null,w.renderList(t.itemsToDisplay,s=>(w.openBlock(),w.createElementBlock("button",{onClick:()=>t.clickItem(s.id),class:"item-display",style:w.normalizeStyle(t.getItemStyle(s.id)),key:s.id},[w.createElementVNode("h3",RK,w.toDisplayString(t.getItemName(s.id)),1),w.createElementVNode("h3",BK,w.toDisplayString(s.amount),1)],12,DK))),128))])):typeof t.chosenId=="string"?(w.openBlock(),w.createElementBlock("div",zK,[w.createElementVNode("div",VK,[w.createElementVNode("div",FK,[w.createElementVNode("div",{class:"item-display",style:w.normalizeStyle(t.getItemStyle(t.chosenId))},null,4)]),w.createElementVNode("div",qK,[w.createElementVNode("h2",null,w.toDisplayString(t.getItemName(t.chosenId)),1),HK,w.createElementVNode("h3",null,"Amount: "+w.toDisplayString(t.chosenItem.amount),1),w.createElementVNode("p",null,w.toDisplayString(t.chosenItemConf.description),1),w.createElementVNode("button",{onClick:e[0]||(e[0]=(...s)=>t.useItem&&t.useItem(...s)),class:w.normalizeClass(["button",t.canUseChosenItem?"":"disabled"])}," Use ",2)])]),w.createElementVNode("button",{class:"button",onClick:e[1]||(e[1]=(...s)=>t.closeItem&&t.closeItem(...s))},w.toDisplayString("<--"))])):(w.openBlock(),w.createElementBlock("div",WK,UK))]),_:1},8,["onClose"])}const GK=Yr(IK,[["render",JK]]),KK=w.defineComponent({props:{pictureUrl:String},methods:{getAssetUrl(t){return xu(t)}},computed:{...Lo(ks,["layoutMode"]),boxStyle(){const t=ft().layout;let e=0,n=0;return this.layoutMode==="vertical"?(e="50%",n=`${t.mobileDialogHeightPercentage-5}%`):(e=`${t.minTextWidth-10}px`,n="20%"),{right:e,bottom:n,width:`${t.portraits.width}px`,height:`${t.portraits.height}px`}}}}),HZ="",QK=["src"];function YK(t,e,n,r,i,o){return w.openBlock(),w.createElementBlock("div",{class:"dialog-picture override",style:w.normalizeStyle(t.boxStyle)},[w.createElementVNode("img",{src:t.getAssetUrl(t.pictureUrl),class:"picture override"},null,8,QK)],4)}const XK=Yr(KK,[["render",YK]]),ZK=w.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=sc.on("debouncedKeydown",t),this.timeout=setTimeout(()=>{this.options.textField&&this.$refs.playerInput.focus()},10)}},unmounted(){this.clearListeners()},computed:{...Lo(Gt,["paused"]),preText(){return this.options.title?" &nbsp;\u2013&nbsp; ":""},style(){return xh(this.options.styleId)},dialogBoxStyle(){const t=xh(this.options.styleId),e={opacity:this.options.old?"0.7":"1"};return this.options.title||(e.marginTop="-20px"),{...t.boxCss,...e}},titleStyle(){const t=xh(this.options.styleId);return{color:t.color,...t.nameCss}},textStyle(){return xh(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&&(sc.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,Gt().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;Gt().playerAnswered(t)}}}),WZ="",eQ={class:"dialog-content"},tQ=["innerHTML"],nQ=["innerHTML"],rQ=["innerHTML"],iQ={key:1,class:"dialog-choices"},oQ=["onClick","innerHTML"],aQ={key:2},sQ={key:3,class:"buttons-container"};function uQ(t,e,n,r,i,o){return w.openBlock(),w.createElementBlock("div",{class:"dialog-box w-full override",style:w.normalizeStyle(t.dialogBoxStyle)},[w.createElementVNode("div",eQ,[t.options.title?(w.openBlock(),w.createElementBlock("span",{key:0,class:"dialog-title override",style:w.normalizeStyle(t.titleStyle),innerHTML:t.options.title},null,12,tQ)):w.createCommentVNode("",!0),w.createElementVNode("span",{class:"dialog-text dialog-separator override",style:w.normalizeStyle(t.textStyle),innerHTML:t.preText},null,12,nQ),w.createElementVNode("span",{class:w.normalizeClass(["dialog-text override",t.options.cssClass]),style:w.normalizeStyle(t.textStyle),innerHTML:t.options.text},null,14,rQ),t.canInteract&&t.choices?(w.openBlock(),w.createElementBlock("div",iQ,[(w.openBlock(!0),w.createElementBlock(w.Fragment,null,w.renderList(t.choices,(a,s)=>(w.openBlock(),w.createElementBlock("p",{key:s,style:w.normalizeStyle(t.dialogStyle(a)),class:w.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,oQ))),128))])):t.canInteract&&t.options.textField?(w.openBlock(),w.createElementBlock("div",aQ,[w.withDirectives(w.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),[[w.vModelText,t.playerText]]),w.createElementVNode("button",{onClick:e[1]||(e[1]=(...a)=>t.submitText&&t.submitText(...a)),class:"button",id:"player-input-submit"}," Submit ")])):t.canInteract?(w.openBlock(),w.createElementBlock("div",sQ,[w.createElementVNode("div",{onClick:e[2]||(e[2]=a=>t.chooseOption(0)),ref:"continue",class:"interact-button button override"}," Continue ",512)])):w.createCommentVNode("",!0)])],4)}const lQ=Yr(ZK,[["render",uQ]]),cQ=w.createElementVNode("div",{class:"anchor"},null,-1),fQ=w.defineComponent({__name:"game-dialog",props:{layoutMode:String,inGame:Boolean},setup(t){const e=t,n=dn(),r=w.computed(()=>n.stack),i=ii(),o=w.computed(()=>i.dialog),a=w.ref(null),s=w.computed(()=>e.layoutMode==="vertical"?{}:{paddingBottom:`${ft().layout.dialogBottomPadding}px`}),u=w.computed(()=>{if(o.value.length>0)return o.value[o.value.length-1]}),l=w.computed(()=>{if(u.value)return VJ(u.value.speaker,u.value.pose)}),f=w.computed(()=>ft().layout.minTextWidth),c=w.computed(()=>{let p;const v="100%";return e.layoutMode,{width:e.layoutMode==="horizontal"?`${f.value}px`:"100%",height:v,transform:p,transformOrigin:"right"}});function d(p,v){let g=G0(p.speaker).name;return v>=1&&o.value[v-1].speaker===p.speaker&&(g=void 0),p.choices&&p.choices.forEach(y=>{y.choice=ey(y.choice)}),{title:g!=null?g:"",text:p.text,cssClass:p.cssClass,styleId:p.speaker,choices:p.choices,old:v<o.value.length-1,interactive:p.interactive,textField:p.textField}}function h(p){return p===i.dialog.length-1&&r.value.length>0}return w.watch(o.value,p=>{if(a.value){const v=a.value;v.scrollTop=v.scrollHeight+1e8}}),(p,v)=>(w.openBlock(),w.createElementBlock(w.Fragment,null,[w.createVNode(w.Transition,{name:"fade"},{default:w.withCtx(()=>[w.unref(l)?(w.openBlock(),w.createBlock(XK,{key:0,pictureUrl:w.unref(l)},null,8,["pictureUrl"])):w.createCommentVNode("",!0)]),_:1}),t.inGame?(w.openBlock(),w.createElementBlock("div",{key:0,class:"dialog override",ref_key:"dialogRef",ref:a,style:w.normalizeStyle(w.unref(c))},[w.createVNode(w.TransitionGroup,{name:"list",tag:"div",class:"dialog-container w-full override",style:w.normalizeStyle(w.unref(s))},{default:w.withCtx(()=>[(w.openBlock(!0),w.createElementBlock(w.Fragment,null,w.renderList(w.unref(o),(m,g)=>(w.openBlock(),w.createBlock(lQ,{key:m.id,options:d(m,g),active:h(g)},null,8,["options","active"]))),128))]),_:1},8,["style"]),cQ],4)):w.createCommentVNode("",!0)],64))}}),UZ="",dQ=w.defineComponent({setup(){const t=Kr();return{quests:w.computed(()=>t.quests)}},computed:{questsToDisplay(){return A7(this.quests,t=>t.state!=="hidden")}},methods:{close(){this.$emit("close")},getQuestData(t){return vh(t)},getObjectiveData(t,e){return D0(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 A7(t.objectives,e=>e.state!=="hidden")}},components:{Modal:ra}}),JZ="",hQ=w.createElementVNode("h3",{class:"title"},"Quests",-1),pQ={key:0,class:"quests-container"},vQ={class:"quest-title"},mQ={class:"quest-description"},gQ={key:0,class:"quest-objectives-container list-disc"},yQ={key:1,class:"menu-container"},bQ=[w.createElementVNode("h2",{class:"title"},"There are no quests!",-1)];function kQ(t,e,n,r,i,o){const a=w.resolveComponent("modal");return w.openBlock(),w.createBlock(a,{class:"quests",onClose:t.close,containerCssClass:"quests-modal"},{header:w.withCtx(()=>[hQ]),body:w.withCtx(()=>[Object.keys(t.questsToDisplay).length>0?(w.openBlock(),w.createElementBlock("div",pQ,[(w.openBlock(!0),w.createElementBlock(w.Fragment,null,w.renderList(t.questsToDisplay,s=>(w.openBlock(),w.createElementBlock("div",{class:"quest-display",key:s.id},[w.createElementVNode("div",{class:w.normalizeClass(["quest-header",s.state==="completed"?"quest-completed":"quest-in-progress"])},[w.createElementVNode("h3",vQ,w.toDisplayString(t.getQuestData(s.id).title)+" "+w.toDisplayString(t.getDisplayTextForQuestState(s)),1)],2),w.createElementVNode("p",mQ,w.toDisplayString(t.getQuestDescription(s)),1),s.state!=="completed"?(w.openBlock(),w.createElementBlock("ul",gQ,[(w.openBlock(!0),w.createElementBlock(w.Fragment,null,w.renderList(t.getAvailableObjectives(s),u=>(w.openBlock(),w.createElementBlock("li",{class:"quest-objective-display",key:u.id},[w.createElementVNode("p",{class:w.normalizeClass(["quest-objective-description",u.state==="completed"?"quest-objective-completed":"quest-objctive-in-progress"])},w.toDisplayString(t.getObjectiveData(s.id,u.id).description),3)]))),128))])):w.createCommentVNode("",!0)]))),128))])):(w.openBlock(),w.createElementBlock("div",yQ,bQ))]),_:1},8,["onClose"])}const wQ=Yr(dQ,[["render",kQ]]),xQ=w.defineComponent({data(){return{buttons:[{id:"menu",cssId:"menu-button",text:"Menu"},{id:"skills",cssId:"skills-menu-button",text:"Skills",condition:()=>this.showSkills},{id:"inventory",cssId:"inventory-menu-button",text:"Items",condition:()=>this.showInventory},{id:"quests",cssId:"quests-menu-button",text:"Quests",condition:()=>this.showQuests}],activeMenu:!1}},mounted(){document.addEventListener("keydown",t=>{t.key==="Escape"&&this.toggleMenu()}),lr.callHook("onGameMounted")},unmounted(){lr.callHook("onGameUnmounted")},methods:{buttonClick(t){t.onClick?t.onClick():Gt().openModal(t.id)},openMenu(){Gt().openModal("menu")},openSkills(){Gt().openModal("skills")},openInventory(){Gt().openModal("inventory")},openQuests(){Gt().openModal("quests")},closeMenu(){Gt().closeModal()},toggleMenu(){Gt().toggleMenu()}},computed:{buttonsToShow(){return this.buttons.map(t=>{const e=ft().menuButtons[t.id]||{};return{...t,...e}}).filter(t=>t.condition?t.condition():!0)},showSkills(){return Object.entries(ft().skills).length>0},showInventory(){return Object.entries(ft().items).length>0},showQuests(){return Object.entries(ft().quests).length>0}}}),KZ="",jQ={class:"menu-container"},_Q=["onClick","id"];function SQ(t,e,n,r,i,o){return w.openBlock(),w.createElementBlock("div",jQ,[(w.openBlock(!0),w.createElementBlock(w.Fragment,null,w.renderList(t.buttonsToShow,a=>(w.openBlock(),w.createElementBlock("button",{key:a.id,onClick:s=>t.buttonClick(a),id:a.cssId,class:"button menu-toggle-button"},w.toDisplayString(a.text),9,_Q))),128))])}const CQ=Yr(xQ,[["render",SQ]]),$Q=["id"],OQ=["id","onClick"],ry=w.defineComponent({__name:"screen-layer",props:{layer:String,transitioning:{type:Boolean,default:!1}},setup(t){const e=t,n=dn(),r=Gt(),i=Do(),o=w.computed(()=>ft().layout.backgrounds.width),a=w.computed(()=>ft().layout.backgrounds.height),s=w.computed(()=>e.layer),u=w.computed(()=>i.buttons),l=w.computed(()=>{const b=ft().screens[s.value];if(!b)throw new Error(`Screen ${s.value} doesn't have a config`);return b}),f=w.computed(()=>l.value.buttons||[]),c=w.computed(()=>r.isInGame);function d(b){const x=tc(b).background;if(!!x)return r7(x)}function h(b){const k=tc(b),x=u.value[b],$=k.tag||"default",S=x.state;return S===!0&&kr().isInteractionTagBlocked($)?"greyed":S}function p(b){const k=h(b);return k==="hidden"||k==="greyed"||k===!1}function v(b){const k=h(b),x={};return k===!0?x.interactable=!0:(x.disabled=!0,k==="greyed"?x.greyed=!0:(k==="hidden"||k===!1)&&(x.hidden=!0)),x}function m(b){const k=tc(b),x={};h(b),k.position.width&&(x.width=`${k.position.width}px`),k.position.height&&(x.height=`${k.position.height}px`),k.background&&(x.backgroundImage=`url(${d(b)})`);let $=k.position.left,S=k.position.top;return k.anchor&&($=k.position.left-k.position.width*k.anchor.x,S=k.position.top-k.position.height*k.anchor.y),{...x,left:`${$}px`,top:`${S}px`}}function g(b){if(p(b)||e.transitioning)return;const k=tc(b);if(u.value[b].state===!0){const $=k.action;k.actionType==="run"?n.runLabelFunction($):n.jumpToLabel($)}}const y=w.computed(()=>({backgroundImage:`url(${r7(l.value.background)})`,width:`${o.value}px`,height:`${a.value}px`}));return(b,k)=>w.unref(c)?(w.openBlock(),w.createElementBlock("div",{key:0,class:"viewport-layer",id:`viewport-layer-${w.unref(s)}`,style:w.normalizeStyle(w.unref(y))},[(w.openBlock(!0),w.createElementBlock(w.Fragment,null,w.renderList(w.unref(f),(x,$)=>(w.openBlock(),w.createElementBlock("div",{key:$,tabindex:"-1",class:w.normalizeClass(["viewport-button",v(x)]),id:`viewport-button-${x}`,onClick:S=>g(x),style:w.normalizeStyle(m(x))},w.toDisplayString(w.unref(tc)(x).text),15,OQ))),128))],12,$Q)):w.createCommentVNode("",!0)}}),QZ="",EQ=w.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=w.ref("start"),i=w.reactive({oldSlotClasses:{},oldSlotStyle:{},newSlotClasses:{},newSlotStyle:{}});return w.onMounted(async()=>{var a;const o=`narrat-transition-${n.name}`;i.newSlotClasses={[`${o}-enter-from`]:!0,[`${o}-enter-active`]:!0},i.oldSlotStyle={transitionDuration:`${n.duration/1e3}s`},i.newSlotStyle={transitionDuration:`${n.duration/1e3}s`},i.oldSlotClasses={[`${o}-leave-active`]:!0},await to(30),i.oldSlotClasses[`${o}-leave-to`]=!0,await to((a=n.delay)!=null?a:0),delete i.newSlotClasses[`${o}-enter-from`],await to(n.duration),delete i.newSlotClasses[`${o}-enter-active`],delete i.oldSlotClasses[`${o}-leave-active`],r.value="end",e("complete")}),(o,a)=>(w.openBlock(),w.createElementBlock(w.Fragment,null,[r.value!=="end"?(w.openBlock(),w.createElementBlock("div",{key:0,class:w.normalizeClass(["transition-holder",i.oldSlotClasses]),style:w.normalizeStyle(i.oldSlotStyle)},[w.renderSlot(o.$slots,"oldElement",{class:w.normalizeClass(i.oldSlotClasses)})],6)):w.createCommentVNode("",!0),w.createElementVNode("div",{class:w.normalizeClass(["transition-holder",i.newSlotClasses]),style:w.normalizeStyle(i.newSlotStyle)},[w.renderSlot(o.$slots,"newElement")],6)],64))}}),YZ="",AQ=w.defineComponent({__name:"screens",setup(t){const e=ks(),n=Gt(),r=Do(),i=w.computed(()=>r.layers.filter(c=>c)),o=w.computed(()=>e.layoutMode),a=w.computed(()=>ft().layout.backgrounds.width),s=w.computed(()=>ft().layout.backgrounds.height),u=w.computed(()=>n.isInGame);function l(c){r.finishTransition(c)}const f=w.computed(()=>{const c=`${a.value}px`;let d=`${s.value}px`;return o.value==="vertical"&&(d=`${100-ft().layout.mobileDialogHeightPercentage}%`),{height:d,width:c}});return(c,d)=>w.unref(u)?(w.openBlock(),w.createElementBlock("div",{key:0,class:"viewport",id:"narrat-viewport",style:w.normalizeStyle(w.unref(f))},[(w.openBlock(!0),w.createElementBlock(w.Fragment,null,w.renderList(w.unref(i),(h,p)=>(w.openBlock(),w.createElementBlock("div",{key:p,class:"layer-container"},[h.transition?(w.openBlock(),w.createBlock(EQ,{key:0,name:h.transition.transition,duration:h.transition.duration,delay:h.transition.delay,onComplete:()=>l(p)},{oldElement:w.withCtx(()=>[w.createVNode(ry,{layer:h.transition.oldScreen,transitioning:!0},null,8,["layer"])]),newElement:w.withCtx(()=>[w.createVNode(ry,{layer:h.screen,transitioning:!0},null,8,["layer"])]),_:2},1032,["name","duration","delay","onComplete"])):(w.openBlock(),w.createBlock(ry,{key:1,layer:h.screen},null,8,["layer"]))]))),128))],4)):w.createCommentVNode("",!0)}}),XZ="",MQ=w.defineComponent({setup(){const t=pr();return{skills:w.computed(()=>t.skills)}},components:{Modal:ra},data(){return{chosenSkill:!1}},mounted(){},methods:{getSkillStyle(t){return{backgroundImage:`url(${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 ft().skills},xpPerLevel(){return ft().skillOptions.xpPerLevel}}}),ZZ="",TQ=w.createElementVNode("h3",{class:"title"},"Skills",-1),PQ={key:0,class:"skills-container"},IQ=["onClick"],NQ={class:"skill-title"},LQ={class:"skill-xp-container"},DQ={class:"skill-xp-text"},RQ={class:"skill-level"},BQ={key:1},zQ={class:"flex flex-row skill-description-container"},VQ={class:"flex skill-left"},FQ={class:"flex skill-right"},qQ=w.createElementVNode("hr",{class:"hr-solid"},null,-1);function HQ(t,e,n,r,i,o){const a=w.resolveComponent("modal");return w.openBlock(),w.createBlock(a,{class:"menu",onClose:e[1]||(e[1]=s=>t.$emit("close")),containerCssClass:"skills-modal"},{header:w.withCtx(()=>[TQ]),body:w.withCtx(()=>[t.chosenSkill?typeof t.chosenSkill=="string"?(w.openBlock(),w.createElementBlock("div",BQ,[w.createElementVNode("div",zQ,[w.createElementVNode("div",VQ,[w.createElementVNode("div",{class:"skill-display",style:w.normalizeStyle(t.getSkillStyle(t.chosenSkill))},null,4)]),w.createElementVNode("div",FQ,[w.createElementVNode("h2",null,w.toDisplayString(t.getSkillName(t.chosenSkill)),1),qQ,w.createElementVNode("h3",null,"Level: "+w.toDisplayString(t.skills[t.chosenSkill].level),1),w.createElementVNode("p",null,w.toDisplayString(t.skillConf[t.chosenSkill].description),1)])]),w.createElementVNode("button",{class:"button",onClick:e[0]||(e[0]=(...s)=>t.closeSkill&&t.closeSkill(...s))},w.toDisplayString("<--"))])):w.createCommentVNode("",!0):(w.openBlock(),w.createElementBlock("div",PQ,[(w.openBlock(!0),w.createElementBlock(w.Fragment,null,w.renderList(t.skillsToDisplay,s=>(w.openBlock(),w.createElementBlock("button",{onClick:()=>t.clickSkill(s.id),class:"skill-display",style:w.normalizeStyle(t.getSkillStyle(s.id)),key:s.id},[w.createElementVNode("h3",NQ,w.toDisplayString(t.getSkillName(s.id)),1),w.createElementVNode("div",LQ,[w.createElementVNode("div",{class:"skill-xp-bar",style:w.normalizeStyle(t.xpBarWidth(s.xp))},null,4),w.createElementVNode("h3",DQ,w.toDisplayString(s.xp)+" / "+w.toDisplayString(t.xpPerLevel)+" XP",1)]),w.createElementVNode("h3",RQ,w.toDisplayString(s.level),1)],12,IQ))),128))]))]),_:1})}const WQ=Yr(MQ,[["render",HQ]]),UQ=w.defineComponent({data(){return{muted:!1,volumes:[],modeNames:{master:"Master volume:",music:"Music:",ambiant:"Ambiant:",sound:"Sound effects:"}}},mounted(){const t=Ir(),e=Pa.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"?Ir().setMasterVolume(n.value):Ir().setModeVolume(t,n.value)},toggleMute(){this.muted?(Pa.Howler.mute(!1),this.muted=!1):(Pa.Howler.mute(!0),this.muted=!0)}}}),eee="",JQ={class:"volume-controls"},GQ=w.createElementVNode("h3",{class:"subtitle"},"Volume",-1),KQ={for:"volume",class:"volume-label"},QQ=["onUpdate:modelValue","onChange"];function YQ(t,e,n,r,i,o){return w.openBlock(),w.createElementBlock("div",JQ,[GQ,(w.openBlock(!0),w.createElementBlock(w.Fragment,null,w.renderList(t.volumes,(a,s)=>(w.openBlock(),w.createElementBlock("div",{class:"volume-control",key:a.mode},[w.createElementVNode("label",KQ,w.toDisplayString(t.modeNames[a.mode]),1),w.withDirectives(w.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,QQ),[[w.vModelText,t.volumes[s].volume]])]))),128))])}const XQ=Yr(UQ,[["render",YQ]]),ZQ=w.defineComponent({components:{Modal:ra,VolumeControls:XQ},data(){return{}},mounted(){},methods:{quit(){window.close()},mainMenu(){Gt().menuReturn(),this.closeMenu()},closeMenu(){this.$emit("close")},getPlayTimeString(){const t=mc(this.playTime.start,this.playTime.previousPlaytime);return Lh(t/1e3)}},computed:{...Lo(Gt,["playTime"])}}),tee="",eY=w.createElementVNode("h3",{class:"title"},"Menu",-1),tY={class:"menu-content"};function nY(t,e,n,r,i,o){const a=w.resolveComponent("VolumeControls"),s=w.resolveComponent("modal");return w.openBlock(),w.createBlock(s,{class:"menu",onClose:e[2]||(e[2]=u=>t.$emit("close")),containerCssClass:"main-menu-modal"},{header:w.withCtx(()=>[eY]),body:w.withCtx(()=>[w.createElementVNode("div",tY,[w.createElementVNode("h3",null,"Play time: "+w.toDisplayString(t.getPlayTimeString()),1),w.createVNode(a),w.createElementVNode("button",{class:"button title quit-button",onClick:e[0]||(e[0]=(...u)=>t.mainMenu&&t.mainMenu(...u))}," Main Menu "),w.createElementVNode("button",{class:"button title quit-button",onClick:e[1]||(e[1]=(...u)=>t.quit&&t.quit(...u))},"Exit")])]),_:1})}const rY=Yr(ZQ,[["render",nY]]),iY=w.defineComponent({data(){return{}},methods:{getStatImage(t){return xu(this.statsConfig[t].icon)}},computed:{...Lo(ta,["hudStats"]),...Lo(ks,["layoutMode"]),statsConfig(){return ft().hudStats},stats(){return this.hudStats},hudStyle(){let t="0";return this.layoutMode==="horizontal"&&(t=`${ft().layout.minTextWidth}px`),{right:t}}}}),nee="",oY=["src"],aY={class:"bold hud-text"},sY=w.createTextVNode(": ");function uY(t,e,n,r,i,o){return w.openBlock(),w.createElementBlock("div",{class:"hud",style:w.normalizeStyle(t.hudStyle)},[(w.openBlock(!0),w.createElementBlock(w.Fragment,null,w.renderList(t.stats,(a,s)=>(w.openBlock(),w.createElementBlock("div",{key:s,class:"hud-stat"},[w.createElementVNode("img",{class:"hud-icon",src:t.getStatImage(s)},null,8,oY),w.createElementVNode("span",aY,w.toDisplayString(t.statsConfig[s].name),1),sY,w.createElementVNode("span",null,w.toDisplayString(Math.floor(a.value*100)/100),1)]))),128))],4)}const lY=Yr(iY,[["render",uY]]),cY=w.defineComponent({__name:"in-game",setup(t){const e=Gt(),n=ks(),r=w.computed(()=>e.modal),i=w.computed(()=>n.layoutMode),o=w.computed(()=>e.saving),a=w.ref(null),s=w.computed(()=>o.value&&!o.value.withPrompt||o.value&&a.value);function u(){Gt().closeModal()}const l=w.computed(()=>{let h="row";return i.value==="vertical"&&(h="column"),{flexDirection:h}});function f(h){if(a.value=null,h===null){Gt().finishManualSave(h,!1);return}Gt().finishManualSave(h,!0)}function c(){a.value=!0}function d(){a.value=!1,e.finishManualSave(null,!1),a.value=null}return(h,p)=>(w.openBlock(),w.createElementBlock("div",{class:"game",style:w.normalizeStyle(w.unref(l))},[w.createVNode(lY),w.createVNode(CQ,{class:"menu-toggle"}),w.unref(r)==="skills"?(w.openBlock(),w.createBlock(WQ,{key:0,onClose:u})):w.createCommentVNode("",!0),w.unref(r)==="inventory"?(w.openBlock(),w.createBlock(GK,{key:1,onClose:u})):w.createCommentVNode("",!0),w.unref(r)==="quests"?(w.openBlock(),w.createBlock(wQ,{key:2,onClose:u})):w.createCommentVNode("",!0),w.unref(r)==="menu"?(w.openBlock(),w.createBlock(rY,{key:3,onClose:u})):w.createCommentVNode("",!0),w.createVNode(AQ),w.createVNode(fQ,{inGame:!0,layoutMode:w.unref(i)},null,8,["layoutMode"]),w.unref(s)?(w.openBlock(),w.createBlock(n8,{key:4,mode:"pick",onChosen:f,onClose:p[0]||(p[0]=()=>f(null))})):w.createCommentVNode("",!0),w.unref(o)&&w.unref(o).withPrompt&&a.value===null?(w.openBlock(),w.createBlock(Oh,{key:5,prompt:"Would you like to save the game?",onConfirm:c,onRefuse:d})):w.createCommentVNode("",!0)],4))}}),ree="",fY=w.defineComponent({props:{percentage:Number,step:String},methods:{loadingStyle(){return{width:`${this.percentage*60}vw`}}},computed:{}}),iee="",dY={id:"loading-bar"},hY={id:"loading-text"};function pY(t,e,n,r,i,o){return w.openBlock(),w.createElementBlock("div",dY,[w.createElementVNode("div",{id:"inner-loading-bar",style:w.normalizeStyle(t.loadingStyle())},null,4),w.createElementVNode("div",hY,[w.createElementVNode("h3",null,"Loading "+w.toDisplayString(Math.floor(t.percentage*100))+"% - "+w.toDisplayString(t.step),1)])])}const vY=Yr(fY,[["render",pY]]),mY="data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4NCjwhLS0gR2VuZXJhdG9yOiBBZG9iZSBJbGx1c3RyYXRvciAxOS4wLjAsIFNWRyBFeHBvcnQgUGx1Zy1JbiAuIFNWRyBWZXJzaW9uOiA2LjAwIEJ1aWxkIDApICAtLT4NCjxzdmcgdmVyc2lvbj0iMS4xIiBpZD0iUmF0IiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB4PSIwcHgiIHk9IjBweCINCgkgdmlld0JveD0iMCAwIDU5NS4zIDU5NS4zIiBzdHlsZT0iZW5hYmxlLWJhY2tncm91bmQ6bmV3IDAgMCA1OTUuMyA1OTUuMzsiIHhtbDpzcGFjZT0icHJlc2VydmUiPg0KPHN0eWxlIHR5cGU9InRleHQvY3NzIj4NCgkuc3Qwe2ZpbGw6I0UyM0IzMzt9DQo8L3N0eWxlPg0KPHBhdGggaWQ9IlJhdF9TaGFwZSIgY2xhc3M9InN0MCIgZD0iTTU1Ni45LDgyLjVjLTEwLjgtMjQuMy00Ny01Ny4xLTcxLjMtNjUuNmMtMjQuMy04LjQtNjQuMS0wLjMtODguNywyMi4zDQoJYy0yMCwxOC40LTI2LDI4LjItMjkuMSwzN2MtMi4xLDUuOS00LjgsMTMuNS02LDIwLjl2MGMtMC41LDQuMS00LjUsNy04LjYsNi4xYy0xMC40LTIuMy0yOS41LTYtNDQuNC02LjMNCgljLTEzLjctMC4yLTMwLjEsMy4yLTQwLjQsNS43Yy00LjUsMS4xLTguOC0yLjItOC44LTYuOGMtMC4xLTUuMy0xLjEtMTIuMy00LjgtMTkuNmMtOC41LTE2LjktMTkuNi0zMi42LTU3LjgtNDcuNA0KCWMtMzEuOS0xMi40LTc1LjEtOS43LTEwMC44LDEuOGMtMjguMSwxMi42LTQyLjQsMzcuOS01NCw2MS44Yy0xNC40LDI5LjgtMTQuOSw4My42LTYuNCwxMDRjMTIuOCwzMC43LDM1LjgsNDcuMiw1Mi42LDUzDQoJYzExLjMsMy44LDI4LjIsMy43LDM4LjIsMy4zYzQuMi0wLjIsNy43LDMuMyw3LjUsNy41Yy0wLjcsMTMuNi0wLjksNDEuNSw3LDYxLjRjNy43LDE5LjQsMjkuNyw2Mi4zLDUwLjcsMTAxLjINCgljMCwwLjEtMTQuNiwyLjktMzEuNCw2LjhjLTIzLjksNS41LTUyLjYsMTIuNy01NC4zLDEzLjdjLTMuNSwyLjEtMywxMC0yLjcsMTJjMC41LDMuNCw1LjMsOC4xLDYuOSw4LjNjMy45LDAuMywzMS4zLTcuNiw1NS43LTE0LjYNCgljMTguNS01LjMsMzQuOS05LjMsMzUuNS04LjJjNS4xLDkuMywxMCwxOCwxNC40LDI1LjhjNS4yLDkuMSwxMC43LDE2LjQsMTQuMSwyMy42YzEuMSwyLjMtMTYuNiw1LjgtMzIuNSwxNC43DQoJYy0xNi40LDkuMS0yOS43LDIxLTMyLjMsMjRjLTEuOCwyLjEtMyw2LTEuMiwxMC43YzEuMSwyLjksMTAsNS43LDEyLjQsNS4xYzYuOC0xLjcsMTYuNS0xMi41LDMzLjEtMjEuMQ0KCWMxNi4zLTguNSwzMi45LTE0LjksMzMuOC0xMy42YzkuNywxNC4zLDE2LjksMjEuNiwyMi42LDMxLjJjOS44LDE2LjUsMjcuMyw0NS45LDQ2LjYsMzkuNWM2LjQtMi4xLDMxLjEtMzMuNiw1My4zLTY4LjYNCgljMS4zLTIuMSwxNi4xLDExLjMsMzAuNCwyMy4yYzEzLjgsMTEuNCwyMi43LDIwLjYsMjcuMSwyMS40YzUuNCwxLDE0LjItNy43LDE0LjEtMTQuN2MtMC4xLTIuNy0xNC4zLTEzLjgtMjkuMS0yNi4yDQoJYy0xNC41LTEyLjEtMzAuMS0yMi44LTI5LjItMjQuM2M3LjYtMTIsMTQuNS0yMy43LDIwLjEtMzMuOWM0LjMtNy44LDguOS0xNiwxMy0yNC43YzAuNi0xLjIsMTUuOSwzLDMxLjQsNy4xYzE1LjMsNCwyNi43LDEwLDMxLDgNCgljNi45LTMsMTEuNi0xMy44LDkuNC0xOC4zYy0xLjEtMi4zLTE3LTcuMy0zMy4yLTEyYy0xNC4yLTQuMS0yOC02LjUtMjcuNy03LjNjMTUuNS0zNCwyOC44LTY0LjgsMjcuNi02OS42DQoJYy0xLjctNy4xLDIuNi0xMS45LDctMzYuNWMzLjItMTguMSw0LjctNDAuOSw1LjItNTEuN2MwLjItMy41LDIuOC02LjMsNi4zLTYuN2MzLjEtMC4zLDYuOS0wLjksMTAuNS0xLjljNy44LTIsMTguNi03LjgsMzYuNC0yMC42DQoJYzE3LjktMTIuOCwzOC43LTQ5LjYsNDQuNC02Ny44UzU2Ny42LDEwNi44LDU1Ni45LDgyLjV6IE0yNjUuMSwzMzYuMmMtOC4xLDQtMTMsNy0yNi40LDkuNmMtNi45LDEuNC0yOS40LTAuMi00MC43LTQuNg0KCWMtMTAuNS00LjEtMTkuOS03LjYtMzAtMTUuNHMtMTUuNy0xMy4yLTE1LjctMTUuM2MwLTQuNCw2LTkuNCwxMS05LjRjNS4xLDAsMTQuNSw5LjIsMjkuNywxNi42YzE0LjMsNywxNy45LDYuMSwyNS40LDcuMw0KCWMyLjksMC41LDcuNywwLjYsMTAuNywwLjRjMTQuMS0xLjMsMjEuNC01LjksMjUuMy04LjhjNC0zLDEzLjctMTIuOSwxNy4yLTEyLjVjOCwxLDE4LjksMy40LDE4LjksNy4xDQoJQzI5MC40LDMxOSwyNzMuMiwzMzIuMSwyNjUuMSwzMzYuMnogTTMyMC45LDUyMS40Yy00LjMsMy43LTE3LjcsMTMuNS0yMy4zLDEzLjVjLTIuOCwwLTcuNC04LjItMTEuNS0xNi44DQoJYy00LjEtOC41LTkuMS0yMS4xLTkuMS0zMS42YzAtNC42LDYtNy40LDEzLjQtOS4yYzcuMi0xLjcsMjcuMy0xLjgsMjkuOS0xLjFjNi44LDEuNywxMi45LDIuMiwxMi43LDYuNGMtMC40LDEyLjctNywxOC45LTguMywyNC4zDQoJQzMyMy40LDUxMi4zLDMyMy40LDUxOS4yLDMyMC45LDUyMS40eiBNNDMxLjEsMzIwLjNjLTkuMiw3LjQtMTAuNiw4LjEtMjQuOSwxMy43Yy0xMS4zLDQuNC0yOC42LDUuOC00MS42LDMuNg0KCWMtMTIuMi0yLjEtMjIuMy00LjYtMjkuNS0xMC4xYy05LjctNy4zLTE2LjQtMTUuMS0xNi40LTE5LjhjMC0zLjcsNi40LTQuMywxNC41LTQuOWMzLjUtMC4zLDkuMyw1LjksMTMuMiw5LjINCgljOC4xLDYuOCwxNC44LDgsMjguOCw5LjljMi45LDAuNCw3LjgsMC40LDEwLjcsMC4xYzcuNS0wLjksMTItMC40LDI1LjgtOC4yYzIwLTExLjIsMTcuOC0xNC40LDI1LjEtMTIuNmMyLjIsMC42LDUuOCwxLjIsNS42LDUuNg0KCUM0NDIuNCwzMDksNDQwLjUsMzEyLjcsNDMxLjEsMzIwLjN6Ii8+DQo8L3N2Zz4NCg==",gY={id:"engine-splash-screen",class:"flex justify-center items-center"},yY={id:"engine-splash-title"},bY=["src"],kY=w.defineComponent({__name:"engine-splash",emits:["finished"],setup(t,{emit:e}){const n=w.ref("hidden"),r=w.computed(()=>({transitionDuration:`${l.value}s`})),i=w.computed(()=>({invisible:n.value!=="appear"})),o=Gt(),a=w.computed(()=>{var d,h;return(h=(d=ft().splashScreens)==null?void 0:d.engineSplashScreen)!=null?h:{}}),s=w.computed(()=>typeof a.value.overrideText=="string"?a.value.overrideText:"Made with narrat engine"),u=w.computed(()=>{var d;return(d=a.value.overrideLogo)!=null?d:mY}),l=w.computed(()=>typeof a.value.fadeDuration=="number"?a.value.fadeDuration:2),f=w.computed(()=>typeof a.value.timeBeforeFadeout=="number"?a.value.timeBeforeFadeout:3);w.onMounted(async()=>{if(await to(10),n.value="appear",a.value.skip||o.options.debug){c();return}await to(l.value*1e3),await to(f.value*1e3),n.value="disappear",await to(l.value*1e3),c()});function c(){o.loading.loaded?e("finished"):o.listener.once("gameLoaded",()=>{e("finished")})}return(d,h)=>(w.openBlock(),w.createElementBlock("div",gY,[w.createElementVNode("div",{id:"engine-splash-header",class:w.normalizeClass(["flex justify-center flex-col items-center",w.unref(i)]),style:w.normalizeStyle(w.unref(r))},[w.createElementVNode("h1",yY,w.toDisplayString(w.unref(s)),1),w.createElementVNode("img",{src:w.unref(u),alt:"Narrat Logo",id:"engine-splash-logo"},null,8,bY),w.createVNode(vY,{percentage:w.unref(o).loading.percentage,step:w.unref(o).loading.step},null,8,["percentage","step"])],6)]))}}),oee="",wY={id:"game-splash-screen",style:{height:"100%",padding:"20px"},class:"flex justify-center items-center"},xY={id:"game-splash-screen-header flex justify-center flex-col items-center",class:"flex justify-center flex-col items-center"},jY={class:"title",id:"game-splash-title"},_Y=w.defineComponent({__name:"game-splash",setup(t){const e=Gt(),n=w.computed(()=>{var s,u;return(u=(s=ft().splashScreens)==null?void 0:s.gameSplashScreen)!=null?u:{}}),r=w.computed(()=>typeof n.value.startButtonText=="string"?n.value.startButtonText:"Press to start"),i=w.computed(()=>e.loading.loaded),o=w.computed(()=>ft().gameTitle||"Narrat Game");function a(){e.flowState="menu"}return w.onMounted(()=>{e.options.debug&&a()}),(s,u)=>(w.openBlock(),w.createElementBlock("div",wY,[w.createElementVNode("div",xY,[w.createElementVNode("h1",jY,w.toDisplayString(w.unref(o)),1),w.unref(i)?(w.openBlock(),w.createElementBlock("button",{key:0,class:"button menu-button main-menu-button large splash-start-button override",onClick:a},w.toDisplayString(w.unref(r)),1)):w.createCommentVNode("",!0)])]))}}),aee="",SY=w.defineComponent({setup(){const t=ii(),e=dn(),n=Gt();return{dialog:w.computed(()=>t.dialog),stack:w.computed(()=>e.stack),modal:w.computed(()=>n.modal),flowState:w.computed(()=>n.flowState),alerts:w.computed(()=>n.alerts)}},$refs:{dialogContainer:HTMLInputElement},inject:["mq"],components:{DebugMenu:lK,NotificationToast:hK,StartMenu:AK,AlertModal:PK,InGame:cY,EngineSplash:kY,GameSplash:_Y},data(){return{lineTitle:"title",lineText:"hello"}},props:{options:Object},async mounted(){lr.callHook("onAppMounted"),await Gt().engineLoading(),window.addEventListener("resize",t8(()=>{this.updateScreenSize()},100,{maxWait:200})),sc.setup(this.options.debug),setTimeout(()=>{this.updateScreenSize()},50)},computed:{...Lo(ks,["screenWidth","screenHeight","canvasWidth","canvasHeight","topOffset","leftOffset","layoutMode"]),...Lo(dn,["currentLine"]),backgroundStyle(){let t;return this.layoutMode==="vertical"&&(t=`${100-ft().layout.mobileDialogHeightPercentage}%`),{backgroundColor:"red",height:t}},layoutWidth(){return ft().layout.backgrounds.width},layoutHeight(){return ft().layout.backgrounds.height},backgroundSize(){return{width:this.canvasWidth,height:this.canvasHeight,top:this.topOffset,left:this.leftOffset}},gameWidth(){const t=ft();return this.layoutMode==="vertical"?window.innerWidth:t.layout.backgrounds.width+t.layout.minTextWidth},gameHeight(){const t=ft();return this.layoutMode==="vertical"?window.innerHeight:t.layout.backgrounds.height},appStyle(){const t=ft();if(this.screenWidth&&this.screenHeight&&t&&this.layoutMode==="horizontal"){const e=e8(this.screenWidth,this.screenHeight,this.gameWidth,this.gameHeight);return{transform:`scale(${e}, ${e})`,width:`${this.gameWidth}px`,height:`${this.gameHeight}px`}}return{}},gameStyle(){let t="row";return this.layoutMode==="vertical"&&(t="column"),{flexDirection:t}},screenRatio(){const t=ft(),e=t.layout.minTextWidth+t.layout.backgrounds.width;return this.screenWidth/e}},methods:{closeAlert(t){Gt().closeAlert(t)},engineSplashDone(){Gt().flowState="game-splash"},updateScreenSize(){ks().updateScreenSize(window.innerWidth,window.innerHeight,this.layoutMode==="horizontal"?ft().layout.minTextWidth*this.screenRatio:0)}}}),see="";function CY(t,e,n,r,i,o){const a=w.resolveComponent("EngineSplash"),s=w.resolveComponent("GameSplash"),u=w.resolveComponent("StartMenu"),l=w.resolveComponent("InGame"),f=w.resolveComponent("DebugMenu"),c=w.resolveComponent("NotificationToast"),d=w.resolveComponent("AlertModal");return w.openBlock(),w.createElementBlock("div",{id:"app",style:w.normalizeStyle(t.appStyle)},[t.flowState==="engine-splash"?(w.openBlock(),w.createBlock(a,{key:0,onFinished:t.engineSplashDone},null,8,["onFinished"])):(w.openBlock(),w.createBlock(w.Transition,{key:1,name:"screens-fade"},{default:w.withCtx(()=>[t.flowState==="game-splash"?(w.openBlock(),w.createBlock(s,{key:"1"})):t.flowState==="menu"?(w.openBlock(),w.createBlock(u,{key:"2"})):t.flowState==="playing"?(w.openBlock(),w.createBlock(l,{key:"3"})):w.createCommentVNode("",!0)]),_:1})),t.options.debug?(w.openBlock(),w.createBlock(f,{key:2})):w.createCommentVNode("",!0),w.createVNode(c),(w.openBlock(!0),w.createElementBlock(w.Fragment,null,w.renderList(t.alerts,h=>(w.openBlock(),w.createBlock(d,{key:h.id,title:h.title,text:h.text,onClose:()=>t.closeAlert(h.id)},null,8,["title","text","onClose"]))),128))],4)}const $Y=Yr(SY,[["render",CY]]);function vn(t,e){console.error("Runtime error ========================="),console.error(`Command: ${t.commandType}`),console.error("Args: ",t.args),console.error("Options: ",t.options),Sn(`Runtime error at ${t.fileName}:${t.line} (${t.commandType}) ${t.code}. -
183
183
  <br />
184
184
  Error: ${e}`),console.error("============================")}function OY(t,...e){console.log(`[${t.fileName}:${t.line}] log: `,...e)}class et{constructor(e,n,r,i){Ri(this,"keyword");Ri(this,"runner");Ri(this,"argTypes");Ri(this,"parser");Ri(this,"onPlayerAnswered");Ri(this,"returnAfterPlayerAnswer");this.keyword=e,this.runner=r,this.argTypes=n,i?this.parser=i:this.parser=uc(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)=>{dn().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 et(e.keyword,e.argTypes,e.runner,e.parser);return n.onPlayerAnswered=e.onPlayerAnswered,n.returnAfterPlayerAnswer=(r=e.returnAfterPlayerAnswer)!=null?r:!1,n}}function uc(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];!G7(s)&&!K7(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 EY=new et("add_level",[{name:"skillKey",type:"string"},{name:"amount",type:"number"}],async t=>{let{skillKey:e,amount:n}=t.options;if((!e||!n)&&vn(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}`)}pr().incrementSkill(e,n)}),AY=et.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)&&vn(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}`)}pr().setSkillLevel(e,n)}}),MY=new et("add_xp",[{name:"xpKey",type:"string"},{name:"xpToAdd",type:"number"}],async t=>{const{xpKey:e,xpToAdd:n}=t.options;(!e||!n)&&vn(t,"add_xp command needs a skill id and a value as parameters"),pr().addXp(e,n)}),TY=new et("get_level",[{name:"skillKey",type:"string"}],async t=>{const{skillKey:e}=t.options;e||vn(t,"get_level command needs a skill id as parameter");const n=pr().getSkill(e);return n||vn(t,`Skill ${e} not found`),n.level}),PY=new et("get_xp",[{name:"xpKey",type:"string"}],async t=>{const{xpKey:e}=t.options;e||vn(t,"get_xp command needs a skill id as parameter");const n=pr().getSkillXp(e);return n||vn(t,`XP ${e} not found`),n}),IY=new et("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 J7({id:e,skill:n,value:r,hideAfterRoll:i}).succeeded}),NY=new et("add_stat",[{name:"statKey",type:"string"},{name:"amountToAdd",type:"number"}],async t=>{const{statKey:e,amountToAdd:n}=t.options;(!e||typeof n!="number")&&vn(t,"add_stat command needs a stat id and a value as parameters"),ta().addStat(e,n)}),LY=new et("set_stat",[{name:"statKey",type:"string"},{name:"value",type:"number"}],async t=>{const{statKey:e,value:n}=t.options;(!e||typeof n!="number")&&vn(t,"set_stat command needs a stat id and a value as parameters"),ta().setStat(e,n)}),DY=new et("get_stat_value",[{name:"statKey",type:"string"}],async t=>{const{statKey:e}=t.options;return e||vn(t,"get_stat_value command needs a stat id as parameter"),ta().getStatValue(e)}),RY=et.FromOptions({keyword:"jump",argTypes:"any",runner:async t=>{(t.args.length<1||typeof t.args[0]!="string")&&vn(t,"requires a label argument");const e=t.args[0],n=dn(),r={branchData:n.script[e],label:e,args:t.args.splice(1),currentIndex:0};if(!n.script[e]){Sn(`Trying to jump but label ${e} not found`);return}return n.jumpTarget=r,_h}}),BY=et.FromOptions({keyword:"run",argTypes:"any",runner:async t=>{(t.args.length<1||typeof t.args[0]!="string")&&vn(t,"run command needs a label to argument run");const e=t.args[0];return await dn().runLabelFunction(e,...t.args.slice(1))}}),zY=et.FromOptions({keyword:"var",argTypes:[{name:"name",type:"string"},{name:"value",type:"any"}],runner:async t=>{const{name:e,value:n}=t.options;dn().addScopedVariable(e,n)}}),VY=et.FromOptions({keyword:"return",argTypes:[{name:"value",type:"any"}],runner:async t=>{const{value:e}=t.options;return dn().setReturnValue(e),K0}}),FY=et.FromOptions({keyword:"log",argTypes:"any",runner:async t=>{OY(t,...t.args)}}),qY=et.FromOptions({keyword:"menu_return",argTypes:[],runner:async t=>(Gt().menuReturn(),Sh)}),HY=et.FromOptions({keyword:"save",argTypes:[{name:"name",type:"string",optional:!0}],runner:async t=>{await Gt().manualSave({saveName:t.options.name})}}),WY=et.FromOptions({keyword:"save_prompt",argTypes:[{name:"name",type:"string",optional:!0}],runner:async t=>{await Gt().manualSave({saveName:t.options.name,withPrompt:!0})}}),UY=[{name:"mode",type:"string"},{name:"audio",type:"string"},{name:"channel",type:"number",optional:!0}],JY=new et("play",UY,async t=>{const e=Ir(),{mode:n,audio:r,channel:i}=t.options,o=iy(t,n);o&&e.playChannel(o,r,i!=null?i:0)}),GY=new et("pause",[{name:"mode",type:"string"},{name:"channel",type:"number",optional:!0}],async t=>{const e=Ir(),{mode:n,channel:r}=t.options,i=iy(t,n);i&&e.pauseChannel(i,r!=null?r:0)}),KY=new et("stop",[{name:"mode",type:"string"},{name:"channel",type:"number",optional:!0}],async t=>{const e=Ir(),{mode:n,channel:r}=t.options,i=iy(t,n);i&&e.stopChannel(i,r!=null?r:0)});function iy(t,e){return QY(e)?e:(vn(t,`${e} is not a valid audio mode.`),!1)}function QY(t){return!!j7.includes(t)}const YY=new et("set",[{name:"key",type:"string"},{name:"value",type:"any"}],async t=>{const e=Ou();q7(e,t.options.key,t.options.value)}),XY=new et("add",[{name:"key",type:"string"},{name:"value",type:"any"}],async t=>{const e=Ou();H7(e,t.options.key,t.options.value)}),ZY=new et("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=Do();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)}),eX=new et("empty_layer",[{name:"layer",type:"number"}],async t=>{Do().emptyLayer(t.options.layer)}),tX=new et("set_button",[{name:"buttonId",type:"string"},{name:"state",type:"any"}],async t=>{const{buttonId:e,state:n}=t.options;Do().changeButton(e,n)}),nX=et.FromOptions({keyword:"talk",argTypes:[{name:"speaker",type:"string"},{name:"pose",type:"string"},{name:"text",type:"string"}],runner:async(t,e)=>{await ty({speaker:t.options.speaker,pose:t.options.pose,cssClass:"talk-command",text:`"${t.options.text}"`,choices:e,interactive:!0})},returnAfterPlayerAnswer:!0}),rX=et.FromOptions({keyword:"think",argTypes:[{name:"speaker",type:"string"},{name:"pose",type:"string"},{name:"text",type:"string"}],runner:async(t,e)=>{await ty({speaker:t.options.speaker,pose:t.options.pose,cssClass:"think-command",text:`${t.options.text}`,choices:e,interactive:!0})},returnAfterPlayerAnswer:!0}),iX=()=>{const t=uc("text",[]);return(e,n)=>{const r=t(e,n);return n.command.staticOptions={text:n.code.substring(1,n.code.length-1)},r}},oX=et.FromOptions({keyword:"text",argTypes:[],runner:async(t,e)=>{await ty({speaker:"game",cssClass:"text-command",text:t.staticOptions.text,choices:e,interactive:!0})},parser:iX(),returnAfterPlayerAnswer:!0}),aX=new et("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})}),sX=new et("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})}),uX=new et("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)}),lX=new et("item_amount?",[{name:"id",type:"string"}],async t=>{const{id:e}=t.options;return kr().getItemAmount(e)}),cX=new et("enable_interaction",[{name:"tag",type:"string"}],async t=>{const e=t.options.tag;kr().enableInteraction(e)}),fX=new et("disable_interaction",[{name:"tag",type:"string"}],async t=>{const e=t.options.tag;kr().disableInteraction(e)}),dX=new et("start_quest",[{name:"questId",type:"string"}],async t=>{const e=t.options.questId;Kr().startQuest(e)}),hX=new et("start_objective",[{name:"questId",type:"string"},{name:"objectiveId",type:"string"}],async t=>{const{questId:e,objectiveId:n}=t.options;Kr().startObjective(e,n)}),pX=new et("complete_objective",[{name:"questId",type:"string"},{name:"objectiveId",type:"string"}],async t=>{const{questId:e,objectiveId:n}=t.options;Kr().completeObjective(e,n)}),vX=new et("complete_quest",[{name:"questId",type:"string"},{name:"ending",type:"string",optional:!0}],async t=>{const{questId:e,ending:n}=t.options;Kr().completeQuest(e,n)}),mX=new et("quest_completed?",[{name:"questId",type:"string"}],async t=>{const{questId:e}=t.options;return Kr().isQuestCompleted(e)}),gX=new et("objective_completed?",[{name:"questId",type:"string"},{name:"objectiveId",type:"string"}],async t=>{const{questId:e,objectiveId:n}=t.options;return Kr().isObjectiveCompleted(e,n)}),yX=new et("quest_started?",[{name:"questId",type:"string"}],async t=>{const{questId:e}=t.options;return Kr().isQuestStarted(e)}),bX=new et("objective_started?",[{name:"questId",type:"string"},{name:"objectiveId",type:"string"}],async t=>{const{questId:e,objectiveId:n}=t.options;return Kr().isObjectiveStarted(e,n)}),kX=et.FromOptions({keyword:"wait",argTypes:[{name:"duration",type:"number"}],runner:async t=>{await to(t.options.duration)}}),wX=new et("notify",[{name:"text",type:"string"}],async t=>{const{text:e}=t.options;Ii().addNotification(e)}),xX=new et("disable_notifications",[],async t=>{Ii().disableNotifications()}),jX=new et("enable_notifications",[],async t=>{Ii().enableNotifications()}),_X=new et("clear_dialog",[],async t=>{ii().clearDialog()}),SX=new et("if",[{name:"condition",type:"boolean"}],async t=>{const e=EG(t),n=dn();if(e){const r={branchData:{branch:e},currentIndex:0};return n.addAndRunBlock(r)}},(t,e)=>{let n=t.currentLine;uc("if",[{name:"condition",type:"string"}])(t,e);const{lines:i,currentLine:o,line:a}=t,s=e.command;let u;const l=AG(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}}),CX=new et("==","any",async t=>{t.args.length<2&&vn(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}),$X=new et(">",[{name:"a",type:"any"},{name:"b",type:"any"}],async t=>{const{a:e,b:n}=t.options;return e>n}),OX=new et("<",[{name:"a",type:"any"},{name:"b",type:"any"}],async t=>{const{a:e,b:n}=t.options;return e<n}),EX=new et(">=",[{name:"a",type:"any"},{name:"b",type:"any"}],async t=>{const{a:e,b:n}=t.options;return e>=n}),AX=new et("<=",[{name:"a",type:"any"},{name:"b",type:"any"}],async t=>{const{a:e,b:n}=t.options;return e<=n}),MX=new et("!=",[{name:"a",type:"any"},{name:"b",type:"any"}],async t=>{const{a:e,b:n}=t.options;return e!=n}),TX=new et("!",[{name:"a",type:"any"}],async t=>{const{a:e}=t.options;return!e}),PX=new et("&&","any",async t=>{const e=t.args;return t.args.length<2&&vn(t,"requires at least two arguments"),e.reduce((n,r)=>n&&r,!0)}),IX=new et("||","any",async t=>(t.args.length<2&&vn(t,"requires at least two arguments"),t.args.reduce((e,n)=>e||n,!1))),NX=new et("?",[{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}),LX=new et("+","any",async t=>(t.args.length<2&&vn(t,"requires at least two arguments"),t.args.reduce((e,n)=>typeof n=="number"?e+n:(vn(t,"requires all arguments to be numbers"),e),0))),DX=new et("-","any",async t=>(t.args.length<2&&vn(t,"requires at least two arguments"),t.args.slice(1).reduce((e,n)=>typeof n=="number"?e-n:(vn(t,"requires all arguments to be numbers"),e),t.args[0]))),RX=new et("neg",[{name:"a",type:"number"}],async t=>(t.args.length!==1&&vn(t,"requires one argument"),-t.options.a)),BX=new et("abs",[{name:"a",type:"number"}],async t=>(t.args.length!==1&&vn(t,"requires one argument"),Math.abs(t.options.a))),zX=new et("*","any",async t=>(t.args.length<2&&vn(t,"requires at least two arguments"),t.args.reduce((e,n)=>typeof n=="number"?e*n:(vn(t,"requires all arguments to be numbers"),e),1))),VX=new et("/","any",async t=>{t.args.length<2&&vn(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:(vn(t,"requires all arguments to be numbers"),n),e)}),FX=async t=>{const{prompt:e,choices:n}=t.staticOptions,r=[];for(const[,a]of n.entries()){const s=await ny(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 Y7(e,i);return await UX(t,o)};function qX(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 HX=(t,e)=>{let n=t.currentLine;uc("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=JX(t.parserContext,u),qX(t,u)));return i.staticOptions={prompt:t.processCommandsFunction(t.parserContext,[o],r)[0],choices:s},n++,{newLine:n}},WX=et.FromOptions({keyword:"choice",argTypes:[],runner:FX,parser:HX}),UX=async(t,e)=>{const n=e,r=dn(),{choices:i}=t.staticOptions,o=i[n],a=t.options.choiceResults[n];let s=a.text,u;if(a.skillCheck?(s=null,J7({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};ii().addDialog(l)}if(u){const l={currentIndex:0,branchData:{branch:u}};return await r.addAndRunBlock(l)}};function JX(t,e){return{code:`choicePrompt ${e.code}`,indentation:e.indentation,line:e.line,branch:e.branch,expression:["choicePrompt",...e.expression]}}const GX=new et("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=pr().getSkillCheck(n);if(s.hidden)return{text:null};const u=s.happened&&!s.succeeded,{difficultyText:l}=SG({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]}}),r8=et.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};ii().addDialog(e)}});r8.onPlayerAnswered=async(t,e)=>(typeof e!="string"&&vn(t,"The player's answer should be a string"),e);const KX=et.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};ii().addDialog(e)}}),QX=new et("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"?(vn(t,"random command needs two numbers as parameters"),0):Math.floor(Math.random()*(n-e+1))+e}),YX=new et("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"?(vn(t,"random_float command needs two numbers as parameters"),0):Math.random()*(n-e)+e}),XX=new et("random_from_args",[],async t=>{const e=t.args;return!e||!e.length?(vn(t,"random_from_args command needs at least one argument"),0):e[Math.floor(Math.random()*e.length)]}),ZX=new et("concat","any",async t=>(t.args.length<2&&vn(t,"requires at least two arguments"),t.args.reduce((e,n)=>typeof n=="string"?`${e}${n}`:(vn(t,"requires all arguments to be strings"),e),""))),eZ=new et("join","any",async t=>{const e=t.args[0];return t.args.length<3&&vn(t,"requires at least 3 arguments"),t.args.slice(1).reduce((n,r)=>typeof r=="string"?`${n}${e}${r}`:(vn(t,"requires all arguments to be strings"),n),"")}),tZ=et.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}}),nZ=et.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}}),rZ=et.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}}),iZ=et.FromOptions({keyword:"floor",argTypes:[{name:"value",type:"number"}],runner:async t=>{const{value:e}=t.options;return Math.floor(e)}}),oZ=et.FromOptions({keyword:"ceil",argTypes:[{name:"value",type:"number"}],runner:async t=>{const{value:e}=t.options;return Math.ceil(e)}}),aZ=et.FromOptions({keyword:"round",argTypes:[{name:"value",type:"number"}],runner:async t=>{const{value:e}=t.options;return Math.round(e)}}),sZ=et.FromOptions({keyword:"sqrt",argTypes:[{name:"value",type:"number"}],runner:async t=>{const{value:e}=t.options;return Math.sqrt(e)}}),uZ=et.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)}});function lZ(t){t.addCommand(WX),t.addCommand(GX),t.addCommand(SX),t.addCommand(NY),t.addCommand(LY),t.addCommand(DY),t.addCommand(_X),t.addCommand(wX),t.addCommand(xX),t.addCommand(jX),t.addCommand(GY),t.addCommand(JY),t.addCommand(KY),t.addCommand(tX),t.addCommand(ZY),t.addCommand(eX),t.addCommand(kX),t.addCommand(CX),t.addCommand($X),t.addCommand(OX),t.addCommand(EX),t.addCommand(AX),t.addCommand(MX),t.addCommand(TX),t.addCommand(PX),t.addCommand(IX),t.addCommand(NX),t.addCommand(LX),t.addCommand(DX),t.addCommand(zX),t.addCommand(VX),t.addCommand(RX),t.addCommand(BX),t.addCommand(XY),t.addCommand(YY),t.addCommand(oX),t.addCommand(nX),t.addCommand(rX),t.addCommand(RY),t.addCommand(BY),t.addCommand(zY),t.addCommand(VY),t.addCommand(FY),t.addCommand(qY),t.addCommand(HY),t.addCommand(WY),t.addCommand(dX),t.addCommand(hX),t.addCommand(pX),t.addCommand(vX),t.addCommand(yX),t.addCommand(bX),t.addCommand(mX),t.addCommand(gX),t.addCommand(aX),t.addCommand(sX),t.addCommand(cX),t.addCommand(fX),t.addCommand(uX),t.addCommand(lX),t.addCommand(EY),t.addCommand(AY),t.addCommand(MY),t.addCommand(IY),t.addCommand(TY),t.addCommand(PY),t.addCommand(r8),t.addCommand(KX),t.addCommand(QX),t.addCommand(YX),t.addCommand(XX),t.addCommand(ZX),t.addCommand(eZ),t.addCommand(tZ),t.addCommand(nZ),t.addCommand(rZ),t.addCommand(iZ),t.addCommand(aZ),t.addCommand(oZ),t.addCommand(sZ),t.addCommand(uZ)}let lc;lr.callHook("onPageLoaded");async function cZ(t,e){const n=Object.assign(IG(),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));const r=await L0(n.configPath);uJ(JSON.parse(r)),n.baseAssetsPath&&(ft().baseAssetsPath=n.baseAssetsPath),n.baseDataPath&&(ft().baseDataPath=n.baseDataPath),lc=w.createApp($Y,{options:n});const i=IJ();if(lc.use(i),Gt().setOptions(n),lc.use(j8,{breakpoints:{s:0,m:800,l:1200}}),lZ(lr),by.setupDebugger(n.debug),console.log("%c Narrat game engine \u2013 [VI]{version} - {date}[/VI]","background: #222; color: #bada55"),lr.callHook("onNarratSetup"),lc.mount("#game-holder"),n.debug){const o={app:lc,vm:lr,jump:a=>{dn().jumpToLabel(a)}};window.narrat=o}}class fZ{onPageLoaded(){}onNarratSetup(){}onAppMounted(){}onAssetsLoaded(){}onGameSetup(){}onGameStart(){}onGameMounted(){}onGameDismounted(){}}function dZ(t){lr.addPlugin(t)}function hZ(t){lr.addCommand(t)}ln.CommandPlugin=et,ln.NarratPlugin=fZ,ln.addCommand=hZ,ln.aspectRatioFit=e8,ln.generateParser=uc,ln.getConfig=ft,ln.registerPlugin=dZ,ln.startApp=cZ,Object.defineProperties(ln,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
185
185
  //# sourceMappingURL=narrat.umd.js.map