narrat 2.10.7 → 2.10.8

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.
Files changed (153) hide show
  1. package/dist/app.vue.d.ts +78 -78
  2. package/dist/components/MainMenu.vue.d.ts +7 -7
  3. package/dist/components/SkillsWindow.vue.d.ts +28 -28
  4. package/dist/components/StartMenu.vue.d.ts +46 -46
  5. package/dist/components/auto-play/AutoPlayFeedback.vue.d.ts +46 -46
  6. package/dist/components/debug/debug-menu.vue.d.ts +51 -51
  7. package/dist/components/dialog-picture.vue.d.ts +11 -11
  8. package/dist/components/engine-splash/engine-splash.vue.d.ts +54 -54
  9. package/dist/components/game-dialog.vue.d.ts +65 -65
  10. package/dist/components/game-splash/game-splash.vue.d.ts +46 -46
  11. package/dist/components/hud.vue.d.ts +20 -20
  12. package/dist/components/in-game.vue.d.ts +46 -46
  13. package/dist/components/inventory/inventory-section.vue.d.ts +61 -61
  14. package/dist/components/inventory/item-details.vue.d.ts +76 -76
  15. package/dist/components/inventory-ui.vue.d.ts +39 -39
  16. package/dist/components/loading-bar.vue.d.ts +10 -10
  17. package/dist/components/menu-buttons.vue.d.ts +46 -46
  18. package/dist/components/notification-toast.vue.d.ts +6 -6
  19. package/dist/components/quests/QuestDetails.vue.d.ts +64 -64
  20. package/dist/components/quests/QuestDisplay.vue.d.ts +64 -64
  21. package/dist/components/quests/quests-list-section.vue.d.ts +75 -75
  22. package/dist/components/quests-ui.vue.d.ts +22 -22
  23. package/dist/components/save-slots.vue.d.ts +79 -79
  24. package/dist/components/saves/save-slot-ui.vue.d.ts +108 -108
  25. package/dist/components/screen-layer.vue.d.ts +76 -76
  26. package/dist/components/screen-objects/screen-object.vue.d.ts +68 -68
  27. package/dist/components/screens.vue.d.ts +46 -46
  28. package/dist/components/tabs/TabsController.vue.d.ts +72 -72
  29. package/dist/components/tabs/tab-selector.vue.d.ts +82 -82
  30. package/dist/components/tooltips/tooltips-ui.vue.d.ts +46 -46
  31. package/dist/components/transitions/NarratTransition.vue.d.ts +97 -97
  32. package/dist/components/utils/alert-modal.vue.d.ts +82 -82
  33. package/dist/components/utils/floating-tooltip.vue.d.ts +62 -62
  34. package/dist/components/utils/modal-window.vue.d.ts +18 -18
  35. package/dist/components/utils/yes-no.vue.d.ts +106 -106
  36. package/dist/components/volume-controls.vue.d.ts +18 -18
  37. package/dist/config/audio-config.d.ts +58 -58
  38. package/dist/config/buttons-config.d.ts +68 -68
  39. package/dist/config/characters-config.d.ts +36 -36
  40. package/dist/config/common-config.d.ts +80 -80
  41. package/dist/config/config-input.d.ts +231 -231
  42. package/dist/config/config-output.d.ts +232 -232
  43. package/dist/config/items-config.d.ts +71 -71
  44. package/dist/config/layout-config.d.ts +26 -26
  45. package/dist/config/quests-config.d.ts +48 -48
  46. package/dist/config/screens-config.d.ts +133 -133
  47. package/dist/config/skills-config.d.ts +70 -70
  48. package/dist/config/tooltips-config.d.ts +15 -15
  49. package/dist/config.d.ts +182 -182
  50. package/dist/constants.d.ts +12 -12
  51. package/dist/demo/demo.d.ts +1 -1
  52. package/dist/dialog-box.vue.d.ts +71 -71
  53. package/dist/exports/components.d.ts +2 -2
  54. package/dist/exports/config.d.ts +2 -2
  55. package/dist/exports/display.d.ts +2 -2
  56. package/dist/exports/events.d.ts +1 -1
  57. package/dist/exports/inputs.d.ts +1 -1
  58. package/dist/exports/others.d.ts +1 -1
  59. package/dist/exports/plugins.d.ts +67 -67
  60. package/dist/exports/stores.d.ts +16 -16
  61. package/dist/exports/utils.d.ts +12 -12
  62. package/dist/gamepad/gamepad.d.ts +1 -1
  63. package/dist/hooks/util-hooks.d.ts +1 -1
  64. package/dist/inputs/Inputs.d.ts +61 -61
  65. package/dist/lib.d.ts +20 -20
  66. package/dist/main.d.ts +6 -6
  67. package/dist/menu-buttons/menu-buttons.d.ts +7 -7
  68. package/dist/narrat.es.js +5 -8
  69. package/dist/narrat.es.js.map +1 -1
  70. package/dist/narrat.umd.js +2 -2
  71. package/dist/narrat.umd.js.map +1 -1
  72. package/dist/plugins/NarratPlugin.d.ts +12 -12
  73. package/dist/stores/audio-store.d.ts +56 -56
  74. package/dist/stores/config-store.d.ts +6 -6
  75. package/dist/stores/dialog-store.d.ts +35 -35
  76. package/dist/stores/hud-stats-store.d.ts +20 -20
  77. package/dist/stores/inputs-store.d.ts +14 -14
  78. package/dist/stores/inventory-store.d.ts +49 -49
  79. package/dist/stores/main-store.d.ts +1637 -1637
  80. package/dist/stores/menu-store.d.ts +45 -45
  81. package/dist/stores/notification-store.d.ts +15 -15
  82. package/dist/stores/quest-log.d.ts +37 -37
  83. package/dist/stores/rendering-store.d.ts +20 -20
  84. package/dist/stores/screen-objects-store.d.ts +80 -80
  85. package/dist/stores/screens-store.d.ts +34 -34
  86. package/dist/stores/skills.d.ts +39 -39
  87. package/dist/stores/start-menu-store.d.ts +7 -7
  88. package/dist/stores/tooltip-store.d.ts +18 -18
  89. package/dist/stores/vm-store.d.ts +181 -181
  90. package/dist/types/app-types.d.ts +8 -8
  91. package/dist/types/dialog-box-types.d.ts +11 -11
  92. package/dist/types/game-save.d.ts +41 -41
  93. package/dist/types/parser.d.ts +93 -93
  94. package/dist/types/state.d.ts +3 -3
  95. package/dist/utils/InputsListener.d.ts +9 -9
  96. package/dist/utils/Vector2.d.ts +49 -49
  97. package/dist/utils/ajax.d.ts +2 -2
  98. package/dist/utils/audio-loader.d.ts +10 -10
  99. package/dist/utils/characters.d.ts +4 -4
  100. package/dist/utils/data-helpers.d.ts +35 -35
  101. package/dist/utils/data-helpers.test.d.ts +1 -1
  102. package/dist/utils/debounce.d.ts +14 -14
  103. package/dist/utils/error-handling.d.ts +4 -4
  104. package/dist/utils/gameloop.d.ts +10 -10
  105. package/dist/utils/getWindow.d.ts +1 -1
  106. package/dist/utils/helpers.d.ts +6 -6
  107. package/dist/utils/images-loader.d.ts +7 -7
  108. package/dist/utils/logger.d.ts +11 -11
  109. package/dist/utils/object-iterators.d.ts +9 -9
  110. package/dist/utils/promises.d.ts +1 -1
  111. package/dist/utils/randomId.d.ts +1 -1
  112. package/dist/utils/save-helpers.d.ts +16 -16
  113. package/dist/utils/skillchecks.d.ts +17 -17
  114. package/dist/utils/string-helpers.d.ts +5 -5
  115. package/dist/utils/time-helpers.d.ts +2 -2
  116. package/dist/utils/tooltip-utils.d.ts +2 -2
  117. package/dist/utils/transition.d.ts +21 -21
  118. package/dist/utils/type-utils.d.ts +2 -2
  119. package/dist/utils/typed-emitter.d.ts +18 -18
  120. package/dist/utils/viewport-utils.d.ts +3 -3
  121. package/dist/utils/vue-directives.d.ts +2 -2
  122. package/dist/vm/commands/arithmetic-commands.d.ts +23 -23
  123. package/dist/vm/commands/array-commands.d.ts +42 -42
  124. package/dist/vm/commands/audio-commands.d.ts +15 -15
  125. package/dist/vm/commands/choice.d.ts +38 -38
  126. package/dist/vm/commands/clear_dialog.d.ts +2 -2
  127. package/dist/vm/commands/command-helpers.d.ts +3 -3
  128. package/dist/vm/commands/command-plugin.d.ts +43 -43
  129. package/dist/vm/commands/flow-commands.d.ts +27 -27
  130. package/dist/vm/commands/if.d.ts +10 -10
  131. package/dist/vm/commands/index.d.ts +2 -2
  132. package/dist/vm/commands/inventory-commands.d.ts +15 -15
  133. package/dist/vm/commands/logic-command.d.ts +42 -42
  134. package/dist/vm/commands/math-commands.d.ts +30 -30
  135. package/dist/vm/commands/notify.d.ts +6 -6
  136. package/dist/vm/commands/quest-commands.d.ts +30 -30
  137. package/dist/vm/commands/random-commands.d.ts +13 -13
  138. package/dist/vm/commands/screen-commands.d.ts +18 -18
  139. package/dist/vm/commands/set.d.ts +6 -6
  140. package/dist/vm/commands/skill-commands.d.ts +39 -39
  141. package/dist/vm/commands/sprite-commands.d.ts +16 -16
  142. package/dist/vm/commands/stats-commands.d.ts +12 -12
  143. package/dist/vm/commands/string-commands.d.ts +9 -9
  144. package/dist/vm/commands/text-field.d.ts +7 -7
  145. package/dist/vm/commands/text.d.ts +14 -14
  146. package/dist/vm/commands/time-commands.d.ts +16 -16
  147. package/dist/vm/commands/util-commands.d.ts +4 -4
  148. package/dist/vm/commands/wait.d.ts +4 -4
  149. package/dist/vm/vm-helpers.d.ts +19 -19
  150. package/dist/vm/vm-parser.d.ts +19 -19
  151. package/dist/vm/vm-parser.test.d.ts +1 -1
  152. package/dist/vm/vm.d.ts +21 -21
  153. package/package.json +1 -1
@@ -175,7 +175,7 @@ Only state can be modified.`);a[0]="$state",Bl=!1,r.set(o,a,r.state.value),Bl=!0
175
175
  Found in store "${C.$id}".`),p&&o&&n.hydrate&&n.hydrate(C.$state,p),l=!0,f=!0,C}function Jr(t,e,n){let r,i;const o=typeof e=="function";typeof t=="string"?(r=t,i=o?n:e):(i=t,r=t.id);function a(s,u){const l=b.getCurrentInstance();if(s=s||l&&b.inject(P8),s&&Mf(s),!Z1)throw new Error(`[\u{1F34D}]: getActivePinia was called with no active Pinia. Did you forget to install pinia?
176
176
  const pinia = createPinia()
177
177
  app.use(pinia)
178
- This will fail in production.`);s=Z1,s._s.has(r)||(o?ib(r,e,i,s):W8(r,i,s),a._pinia=s);const f=s._s.get(r);if(u){const c="__hot:"+r,d=o?ib(c,e,i,s,!0):W8(c,Ho({},i),s,!0);u._hotUpdate(d),delete s.state.value[c],s._s.delete(c)}if(Ds&&l&&l.proxy&&!u){const c=l.proxy,d="_pStores"in c?c._pStores:c._pStores={};d[r]=f}return f}return a.$id=r,a}function Za(t,e){return Array.isArray(e)?e.reduce((n,r)=>(n[r]=function(){return t(this.$pinia)[r]},n),{}):Object.keys(e).reduce((n,r)=>(n[r]=function(){const i=t(this.$pinia),o=e[r];return typeof o=="function"?o.call(this,i):i[o]},n),{})}const K8=["music","ambiant","sound"],J8=dZ(K8),Gr=Jr("audio",{state:()=>{const t=new Map;for(const e in J8)t.set(e,{channels:[],options:{volume:1}});return{modes:t,masterVolume:1}},actions:{stopAll(){this.modes.forEach(t=>{t.channels.forEach((e,n)=>{e&&(this.actuallyStopChannel(e),t.channels[n]=null)})})},async stopChannel(t,e){const n=this.getAudioChannel(t,e);if(!!n){if(this.setAudioChannel(t,e,null),Aa().options.musicFadeOutTime){const r=Fl(n.audio);r&&r.fade(r.volume(n.howlerId),0,Aa().options.musicFadeOutTime*1e3,n.howlerId),await _o(Aa().options.musicFadeOutTime*1e3)}this.actuallyStopChannel(n)}},async pauseChannel(t,e){const n=this.getAudioChannel(t,e);if(!n)return;const r=Fl(n.audio);if(!r){Kt(`Could not find audio ${n.audio}`);return}r.pause(n.howlerId)},async playChannel(t,e,n){if(Ya.Howler.ctx.state==="suspended"){console.warn("Audio context not started yet, skipping audio");return}const r=this.getAudioChannel(t,n);if(t==="sound")return this.actuallyPlayChannel(t,n,e);r&&r.audio!==e?await this.changeChannel(t,e,n):r&&r.audio===e||await this.actuallyPlayChannel(t,n,e)},async changeChannel(t,e,n){this.getAudioChannel(t,n)&&t!=="sound"&&await this.stopChannel(t,n),await this.actuallyPlayChannel(t,n,e)},actuallyStopChannel(t){HZ(t.audio,t.howlerId)},getAudioChannel(t,e){return this.modes.get(t).channels[e]||null},setAudioChannel(t,e,n){this.modes.get(t).channels[e]=n},async actuallyPlayChannel(t,e,n){const r=Fl(n);if(!r){Kt(`Could not find audio ${n}`);return}if(t!=="sound"){const i=r.play();r.volume(0,i),r.pause(i),this.setAudioChannel(t,e,{audio:n,howlerId:i}),await _o(Aa().options.musicFadeInDelay*1e3);const o=this.getAudioChannel(t,e);o!==null&&o.audio===n&&(r.play(i),r.fade(0,this.modeVolume(t),Aa().options.musicFadeInTime*1e3,i))}else if(t==="sound"){const i=r.play();r.volume(this.modeVolume(t),i),this.setAudioChannel(t,e,{audio:n,howlerId:i})}},reloadAudio(t){for(const e in t.modes){if(e==="sound")continue;const n=e;this.modes.get(n).options=pi(t.modes[n].options);for(const r in t.modes[n].channels){const i=t.modes[n].channels[r];i&&i.audio&&this.actuallyPlayChannel(n,Number(r),i.audio)}}},stopSound(t){const e=Fl(t);e&&e.stop()},generateSaveData(){const t={};for(const e in J8){const n=this.modes.get(e);t[e]={options:pi(n.options),channels:pi(n.channels).map(r=>r?{audio:r.audio}:{audio:null})}}return{modes:t,masterVolume:this.masterVolume}},loadSaveData(t){this.masterVolume=t.masterVolume},reset(){this.stopAll()},setModeVolume(t,e){const n=this.modes.get(t);n.options.volume=e;for(const r in n.channels){const i=n.channels[r];if(i){const o=Fl(i.audio);o&&o.volume(this.modeVolume(t),i.howlerId)}}},setMasterVolume(t){this.masterVolume=t,Ya.Howler.volume(t)},modeVolume(t){return this.masterVolume*this.modes.get(t).options.volume}}}),G8={};Ya.Howler.volume(.5);let ob={};async function VZ(t){Zo.log("Loading audio");const e=[];Ya.Howler.volume(t.options.volume);for(const n in t.files){const r=t.files[n];r.src||(r.src=r.path,r.path||console.error(`Audio config for ${n} doesn't have any \`src\` value to find the file`),console.warn("Using `path` for audio and musics is deprecated. Please replace `path` with `src` in your config file!")),e.push(qZ(n,t.files[n]))}return t.audioTriggers&&(ob=t.audioTriggers),Promise.all(e)}function Eu(t){ob[t]&&Gr().playChannel("sound",ob[t],0)}async function qZ(t,e){return new Promise((n,r)=>{Zo.log(`Loading audio ${e.src}`);const i=new Ya.Howl({...e,src:Ma(e.src)});i.load(),G8[t]=i,n()})}function HZ(t,e){const n=Fl(t);if(!n){Au(`Could not find music ${t}`);return}n.stop(e)}function Fl(t){return G8[t]}const Vl={};async function UZ(t){return Vl[t]?Vl[t]:Q8(t,t)}async function WZ(t){Zo.log("Loading images");let e=0,n=0;const r=[],i=async(a,s)=>{n++;const u=await Q8(a,s);return e++,console.log(`Loaded ${e} / ${n} images`),u},o=(a,s)=>{r.push(i(a,s))};for(const a in t.images){const s=t.images[a];o(a,s)}for(const a in t.screens.screens){const s=t.screens.screens[a];if(s.background&&!t.images[s.background]&&o(s.background,s.background),s.buttons)for(const u in s.buttons){const l=s.buttons[u];typeof l=="object"&&l.background&&!t.images[l.background]&&o(l.background,l.background)}}return Promise.all(r)}async function Q8(t,e){if(Vl[t])return Vl[t];const n=new Promise((r,i)=>{Zo.log(`Loading image ${t} at ${e}`);const o=new Image;o.onload=()=>{Vl[t]=o,Zo.log(`Loaded image ${t} successfully`),r(o)},o.onerror=a=>{Kt(`Failed to load image ${t} at ${e}`,a),i(a)},o.src=Ma(e)});return Vl[t]=n,n}function ql(){return`${Date.now()}-${Math.floor(Math.random()*1e11)}-${Math.floor(Math.random()*1e11)}`}const Y8="gameSave",am="###_--_~=:;_JUMP",ab="###_--_~=:;_RETURN",KZ="###_--_~=:;_OK",sm="###_--_~=:;_STOP";function JZ(t){return t===am||t===ab||t===KZ||t===sm}const GZ="2.10.7",QZ=new Date("2023-02-13T22:28:38.149Z"),YZ=400,sb=20,X8="1.4.0";let Fr;function Z8(){if(Fr)return Fr;if(!Fr){let t=null;try{const e=localStorage.getItem(Y8);e&&(t=JSON.parse(e)),t&&typeof t=="object"&&t.slots&&t.slots[0]&&t.slots[0].id||(t=null,localStorage.clear())}catch(e){Au(`Save file deleted because it was either broken or an outdated format: ${e}`)}t?Fr=t:Fr=ZZ()}return XZ(Fr),e7(Fr),um(),Fr}function XZ(t){t.version}function ZZ(){const t={version:X8,slots:[]};return e7(t),t}function e7(t){var n;const e=(n=gt().saves.slots)!=null?n:10;t.slots.length<1&&(t.slots[0]={slotType:"auto",id:ql(),saveData:null,slotNumber:0}),t.slots[0].slotType="auto";for(let r=1;r<e+1;r++)t.slots.length<=r&&(t.slots[r]={slotNumber:r,slotType:gt().saves.mode==="manual"?"manual":"auto",id:ql(),saveData:null})}function t7(t,e){const n=nee(e);if(Fr.slots[n])Fr.slots[n].saveData=t;else{Kt(`Tried to save to slot ${e} but it doesn't exist`);return}um()}function eee(t){Fr.lastSaveSlot=t}function um(){localStorage.setItem(Y8,JSON.stringify(Fr))}function tee(){const t=Fr.slots.find(e=>!e.saveData);return t?t.id:!1}function nee(t){return Fr.slots.findIndex(e=>e.id===t)}function Pf(t){return Fr.slots.find(e=>e.id===t)}function ub(){return Fr.slots.find(t=>t.slotType==="auto")}function ree(t){const e=Fr.slots.findIndex(n=>n.id===t);Fr.slots[e].saveData=null,um()}function iee(t,e){const n=Pf(t);n&&n.saveData&&(n.saveData.metadata.name=e),um()}function oee(){return{saveDate:new Date().toISOString(),name:"New Save"}}const lm=Jr("tooltips",{state:()=>({tooltip:null}),actions:{addCustomTooltip(t){t.title&&(t.title=es(t.title)),t.text=es(t.text),this.tooltip=t},addTooltip(t,e){var r,i;const n=QD(t);n&&this.addCustomTooltip({title:n.title,text:n.description,x:(r=e==null?void 0:e.x)!=null?r:window.screenX,y:(i=e==null?void 0:e.y)!=null?i:window.screenY,width:ed().options.width})},deleteTooltip(){this.tooltip=null}}});function lb(){return window}function aee(t){const e=ed().options.keywordsPrefix,n=new RegExp(`${e}(\\w*)`,"gi");return t=t.replace(n,see),t}lb().onTooltipEnter=(t,e)=>{const n={x:t.clientX,y:t.clientY-20};lm().addTooltip(e,n)},lb().onTooltipLeave=()=>{lm().deleteTooltip()};function see(t,e){const n=e.toLowerCase();return QD(n)?`<span class='highlighted-tooltip-keyword'
178
+ This will fail in production.`);s=Z1,s._s.has(r)||(o?ib(r,e,i,s):W8(r,i,s),a._pinia=s);const f=s._s.get(r);if(u){const c="__hot:"+r,d=o?ib(c,e,i,s,!0):W8(c,Ho({},i),s,!0);u._hotUpdate(d),delete s.state.value[c],s._s.delete(c)}if(Ds&&l&&l.proxy&&!u){const c=l.proxy,d="_pStores"in c?c._pStores:c._pStores={};d[r]=f}return f}return a.$id=r,a}function Za(t,e){return Array.isArray(e)?e.reduce((n,r)=>(n[r]=function(){return t(this.$pinia)[r]},n),{}):Object.keys(e).reduce((n,r)=>(n[r]=function(){const i=t(this.$pinia),o=e[r];return typeof o=="function"?o.call(this,i):i[o]},n),{})}const K8=["music","ambiant","sound"],J8=dZ(K8),Gr=Jr("audio",{state:()=>{const t=new Map;for(const e in J8)t.set(e,{channels:[],options:{volume:1}});return{modes:t,masterVolume:1}},actions:{stopAll(){this.modes.forEach(t=>{t.channels.forEach((e,n)=>{e&&(this.actuallyStopChannel(e),t.channels[n]=null)})})},async stopChannel(t,e){const n=this.getAudioChannel(t,e);if(!!n){if(this.setAudioChannel(t,e,null),Aa().options.musicFadeOutTime){const r=Fl(n.audio);r&&r.fade(r.volume(n.howlerId),0,Aa().options.musicFadeOutTime*1e3,n.howlerId),await _o(Aa().options.musicFadeOutTime*1e3)}this.actuallyStopChannel(n)}},async pauseChannel(t,e){const n=this.getAudioChannel(t,e);if(!n)return;const r=Fl(n.audio);if(!r){Kt(`Could not find audio ${n.audio}`);return}r.pause(n.howlerId)},async playChannel(t,e,n){if(Ya.Howler.ctx.state==="suspended"){console.warn("Audio context not started yet, skipping audio");return}const r=this.getAudioChannel(t,n);if(t==="sound")return this.actuallyPlayChannel(t,n,e);r&&r.audio!==e?await this.changeChannel(t,e,n):r&&r.audio===e||await this.actuallyPlayChannel(t,n,e)},async changeChannel(t,e,n){this.getAudioChannel(t,n)&&t!=="sound"&&await this.stopChannel(t,n),await this.actuallyPlayChannel(t,n,e)},actuallyStopChannel(t){HZ(t.audio,t.howlerId)},getAudioChannel(t,e){return this.modes.get(t).channels[e]||null},setAudioChannel(t,e,n){this.modes.get(t).channels[e]=n},async actuallyPlayChannel(t,e,n){const r=Fl(n);if(!r){Kt(`Could not find audio ${n}`);return}if(t!=="sound"){const i=r.play();r.volume(0,i),r.pause(i),this.setAudioChannel(t,e,{audio:n,howlerId:i}),await _o(Aa().options.musicFadeInDelay*1e3);const o=this.getAudioChannel(t,e);o!==null&&o.audio===n&&(r.play(i),r.fade(0,this.modeVolume(t),Aa().options.musicFadeInTime*1e3,i))}else if(t==="sound"){const i=r.play();r.volume(this.modeVolume(t),i),this.setAudioChannel(t,e,{audio:n,howlerId:i})}},reloadAudio(t){for(const e in t.modes){if(e==="sound")continue;const n=e;this.modes.get(n).options=pi(t.modes[n].options);for(const r in t.modes[n].channels){const i=t.modes[n].channels[r];i&&i.audio&&this.actuallyPlayChannel(n,Number(r),i.audio)}}},stopSound(t){const e=Fl(t);e&&e.stop()},generateSaveData(){const t={};for(const e in J8){const n=this.modes.get(e);t[e]={options:pi(n.options),channels:pi(n.channels).map(r=>r?{audio:r.audio}:{audio:null})}}return{modes:t,masterVolume:this.masterVolume}},loadSaveData(t){this.masterVolume=t.masterVolume},reset(){this.stopAll()},setModeVolume(t,e){const n=this.modes.get(t);n.options.volume=e;for(const r in n.channels){const i=n.channels[r];if(i){const o=Fl(i.audio);o&&o.volume(this.modeVolume(t),i.howlerId)}}},setMasterVolume(t){this.masterVolume=t,Ya.Howler.volume(t)},modeVolume(t){return this.masterVolume*this.modes.get(t).options.volume}}}),G8={};Ya.Howler.volume(.5);let ob={};async function VZ(t){Zo.log("Loading audio");const e=[];Ya.Howler.volume(t.options.volume);for(const n in t.files){const r=t.files[n];r.src||(r.src=r.path,r.path||console.error(`Audio config for ${n} doesn't have any \`src\` value to find the file`),console.warn("Using `path` for audio and musics is deprecated. Please replace `path` with `src` in your config file!")),e.push(qZ(n,t.files[n]))}return t.audioTriggers&&(ob=t.audioTriggers),Promise.all(e)}function Eu(t){ob[t]&&Gr().playChannel("sound",ob[t],0)}async function qZ(t,e){return new Promise((n,r)=>{Zo.log(`Loading audio ${e.src}`);const i=new Ya.Howl({...e,src:Ma(e.src)});i.load(),G8[t]=i,n()})}function HZ(t,e){const n=Fl(t);if(!n){Au(`Could not find music ${t}`);return}n.stop(e)}function Fl(t){return G8[t]}const Vl={};async function UZ(t){return Vl[t]?Vl[t]:Q8(t,t)}async function WZ(t){Zo.log("Loading images");let e=0,n=0;const r=[],i=async(a,s)=>{n++;const u=await Q8(a,s);return e++,console.log(`Loaded ${e} / ${n} images`),u},o=(a,s)=>{r.push(i(a,s))};for(const a in t.images){const s=t.images[a];o(a,s)}for(const a in t.screens.screens){const s=t.screens.screens[a];if(s.background&&!t.images[s.background]&&o(s.background,s.background),s.buttons)for(const u in s.buttons){const l=s.buttons[u];typeof l=="object"&&l.background&&!t.images[l.background]&&o(l.background,l.background)}}return Promise.all(r)}async function Q8(t,e){if(Vl[t])return Vl[t];const n=new Promise((r,i)=>{Zo.log(`Loading image ${t} at ${e}`);const o=new Image;o.onload=()=>{Vl[t]=o,Zo.log(`Loaded image ${t} successfully`),r(o)},o.onerror=a=>{Kt(`Failed to load image ${t} at ${e}`,a),i(a)},o.src=Ma(e)});return Vl[t]=n,n}function ql(){return`${Date.now()}-${Math.floor(Math.random()*1e11)}-${Math.floor(Math.random()*1e11)}`}const Y8="gameSave",am="###_--_~=:;_JUMP",ab="###_--_~=:;_RETURN",KZ="###_--_~=:;_OK",sm="###_--_~=:;_STOP";function JZ(t){return t===am||t===ab||t===KZ||t===sm}const GZ="2.10.8",QZ=new Date("2023-02-14T10:29:13.921Z"),YZ=400,sb=20,X8="1.4.0";let Fr;function Z8(){if(Fr)return Fr;if(!Fr){let t=null;try{const e=localStorage.getItem(Y8);e&&(t=JSON.parse(e)),t&&typeof t=="object"&&t.slots&&t.slots[0]&&t.slots[0].id||(t=null,localStorage.clear())}catch(e){Au(`Save file deleted because it was either broken or an outdated format: ${e}`)}t?Fr=t:Fr=ZZ()}return XZ(Fr),e7(Fr),um(),Fr}function XZ(t){t.version}function ZZ(){const t={version:X8,slots:[]};return e7(t),t}function e7(t){var n;const e=(n=gt().saves.slots)!=null?n:10;t.slots.length<1&&(t.slots[0]={slotType:"auto",id:ql(),saveData:null,slotNumber:0}),t.slots[0].slotType="auto";for(let r=1;r<e+1;r++)t.slots.length<=r&&(t.slots[r]={slotNumber:r,slotType:gt().saves.mode==="manual"?"manual":"auto",id:ql(),saveData:null})}function t7(t,e){const n=nee(e);if(Fr.slots[n])Fr.slots[n].saveData=t;else{Kt(`Tried to save to slot ${e} but it doesn't exist`);return}um()}function eee(t){Fr.lastSaveSlot=t}function um(){localStorage.setItem(Y8,JSON.stringify(Fr))}function tee(){const t=Fr.slots.find(e=>!e.saveData);return t?t.id:!1}function nee(t){return Fr.slots.findIndex(e=>e.id===t)}function Pf(t){return Fr.slots.find(e=>e.id===t)}function ub(){return Fr.slots.find(t=>t.slotType==="auto")}function ree(t){const e=Fr.slots.findIndex(n=>n.id===t);Fr.slots[e].saveData=null,um()}function iee(t,e){const n=Pf(t);n&&n.saveData&&(n.saveData.metadata.name=e),um()}function oee(){return{saveDate:new Date().toISOString(),name:"New Save"}}const lm=Jr("tooltips",{state:()=>({tooltip:null}),actions:{addCustomTooltip(t){t.title&&(t.title=es(t.title)),t.text=es(t.text),this.tooltip=t},addTooltip(t,e){var r,i;const n=QD(t);n&&this.addCustomTooltip({title:n.title,text:n.description,x:(r=e==null?void 0:e.x)!=null?r:window.screenX,y:(i=e==null?void 0:e.y)!=null?i:window.screenY,width:ed().options.width})},deleteTooltip(){this.tooltip=null}}});function lb(){return window}function aee(t){const e=ed().options.keywordsPrefix,n=new RegExp(`${e}(\\w*)`,"gi");return t=t.replace(n,see),t}lb().onTooltipEnter=(t,e)=>{const n={x:t.clientX,y:t.clientY-20};lm().addTooltip(e,n)},lb().onTooltipLeave=()=>{lm().deleteTooltip()};function see(t,e){const n=e.toLowerCase();return QD(n)?`<span class='highlighted-tooltip-keyword'
179
179
  onmouseenter="onTooltipEnter(event, '${n}')"
180
180
  onmouseleave="onTooltipLeave()">${e}</span>`:n}function es(t){const e=t.replace(/%{[^}]*}/g,n=>{const r=n.substr(2,n.length-3);return n7(r)});return aee(e)}function n7(t){const e=ic(),[n,r]=qm(e,t);return n[r]}const r7=/\$\$"/,uee=t=>typeof t=="string"&&t.search(r7)===0;function lee(t){let e=null;const n=[],r=/<[^>]*>/g;do e=r.exec(t),e&&n.push(e);while(e);return n}const zn=Jr("dialog",{state:()=>({dialog:[],playMode:"normal"}),actions:{generateSaveData(){return{dialog:pi(this.dialog)}},loadSaveData(t){this.dialog=t.dialog},addDialog(t){var e;this.dialog.push({...t,interactive:(e=t.interactive)!=null?e:!1,id:ql(),text:es(t.text)}),this.dialog.length>200&&this.dialog.shift()},toggleAutoPlay(){this.playMode=this.playMode==="auto"?"normal":"auto"},toggleSkip(){this.playMode=this.playMode==="skip"?"normal":"skip"},clearDialog(){this.dialog.splice(0,this.dialog.length)},reset(){this.dialog=[],this.playMode="normal"}},getters:{currentDialog(){return this.dialog[this.dialog.length-1]}}});function cee(t,e){return t-e*Co().skillChecks.skillMultiplier}function i7(t,e){const n=cee(t,e),r=Co().skillChecks;let i=!1,o=0,a=r.difficultyText[0][1];for(;!i;)r.difficultyText.length>o&&n>=r.difficultyText[o][0]?a=r.difficultyText[o][1]:i=!0,o++;return a}function fee({skill:t,skillCheckId:e,value:n}){const r=_r(),i=r.getSkillCheck(e),o=Ek(t),a=r.skills[t].level,s=i7(n,a);let u=!0,l=`<span class='skill-check'>[<span class='skill-check-name'>${o.name}</span> - `;return i.happened?i.succeeded?l="":(u=!1,l+=` <span class='skill-check-difficulty'>${s}</span> - <span class='skill-check-failed'>FAILED</span>]</span>`):l+=` <span class='skill-check-difficulty'>${s}</span>]</span>`,{difficultyText:l,allowed:u}}function dee(t,e){const n=_r(),r=Ek(e.skill),i=i7(e.value,n.skills[e.skill].level);return`<span class='passive-skill-check skill-check'>[<span class='skill-check-name'>${r.name}</span> - <span class='skill-check-difficulty'>${i}</span> - ${t?'<span class="skill-check-success">Success</span>':'<span class="skill-check-failed">Failure</span>'}]</span>`}function hee(t){const{skillChecks:e}=Co(),n=_r(),r=Math.floor(Math.random()*e.rollRange),i=n.skills[t].level*e.skillMultiplier,o=r+i;return Zo.log(`[SKILL CHECK] Roll: ${o}. (Base roll: ${r}, modifier: ${i} - Skill level: ${n.skills[t].level})`),{roll:o,unmodifiedRoll:r}}function pee(t){const{skills:e,skillChecks:n}=Co();let r=!0;const{roll:i}=hee(t.skill);i<=n.failureChance-1&&(r=!1);const o=e[t.skill];return i<t.value&&(r=!1),Zo.log(`[SKILL CHECK ${o.name}]: ${r?"\u2705":"\u274C"}`,`(${t.id}) - ${i}/${t.value}`),Eu(r?"onSkillCheckSuccess":"onSkillCheckFailure"),r}function o7(t){const e=_r(),n=e.getSkillCheck(t.id);if(n&&n.happened&&(n.succeeded||!t.repeatable))return n;const r=pee(t);return u7(dee(r,t)),r?e.passSkillCheck(t.id,t.hideAfterRoll):e.failSkillCheck(t.id,t.hideAfterRoll),e.getSkillCheck(t.id)}function mee(t){const e=t.options,n=t.staticOptions,r=!!e.condition;if(r)return n.success;if(!r&&n.failure)return n.failure}function a7(t){return typeof t=="object"}function s7(t){return typeof t=="string"&&t.search(/\$/)===0}function u7(t){const e={speaker:"game",text:t,interactive:!1};zn().addDialog(e)}async function cb(t){zn().addDialog(t)}function vee(t,e){if(e<t.length)return t[e]}/*! js-yaml 4.1.0 https://github.com/nodeca/js-yaml @license MIT */function l7(t){return typeof t>"u"||t===null}function gee(t){return typeof t=="object"&&t!==null}function yee(t){return Array.isArray(t)?t:l7(t)?[]:[t]}function bee(t,e){var n,r,i,o;if(e)for(o=Object.keys(e),n=0,r=o.length;n<r;n+=1)i=o[n],t[i]=e[i];return t}function kee(t,e){var n="",r;for(r=0;r<e;r+=1)n+=t;return n}function wee(t){return t===0&&Number.NEGATIVE_INFINITY===1/t}var _ee=l7,xee=gee,jee=yee,See=kee,Cee=wee,$ee=bee,Pr={isNothing:_ee,isObject:xee,toArray:jee,repeat:See,isNegativeZero:Cee,extend:$ee};function c7(t,e){var n="",r=t.reason||"(unknown reason)";return t.mark?(t.mark.name&&(n+='in "'+t.mark.name+'" '),n+="("+(t.mark.line+1)+":"+(t.mark.column+1)+")",!e&&t.mark.snippet&&(n+=`
181
181
 
@@ -208,7 +208,7 @@ This will fail in production.`);s=Z1,s._s.has(r)||(o?ib(r,e,i,s):W8(r,i,s),a._pi
208
208
  `+t.slice(i,o),i=o+1),a=s;return u+=`
209
209
  `,t.length-i>e&&a>i?u+=t.slice(i,a)+`
210
210
  `+t.slice(a+1):u+=t.slice(i),u.slice(1)}function pne(t){for(var e="",n=0,r,i=0;i<t.length;n>=65536?i+=2:i++)n=Rf(t,i),r=fi[n],!r&&Df(n)?(e+=t[i],n>=65536&&(e+=t[i+1])):e+=r||one(n);return e}function mne(t,e,n){var r="",i=t.tag,o,a,s;for(o=0,a=n.length;o<a;o+=1)s=n[o],t.replacer&&(s=t.replacer.call(n,String(o),s)),(ts(t,e,s,!1,!1)||typeof s>"u"&&ts(t,e,null,!1,!1))&&(r!==""&&(r+=","+(t.condenseFlow?"":" ")),r+=t.dump);t.tag=i,t.dump="["+r+"]"}function lL(t,e,n,r){var i="",o=t.tag,a,s,u;for(a=0,s=n.length;a<s;a+=1)u=n[a],t.replacer&&(u=t.replacer.call(n,String(a),u)),(ts(t,e+1,u,!0,!0,!1,!0)||typeof u>"u"&&ts(t,e+1,null,!0,!0,!1,!0))&&((!r||i!=="")&&(i+=wb(t,e)),t.dump&&If===t.dump.charCodeAt(0)?i+="-":i+="- ",i+=t.dump);t.tag=o,t.dump=i||"[]"}function vne(t,e,n){var r="",i=t.tag,o=Object.keys(n),a,s,u,l,f;for(a=0,s=o.length;a<s;a+=1)f="",r!==""&&(f+=", "),t.condenseFlow&&(f+='"'),u=o[a],l=n[u],t.replacer&&(l=t.replacer.call(n,u,l)),ts(t,e,u,!1,!1)&&(t.dump.length>1024&&(f+="? "),f+=t.dump+(t.condenseFlow?'"':"")+":"+(t.condenseFlow?"":" "),ts(t,e,l,!1,!1)&&(f+=t.dump,r+=f));t.tag=i,t.dump="{"+r+"}"}function gne(t,e,n,r){var i="",o=t.tag,a=Object.keys(n),s,u,l,f,c,d;if(t.sortKeys===!0)a.sort();else if(typeof t.sortKeys=="function")a.sort(t.sortKeys);else if(t.sortKeys)throw new Mi("sortKeys must be a boolean or a function");for(s=0,u=a.length;s<u;s+=1)d="",(!r||i!=="")&&(d+=wb(t,e)),l=a[s],f=n[l],t.replacer&&(f=t.replacer.call(n,l,f)),ts(t,e+1,l,!0,!0,!0)&&(c=t.tag!==null&&t.tag!=="?"||t.dump&&t.dump.length>1024,c&&(t.dump&&If===t.dump.charCodeAt(0)?d+="?":d+="? "),d+=t.dump,c&&(d+=wb(t,e)),ts(t,e+1,f,!0,c)&&(t.dump&&If===t.dump.charCodeAt(0)?d+=":":d+=": ",d+=t.dump,i+=d));t.tag=o,t.dump=i||"{}"}function cL(t,e,n){var r,i,o,a,s,u;for(i=n?t.explicitTypes:t.implicitTypes,o=0,a=i.length;o<a;o+=1)if(s=i[o],(s.instanceOf||s.predicate)&&(!s.instanceOf||typeof e=="object"&&e instanceof s.instanceOf)&&(!s.predicate||s.predicate(e))){if(n?s.multi&&s.representName?t.tag=s.representName(e):t.tag=s.tag:t.tag="?",s.represent){if(u=t.styleMap[s.tag]||s.defaultStyle,W7.call(s.represent)==="[object Function]")r=s.represent(e,u);else if(K7.call(s.represent,u))r=s.represent[u](e,u);else throw new Mi("!<"+s.tag+'> tag resolver accepts not "'+u+'" style');t.dump=r}return!0}return!1}function ts(t,e,n,r,i,o,a){t.tag=null,t.dump=n,cL(t,n,!1)||cL(t,n,!0);var s=W7.call(t.dump),u=r,l;r&&(r=t.flowLevel<0||t.flowLevel>e);var f=s==="[object Object]"||s==="[object Array]",c,d;if(f&&(c=t.duplicates.indexOf(n),d=c!==-1),(t.tag!==null&&t.tag!=="?"||d||t.indent!==2&&e>0)&&(i=!1),d&&t.usedDuplicates[c])t.dump="*ref_"+c;else{if(f&&d&&!t.usedDuplicates[c]&&(t.usedDuplicates[c]=!0),s==="[object Object]")r&&Object.keys(t.dump).length!==0?(gne(t,e,t.dump,i),d&&(t.dump="&ref_"+c+t.dump)):(vne(t,e,t.dump),d&&(t.dump="&ref_"+c+" "+t.dump));else if(s==="[object Array]")r&&t.dump.length!==0?(t.noArrayIndent&&!a&&e>0?lL(t,e-1,t.dump,i):lL(t,e,t.dump,i),d&&(t.dump="&ref_"+c+t.dump)):(mne(t,e,t.dump),d&&(t.dump="&ref_"+c+" "+t.dump));else if(s==="[object String]")t.tag!=="?"&&dne(t,t.dump,e,o,u);else{if(s==="[object Undefined]")return!1;if(t.skipInvalid)return!1;throw new Mi("unacceptable kind of an object to dump "+s)}t.tag!==null&&t.tag!=="?"&&(l=encodeURI(t.tag[0]==="!"?t.tag.slice(1):t.tag).replace(/!/g,"%21"),t.tag[0]==="!"?l="!"+l:l.slice(0,18)==="tag:yaml.org,2002:"?l="!!"+l.slice(18):l="!<"+l+">",t.dump=l+" "+t.dump)}return!0}function yne(t,e){var n=[],r=[],i,o;for(xb(t,n,r),i=0,o=r.length;i<o;i+=1)e.duplicates.push(n[r[i]]);e.usedDuplicates=new Array(o)}function xb(t,e,n){var r,i,o;if(t!==null&&typeof t=="object")if(i=e.indexOf(t),i!==-1)n.indexOf(i)===-1&&n.push(i);else if(e.push(t),Array.isArray(t))for(i=0,o=t.length;i<o;i+=1)xb(t[i],e,n);else for(r=Object.keys(t),i=0,o=r.length;i<o;i+=1)xb(t[r[i]],e,n)}function bne(t,e){e=e||{};var n=new sne(e);n.noRefs||yne(t,n);var r=t;return n.replacer&&(r=n.replacer.call({"":r},"",r)),ts(n,0,r,!0,!0)?n.dump+`
211
- `:""}var kne=bne,wne={dump:kne};function jb(t,e){return function(){throw new Error("Function yaml."+t+" is removed in js-yaml 4. Use yaml."+e+" instead, which is now safe by default.")}}var _ne=Qr,xne=d7,jne=v7,Sne=w7,Cne=_7,$ne=mb,One=U7.load,Ene=U7.loadAll,Tne=wne.dump,Ane=Mi,Mne={binary:$7,float:k7,map:m7,null:g7,pairs:E7,set:T7,timestamp:S7,bool:y7,int:b7,merge:C7,omap:O7,seq:p7,str:h7},Pne=jb("safeLoad","load"),Nne=jb("safeLoadAll","loadAll"),Ine=jb("safeDump","dump"),Lne={Type:_ne,Schema:xne,FAILSAFE_SCHEMA:jne,JSON_SCHEMA:Sne,CORE_SCHEMA:Cne,DEFAULT_SCHEMA:$ne,load:One,loadAll:Ene,dump:Tne,YAMLException:Ane,types:Mne,safeLoad:Pne,safeLoadAll:Nne,safeDump:Ine};function Sb(t){return new Promise((e,n)=>{const r=new XMLHttpRequest;r.onload=function(){r.status>=200&&r.status<300?e(r.responseText):(Kt(`Failed to load file ${t}`,r.status),n(r.status))},r.open("GET",t),r.send()})}async function vm(t){try{const e=await Sb(t);let n;if(t.endsWith(".json"))n=JSON.parse(e);else if(t.endsWith(".yaml"))n=Lne.load(e);else{const r=`Unsupported file type for data file ${t} (must be .json or .yaml)`;throw new Error(r)}if(!n)throw new Error(`Data loaded from ${t} is empty`);return n}catch(e){throw console.error(`Failed to load data file ${t}: ${e}`),e}}const Dne=(t,e)=>{const n={};for(const r in t)n[r]=e(t[r]);return n},fL=(t,e)=>{for(const n in t){const r=t[n];e(r,n,t),typeof r=="object"&&r!==null&&fL(r,e)}},dL=new Gm;dL.setupDebugger(!1);const xo=dL.logger;function Rne(t,e,n){const r={fileName:n,currentLine:0,error:(a,s)=>t(r,a,s),processCommandsFunction:Cb,indentSize:0};r.indentSize=Kne(r,e);const i=Hne(r,e);r.currentLine=0,xo.log(i);const o={};for(const a of i){a.code.search(":")===-1&&r.error(a.line,"First indentation level should only be used to specify labels");const u=a.code.replace(":","").split(/ +/g),l=u[0],f=u.slice(1);a.branch||r.error(a.line,"This line should have a branch but doesn't"),o[l]={branch:Cb(r,a.branch,void 0),args:f}}return o}function Cb(t,e,n){const r=t.currentLine,i={processCommandsFunction:Cb,parserContext:t,lines:e,currentLine:0,line:e[0]},o=[];if(!e){let a=0;return n&&(a=n.line),t.error(a,"Processing of command failed because the current branch has no lines inside"),[]}for(;i.currentLine<e.length;){const a=e[i.currentLine];i.line=a;const s=hL(t,a,a.expression),u=Fn.commands[s.command.operator];let l=u==null?void 0:u.parser;l||(l=Fn.commands.text.parser),xo.log(Fn.commands.text);const{newLine:f}=l(i,s);i.currentLine=f,t.currentLine=r+f,o.push(s)}return o}function hL(t,e,n){xo.log(n),typeof n[0]!="string"&&t.error(e.line,"Expression operator should be a string");const r={code:e.code,fileName:t.fileName,line:e.line,command:{staticOptions:{},commandType:n[0],operator:n[0],args:n.slice(1).map(a=>Bne(t,e,a)),options:{}}},i=n[0];if(!Fn.commands[i]){const a=["else","success","failure"];!uee(i)&&!a.includes(i)&&t.error(e.line,`Unknown command ${i}`)}return r}function Bne(t,e,n){return Array.isArray(n)?hL(t,e,n):n}function zne(t){return t==="true"?!0:t==="false"?!1:t==="undefined"?void 0:t===null?null:isNaN(Number(t))?t:Number(t)}function Fne(t,e){e.charAt(e.length-1)===":"&&(e=e.substr(0,e.length-1));const n=Vne(e),[r]=mL(t,n);return r}function Vne(t){const e=/(["'])(?:\\\1|.)*?\1/g,n=[];let r;for(;(r=e.exec(t))!=null;)n.push(r);let i=0,o=[];for(const a of n){const s=a.index;if(s>i){const l=t.substr(i,s-i),f=pL(l);o=[...o,...f]}const u=a[0].replace(/\\/g,"");o.push(`$$"${u.substring(1,u.length-1)}`),i=s+a[0].length}return o=[...o,...pL(t.substr(i))],o.push(")"),o}function pL(t){t=t.replace(/: *$/g,"");let e=t.split(" ").filter(n=>n);return e=e.reduce((n,r)=>[...n,...r.split(/(\(|\))/g)].filter(i=>i&&i),[]),e.map(n=>zne(n))}function mL(t,e){xo.log("===============");let n=[],r=0,i=vL(e)+r,o=$b(e)+r;for(xo.log(`Parsing expression: ${e}`),xo.log(`Parenthesis start index: ${i} - end: ${o}`);i!==-1&&o>i;){n=[...n,...e.slice(r,i)];const u=e.slice(i+1);xo.log(`Found a sub expression. Before: ${n} - After: ${u}`),r=i;const[l,f]=mL(t,u),c=r+f;n.push(l),r=c+1;const d=e.slice(r);xo.log(`Sub expression came back: ${l} - rest of string: ${d}`),i=vL(d),i!==-1&&(i+=r),o=$b(d),o!==-1&&(o+=r)}o!==-1&&xo.log("Found parenthesis end before new opening parenthesis, close this expression");const a=$b(e.slice(r))+r;if(a===-1)return t.error(t.currentLine,'Expression is not closed (missing ")" closing parenthesis)'),[n,a];const s=e.slice(r,a);return xo.log(`End of expression: ${a} - ${s}`),xo.log("==================="),n=[...n,...s],qne(t,n),[n,a+1]}function qne(t,e){e.length<1&&t.error(t.currentLine,"Expression is empty")}function vL(t){return t.findIndex(e=>e==="(")}function $b(t){return t.findIndex(e=>e===")")}function Hne(t,e){const n=e.split(/\r?\n|$/).map(i=>{const o=i.search(/ *\/\//g);return o!==-1?i.substr(0,o):i});return gL(t,n,0,0).lines}function gL(t,e,n,r){let i=!0,o=n;const a=[];for(;i&&!(o>=e.length);){let s=e[o];if(s.search(/^\s*$/)!==-1)o++;else{const u=Wne(t,s);if(s=s.substring(u*t.indentSize),Une(t,u,o),u<r)i=!1;else if(u>r){(a.length===0||u-r!==1)&&t.error(o,"Wrong double indentation");const l=gL(t,e,o,u);a[a.length-1].branch=l.lines,o=l.endLine}else{const l=Fne(t,s),f={code:s,indentation:u,line:o,expression:l};a.push(f),o++,t.currentLine=o}}}return{lines:a,endLine:o}}function Une(t,e,n){e%1!==0&&t.error(n,`Indentation level of ${e} incorrect. Expected indentation of ${t.indentSize} spaces for this file.`)}function Wne(t,e){return e.search(/[^ ]/)/t.indentSize}function Kne(t,e){const n=/\n( *)/,r=e.match(n);return!r||r.length<2?(t.error(0,"Can't detect indentation level. Make sure you indent with at least 2 spaces and consistently"),0):(xo.log(r),r[1].length)}function yL(t){if(!Gt().inScript)return!0;const e=$k().clickableDuringScriptsByDefault;if(e)return t.scriptClickable!==!1;if(!e)return t.scriptClickable===!0}const Jne=["screenObject","sprite"];function bL(t){return typeof t=="object"&&t!==null&&Jne.includes(t._entityType)}function Gne(t){return typeof t=="object"&&t!==null&&t._entityType==="sprite"}function Qne(t){if(t.includes(" ")){const e=t.split(" ");return{label:e[0],args:e.slice(1)}}else return{label:t}}const io=Jr("screenObjects",{state:()=>({tree:[],objectsList:{}}),actions:{addObject(t){t.parent?t.parent.children.push(t):this.tree.push(t),this.objectsList[t.id]=t},createObject(t){const e={_entityType:"screenObject",id:ql(),name:"Screen Object",tags:[],x:0,y:0,anchor:{x:0,y:0},width:1,height:1,opacity:1,scale:1,layer:0,children:[],...t};return this.addObject(e),e},destroyObject(t){let e=t;typeof e=="string"&&(e=this.getObject(e));for(const n of e.children)this.destroyObject(n);if(e.parent){const n=e.parent,r=n.children.indexOf(e);r!==-1?n.children.splice(r,1):Au(`Could not find object ${e.id} in parent's children`)}else{const n=this.tree.indexOf(e);n!==-1?this.tree.splice(n,1):Au(`Object to destroy not found in store (${e.id})`)}delete this.objectsList[e.id]},createSprite(t){const e=this.createObject(t);return e._entityType="sprite",UZ(t.image).then(n=>{const r=this.getObject(e.id);r.width===1&&r.height===1&&(r.width=n.width,r.height=n.height)}),e},getObject(t){return this.objectsList[t]},clickObject(t){var e,n,r;if(!!yL(t)&&t.onClick){console.log("click",Date.now()),Eu("onSpriteClicked");let i;if(typeof t.onClick=="string"){const o=Qne(t.onClick);i={label:o.label,args:o.args}}else i=t.onClick;i.method=(n=(e=i.method)!=null?e:t.clickMethod)!=null?n:"jump",i.args=(r=i.args)!=null?r:[],i.method==="run"?wn().runThenGoBackToPreviousDialog(i.label,...i.args):i.method==="jump"?wn().jumpToLabel(i.label,...i.args):Kt(`Unknown sprite click method ${t.clickMethod}`)}},generateSaveData(){return{tree:pi(this.tree.map(t=>t.id)),objectsList:pi(Dne(this.objectsList,t=>this.screenObjectToSave(t)))}},loadSaveData(t){this.objectsList=this.loadAllObjects(t.objectsList),this.tree=t.tree.map(e=>this.objectsList[e])},reset(){this.tree=[],this.objectsList={}},screenObjectToSave(t){return{...t,children:t.children.map(e=>e.id),parent:t.parent?t.parent.id:void 0}},loadAllObjects(t){for(const e of Object.values(t)){const n=e;n.parent=n.parent?t[n.parent]:void 0,n.children=n.children.map(r=>t[r])}return t}}}),wn=Jr("vm",{state:()=>({stack:[],data:{},lastLabel:"main",script:{},labelStack:["main"],commandsWaitingForPlayerAnswer:[],hasJumped:!1}),actions:{generateSaveData(){return{lastLabel:this.lastLabel,data:Ak(this.data,t=>{if(bL(t))return{_entityType:t._entityType,id:t.id}})}},loadSaveData(t){this.lastLabel=t.lastLabel,this.data=t.data,this.findEntitiesInData(this.data)},findEntitiesInData(t){fL(this.data,(e,n,r)=>{if(bL(e)){const i=io().getObject(e.id);i?r[n]=i:Au(`Trying to reload sprite ${n} (${JSON.stringify(e)} - ${e.id}) but it does not exist.`)}})},setReturnValue(t){this.currentFrame.returnValue=t},waitForPlayerAnswer(t){this.commandsWaitingForPlayerAnswer.push(t)},popAnswerQueue(){return this.commandsWaitingForPlayerAnswer.pop()},addScopedVariable(t,e){this.currentFrame&&(this.currentFrame.scope[t]=e)},async loadScripts(t){const e=[];for(const a of t)e.push(Sb(Tk(a)));const n=await Promise.all(e),r=Date.now();let i={};for(const a in n){const s=n[a];i={...i,...Rne((u,l,f)=>vre(u,l,f),s,t[a])}}const o=Date.now();Zo.log(`script parsed in ${o-r} ms`),this.setScript(i)},start(){this.setStack({currentIndex:0,branchData:{branch:this.script.main.branch},label:"main"}),this.setStack({currentIndex:0,branchData:{branch:this.script.main.branch},label:"main"})},setLastLabel(t){this.lastLabel=t},reset(){this.stack=[],this.data={},this.hasJumped=!0,this.setStack({currentIndex:0,branchData:{branch:this.script.main.branch},label:"main"})},setScript(t){this.script=t},overrideData(t){this.data=t},setStack(t){this.stack=[];const e=this.frameOptionsToFrame(t);this.lastLabel=t.label,this.stack.push(e)},frameOptionsToFrame(t){const e=t.branchData,n={...t,blocks:[],scope:{},returnValue:null};if(this.addBlock(n,{branchData:e,currentIndex:t.currentIndex}),t.scope&&(n.scope=t.scope),t.args&&t.branchData.args)for(const[r,i]of t.branchData.args.entries())t.args.length>r&&(n.scope[i]=t.args[r]);return n},addBlock(t,e){t.blocks.push(e)},async addAndRunBlock(t){const e=this.currentFrame;if(!e)throw new Error("No frame to add block to");return this.addBlock(e,t),await this.runBlock()},setData(t,e){const n=ic();eR(n,t,e)},addInstruction(t,e){const n=ic();tR(n,t,e)},addFrame(t){if(!t.label)if(this.currentFrame)t.label=this.currentFrame.label;else throw new Error("Tried to add a new frame but no label was passed and there is no current frame label");const e=this.frameOptionsToFrame(t);this.stack.push(e)},async addAndRunFrame(t){return await this.addFrame(t),await this.runFrame()},async runFrame(){if(!this.currentFrame)throw new Error("Tried to run a frame but there is no current frame");let e;for(;this.currentBlock;){const n=await this.runBlock();if(n===am||n===sm)return this.cleanFrame(),n;if(n===ab)return this.cleanFrame()}return this.cleanFrame(),e},cleanFrame(){const t=this.currentFrame,{returnValue:e}=t;return this.stack.splice(this.stack.length-1,1),e},async runBlock(){const t=this.currentBlock;if(!t)throw new Error("Tried to run a block but there is no current block");let e;for(;this.currentLine;){if(e=await this.runLineOnly(),JZ(e))return this.cleanBlock(),e;t.currentIndex++}return this.cleanBlock(),e},cleanBlock(){if(!this.currentFrame){Kt("Tried to clean a block but there is no current frame");return}if(!this.currentFrame.blocks){Kt("Tried to clean a block but there is no current block");return}this.currentFrame.blocks.splice(this.currentFrame.blocks.length-1,1)},async runGame(){let t=await this.runFrame();for(;t===am;){const e=this.jumpTarget;if(!e){Kt("Tried to jump but no target was set");return}this.hasJumped=!0,this.setStack(e),await Gt().autoSaveGame({}),t=await this.runFrame()}t!==sm&&this.stack.length===0&&this.reachedEndOfScript()},async nextLineOnly(){return this.stack.length===0||this.isBlockFinished()?!1:(this.currentBlock.currentIndex++,!0)},isBlockFinished(){return!this.currentBlock||this.currentBlock&&this.currentBlock.currentIndex>=this.currentBlock.branchData.branch.length},reachedEndOfScript(){if(gt().gameFlow.labelToJumpOnScriptEnd&&this.lastLabel!==gt().gameFlow.labelToJumpOnScriptEnd){this.jumpToLabel(gt().gameFlow.labelToJumpOnScriptEnd);return}Gt().endingScript(),Gt().options.debug&&(zn(),gt().debugging.showScriptFinishedMessage)},async runLineOnly(){const t=this.currentLine;if(!t){Kt("There is no line of script to run.");return}return Gt().startingScript(),await kL(t)},async runLabelFunction(t,...e){const n=this.script[t];if(!n){Kt(`Tried to run a label that doesn't exist: ${t}`);return}const r={currentIndex:0,branchData:n,label:t,args:e};return this.addAndRunFrame(r)},runCustomFrame(t){this.addAndRunFrame(t)},async jumpToLabel(t,...e){const n=this.script[t];if(!n){Kt(`Label ${t} doesn't exist. Is the file with this label added in the list of script files to load in the config?`);return}t!==this.lastLabel&&(this.hasJumped=!0),this.setLastLabel(t),this.setStack({currentIndex:0,branchData:n,args:e,label:t}),this.runGame()},async runThenGoBackToPreviousDialog(t,...e){const n=zn(),r=n.dialog[n.dialog.length-1],i=Gt().inScript,o=await this.runLabelFunction(t,...e);return i?n.dialog.push(r):Gt().endingScript(),o}},getters:{currentFrame(t){return t.stack[t.stack.length-1]},scope(){var t,e;return(e=(t=this.currentFrame)==null?void 0:t.scope)!=null?e:{}},currentBlock(){const t=this.currentFrame;return t?t.blocks[t.blocks.length-1]:void 0},currentLine(){const t=this.currentBlock;if(t&&t.branchData.branch.length>t.currentIndex)return t.branchData.branch[t.currentIndex]},commandWaitingForAnswer(){if(this.commandsWaitingForPlayerAnswer.length>0)return this.commandsWaitingForPlayerAnswer[0]}}});class Yne{constructor(){ei(this,"plugins",[]);ei(this,"pinia");ei(this,"commands",{})}addCommand(e){this.commands[e.keyword]=e}addPlugin(e){if(this.plugins.push(e),e.customCommands)for(const n of e.customCommands)this.addCommand(n)}callHook(e,...n){for(const r of this.plugins)typeof r[e]=="function"&&r[e](...n)}customStores(){const e=[];for(const n of this.plugins)if(n.customStores)for(const r in n.customStores)e.push([r,n.customStores[r](this.pinia)]);return e}}const Fn=new Yne;async function kL(t,e){var r;const n=wn();try{return await Ob(t,e)}catch(i){console.error(i),console.error(t),Kt(`Narrat script runtime error at <span class="error-filename">${t.fileName}:${t.line+1}</span>
211
+ `:""}var kne=bne,wne={dump:kne};function jb(t,e){return function(){throw new Error("Function yaml."+t+" is removed in js-yaml 4. Use yaml."+e+" instead, which is now safe by default.")}}var _ne=Qr,xne=d7,jne=v7,Sne=w7,Cne=_7,$ne=mb,One=U7.load,Ene=U7.loadAll,Tne=wne.dump,Ane=Mi,Mne={binary:$7,float:k7,map:m7,null:g7,pairs:E7,set:T7,timestamp:S7,bool:y7,int:b7,merge:C7,omap:O7,seq:p7,str:h7},Pne=jb("safeLoad","load"),Nne=jb("safeLoadAll","loadAll"),Ine=jb("safeDump","dump"),Lne={Type:_ne,Schema:xne,FAILSAFE_SCHEMA:jne,JSON_SCHEMA:Sne,CORE_SCHEMA:Cne,DEFAULT_SCHEMA:$ne,load:One,loadAll:Ene,dump:Tne,YAMLException:Ane,types:Mne,safeLoad:Pne,safeLoadAll:Nne,safeDump:Ine};function Sb(t){return new Promise((e,n)=>{const r=new XMLHttpRequest;r.onload=function(){r.status>=200&&r.status<300?e(r.responseText):(Kt(`Failed to load file ${t}`,r.status),n(r.status))},r.open("GET",t),r.send()})}async function vm(t){try{const e=await Sb(t);let n;if(t.endsWith(".json"))n=JSON.parse(e);else if(t.endsWith(".yaml"))n=Lne.load(e);else{const r=`Unsupported file type for data file ${t} (must be .json or .yaml)`;throw new Error(r)}if(!n)throw new Error(`Data loaded from ${t} is empty`);return n}catch(e){throw console.error(`Failed to load data file ${t}: ${e}`),e}}const Dne=(t,e)=>{const n={};for(const r in t)n[r]=e(t[r]);return n},fL=(t,e)=>{for(const n in t){const r=t[n];e(r,n,t),typeof r=="object"&&r!==null&&fL(r,e)}},dL=new Gm;dL.setupDebugger(!1);const xo=dL.logger;function Rne(t,e,n){const r={fileName:n,currentLine:0,error:(a,s)=>t(r,a,s),processCommandsFunction:Cb,indentSize:0};r.indentSize=Kne(r,e);const i=Hne(r,e);r.currentLine=0,xo.log(i);const o={};for(const a of i){a.code.search(":")===-1&&r.error(a.line,"First indentation level should only be used to specify labels");const u=a.code.replace(":","").split(/ +/g),l=u[0],f=u.slice(1);a.branch||r.error(a.line,"This line should have a branch but doesn't"),o[l]={branch:Cb(r,a.branch,void 0),args:f}}return o}function Cb(t,e,n){const r=t.currentLine,i={processCommandsFunction:Cb,parserContext:t,lines:e,currentLine:0,line:e[0]},o=[];if(!e){let a=0;return n&&(a=n.line),t.error(a,"Processing of command failed because the current branch has no lines inside"),[]}for(;i.currentLine<e.length;){const a=e[i.currentLine];i.line=a;const s=hL(t,a,a.expression),u=Fn.commands[s.command.operator];let l=u==null?void 0:u.parser;l||(l=Fn.commands.text.parser),xo.log(Fn.commands.text);const{newLine:f}=l(i,s);i.currentLine=f,t.currentLine=r+f,o.push(s)}return o}function hL(t,e,n){xo.log(n),typeof n[0]!="string"&&t.error(e.line,"Expression operator should be a string");const r={code:e.code,fileName:t.fileName,line:e.line,command:{staticOptions:{},commandType:n[0],operator:n[0],args:n.slice(1).map(a=>Bne(t,e,a)),options:{}}},i=n[0];if(!Fn.commands[i]){const a=["else","success","failure"];!uee(i)&&!a.includes(i)&&t.error(e.line,`Unknown command ${i}`)}return r}function Bne(t,e,n){return Array.isArray(n)?hL(t,e,n):n}function zne(t){return t==="true"?!0:t==="false"?!1:t==="undefined"?void 0:t===null?null:isNaN(Number(t))?t:Number(t)}function Fne(t,e){e.charAt(e.length-1)===":"&&(e=e.substr(0,e.length-1));const n=Vne(e),[r]=mL(t,n);return r}function Vne(t){const e=/(["'])(?:\\\1|.)*?\1/g,n=[];let r;for(;(r=e.exec(t))!=null;)n.push(r);let i=0,o=[];for(const a of n){const s=a.index;if(s>i){const l=t.substr(i,s-i),f=pL(l);o=[...o,...f]}const u=a[0].replace(/\\/g,"");o.push(`$$"${u.substring(1,u.length-1)}`),i=s+a[0].length}return o=[...o,...pL(t.substr(i))],o.push(")"),o}function pL(t){t=t.replace(/: *$/g,"");let e=t.split(" ").filter(n=>n);return e=e.reduce((n,r)=>[...n,...r.split(/(\(|\))/g)].filter(i=>i&&i),[]),e.map(n=>zne(n))}function mL(t,e){xo.log("===============");let n=[],r=0,i=vL(e)+r,o=$b(e)+r;for(xo.log(`Parsing expression: ${e}`),xo.log(`Parenthesis start index: ${i} - end: ${o}`);i!==-1&&o>i;){n=[...n,...e.slice(r,i)];const u=e.slice(i+1);xo.log(`Found a sub expression. Before: ${n} - After: ${u}`),r=i;const[l,f]=mL(t,u),c=r+f;n.push(l),r=c+1;const d=e.slice(r);xo.log(`Sub expression came back: ${l} - rest of string: ${d}`),i=vL(d),i!==-1&&(i+=r),o=$b(d),o!==-1&&(o+=r)}o!==-1&&xo.log("Found parenthesis end before new opening parenthesis, close this expression");const a=$b(e.slice(r))+r;if(a===-1)return t.error(t.currentLine,'Expression is not closed (missing ")" closing parenthesis)'),[n,a];const s=e.slice(r,a);return xo.log(`End of expression: ${a} - ${s}`),xo.log("==================="),n=[...n,...s],qne(t,n),[n,a+1]}function qne(t,e){e.length<1&&t.error(t.currentLine,"Expression is empty")}function vL(t){return t.findIndex(e=>e==="(")}function $b(t){return t.findIndex(e=>e===")")}function Hne(t,e){const n=e.split(/\r?\n|$/).map(i=>{const o=i.search(/ *\/\//g);return o!==-1?i.substr(0,o):i});return gL(t,n,0,0).lines}function gL(t,e,n,r){let i=!0,o=n;const a=[];for(;i&&!(o>=e.length);){let s=e[o];if(s.search(/^\s*$/)!==-1)o++;else{const u=Wne(t,s);if(s=s.substring(u*t.indentSize),Une(t,u,o),u<r)i=!1;else if(u>r){(a.length===0||u-r!==1)&&t.error(o,"Wrong double indentation");const l=gL(t,e,o,u);a[a.length-1].branch=l.lines,o=l.endLine}else{const l=Fne(t,s),f={code:s,indentation:u,line:o,expression:l};a.push(f),o++,t.currentLine=o}}}return{lines:a,endLine:o}}function Une(t,e,n){e%1!==0&&t.error(n,`Indentation level of ${e} incorrect. Expected indentation of ${t.indentSize} spaces for this file.`)}function Wne(t,e){return e.search(/[^ ]/)/t.indentSize}function Kne(t,e){const n=/\n( *)/,r=e.match(n);return!r||r.length<2?(t.error(0,"Can't detect indentation level. Make sure you indent with at least 2 spaces and consistently"),0):(xo.log(r),r[1].length)}function yL(t){if(!Gt().inScript)return!0;const e=$k().clickableDuringScriptsByDefault;if(e)return t.scriptClickable!==!1;if(!e)return t.scriptClickable===!0}const Jne=["screenObject","sprite"];function bL(t){return typeof t=="object"&&t!==null&&Jne.includes(t._entityType)}function Gne(t){return typeof t=="object"&&t!==null&&t._entityType==="sprite"}function Qne(t){if(t.includes(" ")){const e=t.split(" ");return{label:e[0],args:e.slice(1)}}else return{label:t}}const io=Jr("screenObjects",{state:()=>({tree:[],objectsList:{}}),actions:{addObject(t){t.parent?t.parent.children.push(t):this.tree.push(t),this.objectsList[t.id]=t},createObject(t){const e={_entityType:"screenObject",id:ql(),name:"Screen Object",tags:[],x:0,y:0,anchor:{x:0,y:0},width:1,height:1,opacity:1,scale:1,layer:0,children:[],...t};return this.addObject(e),e},destroyObject(t){let e=t;typeof e=="string"&&(e=this.getObject(e));for(const n of e.children)this.destroyObject(n);if(e.parent){const n=e.parent,r=n.children.indexOf(e);r!==-1?n.children.splice(r,1):Au(`Could not find object ${e.id} in parent's children`)}else{const n=this.tree.indexOf(e);n!==-1?this.tree.splice(n,1):Au(`Object to destroy not found in store (${e.id})`)}delete this.objectsList[e.id]},createSprite(t){const e=this.createObject(t);return e._entityType="sprite",UZ(t.image).then(n=>{const r=this.getObject(e.id);r.width===1&&r.height===1&&(r.width=n.width,r.height=n.height)}),e},getObject(t){return this.objectsList[t]},clickObject(t){var e,n,r;if(!!yL(t)&&t.onClick){console.log("click",Date.now()),Eu("onSpriteClicked");let i;if(typeof t.onClick=="string"){const o=Qne(t.onClick);i={label:o.label,args:o.args}}else i=t.onClick;i.method=(n=(e=i.method)!=null?e:t.clickMethod)!=null?n:"jump",i.args=(r=i.args)!=null?r:[],i.method==="run"?wn().runThenGoBackToPreviousDialog(i.label,...i.args):i.method==="jump"?wn().jumpToLabel(i.label,...i.args):Kt(`Unknown sprite click method ${t.clickMethod}`)}},generateSaveData(){return{tree:pi(this.tree.map(t=>t.id)),objectsList:pi(Dne(this.objectsList,t=>this.screenObjectToSave(t)))}},loadSaveData(t){this.objectsList=this.loadAllObjects(t.objectsList),this.tree=t.tree.map(e=>this.objectsList[e])},reset(){this.tree=[],this.objectsList={}},screenObjectToSave(t){return{...t,children:t.children.map(e=>e.id),parent:t.parent?t.parent.id:void 0}},loadAllObjects(t){for(const e of Object.values(t)){const n=e;n.parent=n.parent?t[n.parent]:void 0,n.children=n.children.map(r=>t[r])}return t}}}),wn=Jr("vm",{state:()=>({stack:[],data:{},lastLabel:"main",script:{},labelStack:["main"],commandsWaitingForPlayerAnswer:[],hasJumped:!1}),actions:{generateSaveData(){return{lastLabel:this.lastLabel,data:Ak(this.data,t=>bL(t)?{_entityType:t._entityType,id:t.id}:t)}},loadSaveData(t){this.lastLabel=t.lastLabel,this.data=t.data,this.findEntitiesInData(this.data)},findEntitiesInData(t){fL(this.data,(e,n,r)=>{if(bL(e)){const i=io().getObject(e.id);i?r[n]=i:Au(`Trying to reload sprite ${n} (${JSON.stringify(e)} - ${e.id}) but it does not exist.`)}})},setReturnValue(t){this.currentFrame.returnValue=t},waitForPlayerAnswer(t){this.commandsWaitingForPlayerAnswer.push(t)},popAnswerQueue(){return this.commandsWaitingForPlayerAnswer.pop()},addScopedVariable(t,e){this.currentFrame&&(this.currentFrame.scope[t]=e)},async loadScripts(t){const e=[];for(const a of t)e.push(Sb(Tk(a)));const n=await Promise.all(e),r=Date.now();let i={};for(const a in n){const s=n[a];i={...i,...Rne((u,l,f)=>vre(u,l,f),s,t[a])}}const o=Date.now();Zo.log(`script parsed in ${o-r} ms`),this.setScript(i)},start(){this.setStack({currentIndex:0,branchData:{branch:this.script.main.branch},label:"main"}),this.setStack({currentIndex:0,branchData:{branch:this.script.main.branch},label:"main"})},setLastLabel(t){this.lastLabel=t},reset(){this.stack=[],this.data={},this.hasJumped=!0,this.setStack({currentIndex:0,branchData:{branch:this.script.main.branch},label:"main"})},setScript(t){this.script=t},overrideData(t){this.data=t},setStack(t){this.stack=[];const e=this.frameOptionsToFrame(t);this.lastLabel=t.label,this.stack.push(e)},frameOptionsToFrame(t){const e=t.branchData,n={...t,blocks:[],scope:{},returnValue:null};if(this.addBlock(n,{branchData:e,currentIndex:t.currentIndex}),t.scope&&(n.scope=t.scope),t.args&&t.branchData.args)for(const[r,i]of t.branchData.args.entries())t.args.length>r&&(n.scope[i]=t.args[r]);return n},addBlock(t,e){t.blocks.push(e)},async addAndRunBlock(t){const e=this.currentFrame;if(!e)throw new Error("No frame to add block to");return this.addBlock(e,t),await this.runBlock()},setData(t,e){const n=ic();eR(n,t,e)},addInstruction(t,e){const n=ic();tR(n,t,e)},addFrame(t){if(!t.label)if(this.currentFrame)t.label=this.currentFrame.label;else throw new Error("Tried to add a new frame but no label was passed and there is no current frame label");const e=this.frameOptionsToFrame(t);this.stack.push(e)},async addAndRunFrame(t){return await this.addFrame(t),await this.runFrame()},async runFrame(){if(!this.currentFrame)throw new Error("Tried to run a frame but there is no current frame");let e;for(;this.currentBlock;){const n=await this.runBlock();if(n===am||n===sm)return this.cleanFrame(),n;if(n===ab)return this.cleanFrame()}return this.cleanFrame(),e},cleanFrame(){const t=this.currentFrame,{returnValue:e}=t;return this.stack.splice(this.stack.length-1,1),e},async runBlock(){const t=this.currentBlock;if(!t)throw new Error("Tried to run a block but there is no current block");let e;for(;this.currentLine;){if(e=await this.runLineOnly(),JZ(e))return this.cleanBlock(),e;t.currentIndex++}return this.cleanBlock(),e},cleanBlock(){if(!this.currentFrame){Kt("Tried to clean a block but there is no current frame");return}if(!this.currentFrame.blocks){Kt("Tried to clean a block but there is no current block");return}this.currentFrame.blocks.splice(this.currentFrame.blocks.length-1,1)},async runGame(){let t=await this.runFrame();for(;t===am;){const e=this.jumpTarget;if(!e){Kt("Tried to jump but no target was set");return}this.hasJumped=!0,this.setStack(e),await Gt().autoSaveGame({}),t=await this.runFrame()}t!==sm&&this.stack.length===0&&this.reachedEndOfScript()},async nextLineOnly(){return this.stack.length===0||this.isBlockFinished()?!1:(this.currentBlock.currentIndex++,!0)},isBlockFinished(){return!this.currentBlock||this.currentBlock&&this.currentBlock.currentIndex>=this.currentBlock.branchData.branch.length},reachedEndOfScript(){if(gt().gameFlow.labelToJumpOnScriptEnd&&this.lastLabel!==gt().gameFlow.labelToJumpOnScriptEnd){this.jumpToLabel(gt().gameFlow.labelToJumpOnScriptEnd);return}Gt().endingScript(),Gt().options.debug&&(zn(),gt().debugging.showScriptFinishedMessage)},async runLineOnly(){const t=this.currentLine;if(!t){Kt("There is no line of script to run.");return}return Gt().startingScript(),await kL(t)},async runLabelFunction(t,...e){const n=this.script[t];if(!n){Kt(`Tried to run a label that doesn't exist: ${t}`);return}const r={currentIndex:0,branchData:n,label:t,args:e};return this.addAndRunFrame(r)},runCustomFrame(t){this.addAndRunFrame(t)},async jumpToLabel(t,...e){const n=this.script[t];if(!n){Kt(`Label ${t} doesn't exist. Is the file with this label added in the list of script files to load in the config?`);return}t!==this.lastLabel&&(this.hasJumped=!0),this.setLastLabel(t),this.setStack({currentIndex:0,branchData:n,args:e,label:t}),this.runGame()},async runThenGoBackToPreviousDialog(t,...e){const n=zn(),r=n.dialog[n.dialog.length-1],i=Gt().inScript,o=await this.runLabelFunction(t,...e);return i?n.dialog.push(r):Gt().endingScript(),o}},getters:{currentFrame(t){return t.stack[t.stack.length-1]},scope(){var t,e;return(e=(t=this.currentFrame)==null?void 0:t.scope)!=null?e:{}},currentBlock(){const t=this.currentFrame;return t?t.blocks[t.blocks.length-1]:void 0},currentLine(){const t=this.currentBlock;if(t&&t.branchData.branch.length>t.currentIndex)return t.branchData.branch[t.currentIndex]},commandWaitingForAnswer(){if(this.commandsWaitingForPlayerAnswer.length>0)return this.commandsWaitingForPlayerAnswer[0]}}});class Yne{constructor(){ei(this,"plugins",[]);ei(this,"pinia");ei(this,"commands",{})}addCommand(e){this.commands[e.keyword]=e}addPlugin(e){if(this.plugins.push(e),e.customCommands)for(const n of e.customCommands)this.addCommand(n)}callHook(e,...n){for(const r of this.plugins)typeof r[e]=="function"&&r[e](...n)}customStores(){const e=[];for(const n of this.plugins)if(n.customStores)for(const r in n.customStores)e.push([r,n.customStores[r](this.pinia)]);return e}}const Fn=new Yne;async function kL(t,e){var r;const n=wn();try{return await Ob(t,e)}catch(i){console.error(i),console.error(t),Kt(`Narrat script runtime error at <span class="error-filename">${t.fileName}:${t.line+1}</span>
212
212
  <b>${i}</b>
213
213
  Script: ${t.code}
214
214
  Label: ${((r=n.currentFrame)==null?void 0:r.label)||"none"}`)}}async function Xne(t,e){const n=t.command,r=Fn.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(a7(s))u=await Ob(s,e);else if(typeof s=="string")if(s.search(r7)===0)u=es(s.substring(3));else if(s7(s)){const l=ic(),f=lse(l,s);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 Ob(t,e){const n=await Xne(t,e),r=Fn.commands[n.commandType];if(r)return await r.run(n,e);throw new Error(`${n.commandType} is not a valid command`)}async function Zne(t){Eu("onPlayerAnswered");const e=wn(),n=e.popAnswerQueue(),r=e.currentLine;try{if(n){const i=Fn.commands[n.commandType];if(i)return await i.processPlayerAnswer(n,t)}}catch(i){console.error(i),Kt(`Error after player answer at ${r.fileName}:${r.line+1} (${r.code}<br /> - Error: ${i}`)}}var ere=function(e){return tre(e)&&!nre(e)};function tre(t){return!!t&&typeof t=="object"}function nre(t){var e=Object.prototype.toString.call(t);return e==="[object RegExp]"||e==="[object Date]"||ore(t)}var rre=typeof Symbol=="function"&&Symbol.for,ire=rre?Symbol.for("react.element"):60103;function ore(t){return t.$$typeof===ire}function are(t){return Array.isArray(t)?[]:{}}function Bf(t,e){return e.clone!==!1&&e.isMergeableObject(t)?Gl(are(t),t,e):t}function sre(t,e,n){return t.concat(e).map(function(r){return Bf(r,n)})}function ure(t,e){if(!e.customMerge)return Gl;var n=e.customMerge(t);return typeof n=="function"?n:Gl}function lre(t){return Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(t).filter(function(e){return t.propertyIsEnumerable(e)}):[]}function wL(t){return Object.keys(t).concat(lre(t))}function _L(t,e){try{return e in t}catch{return!1}}function cre(t,e){return _L(t,e)&&!(Object.hasOwnProperty.call(t,e)&&Object.propertyIsEnumerable.call(t,e))}function fre(t,e,n){var r={};return n.isMergeableObject(t)&&wL(t).forEach(function(i){r[i]=Bf(t[i],n)}),wL(e).forEach(function(i){cre(t,i)||(_L(t,i)&&n.isMergeableObject(e[i])?r[i]=ure(i,n)(t[i],e[i],n):r[i]=Bf(e[i],n))}),r}function Gl(t,e,n){n=n||{},n.arrayMerge=n.arrayMerge||sre,n.isMergeableObject=n.isMergeableObject||ere,n.cloneUnlessOtherwiseSpecified=Bf;var r=Array.isArray(e),i=Array.isArray(t),o=r===i;return o?r?n.arrayMerge(t,e,n):fre(t,e,n):Bf(e,n)}Gl.all=function(e,n){if(!Array.isArray(e))throw new Error("first argument should be an array");return e.reduce(function(r,i){return Gl(r,i,n)},{})};var dre=Gl,gm=dre;const $a=Jr("hud",{state:()=>({hudStats:{}}),actions:{setupHudStats(t){for(const e in t)this.hudStats[e]={value:t[e].startingValue}},setStat(t,e){this.hudStats[t].value=e},addStat(t,e){this.hudStats[t].value+=e},getStat(t){return this.hudStats[t]},getStatValue(t){return this.hudStats[t].value},generateSaveData(){return{hudStats:pi(this.hudStats)}},loadSaveData(t){this.hudStats=gm(this.hudStats,t.hudStats)}}}),oo=Jr("notifications",{state:()=>({notifications:{},enabled:!0}),actions:{async addNotification(t){if(!this.enabled)return;t=es(t);const e=`${Date.now()}-${Math.random()*1e4}`;this.notifications[e]={text:t},gt().notifications.alsoPrintInDialogue&&u7(`[NOTIFICATION] ${t}`),await _o(gt().notifications.timeOnScreen*1e3),this.deleteNotification(e)},deleteNotification(t){delete this.notifications[t]},disableNotifications(){this.enabled=!1;for(const t in this.notifications)this.deleteNotification(t)},enableNotifications(){this.enabled=!0}}}),Nr=Jr("inventory",{state:()=>({items:{},interactionTags:{}}),actions:{generateSaveData(){return{items:pi(this.items),interactionTags:pi(this.interactionTags)}},loadSaveData(t){this.items={...this.items,...t.items},this.interactionTags={...t.interactionTags}},setupItems(t){Object.keys(t).forEach(e=>{this.items[e]={amount:0,id:e}})},hasItem(t,e){var n;return e||(e=1),((n=this.items[t])==null?void 0:n.amount)>=e},getExistingItem(t){return this.items[t]},getItemAmount(t){var e;return((e=this.getExistingItem(t))==null?void 0:e.amount)||0},add(t){const e=this.getExistingItem(t.id);e?e.amount+=t.amount:this.items[t.id]={...t},oo().addNotification(`Received item: ${is(t.id).name} x ${t.amount}`)},enableInteraction(t){t||(t="default"),this.interactionTags[t]={blockedInteraction:!1}},disableInteraction(t){t||(t="default"),this.interactionTags[t]={blockedInteraction:!0}},onScriptStart(){const t=gt().interactionTags;Object.keys(t).forEach(e=>{t[e].onlyInteractOutsideOfScripts&&this.disableInteraction(e)})},onScriptEnd(){const t=gt().interactionTags;Object.keys(t).forEach(e=>{t[e].onlyInteractOutsideOfScripts&&this.enableInteraction(e)})},isInteractionTagBlocked(t){return t||(t="default"),this.interactionTags[t]?this.interactionTags[t].blockedInteraction:!1},remove(t){const e=this.getExistingItem(t.id);e&&(e.amount-=t.amount,oo().addNotification(`Lost item: ${is(t.id).name} x ${t.amount}`),e.amount<=0&&this.deleteItem(t.id))},deleteItem(t){this.getExistingItem(t)&&(this.items[t].amount=0)},canUseItem(t){var n;const e=is(t.id);return!!(e&&e.onUse&&!this.isInteractionTagBlocked(e.tag)&&!((n=zn().currentDialog)!=null&&n.choices))}}}),di=Jr("quests",{state:()=>({quests:{}}),actions:{getQuest(t){const e=this.quests[t];if(e)return e;{const n=`Quest ${t} doesn't exist!`;throw Kt(n),new Error(n)}},getObjective(t,e){const n=this.getQuest(t);if(!n){const o=`Quest ${t} doesn't exist!`;throw Kt(o),new Error(o)}const r=n.objectives[e];if(r)return r;const i=`Objective ${e} doesn't exist in quest ${t}!`;throw Kt(i),new Error(i)},setupQuests(t){const e=t.quests;for(const n of Object.keys(e)){const r=e[n];this.quests[n]={id:n,state:"hidden",objectives:{}};for(const i of Object.keys(r.objectives)){const o=r.objectives[i];this.quests[n].objectives[i]={id:i,state:o.hidden?"hidden":"unlocked"}}}},startQuest(t){const e=this.getQuest(t);e?(e.state="unlocked",oo().addNotification(`Started quest: ${Bu(t).title}`)):Kt(`Quest ${t} doesn't exist!`)},startObjective(t,e){const n=this.getObjective(t,e);n?(n.state="unlocked",oo().addNotification(`New quest objective: ${Fm(t,e).description}`)):Kt(`Objective ${e} doesn't exist in quest ${t}!`)},completeObjective(t,e){const n=this.getObjective(t,e);n?(n.state="completed",oo().addNotification(`Completed quest objective: ${Fm(t,e).description}`)):Kt(`Objective ${e} doesn't exist in quest ${t}!`)},completeQuest(t,e){const n=this.getQuest(t);n?(n.state="completed",n.ending=e,oo().addNotification(`Completed quest: ${Bu(t).title}`)):Kt(`Quest ${t} doesn't exist!`)},isQuestCompleted(t){const e=this.getQuest(t);return e?e.state==="completed":!1},isObjectiveCompleted(t,e){const n=this.getObjective(t,e);return n?n.state==="completed":!1},isQuestStarted(t){const e=this.getQuest(t);return e&&e.state==="unlocked"},isObjectiveStarted(t,e){return this.getObjective(t,e).state==="unlocked"},removeQuest(t){delete this.quests[t]},generateSaveData(){return{quests:pi(this.quests)}},loadSaveData(t){this.quests=t.quests}}});function xL(t,e,n,r){const i=t/n,o=e/r;return Math.min(i,o)}const ao=Jr("rendering",{state:()=>({screenHeight:window.innerHeight,screenWidth:window.innerWidth,layoutMode:"horizontal"}),actions:{updateScreenSize(t,e){this.screenHeight=e,this.screenWidth=t,t<gt().layout.verticalLayoutThreshold?(this.layoutMode="vertical",document.querySelector("html").style.fontSize="40px"):(this.layoutMode="horizontal",document.querySelector("html").style.fontSize="16px")}},getters:{gameScaleRatio(t){return xL(this.screenWidth,this.screenHeight,this.gameWidth,this.gameHeight)},overlayMode(t){return!!(gt().dialogPanel.overlayMode&&t.layoutMode==="horizontal")},gameWidth(){const t=gt();return this.layoutMode==="vertical"||this.overlayMode?t.layout.backgrounds.width:t.layout.backgrounds.width+Vm()},gameHeight(){const t=gt();return this.layoutMode==="vertical",t.layout.backgrounds.height},dialogWidth(){return this.layoutMode==="vertical"?this.viewportWidth:Vm()},dialogHeight(){var t;return this.layoutMode==="vertical"?this.actualGameHeight-this.gameHeight:(t=gt().dialogPanel.height)!=null?t:this.gameHeight},actualGameHeight(){let t=this.gameHeight;return this.layoutMode==="vertical"&&(t=this.screenHeight/this.gameScaleRatio),t},viewportRatio(t){if(this.layoutMode==="vertical"){const e=gt().layout.backgrounds;return t.screenWidth/e.width}return 1},viewportHeight(t){return gt().layout.backgrounds.height*this.viewportRatio},viewportWidth(t){return gt().layout.backgrounds.width*this.viewportRatio},showDialog(t){const e=Gt().inScript;return!this.overlayMode||this.layoutMode==="vertical"?!0:e}}}),ym={};function hre(t){var e;return(e=ym[t])!=null?e:{}}function jL(t,e,n){var s,u,l,f;const r=hre(t.transition),i=(u=(s=t.duration)!=null?s:r.duration)!=null?u:500,o=(f=(l=t.delay)!=null?l:r.delay)!=null?f:0;return{...t,resolve:n,duration:i,delay:o,oldScreen:e}}const Uo=Jr("screens",{state:()=>({layers:[{screen:"default"}],buttons:{}}),actions:{setScreen(t,e,n){return new Promise(r=>{var s;const i=this.layers[e||0];let o;const a=(s=i==null?void 0:i.screen)!=null?s:null;if(a===t){r();return}n&&(o=jL(n,a,r)),this.layers[e||0]={screen:t,transition:o},o||r()})},finishTransition(t){const e=this.layers[t];if(!e)Kt(`Tried to finish transition on layer ${t} but it doesn't exist`);else if(e.transition){const n=e.transition.resolve;delete e.transition,n()}},transitionScreen(t,e,n){return this.setScreen(t,n!=null?n:0,e)},emptyLayer(t,e){return new Promise(n=>{const r=this.layers[t];if(!r){Au(`Tried to empty layer ${t} but it doesn't exist`);return}if(e){const i=r.screen,o=jL(e,i,n);r.transition=o}r.screen=null,e||n()})},setButtons(t){const e=t.screens.screens,n=t.buttons.buttons;for(const r in n)this.buttons[r]={state:n[r].enabled};for(const r in e){const i=e[r];if(i.buttons)for(const[o,a]of i.buttons.entries())typeof a=="object"&&(n[a.id]=a,i.buttons[o]=a.id,this.buttons[a.id]={state:a.enabled})}},changeButton(t,e){if(!this.buttons[t]){Kt(`Tried to change button ${t} but it doesn't exist`);return}this.buttons[t].state=e},generateSaveData(){return{layers:pi(this.layers).filter(t=>t).map(t=>{var e;return(e=t.screen)!=null?e:null}),buttons:pi(this.buttons)}},loadSaveData(t){this.layers=t.layers.map(e=>(e!==null&&typeof e!="string"&&(e=null),{screen:e})),this.buttons=gm(this.buttons,t.buttons)}},getters:{nonEmptyLayers(t){return t.layers.filter(e=>e)}}});class Eb{constructor(){ei(this,"listeners",{})}on(e,n){return this.listeners[e]||this.addEventToMap(e),this.listeners[e].add(n),n}off(e,n){return this.listeners[e]&&this.listeners[e].delete(n),n}once(e,n){const r=(...i)=>{this.off(e,r),n(...i)};return this.on(e,r)}emit(e,...n){this.listeners[e]&&this.listeners[e].forEach(r=>r(...n))}clear(){Object.keys(this.listeners).forEach(e=>{delete this.listeners[e]})}addEventToMap(e){this.listeners[e]=new Set}}const jo=Jr("menu",{state:()=>({menus:{},activeMenu:!1}),getters:{showSkills(){return Object.entries(Co().skills).length>0},showInventory(){return Object.entries(Bm().items).length>0},showQuests(){return Object.entries(Zf().quests).length>0},menuTabsToShow(t){return t.menus.menu.tabs.map(e=>{const n=gt().menuButtons[e.id]||{};return{...e,...n}}).filter(e=>e.condition?e.condition():!0)},menu(t){return t.activeMenu?t.menus[t.activeMenu]:void 0},tab(){if(this.menu)return this.menu.tabs[this.menu.activeTab]}},actions:{setup(){},addMenu(t,e){this.menus[t]={...e,id:t}},addMenuOption(t,e){this.menus[t]||(this.menus[t]={id:t,label:t,tabs:[],activeTab:0}),this.menus[t].tabs.push(e)},setActiveTab(t){this.menu&&(this.menu.activeTab=t)},openMenu(t){this.activeMenu=t},closeMenu(){this.activeMenu=!1},toggleMenu(){this.activeMenu?this.activeMenu=!1:this.activeMenu="menu"}}});function pre(){return{baseAssetsPath:"",baseDataPath:"",configPath:"data/config.json",logging:!1,debug:!1}}class mre extends Eb{}const Gt=Jr("main",{state:()=>({ready:!1,playing:!1,errors:[],playTime:{start:0,previousPlaytime:0},saveSlot:"",flowState:"engine-splash",paused:!1,debugMode:!0,options:{baseAssetsPath:"",baseDataPath:"",configPath:"data/config.json",logging:!1,debug:!1},loading:{step:"Loading",percentage:.1,loaded:!1},alerts:[],saving:null,listener:new mre,inScript:!1}),actions:{async setup(){var n;const e=gt().scripts;Gr().setMasterVolume((n=Aa().options.volume)!=null?n:1),await wn().loadScripts(e),jo().setup();for(const[,r]of Fn.customStores())if(r.setup){const i=r.setup();hZ(i)&&await i}this.resetAllStores()},async engineLoading(){const t=WZ(gt()),e=VZ(Aa());if(Fn.plugins){const n=[];for(const r of Fn.plugins)r.loadingPromises&&n.push(Promise.all(r.loadingPromises));n.length>0&&(this.loading.step="Plugins",this.loading.percentage=.3,await Promise.all(n))}this.loading.step="Images",await t,this.loading.percentage=.7,this.loading.step="Audio",await e,Fn.callHook("onAssetsLoaded"),this.loading.percentage=.95,this.loading.step="Starting...",await this.setup(),Fn.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:ql()})})},closeAlert(t){const e=this.alerts.findIndex(n=>n.id===t);e!==-1&&(this.alerts[e].resolver(),this.alerts.splice(e,1))},startingScript(){Nr().onScriptStart(),this.inScript=!0},endingScript(){Nr().onScriptEnd(),this.inScript=!1},startMachine(){Gr().stopAll(),Eu("onPressStart"),wn().start(),this.ready=!0,this.startPlaying(),Fn.callHook("onGameStart"),this.setFlowState("playing")},setSaveSlot(t){this.saveSlot=t,eee(t)},async startGame(t){if(gt().saves.mode==="manual"){const e=ub();e&&(t=e.id)}this.setSaveSlot(t),this.startMachine(),wn().runGame()},async loadGame(t,e){if(gt().saves.mode==="manual"){const n=ub();n&&(e=n.id)}this.setSaveSlot(e),this.startMachine(),t.saveData&&(this.setLoadedData(t.saveData),Gr().reloadAudio(t.saveData.audio),wn().jumpToLabel(t.saveData.vm.lastLabel))},manualSave({saveName:t,withPrompt:e}){return new Promise(n=>{wn().hasJumped?this.saving={name:t,withPrompt:e,resolver:n}:n()})},finishManualSave(t,e){var n,r;if(!this.saving){Kt("Trying to save but there is no saving request!");return}if(!e||!t){this.saving.resolver(),this.saving=null;return}this.saveData?(t7({...this.saveData,main:{...this.saveData.main,playTime:Fu(this.playTime.start,this.playTime.previousPlaytime)},metadata:{...this.saveData.metadata,name:(r=(n=this.saving)==null?void 0:n.name)!=null?r:"Manual Save",saveDate:new Date().toISOString()}},t.slotId),this.alert("Success","Game saved!")):Kt("There was no data to save!"),this.saving.resolver(),this.saving=null},playerAnswered(t){Zne(t)},menuReturn(){this.reset(),this.setFlowState("menu"),Aa().options.defaultMusic&&Gr().playChannel("music",Aa().options.defaultMusic,0)},createError(t){this.errors.push({text:t,type:"error"})},createWarning(t){this.errors.push({text:t,type:"warning"})},clearErrors(){this.errors=[]},setFlowState(t){this.flowState=t},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.paused=!1,wn().reset(),Gr().reset(),this.resetAllStores(),this.playing=!1,this.ready=!0,Fn.plugins.forEach(t=>{t.reset&&t.reset()})},resetAllStores(){const t=Uo(),e=gt();io().reset(),t.setButtons(e),_r().setupSkills(Co()),$a().setupHudStats(e.hudStats),Nr().setupItems(Bm().items),di().setupQuests(Zf()),zn().reset(),Fn.customStores().forEach(([a,s])=>{s.reset&&s.reset()})},generateSaveData(){return{playTime:Fu(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=Pf(n),i=oee();r&&r.saveData?i.name=r.saveData.metadata.name:i.name=e!=null?e:"Auto Save",gt().saves.mode==="manual"&&(i.name="Auto Save");const o=Uo(),a=_r(),s=zn(),u=wn(),l=Gt(),f=$a(),c=Gr(),d=Nr(),h={version:X8,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:di().generateSaveData(),metadata:i,screenObjects:io().generateSaveData()};Fn.plugins.forEach(p=>{p.save&&(h[p.pluginId]=p.save())}),Fn.customStores().forEach(([p,m])=>{if(m.save){const g=m.save();g&&(h[p]=g)}}),this.saveData=h,t7(h,this.saveSlot)},setLoadedData(t){const e=Uo(),n=_r(),r=zn(),i=wn(),o=Gt(),a=$a(),s=Gr(),u=Nr();io().loadSaveData(t.screenObjects),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),di().loadSaveData(t.quests),Fn.plugins.forEach(l=>{l.load&&t[l.pluginId]&&l.load(t[l.pluginId])}),Fn.customStores().forEach(([l,f])=>{f.load&&f.load(t[l])})},getAllStates(){return{main:this,screens:Uo(),skills:_r(),dialog:zn(),vm:wn(),hud:$a(),audio:Gr(),rendering:ao(),notifications:oo(),inventory:Nr(),quests:di(),sprites:io()}},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"},totalPlayTime(t){return Fu(t.playTime.start,t.playTime.previousPlaytime)},sessionPlayTime(t){return Fu(t.playTime.start,0)}}});function vre(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>`;Kt(r)}function Kt(t,...e){const n=Gt();console.error(t,...e),t=t.replace(/[\r\n]/g,`