@drincs/pixi-vn 1.8.25 → 1.9.0

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 (53) hide show
  1. package/README.md +23 -1
  2. package/dist/{ContainerMemory-D2HtgX7w.d.cts → ContainerMemory-BpDgacyr.d.cts} +2 -15
  3. package/dist/{ContainerMemory-D2HtgX7w.d.ts → ContainerMemory-BpDgacyr.d.ts} +2 -15
  4. package/dist/{HistoryChoiceMenuOption-DVMD78W7.d.cts → HistoryChoiceMenuOption-BxMSXnyI.d.cts} +1 -1
  5. package/dist/{HistoryChoiceMenuOption-B8RfQz5H.d.ts → HistoryChoiceMenuOption-hSI4SHV-.d.ts} +1 -1
  6. package/dist/{HistoryGameState-CmjUtlkV.d.ts → HistoryGameState-C8ATx9K6.d.ts} +1 -1
  7. package/dist/{HistoryGameState-C28NcKKl.d.cts → HistoryGameState-CGfvq5iL.d.cts} +1 -1
  8. package/dist/{HistoryStep-G9dUn0Lf.d.cts → HistoryStep-WGB6nA4N.d.cts} +5 -0
  9. package/dist/{HistoryStep-G9dUn0Lf.d.ts → HistoryStep-WGB6nA4N.d.ts} +5 -0
  10. package/dist/{OpenedLabel-DLfFuZgk.d.ts → OpenedLabel-CmRdzTXP.d.ts} +1 -1
  11. package/dist/{OpenedLabel-BxfL31aQ.d.cts → OpenedLabel-Cmd675NI.d.cts} +1 -1
  12. package/dist/SoundGameState-C_6ZsQX6.d.cts +186 -0
  13. package/dist/SoundGameState-C_6ZsQX6.d.ts +186 -0
  14. package/dist/{StorageGameState-CtjNJpvE.d.cts → StorageGameState-C3PGrFPr.d.cts} +2 -2
  15. package/dist/{StorageGameState-BJy57o6K.d.ts → StorageGameState-jAexrJLj.d.ts} +2 -2
  16. package/dist/canvas.cjs +2 -2
  17. package/dist/canvas.d.cts +265 -24
  18. package/dist/canvas.d.ts +265 -24
  19. package/dist/canvas.mjs +2 -2
  20. package/dist/characters.cjs +1 -1
  21. package/dist/characters.mjs +1 -1
  22. package/dist/chunk-HD353M4B.mjs +1 -0
  23. package/dist/chunk-I7DOUH5V.mjs +1 -0
  24. package/dist/history.cjs +1 -1
  25. package/dist/history.d.cts +38 -15
  26. package/dist/history.d.ts +38 -15
  27. package/dist/history.mjs +1 -1
  28. package/dist/index.cjs +2 -2
  29. package/dist/index.d.cts +32 -34
  30. package/dist/index.d.ts +32 -34
  31. package/dist/index.mjs +2 -2
  32. package/dist/motion.cjs +1 -1
  33. package/dist/motion.mjs +1 -1
  34. package/dist/narration.cjs +2 -2
  35. package/dist/narration.d.cts +196 -52
  36. package/dist/narration.d.ts +196 -52
  37. package/dist/narration.mjs +2 -2
  38. package/dist/pixi/browser.js +115 -115
  39. package/dist/sound.cjs +1 -1
  40. package/dist/sound.d.cts +313 -6
  41. package/dist/sound.d.ts +313 -6
  42. package/dist/sound.mjs +1 -1
  43. package/dist/storage.cjs +1 -1
  44. package/dist/storage.d.cts +50 -3
  45. package/dist/storage.d.ts +50 -3
  46. package/dist/storage.mjs +1 -1
  47. package/dist/vite.cjs +2 -2
  48. package/dist/vite.mjs +2 -2
  49. package/package.json +2 -1
  50. package/dist/SoundManagerInterface-Dd0b88_N.d.cts +0 -436
  51. package/dist/SoundManagerInterface-Dd0b88_N.d.ts +0 -436
  52. package/dist/chunk-GIYMPXBT.mjs +0 -1
  53. package/dist/chunk-IWAXXFXE.mjs +0 -1
@@ -1,2 +1,2 @@
1
- 'use strict';var core=require('@drincs/pixi-vn/core');var yt=Object.create;var We=Object.defineProperty;var St=Object.getOwnPropertyDescriptor;var mt=Object.getOwnPropertyNames;var gt=Object.getPrototypeOf,Lt=Object.prototype.hasOwnProperty;var Qe=s=>{throw TypeError(s)};var Tt=(s,e,t)=>e in s?We(s,e,{enumerable:true,configurable:true,writable:true,value:t}):s[e]=t;var Be=(s=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(s,{get:(e,t)=>(typeof require<"u"?require:e)[t]}):s)(function(s){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+s+'" is not supported')});var Ze=(s,e)=>()=>(e||s((e={exports:{}}).exports,e),e.exports);var _t=(s,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of mt(e))!Lt.call(s,i)&&i!==t&&We(s,i,{get:()=>e[i],enumerable:!(n=St(e,i))||n.enumerable});return s};var Et=(s,e,t)=>(t=s!=null?yt(gt(s)):{},_t(We(t,"default",{value:s,enumerable:true}),s));var z=(s,e,t)=>Tt(s,typeof e!="symbol"?e+"":e,t),je=(s,e,t)=>e.has(s)||Qe("Cannot "+t);var r=(s,e,t)=>(je(s,e,"read from private field"),t?t.call(s):e.get(s)),v=(s,e,t)=>e.has(s)?Qe("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(s):e.set(s,t),S=(s,e,t,n)=>(je(s,e,"write to private field"),e.set(s,t),t),f=(s,e,t)=>(je(s,e,"access private method"),t);var Ue=(s,e,t,n)=>({set _(i){S(s,e,i);},get _(){return r(s,e,n)}});var ct=Ze((ze,ht)=>{(function(s,e){typeof ze=="object"?ht.exports=ze=e():typeof define=="function"&&define.amd?define([],e):s.CryptoJS=e();})(ze,function(){var s=s||(function(e,t){var n;if(typeof window<"u"&&window.crypto&&(n=window.crypto),typeof self<"u"&&self.crypto&&(n=self.crypto),typeof globalThis<"u"&&globalThis.crypto&&(n=globalThis.crypto),!n&&typeof window<"u"&&window.msCrypto&&(n=window.msCrypto),!n&&typeof global<"u"&&global.crypto&&(n=global.crypto),!n&&typeof Be=="function")try{n=Be("crypto");}catch{}var i=function(){if(n){if(typeof n.getRandomValues=="function")try{return n.getRandomValues(new Uint32Array(1))[0]}catch{}if(typeof n.randomBytes=="function")try{return n.randomBytes(4).readInt32LE()}catch{}}throw new Error("Native crypto module could not be used to get secure random number.")},a=Object.create||(function(){function l(){}return function(d){var C;return l.prototype=d,C=new l,l.prototype=null,C}})(),o={},p=o.lib={},h=p.Base=(function(){return {extend:function(l){var d=a(this);return l&&d.mixIn(l),(!d.hasOwnProperty("init")||this.init===d.init)&&(d.init=function(){d.$super.init.apply(this,arguments);}),d.init.prototype=d,d.$super=this,d},create:function(){var l=this.extend();return l.init.apply(l,arguments),l},init:function(){},mixIn:function(l){for(var d in l)l.hasOwnProperty(d)&&(this[d]=l[d]);l.hasOwnProperty("toString")&&(this.toString=l.toString);},clone:function(){return this.init.prototype.extend(this)}}})(),b=p.WordArray=h.extend({init:function(l,d){l=this.words=l||[],d!=t?this.sigBytes=d:this.sigBytes=l.length*4;},toString:function(l){return (l||g).stringify(this)},concat:function(l){var d=this.words,C=l.words,E=this.sigBytes,R=l.sigBytes;if(this.clamp(),E%4)for(var D=0;D<R;D++){var se=C[D>>>2]>>>24-D%4*8&255;d[E+D>>>2]|=se<<24-(E+D)%4*8;}else for(var G=0;G<R;G+=4)d[E+G>>>2]=C[G>>>2];return this.sigBytes+=R,this},clamp:function(){var l=this.words,d=this.sigBytes;l[d>>>2]&=4294967295<<32-d%4*8,l.length=e.ceil(d/4);},clone:function(){var l=h.clone.call(this);return l.words=this.words.slice(0),l},random:function(l){for(var d=[],C=0;C<l;C+=4)d.push(i());return new b.init(d,l)}}),u=o.enc={},g=u.Hex={stringify:function(l){for(var d=l.words,C=l.sigBytes,E=[],R=0;R<C;R++){var D=d[R>>>2]>>>24-R%4*8&255;E.push((D>>>4).toString(16)),E.push((D&15).toString(16));}return E.join("")},parse:function(l){for(var d=l.length,C=[],E=0;E<d;E+=2)C[E>>>3]|=parseInt(l.substr(E,2),16)<<24-E%8*4;return new b.init(C,d/2)}},M=u.Latin1={stringify:function(l){for(var d=l.words,C=l.sigBytes,E=[],R=0;R<C;R++){var D=d[R>>>2]>>>24-R%4*8&255;E.push(String.fromCharCode(D));}return E.join("")},parse:function(l){for(var d=l.length,C=[],E=0;E<d;E++)C[E>>>2]|=(l.charCodeAt(E)&255)<<24-E%4*8;return new b.init(C,d)}},N=u.Utf8={stringify:function(l){try{return decodeURIComponent(escape(M.stringify(l)))}catch{throw new Error("Malformed UTF-8 data")}},parse:function(l){return M.parse(unescape(encodeURIComponent(l)))}},P=p.BufferedBlockAlgorithm=h.extend({reset:function(){this._data=new b.init,this._nDataBytes=0;},_append:function(l){typeof l=="string"&&(l=N.parse(l)),this._data.concat(l),this._nDataBytes+=l.sigBytes;},_process:function(l){var d,C=this._data,E=C.words,R=C.sigBytes,D=this.blockSize,se=D*4,G=R/se;l?G=e.ceil(G):G=e.max((G|0)-this._minBufferSize,0);var J=G*D,Le=e.min(J*4,R);if(J){for(var Ke=0;Ke<J;Ke+=D)this._doProcessBlock(E,Ke);d=E.splice(0,J),C.sigBytes-=Le;}return new b.init(d,Le)},clone:function(){var l=h.clone.call(this);return l._data=this._data.clone(),l},_minBufferSize:0});p.Hasher=P.extend({cfg:h.extend(),init:function(l){this.cfg=this.cfg.extend(l),this.reset();},reset:function(){P.reset.call(this),this._doReset();},update:function(l){return this._append(l),this._process(),this},finalize:function(l){l&&this._append(l);var d=this._doFinalize();return d},blockSize:512/32,_createHelper:function(l){return function(d,C){return new l.init(C).finalize(d)}},_createHmacHelper:function(l){return function(d,C){return new _.HMAC.init(l,C).finalize(d)}}});var _=o.algo={};return o})(Math);return s});});var dt=Ze((He,ut)=>{(function(s,e){typeof He=="object"?ut.exports=He=e(ct()):typeof define=="function"&&define.amd?define(["./core"],e):e(s.CryptoJS);})(He,function(s){return (function(){var e=s,t=e.lib,n=t.WordArray,i=t.Hasher,a=e.algo,o=[],p=a.SHA1=i.extend({_doReset:function(){this._hash=new n.init([1732584193,4023233417,2562383102,271733878,3285377520]);},_doProcessBlock:function(h,b){for(var u=this._hash.words,g=u[0],M=u[1],N=u[2],P=u[3],w=u[4],_=0;_<80;_++){if(_<16)o[_]=h[b+_]|0;else {var l=o[_-3]^o[_-8]^o[_-14]^o[_-16];o[_]=l<<1|l>>>31;}var d=(g<<5|g>>>27)+w+o[_];_<20?d+=(M&N|~M&P)+1518500249:_<40?d+=(M^N^P)+1859775393:_<60?d+=(M&N|M&P|N&P)-1894007588:d+=(M^N^P)-899497514,w=P,P=N,N=M<<30|M>>>2,M=g,g=d;}u[0]=u[0]+g|0,u[1]=u[1]+M|0,u[2]=u[2]+N|0,u[3]=u[3]+P|0,u[4]=u[4]+w|0;},_doFinalize:function(){var h=this._data,b=h.words,u=this._nDataBytes*8,g=h.sigBytes*8;return b[g>>>5]|=128<<24-g%32,b[(g+64>>>9<<4)+14]=Math.floor(u/4294967296),b[(g+64>>>9<<4)+15]=u,h.sigBytes=b.length*4,this._process(),this._hash},clone:function(){var h=i.clone.call(this);return h._hash=this._hash.clone(),h}});e.SHA1=i._createHelper(p),e.HmacSHA1=i._createHmacHelper(p);})(),s.SHA1});});var O="narration";var I={CURRENT_DIALOGUE_MEMORY_KEY:"dialogue",LAST_DIALOGUE_ADDED_IN_STEP_MEMORY_KEY:"dialogue:step_counter",CURRENT_MENU_OPTIONS_MEMORY_KEY:"choice:options",LAST_MENU_OPTIONS_ADDED_IN_STEP_MEMORY_KEY:"choice:step_counter",CURRENT_INPUT_VALUE_MEMORY_KEY:"input:value",LAST_INPUT_ADDED_IN_STEP_MEMORY_KEY:"input:step_counter",CURRENT_INPUT_INFO_MEMORY_KEY:"input:info",CHARACTER_CATEGORY_KEY:"character",ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY:"___glue___",OPENED_LABELS_COUNTER_KEY:"label:opened",ALL_CHOICES_MADE_KEY:"choices:made",CURRENT_STEP_TIMES_COUNTER_KEY:"label:history",LAST_STEP_GLUED:"glue:last_step"};var Ct=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,nt=new Set,ke=typeof process=="object"&&process?process:{},it=(s,e,t,n)=>{typeof ke.emitWarning=="function"?ke.emitWarning(s,e,t,n):console.error(`[${t}] ${e}: ${s}`);},Ge=globalThis.AbortController,et=globalThis.AbortSignal;if(typeof Ge>"u"){et=class{onabort;_onabort=[];reason;aborted=false;addEventListener(t,n){this._onabort.push(n);}},Ge=class{constructor(){e();}signal=new et;abort(t){if(!this.signal.aborted){this.signal.reason=t,this.signal.aborted=true;for(let n of this.signal._onabort)n(t);this.signal.onabort?.(t);}}};let s=ke.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",e=()=>{s&&(s=false,it("AbortController is not defined. If using lru-cache in node 14, load an AbortController polyfill from the `node-abort-controller` package. A minimal polyfill is provided for use by LRUCache.fetch(), but it should not be relied upon in other contexts (eg, passing it to other APIs that use AbortController/AbortSignal might have undesirable effects). You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.","NO_ABORT_CONTROLLER","ENOTSUP",e));};}var It=s=>!nt.has(s);var ue=s=>s&&s===Math.floor(s)&&s>0&&isFinite(s),at=s=>ue(s)?s<=Math.pow(2,8)?Uint8Array:s<=Math.pow(2,16)?Uint16Array:s<=Math.pow(2,32)?Uint32Array:s<=Number.MAX_SAFE_INTEGER?Ye:null:null,Ye=class extends Array{constructor(s){super(s),this.fill(0);}},oe,Te,Rt=(oe=class{heap;length;static create(e){let t=at(e);if(!t)return [];S(oe,Te,true);let n=new oe(e,t);return S(oe,Te,false),n}constructor(e,t){if(!r(oe,Te))throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new t(e),this.length=0;}push(e){this.heap[this.length++]=e;}pop(){return this.heap[--this.length]}},Te=new WeakMap,v(oe,Te,false),oe),tt,rt,X,B,Q,Se,Z,_e,Ee,ee,Y,te,U,A,T,K,j,H,F,re,V,ne,ie,k,$,ae,ye,W,Ce,c,$e,me,pe,Ae,q,ot,ge,Ie,Me,de,fe,qe,Fe,Ve,x,Xe,xe,be,Je,Re,st=(Re=class{constructor(e){v(this,c);v(this,X);v(this,B);v(this,Q);v(this,Se);v(this,Z);v(this,_e);v(this,Ee);v(this,ee);z(this,"ttl");z(this,"ttlResolution");z(this,"ttlAutopurge");z(this,"updateAgeOnGet");z(this,"updateAgeOnHas");z(this,"allowStale");z(this,"noDisposeOnSet");z(this,"noUpdateTTL");z(this,"maxEntrySize");z(this,"sizeCalculation");z(this,"noDeleteOnFetchRejection");z(this,"noDeleteOnStaleGet");z(this,"allowStaleOnFetchAbort");z(this,"allowStaleOnFetchRejection");z(this,"ignoreFetchAbort");v(this,Y);v(this,te);v(this,U);v(this,A);v(this,T);v(this,K);v(this,j);v(this,H);v(this,F);v(this,re);v(this,V);v(this,ne);v(this,ie);v(this,k);v(this,$);v(this,ae);v(this,ye);v(this,W);v(this,Ce);v(this,me,()=>{});v(this,pe,()=>{});v(this,Ae,()=>{});v(this,q,()=>false);v(this,ge,e=>{});v(this,Ie,(e,t,n)=>{});v(this,Me,(e,t,n,i)=>{if(n||i)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0});z(this,tt,"LRUCache");let{max:t=0,ttl:n,ttlResolution:i=1,ttlAutopurge:a,updateAgeOnGet:o,updateAgeOnHas:p,allowStale:h,dispose:b,onInsert:u,disposeAfter:g,noDisposeOnSet:M,noUpdateTTL:N,maxSize:P=0,maxEntrySize:w=0,sizeCalculation:_,fetchMethod:l,memoMethod:d,noDeleteOnFetchRejection:C,noDeleteOnStaleGet:E,allowStaleOnFetchRejection:R,allowStaleOnFetchAbort:D,ignoreFetchAbort:se,perf:G}=e;if(G!==void 0&&typeof G?.now!="function")throw new TypeError("perf option must have a now() method if specified");if(S(this,ee,G??Ct),t!==0&&!ue(t))throw new TypeError("max option must be a nonnegative integer");let J=t?at(t):Array;if(!J)throw new Error("invalid max value: "+t);if(S(this,X,t),S(this,B,P),this.maxEntrySize=w||r(this,B),this.sizeCalculation=_,this.sizeCalculation){if(!r(this,B)&&!this.maxEntrySize)throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");if(typeof this.sizeCalculation!="function")throw new TypeError("sizeCalculation set to non-function")}if(d!==void 0&&typeof d!="function")throw new TypeError("memoMethod must be a function if defined");if(S(this,Ee,d),l!==void 0&&typeof l!="function")throw new TypeError("fetchMethod must be a function if specified");if(S(this,_e,l),S(this,ye,!!l),S(this,U,new Map),S(this,A,new Array(t).fill(void 0)),S(this,T,new Array(t).fill(void 0)),S(this,K,new J(t)),S(this,j,new J(t)),S(this,H,0),S(this,F,0),S(this,re,Rt.create(t)),S(this,Y,0),S(this,te,0),typeof b=="function"&&S(this,Q,b),typeof u=="function"&&S(this,Se,u),typeof g=="function"?(S(this,Z,g),S(this,V,[])):(S(this,Z,void 0),S(this,V,void 0)),S(this,ae,!!r(this,Q)),S(this,Ce,!!r(this,Se)),S(this,W,!!r(this,Z)),this.noDisposeOnSet=!!M,this.noUpdateTTL=!!N,this.noDeleteOnFetchRejection=!!C,this.allowStaleOnFetchRejection=!!R,this.allowStaleOnFetchAbort=!!D,this.ignoreFetchAbort=!!se,this.maxEntrySize!==0){if(r(this,B)!==0&&!ue(r(this,B)))throw new TypeError("maxSize must be a positive integer if specified");if(!ue(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");f(this,c,ot).call(this);}if(this.allowStale=!!h,this.noDeleteOnStaleGet=!!E,this.updateAgeOnGet=!!o,this.updateAgeOnHas=!!p,this.ttlResolution=ue(i)||i===0?i:1,this.ttlAutopurge=!!a,this.ttl=n||0,this.ttl){if(!ue(this.ttl))throw new TypeError("ttl must be a positive integer if specified");f(this,c,$e).call(this);}if(r(this,X)===0&&this.ttl===0&&r(this,B)===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!r(this,X)&&!r(this,B)){let Le="LRU_CACHE_UNBOUNDED";It(Le)&&(nt.add(Le),it("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",Le,Re));}}get perf(){return r(this,ee)}static unsafeExposeInternals(e){return {starts:r(e,ie),ttls:r(e,k),autopurgeTimers:r(e,$),sizes:r(e,ne),keyMap:r(e,U),keyList:r(e,A),valList:r(e,T),next:r(e,K),prev:r(e,j),get head(){return r(e,H)},get tail(){return r(e,F)},free:r(e,re),isBackgroundFetch:t=>{var n;return f(n=e,c,x).call(n,t)},backgroundFetch:(t,n,i,a)=>{var o;return f(o=e,c,Ve).call(o,t,n,i,a)},moveToTail:t=>{var n;return f(n=e,c,xe).call(n,t)},indexes:t=>{var n;return f(n=e,c,de).call(n,t)},rindexes:t=>{var n;return f(n=e,c,fe).call(n,t)},isStale:t=>{var n;return r(n=e,q).call(n,t)}}}get max(){return r(this,X)}get maxSize(){return r(this,B)}get calculatedSize(){return r(this,te)}get size(){return r(this,Y)}get fetchMethod(){return r(this,_e)}get memoMethod(){return r(this,Ee)}get dispose(){return r(this,Q)}get onInsert(){return r(this,Se)}get disposeAfter(){return r(this,Z)}getRemainingTTL(e){return r(this,U).has(e)?1/0:0}*entries(){for(let e of f(this,c,de).call(this))r(this,T)[e]!==void 0&&r(this,A)[e]!==void 0&&!f(this,c,x).call(this,r(this,T)[e])&&(yield [r(this,A)[e],r(this,T)[e]]);}*rentries(){for(let e of f(this,c,fe).call(this))r(this,T)[e]!==void 0&&r(this,A)[e]!==void 0&&!f(this,c,x).call(this,r(this,T)[e])&&(yield [r(this,A)[e],r(this,T)[e]]);}*keys(){for(let e of f(this,c,de).call(this)){let t=r(this,A)[e];t!==void 0&&!f(this,c,x).call(this,r(this,T)[e])&&(yield t);}}*rkeys(){for(let e of f(this,c,fe).call(this)){let t=r(this,A)[e];t!==void 0&&!f(this,c,x).call(this,r(this,T)[e])&&(yield t);}}*values(){for(let e of f(this,c,de).call(this))r(this,T)[e]!==void 0&&!f(this,c,x).call(this,r(this,T)[e])&&(yield r(this,T)[e]);}*rvalues(){for(let e of f(this,c,fe).call(this))r(this,T)[e]!==void 0&&!f(this,c,x).call(this,r(this,T)[e])&&(yield r(this,T)[e]);}[(rt=Symbol.iterator,tt=Symbol.toStringTag,rt)](){return this.entries()}find(e,t={}){for(let n of f(this,c,de).call(this)){let i=r(this,T)[n],a=f(this,c,x).call(this,i)?i.__staleWhileFetching:i;if(a!==void 0&&e(a,r(this,A)[n],this))return this.get(r(this,A)[n],t)}}forEach(e,t=this){for(let n of f(this,c,de).call(this)){let i=r(this,T)[n],a=f(this,c,x).call(this,i)?i.__staleWhileFetching:i;a!==void 0&&e.call(t,a,r(this,A)[n],this);}}rforEach(e,t=this){for(let n of f(this,c,fe).call(this)){let i=r(this,T)[n],a=f(this,c,x).call(this,i)?i.__staleWhileFetching:i;a!==void 0&&e.call(t,a,r(this,A)[n],this);}}purgeStale(){let e=false;for(let t of f(this,c,fe).call(this,{allowStale:true}))r(this,q).call(this,t)&&(f(this,c,be).call(this,r(this,A)[t],"expire"),e=true);return e}info(e){let t=r(this,U).get(e);if(t===void 0)return;let n=r(this,T)[t],i=f(this,c,x).call(this,n)?n.__staleWhileFetching:n;if(i===void 0)return;let a={value:i};if(r(this,k)&&r(this,ie)){let o=r(this,k)[t],p=r(this,ie)[t];if(o&&p){let h=o-(r(this,ee).now()-p);a.ttl=h,a.start=Date.now();}}return r(this,ne)&&(a.size=r(this,ne)[t]),a}dump(){let e=[];for(let t of f(this,c,de).call(this,{allowStale:true})){let n=r(this,A)[t],i=r(this,T)[t],a=f(this,c,x).call(this,i)?i.__staleWhileFetching:i;if(a===void 0||n===void 0)continue;let o={value:a};if(r(this,k)&&r(this,ie)){o.ttl=r(this,k)[t];let p=r(this,ee).now()-r(this,ie)[t];o.start=Math.floor(Date.now()-p);}r(this,ne)&&(o.size=r(this,ne)[t]),e.unshift([n,o]);}return e}load(e){this.clear();for(let[t,n]of e){if(n.start){let i=Date.now()-n.start;n.start=r(this,ee).now()-i;}this.set(t,n.value,n);}}set(e,t,n={}){var M,N,P,w;if(t===void 0)return this.delete(e),this;let{ttl:i=this.ttl,start:a,noDisposeOnSet:o=this.noDisposeOnSet,sizeCalculation:p=this.sizeCalculation,status:h}=n,{noUpdateTTL:b=this.noUpdateTTL}=n,u=r(this,Me).call(this,e,t,n.size||0,p);if(this.maxEntrySize&&u>this.maxEntrySize)return h&&(h.set="miss",h.maxEntrySizeExceeded=true),f(this,c,be).call(this,e,"set"),this;let g=r(this,Y)===0?void 0:r(this,U).get(e);if(g===void 0)g=r(this,Y)===0?r(this,F):r(this,re).length!==0?r(this,re).pop():r(this,Y)===r(this,X)?f(this,c,Fe).call(this,false):r(this,Y),r(this,A)[g]=e,r(this,T)[g]=t,r(this,U).set(e,g),r(this,K)[r(this,F)]=g,r(this,j)[g]=r(this,F),S(this,F,g),Ue(this,Y)._++,r(this,Ie).call(this,g,u,h),h&&(h.set="add"),b=false,r(this,Ce)&&((M=r(this,Se))==null||M.call(this,t,e,"add"));else {f(this,c,xe).call(this,g);let _=r(this,T)[g];if(t!==_){if(r(this,ye)&&f(this,c,x).call(this,_)){_.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:l}=_;l!==void 0&&!o&&(r(this,ae)&&((N=r(this,Q))==null||N.call(this,l,e,"set")),r(this,W)&&r(this,V)?.push([l,e,"set"]));}else o||(r(this,ae)&&((P=r(this,Q))==null||P.call(this,_,e,"set")),r(this,W)&&r(this,V)?.push([_,e,"set"]));if(r(this,ge).call(this,g),r(this,Ie).call(this,g,u,h),r(this,T)[g]=t,h){h.set="replace";let l=_&&f(this,c,x).call(this,_)?_.__staleWhileFetching:_;l!==void 0&&(h.oldValue=l);}}else h&&(h.set="update");r(this,Ce)&&this.onInsert?.(t,e,t===_?"update":"replace");}if(i!==0&&!r(this,k)&&f(this,c,$e).call(this),r(this,k)&&(b||r(this,Ae).call(this,g,i,a),h&&r(this,pe).call(this,h,g)),!o&&r(this,W)&&r(this,V)){let _=r(this,V),l;for(;l=_?.shift();)(w=r(this,Z))==null||w.call(this,...l);}return this}pop(){var e;try{for(;r(this,Y);){let t=r(this,T)[r(this,H)];if(f(this,c,Fe).call(this,!0),f(this,c,x).call(this,t)){if(t.__staleWhileFetching)return t.__staleWhileFetching}else if(t!==void 0)return t}}finally{if(r(this,W)&&r(this,V)){let t=r(this,V),n;for(;n=t?.shift();)(e=r(this,Z))==null||e.call(this,...n);}}}has(e,t={}){let{updateAgeOnHas:n=this.updateAgeOnHas,status:i}=t,a=r(this,U).get(e);if(a!==void 0){let o=r(this,T)[a];if(f(this,c,x).call(this,o)&&o.__staleWhileFetching===void 0)return false;if(r(this,q).call(this,a))i&&(i.has="stale",r(this,pe).call(this,i,a));else return n&&r(this,me).call(this,a),i&&(i.has="hit",r(this,pe).call(this,i,a)),true}else i&&(i.has="miss");return false}peek(e,t={}){let{allowStale:n=this.allowStale}=t,i=r(this,U).get(e);if(i===void 0||!n&&r(this,q).call(this,i))return;let a=r(this,T)[i];return f(this,c,x).call(this,a)?a.__staleWhileFetching:a}async fetch(e,t={}){let{allowStale:n=this.allowStale,updateAgeOnGet:i=this.updateAgeOnGet,noDeleteOnStaleGet:a=this.noDeleteOnStaleGet,ttl:o=this.ttl,noDisposeOnSet:p=this.noDisposeOnSet,size:h=0,sizeCalculation:b=this.sizeCalculation,noUpdateTTL:u=this.noUpdateTTL,noDeleteOnFetchRejection:g=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:M=this.allowStaleOnFetchRejection,ignoreFetchAbort:N=this.ignoreFetchAbort,allowStaleOnFetchAbort:P=this.allowStaleOnFetchAbort,context:w,forceRefresh:_=false,status:l,signal:d}=t;if(!r(this,ye))return l&&(l.fetch="get"),this.get(e,{allowStale:n,updateAgeOnGet:i,noDeleteOnStaleGet:a,status:l});let C={allowStale:n,updateAgeOnGet:i,noDeleteOnStaleGet:a,ttl:o,noDisposeOnSet:p,size:h,sizeCalculation:b,noUpdateTTL:u,noDeleteOnFetchRejection:g,allowStaleOnFetchRejection:M,allowStaleOnFetchAbort:P,ignoreFetchAbort:N,status:l,signal:d},E=r(this,U).get(e);if(E===void 0){l&&(l.fetch="miss");let R=f(this,c,Ve).call(this,e,E,C,w);return R.__returned=R}else {let R=r(this,T)[E];if(f(this,c,x).call(this,R)){let J=n&&R.__staleWhileFetching!==void 0;return l&&(l.fetch="inflight",J&&(l.returnedStale=true)),J?R.__staleWhileFetching:R.__returned=R}let D=r(this,q).call(this,E);if(!_&&!D)return l&&(l.fetch="hit"),f(this,c,xe).call(this,E),i&&r(this,me).call(this,E),l&&r(this,pe).call(this,l,E),R;let se=f(this,c,Ve).call(this,e,E,C,w),G=se.__staleWhileFetching!==void 0&&n;return l&&(l.fetch=D?"stale":"refresh",G&&D&&(l.returnedStale=true)),G?se.__staleWhileFetching:se.__returned=se}}async forceFetch(e,t={}){let n=await this.fetch(e,t);if(n===void 0)throw new Error("fetch() returned undefined");return n}memo(e,t={}){let n=r(this,Ee);if(!n)throw new Error("no memoMethod provided to constructor");let{context:i,forceRefresh:a,...o}=t,p=this.get(e,o);if(!a&&p!==void 0)return p;let h=n(e,p,{options:o,context:i});return this.set(e,h,o),h}get(e,t={}){let{allowStale:n=this.allowStale,updateAgeOnGet:i=this.updateAgeOnGet,noDeleteOnStaleGet:a=this.noDeleteOnStaleGet,status:o}=t,p=r(this,U).get(e);if(p!==void 0){let h=r(this,T)[p],b=f(this,c,x).call(this,h);return o&&r(this,pe).call(this,o,p),r(this,q).call(this,p)?(o&&(o.get="stale"),b?(o&&n&&h.__staleWhileFetching!==void 0&&(o.returnedStale=true),n?h.__staleWhileFetching:void 0):(a||f(this,c,be).call(this,e,"expire"),o&&n&&(o.returnedStale=true),n?h:void 0)):(o&&(o.get="hit"),b?h.__staleWhileFetching:(f(this,c,xe).call(this,p),i&&r(this,me).call(this,p),h))}else o&&(o.get="miss");}delete(e){return f(this,c,be).call(this,e,"delete")}clear(){return f(this,c,Je).call(this,"delete")}},X=new WeakMap,B=new WeakMap,Q=new WeakMap,Se=new WeakMap,Z=new WeakMap,_e=new WeakMap,Ee=new WeakMap,ee=new WeakMap,Y=new WeakMap,te=new WeakMap,U=new WeakMap,A=new WeakMap,T=new WeakMap,K=new WeakMap,j=new WeakMap,H=new WeakMap,F=new WeakMap,re=new WeakMap,V=new WeakMap,ne=new WeakMap,ie=new WeakMap,k=new WeakMap,$=new WeakMap,ae=new WeakMap,ye=new WeakMap,W=new WeakMap,Ce=new WeakMap,c=new WeakSet,$e=function(){let e=new Ye(r(this,X)),t=new Ye(r(this,X));S(this,k,e),S(this,ie,t);let n=this.ttlAutopurge?new Array(r(this,X)):void 0;S(this,$,n),S(this,Ae,(p,h,b=r(this,ee).now())=>{t[p]=h!==0?b:0,e[p]=h,i(p,h);}),S(this,me,p=>{t[p]=e[p]!==0?r(this,ee).now():0,i(p,e[p]);});let i=this.ttlAutopurge?(p,h)=>{if(n?.[p]&&(clearTimeout(n[p]),n[p]=void 0),h&&h!==0&&n){let b=setTimeout(()=>{r(this,q).call(this,p)&&f(this,c,be).call(this,r(this,A)[p],"expire");},h+1);b.unref&&b.unref(),n[p]=b;}}:()=>{};S(this,pe,(p,h)=>{if(e[h]){let b=e[h],u=t[h];if(!b||!u)return;p.ttl=b,p.start=u,p.now=a||o();let g=p.now-u;p.remainingTTL=b-g;}});let a=0,o=()=>{let p=r(this,ee).now();if(this.ttlResolution>0){a=p;let h=setTimeout(()=>a=0,this.ttlResolution);h.unref&&h.unref();}return p};this.getRemainingTTL=p=>{let h=r(this,U).get(p);if(h===void 0)return 0;let b=e[h],u=t[h];if(!b||!u)return 1/0;let g=(a||o())-u;return b-g},S(this,q,p=>{let h=t[p],b=e[p];return !!b&&!!h&&(a||o())-h>b});},me=new WeakMap,pe=new WeakMap,Ae=new WeakMap,q=new WeakMap,ot=function(){let e=new Ye(r(this,X));S(this,te,0),S(this,ne,e),S(this,ge,t=>{S(this,te,r(this,te)-e[t]),e[t]=0;}),S(this,Me,(t,n,i,a)=>{if(f(this,c,x).call(this,n))return 0;if(!ue(i))if(a){if(typeof a!="function")throw new TypeError("sizeCalculation must be a function");if(i=a(n,t),!ue(i))throw new TypeError("sizeCalculation return invalid (expect positive integer)")}else throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");return i}),S(this,Ie,(t,n,i)=>{if(e[t]=n,r(this,B)){let a=r(this,B)-e[t];for(;r(this,te)>a;)f(this,c,Fe).call(this,true);}S(this,te,r(this,te)+e[t]),i&&(i.entrySize=n,i.totalCalculatedSize=r(this,te));});},ge=new WeakMap,Ie=new WeakMap,Me=new WeakMap,de=function*({allowStale:e=this.allowStale}={}){if(r(this,Y))for(let t=r(this,F);!(!f(this,c,qe).call(this,t)||((e||!r(this,q).call(this,t))&&(yield t),t===r(this,H)));)t=r(this,j)[t];},fe=function*({allowStale:e=this.allowStale}={}){if(r(this,Y))for(let t=r(this,H);!(!f(this,c,qe).call(this,t)||((e||!r(this,q).call(this,t))&&(yield t),t===r(this,F)));)t=r(this,K)[t];},qe=function(e){return e!==void 0&&r(this,U).get(r(this,A)[e])===e},Fe=function(e){var a;let t=r(this,H),n=r(this,A)[t],i=r(this,T)[t];return r(this,ye)&&f(this,c,x).call(this,i)?i.__abortController.abort(new Error("evicted")):(r(this,ae)||r(this,W))&&(r(this,ae)&&((a=r(this,Q))==null||a.call(this,i,n,"evict")),r(this,W)&&r(this,V)?.push([i,n,"evict"])),r(this,ge).call(this,t),r(this,$)?.[t]&&(clearTimeout(r(this,$)[t]),r(this,$)[t]=void 0),e&&(r(this,A)[t]=void 0,r(this,T)[t]=void 0,r(this,re).push(t)),r(this,Y)===1?(S(this,H,S(this,F,0)),r(this,re).length=0):S(this,H,r(this,K)[t]),r(this,U).delete(n),Ue(this,Y)._--,t},Ve=function(e,t,n,i){let a=t===void 0?void 0:r(this,T)[t];if(f(this,c,x).call(this,a))return a;let o=new Ge,{signal:p}=n;p?.addEventListener("abort",()=>o.abort(p.reason),{signal:o.signal});let h={signal:o.signal,options:n,context:i},b=(w,_=false)=>{let{aborted:l}=o.signal,d=n.ignoreFetchAbort&&w!==void 0,C=n.ignoreFetchAbort||!!(n.allowStaleOnFetchAbort&&w!==void 0);if(n.status&&(l&&!_?(n.status.fetchAborted=true,n.status.fetchError=o.signal.reason,d&&(n.status.fetchAbortIgnored=true)):n.status.fetchResolved=true),l&&!d&&!_)return g(o.signal.reason,C);let E=N,R=r(this,T)[t];return (R===N||d&&_&&R===void 0)&&(w===void 0?E.__staleWhileFetching!==void 0?r(this,T)[t]=E.__staleWhileFetching:f(this,c,be).call(this,e,"fetch"):(n.status&&(n.status.fetchUpdated=true),this.set(e,w,h.options))),w},u=w=>(n.status&&(n.status.fetchRejected=true,n.status.fetchError=w),g(w,false)),g=(w,_)=>{let{aborted:l}=o.signal,d=l&&n.allowStaleOnFetchAbort,C=d||n.allowStaleOnFetchRejection,E=C||n.noDeleteOnFetchRejection,R=N;if(r(this,T)[t]===N&&(!E||!_&&R.__staleWhileFetching===void 0?f(this,c,be).call(this,e,"fetch"):d||(r(this,T)[t]=R.__staleWhileFetching)),C)return n.status&&R.__staleWhileFetching!==void 0&&(n.status.returnedStale=true),R.__staleWhileFetching;if(R.__returned===R)throw w},M=(w,_)=>{var d;let l=(d=r(this,_e))==null?void 0:d.call(this,e,a,h);l&&l instanceof Promise&&l.then(C=>w(C===void 0?void 0:C),_),o.signal.addEventListener("abort",()=>{(!n.ignoreFetchAbort||n.allowStaleOnFetchAbort)&&(w(void 0),n.allowStaleOnFetchAbort&&(w=C=>b(C,true)));});};n.status&&(n.status.fetchDispatched=true);let N=new Promise(M).then(b,u),P=Object.assign(N,{__abortController:o,__staleWhileFetching:a,__returned:void 0});return t===void 0?(this.set(e,P,{...h.options,status:void 0}),t=r(this,U).get(e)):r(this,T)[t]=P,P},x=function(e){if(!r(this,ye))return false;let t=e;return !!t&&t instanceof Promise&&t.hasOwnProperty("__staleWhileFetching")&&t.__abortController instanceof Ge},Xe=function(e,t){r(this,j)[t]=e,r(this,K)[e]=t;},xe=function(e){e!==r(this,F)&&(e===r(this,H)?S(this,H,r(this,K)[e]):f(this,c,Xe).call(this,r(this,j)[e],r(this,K)[e]),f(this,c,Xe).call(this,r(this,F),e),S(this,F,e));},be=function(e,t){var i,a;let n=false;if(r(this,Y)!==0){let o=r(this,U).get(e);if(o!==void 0)if(r(this,$)?.[o]&&(clearTimeout(r(this,$)?.[o]),r(this,$)[o]=void 0),n=true,r(this,Y)===1)f(this,c,Je).call(this,t);else {r(this,ge).call(this,o);let p=r(this,T)[o];if(f(this,c,x).call(this,p)?p.__abortController.abort(new Error("deleted")):(r(this,ae)||r(this,W))&&(r(this,ae)&&((i=r(this,Q))==null||i.call(this,p,e,t)),r(this,W)&&r(this,V)?.push([p,e,t])),r(this,U).delete(e),r(this,A)[o]=void 0,r(this,T)[o]=void 0,o===r(this,F))S(this,F,r(this,j)[o]);else if(o===r(this,H))S(this,H,r(this,K)[o]);else {let h=r(this,j)[o];r(this,K)[h]=r(this,K)[o];let b=r(this,K)[o];r(this,j)[b]=r(this,j)[o];}Ue(this,Y)._--,r(this,re).push(o);}}if(r(this,W)&&r(this,V)?.length){let o=r(this,V),p;for(;p=o?.shift();)(a=r(this,Z))==null||a.call(this,...p);}return n},Je=function(e){var t,n;for(let i of f(this,c,fe).call(this,{allowStale:true})){let a=r(this,T)[i];if(f(this,c,x).call(this,a))a.__abortController.abort(new Error("deleted"));else {let o=r(this,A)[i];r(this,ae)&&((t=r(this,Q))==null||t.call(this,a,o,e)),r(this,W)&&r(this,V)?.push([a,o,e]);}}if(r(this,U).clear(),r(this,T).fill(void 0),r(this,A).fill(void 0),r(this,k)&&r(this,ie)){r(this,k).fill(0),r(this,ie).fill(0);for(let i of r(this,$)??[])i!==void 0&&clearTimeout(i);r(this,$)?.fill(void 0);}if(r(this,ne)&&r(this,ne).fill(0),S(this,H,0),S(this,F,0),r(this,re).length=0,S(this,te,0),S(this,Y,0),r(this,W)&&r(this,V)){let i=r(this,V),a;for(;a=i?.shift();)(n=r(this,Z))==null||n.call(this,...a);}},Re);var Ne=class{cache;map=new Map;constructor(e){this.cache=new st({max:e.cacheSize}),this.map=new Map;}get[Symbol.iterator](){return this.map[Symbol.iterator]}get[Symbol.toStringTag](){return this.map[Symbol.toStringTag]}clear(){this.cache.clear(),this.map.clear();}delete(e){let t=this.map.delete(e);return t&&this.cache.delete(e),t}get forEach(){return this.map.forEach}get(e){let t=this.cache.get(e);return t||this.map.get(e)}has(e){return this.map.has(e)}set(e,t){return this.map.set(e,t),this.cache.set(e,t),this}get size(){return this.map.size}entries(){return this.map.entries()}keys(){return this.map.keys()}values(){return this.map.values()}};var L;(i=>(i.log=(a,...o)=>console.log(`[Pixi\u2019VN] ${a}`,...o),i.warn=(a,...o)=>console.warn(`[Pixi\u2019VN] ${a}`,...o),i.error=(a,...o)=>console.error(`[Pixi\u2019VN] ${a}`,...o),i.info=(a,...o)=>console.info(`[Pixi\u2019VN] ${a}`,...o)))(L||={});var Oe=new Ne({cacheSize:10}),lt;(o=>{function s(p){let h=Oe.get(p);if(!h){L.error(`Label "${p}" not found`);return}return h}o.get=s;function e(...p){for(let h of p)Oe.set(h.id,h);}o.add=e;function t(){return Array.from(Oe.values())}o.values=t;function n(p){return Oe.has(p)}o.has=n;function i(){return Array.from(Oe.keys())}o.keys=i;function a(){Oe.clear();}o.clear=a;})(lt||={});var le=lt;function he(s){try{if(typeof s>"u")return s;let e=JSON.stringify(s);return JSON.parse(e)}catch(e){throw L.error("Error creating exportable element",s,e),new core.PixiError("not_json_serializable","Error creating exportable element")}}var y=class s{constructor(){}static choiceMadeTemp=void 0;static lastHistoryStep=null;static get allOpenedLabels(){return core.GameUnifier.getVariable(O,I.OPENED_LABELS_COUNTER_KEY)||{}}static set allOpenedLabels(e){core.GameUnifier.setVariable(O,I.OPENED_LABELS_COUNTER_KEY,e);}static getCurrentStepTimesCounterData(e=""){let t=s.currentLabelStepIndex;if(t===null)return L.error("currentLabelStepIndex is null"),null;let n=`${t}${e}`,i=s.currentLabelId,a=s._currentLabel;if(!i||t===null||!a)return L.error("currentLabelId or currentLabelStepIndex is null or currentLabel not found"),null;let o=a.getStepSha(t)||"error",p=core.GameUnifier.getVariable(O,I.CURRENT_STEP_TIMES_COUNTER_KEY)||{};return p[i]||(p[i]={}),(!p[i][n]||p[i][n].stepSha1!==o)&&(p[i][n]={stepSha1:o}),p[i][n]}static setCurrentStepTimesCounterData(e="",t){let n=s.currentLabelStepIndex,i=n+e,a=s.currentLabelId;if(!a||n===null){L.error("currentLabelId or currentLabelStepIndex is null");return}let o=core.GameUnifier.getVariable(O,I.CURRENT_STEP_TIMES_COUNTER_KEY)||{};o[a]||(o[a]={}),o[a][i]=t,core.GameUnifier.setVariable(O,I.CURRENT_STEP_TIMES_COUNTER_KEY,o);}static getCurrentStepTimesCounter(e=""){let t=s._stepCounter,n=s.getCurrentStepTimesCounterData(e);if(!n)return L.error("getCurrentStepTimesCounter obj is null"),0;let i=n.stepCounters||[];return i.find(o=>o===t)||(i.push(t),n.stepCounters=i,s.setCurrentStepTimesCounterData(e,n)),i.length}static getRandomNumber(e,t,n={}){let i=n.nestedId||"";if(n.onceOnly||false){let o=s.getCurrentStepTimesCounterData(i);if(!o)return;let p=o.usedRandomNumbers||{},h=Array.from({length:t-e+1},(g,M)=>M+e).filter(g=>!p[`${e}-${t}`]?.includes(g));if(h.length===0)return;let b=Math.floor(Math.random()*h.length),u=h[b];return p[`${e}-${t}`]||(p[`${e}-${t}`]=[]),p[`${e}-${t}`].push(u),o.usedRandomNumbers=p,s.setCurrentStepTimesCounterData(i,o),u}return Math.floor(Math.random()*(t-e+1))+e}static resetCurrentStepTimesCounter(e=""){let t=s.currentLabelStepIndex,n=t+e,i=s.currentLabelId;if(!i||t===null){L.error("currentLabelId or currentLabelStepIndex is null");return}let a=core.GameUnifier.getVariable(O,I.CURRENT_STEP_TIMES_COUNTER_KEY)||{};a[i]||(a[i]={}),a[i][n]={stepCounters:[],stepSha1:""},core.GameUnifier.setVariable(O,I.CURRENT_STEP_TIMES_COUNTER_KEY,a);}static get allChoicesMade(){return core.GameUnifier.getVariable(O,I.ALL_CHOICES_MADE_KEY)||[]}static set allChoicesMade(e){core.GameUnifier.setVariable(O,I.ALL_CHOICES_MADE_KEY,e);}static _stepCounter=0;static increaseStepCounter(){s._stepCounter++;}static _openedLabels=[];static get openedLabels(){return he(s._openedLabels)}static set openedLabels(e){s._openedLabels=he(e);}static _originalOpenedLabels=[];static get originalOpenedLabels(){return he(s._originalOpenedLabels)}static set originalOpenedLabels(e){s._originalOpenedLabels=he(e);}static get _currentLabel(){if(s.currentLabelId)return le.get(s.currentLabelId)}static get currentLabelId(){if(s._openedLabels.length>0)return s._openedLabels[s._openedLabels.length-1].label}static get currentLabelStepIndex(){return s._openedLabels.length>0?s._openedLabels[s._openedLabels.length-1].currentStepIndex:null}static addLabelHistory(e,t){let n=s.allOpenedLabels,i=s.allOpenedLabels[e]?.biggestStep||0,a=s.allOpenedLabels[e]?.openCount||0;(!i||i<t)&&(n[e]={biggestStep:t,openCount:a},s.allOpenedLabels=n);}static addChoicesMade(e,t,n,i){let a=s.allChoicesMade,o=a.findIndex(p=>p.labelId===e&&p.stepIndex===t&&p.choiceIndex===i&&p.stepSha1===n);o<0?a.push({labelId:e,stepIndex:t,choiceIndex:i,stepSha1:n,madeTimes:1}):a[o].madeTimes++,s.allChoicesMade=a;}static pushNewLabel(e){if(!le.get(e))throw new core.PixiError("unregistered_element",`Label ${e} not found`);s._openedLabels.push({label:e,currentStepIndex:0});let n=s.allOpenedLabels,i=s.allOpenedLabels[e]?.biggestStep||0,a=s.allOpenedLabels[e]?.openCount||0;n[e]={biggestStep:i,openCount:a+1},s.allOpenedLabels=n;}static increaseCurrentStepIndex(){if(s._openedLabels.length>0){let e=s._openedLabels[s._openedLabels.length-1];s._openedLabels[s._openedLabels.length-1]={...e,currentStepIndex:e.currentStepIndex+1};}}static _onStepStart;static set onStepStart(e){s._onStepStart=e;}static get onStepStart(){return async(e,t)=>{let n=[];return s.onLoadingLabel&&e===0&&n.push(s.onLoadingLabel(e,t)),s._onStepStart&&n.push(s._onStepStart(e,t)),await Promise.all(n)}}static onLoadingLabel;static onStepEnd;static onLabelStarting};var De=class{get currentStepTimesCounter(){return y.getCurrentStepTimesCounter()}set currentStepTimesCounter(e){y.resetCurrentStepTimesCounter();}getRandomNumber(e,t,n={}){return y.getRandomNumber(e,t,n)}get stepCounter(){return y._stepCounter}get openedLabels(){return y.openedLabels}get currentLabel(){return y._currentLabel}addStepHistory(e,t={}){let{choiceMade:n,ignoreSameStep:i}=t,a,o,p,h=core.GameUnifier.getVariable(O,I.LAST_STEP_GLUED)===this.stepCounter;core.GameUnifier.getVariable(O,I.LAST_DIALOGUE_ADDED_IN_STEP_MEMORY_KEY)===this.stepCounter&&(a=core.GameUnifier.getVariable(O,I.CURRENT_DIALOGUE_MEMORY_KEY)),core.GameUnifier.getVariable(O,I.LAST_MENU_OPTIONS_ADDED_IN_STEP_MEMORY_KEY)===this.stepCounter&&(o=core.GameUnifier.getVariable(O,I.CURRENT_MENU_OPTIONS_MEMORY_KEY)),core.GameUnifier.getVariable(O,I.LAST_INPUT_ADDED_IN_STEP_MEMORY_KEY)===this.stepCounter&&(p=core.GameUnifier.getVariable(O,I.CURRENT_INPUT_VALUE_MEMORY_KEY));let b=y.openedLabels,u={currentLabel:y.currentLabelId,dialogue:a,choices:o,stepSha1:e,index:this.stepCounter,labelStepIndex:y.currentLabelStepIndex,choiceIndexMade:n,inputValue:p,alreadyMadeChoices:this.getAlreadyMadeChoicesForSha(e),isGlued:h,openedLabels:b};y.originalOpenedLabels=b,core.GameUnifier.addHistoryItem(u,{ignoreSameStep:i}),y.lastHistoryStep=u,y.increaseStepCounter();}getAlreadyMadeChoicesForSha(e){let t=y.currentLabelStepIndex,n=this.currentLabel;if(!(t===null||!n))return y.allChoicesMade.filter(i=>i.labelId===n.id&&i.stepIndex===t&&i.stepSha1===e).map(i=>i.choiceIndex)}closeCurrentLabel(){if(!y.currentLabelId){L.warn("No label to close");return}if(!this.currentLabel){L.error("currentLabel not found");return}let e=y.openedLabels;e.pop(),y.openedLabels=e,core.GameUnifier.onLabelClosing(this.openedLabels.length);}closeAllLabels(){for(;y.openedLabels.length>0;)this.closeCurrentLabel(),core.GameUnifier.onLabelClosing(this.openedLabels.length);}isLabelAlreadyCompleted(e){let t;typeof e=="string"?t=e:t=e.id;let i=y.allOpenedLabels[t]?.biggestStep||0;if(i){let a=le.get(t);if(a)return a.stepCount<=i}return false}get alreadyCurrentStepMadeChoicesObj(){let e=y.currentLabelStepIndex,t=this.currentLabel;if(e===null||!t)return;let n=t.getStepSha(e);return n||(L.warn("stepSha not found, setting to ERROR"),n="error"),y.allChoicesMade.filter(i=>i.labelId===t?.id&&i.stepIndex===e&&i.stepSha1===n)}get alreadyCurrentStepMadeChoices(){return this.alreadyCurrentStepMadeChoicesObj?.map(e=>e.choiceIndex)}get isCurrentStepAlreadyOpened(){let e=y.currentLabelId;if(e){let t=y.allOpenedLabels[e]?.openCount||0;if(y.currentLabelStepIndex&&t>=y.currentLabelStepIndex)return true}return false}getTimesLabelOpened(e){return y.allOpenedLabels[e]?.openCount||0}getTimesChoiceMade(e){return this.alreadyCurrentStepMadeChoicesObj?.find(t=>t.choiceIndex===e)?.madeTimes||0}addCurrentStepToHistory(){this.addStepHistory("dev",{ignoreSameStep:true});}getCanContinue(e){let t=e?.showWarn||false,n=this.choices;return n&&n.length>0?(t&&L.warn("The player must make a choice"),false):this.isRequiredInput?(t&&L.warn("The player must enter a value"),false):true}get canContinue(){return core.GameUnifier.runningStepsCount!==0?false:this.getCanContinue()}async onStepStart(e,t){let n=[];return e.onStepStart&&n.push(e.onStepStart(t,e)),y.onStepStart&&n.push(y.onStepStart(t,e)),await Promise.all(n)}async onStepEnd(e,t){let n=[];return e.onStepEnd&&n.push(e.onStepEnd(t,e)),y.onStepEnd&&n.push(y.onStepEnd(t,e)),await Promise.all(n)}async continue(e,t={}){let{runNow:n=false,steps:i=1}=t;if(!Number.isFinite(i)){L.warn(`[continue] The parameter steps must be a valid finite number, received: ${i}`);return}if(i<=0){L.warn(`[continue] The parameter steps must be greater than 0, received: ${i}`);return}if(!n&&!this.getCanContinue({showWarn:true}))return;if(!n&&core.GameUnifier.runningStepsCount!==0){core.GameUnifier.increaseContinueRequest(i);return}i>1&&core.GameUnifier.increaseContinueRequest(i-1),core.GameUnifier.runningStepsCount++;let a;try{core.GameUnifier.runningStepsCount===1&&await core.GameUnifier.onPreContinue(),y.increaseCurrentStepIndex(),a=await this.runCurrentStep(e,t);}catch(o){throw L.error("Error continuing",o),o}return core.GameUnifier.runningStepsCount--,await this.afterRunCurrentStep(e)||a}async afterRunCurrentStep(e){if(core.GameUnifier.runningStepsCount===0&&core.GameUnifier.continueRequestsCount!==0)return await core.GameUnifier.processNavigationRequests(e);if(this.openedLabels.length===0){if(core.GameUnifier.onEnd)return await core.GameUnifier.onEnd(e,{labelId:"end"});L.error("The end of the game is not managed, so the game is blocked. Read this documentation to know how to manage the end of the game: https://pixi-vn.com/start/other-narrative-features.html#how-manage-the-end-of-the-game");}}async runCurrentStep(e,t={}){let{choiceMade:n}=t;if(y.currentLabelId){let i=y.currentLabelStepIndex;if(i===null){L.error("currentLabelStepIndex is null");return}let a=y._currentLabel;if(!a){L.error("currentLabel not found");return}if(a.stepCount>i){try{await this.onStepStart(a,i);}catch(u){L.error("Error running onStepStart",u),this.onStepError&&await this.onStepError(u,e);return}let o=a.getStepById(i);if(!o){L.error("step not found");return}let p=a.getStepSha(i);p||(L.warn("stepSha not found, setting to ERROR"),p="error");let h,b;try{h=await o(e,{labelId:a.id});}catch(u){L.error("Error running step",u),b=u;}try{let u=this.choices;if(u?.length===1&&u[0].autoSelect){let g=u[0];h=await this.selectChoice(g,e);}}catch(u){L.error("Error auto-selecting choice",u),b||(b=u);}try{let u=y.lastHistoryStep;n!==void 0&&u&&(p=u.stepSha1,p||(L.warn("stepSha not found, setting to ERROR"),p="error"),y.addChoicesMade(u.currentLabel||"error",typeof u.labelStepIndex=="number"?u.labelStepIndex:-1,u.stepSha1||"error",n),y.choiceMadeTemp=n);}catch(u){L.warn("Error adding choice made to history",u);}try{core.GameUnifier.runningStepsCount===1&&(y.addLabelHistory(a.id,i),this.addStepHistory(p,{...t,choiceMade:y.choiceMadeTemp}),y.choiceMadeTemp=void 0);}catch(u){L.warn("Error adding step to history",u);}try{this.currentLabel&&await this.onStepEnd(this.currentLabel,y.currentLabelStepIndex||0);}catch(u){L.warn("Error running onStepEnd",u);}return b&&this.onStepError&&await this.onStepError(b,e),h}else {if(this.openedLabels.length>1)return this.closeCurrentLabel(),await this.continue(e,t);if(this.openedLabels.length===1){y.openedLabels=[];return}}}else {if(this.openedLabels.length===0)return;L.error("currentLabelId not found");}}async startLabel(e,t,n){let i=async()=>{let{choiceMade:a,closeCurrentLabel:o,type:p}=n;o&&this.openedLabels.length>0&&this.closeCurrentLabel(),core.GameUnifier.runningStepsCount++;let h;try{let b=le.get(e);if(!b)throw new core.PixiError("unregistered_element",`Label ${e} not found`);y.pushNewLabel(b.id),h=await this.runCurrentStep(t,{choiceMade:a});}catch(b){throw L.error(`Error ${p} label`,b),b}return core.GameUnifier.runningStepsCount--,await this.afterRunCurrentStep(t)||h};return y.onLabelStarting?await y.onLabelStarting(e,t,n,i):await i()}async call(e,t,n){let{choiceMade:i}=n||{},a;return typeof e=="string"?a=e:a=e.id,await this.startLabel(a,t,{choiceMade:i,type:"calling"})}async jump(e,t,n){if(this.stepCounter===0)return await this.call(e,t,n);let{choiceMade:i}=n||{},a;return typeof e=="string"?a=e:a=e.id,await this.startLabel(a,t,{choiceMade:i,closeCurrentLabel:true,type:"jumping to"})}async selectChoice(e,t){this.choices=void 0;let n=e.type;switch(n){case "call":return await this.call(e.label,{...e.props,...t},{choiceMade:e.choiceIndex});case "jump":return await this.jump(e.label,{...e.props,...t},{choiceMade:e.choiceIndex});case "close":return await this.closeChoiceMenu(e,{...e.props,...t});default:throw L.error(`Type ${n} not found`),new core.PixiError("invalid_usage",`Type ${n} not found`)}}async closeChoiceMenu(e,t){if(e.type!=="close")throw L.error("For closeChoiceMenu, the type must be close"),new core.PixiError("invalid_usage","For closeChoiceMenu, the type must be close");let n;return typeof e.choiceIndex=="number"&&(n=e.choiceIndex),e.closeCurrentLabel&&this.closeCurrentLabel(),await this.continue(t,{choiceMade:n})}get onStepError(){return async(e,t)=>{try{await core.GameUnifier.runOnError(e,t);}catch(n){L.error("Error in onError handler",n);}}}get dialogue(){let e=core.GameUnifier.getVariable(O,I.CURRENT_DIALOGUE_MEMORY_KEY);if(e)return {...e,character:e.character?core.GameUnifier.getCharacter(e.character)||e.character:void 0}}set dialogue(e){if(e===void 0){core.GameUnifier.setVariable(O,I.CURRENT_DIALOGUE_MEMORY_KEY,void 0);return}if((typeof e=="string"||Array.isArray(e))&&(e={text:e}),this.dialogGlue){let t=core.GameUnifier.getVariable(O,I.CURRENT_DIALOGUE_MEMORY_KEY);if(t){let n=[];Array.isArray(t.text)?n=[...t.text]:n=[t.text],Array.isArray(e.text)?n=[...n,...e.text]:n=[...n,e.text],e.text=n,e.character=e.character||t.character;}core.GameUnifier.setVariable(O,I.LAST_STEP_GLUED,this.stepCounter),this.dialogGlue=false;}try{core.GameUnifier.setVariable(O,I.CURRENT_DIALOGUE_MEMORY_KEY,he({...e,character:typeof e.character=="string"?e.character:e.character?.id})),core.GameUnifier.setVariable(O,I.LAST_DIALOGUE_ADDED_IN_STEP_MEMORY_KEY,this.stepCounter);}catch{throw L.error("DialogueInterface cannot contain functions or classes"),new core.PixiError("not_json_serializable","ChoiceInterface cannot contain functions or classes")}}get choices(){let e=core.GameUnifier.getVariable(O,I.CURRENT_MENU_OPTIONS_MEMORY_KEY);if(e){let t=[],n=e.map((a,o)=>({...a,choiceIndex:o})),i=this.alreadyCurrentStepMadeChoices;if(n=n.filter((a,o)=>a.oneTime&&i?.includes(o)?false:a.onlyHaveNoChoice?(t.push(a),false):true),n.length>0)return n;if(t.length>0)return [t[0]]}}set choices(e){if(!e||e.length===0){core.GameUnifier.setVariable(O,I.CURRENT_MENU_OPTIONS_MEMORY_KEY,void 0);return}try{core.GameUnifier.setVariable(O,I.CURRENT_MENU_OPTIONS_MEMORY_KEY,he(e)),core.GameUnifier.setVariable(O,I.LAST_MENU_OPTIONS_ADDED_IN_STEP_MEMORY_KEY,this.stepCounter);}catch{throw L.error("ChoiceInterface cannot contain functions or classes"),new core.PixiError("not_json_serializable","ChoiceInterface cannot contain functions or classes")}}get dialogGlue(){return core.GameUnifier.getFlag(I.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY)}set dialogGlue(e){core.GameUnifier.setFlag(I.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,e);}get inputValue(){return core.GameUnifier.getVariable(O,I.CURRENT_INPUT_VALUE_MEMORY_KEY)}set inputValue(e){this.removeInputRequest(),core.GameUnifier.setVariable(O,I.CURRENT_INPUT_VALUE_MEMORY_KEY,e),core.GameUnifier.setVariable(O,I.LAST_INPUT_ADDED_IN_STEP_MEMORY_KEY,this.stepCounter);}get isRequiredInput(){return core.GameUnifier.getVariable(O,I.CURRENT_INPUT_INFO_MEMORY_KEY)?.isRequired||false}get inputType(){return core.GameUnifier.getVariable(O,I.CURRENT_INPUT_INFO_MEMORY_KEY)?.type}requestInput(e={},t){e.isRequired=true,core.GameUnifier.setVariable(O,I.CURRENT_INPUT_INFO_MEMORY_KEY,e),t!==void 0?core.GameUnifier.setVariable(O,I.CURRENT_INPUT_VALUE_MEMORY_KEY,t):core.GameUnifier.removeVariable(O,I.CURRENT_INPUT_VALUE_MEMORY_KEY);}removeInputRequest(){core.GameUnifier.removeVariable(O,I.CURRENT_INPUT_INFO_MEMORY_KEY),core.GameUnifier.removeVariable(O,I.CURRENT_INPUT_VALUE_MEMORY_KEY);}clear(){y.openedLabels=[],y._stepCounter=0;}export(){return {openedLabels:he(y.openedLabels),stepCounter:this.stepCounter}}async onLoadingLabel(e){let t=this.openedLabels.map(async n=>{let i=[],a=le.get(n.label);return a&&(a.onLoadingLabel&&i.push(a.onLoadingLabel(e,a)),y.onLoadingLabel&&i.push(y.onLoadingLabel(e,a))),await Promise.all(i)});return await Promise.all(t)}async restore(e,t){this.clear();try{y.lastHistoryStep=t,Object.hasOwn(e,"openedLabels")?(y.openedLabels=e.openedLabels,y.originalOpenedLabels=y.openedLabels):L.warn("Could not import openedLabels data, so will be ignored"),Object.hasOwn(e,"stepCounter")?y._stepCounter=e.stepCounter:L.warn("Could not import stepCounter data, so will be ignored");try{await this.onLoadingLabel(y.currentLabelStepIndex||0);}catch(n){L.error("Error running onLoadingLabel",n);}}catch(n){L.error("Error importing data",n);}}};function xt(s,e,t,n){let i=typeof e=="string"?e:e.id;return {...n,label:i,props:t,text:s,type:n?.type||"call"}}var pt="close";function At(s,e){return {...e,type:pt,text:s}}var ft=Et(dt());var ve=class{constructor(e,t){this.id=e,this._onStepStart=t?.onStepStart,this._onLoadingLabel=t?.onLoadingLabel,this._onStepEnd=t?.onStepEnd;}id;_onStepStart;get onStepStart(){return async(e,t)=>{if(this._onLoadingLabel&&e===0&&await this._onLoadingLabel(e,t),this._onStepStart)return await this._onStepStart(e,t)}}_onLoadingLabel;get onLoadingLabel(){return this._onLoadingLabel}_onStepEnd;get onStepEnd(){return this._onStepEnd}};var we=class extends ve{get stepCount(){return this.steps.length}getStepById(e){return this.steps[e]}constructor(e,t,n){super(e,n),this._steps=t;}_steps;get steps(){return typeof this._steps=="function"?this._steps():this._steps}getStepSha(e){let t=this.steps;if(e<0||e>=t.length)return typeof this._steps!="function"&&L.warn("stepSha not found, setting to ERROR"),"error";try{return (0,ft.default)(t[e].toString().toLocaleLowerCase()).toString()}catch(n){return L.warn("stepSha not found, setting to ERROR",n),"error"}}};function bt(s,e,t){let n=new we(s,e,t);return le.add(n),n}var Er=new De;
2
- exports.Label=we;exports.LabelAbstract=ve;exports.NarrationManagerStatic=y;exports.RegisteredLabels=le;exports.narration=Er;exports.newChoiceOption=xt;exports.newCloseChoiceOption=At;exports.newLabel=bt;
1
+ 'use strict';var core=require('@drincs/pixi-vn/core');var yt=Object.create;var We=Object.defineProperty;var St=Object.getOwnPropertyDescriptor;var mt=Object.getOwnPropertyNames;var gt=Object.getPrototypeOf,Lt=Object.prototype.hasOwnProperty;var Je=s=>{throw TypeError(s)};var Tt=(s,e,t)=>e in s?We(s,e,{enumerable:true,configurable:true,writable:true,value:t}):s[e]=t;var Be=(s=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(s,{get:(e,t)=>(typeof require<"u"?require:e)[t]}):s)(function(s){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+s+'" is not supported')});var Ze=(s,e)=>()=>(e||s((e={exports:{}}).exports,e),e.exports);var _t=(s,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of mt(e))!Lt.call(s,i)&&i!==t&&We(s,i,{get:()=>e[i],enumerable:!(n=St(e,i))||n.enumerable});return s};var Ct=(s,e,t)=>(t=s!=null?yt(gt(s)):{},_t(We(t,"default",{value:s,enumerable:true}),s));var z=(s,e,t)=>Tt(s,typeof e!="symbol"?e+"":e,t),je=(s,e,t)=>e.has(s)||Je("Cannot "+t);var r=(s,e,t)=>(je(s,e,"read from private field"),t?t.call(s):e.get(s)),v=(s,e,t)=>e.has(s)?Je("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(s):e.set(s,t),S=(s,e,t,n)=>(je(s,e,"write to private field"),e.set(s,t),t),f=(s,e,t)=>(je(s,e,"access private method"),t);var Ue=(s,e,t,n)=>({set _(i){S(s,e,i);},get _(){return r(s,e,n)}});var ut=Ze((ze,ct)=>{(function(s,e){typeof ze=="object"?ct.exports=ze=e():typeof define=="function"&&define.amd?define([],e):s.CryptoJS=e();})(ze,function(){var s=s||(function(e,t){var n;if(typeof window<"u"&&window.crypto&&(n=window.crypto),typeof self<"u"&&self.crypto&&(n=self.crypto),typeof globalThis<"u"&&globalThis.crypto&&(n=globalThis.crypto),!n&&typeof window<"u"&&window.msCrypto&&(n=window.msCrypto),!n&&typeof global<"u"&&global.crypto&&(n=global.crypto),!n&&typeof Be=="function")try{n=Be("crypto");}catch{}var i=function(){if(n){if(typeof n.getRandomValues=="function")try{return n.getRandomValues(new Uint32Array(1))[0]}catch{}if(typeof n.randomBytes=="function")try{return n.randomBytes(4).readInt32LE()}catch{}}throw new Error("Native crypto module could not be used to get secure random number.")},a=Object.create||(function(){function l(){}return function(d){var E;return l.prototype=d,E=new l,l.prototype=null,E}})(),o={},p=o.lib={},c=p.Base=(function(){return {extend:function(l){var d=a(this);return l&&d.mixIn(l),(!d.hasOwnProperty("init")||this.init===d.init)&&(d.init=function(){d.$super.init.apply(this,arguments);}),d.init.prototype=d,d.$super=this,d},create:function(){var l=this.extend();return l.init.apply(l,arguments),l},init:function(){},mixIn:function(l){for(var d in l)l.hasOwnProperty(d)&&(this[d]=l[d]);l.hasOwnProperty("toString")&&(this.toString=l.toString);},clone:function(){return this.init.prototype.extend(this)}}})(),y=p.WordArray=c.extend({init:function(l,d){l=this.words=l||[],d!=t?this.sigBytes=d:this.sigBytes=l.length*4;},toString:function(l){return (l||g).stringify(this)},concat:function(l){var d=this.words,E=l.words,C=this.sigBytes,R=l.sigBytes;if(this.clamp(),C%4)for(var D=0;D<R;D++){var se=E[D>>>2]>>>24-D%4*8&255;d[C+D>>>2]|=se<<24-(C+D)%4*8;}else for(var G=0;G<R;G+=4)d[C+G>>>2]=E[G>>>2];return this.sigBytes+=R,this},clamp:function(){var l=this.words,d=this.sigBytes;l[d>>>2]&=4294967295<<32-d%4*8,l.length=e.ceil(d/4);},clone:function(){var l=c.clone.call(this);return l.words=this.words.slice(0),l},random:function(l){for(var d=[],E=0;E<l;E+=4)d.push(i());return new y.init(d,l)}}),h=o.enc={},g=h.Hex={stringify:function(l){for(var d=l.words,E=l.sigBytes,C=[],R=0;R<E;R++){var D=d[R>>>2]>>>24-R%4*8&255;C.push((D>>>4).toString(16)),C.push((D&15).toString(16));}return C.join("")},parse:function(l){for(var d=l.length,E=[],C=0;C<d;C+=2)E[C>>>3]|=parseInt(l.substr(C,2),16)<<24-C%8*4;return new y.init(E,d/2)}},M=h.Latin1={stringify:function(l){for(var d=l.words,E=l.sigBytes,C=[],R=0;R<E;R++){var D=d[R>>>2]>>>24-R%4*8&255;C.push(String.fromCharCode(D));}return C.join("")},parse:function(l){for(var d=l.length,E=[],C=0;C<d;C++)E[C>>>2]|=(l.charCodeAt(C)&255)<<24-C%4*8;return new y.init(E,d)}},N=h.Utf8={stringify:function(l){try{return decodeURIComponent(escape(M.stringify(l)))}catch{throw new Error("Malformed UTF-8 data")}},parse:function(l){return M.parse(unescape(encodeURIComponent(l)))}},P=p.BufferedBlockAlgorithm=c.extend({reset:function(){this._data=new y.init,this._nDataBytes=0;},_append:function(l){typeof l=="string"&&(l=N.parse(l)),this._data.concat(l),this._nDataBytes+=l.sigBytes;},_process:function(l){var d,E=this._data,C=E.words,R=E.sigBytes,D=this.blockSize,se=D*4,G=R/se;l?G=e.ceil(G):G=e.max((G|0)-this._minBufferSize,0);var Q=G*D,Le=e.min(Q*4,R);if(Q){for(var Ke=0;Ke<Q;Ke+=D)this._doProcessBlock(C,Ke);d=C.splice(0,Q),E.sigBytes-=Le;}return new y.init(d,Le)},clone:function(){var l=c.clone.call(this);return l._data=this._data.clone(),l},_minBufferSize:0});p.Hasher=P.extend({cfg:c.extend(),init:function(l){this.cfg=this.cfg.extend(l),this.reset();},reset:function(){P.reset.call(this),this._doReset();},update:function(l){return this._append(l),this._process(),this},finalize:function(l){l&&this._append(l);var d=this._doFinalize();return d},blockSize:512/32,_createHelper:function(l){return function(d,E){return new l.init(E).finalize(d)}},_createHmacHelper:function(l){return function(d,E){return new _.HMAC.init(l,E).finalize(d)}}});var _=o.algo={};return o})(Math);return s});});var dt=Ze((He,ht)=>{(function(s,e){typeof He=="object"?ht.exports=He=e(ut()):typeof define=="function"&&define.amd?define(["./core"],e):e(s.CryptoJS);})(He,function(s){return (function(){var e=s,t=e.lib,n=t.WordArray,i=t.Hasher,a=e.algo,o=[],p=a.SHA1=i.extend({_doReset:function(){this._hash=new n.init([1732584193,4023233417,2562383102,271733878,3285377520]);},_doProcessBlock:function(c,y){for(var h=this._hash.words,g=h[0],M=h[1],N=h[2],P=h[3],w=h[4],_=0;_<80;_++){if(_<16)o[_]=c[y+_]|0;else {var l=o[_-3]^o[_-8]^o[_-14]^o[_-16];o[_]=l<<1|l>>>31;}var d=(g<<5|g>>>27)+w+o[_];_<20?d+=(M&N|~M&P)+1518500249:_<40?d+=(M^N^P)+1859775393:_<60?d+=(M&N|M&P|N&P)-1894007588:d+=(M^N^P)-899497514,w=P,P=N,N=M<<30|M>>>2,M=g,g=d;}h[0]=h[0]+g|0,h[1]=h[1]+M|0,h[2]=h[2]+N|0,h[3]=h[3]+P|0,h[4]=h[4]+w|0;},_doFinalize:function(){var c=this._data,y=c.words,h=this._nDataBytes*8,g=c.sigBytes*8;return y[g>>>5]|=128<<24-g%32,y[(g+64>>>9<<4)+14]=Math.floor(h/4294967296),y[(g+64>>>9<<4)+15]=h,c.sigBytes=y.length*4,this._process(),this._hash},clone:function(){var c=i.clone.call(this);return c._hash=this._hash.clone(),c}});e.SHA1=i._createHelper(p),e.HmacSHA1=i._createHmacHelper(p);})(),s.SHA1});});var O="narration";var I={CURRENT_DIALOGUE_MEMORY_KEY:"dialogue",LAST_DIALOGUE_ADDED_IN_STEP_MEMORY_KEY:"dialogue:step_counter",CURRENT_MENU_OPTIONS_MEMORY_KEY:"choice:options",LAST_MENU_OPTIONS_ADDED_IN_STEP_MEMORY_KEY:"choice:step_counter",CURRENT_INPUT_VALUE_MEMORY_KEY:"input:value",LAST_INPUT_ADDED_IN_STEP_MEMORY_KEY:"input:step_counter",CURRENT_INPUT_INFO_MEMORY_KEY:"input:info",CHARACTER_CATEGORY_KEY:"character",ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY:"___glue___",OPENED_LABELS_COUNTER_KEY:"label:opened",ALL_CHOICES_MADE_KEY:"choices:made",CURRENT_STEP_TIMES_COUNTER_KEY:"label:history",LAST_STEP_GLUED:"glue:last_step"};var Et=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,nt=new Set,ke=typeof process=="object"&&process?process:{},it=(s,e,t,n)=>{typeof ke.emitWarning=="function"?ke.emitWarning(s,e,t,n):console.error(`[${t}] ${e}: ${s}`);},Ge=globalThis.AbortController,et=globalThis.AbortSignal;if(typeof Ge>"u"){et=class{onabort;_onabort=[];reason;aborted=false;addEventListener(t,n){this._onabort.push(n);}},Ge=class{constructor(){e();}signal=new et;abort(t){if(!this.signal.aborted){this.signal.reason=t,this.signal.aborted=true;for(let n of this.signal._onabort)n(t);this.signal.onabort?.(t);}}};let s=ke.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",e=()=>{s&&(s=false,it("AbortController is not defined. If using lru-cache in node 14, load an AbortController polyfill from the `node-abort-controller` package. A minimal polyfill is provided for use by LRUCache.fetch(), but it should not be relied upon in other contexts (eg, passing it to other APIs that use AbortController/AbortSignal might have undesirable effects). You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.","NO_ABORT_CONTROLLER","ENOTSUP",e));};}var It=s=>!nt.has(s);var he=s=>s&&s===Math.floor(s)&&s>0&&isFinite(s),at=s=>he(s)?s<=Math.pow(2,8)?Uint8Array:s<=Math.pow(2,16)?Uint16Array:s<=Math.pow(2,32)?Uint32Array:s<=Number.MAX_SAFE_INTEGER?Ye:null:null,Ye=class extends Array{constructor(s){super(s),this.fill(0);}},oe,Te,Rt=(oe=class{heap;length;static create(e){let t=at(e);if(!t)return [];S(oe,Te,true);let n=new oe(e,t);return S(oe,Te,false),n}constructor(e,t){if(!r(oe,Te))throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new t(e),this.length=0;}push(e){this.heap[this.length++]=e;}pop(){return this.heap[--this.length]}},Te=new WeakMap,v(oe,Te,false),oe),tt,rt,X,B,J,Se,Z,_e,Ce,ee,Y,te,U,A,T,K,j,H,V,re,F,ne,ie,k,q,ae,ye,W,Ee,u,qe,me,pe,Ae,$,ot,ge,Ie,Me,de,fe,$e,Ve,Fe,x,Xe,xe,be,Qe,Re,st=(Re=class{constructor(e){v(this,u);v(this,X);v(this,B);v(this,J);v(this,Se);v(this,Z);v(this,_e);v(this,Ce);v(this,ee);z(this,"ttl");z(this,"ttlResolution");z(this,"ttlAutopurge");z(this,"updateAgeOnGet");z(this,"updateAgeOnHas");z(this,"allowStale");z(this,"noDisposeOnSet");z(this,"noUpdateTTL");z(this,"maxEntrySize");z(this,"sizeCalculation");z(this,"noDeleteOnFetchRejection");z(this,"noDeleteOnStaleGet");z(this,"allowStaleOnFetchAbort");z(this,"allowStaleOnFetchRejection");z(this,"ignoreFetchAbort");v(this,Y);v(this,te);v(this,U);v(this,A);v(this,T);v(this,K);v(this,j);v(this,H);v(this,V);v(this,re);v(this,F);v(this,ne);v(this,ie);v(this,k);v(this,q);v(this,ae);v(this,ye);v(this,W);v(this,Ee);v(this,me,()=>{});v(this,pe,()=>{});v(this,Ae,()=>{});v(this,$,()=>false);v(this,ge,e=>{});v(this,Ie,(e,t,n)=>{});v(this,Me,(e,t,n,i)=>{if(n||i)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0});z(this,tt,"LRUCache");let{max:t=0,ttl:n,ttlResolution:i=1,ttlAutopurge:a,updateAgeOnGet:o,updateAgeOnHas:p,allowStale:c,dispose:y,onInsert:h,disposeAfter:g,noDisposeOnSet:M,noUpdateTTL:N,maxSize:P=0,maxEntrySize:w=0,sizeCalculation:_,fetchMethod:l,memoMethod:d,noDeleteOnFetchRejection:E,noDeleteOnStaleGet:C,allowStaleOnFetchRejection:R,allowStaleOnFetchAbort:D,ignoreFetchAbort:se,perf:G}=e;if(G!==void 0&&typeof G?.now!="function")throw new TypeError("perf option must have a now() method if specified");if(S(this,ee,G??Et),t!==0&&!he(t))throw new TypeError("max option must be a nonnegative integer");let Q=t?at(t):Array;if(!Q)throw new Error("invalid max value: "+t);if(S(this,X,t),S(this,B,P),this.maxEntrySize=w||r(this,B),this.sizeCalculation=_,this.sizeCalculation){if(!r(this,B)&&!this.maxEntrySize)throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");if(typeof this.sizeCalculation!="function")throw new TypeError("sizeCalculation set to non-function")}if(d!==void 0&&typeof d!="function")throw new TypeError("memoMethod must be a function if defined");if(S(this,Ce,d),l!==void 0&&typeof l!="function")throw new TypeError("fetchMethod must be a function if specified");if(S(this,_e,l),S(this,ye,!!l),S(this,U,new Map),S(this,A,new Array(t).fill(void 0)),S(this,T,new Array(t).fill(void 0)),S(this,K,new Q(t)),S(this,j,new Q(t)),S(this,H,0),S(this,V,0),S(this,re,Rt.create(t)),S(this,Y,0),S(this,te,0),typeof y=="function"&&S(this,J,y),typeof h=="function"&&S(this,Se,h),typeof g=="function"?(S(this,Z,g),S(this,F,[])):(S(this,Z,void 0),S(this,F,void 0)),S(this,ae,!!r(this,J)),S(this,Ee,!!r(this,Se)),S(this,W,!!r(this,Z)),this.noDisposeOnSet=!!M,this.noUpdateTTL=!!N,this.noDeleteOnFetchRejection=!!E,this.allowStaleOnFetchRejection=!!R,this.allowStaleOnFetchAbort=!!D,this.ignoreFetchAbort=!!se,this.maxEntrySize!==0){if(r(this,B)!==0&&!he(r(this,B)))throw new TypeError("maxSize must be a positive integer if specified");if(!he(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");f(this,u,ot).call(this);}if(this.allowStale=!!c,this.noDeleteOnStaleGet=!!C,this.updateAgeOnGet=!!o,this.updateAgeOnHas=!!p,this.ttlResolution=he(i)||i===0?i:1,this.ttlAutopurge=!!a,this.ttl=n||0,this.ttl){if(!he(this.ttl))throw new TypeError("ttl must be a positive integer if specified");f(this,u,qe).call(this);}if(r(this,X)===0&&this.ttl===0&&r(this,B)===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!r(this,X)&&!r(this,B)){let Le="LRU_CACHE_UNBOUNDED";It(Le)&&(nt.add(Le),it("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",Le,Re));}}get perf(){return r(this,ee)}static unsafeExposeInternals(e){return {starts:r(e,ie),ttls:r(e,k),autopurgeTimers:r(e,q),sizes:r(e,ne),keyMap:r(e,U),keyList:r(e,A),valList:r(e,T),next:r(e,K),prev:r(e,j),get head(){return r(e,H)},get tail(){return r(e,V)},free:r(e,re),isBackgroundFetch:t=>{var n;return f(n=e,u,x).call(n,t)},backgroundFetch:(t,n,i,a)=>{var o;return f(o=e,u,Fe).call(o,t,n,i,a)},moveToTail:t=>{var n;return f(n=e,u,xe).call(n,t)},indexes:t=>{var n;return f(n=e,u,de).call(n,t)},rindexes:t=>{var n;return f(n=e,u,fe).call(n,t)},isStale:t=>{var n;return r(n=e,$).call(n,t)}}}get max(){return r(this,X)}get maxSize(){return r(this,B)}get calculatedSize(){return r(this,te)}get size(){return r(this,Y)}get fetchMethod(){return r(this,_e)}get memoMethod(){return r(this,Ce)}get dispose(){return r(this,J)}get onInsert(){return r(this,Se)}get disposeAfter(){return r(this,Z)}getRemainingTTL(e){return r(this,U).has(e)?1/0:0}*entries(){for(let e of f(this,u,de).call(this))r(this,T)[e]!==void 0&&r(this,A)[e]!==void 0&&!f(this,u,x).call(this,r(this,T)[e])&&(yield [r(this,A)[e],r(this,T)[e]]);}*rentries(){for(let e of f(this,u,fe).call(this))r(this,T)[e]!==void 0&&r(this,A)[e]!==void 0&&!f(this,u,x).call(this,r(this,T)[e])&&(yield [r(this,A)[e],r(this,T)[e]]);}*keys(){for(let e of f(this,u,de).call(this)){let t=r(this,A)[e];t!==void 0&&!f(this,u,x).call(this,r(this,T)[e])&&(yield t);}}*rkeys(){for(let e of f(this,u,fe).call(this)){let t=r(this,A)[e];t!==void 0&&!f(this,u,x).call(this,r(this,T)[e])&&(yield t);}}*values(){for(let e of f(this,u,de).call(this))r(this,T)[e]!==void 0&&!f(this,u,x).call(this,r(this,T)[e])&&(yield r(this,T)[e]);}*rvalues(){for(let e of f(this,u,fe).call(this))r(this,T)[e]!==void 0&&!f(this,u,x).call(this,r(this,T)[e])&&(yield r(this,T)[e]);}[(rt=Symbol.iterator,tt=Symbol.toStringTag,rt)](){return this.entries()}find(e,t={}){for(let n of f(this,u,de).call(this)){let i=r(this,T)[n],a=f(this,u,x).call(this,i)?i.__staleWhileFetching:i;if(a!==void 0&&e(a,r(this,A)[n],this))return this.get(r(this,A)[n],t)}}forEach(e,t=this){for(let n of f(this,u,de).call(this)){let i=r(this,T)[n],a=f(this,u,x).call(this,i)?i.__staleWhileFetching:i;a!==void 0&&e.call(t,a,r(this,A)[n],this);}}rforEach(e,t=this){for(let n of f(this,u,fe).call(this)){let i=r(this,T)[n],a=f(this,u,x).call(this,i)?i.__staleWhileFetching:i;a!==void 0&&e.call(t,a,r(this,A)[n],this);}}purgeStale(){let e=false;for(let t of f(this,u,fe).call(this,{allowStale:true}))r(this,$).call(this,t)&&(f(this,u,be).call(this,r(this,A)[t],"expire"),e=true);return e}info(e){let t=r(this,U).get(e);if(t===void 0)return;let n=r(this,T)[t],i=f(this,u,x).call(this,n)?n.__staleWhileFetching:n;if(i===void 0)return;let a={value:i};if(r(this,k)&&r(this,ie)){let o=r(this,k)[t],p=r(this,ie)[t];if(o&&p){let c=o-(r(this,ee).now()-p);a.ttl=c,a.start=Date.now();}}return r(this,ne)&&(a.size=r(this,ne)[t]),a}dump(){let e=[];for(let t of f(this,u,de).call(this,{allowStale:true})){let n=r(this,A)[t],i=r(this,T)[t],a=f(this,u,x).call(this,i)?i.__staleWhileFetching:i;if(a===void 0||n===void 0)continue;let o={value:a};if(r(this,k)&&r(this,ie)){o.ttl=r(this,k)[t];let p=r(this,ee).now()-r(this,ie)[t];o.start=Math.floor(Date.now()-p);}r(this,ne)&&(o.size=r(this,ne)[t]),e.unshift([n,o]);}return e}load(e){this.clear();for(let[t,n]of e){if(n.start){let i=Date.now()-n.start;n.start=r(this,ee).now()-i;}this.set(t,n.value,n);}}set(e,t,n={}){var M,N,P,w;if(t===void 0)return this.delete(e),this;let{ttl:i=this.ttl,start:a,noDisposeOnSet:o=this.noDisposeOnSet,sizeCalculation:p=this.sizeCalculation,status:c}=n,{noUpdateTTL:y=this.noUpdateTTL}=n,h=r(this,Me).call(this,e,t,n.size||0,p);if(this.maxEntrySize&&h>this.maxEntrySize)return c&&(c.set="miss",c.maxEntrySizeExceeded=true),f(this,u,be).call(this,e,"set"),this;let g=r(this,Y)===0?void 0:r(this,U).get(e);if(g===void 0)g=r(this,Y)===0?r(this,V):r(this,re).length!==0?r(this,re).pop():r(this,Y)===r(this,X)?f(this,u,Ve).call(this,false):r(this,Y),r(this,A)[g]=e,r(this,T)[g]=t,r(this,U).set(e,g),r(this,K)[r(this,V)]=g,r(this,j)[g]=r(this,V),S(this,V,g),Ue(this,Y)._++,r(this,Ie).call(this,g,h,c),c&&(c.set="add"),y=false,r(this,Ee)&&((M=r(this,Se))==null||M.call(this,t,e,"add"));else {f(this,u,xe).call(this,g);let _=r(this,T)[g];if(t!==_){if(r(this,ye)&&f(this,u,x).call(this,_)){_.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:l}=_;l!==void 0&&!o&&(r(this,ae)&&((N=r(this,J))==null||N.call(this,l,e,"set")),r(this,W)&&r(this,F)?.push([l,e,"set"]));}else o||(r(this,ae)&&((P=r(this,J))==null||P.call(this,_,e,"set")),r(this,W)&&r(this,F)?.push([_,e,"set"]));if(r(this,ge).call(this,g),r(this,Ie).call(this,g,h,c),r(this,T)[g]=t,c){c.set="replace";let l=_&&f(this,u,x).call(this,_)?_.__staleWhileFetching:_;l!==void 0&&(c.oldValue=l);}}else c&&(c.set="update");r(this,Ee)&&this.onInsert?.(t,e,t===_?"update":"replace");}if(i!==0&&!r(this,k)&&f(this,u,qe).call(this),r(this,k)&&(y||r(this,Ae).call(this,g,i,a),c&&r(this,pe).call(this,c,g)),!o&&r(this,W)&&r(this,F)){let _=r(this,F),l;for(;l=_?.shift();)(w=r(this,Z))==null||w.call(this,...l);}return this}pop(){var e;try{for(;r(this,Y);){let t=r(this,T)[r(this,H)];if(f(this,u,Ve).call(this,!0),f(this,u,x).call(this,t)){if(t.__staleWhileFetching)return t.__staleWhileFetching}else if(t!==void 0)return t}}finally{if(r(this,W)&&r(this,F)){let t=r(this,F),n;for(;n=t?.shift();)(e=r(this,Z))==null||e.call(this,...n);}}}has(e,t={}){let{updateAgeOnHas:n=this.updateAgeOnHas,status:i}=t,a=r(this,U).get(e);if(a!==void 0){let o=r(this,T)[a];if(f(this,u,x).call(this,o)&&o.__staleWhileFetching===void 0)return false;if(r(this,$).call(this,a))i&&(i.has="stale",r(this,pe).call(this,i,a));else return n&&r(this,me).call(this,a),i&&(i.has="hit",r(this,pe).call(this,i,a)),true}else i&&(i.has="miss");return false}peek(e,t={}){let{allowStale:n=this.allowStale}=t,i=r(this,U).get(e);if(i===void 0||!n&&r(this,$).call(this,i))return;let a=r(this,T)[i];return f(this,u,x).call(this,a)?a.__staleWhileFetching:a}async fetch(e,t={}){let{allowStale:n=this.allowStale,updateAgeOnGet:i=this.updateAgeOnGet,noDeleteOnStaleGet:a=this.noDeleteOnStaleGet,ttl:o=this.ttl,noDisposeOnSet:p=this.noDisposeOnSet,size:c=0,sizeCalculation:y=this.sizeCalculation,noUpdateTTL:h=this.noUpdateTTL,noDeleteOnFetchRejection:g=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:M=this.allowStaleOnFetchRejection,ignoreFetchAbort:N=this.ignoreFetchAbort,allowStaleOnFetchAbort:P=this.allowStaleOnFetchAbort,context:w,forceRefresh:_=false,status:l,signal:d}=t;if(!r(this,ye))return l&&(l.fetch="get"),this.get(e,{allowStale:n,updateAgeOnGet:i,noDeleteOnStaleGet:a,status:l});let E={allowStale:n,updateAgeOnGet:i,noDeleteOnStaleGet:a,ttl:o,noDisposeOnSet:p,size:c,sizeCalculation:y,noUpdateTTL:h,noDeleteOnFetchRejection:g,allowStaleOnFetchRejection:M,allowStaleOnFetchAbort:P,ignoreFetchAbort:N,status:l,signal:d},C=r(this,U).get(e);if(C===void 0){l&&(l.fetch="miss");let R=f(this,u,Fe).call(this,e,C,E,w);return R.__returned=R}else {let R=r(this,T)[C];if(f(this,u,x).call(this,R)){let Q=n&&R.__staleWhileFetching!==void 0;return l&&(l.fetch="inflight",Q&&(l.returnedStale=true)),Q?R.__staleWhileFetching:R.__returned=R}let D=r(this,$).call(this,C);if(!_&&!D)return l&&(l.fetch="hit"),f(this,u,xe).call(this,C),i&&r(this,me).call(this,C),l&&r(this,pe).call(this,l,C),R;let se=f(this,u,Fe).call(this,e,C,E,w),G=se.__staleWhileFetching!==void 0&&n;return l&&(l.fetch=D?"stale":"refresh",G&&D&&(l.returnedStale=true)),G?se.__staleWhileFetching:se.__returned=se}}async forceFetch(e,t={}){let n=await this.fetch(e,t);if(n===void 0)throw new Error("fetch() returned undefined");return n}memo(e,t={}){let n=r(this,Ce);if(!n)throw new Error("no memoMethod provided to constructor");let{context:i,forceRefresh:a,...o}=t,p=this.get(e,o);if(!a&&p!==void 0)return p;let c=n(e,p,{options:o,context:i});return this.set(e,c,o),c}get(e,t={}){let{allowStale:n=this.allowStale,updateAgeOnGet:i=this.updateAgeOnGet,noDeleteOnStaleGet:a=this.noDeleteOnStaleGet,status:o}=t,p=r(this,U).get(e);if(p!==void 0){let c=r(this,T)[p],y=f(this,u,x).call(this,c);return o&&r(this,pe).call(this,o,p),r(this,$).call(this,p)?(o&&(o.get="stale"),y?(o&&n&&c.__staleWhileFetching!==void 0&&(o.returnedStale=true),n?c.__staleWhileFetching:void 0):(a||f(this,u,be).call(this,e,"expire"),o&&n&&(o.returnedStale=true),n?c:void 0)):(o&&(o.get="hit"),y?c.__staleWhileFetching:(f(this,u,xe).call(this,p),i&&r(this,me).call(this,p),c))}else o&&(o.get="miss");}delete(e){return f(this,u,be).call(this,e,"delete")}clear(){return f(this,u,Qe).call(this,"delete")}},X=new WeakMap,B=new WeakMap,J=new WeakMap,Se=new WeakMap,Z=new WeakMap,_e=new WeakMap,Ce=new WeakMap,ee=new WeakMap,Y=new WeakMap,te=new WeakMap,U=new WeakMap,A=new WeakMap,T=new WeakMap,K=new WeakMap,j=new WeakMap,H=new WeakMap,V=new WeakMap,re=new WeakMap,F=new WeakMap,ne=new WeakMap,ie=new WeakMap,k=new WeakMap,q=new WeakMap,ae=new WeakMap,ye=new WeakMap,W=new WeakMap,Ee=new WeakMap,u=new WeakSet,qe=function(){let e=new Ye(r(this,X)),t=new Ye(r(this,X));S(this,k,e),S(this,ie,t);let n=this.ttlAutopurge?new Array(r(this,X)):void 0;S(this,q,n),S(this,Ae,(p,c,y=r(this,ee).now())=>{t[p]=c!==0?y:0,e[p]=c,i(p,c);}),S(this,me,p=>{t[p]=e[p]!==0?r(this,ee).now():0,i(p,e[p]);});let i=this.ttlAutopurge?(p,c)=>{if(n?.[p]&&(clearTimeout(n[p]),n[p]=void 0),c&&c!==0&&n){let y=setTimeout(()=>{r(this,$).call(this,p)&&f(this,u,be).call(this,r(this,A)[p],"expire");},c+1);y.unref&&y.unref(),n[p]=y;}}:()=>{};S(this,pe,(p,c)=>{if(e[c]){let y=e[c],h=t[c];if(!y||!h)return;p.ttl=y,p.start=h,p.now=a||o();let g=p.now-h;p.remainingTTL=y-g;}});let a=0,o=()=>{let p=r(this,ee).now();if(this.ttlResolution>0){a=p;let c=setTimeout(()=>a=0,this.ttlResolution);c.unref&&c.unref();}return p};this.getRemainingTTL=p=>{let c=r(this,U).get(p);if(c===void 0)return 0;let y=e[c],h=t[c];if(!y||!h)return 1/0;let g=(a||o())-h;return y-g},S(this,$,p=>{let c=t[p],y=e[p];return !!y&&!!c&&(a||o())-c>y});},me=new WeakMap,pe=new WeakMap,Ae=new WeakMap,$=new WeakMap,ot=function(){let e=new Ye(r(this,X));S(this,te,0),S(this,ne,e),S(this,ge,t=>{S(this,te,r(this,te)-e[t]),e[t]=0;}),S(this,Me,(t,n,i,a)=>{if(f(this,u,x).call(this,n))return 0;if(!he(i))if(a){if(typeof a!="function")throw new TypeError("sizeCalculation must be a function");if(i=a(n,t),!he(i))throw new TypeError("sizeCalculation return invalid (expect positive integer)")}else throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");return i}),S(this,Ie,(t,n,i)=>{if(e[t]=n,r(this,B)){let a=r(this,B)-e[t];for(;r(this,te)>a;)f(this,u,Ve).call(this,true);}S(this,te,r(this,te)+e[t]),i&&(i.entrySize=n,i.totalCalculatedSize=r(this,te));});},ge=new WeakMap,Ie=new WeakMap,Me=new WeakMap,de=function*({allowStale:e=this.allowStale}={}){if(r(this,Y))for(let t=r(this,V);!(!f(this,u,$e).call(this,t)||((e||!r(this,$).call(this,t))&&(yield t),t===r(this,H)));)t=r(this,j)[t];},fe=function*({allowStale:e=this.allowStale}={}){if(r(this,Y))for(let t=r(this,H);!(!f(this,u,$e).call(this,t)||((e||!r(this,$).call(this,t))&&(yield t),t===r(this,V)));)t=r(this,K)[t];},$e=function(e){return e!==void 0&&r(this,U).get(r(this,A)[e])===e},Ve=function(e){var a;let t=r(this,H),n=r(this,A)[t],i=r(this,T)[t];return r(this,ye)&&f(this,u,x).call(this,i)?i.__abortController.abort(new Error("evicted")):(r(this,ae)||r(this,W))&&(r(this,ae)&&((a=r(this,J))==null||a.call(this,i,n,"evict")),r(this,W)&&r(this,F)?.push([i,n,"evict"])),r(this,ge).call(this,t),r(this,q)?.[t]&&(clearTimeout(r(this,q)[t]),r(this,q)[t]=void 0),e&&(r(this,A)[t]=void 0,r(this,T)[t]=void 0,r(this,re).push(t)),r(this,Y)===1?(S(this,H,S(this,V,0)),r(this,re).length=0):S(this,H,r(this,K)[t]),r(this,U).delete(n),Ue(this,Y)._--,t},Fe=function(e,t,n,i){let a=t===void 0?void 0:r(this,T)[t];if(f(this,u,x).call(this,a))return a;let o=new Ge,{signal:p}=n;p?.addEventListener("abort",()=>o.abort(p.reason),{signal:o.signal});let c={signal:o.signal,options:n,context:i},y=(w,_=false)=>{let{aborted:l}=o.signal,d=n.ignoreFetchAbort&&w!==void 0,E=n.ignoreFetchAbort||!!(n.allowStaleOnFetchAbort&&w!==void 0);if(n.status&&(l&&!_?(n.status.fetchAborted=true,n.status.fetchError=o.signal.reason,d&&(n.status.fetchAbortIgnored=true)):n.status.fetchResolved=true),l&&!d&&!_)return g(o.signal.reason,E);let C=N,R=r(this,T)[t];return (R===N||d&&_&&R===void 0)&&(w===void 0?C.__staleWhileFetching!==void 0?r(this,T)[t]=C.__staleWhileFetching:f(this,u,be).call(this,e,"fetch"):(n.status&&(n.status.fetchUpdated=true),this.set(e,w,c.options))),w},h=w=>(n.status&&(n.status.fetchRejected=true,n.status.fetchError=w),g(w,false)),g=(w,_)=>{let{aborted:l}=o.signal,d=l&&n.allowStaleOnFetchAbort,E=d||n.allowStaleOnFetchRejection,C=E||n.noDeleteOnFetchRejection,R=N;if(r(this,T)[t]===N&&(!C||!_&&R.__staleWhileFetching===void 0?f(this,u,be).call(this,e,"fetch"):d||(r(this,T)[t]=R.__staleWhileFetching)),E)return n.status&&R.__staleWhileFetching!==void 0&&(n.status.returnedStale=true),R.__staleWhileFetching;if(R.__returned===R)throw w},M=(w,_)=>{var d;let l=(d=r(this,_e))==null?void 0:d.call(this,e,a,c);l&&l instanceof Promise&&l.then(E=>w(E===void 0?void 0:E),_),o.signal.addEventListener("abort",()=>{(!n.ignoreFetchAbort||n.allowStaleOnFetchAbort)&&(w(void 0),n.allowStaleOnFetchAbort&&(w=E=>y(E,true)));});};n.status&&(n.status.fetchDispatched=true);let N=new Promise(M).then(y,h),P=Object.assign(N,{__abortController:o,__staleWhileFetching:a,__returned:void 0});return t===void 0?(this.set(e,P,{...c.options,status:void 0}),t=r(this,U).get(e)):r(this,T)[t]=P,P},x=function(e){if(!r(this,ye))return false;let t=e;return !!t&&t instanceof Promise&&t.hasOwnProperty("__staleWhileFetching")&&t.__abortController instanceof Ge},Xe=function(e,t){r(this,j)[t]=e,r(this,K)[e]=t;},xe=function(e){e!==r(this,V)&&(e===r(this,H)?S(this,H,r(this,K)[e]):f(this,u,Xe).call(this,r(this,j)[e],r(this,K)[e]),f(this,u,Xe).call(this,r(this,V),e),S(this,V,e));},be=function(e,t){var i,a;let n=false;if(r(this,Y)!==0){let o=r(this,U).get(e);if(o!==void 0)if(r(this,q)?.[o]&&(clearTimeout(r(this,q)?.[o]),r(this,q)[o]=void 0),n=true,r(this,Y)===1)f(this,u,Qe).call(this,t);else {r(this,ge).call(this,o);let p=r(this,T)[o];if(f(this,u,x).call(this,p)?p.__abortController.abort(new Error("deleted")):(r(this,ae)||r(this,W))&&(r(this,ae)&&((i=r(this,J))==null||i.call(this,p,e,t)),r(this,W)&&r(this,F)?.push([p,e,t])),r(this,U).delete(e),r(this,A)[o]=void 0,r(this,T)[o]=void 0,o===r(this,V))S(this,V,r(this,j)[o]);else if(o===r(this,H))S(this,H,r(this,K)[o]);else {let c=r(this,j)[o];r(this,K)[c]=r(this,K)[o];let y=r(this,K)[o];r(this,j)[y]=r(this,j)[o];}Ue(this,Y)._--,r(this,re).push(o);}}if(r(this,W)&&r(this,F)?.length){let o=r(this,F),p;for(;p=o?.shift();)(a=r(this,Z))==null||a.call(this,...p);}return n},Qe=function(e){var t,n;for(let i of f(this,u,fe).call(this,{allowStale:true})){let a=r(this,T)[i];if(f(this,u,x).call(this,a))a.__abortController.abort(new Error("deleted"));else {let o=r(this,A)[i];r(this,ae)&&((t=r(this,J))==null||t.call(this,a,o,e)),r(this,W)&&r(this,F)?.push([a,o,e]);}}if(r(this,U).clear(),r(this,T).fill(void 0),r(this,A).fill(void 0),r(this,k)&&r(this,ie)){r(this,k).fill(0),r(this,ie).fill(0);for(let i of r(this,q)??[])i!==void 0&&clearTimeout(i);r(this,q)?.fill(void 0);}if(r(this,ne)&&r(this,ne).fill(0),S(this,H,0),S(this,V,0),r(this,re).length=0,S(this,te,0),S(this,Y,0),r(this,W)&&r(this,F)){let i=r(this,F),a;for(;a=i?.shift();)(n=r(this,Z))==null||n.call(this,...a);}},Re);var Ne=class{cache;map=new Map;constructor(e){this.cache=new st({max:e.cacheSize}),this.map=new Map;}get[Symbol.iterator](){return this.map[Symbol.iterator]}get[Symbol.toStringTag](){return this.map[Symbol.toStringTag]}clear(){this.cache.clear(),this.map.clear();}delete(e){let t=this.map.delete(e);return t&&this.cache.delete(e),t}get forEach(){return this.map.forEach}get(e){let t=this.cache.get(e);return t||this.map.get(e)}has(e){return this.map.has(e)}set(e,t){return this.map.set(e,t),this.cache.set(e,t),this}get size(){return this.map.size}entries(){return this.map.entries()}keys(){return this.map.keys()}values(){return this.map.values()}};var L;(i=>(i.log=(a,...o)=>console.log(`[Pixi\u2019VN] ${a}`,...o),i.warn=(a,...o)=>console.warn(`[Pixi\u2019VN] ${a}`,...o),i.error=(a,...o)=>console.error(`[Pixi\u2019VN] ${a}`,...o),i.info=(a,...o)=>console.info(`[Pixi\u2019VN] ${a}`,...o)))(L||={});var Oe=new Ne({cacheSize:10}),lt;(o=>{function s(p){let c=Oe.get(p);if(!c){L.error(`Label "${p}" not found`);return}return c}o.get=s;function e(...p){for(let c of p)Oe.set(c.id,c);}o.add=e;function t(){return Array.from(Oe.values())}o.values=t;function n(p){return Oe.has(p)}o.has=n;function i(){return Array.from(Oe.keys())}o.keys=i;function a(){Oe.clear();}o.clear=a;})(lt||={});var le=lt;function ce(s){try{if(typeof s>"u")return s;let e=JSON.stringify(s);return JSON.parse(e)}catch(e){throw L.error("Error creating exportable element",s,e),new core.PixiError("not_json_serializable","Error creating exportable element")}}var b=class s{constructor(){}static choiceMadeTemp=void 0;static lastHistoryStep=null;static get allOpenedLabels(){return core.GameUnifier.getVariable(O,I.OPENED_LABELS_COUNTER_KEY)||{}}static set allOpenedLabels(e){core.GameUnifier.setVariable(O,I.OPENED_LABELS_COUNTER_KEY,e);}static getCurrentStepTimesCounterData(e=""){let t=s.currentLabelStepIndex;if(t===null)return L.error("currentLabelStepIndex is null"),null;let n=`${t}${e}`,i=s.currentLabelId,a=s._currentLabel;if(!i||t===null||!a)return L.error("currentLabelId or currentLabelStepIndex is null or currentLabel not found"),null;let o=a.getStepSha(t)||"error",p=core.GameUnifier.getVariable(O,I.CURRENT_STEP_TIMES_COUNTER_KEY)||{};return p[i]||(p[i]={}),(!p[i][n]||p[i][n].stepSha1!==o)&&(p[i][n]={stepSha1:o}),p[i][n]}static setCurrentStepTimesCounterData(e="",t){let n=s.currentLabelStepIndex,i=n+e,a=s.currentLabelId;if(!a||n===null){L.error("currentLabelId or currentLabelStepIndex is null");return}let o=core.GameUnifier.getVariable(O,I.CURRENT_STEP_TIMES_COUNTER_KEY)||{};o[a]||(o[a]={}),o[a][i]=t,core.GameUnifier.setVariable(O,I.CURRENT_STEP_TIMES_COUNTER_KEY,o);}static getCurrentStepTimesCounter(e=""){let t=s._stepCounter,n=s.getCurrentStepTimesCounterData(e);if(!n)return L.error("getCurrentStepTimesCounter obj is null"),0;let i=n.stepCounters||[];return i.find(o=>o===t)||(i.push(t),n.stepCounters=i,s.setCurrentStepTimesCounterData(e,n)),i.length}static getRandomNumber(e,t,n={}){let i=n.nestedId||"";if(n.onceOnly||false){let o=s.getCurrentStepTimesCounterData(i);if(!o)return;let p=o.usedRandomNumbers||{},c=Array.from({length:t-e+1},(g,M)=>M+e).filter(g=>!p[`${e}-${t}`]?.includes(g));if(c.length===0)return;let y=Math.floor(Math.random()*c.length),h=c[y];return p[`${e}-${t}`]||(p[`${e}-${t}`]=[]),p[`${e}-${t}`].push(h),o.usedRandomNumbers=p,s.setCurrentStepTimesCounterData(i,o),h}return Math.floor(Math.random()*(t-e+1))+e}static resetCurrentStepTimesCounter(e=""){let t=s.currentLabelStepIndex,n=t+e,i=s.currentLabelId;if(!i||t===null){L.error("currentLabelId or currentLabelStepIndex is null");return}let a=core.GameUnifier.getVariable(O,I.CURRENT_STEP_TIMES_COUNTER_KEY)||{};a[i]||(a[i]={}),a[i][n]={stepCounters:[],stepSha1:""},core.GameUnifier.setVariable(O,I.CURRENT_STEP_TIMES_COUNTER_KEY,a);}static get allChoicesMade(){return core.GameUnifier.getVariable(O,I.ALL_CHOICES_MADE_KEY)||[]}static set allChoicesMade(e){core.GameUnifier.setVariable(O,I.ALL_CHOICES_MADE_KEY,e);}static _stepCounter=0;static increaseStepCounter(){s._stepCounter++;}static _openedLabels=[];static get openedLabels(){return ce(s._openedLabels)}static set openedLabels(e){s._openedLabels=ce(e);}static _originalOpenedLabels=[];static get originalOpenedLabels(){return ce(s._originalOpenedLabels)}static set originalOpenedLabels(e){s._originalOpenedLabels=ce(e);}static get _currentLabel(){if(s.currentLabelId)return le.get(s.currentLabelId)}static get currentLabelId(){if(s._openedLabels.length>0)return s._openedLabels[s._openedLabels.length-1].label}static get currentLabelStepIndex(){return s._openedLabels.length>0?s._openedLabels[s._openedLabels.length-1].currentStepIndex:null}static addLabelHistory(e,t){let n=s.allOpenedLabels,i=s.allOpenedLabels[e]?.biggestStep||0,a=s.allOpenedLabels[e]?.openCount||0;(!i||i<t)&&(n[e]={biggestStep:t,openCount:a},s.allOpenedLabels=n);}static addChoicesMade(e,t,n,i){let a=s.allChoicesMade,o=a.findIndex(p=>p.labelId===e&&p.stepIndex===t&&p.choiceIndex===i&&p.stepSha1===n);o<0?a.push({labelId:e,stepIndex:t,choiceIndex:i,stepSha1:n,madeTimes:1}):a[o].madeTimes++,s.allChoicesMade=a;}static pushNewLabel(e){if(!le.get(e))throw new core.PixiError("unregistered_element",`Label ${e} not found`);s._openedLabels.push({label:e,currentStepIndex:0});let n=s.allOpenedLabels,i=s.allOpenedLabels[e]?.biggestStep||0,a=s.allOpenedLabels[e]?.openCount||0;n[e]={biggestStep:i,openCount:a+1},s.allOpenedLabels=n;}static increaseCurrentStepIndex(){if(s._openedLabels.length>0){let e=s._openedLabels[s._openedLabels.length-1];s._openedLabels[s._openedLabels.length-1]={...e,currentStepIndex:e.currentStepIndex+1};}}static _onStepStart;static set onStepStart(e){s._onStepStart=e;}static get onStepStart(){return async(e,t)=>{let n=[];return s.onLoadingLabel&&e===0&&n.push(s.onLoadingLabel(e,t)),s._onStepStart&&n.push(s._onStepStart(e,t)),await Promise.all(n)}}static onLoadingLabel;static onStepEnd;static onLabelStarting;static onLabelClosing};var De=class{get currentStepTimesCounter(){return b.getCurrentStepTimesCounter()}set currentStepTimesCounter(e){b.resetCurrentStepTimesCounter();}getRandomNumber(e,t,n={}){return b.getRandomNumber(e,t,n)}get stepCounter(){return b._stepCounter}get openedLabels(){return b.openedLabels}get currentLabel(){return b._currentLabel}addStepHistory(e,t={}){let{choiceMade:n,ignoreSameStep:i}=t,a,o,p,c=core.GameUnifier.getVariable(O,I.LAST_STEP_GLUED)===this.stepCounter;core.GameUnifier.getVariable(O,I.LAST_DIALOGUE_ADDED_IN_STEP_MEMORY_KEY)===this.stepCounter&&(a=core.GameUnifier.getVariable(O,I.CURRENT_DIALOGUE_MEMORY_KEY)),core.GameUnifier.getVariable(O,I.LAST_MENU_OPTIONS_ADDED_IN_STEP_MEMORY_KEY)===this.stepCounter&&(o=core.GameUnifier.getVariable(O,I.CURRENT_MENU_OPTIONS_MEMORY_KEY)),core.GameUnifier.getVariable(O,I.LAST_INPUT_ADDED_IN_STEP_MEMORY_KEY)===this.stepCounter&&(p=core.GameUnifier.getVariable(O,I.CURRENT_INPUT_VALUE_MEMORY_KEY));let y=b.openedLabels,h={currentLabel:b.currentLabelId,dialogue:a,choices:o,stepSha1:e,index:this.stepCounter,labelStepIndex:b.currentLabelStepIndex,choiceIndexMade:n,inputValue:p,...this.isRequiredInput?{isRequiredInput:true}:{},alreadyMadeChoices:this.getAlreadyMadeChoicesForSha(e),isGlued:c,openedLabels:y};b.originalOpenedLabels=y,core.GameUnifier.addHistoryItem(h,{ignoreSameStep:i}),b.lastHistoryStep=h,b.increaseStepCounter();}getAlreadyMadeChoicesForSha(e){let t=b.currentLabelStepIndex,n=this.currentLabel;if(!(t===null||!n))return b.allChoicesMade.filter(i=>i.labelId===n.id&&i.stepIndex===t&&i.stepSha1===e).map(i=>i.choiceIndex)}closeCurrentLabel(){if(!b.currentLabelId){L.warn("No label to close");return}if(!this.currentLabel){L.error("currentLabel not found");return}let e=b.openedLabels;e.pop(),b.openedLabels=e,core.GameUnifier.onLabelClosing(this.openedLabels.length);}closeAllLabels(){for(;b.openedLabels.length>0;)this.closeCurrentLabel(),core.GameUnifier.onLabelClosing(this.openedLabels.length);}labels={get opened(){return b.openedLabels},get current(){return b._currentLabel},closeCurrent:()=>this.closeCurrentLabel(),closeAll:()=>this.closeAllLabels()};isLabelAlreadyCompleted(e){let t;typeof e=="string"?t=e:t=e.id;let i=b.allOpenedLabels[t]?.biggestStep||0;if(i){let a=le.get(t);if(a)return a.stepCount<=i}return false}get alreadyCurrentStepMadeChoicesObj(){let e=b.currentLabelStepIndex,t=this.currentLabel;if(e===null||!t)return;let n=t.getStepSha(e);return n||(L.warn("stepSha not found, setting to ERROR"),n="error"),b.allChoicesMade.filter(i=>i.labelId===t?.id&&i.stepIndex===e&&i.stepSha1===n)}get alreadyCurrentStepMadeChoices(){return this.alreadyCurrentStepMadeChoicesObj?.map(e=>e.choiceIndex)}get isCurrentStepAlreadyOpened(){let e=b.currentLabelId;if(e){let t=b.allOpenedLabels[e]?.openCount||0;if(b.currentLabelStepIndex&&t>=b.currentLabelStepIndex)return true}return false}getTimesLabelOpened(e){return b.allOpenedLabels[e]?.openCount||0}getTimesChoiceMade(e){return this.alreadyCurrentStepMadeChoicesObj?.find(t=>t.choiceIndex===e)?.madeTimes||0}queries=(()=>{let e=this;return {isLabelAlreadyCompleted:t=>e.isLabelAlreadyCompleted(t),get alreadyCurrentStepMadeChoices(){return e.alreadyCurrentStepMadeChoices},get isCurrentStepAlreadyOpened(){return e.isCurrentStepAlreadyOpened},timesLabelOpened:t=>e.getTimesLabelOpened(t),timesChoiceMade:t=>e.getTimesChoiceMade(t)}})();addCurrentStepToHistory(){this.addStepHistory("dev",{ignoreSameStep:true});}getCanContinue(e){let t=e?.showWarn||false,n=this.choicesValue;return n&&n.length>0?(t&&L.warn("The player must make a choice"),false):this.isRequiredInput?(t&&L.warn("The player must enter a value"),false):true}get canContinue(){return core.GameUnifier.runningStepsCount!==0||this.openedLabels.length===0?false:this.getCanContinue()}async onStepStart(e,t){let n=[];return e.onStepStart&&n.push(e.onStepStart(t,e)),b.onStepStart&&n.push(b.onStepStart(t,e)),await Promise.all(n)}async onStepEnd(e,t){let n=[];return e.onStepEnd&&n.push(e.onStepEnd(t,e)),b.onStepEnd&&n.push(b.onStepEnd(t,e)),await Promise.all(n)}async continue(e,t={}){let{runNow:n=false,steps:i=1}=t;if(!Number.isFinite(i)){L.warn(`[continue] The parameter steps must be a valid finite number, received: ${i}`);return}if(i<=0){L.warn(`[continue] The parameter steps must be greater than 0, received: ${i}`);return}if(!n&&!this.getCanContinue({showWarn:true}))return;if(!n&&core.GameUnifier.runningStepsCount!==0){core.GameUnifier.increaseContinueRequest(i);return}i>1&&core.GameUnifier.increaseContinueRequest(i-1),core.GameUnifier.runningStepsCount++;let a;try{core.GameUnifier.runningStepsCount===1&&await core.GameUnifier.onPreContinue(),b.increaseCurrentStepIndex(),a=await this.runCurrentStep(e,t);}catch(o){throw L.error("Error continuing",o),o}return core.GameUnifier.runningStepsCount--,await this.afterRunCurrentStep(e)||a}async afterRunCurrentStep(e){if(core.GameUnifier.runningStepsCount===0&&core.GameUnifier.continueRequestsCount!==0)return await core.GameUnifier.processNavigationRequests(e);if(this.openedLabels.length===0){if(core.GameUnifier.onEnd)return await core.GameUnifier.onEnd(e,{labelId:"end"});L.error("The end of the game is not managed, so the game is blocked. Read this documentation to know how to manage the end of the game: https://pixi-vn.com/start/other-narrative-features.html#how-manage-the-end-of-the-game");}}async runCurrentStep(e,t={}){let{choiceMade:n}=t;if(b.currentLabelId){let i=b.currentLabelStepIndex;if(i===null){L.error("currentLabelStepIndex is null");return}let a=b._currentLabel;if(!a){L.error("currentLabel not found");return}if(a.stepCount>i){try{await this.onStepStart(a,i);}catch(h){L.error("Error running onStepStart",h),this.onStepError&&await this.onStepError(h,e);return}let o=a.getStepById(i);if(!o){L.error("step not found");return}let p=a.getStepSha(i);p||(L.warn("stepSha not found, setting to ERROR"),p="error");let c,y;try{c=await o(e,{labelId:a.id});}catch(h){L.error("Error running step",h),y=h;}try{let h=this.choicesValue;if(h?.length===1&&h[0].autoSelect){let g=h[0];c=await this.selectChoice(g,e);}}catch(h){L.error("Error auto-selecting choice",h),y||(y=h);}try{let h=b.lastHistoryStep;n!==void 0&&h&&(p=h.stepSha1,p||(L.warn("stepSha not found, setting to ERROR"),p="error"),b.addChoicesMade(h.currentLabel||"error",typeof h.labelStepIndex=="number"?h.labelStepIndex:-1,h.stepSha1||"error",n),b.choiceMadeTemp=n);}catch(h){L.warn("Error adding choice made to history",h);}try{core.GameUnifier.runningStepsCount===1&&(b.addLabelHistory(a.id,i),this.addStepHistory(p,{...t,choiceMade:b.choiceMadeTemp}),b.choiceMadeTemp=void 0);}catch(h){L.warn("Error adding step to history",h);}try{this.currentLabel&&await this.onStepEnd(this.currentLabel,b.currentLabelStepIndex||0);}catch(h){L.warn("Error running onStepEnd",h);}return y&&this.onStepError&&await this.onStepError(y,e),c}else if(this.openedLabels.length>=1)return await this.closeLabel(a.id,e,t)}else {if(this.openedLabels.length===0)return;L.error("currentLabelId not found");}}async closeLabel(e,t,n){let i=async()=>(this.closeCurrentLabel(),await this.continue(t,n));return b.onLabelClosing?await b.onLabelClosing(e,t,i):await i()}async startLabel(e,t,n){let i=async()=>{let{choiceMade:a,closeCurrentLabel:o,type:p}=n;o&&this.openedLabels.length>0&&this.closeCurrentLabel(),core.GameUnifier.runningStepsCount++;let c;try{let y=le.get(e);if(!y)throw new core.PixiError("unregistered_element",`Label ${e} not found`);b.pushNewLabel(y.id),c=await this.runCurrentStep(t,{choiceMade:a});}catch(y){throw L.error(`Error ${p} label`,y),y}return core.GameUnifier.runningStepsCount--,await this.afterRunCurrentStep(t)||c};return b.onLabelStarting?await b.onLabelStarting(e,t,n,i):await i()}async call(e,t,n){let{choiceMade:i}=n||{},a;return typeof e=="string"?a=e:a=e.id,await this.startLabel(a,t,{choiceMade:i,type:"calling"})}async jump(e,t,n){if(this.stepCounter===0)return await this.call(e,t,n);let{choiceMade:i}=n||{},a;return typeof e=="string"?a=e:a=e.id,await this.startLabel(a,t,{choiceMade:i,closeCurrentLabel:true,type:"jumping to"})}async selectChoice(e,t){this.choicesValue=void 0;let n=e.type;switch(n){case "call":return await this.call(e.label,{...e.props,...t},{choiceMade:e.choiceIndex});case "jump":return await this.jump(e.label,{...e.props,...t},{choiceMade:e.choiceIndex});case "close":return await this.closeChoiceMenu(e,{...e.props,...t});default:throw L.error(`Type ${n} not found`),new core.PixiError("invalid_usage",`Type ${n} not found`)}}async closeChoiceMenu(e,t){if(e.type!=="close")throw L.error("For closeChoiceMenu, the type must be close"),new core.PixiError("invalid_usage","For closeChoiceMenu, the type must be close");let n;return typeof e.choiceIndex=="number"&&(n=e.choiceIndex),e.closeCurrentLabel&&this.closeCurrentLabel(),await this.continue(t,{choiceMade:n})}get onStepError(){return async(e,t)=>{try{await core.GameUnifier.runOnError(e,t);}catch(n){L.error("Error in onError handler",n);}}}get dialogue(){let e=core.GameUnifier.getVariable(O,I.CURRENT_DIALOGUE_MEMORY_KEY);if(e)return {...e,character:e.character?core.GameUnifier.getCharacter(e.character)||e.character:void 0}}set dialogue(e){if(e===void 0){core.GameUnifier.setVariable(O,I.CURRENT_DIALOGUE_MEMORY_KEY,void 0);return}if((typeof e=="string"||Array.isArray(e))&&(e={text:e}),this.dialogGlue){let t=core.GameUnifier.getVariable(O,I.CURRENT_DIALOGUE_MEMORY_KEY);if(t){let n=[];Array.isArray(t.text)?n=[...t.text]:n=[t.text],Array.isArray(e.text)?n=[...n,...e.text]:n=[...n,e.text],e.text=n,e.character=e.character||t.character;}core.GameUnifier.setVariable(O,I.LAST_STEP_GLUED,this.stepCounter),this.dialogGlue=false;}try{core.GameUnifier.setVariable(O,I.CURRENT_DIALOGUE_MEMORY_KEY,ce({...e,character:typeof e.character=="string"?e.character:e.character?.id})),core.GameUnifier.setVariable(O,I.LAST_DIALOGUE_ADDED_IN_STEP_MEMORY_KEY,this.stepCounter);}catch{throw L.error("DialogueInterface cannot contain functions or classes"),new core.PixiError("not_json_serializable","ChoiceInterface cannot contain functions or classes")}}get choicesValue(){let e=core.GameUnifier.getVariable(O,I.CURRENT_MENU_OPTIONS_MEMORY_KEY);if(e){let t=[],n=e.map((a,o)=>({...a,choiceIndex:o})),i=this.alreadyCurrentStepMadeChoices;if(n=n.filter((a,o)=>a.oneTime&&i?.includes(o)?false:a.onlyHaveNoChoice?(t.push(a),false):true),n.length>0)return n;if(t.length>0)return [t[0]]}}set choicesValue(e){if(!e||e.length===0){core.GameUnifier.setVariable(O,I.CURRENT_MENU_OPTIONS_MEMORY_KEY,void 0);return}try{core.GameUnifier.setVariable(O,I.CURRENT_MENU_OPTIONS_MEMORY_KEY,ce(e)),core.GameUnifier.setVariable(O,I.LAST_MENU_OPTIONS_ADDED_IN_STEP_MEMORY_KEY,this.stepCounter);}catch{throw L.error("ChoiceInterface cannot contain functions or classes"),new core.PixiError("not_json_serializable","ChoiceInterface cannot contain functions or classes")}}choicesObj=(()=>{let e=this,t={select:(n,i)=>e.selectChoice(n,i)};return Object.defineProperty(t,"list",{get:()=>e.choicesValue,set:n=>{e.choicesValue=n;},enumerable:true}),t})();get choices(){return this.choicesObj}set choices(e){this.choicesValue=e;}get dialogGlue(){return core.GameUnifier.getFlag(I.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY)}set dialogGlue(e){core.GameUnifier.setFlag(I.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,e);}get inputValue(){return core.GameUnifier.getVariable(O,I.CURRENT_INPUT_VALUE_MEMORY_KEY)}set inputValue(e){this.removeInputRequest(),core.GameUnifier.setVariable(O,I.CURRENT_INPUT_VALUE_MEMORY_KEY,e),core.GameUnifier.setVariable(O,I.LAST_INPUT_ADDED_IN_STEP_MEMORY_KEY,this.stepCounter);}get isRequiredInput(){return core.GameUnifier.getVariable(O,I.CURRENT_INPUT_INFO_MEMORY_KEY)?.isRequired||false}get inputType(){return core.GameUnifier.getVariable(O,I.CURRENT_INPUT_INFO_MEMORY_KEY)?.type}requestInput(e={},t){e.isRequired=true,core.GameUnifier.setVariable(O,I.CURRENT_INPUT_INFO_MEMORY_KEY,e),t!==void 0?core.GameUnifier.setVariable(O,I.CURRENT_INPUT_VALUE_MEMORY_KEY,t):core.GameUnifier.removeVariable(O,I.CURRENT_INPUT_VALUE_MEMORY_KEY);}removeInputRequest(){core.GameUnifier.removeVariable(O,I.CURRENT_INPUT_INFO_MEMORY_KEY),core.GameUnifier.removeVariable(O,I.CURRENT_INPUT_VALUE_MEMORY_KEY);}input=(()=>{let e=this;return {get value(){return e.inputValue},set value(t){e.inputValue=t;},get isRequired(){return e.isRequiredInput},get type(){return e.inputType},request:(t,n)=>e.requestInput(t,n),removeRequest:()=>e.removeInputRequest()}})();clear(){b.openedLabels=[],b._stepCounter=0;}export(){return {openedLabels:ce(b.openedLabels),stepCounter:this.stepCounter}}async onLoadingLabel(e){let t=this.openedLabels.map(async n=>{let i=[],a=le.get(n.label);return a&&(a.onLoadingLabel&&i.push(a.onLoadingLabel(e,a)),b.onLoadingLabel&&i.push(b.onLoadingLabel(e,a))),await Promise.all(i)});return await Promise.all(t)}async restore(e,t){this.clear();try{b.lastHistoryStep=t,Object.hasOwn(e,"openedLabels")?(b.openedLabels=e.openedLabels,b.originalOpenedLabels=b.openedLabels):L.warn("Could not import openedLabels data, so will be ignored"),Object.hasOwn(e,"stepCounter")?b._stepCounter=e.stepCounter:L.warn("Could not import stepCounter data, so will be ignored");try{await this.onLoadingLabel(b.currentLabelStepIndex||0);}catch(n){L.error("Error running onLoadingLabel",n);}}catch(n){L.error("Error importing data",n);}}};function xt(s,e,t,n){let i=typeof e=="string"?e:e.id;return {...n,label:i,props:t,text:s,type:n?.type||"call"}}var pt="close";function At(s,e){return {...e,type:pt,text:s}}var ft=Ct(dt());var ve=class{constructor(e,t){this.id=e,this._onStepStart=t?.onStepStart,this._onLoadingLabel=t?.onLoadingLabel,this._onStepEnd=t?.onStepEnd;}id;_onStepStart;get onStepStart(){return async(e,t)=>{if(this._onLoadingLabel&&e===0&&await this._onLoadingLabel(e,t),this._onStepStart)return await this._onStepStart(e,t)}}_onLoadingLabel;get onLoadingLabel(){return this._onLoadingLabel}_onStepEnd;get onStepEnd(){return this._onStepEnd}};var we=class extends ve{get stepCount(){return this.steps.length}getStepById(e){return this.steps[e]}constructor(e,t,n){super(e,n),this._steps=t;}_steps;get steps(){return typeof this._steps=="function"?this._steps():this._steps}getStepSha(e){let t=this.steps;if(e<0||e>=t.length)return typeof this._steps!="function"&&L.warn("stepSha not found, setting to ERROR"),"error";try{return (0,ft.default)(t[e].toString().toLocaleLowerCase()).toString()}catch(n){return L.warn("stepSha not found, setting to ERROR",n),"error"}}};function bt(s,e,t){let n=new we(s,e,t);return le.add(n),n}var Cr=new De;
2
+ exports.Label=we;exports.LabelAbstract=ve;exports.NarrationManagerStatic=b;exports.RegisteredLabels=le;exports.narration=Cr;exports.newChoiceOption=xt;exports.newCloseChoiceOption=At;exports.newLabel=bt;
@@ -1,14 +1,156 @@
1
1
  import { S as StorageElementType, a as StorageObjectType } from './StorageElementType-C7ETezlL.cjs';
2
- import { L as LabelIdType, D as DialogueInterface, H as HistoryStep } from './HistoryStep-G9dUn0Lf.cjs';
3
- export { P as PixivnLabelIds } from './HistoryStep-G9dUn0Lf.cjs';
2
+ import { L as LabelIdType, D as DialogueInterface, H as HistoryStep } from './HistoryStep-WGB6nA4N.cjs';
3
+ export { P as PixivnLabelIds } from './HistoryStep-WGB6nA4N.cjs';
4
4
  import { ChoiceInterface as ChoiceInterface$1 } from '@drincs/pixi-vn';
5
- import { L as LabelRunModeType, C as CloseType } from './HistoryChoiceMenuOption-DVMD78W7.cjs';
6
- export { H as HistoryChoiceMenuOption, N as NarrationHistory } from './HistoryChoiceMenuOption-DVMD78W7.cjs';
5
+ import { L as LabelRunModeType, C as CloseType } from './HistoryChoiceMenuOption-BxMSXnyI.cjs';
6
+ export { H as HistoryChoiceMenuOption, N as NarrationHistory } from './HistoryChoiceMenuOption-BxMSXnyI.cjs';
7
7
  import { S as StepLabelPropsType, a as StepLabelResultType, b as StepLabelType } from './StepLabelType-CN97wZzm.cjs';
8
- import { O as OpenedLabel } from './OpenedLabel-BxfL31aQ.cjs';
8
+ import { O as OpenedLabel } from './OpenedLabel-Cmd675NI.cjs';
9
9
  import { LabelProps as LabelProps$1 } from '@drincs/pixi-vn/canvas';
10
10
  import 'microdiff';
11
11
 
12
+ interface ChoiceOptionInterface extends Omit<ChoiceInterface$1, "label" | "type" | "closeCurrentLabel"> {
13
+ /**
14
+ * Label Id to be opened when the option is selected
15
+ */
16
+ label: LabelIdType;
17
+ /**
18
+ * Type of the label to be opened
19
+ */
20
+ type: LabelRunModeType;
21
+ }
22
+ interface CloseChoiceOptionInterface extends Omit<ChoiceInterface$1, "label" | "type" | "closeCurrentLabel"> {
23
+ /**
24
+ * Type of the label to be opened
25
+ */
26
+ type: CloseType;
27
+ /**
28
+ * If true, the current label will be closed
29
+ */
30
+ closeCurrentLabel?: boolean;
31
+ }
32
+ type StoredChoiceInterface = ChoiceOptionInterface | CloseChoiceOptionInterface;
33
+ type StoredIndexedChoiceInterface = StoredChoiceInterface & {
34
+ /**
35
+ * Is the index of the choice in the menu. It is used to identify the choice when it is selected.
36
+ */
37
+ choiceIndex: number;
38
+ };
39
+
40
+ interface NarrationChoicesInterface {
41
+ /**
42
+ * The choices to be shown in the game.
43
+ */
44
+ get list(): StoredIndexedChoiceInterface[] | undefined;
45
+ /**
46
+ * The choices to be shown in the game.
47
+ * @throws {PixiError} when a choice contains functions or class instances that cannot be serialized to JSON.
48
+ */
49
+ set list(data: StoredChoiceInterface[] | undefined);
50
+ /**
51
+ * Select a choice from the choice menu, and close the choice menu.
52
+ * @param item The choice item selected by the player.
53
+ * @param props The props to pass to the label.
54
+ * @returns StepLabelResultType or undefined.
55
+ * @throws {PixiError} when the choice type is not `"call"`, `"jump"`, or `"close"`.
56
+ * @example
57
+ * ```ts
58
+ * narration.choices.select(item, {
59
+ * navigate: navigate,
60
+ * // your props
61
+ * ...item.props
62
+ * })
63
+ * .then(() => {
64
+ * // your code
65
+ * })
66
+ * .catch((e) => {
67
+ * // your code
68
+ * })
69
+ * ```
70
+ */
71
+ select<T extends {}>(item: StoredIndexedChoiceInterface, props: StepLabelPropsType<T>): Promise<StepLabelResultType>;
72
+ }
73
+
74
+ type InputInfo = {
75
+ isRequired?: boolean;
76
+ type?: string;
77
+ };
78
+
79
+ interface NarrationInputInterface {
80
+ /**
81
+ * The input value to be inserted by the player.
82
+ */
83
+ value: StorageElementType;
84
+ /**
85
+ * If true, the player must enter a value.
86
+ */
87
+ readonly isRequired: boolean;
88
+ /**
89
+ * Returns the type of input prompt requested.
90
+ */
91
+ readonly type: string | undefined;
92
+ /**
93
+ * Returns `true` if the player must enter a value.
94
+ * @param info The input value to be inserted by the player.
95
+ * @param defaultValue The default value to be inserted.
96
+ */
97
+ request(info?: Omit<InputInfo, "isRequired">, defaultValue?: StorageElementType): void;
98
+ /**
99
+ * Remove the input request.
100
+ */
101
+ removeRequest(): void;
102
+ }
103
+
104
+ interface NarrationLabelsInterface {
105
+ /**
106
+ * The stack of the opened labels.
107
+ */
108
+ readonly opened: OpenedLabel[];
109
+ /**
110
+ * currentLabel is the current label that occurred during the progression of the steps.
111
+ */
112
+ readonly current: LabelAbstract<any> | undefined;
113
+ /**
114
+ * Close the current label and add it to the history.
115
+ */
116
+ closeCurrent(): void;
117
+ /**
118
+ * Close all labels and add them to the history. **Attention: This method can cause an unhandled game ending.**
119
+ */
120
+ closeAll(): void;
121
+ }
122
+
123
+ interface NarrationQueriesInterface {
124
+ /**
125
+ * Check if the label is already completed.
126
+ * @param label The label to check.
127
+ * @returns True if the label is already completed.
128
+ */
129
+ isLabelAlreadyCompleted(label: LabelIdType | LabelAbstract<any>): boolean;
130
+ /**
131
+ * Get the choices already made in the current step. **Attention**: if the choice step index is edited or the code of choice step is edited, the result will be wrong.
132
+ * @returns The choices already made in the current step. If there are no choices, it will return undefined.
133
+ */
134
+ readonly alreadyCurrentStepMadeChoices: number[] | undefined;
135
+ /**
136
+ * Check if the current step is already completed.
137
+ * @returns True if the current step is already completed.
138
+ */
139
+ readonly isCurrentStepAlreadyOpened: boolean;
140
+ /**
141
+ * Get times a label has been opened.
142
+ * @param label The label to check.
143
+ * @returns times a label has been opened.
144
+ */
145
+ timesLabelOpened(label: LabelIdType): number;
146
+ /**
147
+ * Get times a choice has been made in the current step.
148
+ * @param index The index of the choice.
149
+ * @returns The number of times the choice has been made.
150
+ */
151
+ timesChoiceMade(index: number): number;
152
+ }
153
+
12
154
  interface NarrationManagerInterface {
13
155
  /**
14
156
  * Counter of execution times of the current step. Current execution is also included. Starts from 1.
@@ -43,52 +185,73 @@ interface NarrationManagerInterface {
43
185
  readonly stepCounter: number;
44
186
  /**
45
187
  * The stack of the opened labels.
188
+ * @deprecated Use {@link labels}.opened instead.
46
189
  */
47
190
  readonly openedLabels: OpenedLabel[];
48
191
  /**
49
192
  * currentLabel is the current label that occurred during the progression of the steps.
193
+ * @deprecated Use {@link labels}.current instead.
50
194
  */
51
195
  readonly currentLabel: LabelAbstract<any> | undefined;
52
196
  /**
53
197
  * Close the current label and add it to the history.
54
198
  * @returns
199
+ * @deprecated Use {@link labels}.closeCurrent instead.
55
200
  */
56
201
  closeCurrentLabel(): void;
57
202
  /**
58
203
  * Close all labels and add them to the history. **Attention: This method can cause an unhandled game ending.**
204
+ * @deprecated Use {@link labels}.closeAll instead.
59
205
  */
60
206
  closeAllLabels(): void;
61
207
  /**
62
208
  * Check if the label is already completed.
63
209
  * @param label The label to check.
64
210
  * @returns True if the label is already completed.
211
+ * @deprecated Use {@link queries}.isLabelAlreadyCompleted instead.
65
212
  */
66
213
  isLabelAlreadyCompleted(label: LabelIdType | LabelAbstract<any>): boolean;
67
214
  /**
68
215
  * Get the choices already made in the current step. **Attention**: if the choice step index is edited or the code of choice step is edited, the result will be wrong.
69
216
  * @returns The choices already made in the current step. If there are no choices, it will return undefined.
217
+ * @deprecated Use {@link queries}.alreadyCurrentStepMadeChoices instead.
70
218
  */
71
219
  readonly alreadyCurrentStepMadeChoices: number[] | undefined;
72
220
  /**
73
221
  * Check if the current step is already completed.
74
222
  * @returns True if the current step is already completed.
223
+ * @deprecated Use {@link queries}.isCurrentStepAlreadyOpened instead.
75
224
  */
76
225
  readonly isCurrentStepAlreadyOpened: boolean;
77
226
  /**
78
227
  * Get times a label has been opened
79
228
  * @returns times a label has been opened
229
+ * @deprecated Use {@link queries}.timesLabelOpened instead.
80
230
  */
81
231
  getTimesLabelOpened(label: LabelIdType): number;
82
232
  /**
83
233
  * Get times a choice has been made in the current step.
84
234
  * @param index The index of the choice.
85
235
  * @returns The number of times the choice has been made.
236
+ * @deprecated Use {@link queries}.timesChoiceMade instead.
86
237
  */
87
238
  getTimesChoiceMade(index: number): number;
88
239
  /**
89
240
  * Save the current step to the history.
90
241
  */
91
242
  addCurrentStepToHistory(): void;
243
+ /**
244
+ * Namespace for operations on the input requested to the player.
245
+ */
246
+ readonly input: NarrationInputInterface;
247
+ /**
248
+ * Namespace for operations on the opened labels.
249
+ */
250
+ readonly labels: NarrationLabelsInterface;
251
+ /**
252
+ * Namespace for queries about the current state of the narration.
253
+ */
254
+ readonly queries: NarrationQueriesInterface;
92
255
  /**
93
256
  * Return if can go to the next step. It's `false` when:
94
257
  * - A `step` is running
@@ -200,6 +363,7 @@ interface NarrationManagerInterface {
200
363
  * // your code
201
364
  * })
202
365
  * ```
366
+ * @deprecated Use {@link choices}.select instead.
203
367
  */
204
368
  selectChoice<T extends {}>(item: StoredIndexedChoiceInterface, props: StepLabelPropsType<T>): Promise<StepLabelResultType>;
205
369
  /** Old Step Methods */
@@ -213,21 +377,11 @@ interface NarrationManagerInterface {
213
377
  */
214
378
  set dialogue(props: DialogueInterface | string | string[] | undefined);
215
379
  /**
216
- * The options to be shown in the game
217
- * @example
218
- * ```ts
219
- * narration.choices = [
220
- * newChoiceOption("Events Test", EventsTestLabel, {}),
221
- * newChoiceOption("Show Image Test", ShowImageTest, { image: "imageId" }, "call"),
222
- * newChoiceOption("Ticker Test", TickerTestLabel, {}),
223
- * newChoiceOption("Tinting Test", TintingTestLabel, {}, "jump"),
224
- * newChoiceOption("Base Canvas Element Test", BaseCanvasElementTestLabel, {})
225
- * ]
226
- * ```
380
+ * Namespace for operations on the choices to be shown in the game.
227
381
  */
228
- get choices(): StoredIndexedChoiceInterface[] | undefined;
382
+ get choices(): NarrationChoicesInterface;
229
383
  /**
230
- * The options to be shown in the game
384
+ * Shortcut for {@link NarrationChoicesInterface.list}.
231
385
  * @throws {PixiError} when a choice contains functions or class instances that cannot be serialized to JSON.
232
386
  * @example
233
387
  * ```ts
@@ -247,24 +401,29 @@ interface NarrationManagerInterface {
247
401
  dialogGlue: boolean;
248
402
  /**
249
403
  * The input value to be inserted by the player.
404
+ * @deprecated Use {@link input}.value instead.
250
405
  */
251
406
  inputValue: StorageElementType;
252
407
  /**
253
408
  * If true, the player must enter a value.
409
+ * @deprecated Use {@link input}.isRequired instead.
254
410
  */
255
411
  readonly isRequiredInput: boolean;
256
412
  /**
257
413
  * Returns the type of input prompt requested.
414
+ * @deprecated Use {@link input}.type instead.
258
415
  */
259
416
  readonly inputType: string | undefined;
260
417
  /**
261
418
  * Returns `true` if the player must enter a value.
262
419
  * @param info The input value to be inserted by the player.
263
420
  * @param defaultValue The default value to be inserted.
421
+ * @deprecated Use {@link input}.request instead.
264
422
  */
265
423
  requestInput(info?: Omit<InputInfo, "isRequired">, defaultValue?: StorageElementType): void;
266
424
  /**
267
425
  * Remove the input request.
426
+ * @deprecated Use {@link input}.removeRequest instead.
268
427
  */
269
428
  removeInputRequest(): void;
270
429
  /**
@@ -283,34 +442,6 @@ interface NarrationManagerInterface {
283
442
  restore(data: object, lastHistoryStep: Omit<HistoryStep, "diff"> | null): Promise<void>;
284
443
  }
285
444
 
286
- interface ChoiceOptionInterface extends Omit<ChoiceInterface$1, "label" | "type" | "closeCurrentLabel"> {
287
- /**
288
- * Label Id to be opened when the option is selected
289
- */
290
- label: LabelIdType;
291
- /**
292
- * Type of the label to be opened
293
- */
294
- type: LabelRunModeType;
295
- }
296
- interface CloseChoiceOptionInterface extends Omit<ChoiceInterface$1, "label" | "type" | "closeCurrentLabel"> {
297
- /**
298
- * Type of the label to be opened
299
- */
300
- type: CloseType;
301
- /**
302
- * If true, the current label will be closed
303
- */
304
- closeCurrentLabel?: boolean;
305
- }
306
- type StoredChoiceInterface = ChoiceOptionInterface | CloseChoiceOptionInterface;
307
- type StoredIndexedChoiceInterface = StoredChoiceInterface & {
308
- /**
309
- * Is the index of the choice in the menu. It is used to identify the choice when it is selected.
310
- */
311
- choiceIndex: number;
312
- };
313
-
314
445
  interface LabelProps<T, StepIdType = number> {
315
446
  /**
316
447
  * A function executed before each `step`.
@@ -729,13 +860,26 @@ declare class NarrationManagerStatic {
729
860
  closeCurrentLabel?: boolean;
730
861
  type: string;
731
862
  }, defaultStart: () => Promise<StepLabelResultType>) => StepLabelResultType | Promise<StepLabelResultType>;
863
+ /**
864
+ * Is a function that will be executed every time the current label is about to close because it
865
+ * naturally ran out of steps - either control is returning to the label that called it, or, if
866
+ * there's no parent label left on the stack, the game is about to end (see {@link Game.onEnd}).
867
+ *
868
+ * By default (when this is not set), the label is closed immediately, exactly like before this
869
+ * hook existed. If you set it, you take control: call `defaultClose()` yourself whenever you want
870
+ * the label to actually close (right away, or later, e.g. from a subsequent `next()`-like action in
871
+ * your template). Until `defaultClose()` is called, the label stays open: it is not popped off the
872
+ * opened labels stack, narration does not continue into the parent label, and the game does not end
873
+ * even if this was the last label - this is what lets an app show the final paragraph of a story
874
+ * before actually ending it, instead of both happening within the same `continue()` call.
875
+ *
876
+ * This does not fire for a `jump` or a choice's `closeCurrentLabel` option - those close the
877
+ * current label explicitly as part of starting a new one, so {@link onLabelStarting} already
878
+ * covers deferring them.
879
+ */
880
+ static onLabelClosing?: (labelId: LabelIdType, props: StepLabelPropsType, defaultClose: () => Promise<StepLabelResultType>) => StepLabelResultType | Promise<StepLabelResultType>;
732
881
  }
733
882
 
734
- type InputInfo = {
735
- isRequired?: boolean;
736
- type?: string;
737
- };
738
-
739
883
  declare const narration: NarrationManagerInterface;
740
884
 
741
- export { type ChoiceInterface, type ChoiceOptionInterface, type CloseChoiceOptionInterface, DialogueInterface, HistoryStep, type InputInfo, Label, LabelAbstract, LabelIdType, type LabelProps, LabelRunModeType, type LabelSteps, type NarrationGameState, type NarrationManagerInterface, NarrationManagerStatic, OpenedLabel, RegisteredLabels, type StepLabelProps, StepLabelPropsType, type StepLabelResult, StepLabelResultType, StepLabelType, type StoredChoiceInterface, type StoredIndexedChoiceInterface, narration, newChoiceOption, newCloseChoiceOption, newLabel };
885
+ export { type ChoiceInterface, type ChoiceOptionInterface, type CloseChoiceOptionInterface, DialogueInterface, HistoryStep, type InputInfo, Label, LabelAbstract, LabelIdType, type LabelProps, LabelRunModeType, type LabelSteps, type NarrationChoicesInterface, type NarrationGameState, type NarrationInputInterface, type NarrationLabelsInterface, type NarrationManagerInterface, NarrationManagerStatic, type NarrationQueriesInterface, OpenedLabel, RegisteredLabels, type StepLabelProps, StepLabelPropsType, type StepLabelResult, StepLabelResultType, StepLabelType, type StoredChoiceInterface, type StoredIndexedChoiceInterface, narration, newChoiceOption, newCloseChoiceOption, newLabel };