@drincs/pixi-vn
Version:
Pixi'VN is a npm package that provides various features for creating visual novels.
2 lines • 40.4 kB
JavaScript
var St=Object.create;var Ue=Object.defineProperty;var vt=Object.getOwnPropertyDescriptor;var wt=Object.getOwnPropertyNames;var Et=Object.getPrototypeOf,_t=Object.prototype.hasOwnProperty;var ot=f=>{throw TypeError(f)};var Dt=(f,e,t)=>e in f?Ue(f,e,{enumerable:true,configurable:true,writable:true,value:t}):f[e]=t;var At=(f,e)=>()=>(e||f((e={exports:{}}).exports,e),e.exports);var Ht=(f,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of wt(e))!_t.call(f,n)&&n!==t&&Ue(f,n,{get:()=>e[n],enumerable:!(r=vt(e,n))||r.enumerable});return f};var Ot=(f,e,t)=>(t=f!=null?St(Et(f)):{},Ht(Ue(t,"default",{value:f,enumerable:true}),f));var S=(f,e,t)=>Dt(f,typeof e!="symbol"?e+"":e,t),Ye=(f,e,t)=>e.has(f)||ot("Cannot "+t);var i=(f,e,t)=>(Ye(f,e,"read from private field"),t?t.call(f):e.get(f)),O=(f,e,t)=>e.has(f)?ot("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(f):e.set(f,t),b=(f,e,t,r)=>(Ye(f,e,"write to private field"),e.set(f,t),t),c=(f,e,t)=>(Ye(f,e,"access private method"),t);var Re=(f,e,t,r)=>({set _(n){b(f,e,n);},get _(){return i(f,e,r)}});var lt=At((Je,at)=>{(function(f,e){var t=e(f);if(typeof define=="function"&&define.amd)define("DeepDiff",function(){return t});else if(typeof Je=="object"||typeof navigator=="object"&&navigator.product.match(/ReactNative/i))at.exports=t;else {var r=f.DeepDiff;t.noConflict=function(){return f.DeepDiff===t&&(f.DeepDiff=r),t},f.DeepDiff=t;}})(Je,function(f){var e=["N","E","A","D"];function t(l,h){l.super_=h,l.prototype=Object.create(h.prototype,{constructor:{value:l,enumerable:false,writable:true,configurable:true}});}function r(l,h){Object.defineProperty(this,"kind",{value:l,enumerable:true}),h&&h.length&&Object.defineProperty(this,"path",{value:h,enumerable:true});}function n(l,h,o){n.super_.call(this,"E",l),Object.defineProperty(this,"lhs",{value:h,enumerable:true}),Object.defineProperty(this,"rhs",{value:o,enumerable:true});}t(n,r);function s(l,h){s.super_.call(this,"N",l),Object.defineProperty(this,"rhs",{value:h,enumerable:true});}t(s,r);function a(l,h){a.super_.call(this,"D",l),Object.defineProperty(this,"lhs",{value:h,enumerable:true});}t(a,r);function m(l,h,o){m.super_.call(this,"A",l),Object.defineProperty(this,"index",{value:h,enumerable:true}),Object.defineProperty(this,"item",{value:o,enumerable:true});}t(m,r);function p(l,h,o){var d=l.slice((h)+1||l.length);return l.length=h<0?l.length+h:h,l.push.apply(l,d),l}function D(l){var h=typeof l;return h!=="object"?h:l===Math?"math":l===null?"null":Array.isArray(l)?"array":Object.prototype.toString.call(l)==="[object Date]"?"date":typeof l.toString=="function"&&/^\/.*\//.test(l.toString())?"regexp":"object"}function C(l){var h=0;if(l.length===0)return h;for(var o=0;o<l.length;o++){var d=l.charCodeAt(o);h=(h<<5)-h+d,h=h&h;}return h}function _(l){var h=0,o=D(l);if(o==="array"){l.forEach(function(Se){h+=_(Se);});var d="[type: array, hash: "+h+"]";return h+C(d)}if(o==="object"){for(var y in l)if(l.hasOwnProperty(y)){var x="[ type: object, key: "+y+", value hash: "+_(l[y])+"]";h+=C(x);}return h}var H="[ type: "+o+" ; value: "+l+"]";return h+C(H)}function G(l,h,o,d,y,x,H,Se){o=o||[],y=y||[],H=H||[];var K=y.slice(0);if(typeof x<"u"&&x!==null){if(d){if(typeof d=="function"&&d(K,x))return;if(typeof d=="object"){if(d.prefilter&&d.prefilter(K,x))return;if(d.normalize){var We=d.normalize(K,x,l,h);We&&(l=We[0],h=We[1]);}}}K.push(x);}D(l)==="regexp"&&D(h)==="regexp"&&(l=l.toString(),h=h.toString());var Ke=typeof l,bt=typeof h,N,Te,ee,ze,rt=Ke!=="undefined"||H&&H.length>0&&H[H.length-1].lhs&&Object.getOwnPropertyDescriptor(H[H.length-1].lhs,x),nt=bt!=="undefined"||H&&H.length>0&&H[H.length-1].rhs&&Object.getOwnPropertyDescriptor(H[H.length-1].rhs,x);if(!rt&&nt)o.push(new s(K,h));else if(!nt&&rt)o.push(new a(K,l));else if(D(l)!==D(h))o.push(new n(K,l,h));else if(D(l)==="date"&&l-h!==0)o.push(new n(K,l,h));else if(Ke==="object"&&l!==null&&h!==null){for(N=H.length-1;N>-1;--N)if(H[N].lhs===l){ze=true;break}if(ze)l!==h&&o.push(new n(K,l,h));else {if(H.push({lhs:l,rhs:h}),Array.isArray(l)){for(Se&&(l.sort(function(Be,$e){return _(Be)-_($e)}),h.sort(function(Be,$e){return _(Be)-_($e)})),N=h.length-1,Te=l.length-1;N>Te;)o.push(new m(K,N,new s(void 0,h[N--])));for(;Te>N;)o.push(new m(K,Te,new a(void 0,l[Te--])));for(;N>=0;--N)G(l[N],h[N],o,d,K,N,H,Se);}else {var st=Object.keys(l),Le=Object.keys(h);for(N=0;N<st.length;++N)ee=st[N],ze=Le.indexOf(ee),ze>=0?(G(l[ee],h[ee],o,d,K,ee,H,Se),Le[ze]=null):G(l[ee],void 0,o,d,K,ee,H,Se);for(N=0;N<Le.length;++N)ee=Le[N],ee&&G(void 0,h[ee],o,d,K,ee,H,Se);}H.length=H.length-1;}}else l!==h&&(Ke==="number"&&isNaN(l)&&isNaN(h)||o.push(new n(K,l,h)));}function j(l,h,o,d,y){var x=[];if(G(l,h,x,d,null,null,null,y),o)for(var H=0;H<x.length;++H)o(x[H]);return x}function Z(l,h,o,d,y,x,H){return G(l,h,o,d,y,x,H,true)}function T(l,h,o,d){var y=d?function(H){H&&d.push(H);}:void 0,x=j(l,h,y,o);return d||(x.length?x:void 0)}function z(l,h,o,d){var y=d?function(H){H&&d.push(H);}:void 0,x=j(l,h,y,o,true);return d||(x.length?x:void 0)}function w(l,h,o){if(o.path&&o.path.length){var d=l[h],y,x=o.path.length-1;for(y=0;y<x;y++)d=d[o.path[y]];switch(o.kind){case "A":w(d[o.path[y]],o.index,o.item);break;case "D":delete d[o.path[y]];break;case "E":case "N":d[o.path[y]]=o.rhs;break}}else switch(o.kind){case "A":w(l[h],o.index,o.item);break;case "D":l=p(l,h);break;case "E":case "N":l[h]=o.rhs;break}return l}function W(l,h,o){if(typeof o>"u"&&h&&~e.indexOf(h.kind)&&(o=h),l&&o&&o.kind){for(var d=l,y=-1,x=o.path?o.path.length-1:0;++y<x;)typeof d[o.path[y]]>"u"&&(d[o.path[y]]=typeof o.path[y+1]<"u"&&typeof o.path[y+1]=="number"?[]:{}),d=d[o.path[y]];switch(o.kind){case "A":o.path&&typeof d[o.path[y]]>"u"&&(d[o.path[y]]=[]),w(o.path?d[o.path[y]]:d,o.index,o.item);break;case "D":delete d[o.path[y]];break;case "E":case "N":d[o.path[y]]=o.rhs;break}}}function k(l,h,o){if(o.path&&o.path.length){var d=l[h],y,x=o.path.length-1;for(y=0;y<x;y++)d=d[o.path[y]];switch(o.kind){case "A":k(d[o.path[y]],o.index,o.item);break;case "D":d[o.path[y]]=o.lhs;break;case "E":d[o.path[y]]=o.lhs;break;case "N":delete d[o.path[y]];break}}else switch(o.kind){case "A":k(l[h],o.index,o.item);break;case "D":l[h]=o.lhs;break;case "E":l[h]=o.lhs;break;case "N":l=p(l,h);break}return l}function L(l,h,o){if(l&&h&&o&&o.kind){var d=l,y,x;for(x=o.path.length-1,y=0;y<x;y++)typeof d[o.path[y]]>"u"&&(d[o.path[y]]={}),d=d[o.path[y]];switch(o.kind){case "A":k(d[o.path[y]],o.index,o.item);break;case "D":d[o.path[y]]=o.lhs;break;case "E":d[o.path[y]]=o.lhs;break;case "N":delete d[o.path[y]];break}}}function Y(l,h,o){if(l&&h){var d=function(y){(!o||o(l,h,y))&&W(l,h,y);};j(l,h,d);}}return Object.defineProperties(T,{diff:{value:T,enumerable:true},orderIndependentDiff:{value:z,enumerable:true},observableDiff:{value:j,enumerable:true},orderIndependentObservableDiff:{value:Z,enumerable:true},orderIndepHash:{value:_,enumerable:true},applyDiff:{value:Y,enumerable:true},applyChange:{value:W,enumerable:true},revertChange:{value:L,enumerable:true},isConflict:{value:function(){return typeof $conflict<"u"},enumerable:true}}),T.DeepDiff=T,f&&(f.DeepDiff=T),T});});var gt=Ot(lt());var A;(n=>(n.log=(s,...a)=>console.log(`[Pixi\u2019VN] ${s}`,...a),n.warn=(s,...a)=>console.warn(`[Pixi\u2019VN] ${s}`,...a),n.error=(s,...a)=>console.error(`[Pixi\u2019VN] ${s}`,...a),n.info=(s,...a)=>console.info(`[Pixi\u2019VN] ${s}`,...a)))(A||(A={}));var v=class v{static init(e){v._getStepCounter=e.getStepCounter,v._setStepCounter=e.setStepCounter,v._getCurrentGameStepState=e.getCurrentGameStepState,v._restoreGameStepState=e.restoreGameStepState,v._getOpenedLabels=e.getOpenedLabels,e.onGoNextEnd&&(v._onGoNextEnd=e.onGoNextEnd),v._getVariable=e.getVariable,v._setVariable=e.setVariable,v._removeVariable=e.removeVariable,v._getFlag=e.getFlag,v._setFlag=e.setFlag,e.onLabelClosing&&(v._onLabelClosing=e.onLabelClosing),v._addHistoryItem=e.addHistoryItem,v._getCurrentStepsRunningNumber=e.getCurrentStepsRunningNumber,v._getCharacter=e.getCharacter;}static get stepCounter(){return v._getStepCounter()}static set stepCounter(e){v._setStepCounter(e);}static get currentGameStepState(){return v._getCurrentGameStepState()}static get restoreGameStepState(){return v._restoreGameStepState}static get openedLabels(){return v._getOpenedLabels()}static get onGoNextEnd(){return v._onGoNextEnd}static get getVariable(){return v._getVariable}static get setVariable(){return v._setVariable}static get removeVariable(){return v._removeVariable}static get getFlag(){return v._getFlag}static get setFlag(){return v._setFlag}static get onLabelClosing(){return v._onLabelClosing}static get addHistoryItem(){return v._addHistoryItem}static get currentStepsRunningNumber(){return v._getCurrentStepsRunningNumber()}static get getCharacter(){return v._getCharacter}};S(v,"_getStepCounter",()=>{throw A.error("Method not implemented, you should initialize the Game: Game.init()"),new Error("Method not implemented, you should initialize the Game: Game.init()")}),S(v,"_setStepCounter",()=>{throw A.error("Method not implemented, you should initialize the Game: Game.init()"),new Error("Method not implemented, you should initialize the Game: Game.init()")}),S(v,"_getCurrentGameStepState",()=>{throw A.error("Method not implemented, you should initialize the Game: Game.init()"),new Error("Method not implemented, you should initialize the Game: Game.init()")}),S(v,"_restoreGameStepState",()=>{throw A.error("Method not implemented, you should initialize the Game: Game.init()"),new Error("Method not implemented, you should initialize the Game: Game.init()")}),S(v,"_getOpenedLabels",()=>{throw A.error("Method not implemented, you should initialize the Game: Game.init()"),new Error("Method not implemented, you should initialize the Game: Game.init()")}),S(v,"_onGoNextEnd",async()=>{}),S(v,"_getVariable",()=>{throw A.error("Method not implemented, you should initialize the Game: Game.init()"),new Error("Method not implemented, you should initialize the Game: Game.init()")}),S(v,"_setVariable",()=>{throw A.error("Method not implemented, you should initialize the Game: Game.init()"),new Error("Method not implemented, you should initialize the Game: Game.init()")}),S(v,"_removeVariable",()=>{throw A.error("Method not implemented, you should initialize the Game: Game.init()"),new Error("Method not implemented, you should initialize the Game: Game.init()")}),S(v,"_getFlag",()=>{throw A.error("Method not implemented, you should initialize the Game: Game.init()"),new Error("Method not implemented, you should initialize the Game: Game.init()")}),S(v,"_setFlag",()=>{throw A.error("Method not implemented, you should initialize the Game: Game.init()"),new Error("Method not implemented, you should initialize the Game: Game.init()")}),S(v,"_onLabelClosing",()=>{}),S(v,"_addHistoryItem",()=>{throw A.error("Method not implemented, you should initialize the Game: Game.init()"),new Error("Method not implemented, you should initialize the Game: Game.init()")}),S(v,"_getCurrentStepsRunningNumber",()=>{throw A.error("Method not implemented, you should initialize the Game: Game.init()"),new Error("Method not implemented, you should initialize the Game: Game.init()")}),S(v,"_getCharacter",()=>{throw A.error("Method not implemented, you should initialize the Game: Game.init()"),new Error("Method not implemented.")}),S(v,"onEnd"),S(v,"onError");var fe=v;function ue(f){try{if(typeof f>"u")return f;let e=JSON.stringify(f);return JSON.parse(e)}catch(e){throw A.error("Error creating exportable element",f,e),new Error("[Pixi\u2019VN] Error creating exportable element")}}function ht(f,e){let t=ue(f);return e.length>1&&"type"in e[0]&&(e=e.reverse()),e.forEach(r=>{"type"in r?xt(t,r):Ct(t,r);}),t}function xt(f,e){let t=f;e.path&&e.path.length>0?e.path.forEach((r,n)=>{if(e.path&&n===e.path.length-1)switch(e.type){case "CHANGE":case "REMOVE":t[r]=e.oldValue;break;case "CREATE":Array.isArray(t)&&typeof r=="number"?t.splice(r,1):delete t[r];break}else t=t[r];}):A.warn("No path found, skipping diff",e);}function Ct(f,e){let t=f;e.path&&e.path.length>0?e.path.forEach((r,n)=>{if(e.path&&n===e.path.length-1){if(e.kind==="E"||e.kind==="D")t[r]=e.lhs;else if(e.kind==="N")Number.isInteger(r)?Array.isArray(t)&&t.splice(r,1):typeof r=="string"&&delete t[r];else if(e.kind==="A"){let s=e.index;e.item.kind==="N"?t[r].splice(s,1):e.item.kind==="E"||e.item.kind==="D"?t[r][s]=e.item.lhs:e.item.kind==="A"?A.warn("Nested array found, skipping diff",e):A.warn("No array found, skipping diff",e);}}else t=t[r];}):A.warn("No path found, skipping diff",e);}var De=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,ct=new Set,qe=typeof process=="object"&&process?process:{},pt=(f,e,t,r)=>{typeof qe.emitWarning=="function"?qe.emitWarning(f,e,t,r):console.error(`[${t}] ${e}: ${f}`);},Pe=globalThis.AbortController,ft=globalThis.AbortSignal;if(typeof Pe>"u"){ft=class{constructor(){S(this,"onabort");S(this,"_onabort",[]);S(this,"reason");S(this,"aborted",false);}addEventListener(r,n){this._onabort.push(n);}},Pe=class{constructor(){S(this,"signal",new ft);e();}abort(r){if(!this.signal.aborted){this.signal.reason=r,this.signal.aborted=true;for(let n of this.signal._onabort)n(r);this.signal.onabort?.(r);}}};let f=qe.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",e=()=>{f&&(f=false,pt("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 Gt=f=>!ct.has(f),ce=f=>f&&f===Math.floor(f)&&f>0&&isFinite(f),mt=f=>ce(f)?f<=Math.pow(2,8)?Uint8Array:f<=Math.pow(2,16)?Uint16Array:f<=Math.pow(2,32)?Uint32Array:f<=Number.MAX_SAFE_INTEGER?Ae:null:null,Ae=class extends Array{constructor(e){super(e),this.fill(0);}},He,ve=class ve{constructor(e,t){S(this,"heap");S(this,"length");if(!i(ve,He))throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new t(e),this.length=0;}static create(e){let t=mt(e);if(!t)return [];b(ve,He,true);let r=new ve(e,t);return b(ve,He,false),r}push(e){this.heap[this.length++]=e;}pop(){return this.heap[--this.length]}};He=new WeakMap,O(ve,He,false);var Xe=ve,ut,dt,te,J,ie,we,re,Oe,xe,R,ne,F,M,E,$,q,B,V,se,P,oe,ae,X,le,ge,U,Ce,u,Qe,Ee,de,Me,Q,yt,_e,Ge,Ne,pe,me,Ze,ke,Ve,I,et,Ie,ye,tt,it=class it{constructor(e){O(this,u);O(this,te);O(this,J);O(this,ie);O(this,we);O(this,re);O(this,Oe);O(this,xe);S(this,"ttl");S(this,"ttlResolution");S(this,"ttlAutopurge");S(this,"updateAgeOnGet");S(this,"updateAgeOnHas");S(this,"allowStale");S(this,"noDisposeOnSet");S(this,"noUpdateTTL");S(this,"maxEntrySize");S(this,"sizeCalculation");S(this,"noDeleteOnFetchRejection");S(this,"noDeleteOnStaleGet");S(this,"allowStaleOnFetchAbort");S(this,"allowStaleOnFetchRejection");S(this,"ignoreFetchAbort");O(this,R);O(this,ne);O(this,F);O(this,M);O(this,E);O(this,$);O(this,q);O(this,B);O(this,V);O(this,se);O(this,P);O(this,oe);O(this,ae);O(this,X);O(this,le);O(this,ge);O(this,U);O(this,Ce);O(this,Ee,()=>{});O(this,de,()=>{});O(this,Me,()=>{});O(this,Q,()=>false);O(this,_e,e=>{});O(this,Ge,(e,t,r)=>{});O(this,Ne,(e,t,r,n)=>{if(r||n)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0});S(this,ut,"LRUCache");let{max:t=0,ttl:r,ttlResolution:n=1,ttlAutopurge:s,updateAgeOnGet:a,updateAgeOnHas:m,allowStale:p,dispose:D,onInsert:C,disposeAfter:_,noDisposeOnSet:G,noUpdateTTL:j,maxSize:Z=0,maxEntrySize:T=0,sizeCalculation:z,fetchMethod:w,memoMethod:W,noDeleteOnFetchRejection:k,noDeleteOnStaleGet:L,allowStaleOnFetchRejection:Y,allowStaleOnFetchAbort:l,ignoreFetchAbort:h}=e;if(t!==0&&!ce(t))throw new TypeError("max option must be a nonnegative integer");let o=t?mt(t):Array;if(!o)throw new Error("invalid max value: "+t);if(b(this,te,t),b(this,J,Z),this.maxEntrySize=T||i(this,J),this.sizeCalculation=z,this.sizeCalculation){if(!i(this,J)&&!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(W!==void 0&&typeof W!="function")throw new TypeError("memoMethod must be a function if defined");if(b(this,xe,W),w!==void 0&&typeof w!="function")throw new TypeError("fetchMethod must be a function if specified");if(b(this,Oe,w),b(this,ge,!!w),b(this,F,new Map),b(this,M,new Array(t).fill(void 0)),b(this,E,new Array(t).fill(void 0)),b(this,$,new o(t)),b(this,q,new o(t)),b(this,B,0),b(this,V,0),b(this,se,Xe.create(t)),b(this,R,0),b(this,ne,0),typeof D=="function"&&b(this,ie,D),typeof C=="function"&&b(this,we,C),typeof _=="function"?(b(this,re,_),b(this,P,[])):(b(this,re,void 0),b(this,P,void 0)),b(this,le,!!i(this,ie)),b(this,Ce,!!i(this,we)),b(this,U,!!i(this,re)),this.noDisposeOnSet=!!G,this.noUpdateTTL=!!j,this.noDeleteOnFetchRejection=!!k,this.allowStaleOnFetchRejection=!!Y,this.allowStaleOnFetchAbort=!!l,this.ignoreFetchAbort=!!h,this.maxEntrySize!==0){if(i(this,J)!==0&&!ce(i(this,J)))throw new TypeError("maxSize must be a positive integer if specified");if(!ce(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");c(this,u,yt).call(this);}if(this.allowStale=!!p,this.noDeleteOnStaleGet=!!L,this.updateAgeOnGet=!!a,this.updateAgeOnHas=!!m,this.ttlResolution=ce(n)||n===0?n:1,this.ttlAutopurge=!!s,this.ttl=r||0,this.ttl){if(!ce(this.ttl))throw new TypeError("ttl must be a positive integer if specified");c(this,u,Qe).call(this);}if(i(this,te)===0&&this.ttl===0&&i(this,J)===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!i(this,te)&&!i(this,J)){let d="LRU_CACHE_UNBOUNDED";Gt(d)&&(ct.add(d),pt("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",d,it));}}static unsafeExposeInternals(e){return {starts:i(e,ae),ttls:i(e,X),sizes:i(e,oe),keyMap:i(e,F),keyList:i(e,M),valList:i(e,E),next:i(e,$),prev:i(e,q),get head(){return i(e,B)},get tail(){return i(e,V)},free:i(e,se),isBackgroundFetch:t=>{var r;return c(r=e,u,I).call(r,t)},backgroundFetch:(t,r,n,s)=>{var a;return c(a=e,u,Ve).call(a,t,r,n,s)},moveToTail:t=>{var r;return c(r=e,u,Ie).call(r,t)},indexes:t=>{var r;return c(r=e,u,pe).call(r,t)},rindexes:t=>{var r;return c(r=e,u,me).call(r,t)},isStale:t=>{var r;return i(r=e,Q).call(r,t)}}}get max(){return i(this,te)}get maxSize(){return i(this,J)}get calculatedSize(){return i(this,ne)}get size(){return i(this,R)}get fetchMethod(){return i(this,Oe)}get memoMethod(){return i(this,xe)}get dispose(){return i(this,ie)}get onInsert(){return i(this,we)}get disposeAfter(){return i(this,re)}getRemainingTTL(e){return i(this,F).has(e)?1/0:0}*entries(){for(let e of c(this,u,pe).call(this))i(this,E)[e]!==void 0&&i(this,M)[e]!==void 0&&!c(this,u,I).call(this,i(this,E)[e])&&(yield [i(this,M)[e],i(this,E)[e]]);}*rentries(){for(let e of c(this,u,me).call(this))i(this,E)[e]!==void 0&&i(this,M)[e]!==void 0&&!c(this,u,I).call(this,i(this,E)[e])&&(yield [i(this,M)[e],i(this,E)[e]]);}*keys(){for(let e of c(this,u,pe).call(this)){let t=i(this,M)[e];t!==void 0&&!c(this,u,I).call(this,i(this,E)[e])&&(yield t);}}*rkeys(){for(let e of c(this,u,me).call(this)){let t=i(this,M)[e];t!==void 0&&!c(this,u,I).call(this,i(this,E)[e])&&(yield t);}}*values(){for(let e of c(this,u,pe).call(this))i(this,E)[e]!==void 0&&!c(this,u,I).call(this,i(this,E)[e])&&(yield i(this,E)[e]);}*rvalues(){for(let e of c(this,u,me).call(this))i(this,E)[e]!==void 0&&!c(this,u,I).call(this,i(this,E)[e])&&(yield i(this,E)[e]);}[(dt=Symbol.iterator,ut=Symbol.toStringTag,dt)](){return this.entries()}find(e,t={}){for(let r of c(this,u,pe).call(this)){let n=i(this,E)[r],s=c(this,u,I).call(this,n)?n.__staleWhileFetching:n;if(s!==void 0&&e(s,i(this,M)[r],this))return this.get(i(this,M)[r],t)}}forEach(e,t=this){for(let r of c(this,u,pe).call(this)){let n=i(this,E)[r],s=c(this,u,I).call(this,n)?n.__staleWhileFetching:n;s!==void 0&&e.call(t,s,i(this,M)[r],this);}}rforEach(e,t=this){for(let r of c(this,u,me).call(this)){let n=i(this,E)[r],s=c(this,u,I).call(this,n)?n.__staleWhileFetching:n;s!==void 0&&e.call(t,s,i(this,M)[r],this);}}purgeStale(){let e=false;for(let t of c(this,u,me).call(this,{allowStale:true}))i(this,Q).call(this,t)&&(c(this,u,ye).call(this,i(this,M)[t],"expire"),e=true);return e}info(e){let t=i(this,F).get(e);if(t===void 0)return;let r=i(this,E)[t],n=c(this,u,I).call(this,r)?r.__staleWhileFetching:r;if(n===void 0)return;let s={value:n};if(i(this,X)&&i(this,ae)){let a=i(this,X)[t],m=i(this,ae)[t];if(a&&m){let p=a-(De.now()-m);s.ttl=p,s.start=Date.now();}}return i(this,oe)&&(s.size=i(this,oe)[t]),s}dump(){let e=[];for(let t of c(this,u,pe).call(this,{allowStale:true})){let r=i(this,M)[t],n=i(this,E)[t],s=c(this,u,I).call(this,n)?n.__staleWhileFetching:n;if(s===void 0||r===void 0)continue;let a={value:s};if(i(this,X)&&i(this,ae)){a.ttl=i(this,X)[t];let m=De.now()-i(this,ae)[t];a.start=Math.floor(Date.now()-m);}i(this,oe)&&(a.size=i(this,oe)[t]),e.unshift([r,a]);}return e}load(e){this.clear();for(let[t,r]of e){if(r.start){let n=Date.now()-r.start;r.start=De.now()-n;}this.set(t,r.value,r);}}set(e,t,r={}){var G,j,Z,T;if(t===void 0)return this.delete(e),this;let{ttl:n=this.ttl,start:s,noDisposeOnSet:a=this.noDisposeOnSet,sizeCalculation:m=this.sizeCalculation,status:p}=r,{noUpdateTTL:D=this.noUpdateTTL}=r,C=i(this,Ne).call(this,e,t,r.size||0,m);if(this.maxEntrySize&&C>this.maxEntrySize)return p&&(p.set="miss",p.maxEntrySizeExceeded=true),c(this,u,ye).call(this,e,"set"),this;let _=i(this,R)===0?void 0:i(this,F).get(e);if(_===void 0)_=i(this,R)===0?i(this,V):i(this,se).length!==0?i(this,se).pop():i(this,R)===i(this,te)?c(this,u,ke).call(this,false):i(this,R),i(this,M)[_]=e,i(this,E)[_]=t,i(this,F).set(e,_),i(this,$)[i(this,V)]=_,i(this,q)[_]=i(this,V),b(this,V,_),Re(this,R)._++,i(this,Ge).call(this,_,C,p),p&&(p.set="add"),D=false,i(this,Ce)&&((G=i(this,we))==null||G.call(this,t,e,"add"));else {c(this,u,Ie).call(this,_);let z=i(this,E)[_];if(t!==z){if(i(this,ge)&&c(this,u,I).call(this,z)){z.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:w}=z;w!==void 0&&!a&&(i(this,le)&&((j=i(this,ie))==null||j.call(this,w,e,"set")),i(this,U)&&i(this,P)?.push([w,e,"set"]));}else a||(i(this,le)&&((Z=i(this,ie))==null||Z.call(this,z,e,"set")),i(this,U)&&i(this,P)?.push([z,e,"set"]));if(i(this,_e).call(this,_),i(this,Ge).call(this,_,C,p),i(this,E)[_]=t,p){p.set="replace";let w=z&&c(this,u,I).call(this,z)?z.__staleWhileFetching:z;w!==void 0&&(p.oldValue=w);}}else p&&(p.set="update");i(this,Ce)&&this.onInsert?.(t,e,t===z?"update":"replace");}if(n!==0&&!i(this,X)&&c(this,u,Qe).call(this),i(this,X)&&(D||i(this,Me).call(this,_,n,s),p&&i(this,de).call(this,p,_)),!a&&i(this,U)&&i(this,P)){let z=i(this,P),w;for(;w=z?.shift();)(T=i(this,re))==null||T.call(this,...w);}return this}pop(){var e;try{for(;i(this,R);){let t=i(this,E)[i(this,B)];if(c(this,u,ke).call(this,!0),c(this,u,I).call(this,t)){if(t.__staleWhileFetching)return t.__staleWhileFetching}else if(t!==void 0)return t}}finally{if(i(this,U)&&i(this,P)){let t=i(this,P),r;for(;r=t?.shift();)(e=i(this,re))==null||e.call(this,...r);}}}has(e,t={}){let{updateAgeOnHas:r=this.updateAgeOnHas,status:n}=t,s=i(this,F).get(e);if(s!==void 0){let a=i(this,E)[s];if(c(this,u,I).call(this,a)&&a.__staleWhileFetching===void 0)return false;if(i(this,Q).call(this,s))n&&(n.has="stale",i(this,de).call(this,n,s));else return r&&i(this,Ee).call(this,s),n&&(n.has="hit",i(this,de).call(this,n,s)),true}else n&&(n.has="miss");return false}peek(e,t={}){let{allowStale:r=this.allowStale}=t,n=i(this,F).get(e);if(n===void 0||!r&&i(this,Q).call(this,n))return;let s=i(this,E)[n];return c(this,u,I).call(this,s)?s.__staleWhileFetching:s}async fetch(e,t={}){let{allowStale:r=this.allowStale,updateAgeOnGet:n=this.updateAgeOnGet,noDeleteOnStaleGet:s=this.noDeleteOnStaleGet,ttl:a=this.ttl,noDisposeOnSet:m=this.noDisposeOnSet,size:p=0,sizeCalculation:D=this.sizeCalculation,noUpdateTTL:C=this.noUpdateTTL,noDeleteOnFetchRejection:_=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:G=this.allowStaleOnFetchRejection,ignoreFetchAbort:j=this.ignoreFetchAbort,allowStaleOnFetchAbort:Z=this.allowStaleOnFetchAbort,context:T,forceRefresh:z=false,status:w,signal:W}=t;if(!i(this,ge))return w&&(w.fetch="get"),this.get(e,{allowStale:r,updateAgeOnGet:n,noDeleteOnStaleGet:s,status:w});let k={allowStale:r,updateAgeOnGet:n,noDeleteOnStaleGet:s,ttl:a,noDisposeOnSet:m,size:p,sizeCalculation:D,noUpdateTTL:C,noDeleteOnFetchRejection:_,allowStaleOnFetchRejection:G,allowStaleOnFetchAbort:Z,ignoreFetchAbort:j,status:w,signal:W},L=i(this,F).get(e);if(L===void 0){w&&(w.fetch="miss");let Y=c(this,u,Ve).call(this,e,L,k,T);return Y.__returned=Y}else {let Y=i(this,E)[L];if(c(this,u,I).call(this,Y)){let y=r&&Y.__staleWhileFetching!==void 0;return w&&(w.fetch="inflight",y&&(w.returnedStale=true)),y?Y.__staleWhileFetching:Y.__returned=Y}let l=i(this,Q).call(this,L);if(!z&&!l)return w&&(w.fetch="hit"),c(this,u,Ie).call(this,L),n&&i(this,Ee).call(this,L),w&&i(this,de).call(this,w,L),Y;let h=c(this,u,Ve).call(this,e,L,k,T),d=h.__staleWhileFetching!==void 0&&r;return w&&(w.fetch=l?"stale":"refresh",d&&l&&(w.returnedStale=true)),d?h.__staleWhileFetching:h.__returned=h}}async forceFetch(e,t={}){let r=await this.fetch(e,t);if(r===void 0)throw new Error("fetch() returned undefined");return r}memo(e,t={}){let r=i(this,xe);if(!r)throw new Error("no memoMethod provided to constructor");let{context:n,forceRefresh:s,...a}=t,m=this.get(e,a);if(!s&&m!==void 0)return m;let p=r(e,m,{options:a,context:n});return this.set(e,p,a),p}get(e,t={}){let{allowStale:r=this.allowStale,updateAgeOnGet:n=this.updateAgeOnGet,noDeleteOnStaleGet:s=this.noDeleteOnStaleGet,status:a}=t,m=i(this,F).get(e);if(m!==void 0){let p=i(this,E)[m],D=c(this,u,I).call(this,p);return a&&i(this,de).call(this,a,m),i(this,Q).call(this,m)?(a&&(a.get="stale"),D?(a&&r&&p.__staleWhileFetching!==void 0&&(a.returnedStale=true),r?p.__staleWhileFetching:void 0):(s||c(this,u,ye).call(this,e,"expire"),a&&r&&(a.returnedStale=true),r?p:void 0)):(a&&(a.get="hit"),D?p.__staleWhileFetching:(c(this,u,Ie).call(this,m),n&&i(this,Ee).call(this,m),p))}else a&&(a.get="miss");}delete(e){return c(this,u,ye).call(this,e,"delete")}clear(){return c(this,u,tt).call(this,"delete")}};te=new WeakMap,J=new WeakMap,ie=new WeakMap,we=new WeakMap,re=new WeakMap,Oe=new WeakMap,xe=new WeakMap,R=new WeakMap,ne=new WeakMap,F=new WeakMap,M=new WeakMap,E=new WeakMap,$=new WeakMap,q=new WeakMap,B=new WeakMap,V=new WeakMap,se=new WeakMap,P=new WeakMap,oe=new WeakMap,ae=new WeakMap,X=new WeakMap,le=new WeakMap,ge=new WeakMap,U=new WeakMap,Ce=new WeakMap,u=new WeakSet,Qe=function(){let e=new Ae(i(this,te)),t=new Ae(i(this,te));b(this,X,e),b(this,ae,t),b(this,Me,(s,a,m=De.now())=>{if(t[s]=a!==0?m:0,e[s]=a,a!==0&&this.ttlAutopurge){let p=setTimeout(()=>{i(this,Q).call(this,s)&&c(this,u,ye).call(this,i(this,M)[s],"expire");},a+1);p.unref&&p.unref();}}),b(this,Ee,s=>{t[s]=e[s]!==0?De.now():0;}),b(this,de,(s,a)=>{if(e[a]){let m=e[a],p=t[a];if(!m||!p)return;s.ttl=m,s.start=p,s.now=r||n();let D=s.now-p;s.remainingTTL=m-D;}});let r=0,n=()=>{let s=De.now();if(this.ttlResolution>0){r=s;let a=setTimeout(()=>r=0,this.ttlResolution);a.unref&&a.unref();}return s};this.getRemainingTTL=s=>{let a=i(this,F).get(s);if(a===void 0)return 0;let m=e[a],p=t[a];if(!m||!p)return 1/0;let D=(r||n())-p;return m-D},b(this,Q,s=>{let a=t[s],m=e[s];return !!m&&!!a&&(r||n())-a>m});},Ee=new WeakMap,de=new WeakMap,Me=new WeakMap,Q=new WeakMap,yt=function(){let e=new Ae(i(this,te));b(this,ne,0),b(this,oe,e),b(this,_e,t=>{b(this,ne,i(this,ne)-e[t]),e[t]=0;}),b(this,Ne,(t,r,n,s)=>{if(c(this,u,I).call(this,r))return 0;if(!ce(n))if(s){if(typeof s!="function")throw new TypeError("sizeCalculation must be a function");if(n=s(r,t),!ce(n))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 n}),b(this,Ge,(t,r,n)=>{if(e[t]=r,i(this,J)){let s=i(this,J)-e[t];for(;i(this,ne)>s;)c(this,u,ke).call(this,true);}b(this,ne,i(this,ne)+e[t]),n&&(n.entrySize=r,n.totalCalculatedSize=i(this,ne));});},_e=new WeakMap,Ge=new WeakMap,Ne=new WeakMap,pe=function*({allowStale:e=this.allowStale}={}){if(i(this,R))for(let t=i(this,V);!(!c(this,u,Ze).call(this,t)||((e||!i(this,Q).call(this,t))&&(yield t),t===i(this,B)));)t=i(this,q)[t];},me=function*({allowStale:e=this.allowStale}={}){if(i(this,R))for(let t=i(this,B);!(!c(this,u,Ze).call(this,t)||((e||!i(this,Q).call(this,t))&&(yield t),t===i(this,V)));)t=i(this,$)[t];},Ze=function(e){return e!==void 0&&i(this,F).get(i(this,M)[e])===e},ke=function(e){var s;let t=i(this,B),r=i(this,M)[t],n=i(this,E)[t];return i(this,ge)&&c(this,u,I).call(this,n)?n.__abortController.abort(new Error("evicted")):(i(this,le)||i(this,U))&&(i(this,le)&&((s=i(this,ie))==null||s.call(this,n,r,"evict")),i(this,U)&&i(this,P)?.push([n,r,"evict"])),i(this,_e).call(this,t),e&&(i(this,M)[t]=void 0,i(this,E)[t]=void 0,i(this,se).push(t)),i(this,R)===1?(b(this,B,b(this,V,0)),i(this,se).length=0):b(this,B,i(this,$)[t]),i(this,F).delete(r),Re(this,R)._--,t},Ve=function(e,t,r,n){let s=t===void 0?void 0:i(this,E)[t];if(c(this,u,I).call(this,s))return s;let a=new Pe,{signal:m}=r;m?.addEventListener("abort",()=>a.abort(m.reason),{signal:a.signal});let p={signal:a.signal,options:r,context:n},D=(T,z=false)=>{let{aborted:w}=a.signal,W=r.ignoreFetchAbort&&T!==void 0;if(r.status&&(w&&!z?(r.status.fetchAborted=true,r.status.fetchError=a.signal.reason,W&&(r.status.fetchAbortIgnored=true)):r.status.fetchResolved=true),w&&!W&&!z)return _(a.signal.reason);let k=j;return i(this,E)[t]===j&&(T===void 0?k.__staleWhileFetching?i(this,E)[t]=k.__staleWhileFetching:c(this,u,ye).call(this,e,"fetch"):(r.status&&(r.status.fetchUpdated=true),this.set(e,T,p.options))),T},C=T=>(r.status&&(r.status.fetchRejected=true,r.status.fetchError=T),_(T)),_=T=>{let{aborted:z}=a.signal,w=z&&r.allowStaleOnFetchAbort,W=w||r.allowStaleOnFetchRejection,k=W||r.noDeleteOnFetchRejection,L=j;if(i(this,E)[t]===j&&(!k||L.__staleWhileFetching===void 0?c(this,u,ye).call(this,e,"fetch"):w||(i(this,E)[t]=L.__staleWhileFetching)),W)return r.status&&L.__staleWhileFetching!==void 0&&(r.status.returnedStale=true),L.__staleWhileFetching;if(L.__returned===L)throw T},G=(T,z)=>{var W;let w=(W=i(this,Oe))==null?void 0:W.call(this,e,s,p);w&&w instanceof Promise&&w.then(k=>T(k===void 0?void 0:k),z),a.signal.addEventListener("abort",()=>{(!r.ignoreFetchAbort||r.allowStaleOnFetchAbort)&&(T(void 0),r.allowStaleOnFetchAbort&&(T=k=>D(k,true)));});};r.status&&(r.status.fetchDispatched=true);let j=new Promise(G).then(D,C),Z=Object.assign(j,{__abortController:a,__staleWhileFetching:s,__returned:void 0});return t===void 0?(this.set(e,Z,{...p.options,status:void 0}),t=i(this,F).get(e)):i(this,E)[t]=Z,Z},I=function(e){if(!i(this,ge))return false;let t=e;return !!t&&t instanceof Promise&&t.hasOwnProperty("__staleWhileFetching")&&t.__abortController instanceof Pe},et=function(e,t){i(this,q)[t]=e,i(this,$)[e]=t;},Ie=function(e){e!==i(this,V)&&(e===i(this,B)?b(this,B,i(this,$)[e]):c(this,u,et).call(this,i(this,q)[e],i(this,$)[e]),c(this,u,et).call(this,i(this,V),e),b(this,V,e));},ye=function(e,t){var n,s;let r=false;if(i(this,R)!==0){let a=i(this,F).get(e);if(a!==void 0)if(r=true,i(this,R)===1)c(this,u,tt).call(this,t);else {i(this,_e).call(this,a);let m=i(this,E)[a];if(c(this,u,I).call(this,m)?m.__abortController.abort(new Error("deleted")):(i(this,le)||i(this,U))&&(i(this,le)&&((n=i(this,ie))==null||n.call(this,m,e,t)),i(this,U)&&i(this,P)?.push([m,e,t])),i(this,F).delete(e),i(this,M)[a]=void 0,i(this,E)[a]=void 0,a===i(this,V))b(this,V,i(this,q)[a]);else if(a===i(this,B))b(this,B,i(this,$)[a]);else {let p=i(this,q)[a];i(this,$)[p]=i(this,$)[a];let D=i(this,$)[a];i(this,q)[D]=i(this,q)[a];}Re(this,R)._--,i(this,se).push(a);}}if(i(this,U)&&i(this,P)?.length){let a=i(this,P),m;for(;m=a?.shift();)(s=i(this,re))==null||s.call(this,...m);}return r},tt=function(e){var t,r;for(let n of c(this,u,me).call(this,{allowStale:true})){let s=i(this,E)[n];if(c(this,u,I).call(this,s))s.__abortController.abort(new Error("deleted"));else {let a=i(this,M)[n];i(this,le)&&((t=i(this,ie))==null||t.call(this,s,a,e)),i(this,U)&&i(this,P)?.push([s,a,e]);}}if(i(this,F).clear(),i(this,E).fill(void 0),i(this,M).fill(void 0),i(this,X)&&i(this,ae)&&(i(this,X).fill(0),i(this,ae).fill(0)),i(this,oe)&&i(this,oe).fill(0),b(this,B,0),b(this,V,0),i(this,se).length=0,b(this,ne,0),b(this,R,0),i(this,U)&&i(this,P)){let n=i(this,P),s;for(;s=n?.shift();)(r=i(this,re))==null||r.call(this,...s);}};var je=it;var be=class{constructor(e){S(this,"cache");S(this,"map",new Map);this.cache=new je({max:e.cacheSize}),this.map=new Map;}get[Symbol.iterator](){return this.map[Symbol.iterator]}get[Symbol.toStringTag](){return this.map[Symbol.toStringTag]}clear(){return 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 he=class he{static get originalStepData(){return he._originalStepData?ue(he._originalStepData):{path:"",storage:{},canvas:{elementAliasesOrder:[],elements:{},stage:{},tickers:{},tickersSteps:{},tickersOnPause:{},tickersToCompleteOnStepEnd:{tikersIds:[],stepAlias:[]}},sound:{soundAliasesOrder:[],soundsPlaying:{},playInStepIndex:{},filters:void 0},labelIndex:-1,openedLabels:[]}}static set originalStepData(e){he._originalStepData=ue(e);}};S(he,"_diffHistory",new be({cacheSize:5})),S(he,"_stepsInfoHistory",new be({cacheSize:5})),S(he,"_narrationHistory",new be({cacheSize:50})),S(he,"stepLimitSaved",20),S(he,"goBackRunning",false),S(he,"_originalStepData");var g=he;var Fe=class{get stepsInfoMap(){return g._stepsInfoHistory}get diffMap(){return g._diffHistory}get narrationMap(){return g._narrationHistory}get size(){return g._stepsInfoHistory.size}get lastKey(){return this.size===0?null:Math.max(...Array.from(this.keys()))}keys(){return g._stepsInfoHistory.keys()}get(e){let t=g._narrationHistory.get(e);if(!(t&&Object.keys(t).length===1&&t.stepIndex!==void 0))return t}delete(e){g._stepsInfoHistory.delete(e),g._diffHistory.delete(e),g._narrationHistory.delete(e);}internalRestoreOldGameState(e,t){if(e<=0||this.size==0)return t;let r=this.lastKey;if(typeof r!="number")return A.error("You can't go back, there is no step to go back"),t;let n=g._diffHistory.get(r);if(n)try{let s=ht(t,n);return fe.stepCounter=r,this.delete(r),this.internalRestoreOldGameState(e-1,s)}catch(s){return A.error("Error applying diff",s),t}else return A.error("You can't go back, there is no step to go back"),t}async goBack(e,t=1){if(t<=0){A.warn("The parameter steps must be greater than 0");return}if(g._diffHistory.size<1){A.warn("You can't go back, there is no step to go back");return}if(g.goBackRunning){A.warn("Go back is already running");return}g.goBackRunning=true;try{let r=ue(this.internalRestoreOldGameState(t,g.originalStepData));if(r){await fe.restoreGameStepState(r,e);let n=fe.stepCounter-1,s=g._narrationHistory.get(n);if(s&&Object.keys(s).length===1&&s.stepIndex!==void 0){let a=g._stepsInfoHistory.get(n);if(a){let m=this.itemMapper({step:a});g._narrationHistory.set(a.index,m);}}}else A.error("Error going back");g.goBackRunning=!1;}catch(r){A.error("Error going back",r),g.goBackRunning=false;}}add(e,t={}){let r=g.originalStepData,{ignoreSameStep:n}=t,s=fe.currentGameStepState;if(!n&&this.isSameStep(r,s))return;let a=this.lastKey;(async()=>{try{let p,D;if(typeof a=="number"&&(p=g._stepsInfoHistory.get(a),D=g._narrationHistory.get(a)),g._stepsInfoHistory.set(e.index,e),e.index!==0){let G=(0,gt.diff)(r,s);G?g._diffHistory.set(e.index,G):A.warn("It was not possible to create the difference between the two steps");}let C={},_=this.itemMapper({step:e},C);if(g._narrationHistory.set(e.index,_),p&&D&&typeof a=="number"){let G=this.itemMapper({...C,step:p},{});g._narrationHistory.set(a,G);}}catch(p){A.error("Error adding history step",p);}})(),g.originalStepData=s;}itemMapper(e,t){let{step:r,choiceIndexMade:n,inputValue:s,removeDialogue:a}=e,m=r.dialogue||r.dialoge;t&&r.isGlued&&(t.removeDialogue=true),a&&(m=void 0);let p=r.choices;if(t&&r.currentLabel&&r.choiceIndexMade!==void 0&&(t.choiceIndexMade=r.choiceIndexMade),r.inputValue&&t&&(t.inputValue=r.inputValue),m||p||s){let D=p?.map((C,_)=>{let G=false;return C.oneTime&&r.alreadyMadeChoices&&r.alreadyMadeChoices.includes(_)&&(G=true),{text:C.text,type:C.type,isResponse:false,hidden:G}});if(D){if(D.every(C=>C.hidden)){let C=D.find(_=>_.hidden===false);C&&(C.hidden=false);}n!==void 0&&(D[n].isResponse=true);}return {dialogue:m?{...m,character:m.character?fe.getCharacter(m.character)||m.character:void 0}:void 0,playerMadeChoice:typeof n=="number",choices:D,stepIndex:r.index,inputValue:s}}return {stepIndex:r.index}}get narrativeHistory(){let e=[];return Array.from(this.keys()).sort((r,n)=>r-n).forEach(r=>{let n=this.get(r);n&&e.push(n);}),e}get currentLabelHistory(){let e=[],t=Array.from(this.keys()).sort((p,D)=>D-p);if(t.length===0)return e;let r=t[0];if(typeof r!="number")return e;let n=g._stepsInfoHistory.get(r);if(!n)return e;let s=n.openedLabels;if(!s||!Array.isArray(s)||s.length===0)return e;let a=s[0].currentStepIndex,m=s[0].label;return t.every((p,D)=>{let C=this.get(p);if(C){if(D===0)return e.push(C),true;let _=g._stepsInfoHistory.get(p);if(!_)return true;let G=_.openedLabels;if(!G||!Array.isArray(G)||G.length===0||G[0].label!==m||G[0].currentStepIndex>=a)return false;a=G[0].currentStepIndex,e.push(C);}return true}),e.reverse()}removeNarrativeHistory(e){if(e){let t=Array.from(this.keys()).sort((r,n)=>r-n);t=t.slice(0,e),t.forEach(r=>{g._narrationHistory.delete(r),g._stepsInfoHistory.delete(r),g._diffHistory.delete(r);});}else g._stepsInfoHistory.clear(),g._diffHistory.clear(),g._narrationHistory.clear();}get canGoBack(){let e=this.lastKey;return typeof e!="number"?false:g._diffHistory.has(e)}blockGoBack(){fe.currentStepsRunningNumber===0&&g._diffHistory.clear();}isSameStep(e,t){if(e.openedLabels.length===t.openedLabels.length)try{let r=JSON.stringify(e.openedLabels),n=JSON.stringify(t.openedLabels);if(r===n&&e.path===t.path&&e.labelIndex===t.labelIndex)return !0}catch(r){return A.error("Error comparing opened labels",r),true}return false}clear(){g._stepsInfoHistory.clear(),g._diffHistory.clear(),g._narrationHistory.clear(),g._originalStepData=void 0;}get stepLimitSaved(){return g.stepLimitSaved}set stepLimitSaved(e){g.stepLimitSaved=e;}export(){let e=Array.from(this.keys()).sort((r,n)=>r-n);e.length>this.stepLimitSaved&&(e=e.slice(e.length-this.stepLimitSaved));let t=[];return e.forEach(r=>{let n=g._stepsInfoHistory.get(r);if(n){let s=g._diffHistory.get(r);t.push({...n,diff:s});}}),{stepsHistory:ue(t),originalStepData:ue(g._originalStepData)}}restoreNarrativeHistory(){let e=Array.from(this.keys()).sort((r,n)=>r-n),t={};e.forEach(r=>{let n=g._stepsInfoHistory.get(r);if(n){let s={...t};t={};let a=this.itemMapper({step:n,choiceIndexMade:s.choiceIndexMade,inputValue:s.inputValue,removeDialogue:s.removeDialogue},t);a&&g._narrationHistory.set(r,a);}});}async restore(e){this.clear();try{e.hasOwnProperty("stepsHistory")?(e.stepsHistory.forEach(r=>{r.diff&&g._diffHistory.set(r.index,r.diff);let n={...r,diff:void 0};g._stepsInfoHistory.set(r.index,n);}),this.restoreNarrativeHistory()):A.warn("Could not import stepsHistory data, so will be ignored"),e.hasOwnProperty("originalStepData")?g._originalStepData=e.originalStepData:A.warn("Could not import originalStepData data, so will be ignored");}catch(t){A.error("Error importing data",t);}}};var fi=new Fe;
export{g as HistoryManagerStatic,fi as stepHistory};