@drincs/pixi-vn 1.6.4 → 1.7.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +47 -53
- package/dist/canvas.cjs +2 -2
- package/dist/canvas.d.cts +56 -51
- package/dist/canvas.d.ts +56 -51
- package/dist/canvas.mjs +2 -2
- package/dist/characters.cjs +1 -1
- package/dist/characters.mjs +1 -1
- package/dist/chunk-4KCAZKAJ.mjs +1 -0
- package/dist/{chunk-D45QSSXG.mjs → chunk-HNGW4ITF.mjs} +1 -1
- package/dist/{chunk-L4IHQ3VT.mjs → chunk-X4NBVTSJ.mjs} +1 -1
- package/dist/{chunk-ZW3MIPMS.mjs → chunk-YDNEIPJP.mjs} +1 -1
- package/dist/history.cjs +1 -1
- package/dist/history.mjs +1 -1
- package/dist/index.cjs +2 -9
- package/dist/index.d.cts +73 -4
- package/dist/index.d.ts +73 -4
- package/dist/index.mjs +2 -9
- package/dist/motion.cjs +1 -1
- package/dist/motion.d.cts +3 -1
- package/dist/motion.d.ts +3 -1
- package/dist/motion.mjs +1 -1
- package/dist/narration.cjs +2 -2
- package/dist/narration.mjs +2 -2
- package/dist/pixi/browser.js +183 -171
- package/dist/sound.cjs +1 -1
- package/dist/sound.d.cts +74 -14
- package/dist/sound.d.ts +74 -14
- package/dist/sound.mjs +1 -1
- package/dist/storage.cjs +1 -1
- package/dist/storage.d.cts +63 -12
- package/dist/storage.d.ts +63 -12
- package/dist/storage.mjs +1 -1
- package/dist/vite.cjs +1 -1
- package/dist/vite.d.cts +10 -1
- package/dist/vite.d.ts +10 -1
- package/dist/vite.mjs +1 -1
- package/package.json +12 -7
- package/dist/chunk-EWW7VYPM.mjs +0 -1
- /package/dist/{chunk-XSN6P5JL.mjs → chunk-JMOSOAGB.mjs} +0 -0
package/dist/characters.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
'use strict';var core=require('@drincs/pixi-vn/core');var re=Object.defineProperty;var Xt=c=>{throw TypeError(c)};var ae=(c,e,t)=>e in c?re(c,e,{enumerable:true,configurable:true,writable:true,value:t}):c[e]=t;var g=(c,e,t)=>ae(c,typeof e!="symbol"?e+"":e,t),Kt=(c,e,t)=>e.has(c)||Xt("Cannot "+t);var i=(c,e,t)=>(Kt(c,e,"read from private field"),t?t.call(c):e.get(c)),m=(c,e,t)=>e.has(c)?Xt("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(c):e.set(c,t),f=(c,e,t,s)=>(Kt(c,e,"write to private field"),e.set(c,t),t),l=(c,e,t)=>(Kt(c,e,"access private method"),t);var Ft=(c,e,t,s)=>({set _(a){f(c,e,a);},get _(){return i(c,e,s)}});var ot="storage",ft="temp",Gt="flags",V={CHARACTER_CATEGORY_KEY:"character"};var k;(a=>(a.log=(o,...r)=>console.log(`[Pixi\u2019VN] ${o}`,...r),a.warn=(o,...r)=>console.warn(`[Pixi\u2019VN] ${o}`,...r),a.error=(o,...r)=>console.error(`[Pixi\u2019VN] ${o}`,...r),a.info=(o,...r)=>console.info(`[Pixi\u2019VN] ${o}`,...r)))(k||(k={}));function Ct(c){try{if(typeof c>"u")return c;let e=JSON.stringify(c);return JSON.parse(e)}catch(e){throw k.error("Error creating exportable element",c,e),new core.PixiError("not_json_serializable","Error creating exportable element")}}var ne=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,Zt=new Set,Wt=typeof process=="object"&&process?process:{},te=(c,e,t,s)=>{typeof Wt.emitWarning=="function"?Wt.emitWarning(c,e,t,s):console.error(`[${t}] ${e}: ${c}`);},zt=globalThis.AbortController,Jt=globalThis.AbortSignal;if(typeof zt>"u"){Jt=class{constructor(){g(this,"onabort");g(this,"_onabort",[]);g(this,"reason");g(this,"aborted",false);}addEventListener(t,s){this._onabort.push(s);}},zt=class{constructor(){g(this,"signal",new Jt);e();}abort(t){if(!this.signal.aborted){this.signal.reason=t,this.signal.aborted=true;for(let s of this.signal._onabort)s(t);this.signal.onabort?.(t);}}};let c=Wt.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",e=()=>{c&&(c=false,te("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 he=c=>!Zt.has(c);var nt=c=>c&&c===Math.floor(c)&&c>0&&isFinite(c),ee=c=>nt(c)?c<=Math.pow(2,8)?Uint8Array:c<=Math.pow(2,16)?Uint16Array:c<=Math.pow(2,32)?Uint32Array:c<=Number.MAX_SAFE_INTEGER?Lt:null:null,Lt=class extends Array{constructor(c){super(c),this.fill(0);}},it,Et,le=(it=class{constructor(e,t){g(this,"heap");g(this,"length");if(!i(it,Et))throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new t(e),this.length=0;}static create(e){let t=ee(e);if(!t)return [];f(it,Et,true);let s=new it(e,t);return f(it,Et,false),s}push(e){this.heap[this.length++]=e;}pop(){return this.heap[--this.length]}},Et=new WeakMap,m(it,Et,false),it),qt,Qt,$,U,H,dt,B,Tt,bt,X,O,J,w,A,d,M,z,I,R,q,x,Q,Z,P,Y,tt,ut,F,At,n,jt,gt,st,Dt,K,se,pt,yt,Nt,ht,lt,$t,Vt,Ut,b,kt,It,ct,Ht,vt,ie=(vt=class{constructor(e){m(this,n);m(this,$);m(this,U);m(this,H);m(this,dt);m(this,B);m(this,Tt);m(this,bt);m(this,X);g(this,"ttl");g(this,"ttlResolution");g(this,"ttlAutopurge");g(this,"updateAgeOnGet");g(this,"updateAgeOnHas");g(this,"allowStale");g(this,"noDisposeOnSet");g(this,"noUpdateTTL");g(this,"maxEntrySize");g(this,"sizeCalculation");g(this,"noDeleteOnFetchRejection");g(this,"noDeleteOnStaleGet");g(this,"allowStaleOnFetchAbort");g(this,"allowStaleOnFetchRejection");g(this,"ignoreFetchAbort");m(this,O);m(this,J);m(this,w);m(this,A);m(this,d);m(this,M);m(this,z);m(this,I);m(this,R);m(this,q);m(this,x);m(this,Q);m(this,Z);m(this,P);m(this,Y);m(this,tt);m(this,ut);m(this,F);m(this,At);m(this,gt,()=>{});m(this,st,()=>{});m(this,Dt,()=>{});m(this,K,()=>false);m(this,pt,e=>{});m(this,yt,(e,t,s)=>{});m(this,Nt,(e,t,s,a)=>{if(s||a)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0});g(this,qt,"LRUCache");let{max:t=0,ttl:s,ttlResolution:a=1,ttlAutopurge:o,updateAgeOnGet:r,updateAgeOnHas:h,allowStale:u,dispose:S,onInsert:C,disposeAfter:E,noDisposeOnSet:at,noUpdateTTL:W,maxSize:et=0,maxEntrySize:y=0,sizeCalculation:T,fetchMethod:p,memoMethod:D,noDeleteOnFetchRejection:L,noDeleteOnStaleGet:N,allowStaleOnFetchRejection:v,allowStaleOnFetchAbort:xt,ignoreFetchAbort:_t,perf:mt}=e;if(mt!==void 0&&typeof mt?.now!="function")throw new TypeError("perf option must have a now() method if specified");if(f(this,X,mt??ne),t!==0&&!nt(t))throw new TypeError("max option must be a nonnegative integer");let St=t?ee(t):Array;if(!St)throw new Error("invalid max value: "+t);if(f(this,$,t),f(this,U,et),this.maxEntrySize=y||i(this,U),this.sizeCalculation=T,this.sizeCalculation){if(!i(this,U)&&!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(f(this,bt,D),p!==void 0&&typeof p!="function")throw new TypeError("fetchMethod must be a function if specified");if(f(this,Tt,p),f(this,ut,!!p),f(this,w,new Map),f(this,A,new Array(t).fill(void 0)),f(this,d,new Array(t).fill(void 0)),f(this,M,new St(t)),f(this,z,new St(t)),f(this,I,0),f(this,R,0),f(this,q,le.create(t)),f(this,O,0),f(this,J,0),typeof S=="function"&&f(this,H,S),typeof C=="function"&&f(this,dt,C),typeof E=="function"?(f(this,B,E),f(this,x,[])):(f(this,B,void 0),f(this,x,void 0)),f(this,tt,!!i(this,H)),f(this,At,!!i(this,dt)),f(this,F,!!i(this,B)),this.noDisposeOnSet=!!at,this.noUpdateTTL=!!W,this.noDeleteOnFetchRejection=!!L,this.allowStaleOnFetchRejection=!!v,this.allowStaleOnFetchAbort=!!xt,this.ignoreFetchAbort=!!_t,this.maxEntrySize!==0){if(i(this,U)!==0&&!nt(i(this,U)))throw new TypeError("maxSize must be a positive integer if specified");if(!nt(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");l(this,n,se).call(this);}if(this.allowStale=!!u,this.noDeleteOnStaleGet=!!N,this.updateAgeOnGet=!!r,this.updateAgeOnHas=!!h,this.ttlResolution=nt(a)||a===0?a:1,this.ttlAutopurge=!!o,this.ttl=s||0,this.ttl){if(!nt(this.ttl))throw new TypeError("ttl must be a positive integer if specified");l(this,n,jt).call(this);}if(i(this,$)===0&&this.ttl===0&&i(this,U)===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!i(this,$)&&!i(this,U)){let Yt="LRU_CACHE_UNBOUNDED";he(Yt)&&(Zt.add(Yt),te("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",Yt,vt));}}get perf(){return i(this,X)}static unsafeExposeInternals(e){return {starts:i(e,Z),ttls:i(e,P),autopurgeTimers:i(e,Y),sizes:i(e,Q),keyMap:i(e,w),keyList:i(e,A),valList:i(e,d),next:i(e,M),prev:i(e,z),get head(){return i(e,I)},get tail(){return i(e,R)},free:i(e,q),isBackgroundFetch:t=>{var s;return l(s=e,n,b).call(s,t)},backgroundFetch:(t,s,a,o)=>{var r;return l(r=e,n,Ut).call(r,t,s,a,o)},moveToTail:t=>{var s;return l(s=e,n,It).call(s,t)},indexes:t=>{var s;return l(s=e,n,ht).call(s,t)},rindexes:t=>{var s;return l(s=e,n,lt).call(s,t)},isStale:t=>{var s;return i(s=e,K).call(s,t)}}}get max(){return i(this,$)}get maxSize(){return i(this,U)}get calculatedSize(){return i(this,J)}get size(){return i(this,O)}get fetchMethod(){return i(this,Tt)}get memoMethod(){return i(this,bt)}get dispose(){return i(this,H)}get onInsert(){return i(this,dt)}get disposeAfter(){return i(this,B)}getRemainingTTL(e){return i(this,w).has(e)?1/0:0}*entries(){for(let e of l(this,n,ht).call(this))i(this,d)[e]!==void 0&&i(this,A)[e]!==void 0&&!l(this,n,b).call(this,i(this,d)[e])&&(yield [i(this,A)[e],i(this,d)[e]]);}*rentries(){for(let e of l(this,n,lt).call(this))i(this,d)[e]!==void 0&&i(this,A)[e]!==void 0&&!l(this,n,b).call(this,i(this,d)[e])&&(yield [i(this,A)[e],i(this,d)[e]]);}*keys(){for(let e of l(this,n,ht).call(this)){let t=i(this,A)[e];t!==void 0&&!l(this,n,b).call(this,i(this,d)[e])&&(yield t);}}*rkeys(){for(let e of l(this,n,lt).call(this)){let t=i(this,A)[e];t!==void 0&&!l(this,n,b).call(this,i(this,d)[e])&&(yield t);}}*values(){for(let e of l(this,n,ht).call(this))i(this,d)[e]!==void 0&&!l(this,n,b).call(this,i(this,d)[e])&&(yield i(this,d)[e]);}*rvalues(){for(let e of l(this,n,lt).call(this))i(this,d)[e]!==void 0&&!l(this,n,b).call(this,i(this,d)[e])&&(yield i(this,d)[e]);}[(Qt=Symbol.iterator,qt=Symbol.toStringTag,Qt)](){return this.entries()}find(e,t={}){for(let s of l(this,n,ht).call(this)){let a=i(this,d)[s],o=l(this,n,b).call(this,a)?a.__staleWhileFetching:a;if(o!==void 0&&e(o,i(this,A)[s],this))return this.get(i(this,A)[s],t)}}forEach(e,t=this){for(let s of l(this,n,ht).call(this)){let a=i(this,d)[s],o=l(this,n,b).call(this,a)?a.__staleWhileFetching:a;o!==void 0&&e.call(t,o,i(this,A)[s],this);}}rforEach(e,t=this){for(let s of l(this,n,lt).call(this)){let a=i(this,d)[s],o=l(this,n,b).call(this,a)?a.__staleWhileFetching:a;o!==void 0&&e.call(t,o,i(this,A)[s],this);}}purgeStale(){let e=false;for(let t of l(this,n,lt).call(this,{allowStale:true}))i(this,K).call(this,t)&&(l(this,n,ct).call(this,i(this,A)[t],"expire"),e=true);return e}info(e){let t=i(this,w).get(e);if(t===void 0)return;let s=i(this,d)[t],a=l(this,n,b).call(this,s)?s.__staleWhileFetching:s;if(a===void 0)return;let o={value:a};if(i(this,P)&&i(this,Z)){let r=i(this,P)[t],h=i(this,Z)[t];if(r&&h){let u=r-(i(this,X).now()-h);o.ttl=u,o.start=Date.now();}}return i(this,Q)&&(o.size=i(this,Q)[t]),o}dump(){let e=[];for(let t of l(this,n,ht).call(this,{allowStale:true})){let s=i(this,A)[t],a=i(this,d)[t],o=l(this,n,b).call(this,a)?a.__staleWhileFetching:a;if(o===void 0||s===void 0)continue;let r={value:o};if(i(this,P)&&i(this,Z)){r.ttl=i(this,P)[t];let h=i(this,X).now()-i(this,Z)[t];r.start=Math.floor(Date.now()-h);}i(this,Q)&&(r.size=i(this,Q)[t]),e.unshift([s,r]);}return e}load(e){this.clear();for(let[t,s]of e){if(s.start){let a=Date.now()-s.start;s.start=i(this,X).now()-a;}this.set(t,s.value,s);}}set(e,t,s={}){var at,W,et,y;if(t===void 0)return this.delete(e),this;let{ttl:a=this.ttl,start:o,noDisposeOnSet:r=this.noDisposeOnSet,sizeCalculation:h=this.sizeCalculation,status:u}=s,{noUpdateTTL:S=this.noUpdateTTL}=s,C=i(this,Nt).call(this,e,t,s.size||0,h);if(this.maxEntrySize&&C>this.maxEntrySize)return u&&(u.set="miss",u.maxEntrySizeExceeded=true),l(this,n,ct).call(this,e,"set"),this;let E=i(this,O)===0?void 0:i(this,w).get(e);if(E===void 0)E=i(this,O)===0?i(this,R):i(this,q).length!==0?i(this,q).pop():i(this,O)===i(this,$)?l(this,n,Vt).call(this,false):i(this,O),i(this,A)[E]=e,i(this,d)[E]=t,i(this,w).set(e,E),i(this,M)[i(this,R)]=E,i(this,z)[E]=i(this,R),f(this,R,E),Ft(this,O)._++,i(this,yt).call(this,E,C,u),u&&(u.set="add"),S=false,i(this,At)&&((at=i(this,dt))==null||at.call(this,t,e,"add"));else {l(this,n,It).call(this,E);let T=i(this,d)[E];if(t!==T){if(i(this,ut)&&l(this,n,b).call(this,T)){T.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:p}=T;p!==void 0&&!r&&(i(this,tt)&&((W=i(this,H))==null||W.call(this,p,e,"set")),i(this,F)&&i(this,x)?.push([p,e,"set"]));}else r||(i(this,tt)&&((et=i(this,H))==null||et.call(this,T,e,"set")),i(this,F)&&i(this,x)?.push([T,e,"set"]));if(i(this,pt).call(this,E),i(this,yt).call(this,E,C,u),i(this,d)[E]=t,u){u.set="replace";let p=T&&l(this,n,b).call(this,T)?T.__staleWhileFetching:T;p!==void 0&&(u.oldValue=p);}}else u&&(u.set="update");i(this,At)&&this.onInsert?.(t,e,t===T?"update":"replace");}if(a!==0&&!i(this,P)&&l(this,n,jt).call(this),i(this,P)&&(S||i(this,Dt).call(this,E,a,o),u&&i(this,st).call(this,u,E)),!r&&i(this,F)&&i(this,x)){let T=i(this,x),p;for(;p=T?.shift();)(y=i(this,B))==null||y.call(this,...p);}return this}pop(){var e;try{for(;i(this,O);){let t=i(this,d)[i(this,I)];if(l(this,n,Vt).call(this,!0),l(this,n,b).call(this,t)){if(t.__staleWhileFetching)return t.__staleWhileFetching}else if(t!==void 0)return t}}finally{if(i(this,F)&&i(this,x)){let t=i(this,x),s;for(;s=t?.shift();)(e=i(this,B))==null||e.call(this,...s);}}}has(e,t={}){let{updateAgeOnHas:s=this.updateAgeOnHas,status:a}=t,o=i(this,w).get(e);if(o!==void 0){let r=i(this,d)[o];if(l(this,n,b).call(this,r)&&r.__staleWhileFetching===void 0)return false;if(i(this,K).call(this,o))a&&(a.has="stale",i(this,st).call(this,a,o));else return s&&i(this,gt).call(this,o),a&&(a.has="hit",i(this,st).call(this,a,o)),true}else a&&(a.has="miss");return false}peek(e,t={}){let{allowStale:s=this.allowStale}=t,a=i(this,w).get(e);if(a===void 0||!s&&i(this,K).call(this,a))return;let o=i(this,d)[a];return l(this,n,b).call(this,o)?o.__staleWhileFetching:o}async fetch(e,t={}){let{allowStale:s=this.allowStale,updateAgeOnGet:a=this.updateAgeOnGet,noDeleteOnStaleGet:o=this.noDeleteOnStaleGet,ttl:r=this.ttl,noDisposeOnSet:h=this.noDisposeOnSet,size:u=0,sizeCalculation:S=this.sizeCalculation,noUpdateTTL:C=this.noUpdateTTL,noDeleteOnFetchRejection:E=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:at=this.allowStaleOnFetchRejection,ignoreFetchAbort:W=this.ignoreFetchAbort,allowStaleOnFetchAbort:et=this.allowStaleOnFetchAbort,context:y,forceRefresh:T=false,status:p,signal:D}=t;if(!i(this,ut))return p&&(p.fetch="get"),this.get(e,{allowStale:s,updateAgeOnGet:a,noDeleteOnStaleGet:o,status:p});let L={allowStale:s,updateAgeOnGet:a,noDeleteOnStaleGet:o,ttl:r,noDisposeOnSet:h,size:u,sizeCalculation:S,noUpdateTTL:C,noDeleteOnFetchRejection:E,allowStaleOnFetchRejection:at,allowStaleOnFetchAbort:et,ignoreFetchAbort:W,status:p,signal:D},N=i(this,w).get(e);if(N===void 0){p&&(p.fetch="miss");let v=l(this,n,Ut).call(this,e,N,L,y);return v.__returned=v}else {let v=i(this,d)[N];if(l(this,n,b).call(this,v)){let St=s&&v.__staleWhileFetching!==void 0;return p&&(p.fetch="inflight",St&&(p.returnedStale=true)),St?v.__staleWhileFetching:v.__returned=v}let xt=i(this,K).call(this,N);if(!T&&!xt)return p&&(p.fetch="hit"),l(this,n,It).call(this,N),a&&i(this,gt).call(this,N),p&&i(this,st).call(this,p,N),v;let _t=l(this,n,Ut).call(this,e,N,L,y),mt=_t.__staleWhileFetching!==void 0&&s;return p&&(p.fetch=xt?"stale":"refresh",mt&&xt&&(p.returnedStale=true)),mt?_t.__staleWhileFetching:_t.__returned=_t}}async forceFetch(e,t={}){let s=await this.fetch(e,t);if(s===void 0)throw new Error("fetch() returned undefined");return s}memo(e,t={}){let s=i(this,bt);if(!s)throw new Error("no memoMethod provided to constructor");let{context:a,forceRefresh:o,...r}=t,h=this.get(e,r);if(!o&&h!==void 0)return h;let u=s(e,h,{options:r,context:a});return this.set(e,u,r),u}get(e,t={}){let{allowStale:s=this.allowStale,updateAgeOnGet:a=this.updateAgeOnGet,noDeleteOnStaleGet:o=this.noDeleteOnStaleGet,status:r}=t,h=i(this,w).get(e);if(h!==void 0){let u=i(this,d)[h],S=l(this,n,b).call(this,u);return r&&i(this,st).call(this,r,h),i(this,K).call(this,h)?(r&&(r.get="stale"),S?(r&&s&&u.__staleWhileFetching!==void 0&&(r.returnedStale=true),s?u.__staleWhileFetching:void 0):(o||l(this,n,ct).call(this,e,"expire"),r&&s&&(r.returnedStale=true),s?u:void 0)):(r&&(r.get="hit"),S?u.__staleWhileFetching:(l(this,n,It).call(this,h),a&&i(this,gt).call(this,h),u))}else r&&(r.get="miss");}delete(e){return l(this,n,ct).call(this,e,"delete")}clear(){return l(this,n,Ht).call(this,"delete")}},$=new WeakMap,U=new WeakMap,H=new WeakMap,dt=new WeakMap,B=new WeakMap,Tt=new WeakMap,bt=new WeakMap,X=new WeakMap,O=new WeakMap,J=new WeakMap,w=new WeakMap,A=new WeakMap,d=new WeakMap,M=new WeakMap,z=new WeakMap,I=new WeakMap,R=new WeakMap,q=new WeakMap,x=new WeakMap,Q=new WeakMap,Z=new WeakMap,P=new WeakMap,Y=new WeakMap,tt=new WeakMap,ut=new WeakMap,F=new WeakMap,At=new WeakMap,n=new WeakSet,jt=function(){let e=new Lt(i(this,$)),t=new Lt(i(this,$));f(this,P,e),f(this,Z,t);let s=this.ttlAutopurge?new Array(i(this,$)):void 0;f(this,Y,s),f(this,Dt,(h,u,S=i(this,X).now())=>{t[h]=u!==0?S:0,e[h]=u,a(h,u);}),f(this,gt,h=>{t[h]=e[h]!==0?i(this,X).now():0,a(h,e[h]);});let a=this.ttlAutopurge?(h,u)=>{if(s?.[h]&&(clearTimeout(s[h]),s[h]=void 0),u&&u!==0&&s){let S=setTimeout(()=>{i(this,K).call(this,h)&&l(this,n,ct).call(this,i(this,A)[h],"expire");},u+1);S.unref&&S.unref(),s[h]=S;}}:()=>{};f(this,st,(h,u)=>{if(e[u]){let S=e[u],C=t[u];if(!S||!C)return;h.ttl=S,h.start=C,h.now=o||r();let E=h.now-C;h.remainingTTL=S-E;}});let o=0,r=()=>{let h=i(this,X).now();if(this.ttlResolution>0){o=h;let u=setTimeout(()=>o=0,this.ttlResolution);u.unref&&u.unref();}return h};this.getRemainingTTL=h=>{let u=i(this,w).get(h);if(u===void 0)return 0;let S=e[u],C=t[u];if(!S||!C)return 1/0;let E=(o||r())-C;return S-E},f(this,K,h=>{let u=t[h],S=e[h];return !!S&&!!u&&(o||r())-u>S});},gt=new WeakMap,st=new WeakMap,Dt=new WeakMap,K=new WeakMap,se=function(){let e=new Lt(i(this,$));f(this,J,0),f(this,Q,e),f(this,pt,t=>{f(this,J,i(this,J)-e[t]),e[t]=0;}),f(this,Nt,(t,s,a,o)=>{if(l(this,n,b).call(this,s))return 0;if(!nt(a))if(o){if(typeof o!="function")throw new TypeError("sizeCalculation must be a function");if(a=o(s,t),!nt(a))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 a}),f(this,yt,(t,s,a)=>{if(e[t]=s,i(this,U)){let o=i(this,U)-e[t];for(;i(this,J)>o;)l(this,n,Vt).call(this,true);}f(this,J,i(this,J)+e[t]),a&&(a.entrySize=s,a.totalCalculatedSize=i(this,J));});},pt=new WeakMap,yt=new WeakMap,Nt=new WeakMap,ht=function*({allowStale:e=this.allowStale}={}){if(i(this,O))for(let t=i(this,R);!(!l(this,n,$t).call(this,t)||((e||!i(this,K).call(this,t))&&(yield t),t===i(this,I)));)t=i(this,z)[t];},lt=function*({allowStale:e=this.allowStale}={}){if(i(this,O))for(let t=i(this,I);!(!l(this,n,$t).call(this,t)||((e||!i(this,K).call(this,t))&&(yield t),t===i(this,R)));)t=i(this,M)[t];},$t=function(e){return e!==void 0&&i(this,w).get(i(this,A)[e])===e},Vt=function(e){var o;let t=i(this,I),s=i(this,A)[t],a=i(this,d)[t];return i(this,ut)&&l(this,n,b).call(this,a)?a.__abortController.abort(new Error("evicted")):(i(this,tt)||i(this,F))&&(i(this,tt)&&((o=i(this,H))==null||o.call(this,a,s,"evict")),i(this,F)&&i(this,x)?.push([a,s,"evict"])),i(this,pt).call(this,t),i(this,Y)?.[t]&&(clearTimeout(i(this,Y)[t]),i(this,Y)[t]=void 0),e&&(i(this,A)[t]=void 0,i(this,d)[t]=void 0,i(this,q).push(t)),i(this,O)===1?(f(this,I,f(this,R,0)),i(this,q).length=0):f(this,I,i(this,M)[t]),i(this,w).delete(s),Ft(this,O)._--,t},Ut=function(e,t,s,a){let o=t===void 0?void 0:i(this,d)[t];if(l(this,n,b).call(this,o))return o;let r=new zt,{signal:h}=s;h?.addEventListener("abort",()=>r.abort(h.reason),{signal:r.signal});let u={signal:r.signal,options:s,context:a},S=(y,T=false)=>{let{aborted:p}=r.signal,D=s.ignoreFetchAbort&&y!==void 0,L=s.ignoreFetchAbort||!!(s.allowStaleOnFetchAbort&&y!==void 0);if(s.status&&(p&&!T?(s.status.fetchAborted=true,s.status.fetchError=r.signal.reason,D&&(s.status.fetchAbortIgnored=true)):s.status.fetchResolved=true),p&&!D&&!T)return E(r.signal.reason,L);let N=W,v=i(this,d)[t];return (v===W||D&&T&&v===void 0)&&(y===void 0?N.__staleWhileFetching!==void 0?i(this,d)[t]=N.__staleWhileFetching:l(this,n,ct).call(this,e,"fetch"):(s.status&&(s.status.fetchUpdated=true),this.set(e,y,u.options))),y},C=y=>(s.status&&(s.status.fetchRejected=true,s.status.fetchError=y),E(y,false)),E=(y,T)=>{let{aborted:p}=r.signal,D=p&&s.allowStaleOnFetchAbort,L=D||s.allowStaleOnFetchRejection,N=L||s.noDeleteOnFetchRejection,v=W;if(i(this,d)[t]===W&&(!N||!T&&v.__staleWhileFetching===void 0?l(this,n,ct).call(this,e,"fetch"):D||(i(this,d)[t]=v.__staleWhileFetching)),L)return s.status&&v.__staleWhileFetching!==void 0&&(s.status.returnedStale=true),v.__staleWhileFetching;if(v.__returned===v)throw y},at=(y,T)=>{var D;let p=(D=i(this,Tt))==null?void 0:D.call(this,e,o,u);p&&p instanceof Promise&&p.then(L=>y(L===void 0?void 0:L),T),r.signal.addEventListener("abort",()=>{(!s.ignoreFetchAbort||s.allowStaleOnFetchAbort)&&(y(void 0),s.allowStaleOnFetchAbort&&(y=L=>S(L,true)));});};s.status&&(s.status.fetchDispatched=true);let W=new Promise(at).then(S,C),et=Object.assign(W,{__abortController:r,__staleWhileFetching:o,__returned:void 0});return t===void 0?(this.set(e,et,{...u.options,status:void 0}),t=i(this,w).get(e)):i(this,d)[t]=et,et},b=function(e){if(!i(this,ut))return false;let t=e;return !!t&&t instanceof Promise&&t.hasOwnProperty("__staleWhileFetching")&&t.__abortController instanceof zt},kt=function(e,t){i(this,z)[t]=e,i(this,M)[e]=t;},It=function(e){e!==i(this,R)&&(e===i(this,I)?f(this,I,i(this,M)[e]):l(this,n,kt).call(this,i(this,z)[e],i(this,M)[e]),l(this,n,kt).call(this,i(this,R),e),f(this,R,e));},ct=function(e,t){var a,o;let s=false;if(i(this,O)!==0){let r=i(this,w).get(e);if(r!==void 0)if(i(this,Y)?.[r]&&(clearTimeout(i(this,Y)?.[r]),i(this,Y)[r]=void 0),s=true,i(this,O)===1)l(this,n,Ht).call(this,t);else {i(this,pt).call(this,r);let h=i(this,d)[r];if(l(this,n,b).call(this,h)?h.__abortController.abort(new Error("deleted")):(i(this,tt)||i(this,F))&&(i(this,tt)&&((a=i(this,H))==null||a.call(this,h,e,t)),i(this,F)&&i(this,x)?.push([h,e,t])),i(this,w).delete(e),i(this,A)[r]=void 0,i(this,d)[r]=void 0,r===i(this,R))f(this,R,i(this,z)[r]);else if(r===i(this,I))f(this,I,i(this,M)[r]);else {let u=i(this,z)[r];i(this,M)[u]=i(this,M)[r];let S=i(this,M)[r];i(this,z)[S]=i(this,z)[r];}Ft(this,O)._--,i(this,q).push(r);}}if(i(this,F)&&i(this,x)?.length){let r=i(this,x),h;for(;h=r?.shift();)(o=i(this,B))==null||o.call(this,...h);}return s},Ht=function(e){var t,s;for(let a of l(this,n,lt).call(this,{allowStale:true})){let o=i(this,d)[a];if(l(this,n,b).call(this,o))o.__abortController.abort(new Error("deleted"));else {let r=i(this,A)[a];i(this,tt)&&((t=i(this,H))==null||t.call(this,o,r,e)),i(this,F)&&i(this,x)?.push([o,r,e]);}}if(i(this,w).clear(),i(this,d).fill(void 0),i(this,A).fill(void 0),i(this,P)&&i(this,Z)){i(this,P).fill(0),i(this,Z).fill(0);for(let a of i(this,Y)??[])a!==void 0&&clearTimeout(a);i(this,Y)?.fill(void 0);}if(i(this,Q)&&i(this,Q).fill(0),f(this,I,0),f(this,R,0),i(this,q).length=0,f(this,J,0),f(this,O,0),i(this,F)&&i(this,x)){let a=i(this,x),o;for(;o=a?.shift();)(s=i(this,B))==null||s.call(this,...o);}},vt);var rt=class{constructor(e){g(this,"cache");g(this,"map",new Map);this.cache=new ie({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 G=class G{constructor(){}static clearOldTempVariables(e){G.tempStorageDeadlines.forEach((t,s)=>{t>e&&(G.removeVariable(ft,s),G.tempStorageDeadlines.delete(s));});}static setVariable(e,t,s){s==null?G.storage.delete(`${e}:${t}`):G.storage.set(`${e}:${t}`,s);}static getVariable(e,t){let s=G.storage.get(`${e}:${t}`);return Ct(s)}static removeVariable(e,t){G.storage.delete(`${e}:${t}`);}static setFlag(e,t){let s=G.storage.get(Gt)||[];if(t)s.includes(e)||s.push(e);else {let a=s.indexOf(e);a>-1&&s.splice(a,1);}G.storage.set(Gt,s);}static getFlag(e){return (G.storage.get(Gt)||[]).includes(e)}};g(G,"storage",new rt({cacheSize:50})),g(G,"default",new rt({cacheSize:10})),g(G,"tempStorageDeadlines",new Map);var _=G;var wt=class{constructor(e,t){g(this,"id");g(this,"categoryId");this.categoryId=e,this.id=t,this.migrateOldStorage();}migrateOldStorage(e=this.categoryId){let t=_.getVariable(ot,e);t&&(Object.entries(t).forEach(([s,a])=>{typeof a=="object"&&a!==null&&Object.entries(a).forEach(([o,r])=>{_.setVariable(this.categoryId,`${s}:${o}`,r);});}),_.removeVariable(ot,e));}setStorageProperty(e,t){_.setVariable(this.categoryId,`${this.id}:${e}`,t);}getStorageProperty(e,t=this.id){return _.getVariable(this.categoryId,`${t}:${e}`)}};var ue="@",Ot=class extends wt{constructor(t,s=""){super(V.CHARACTER_CATEGORY_KEY,t+(s?ue+s:""));g(this,"sourceId");this.sourceId=t,this.migrateOldStorage("___character___");}getStorageProperty(t){let s=super.getStorageProperty(t);return s===void 0&&(s=super.getStorageProperty(t,this.sourceId)),s}};var Pt=class extends Ot{constructor(t,s){super(typeof t=="string"?t:t.id,typeof t=="string"?"":t.emotion);g(this,"defaultName");g(this,"defaultSurname");g(this,"defaultAge");g(this,"_icon");g(this,"_color");this.defaultName=s.name,this.defaultSurname=s.surname,this.defaultAge=s.age,this._icon=s.icon,this._color=s.color;}get name(){return this.getStorageProperty("name")||this.defaultName||this.id}set name(t){this.setStorageProperty("name",t);}get surname(){return this.getStorageProperty("surname")||this.defaultSurname}set surname(t){this.setStorageProperty("surname",t);}get age(){return this.getStorageProperty("age")||this.defaultAge}set age(t){this.setStorageProperty("age",t);}get icon(){return this._icon}get color(){return this._color}};var Rt=new rt({cacheSize:10}),Bt;(o=>{function c(r){try{let h=Rt.get(r);if(!h){k.warn(`Character "${r}" not found, did you forget to register it with the RegisteredCharacters.add?`);return}return h}catch(h){k.error(`Error while getting Character "${r}"`,h);return}}o.get=c;function e(r){if(Array.isArray(r)){r.forEach(h=>e(h));return}Rt.get(r.id)&&k.info(`Character id "${r.id}" already exists, it will be overwritten`),Rt.set(r.id,r);}o.add=e;function t(){return Array.from(Rt.values())}o.values=t;function s(r){return Rt.has(r)}o.has=s;function a(){return Array.from(Rt.keys())}o.keys=a;})(Bt||(Bt={}));var fe=Bt;exports.CharacterBaseModel=Pt;exports.CharacterStoredClass=Ot;exports.RegisteredCharacters=fe;
|
|
1
|
+
'use strict';var core=require('@drincs/pixi-vn/core');var se=Object.defineProperty;var Xt=c=>{throw TypeError(c)};var ae=(c,i,e)=>i in c?se(c,i,{enumerable:true,configurable:true,writable:true,value:e}):c[i]=e;var _=(c,i,e)=>ae(c,typeof i!="symbol"?i+"":i,e),Yt=(c,i,e)=>i.has(c)||Xt("Cannot "+e);var t=(c,i,e)=>(Yt(c,i,"read from private field"),e?e.call(c):i.get(c)),m=(c,i,e)=>i.has(c)?Xt("Cannot add the same private member more than once"):i instanceof WeakSet?i.add(c):i.set(c,e),f=(c,i,e,r)=>(Yt(c,i,"write to private field"),i.set(c,e),e),h=(c,i,e)=>(Yt(c,i,"access private method"),e);var Mt=(c,i,e,r)=>({set _(a){f(c,i,a);},get _(){return t(c,i,r)}});var st="storage",ut="temp",Ft="flags",U={CHARACTER_CATEGORY_KEY:"character"};var k;(a=>(a.log=(o,...s)=>console.log(`[Pixi\u2019VN] ${o}`,...s),a.warn=(o,...s)=>console.warn(`[Pixi\u2019VN] ${o}`,...s),a.error=(o,...s)=>console.error(`[Pixi\u2019VN] ${o}`,...s),a.info=(o,...s)=>console.info(`[Pixi\u2019VN] ${o}`,...s)))(k||(k={}));function Rt(c){try{if(typeof c>"u")return c;let i=JSON.stringify(c);return JSON.parse(i)}catch(i){throw k.error("Error creating exportable element",c,i),new core.PixiError("not_json_serializable","Error creating exportable element")}}var ne=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,Zt=new Set,Kt=typeof process=="object"&&process?process:{},te=(c,i,e,r)=>{typeof Kt.emitWarning=="function"?Kt.emitWarning(c,i,e,r):console.error(`[${e}] ${i}: ${c}`);},Pt=globalThis.AbortController,Jt=globalThis.AbortSignal;if(typeof Pt>"u"){Jt=class{constructor(){_(this,"onabort");_(this,"_onabort",[]);_(this,"reason");_(this,"aborted",false);}addEventListener(e,r){this._onabort.push(r);}},Pt=class{constructor(){_(this,"signal",new Jt);i();}abort(e){if(!this.signal.aborted){this.signal.reason=e,this.signal.aborted=true;for(let r of this.signal._onabort)r(e);this.signal.onabort?.(e);}}};let c=Kt.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",i=()=>{c&&(c=false,te("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",i));};}var le=c=>!Zt.has(c);var at=c=>c&&c===Math.floor(c)&&c>0&&isFinite(c),ee=c=>at(c)?c<=Math.pow(2,8)?Uint8Array:c<=Math.pow(2,16)?Uint16Array:c<=Math.pow(2,32)?Uint32Array:c<=Number.MAX_SAFE_INTEGER?Gt:null:null,Gt=class extends Array{constructor(c){super(c),this.fill(0);}},it,St,he=(it=class{constructor(i,e){_(this,"heap");_(this,"length");if(!t(it,St))throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new e(i),this.length=0;}static create(i){let e=ee(i);if(!e)return [];f(it,St,true);let r=new it(i,e);return f(it,St,false),r}push(i){this.heap[this.length++]=i;}pop(){return this.heap[--this.length]}},St=new WeakMap,m(it,St,false),it),qt,Qt,j,z,B,ft,X,Et,Tt,J,C,q,R,w,g,V,Y,M,D,Q,N,Z,tt,K,W,et,ht,L,bt,n,Wt,gt,rt,It,H,re,dt,yt,Dt,ot,nt,Ht,Vt,Lt,O,$t,Ct,lt,jt,At,ie=(At=class{constructor(i){m(this,n);m(this,j);m(this,z);m(this,B);m(this,ft);m(this,X);m(this,Et);m(this,Tt);m(this,J);_(this,"ttl");_(this,"ttlResolution");_(this,"ttlAutopurge");_(this,"updateAgeOnGet");_(this,"updateAgeOnHas");_(this,"allowStale");_(this,"noDisposeOnSet");_(this,"noUpdateTTL");_(this,"maxEntrySize");_(this,"sizeCalculation");_(this,"noDeleteOnFetchRejection");_(this,"noDeleteOnStaleGet");_(this,"allowStaleOnFetchAbort");_(this,"allowStaleOnFetchRejection");_(this,"ignoreFetchAbort");m(this,C);m(this,q);m(this,R);m(this,w);m(this,g);m(this,V);m(this,Y);m(this,M);m(this,D);m(this,Q);m(this,N);m(this,Z);m(this,tt);m(this,K);m(this,W);m(this,et);m(this,ht);m(this,L);m(this,bt);m(this,gt,()=>{});m(this,rt,()=>{});m(this,It,()=>{});m(this,H,()=>false);m(this,dt,i=>{});m(this,yt,(i,e,r)=>{});m(this,Dt,(i,e,r,a)=>{if(r||a)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0});_(this,qt,"LRUCache");let{max:e=0,ttl:r,ttlResolution:a=1,ttlAutopurge:o,updateAgeOnGet:s,updateAgeOnHas:l,allowStale:u,dispose:E,onInsert:I,disposeAfter:d,noDisposeOnSet:y,noUpdateTTL:b,maxSize:T=0,maxEntrySize:A=0,sizeCalculation:v,fetchMethod:p,memoMethod:F,noDeleteOnFetchRejection:P,noDeleteOnStaleGet:G,allowStaleOnFetchRejection:x,allowStaleOnFetchAbort:xt,ignoreFetchAbort:pt,perf:_t}=i;if(_t!==void 0&&typeof _t?.now!="function")throw new TypeError("perf option must have a now() method if specified");if(f(this,J,_t??ne),e!==0&&!at(e))throw new TypeError("max option must be a nonnegative integer");let mt=e?ee(e):Array;if(!mt)throw new Error("invalid max value: "+e);if(f(this,j,e),f(this,z,T),this.maxEntrySize=A||t(this,z),this.sizeCalculation=v,this.sizeCalculation){if(!t(this,z)&&!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(F!==void 0&&typeof F!="function")throw new TypeError("memoMethod must be a function if defined");if(f(this,Tt,F),p!==void 0&&typeof p!="function")throw new TypeError("fetchMethod must be a function if specified");if(f(this,Et,p),f(this,ht,!!p),f(this,R,new Map),f(this,w,new Array(e).fill(void 0)),f(this,g,new Array(e).fill(void 0)),f(this,V,new mt(e)),f(this,Y,new mt(e)),f(this,M,0),f(this,D,0),f(this,Q,he.create(e)),f(this,C,0),f(this,q,0),typeof E=="function"&&f(this,B,E),typeof I=="function"&&f(this,ft,I),typeof d=="function"?(f(this,X,d),f(this,N,[])):(f(this,X,void 0),f(this,N,void 0)),f(this,et,!!t(this,B)),f(this,bt,!!t(this,ft)),f(this,L,!!t(this,X)),this.noDisposeOnSet=!!y,this.noUpdateTTL=!!b,this.noDeleteOnFetchRejection=!!P,this.allowStaleOnFetchRejection=!!x,this.allowStaleOnFetchAbort=!!xt,this.ignoreFetchAbort=!!pt,this.maxEntrySize!==0){if(t(this,z)!==0&&!at(t(this,z)))throw new TypeError("maxSize must be a positive integer if specified");if(!at(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");h(this,n,re).call(this);}if(this.allowStale=!!u,this.noDeleteOnStaleGet=!!G,this.updateAgeOnGet=!!s,this.updateAgeOnHas=!!l,this.ttlResolution=at(a)||a===0?a:1,this.ttlAutopurge=!!o,this.ttl=r||0,this.ttl){if(!at(this.ttl))throw new TypeError("ttl must be a positive integer if specified");h(this,n,Wt).call(this);}if(t(this,j)===0&&this.ttl===0&&t(this,z)===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!t(this,j)&&!t(this,z)){let zt="LRU_CACHE_UNBOUNDED";le(zt)&&(Zt.add(zt),te("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",zt,At));}}get perf(){return t(this,J)}static unsafeExposeInternals(i){return {starts:t(i,tt),ttls:t(i,K),autopurgeTimers:t(i,W),sizes:t(i,Z),keyMap:t(i,R),keyList:t(i,w),valList:t(i,g),next:t(i,V),prev:t(i,Y),get head(){return t(i,M)},get tail(){return t(i,D)},free:t(i,Q),isBackgroundFetch:e=>{var r;return h(r=i,n,O).call(r,e)},backgroundFetch:(e,r,a,o)=>{var s;return h(s=i,n,Lt).call(s,e,r,a,o)},moveToTail:e=>{var r;return h(r=i,n,Ct).call(r,e)},indexes:e=>{var r;return h(r=i,n,ot).call(r,e)},rindexes:e=>{var r;return h(r=i,n,nt).call(r,e)},isStale:e=>{var r;return t(r=i,H).call(r,e)}}}get max(){return t(this,j)}get maxSize(){return t(this,z)}get calculatedSize(){return t(this,q)}get size(){return t(this,C)}get fetchMethod(){return t(this,Et)}get memoMethod(){return t(this,Tt)}get dispose(){return t(this,B)}get onInsert(){return t(this,ft)}get disposeAfter(){return t(this,X)}getRemainingTTL(i){return t(this,R).has(i)?1/0:0}*entries(){for(let i of h(this,n,ot).call(this))t(this,g)[i]!==void 0&&t(this,w)[i]!==void 0&&!h(this,n,O).call(this,t(this,g)[i])&&(yield [t(this,w)[i],t(this,g)[i]]);}*rentries(){for(let i of h(this,n,nt).call(this))t(this,g)[i]!==void 0&&t(this,w)[i]!==void 0&&!h(this,n,O).call(this,t(this,g)[i])&&(yield [t(this,w)[i],t(this,g)[i]]);}*keys(){for(let i of h(this,n,ot).call(this)){let e=t(this,w)[i];e!==void 0&&!h(this,n,O).call(this,t(this,g)[i])&&(yield e);}}*rkeys(){for(let i of h(this,n,nt).call(this)){let e=t(this,w)[i];e!==void 0&&!h(this,n,O).call(this,t(this,g)[i])&&(yield e);}}*values(){for(let i of h(this,n,ot).call(this))t(this,g)[i]!==void 0&&!h(this,n,O).call(this,t(this,g)[i])&&(yield t(this,g)[i]);}*rvalues(){for(let i of h(this,n,nt).call(this))t(this,g)[i]!==void 0&&!h(this,n,O).call(this,t(this,g)[i])&&(yield t(this,g)[i]);}[(Qt=Symbol.iterator,qt=Symbol.toStringTag,Qt)](){return this.entries()}find(i,e={}){for(let r of h(this,n,ot).call(this)){let a=t(this,g)[r],o=h(this,n,O).call(this,a)?a.__staleWhileFetching:a;if(o!==void 0&&i(o,t(this,w)[r],this))return this.get(t(this,w)[r],e)}}forEach(i,e=this){for(let r of h(this,n,ot).call(this)){let a=t(this,g)[r],o=h(this,n,O).call(this,a)?a.__staleWhileFetching:a;o!==void 0&&i.call(e,o,t(this,w)[r],this);}}rforEach(i,e=this){for(let r of h(this,n,nt).call(this)){let a=t(this,g)[r],o=h(this,n,O).call(this,a)?a.__staleWhileFetching:a;o!==void 0&&i.call(e,o,t(this,w)[r],this);}}purgeStale(){let i=false;for(let e of h(this,n,nt).call(this,{allowStale:true}))t(this,H).call(this,e)&&(h(this,n,lt).call(this,t(this,w)[e],"expire"),i=true);return i}info(i){let e=t(this,R).get(i);if(e===void 0)return;let r=t(this,g)[e],a=h(this,n,O).call(this,r)?r.__staleWhileFetching:r;if(a===void 0)return;let o={value:a};if(t(this,K)&&t(this,tt)){let s=t(this,K)[e],l=t(this,tt)[e];if(s&&l){let u=s-(t(this,J).now()-l);o.ttl=u,o.start=Date.now();}}return t(this,Z)&&(o.size=t(this,Z)[e]),o}dump(){let i=[];for(let e of h(this,n,ot).call(this,{allowStale:true})){let r=t(this,w)[e],a=t(this,g)[e],o=h(this,n,O).call(this,a)?a.__staleWhileFetching:a;if(o===void 0||r===void 0)continue;let s={value:o};if(t(this,K)&&t(this,tt)){s.ttl=t(this,K)[e];let l=t(this,J).now()-t(this,tt)[e];s.start=Math.floor(Date.now()-l);}t(this,Z)&&(s.size=t(this,Z)[e]),i.unshift([r,s]);}return i}load(i){this.clear();for(let[e,r]of i){if(r.start){let a=Date.now()-r.start;r.start=t(this,J).now()-a;}this.set(e,r.value,r);}}set(i,e,r={}){var y,b,T,A;if(e===void 0)return this.delete(i),this;let{ttl:a=this.ttl,start:o,noDisposeOnSet:s=this.noDisposeOnSet,sizeCalculation:l=this.sizeCalculation,status:u}=r,{noUpdateTTL:E=this.noUpdateTTL}=r,I=t(this,Dt).call(this,i,e,r.size||0,l);if(this.maxEntrySize&&I>this.maxEntrySize)return u&&(u.set="miss",u.maxEntrySizeExceeded=true),h(this,n,lt).call(this,i,"set"),this;let d=t(this,C)===0?void 0:t(this,R).get(i);if(d===void 0)d=t(this,C)===0?t(this,D):t(this,Q).length!==0?t(this,Q).pop():t(this,C)===t(this,j)?h(this,n,Vt).call(this,false):t(this,C),t(this,w)[d]=i,t(this,g)[d]=e,t(this,R).set(i,d),t(this,V)[t(this,D)]=d,t(this,Y)[d]=t(this,D),f(this,D,d),Mt(this,C)._++,t(this,yt).call(this,d,I,u),u&&(u.set="add"),E=false,t(this,bt)&&((y=t(this,ft))==null||y.call(this,e,i,"add"));else {h(this,n,Ct).call(this,d);let v=t(this,g)[d];if(e!==v){if(t(this,ht)&&h(this,n,O).call(this,v)){v.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:p}=v;p!==void 0&&!s&&(t(this,et)&&((b=t(this,B))==null||b.call(this,p,i,"set")),t(this,L)&&t(this,N)?.push([p,i,"set"]));}else s||(t(this,et)&&((T=t(this,B))==null||T.call(this,v,i,"set")),t(this,L)&&t(this,N)?.push([v,i,"set"]));if(t(this,dt).call(this,d),t(this,yt).call(this,d,I,u),t(this,g)[d]=e,u){u.set="replace";let p=v&&h(this,n,O).call(this,v)?v.__staleWhileFetching:v;p!==void 0&&(u.oldValue=p);}}else u&&(u.set="update");t(this,bt)&&this.onInsert?.(e,i,e===v?"update":"replace");}if(a!==0&&!t(this,K)&&h(this,n,Wt).call(this),t(this,K)&&(E||t(this,It).call(this,d,a,o),u&&t(this,rt).call(this,u,d)),!s&&t(this,L)&&t(this,N)){let v=t(this,N),p;for(;p=v?.shift();)(A=t(this,X))==null||A.call(this,...p);}return this}pop(){var i;try{for(;t(this,C);){let e=t(this,g)[t(this,M)];if(h(this,n,Vt).call(this,!0),h(this,n,O).call(this,e)){if(e.__staleWhileFetching)return e.__staleWhileFetching}else if(e!==void 0)return e}}finally{if(t(this,L)&&t(this,N)){let e=t(this,N),r;for(;r=e?.shift();)(i=t(this,X))==null||i.call(this,...r);}}}has(i,e={}){let{updateAgeOnHas:r=this.updateAgeOnHas,status:a}=e,o=t(this,R).get(i);if(o!==void 0){let s=t(this,g)[o];if(h(this,n,O).call(this,s)&&s.__staleWhileFetching===void 0)return false;if(t(this,H).call(this,o))a&&(a.has="stale",t(this,rt).call(this,a,o));else return r&&t(this,gt).call(this,o),a&&(a.has="hit",t(this,rt).call(this,a,o)),true}else a&&(a.has="miss");return false}peek(i,e={}){let{allowStale:r=this.allowStale}=e,a=t(this,R).get(i);if(a===void 0||!r&&t(this,H).call(this,a))return;let o=t(this,g)[a];return h(this,n,O).call(this,o)?o.__staleWhileFetching:o}async fetch(i,e={}){let{allowStale:r=this.allowStale,updateAgeOnGet:a=this.updateAgeOnGet,noDeleteOnStaleGet:o=this.noDeleteOnStaleGet,ttl:s=this.ttl,noDisposeOnSet:l=this.noDisposeOnSet,size:u=0,sizeCalculation:E=this.sizeCalculation,noUpdateTTL:I=this.noUpdateTTL,noDeleteOnFetchRejection:d=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:y=this.allowStaleOnFetchRejection,ignoreFetchAbort:b=this.ignoreFetchAbort,allowStaleOnFetchAbort:T=this.allowStaleOnFetchAbort,context:A,forceRefresh:v=false,status:p,signal:F}=e;if(!t(this,ht))return p&&(p.fetch="get"),this.get(i,{allowStale:r,updateAgeOnGet:a,noDeleteOnStaleGet:o,status:p});let P={allowStale:r,updateAgeOnGet:a,noDeleteOnStaleGet:o,ttl:s,noDisposeOnSet:l,size:u,sizeCalculation:E,noUpdateTTL:I,noDeleteOnFetchRejection:d,allowStaleOnFetchRejection:y,allowStaleOnFetchAbort:T,ignoreFetchAbort:b,status:p,signal:F},G=t(this,R).get(i);if(G===void 0){p&&(p.fetch="miss");let x=h(this,n,Lt).call(this,i,G,P,A);return x.__returned=x}else {let x=t(this,g)[G];if(h(this,n,O).call(this,x)){let mt=r&&x.__staleWhileFetching!==void 0;return p&&(p.fetch="inflight",mt&&(p.returnedStale=true)),mt?x.__staleWhileFetching:x.__returned=x}let xt=t(this,H).call(this,G);if(!v&&!xt)return p&&(p.fetch="hit"),h(this,n,Ct).call(this,G),a&&t(this,gt).call(this,G),p&&t(this,rt).call(this,p,G),x;let pt=h(this,n,Lt).call(this,i,G,P,A),_t=pt.__staleWhileFetching!==void 0&&r;return p&&(p.fetch=xt?"stale":"refresh",_t&&xt&&(p.returnedStale=true)),_t?pt.__staleWhileFetching:pt.__returned=pt}}async forceFetch(i,e={}){let r=await this.fetch(i,e);if(r===void 0)throw new Error("fetch() returned undefined");return r}memo(i,e={}){let r=t(this,Tt);if(!r)throw new Error("no memoMethod provided to constructor");let{context:a,forceRefresh:o,...s}=e,l=this.get(i,s);if(!o&&l!==void 0)return l;let u=r(i,l,{options:s,context:a});return this.set(i,u,s),u}get(i,e={}){let{allowStale:r=this.allowStale,updateAgeOnGet:a=this.updateAgeOnGet,noDeleteOnStaleGet:o=this.noDeleteOnStaleGet,status:s}=e,l=t(this,R).get(i);if(l!==void 0){let u=t(this,g)[l],E=h(this,n,O).call(this,u);return s&&t(this,rt).call(this,s,l),t(this,H).call(this,l)?(s&&(s.get="stale"),E?(s&&r&&u.__staleWhileFetching!==void 0&&(s.returnedStale=true),r?u.__staleWhileFetching:void 0):(o||h(this,n,lt).call(this,i,"expire"),s&&r&&(s.returnedStale=true),r?u:void 0)):(s&&(s.get="hit"),E?u.__staleWhileFetching:(h(this,n,Ct).call(this,l),a&&t(this,gt).call(this,l),u))}else s&&(s.get="miss");}delete(i){return h(this,n,lt).call(this,i,"delete")}clear(){return h(this,n,jt).call(this,"delete")}},j=new WeakMap,z=new WeakMap,B=new WeakMap,ft=new WeakMap,X=new WeakMap,Et=new WeakMap,Tt=new WeakMap,J=new WeakMap,C=new WeakMap,q=new WeakMap,R=new WeakMap,w=new WeakMap,g=new WeakMap,V=new WeakMap,Y=new WeakMap,M=new WeakMap,D=new WeakMap,Q=new WeakMap,N=new WeakMap,Z=new WeakMap,tt=new WeakMap,K=new WeakMap,W=new WeakMap,et=new WeakMap,ht=new WeakMap,L=new WeakMap,bt=new WeakMap,n=new WeakSet,Wt=function(){let i=new Gt(t(this,j)),e=new Gt(t(this,j));f(this,K,i),f(this,tt,e);let r=this.ttlAutopurge?new Array(t(this,j)):void 0;f(this,W,r),f(this,It,(l,u,E=t(this,J).now())=>{e[l]=u!==0?E:0,i[l]=u,a(l,u);}),f(this,gt,l=>{e[l]=i[l]!==0?t(this,J).now():0,a(l,i[l]);});let a=this.ttlAutopurge?(l,u)=>{if(r?.[l]&&(clearTimeout(r[l]),r[l]=void 0),u&&u!==0&&r){let E=setTimeout(()=>{t(this,H).call(this,l)&&h(this,n,lt).call(this,t(this,w)[l],"expire");},u+1);E.unref&&E.unref(),r[l]=E;}}:()=>{};f(this,rt,(l,u)=>{if(i[u]){let E=i[u],I=e[u];if(!E||!I)return;l.ttl=E,l.start=I,l.now=o||s();let d=l.now-I;l.remainingTTL=E-d;}});let o=0,s=()=>{let l=t(this,J).now();if(this.ttlResolution>0){o=l;let u=setTimeout(()=>o=0,this.ttlResolution);u.unref&&u.unref();}return l};this.getRemainingTTL=l=>{let u=t(this,R).get(l);if(u===void 0)return 0;let E=i[u],I=e[u];if(!E||!I)return 1/0;let d=(o||s())-I;return E-d},f(this,H,l=>{let u=e[l],E=i[l];return !!E&&!!u&&(o||s())-u>E});},gt=new WeakMap,rt=new WeakMap,It=new WeakMap,H=new WeakMap,re=function(){let i=new Gt(t(this,j));f(this,q,0),f(this,Z,i),f(this,dt,e=>{f(this,q,t(this,q)-i[e]),i[e]=0;}),f(this,Dt,(e,r,a,o)=>{if(h(this,n,O).call(this,r))return 0;if(!at(a))if(o){if(typeof o!="function")throw new TypeError("sizeCalculation must be a function");if(a=o(r,e),!at(a))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 a}),f(this,yt,(e,r,a)=>{if(i[e]=r,t(this,z)){let o=t(this,z)-i[e];for(;t(this,q)>o;)h(this,n,Vt).call(this,true);}f(this,q,t(this,q)+i[e]),a&&(a.entrySize=r,a.totalCalculatedSize=t(this,q));});},dt=new WeakMap,yt=new WeakMap,Dt=new WeakMap,ot=function*({allowStale:i=this.allowStale}={}){if(t(this,C))for(let e=t(this,D);!(!h(this,n,Ht).call(this,e)||((i||!t(this,H).call(this,e))&&(yield e),e===t(this,M)));)e=t(this,Y)[e];},nt=function*({allowStale:i=this.allowStale}={}){if(t(this,C))for(let e=t(this,M);!(!h(this,n,Ht).call(this,e)||((i||!t(this,H).call(this,e))&&(yield e),e===t(this,D)));)e=t(this,V)[e];},Ht=function(i){return i!==void 0&&t(this,R).get(t(this,w)[i])===i},Vt=function(i){var o;let e=t(this,M),r=t(this,w)[e],a=t(this,g)[e];return t(this,ht)&&h(this,n,O).call(this,a)?a.__abortController.abort(new Error("evicted")):(t(this,et)||t(this,L))&&(t(this,et)&&((o=t(this,B))==null||o.call(this,a,r,"evict")),t(this,L)&&t(this,N)?.push([a,r,"evict"])),t(this,dt).call(this,e),t(this,W)?.[e]&&(clearTimeout(t(this,W)[e]),t(this,W)[e]=void 0),i&&(t(this,w)[e]=void 0,t(this,g)[e]=void 0,t(this,Q).push(e)),t(this,C)===1?(f(this,M,f(this,D,0)),t(this,Q).length=0):f(this,M,t(this,V)[e]),t(this,R).delete(r),Mt(this,C)._--,e},Lt=function(i,e,r,a){let o=e===void 0?void 0:t(this,g)[e];if(h(this,n,O).call(this,o))return o;let s=new Pt,{signal:l}=r;l?.addEventListener("abort",()=>s.abort(l.reason),{signal:s.signal});let u={signal:s.signal,options:r,context:a},E=(A,v=false)=>{let{aborted:p}=s.signal,F=r.ignoreFetchAbort&&A!==void 0,P=r.ignoreFetchAbort||!!(r.allowStaleOnFetchAbort&&A!==void 0);if(r.status&&(p&&!v?(r.status.fetchAborted=true,r.status.fetchError=s.signal.reason,F&&(r.status.fetchAbortIgnored=true)):r.status.fetchResolved=true),p&&!F&&!v)return d(s.signal.reason,P);let G=b,x=t(this,g)[e];return (x===b||F&&v&&x===void 0)&&(A===void 0?G.__staleWhileFetching!==void 0?t(this,g)[e]=G.__staleWhileFetching:h(this,n,lt).call(this,i,"fetch"):(r.status&&(r.status.fetchUpdated=true),this.set(i,A,u.options))),A},I=A=>(r.status&&(r.status.fetchRejected=true,r.status.fetchError=A),d(A,false)),d=(A,v)=>{let{aborted:p}=s.signal,F=p&&r.allowStaleOnFetchAbort,P=F||r.allowStaleOnFetchRejection,G=P||r.noDeleteOnFetchRejection,x=b;if(t(this,g)[e]===b&&(!G||!v&&x.__staleWhileFetching===void 0?h(this,n,lt).call(this,i,"fetch"):F||(t(this,g)[e]=x.__staleWhileFetching)),P)return r.status&&x.__staleWhileFetching!==void 0&&(r.status.returnedStale=true),x.__staleWhileFetching;if(x.__returned===x)throw A},y=(A,v)=>{var F;let p=(F=t(this,Et))==null?void 0:F.call(this,i,o,u);p&&p instanceof Promise&&p.then(P=>A(P===void 0?void 0:P),v),s.signal.addEventListener("abort",()=>{(!r.ignoreFetchAbort||r.allowStaleOnFetchAbort)&&(A(void 0),r.allowStaleOnFetchAbort&&(A=P=>E(P,true)));});};r.status&&(r.status.fetchDispatched=true);let b=new Promise(y).then(E,I),T=Object.assign(b,{__abortController:s,__staleWhileFetching:o,__returned:void 0});return e===void 0?(this.set(i,T,{...u.options,status:void 0}),e=t(this,R).get(i)):t(this,g)[e]=T,T},O=function(i){if(!t(this,ht))return false;let e=i;return !!e&&e instanceof Promise&&e.hasOwnProperty("__staleWhileFetching")&&e.__abortController instanceof Pt},$t=function(i,e){t(this,Y)[e]=i,t(this,V)[i]=e;},Ct=function(i){i!==t(this,D)&&(i===t(this,M)?f(this,M,t(this,V)[i]):h(this,n,$t).call(this,t(this,Y)[i],t(this,V)[i]),h(this,n,$t).call(this,t(this,D),i),f(this,D,i));},lt=function(i,e){var a,o;let r=false;if(t(this,C)!==0){let s=t(this,R).get(i);if(s!==void 0)if(t(this,W)?.[s]&&(clearTimeout(t(this,W)?.[s]),t(this,W)[s]=void 0),r=true,t(this,C)===1)h(this,n,jt).call(this,e);else {t(this,dt).call(this,s);let l=t(this,g)[s];if(h(this,n,O).call(this,l)?l.__abortController.abort(new Error("deleted")):(t(this,et)||t(this,L))&&(t(this,et)&&((a=t(this,B))==null||a.call(this,l,i,e)),t(this,L)&&t(this,N)?.push([l,i,e])),t(this,R).delete(i),t(this,w)[s]=void 0,t(this,g)[s]=void 0,s===t(this,D))f(this,D,t(this,Y)[s]);else if(s===t(this,M))f(this,M,t(this,V)[s]);else {let u=t(this,Y)[s];t(this,V)[u]=t(this,V)[s];let E=t(this,V)[s];t(this,Y)[E]=t(this,Y)[s];}Mt(this,C)._--,t(this,Q).push(s);}}if(t(this,L)&&t(this,N)?.length){let s=t(this,N),l;for(;l=s?.shift();)(o=t(this,X))==null||o.call(this,...l);}return r},jt=function(i){var e,r;for(let a of h(this,n,nt).call(this,{allowStale:true})){let o=t(this,g)[a];if(h(this,n,O).call(this,o))o.__abortController.abort(new Error("deleted"));else {let s=t(this,w)[a];t(this,et)&&((e=t(this,B))==null||e.call(this,o,s,i)),t(this,L)&&t(this,N)?.push([o,s,i]);}}if(t(this,R).clear(),t(this,g).fill(void 0),t(this,w).fill(void 0),t(this,K)&&t(this,tt)){t(this,K).fill(0),t(this,tt).fill(0);for(let a of t(this,W)??[])a!==void 0&&clearTimeout(a);t(this,W)?.fill(void 0);}if(t(this,Z)&&t(this,Z).fill(0),f(this,M,0),f(this,D,0),t(this,Q).length=0,f(this,q,0),f(this,C,0),t(this,L)&&t(this,N)){let a=t(this,N),o;for(;o=a?.shift();)(r=t(this,X))==null||r.call(this,...o);}},At);var ct=class{constructor(i){_(this,"cache");_(this,"map",new Map);this.cache=new ie({max:i.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(i){let e=this.map.delete(i);return e&&this.cache.delete(i),e}get forEach(){return this.map.forEach}get(i){let e=this.cache.get(i);return e||this.map.get(i)}has(i){return this.map.has(i)}set(i,e){return this.map.set(i,e),this.cache.set(i,e),this}get size(){return this.map.size}entries(){return this.map.entries()}keys(){return this.map.keys()}values(){return this.map.values()}};var kt;(d=>{d.storage=new ct({cacheSize:50}),d.defaultStorage=new ct({cacheSize:10}),d.tempStorageDeadlines=new Map;let r;function a(y){d.tempStorageDeadlines.forEach((b,T)=>{b>y&&(d.storage.delete(`${ut}:${T}`),r?.onClearOldTempVariable?.(T),d.tempStorageDeadlines.delete(T));});}d.clearOldTempVariables=a;function o(y){r=y;}d.setExternalStoreHandler=o;function s(y,b,T){T==null?d.storage.delete(`${y}:${b}`):d.storage.set(`${y}:${b}`,T),r?.onSetVariable?.(b,T);}d.setVariable=s;function l(y,b){let T=d.storage.get(`${y}:${b}`);return Rt(T)}d.getVariable=l;function u(y,b){d.storage.delete(`${y}:${b}`),r?.onRemoveVariable?.(b);}d.removeVariable=u;function E(y,b){let T=d.storage.get(Ft)||[];if(b)T.includes(y)||T.push(y);else {let A=T.indexOf(y);A>-1&&T.splice(A,1);}d.storage.set(Ft,T);}d.setFlag=E;function I(y){return (d.storage.get(Ft)||[]).includes(y)}d.getFlag=I;})(kt||(kt={}));var S=kt;var vt=class{constructor(i,e){_(this,"id");_(this,"categoryId");this.categoryId=i,this.id=e,this.migrateOldStorage();}migrateOldStorage(i=this.categoryId){let e=S.getVariable(st,i);e&&(Object.entries(e).forEach(([r,a])=>{typeof a=="object"&&a!==null&&Object.entries(a).forEach(([o,s])=>{S.setVariable(this.categoryId,`${r}:${o}`,s);});}),S.removeVariable(st,i));}setStorageProperty(i,e){S.setVariable(this.categoryId,`${this.id}:${i}`,e);}getStorageProperty(i,e=this.id){return S.getVariable(this.categoryId,`${e}:${i}`)}};var ue="@",Ot=class extends vt{constructor(e,r=""){super(U.CHARACTER_CATEGORY_KEY,e+(r?ue+r:""));_(this,"sourceId");this.sourceId=e,this.migrateOldStorage("___character___");}getStorageProperty(e){let r=super.getStorageProperty(e);return r===void 0&&(r=super.getStorageProperty(e,this.sourceId)),r}};var Ut=class extends Ot{constructor(e,r){super(typeof e=="string"?e:e.id,typeof e=="string"?"":e.emotion);_(this,"defaultName");_(this,"defaultSurname");_(this,"defaultAge");_(this,"_icon");_(this,"_color");this.defaultName=r.name,this.defaultSurname=r.surname,this.defaultAge=r.age,this._icon=r.icon,this._color=r.color;}get name(){return this.getStorageProperty("name")||this.defaultName||this.id}set name(e){this.setStorageProperty("name",e);}get surname(){return this.getStorageProperty("surname")||this.defaultSurname}set surname(e){this.setStorageProperty("surname",e);}get age(){return this.getStorageProperty("age")||this.defaultAge}set age(e){this.setStorageProperty("age",e);}get icon(){return this._icon}get color(){return this._color}};var wt=new ct({cacheSize:10}),Bt;(o=>{function c(s){try{let l=wt.get(s);if(!l){k.warn(`Character "${s}" not found, did you forget to register it with the RegisteredCharacters.add?`);return}return l}catch(l){k.error(`Error while getting Character "${s}"`,l);return}}o.get=c;function i(s){if(Array.isArray(s)){s.forEach(l=>{i(l);});return}wt.get(s.id)&&k.info(`Character id "${s.id}" already exists, it will be overwritten`),wt.set(s.id,s);}o.add=i;function e(){return Array.from(wt.values())}o.values=e;function r(s){return wt.has(s)}o.has=r;function a(){return Array.from(wt.keys())}o.keys=a;})(Bt||(Bt={}));var fe=Bt;exports.CharacterBaseModel=Ut;exports.CharacterStoredClass=Ot;exports.RegisteredCharacters=fe;
|
package/dist/characters.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import {b}from'./chunk-
|
|
1
|
+
import {b}from'./chunk-4KCAZKAJ.mjs';import {a}from'./chunk-YDNEIPJP.mjs';import {n}from'./chunk-IWAXXFXE.mjs';import {j,d as d$1}from'./chunk-HNGW4ITF.mjs';var l="@",i=class extends b{constructor(e,r=""){super(n.CHARACTER_CATEGORY_KEY,e+(r?l+r:""));d$1(this,"sourceId");this.sourceId=e,this.migrateOldStorage("___character___");}getStorageProperty(e){let r=super.getStorageProperty(e);return r===void 0&&(r=super.getStorageProperty(e,this.sourceId)),r}};var u=class extends i{constructor(e,r){super(typeof e=="string"?e:e.id,typeof e=="string"?"":e.emotion);d$1(this,"defaultName");d$1(this,"defaultSurname");d$1(this,"defaultAge");d$1(this,"_icon");d$1(this,"_color");this.defaultName=r.name,this.defaultSurname=r.surname,this.defaultAge=r.age,this._icon=r.icon,this._color=r.color;}get name(){return this.getStorageProperty("name")||this.defaultName||this.id}set name(e){this.setStorageProperty("name",e);}get surname(){return this.getStorageProperty("surname")||this.defaultSurname}set surname(e){this.setStorageProperty("surname",e);}get age(){return this.getStorageProperty("age")||this.defaultAge}set age(e){this.setStorageProperty("age",e);}get icon(){return this._icon}get color(){return this._color}};var s=new a({cacheSize:10}),d;(y=>{function f(t){try{let n=s.get(t);if(!n){j.warn(`Character "${t}" not found, did you forget to register it with the RegisteredCharacters.add?`);return}return n}catch(n){j.error(`Error while getting Character "${t}"`,n);return}}y.get=f;function g(t){if(Array.isArray(t)){t.forEach(n=>{g(n);});return}s.get(t.id)&&j.info(`Character id "${t.id}" already exists, it will be overwritten`),s.set(t.id,t);}y.add=g;function e(){return Array.from(s.values())}y.values=e;function r(t){return s.has(t)}y.has=r;function C(){return Array.from(s.keys())}y.keys=C;})(d||(d={}));var p=d;export{u as CharacterBaseModel,i as CharacterStoredClass,p as RegisteredCharacters};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import {a}from'./chunk-YDNEIPJP.mjs';import {k as k$1,m,j,l,n}from'./chunk-IWAXXFXE.mjs';import {k as k$2,j as j$1,d}from'./chunk-HNGW4ITF.mjs';import {GameUnifier}from'@drincs/pixi-vn/core';var T;(s=>{s.storage=new a({cacheSize:50}),s.defaultStorage=new a({cacheSize:10}),s.tempStorageDeadlines=new Map;let n;function c(a){s.tempStorageDeadlines.forEach((l,o)=>{l>a&&(s.storage.delete(`${k$1}:${o}`),n?.onClearOldTempVariable?.(o),s.tempStorageDeadlines.delete(o));});}s.clearOldTempVariables=c;function h(a){n=a;}s.setExternalStoreHandler=h;function V(a,l,o){o==null?s.storage.delete(`${a}:${l}`):s.storage.set(`${a}:${l}`,o),n?.onSetVariable?.(l,o);}s.setVariable=V;function O(a,l){let o=s.storage.get(`${a}:${l}`);return k$2(o)}s.getVariable=O;function M(a,l){s.storage.delete(`${a}:${l}`),n?.onRemoveVariable?.(l);}s.removeVariable=M;function D(a,l){let o=s.storage.get(m)||[];if(l)o.includes(a)||o.push(a);else {let x=o.indexOf(a);x>-1&&o.splice(x,1);}s.storage.set(m,o);}s.setFlag=D;function R(a){return (s.storage.get(m)||[]).includes(a)}s.getFlag=R;})(T||(T={}));var r=T;var S=class{get base(){return r.storage.map}get cache(){return r.storage.cache}get tempStorageDeadlines(){return r.tempStorageDeadlines}set default(t){Object.entries(t).forEach(([e,n])=>{r.defaultStorage.map.set(e,n);});}set(t,e){return r.setVariable(j,t,e)}get(t){let e=r.getVariable(k$1,t);return e===void 0&&(e=r.getVariable(j,t)),e===void 0&&(e=k$2(r.defaultStorage.get(t))),e}remove(t){return this.removeTempVariable(t),r.removeVariable(j,t)}setTempVariable(t,e){if(e==null){this.removeTempVariable(t);return}else r.setVariable(k$1,t,e),this.tempStorageDeadlines.has(t)||this.tempStorageDeadlines.set(t,GameUnifier.openedLabels);}removeTempVariable(t){r.removeVariable(k$1,t),this.tempStorageDeadlines.has(t)&&this.tempStorageDeadlines.delete(t);}setFlag(t,e){return r.setFlag(t,e)}getFlag(t){return r.getFlag(t)}setStorageHandler(t){r.setExternalStoreHandler(t);}clear(){this.base.clear(),this.cache.clear(),this.tempStorageDeadlines.clear();}export(){let t=[];[...this.base.keys()].forEach(n=>{t.push({key:n,value:this.base.get(n)});});let e=[];return [...r.tempStorageDeadlines.keys()].forEach(n=>{e.push({key:n,value:this.tempStorageDeadlines.get(n)});}),k$2({main:t,tempDeadlines:e})}restore(t){this.clear();try{t?(t.base?.forEach(e=>{switch(e.key){case "___current_dialogue_memory___":r.setVariable(l,n.CURRENT_DIALOGUE_MEMORY_KEY,e.value);break;case "___last_dialogue_added_in_step_memory___":r.setVariable(l,n.LAST_DIALOGUE_ADDED_IN_STEP_MEMORY_KEY,e.value);break;case "___current_menu_options_memory___":r.setVariable(l,n.CURRENT_MENU_OPTIONS_MEMORY_KEY,e.value);break;case "___last_menu_options_added_in_step_memory___":r.setVariable(l,n.LAST_MENU_OPTIONS_ADDED_IN_STEP_MEMORY_KEY,e.value);break;case "_input_value_":r.setVariable(l,n.CURRENT_INPUT_VALUE_MEMORY_KEY,e.value);break;case "___last_input_added_in_step_memory___":r.setVariable(l,n.LAST_INPUT_ADDED_IN_STEP_MEMORY_KEY,e.value);break;case "___current_input_info_memory___":r.setVariable(l,n.CURRENT_INPUT_INFO_MEMORY_KEY,e.value);break;case "___opened_labels_counter___":r.setVariable(l,n.OPENED_LABELS_COUNTER_KEY,e.value);break;case "___all_choices_made___":r.setVariable(l,n.ALL_CHOICES_MADE_KEY,e.value);break;case "___current_step_times_counter___":r.setVariable(l,n.CURRENT_STEP_TIMES_COUNTER_KEY,e.value);break;case "___last_step_glued___":r.setVariable(l,n.LAST_STEP_GLUED,e.value);break;default:r.setVariable(j,e.key,e.value);}}),t.temp?.forEach(e=>{r.setVariable(k$1,e.key,e.value);}),t.flags?.forEach(e=>{r.setFlag(e,!0);}),t.main?.forEach(e=>{this.base.set(e.key,e.value);}),t.tempDeadlines?.forEach(e=>{this.tempStorageDeadlines.set(e.key,e.value);})):j$1.warn("No storage data found");}catch(e){j$1.error("Error importing data",e);}}};var f=class{constructor(t,e){d(this,"id");d(this,"categoryId");this.categoryId=t,this.id=e,this.migrateOldStorage();}migrateOldStorage(t=this.categoryId){let e=r.getVariable(j,t);e&&(Object.entries(e).forEach(([n,c])=>{typeof c=="object"&&c!==null&&Object.entries(c).forEach(([h,V])=>{r.setVariable(this.categoryId,`${n}:${h}`,V);});}),r.removeVariable(j,t));}setStorageProperty(t,e){r.setVariable(this.categoryId,`${this.id}:${t}`,e);}getStorageProperty(t,e=this.id){return r.getVariable(this.categoryId,`${e}:${t}`)}};var k=new S;export{r as a,f as b,k as c};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import {PixiError}from'@drincs/pixi-vn/core';var y=Object.create;var p=Object.defineProperty;var f=Object.getOwnPropertyDescriptor;var l=Object.getOwnPropertyNames;var m=Object.getPrototypeOf,N=Object.prototype.hasOwnProperty;var
|
|
1
|
+
import {PixiError}from'@drincs/pixi-vn/core';var y=Object.create;var p=Object.defineProperty;var f=Object.getOwnPropertyDescriptor;var l=Object.getOwnPropertyNames;var m=Object.getPrototypeOf,N=Object.prototype.hasOwnProperty;var x=r=>{throw TypeError(r)};var E=(r,o,n)=>o in r?p(r,o,{enumerable:true,configurable:true,writable:true,value:n}):r[o]=n;var V=(r=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(r,{get:(o,n)=>(typeof require<"u"?require:o)[n]}):r)(function(r){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+r+'" is not supported')});var $=(r,o)=>()=>(o||r((o={exports:{}}).exports,o),o.exports);var P=(r,o,n,t)=>{if(o&&typeof o=="object"||typeof o=="function")for(let e of l(o))!N.call(r,e)&&e!==n&&p(r,e,{get:()=>o[e],enumerable:!(t=f(o,e))||t.enumerable});return r};var S=(r,o,n)=>(n=r!=null?y(m(r)):{},P(o||!r||!r.__esModule?p(n,"default",{value:r,enumerable:true}):n,r));var T=(r,o,n)=>E(r,typeof o!="symbol"?o+"":o,n),s=(r,o,n)=>o.has(r)||x("Cannot "+n);var b=(r,o,n)=>(s(r,o,"read from private field"),n?n.call(r):o.get(r)),d=(r,o,n)=>o.has(r)?x("Cannot add the same private member more than once"):o instanceof WeakSet?o.add(r):o.set(r,n),u=(r,o,n,t)=>(s(r,o,"write to private field"),t?t.call(r,n):o.set(r,n),n),h=(r,o,n)=>(s(r,o,"access private method"),n);var J=(r,o,n,t)=>({set _(e){u(r,o,e,n);},get _(){return b(r,o,t)}});var c;(e=>(e.log=(i,...a)=>console.log(`[Pixi\u2019VN] ${i}`,...a),e.warn=(i,...a)=>console.warn(`[Pixi\u2019VN] ${i}`,...a),e.error=(i,...a)=>console.error(`[Pixi\u2019VN] ${i}`,...a),e.info=(i,...a)=>console.info(`[Pixi\u2019VN] ${i}`,...a)))(c||(c={}));function k(r){try{if(typeof r>"u")return r;let o=JSON.stringify(r);return JSON.parse(o)}catch(o){throw c.error("Error creating exportable element",r,o),new PixiError("not_json_serializable","Error creating exportable element")}}export{V as a,$ as b,S as c,T as d,b as e,d as f,u as g,h,J as i,c as j,k};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import {b,a}from'./chunk-
|
|
1
|
+
import {b,a}from'./chunk-HNGW4ITF.mjs';var L=b((S,I)=>{(function(w,o){typeof S=="object"?I.exports=S=o():typeof define=="function"&&define.amd?define([],o):w.CryptoJS=o();})(S,function(){var w=w||(function(o,x){var a$1;if(typeof window<"u"&&window.crypto&&(a$1=window.crypto),typeof self<"u"&&self.crypto&&(a$1=self.crypto),typeof globalThis<"u"&&globalThis.crypto&&(a$1=globalThis.crypto),!a$1&&typeof window<"u"&&window.msCrypto&&(a$1=window.msCrypto),!a$1&&typeof global<"u"&&global.crypto&&(a$1=global.crypto),!a$1&&typeof a=="function")try{a$1=a("crypto");}catch{}var _=function(){if(a$1){if(typeof a$1.getRandomValues=="function")try{return a$1.getRandomValues(new Uint32Array(1))[0]}catch{}if(typeof a$1.randomBytes=="function")try{return a$1.randomBytes(4).readInt32LE()}catch{}}throw new Error("Native crypto module could not be used to get secure random number.")},C=Object.create||(function(){function t(){}return function(e){var n;return t.prototype=e,n=new t,t.prototype=null,n}})(),d={},B=d.lib={},u=B.Base=(function(){return {extend:function(t){var e=C(this);return t&&e.mixIn(t),(!e.hasOwnProperty("init")||this.init===e.init)&&(e.init=function(){e.$super.init.apply(this,arguments);}),e.init.prototype=e,e.$super=this,e},create:function(){var t=this.extend();return t.init.apply(t,arguments),t},init:function(){},mixIn:function(t){for(var e in t)t.hasOwnProperty(e)&&(this[e]=t[e]);t.hasOwnProperty("toString")&&(this.toString=t.toString);},clone:function(){return this.init.prototype.extend(this)}}})(),l=B.WordArray=u.extend({init:function(t,e){t=this.words=t||[],e!=x?this.sigBytes=e:this.sigBytes=t.length*4;},toString:function(t){return (t||v).stringify(this)},concat:function(t){var e=this.words,n=t.words,r=this.sigBytes,f=t.sigBytes;if(this.clamp(),r%4)for(var c=0;c<f;c++){var z=n[c>>>2]>>>24-c%4*8&255;e[r+c>>>2]|=z<<24-(r+c)%4*8;}else for(var g=0;g<f;g+=4)e[r+g>>>2]=n[g>>>2];return this.sigBytes+=f,this},clamp:function(){var t=this.words,e=this.sigBytes;t[e>>>2]&=4294967295<<32-e%4*8,t.length=o.ceil(e/4);},clone:function(){var t=u.clone.call(this);return t.words=this.words.slice(0),t},random:function(t){for(var e=[],n=0;n<t;n+=4)e.push(_());return new l.init(e,t)}}),i=d.enc={},v=i.Hex={stringify:function(t){for(var e=t.words,n=t.sigBytes,r=[],f=0;f<n;f++){var c=e[f>>>2]>>>24-f%4*8&255;r.push((c>>>4).toString(16)),r.push((c&15).toString(16));}return r.join("")},parse:function(t){for(var e=t.length,n=[],r=0;r<e;r+=2)n[r>>>3]|=parseInt(t.substr(r,2),16)<<24-r%8*4;return new l.init(n,e/2)}},h=i.Latin1={stringify:function(t){for(var e=t.words,n=t.sigBytes,r=[],f=0;f<n;f++){var c=e[f>>>2]>>>24-f%4*8&255;r.push(String.fromCharCode(c));}return r.join("")},parse:function(t){for(var e=t.length,n=[],r=0;r<e;r++)n[r>>>2]|=(t.charCodeAt(r)&255)<<24-r%4*8;return new l.init(n,e)}},p=i.Utf8={stringify:function(t){try{return decodeURIComponent(escape(h.stringify(t)))}catch{throw new Error("Malformed UTF-8 data")}},parse:function(t){return h.parse(unescape(encodeURIComponent(t)))}},y=B.BufferedBlockAlgorithm=u.extend({reset:function(){this._data=new l.init,this._nDataBytes=0;},_append:function(t){typeof t=="string"&&(t=p.parse(t)),this._data.concat(t),this._nDataBytes+=t.sigBytes;},_process:function(t){var e,n=this._data,r=n.words,f=n.sigBytes,c=this.blockSize,z=c*4,g=f/z;t?g=o.ceil(g):g=o.max((g|0)-this._minBufferSize,0);var b=g*c,R=o.min(b*4,f);if(b){for(var A=0;A<b;A+=c)this._doProcessBlock(r,A);e=r.splice(0,b),n.sigBytes-=R;}return new l.init(e,R)},clone:function(){var t=u.clone.call(this);return t._data=this._data.clone(),t},_minBufferSize:0});B.Hasher=y.extend({cfg:u.extend(),init:function(t){this.cfg=this.cfg.extend(t),this.reset();},reset:function(){y.reset.call(this),this._doReset();},update:function(t){return this._append(t),this._process(),this},finalize:function(t){t&&this._append(t);var e=this._doFinalize();return e},blockSize:512/32,_createHelper:function(t){return function(e,n){return new t.init(n).finalize(e)}},_createHmacHelper:function(t){return function(e,n){return new s.HMAC.init(t,n).finalize(e)}}});var s=d.algo={};return d})(Math);return w});});var T=b((H,P)=>{(function(w,o){typeof H=="object"?P.exports=H=o(L()):typeof define=="function"&&define.amd?define(["./core"],o):o(w.CryptoJS);})(H,function(w){return (function(){var o=w,x=o.lib,a=x.WordArray,_=x.Hasher,C=o.algo,d=[],B=C.SHA1=_.extend({_doReset:function(){this._hash=new a.init([1732584193,4023233417,2562383102,271733878,3285377520]);},_doProcessBlock:function(u,l){for(var i=this._hash.words,v=i[0],h=i[1],p=i[2],y=i[3],m=i[4],s=0;s<80;s++){if(s<16)d[s]=u[l+s]|0;else {var t=d[s-3]^d[s-8]^d[s-14]^d[s-16];d[s]=t<<1|t>>>31;}var e=(v<<5|v>>>27)+m+d[s];s<20?e+=(h&p|~h&y)+1518500249:s<40?e+=(h^p^y)+1859775393:s<60?e+=(h&p|h&y|p&y)-1894007588:e+=(h^p^y)-899497514,m=y,y=p,p=h<<30|h>>>2,h=v,v=e;}i[0]=i[0]+v|0,i[1]=i[1]+h|0,i[2]=i[2]+p|0,i[3]=i[3]+y|0,i[4]=i[4]+m|0;},_doFinalize:function(){var u=this._data,l=u.words,i=this._nDataBytes*8,v=u.sigBytes*8;return l[v>>>5]|=128<<24-v%32,l[(v+64>>>9<<4)+14]=Math.floor(i/4294967296),l[(v+64>>>9<<4)+15]=i,u.sigBytes=l.length*4,this._process(),this._hash},clone:function(){var u=_.clone.call(this);return u._hash=this._hash.clone(),u}});o.SHA1=_._createHelper(B),o.HmacSHA1=_._createHmacHelper(B);})(),w.SHA1});});export{T as a};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import {d,f,e,g,h,i}from'./chunk-D45QSSXG.mjs';var kt=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,Gt=new Set,zt=typeof process=="object"&&process?process:{},Mt=(_,e,i,s)=>{typeof zt.emitWarning=="function"?zt.emitWarning(_,e,i,s):console.error(`[${i}] ${e}: ${_}`);},Ft=globalThis.AbortController,Dt=globalThis.AbortSignal;if(typeof Ft>"u"){Dt=class{constructor(){d(this,"onabort");d(this,"_onabort",[]);d(this,"reason");d(this,"aborted",false);}addEventListener(i,s){this._onabort.push(s);}},Ft=class{constructor(){d(this,"signal",new Dt);e();}abort(i){if(!this.signal.aborted){this.signal.reason=i,this.signal.aborted=true;for(let s of this.signal._onabort)s(i);this.signal.onabort?.(i);}}};let _=zt.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",e=()=>{_&&(_=false,Mt("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 Ht=_=>!Gt.has(_);var tt=_=>_&&_===Math.floor(_)&&_>0&&isFinite(_),jt=_=>tt(_)?_<=Math.pow(2,8)?Uint8Array:_<=Math.pow(2,16)?Uint16Array:_<=Math.pow(2,32)?Uint32Array:_<=Number.MAX_SAFE_INTEGER?yt:null:null,yt=class extends Array{constructor(_){super(_),this.fill(0);}},J,ft,Vt=(J=class{constructor(e$1,i){d(this,"heap");d(this,"length");if(!e(J,ft))throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new i(e$1),this.length=0;}static create(e){let i=jt(e);if(!i)return [];g(J,ft,true);let s=new J(e,i);return g(J,ft,false),s}push(e){this.heap[this.length++]=e;}pop(){return this.heap[--this.length]}},ft=new WeakMap,f(J,ft,false),J),Lt,Ut,k,U,H,ot,V,ct,dt,K,F,P,O,b,c,W,G,x,E,B,T,$,q,M,j,X,ht,D,gt,o,xt,rt,Q,St,I,Nt,nt,pt,bt,et,it,Ct,At,Ot,S,Rt,vt,st,Wt,wt,It=(wt=class{constructor(e$1){f(this,o);f(this,k);f(this,U);f(this,H);f(this,ot);f(this,V);f(this,ct);f(this,dt);f(this,K);d(this,"ttl");d(this,"ttlResolution");d(this,"ttlAutopurge");d(this,"updateAgeOnGet");d(this,"updateAgeOnHas");d(this,"allowStale");d(this,"noDisposeOnSet");d(this,"noUpdateTTL");d(this,"maxEntrySize");d(this,"sizeCalculation");d(this,"noDeleteOnFetchRejection");d(this,"noDeleteOnStaleGet");d(this,"allowStaleOnFetchAbort");d(this,"allowStaleOnFetchRejection");d(this,"ignoreFetchAbort");f(this,F);f(this,P);f(this,O);f(this,b);f(this,c);f(this,W);f(this,G);f(this,x);f(this,E);f(this,B);f(this,T);f(this,$);f(this,q);f(this,M);f(this,j);f(this,X);f(this,ht);f(this,D);f(this,gt);f(this,rt,()=>{});f(this,Q,()=>{});f(this,St,()=>{});f(this,I,()=>false);f(this,nt,e=>{});f(this,pt,(e,i,s)=>{});f(this,bt,(e,i,s,h)=>{if(s||h)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0});d(this,Lt,"LRUCache");let{max:i=0,ttl:s,ttlResolution:h$1=1,ttlAutopurge:n,updateAgeOnGet:r,updateAgeOnHas:a,allowStale:u,dispose:p,onInsert:z,disposeAfter:w,noDisposeOnSet:Z,noUpdateTTL:N,maxSize:Y=0,maxEntrySize:y=0,sizeCalculation:v,fetchMethod:d$1,memoMethod:C,noDeleteOnFetchRejection:L,noDeleteOnStaleGet:R,allowStaleOnFetchRejection:A,allowStaleOnFetchAbort:mt,ignoreFetchAbort:lt,perf:at}=e$1;if(at!==void 0&&typeof at?.now!="function")throw new TypeError("perf option must have a now() method if specified");if(g(this,K,at??kt),i!==0&&!tt(i))throw new TypeError("max option must be a nonnegative integer");let ut=i?jt(i):Array;if(!ut)throw new Error("invalid max value: "+i);if(g(this,k,i),g(this,U,Y),this.maxEntrySize=y||e(this,U),this.sizeCalculation=v,this.sizeCalculation){if(!e(this,U)&&!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(C!==void 0&&typeof C!="function")throw new TypeError("memoMethod must be a function if defined");if(g(this,dt,C),d$1!==void 0&&typeof d$1!="function")throw new TypeError("fetchMethod must be a function if specified");if(g(this,ct,d$1),g(this,ht,!!d$1),g(this,O,new Map),g(this,b,new Array(i).fill(void 0)),g(this,c,new Array(i).fill(void 0)),g(this,W,new ut(i)),g(this,G,new ut(i)),g(this,x,0),g(this,E,0),g(this,B,Vt.create(i)),g(this,F,0),g(this,P,0),typeof p=="function"&&g(this,H,p),typeof z=="function"&&g(this,ot,z),typeof w=="function"?(g(this,V,w),g(this,T,[])):(g(this,V,void 0),g(this,T,void 0)),g(this,X,!!e(this,H)),g(this,gt,!!e(this,ot)),g(this,D,!!e(this,V)),this.noDisposeOnSet=!!Z,this.noUpdateTTL=!!N,this.noDeleteOnFetchRejection=!!L,this.allowStaleOnFetchRejection=!!A,this.allowStaleOnFetchAbort=!!mt,this.ignoreFetchAbort=!!lt,this.maxEntrySize!==0){if(e(this,U)!==0&&!tt(e(this,U)))throw new TypeError("maxSize must be a positive integer if specified");if(!tt(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");h(this,o,Nt).call(this);}if(this.allowStale=!!u,this.noDeleteOnStaleGet=!!R,this.updateAgeOnGet=!!r,this.updateAgeOnHas=!!a,this.ttlResolution=tt(h$1)||h$1===0?h$1:1,this.ttlAutopurge=!!n,this.ttl=s||0,this.ttl){if(!tt(this.ttl))throw new TypeError("ttl must be a positive integer if specified");h(this,o,xt).call(this);}if(e(this,k)===0&&this.ttl===0&&e(this,U)===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!e(this,k)&&!e(this,U)){let Tt="LRU_CACHE_UNBOUNDED";Ht(Tt)&&(Gt.add(Tt),Mt("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",Tt,wt));}}get perf(){return e(this,K)}static unsafeExposeInternals(e$1){return {starts:e(e$1,q),ttls:e(e$1,M),autopurgeTimers:e(e$1,j),sizes:e(e$1,$),keyMap:e(e$1,O),keyList:e(e$1,b),valList:e(e$1,c),next:e(e$1,W),prev:e(e$1,G),get head(){return e(e$1,x)},get tail(){return e(e$1,E)},free:e(e$1,B),isBackgroundFetch:i=>{var s;return h(s=e$1,o,S).call(s,i)},backgroundFetch:(i,s,h$1,n)=>{var r;return h(r=e$1,o,Ot).call(r,i,s,h$1,n)},moveToTail:i=>{var s;return h(s=e$1,o,vt).call(s,i)},indexes:i=>{var s;return h(s=e$1,o,et).call(s,i)},rindexes:i=>{var s;return h(s=e$1,o,it).call(s,i)},isStale:i=>{var s;return e(s=e$1,I).call(s,i)}}}get max(){return e(this,k)}get maxSize(){return e(this,U)}get calculatedSize(){return e(this,P)}get size(){return e(this,F)}get fetchMethod(){return e(this,ct)}get memoMethod(){return e(this,dt)}get dispose(){return e(this,H)}get onInsert(){return e(this,ot)}get disposeAfter(){return e(this,V)}getRemainingTTL(e$1){return e(this,O).has(e$1)?1/0:0}*entries(){for(let e$1 of h(this,o,et).call(this))e(this,c)[e$1]!==void 0&&e(this,b)[e$1]!==void 0&&!h(this,o,S).call(this,e(this,c)[e$1])&&(yield [e(this,b)[e$1],e(this,c)[e$1]]);}*rentries(){for(let e$1 of h(this,o,it).call(this))e(this,c)[e$1]!==void 0&&e(this,b)[e$1]!==void 0&&!h(this,o,S).call(this,e(this,c)[e$1])&&(yield [e(this,b)[e$1],e(this,c)[e$1]]);}*keys(){for(let e$1 of h(this,o,et).call(this)){let i=e(this,b)[e$1];i!==void 0&&!h(this,o,S).call(this,e(this,c)[e$1])&&(yield i);}}*rkeys(){for(let e$1 of h(this,o,it).call(this)){let i=e(this,b)[e$1];i!==void 0&&!h(this,o,S).call(this,e(this,c)[e$1])&&(yield i);}}*values(){for(let e$1 of h(this,o,et).call(this))e(this,c)[e$1]!==void 0&&!h(this,o,S).call(this,e(this,c)[e$1])&&(yield e(this,c)[e$1]);}*rvalues(){for(let e$1 of h(this,o,it).call(this))e(this,c)[e$1]!==void 0&&!h(this,o,S).call(this,e(this,c)[e$1])&&(yield e(this,c)[e$1]);}[(Ut=Symbol.iterator,Lt=Symbol.toStringTag,Ut)](){return this.entries()}find(e$1,i={}){for(let s of h(this,o,et).call(this)){let h$1=e(this,c)[s],n=h(this,o,S).call(this,h$1)?h$1.__staleWhileFetching:h$1;if(n!==void 0&&e$1(n,e(this,b)[s],this))return this.get(e(this,b)[s],i)}}forEach(e$1,i=this){for(let s of h(this,o,et).call(this)){let h$1=e(this,c)[s],n=h(this,o,S).call(this,h$1)?h$1.__staleWhileFetching:h$1;n!==void 0&&e$1.call(i,n,e(this,b)[s],this);}}rforEach(e$1,i=this){for(let s of h(this,o,it).call(this)){let h$1=e(this,c)[s],n=h(this,o,S).call(this,h$1)?h$1.__staleWhileFetching:h$1;n!==void 0&&e$1.call(i,n,e(this,b)[s],this);}}purgeStale(){let e$1=false;for(let i of h(this,o,it).call(this,{allowStale:true}))e(this,I).call(this,i)&&(h(this,o,st).call(this,e(this,b)[i],"expire"),e$1=true);return e$1}info(e$1){let i=e(this,O).get(e$1);if(i===void 0)return;let s=e(this,c)[i],h$1=h(this,o,S).call(this,s)?s.__staleWhileFetching:s;if(h$1===void 0)return;let n={value:h$1};if(e(this,M)&&e(this,q)){let r=e(this,M)[i],a=e(this,q)[i];if(r&&a){let u=r-(e(this,K).now()-a);n.ttl=u,n.start=Date.now();}}return e(this,$)&&(n.size=e(this,$)[i]),n}dump(){let e$1=[];for(let i of h(this,o,et).call(this,{allowStale:true})){let s=e(this,b)[i],h$1=e(this,c)[i],n=h(this,o,S).call(this,h$1)?h$1.__staleWhileFetching:h$1;if(n===void 0||s===void 0)continue;let r={value:n};if(e(this,M)&&e(this,q)){r.ttl=e(this,M)[i];let a=e(this,K).now()-e(this,q)[i];r.start=Math.floor(Date.now()-a);}e(this,$)&&(r.size=e(this,$)[i]),e$1.unshift([s,r]);}return e$1}load(e$1){this.clear();for(let[i,s]of e$1){if(s.start){let h=Date.now()-s.start;s.start=e(this,K).now()-h;}this.set(i,s.value,s);}}set(e$1,i$1,s={}){var Z,N,Y,y;if(i$1===void 0)return this.delete(e$1),this;let{ttl:h$1=this.ttl,start:n,noDisposeOnSet:r=this.noDisposeOnSet,sizeCalculation:a=this.sizeCalculation,status:u}=s,{noUpdateTTL:p=this.noUpdateTTL}=s,z=e(this,bt).call(this,e$1,i$1,s.size||0,a);if(this.maxEntrySize&&z>this.maxEntrySize)return u&&(u.set="miss",u.maxEntrySizeExceeded=true),h(this,o,st).call(this,e$1,"set"),this;let w=e(this,F)===0?void 0:e(this,O).get(e$1);if(w===void 0)w=e(this,F)===0?e(this,E):e(this,B).length!==0?e(this,B).pop():e(this,F)===e(this,k)?h(this,o,At).call(this,false):e(this,F),e(this,b)[w]=e$1,e(this,c)[w]=i$1,e(this,O).set(e$1,w),e(this,W)[e(this,E)]=w,e(this,G)[w]=e(this,E),g(this,E,w),i(this,F)._++,e(this,pt).call(this,w,z,u),u&&(u.set="add"),p=false,e(this,gt)&&((Z=e(this,ot))==null||Z.call(this,i$1,e$1,"add"));else {h(this,o,vt).call(this,w);let v=e(this,c)[w];if(i$1!==v){if(e(this,ht)&&h(this,o,S).call(this,v)){v.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:d}=v;d!==void 0&&!r&&(e(this,X)&&((N=e(this,H))==null||N.call(this,d,e$1,"set")),e(this,D)&&e(this,T)?.push([d,e$1,"set"]));}else r||(e(this,X)&&((Y=e(this,H))==null||Y.call(this,v,e$1,"set")),e(this,D)&&e(this,T)?.push([v,e$1,"set"]));if(e(this,nt).call(this,w),e(this,pt).call(this,w,z,u),e(this,c)[w]=i$1,u){u.set="replace";let d=v&&h(this,o,S).call(this,v)?v.__staleWhileFetching:v;d!==void 0&&(u.oldValue=d);}}else u&&(u.set="update");e(this,gt)&&this.onInsert?.(i$1,e$1,i$1===v?"update":"replace");}if(h$1!==0&&!e(this,M)&&h(this,o,xt).call(this),e(this,M)&&(p||e(this,St).call(this,w,h$1,n),u&&e(this,Q).call(this,u,w)),!r&&e(this,D)&&e(this,T)){let v=e(this,T),d;for(;d=v?.shift();)(y=e(this,V))==null||y.call(this,...d);}return this}pop(){var e$1;try{for(;e(this,F);){let i=e(this,c)[e(this,x)];if(h(this,o,At).call(this,!0),h(this,o,S).call(this,i)){if(i.__staleWhileFetching)return i.__staleWhileFetching}else if(i!==void 0)return i}}finally{if(e(this,D)&&e(this,T)){let i=e(this,T),s;for(;s=i?.shift();)(e$1=e(this,V))==null||e$1.call(this,...s);}}}has(e$1,i={}){let{updateAgeOnHas:s=this.updateAgeOnHas,status:h$1}=i,n=e(this,O).get(e$1);if(n!==void 0){let r=e(this,c)[n];if(h(this,o,S).call(this,r)&&r.__staleWhileFetching===void 0)return false;if(e(this,I).call(this,n))h$1&&(h$1.has="stale",e(this,Q).call(this,h$1,n));else return s&&e(this,rt).call(this,n),h$1&&(h$1.has="hit",e(this,Q).call(this,h$1,n)),true}else h$1&&(h$1.has="miss");return false}peek(e$1,i={}){let{allowStale:s=this.allowStale}=i,h$1=e(this,O).get(e$1);if(h$1===void 0||!s&&e(this,I).call(this,h$1))return;let n=e(this,c)[h$1];return h(this,o,S).call(this,n)?n.__staleWhileFetching:n}async fetch(e$1,i={}){let{allowStale:s=this.allowStale,updateAgeOnGet:h$1=this.updateAgeOnGet,noDeleteOnStaleGet:n=this.noDeleteOnStaleGet,ttl:r=this.ttl,noDisposeOnSet:a=this.noDisposeOnSet,size:u=0,sizeCalculation:p=this.sizeCalculation,noUpdateTTL:z=this.noUpdateTTL,noDeleteOnFetchRejection:w=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:Z=this.allowStaleOnFetchRejection,ignoreFetchAbort:N=this.ignoreFetchAbort,allowStaleOnFetchAbort:Y=this.allowStaleOnFetchAbort,context:y,forceRefresh:v=false,status:d,signal:C}=i;if(!e(this,ht))return d&&(d.fetch="get"),this.get(e$1,{allowStale:s,updateAgeOnGet:h$1,noDeleteOnStaleGet:n,status:d});let L={allowStale:s,updateAgeOnGet:h$1,noDeleteOnStaleGet:n,ttl:r,noDisposeOnSet:a,size:u,sizeCalculation:p,noUpdateTTL:z,noDeleteOnFetchRejection:w,allowStaleOnFetchRejection:Z,allowStaleOnFetchAbort:Y,ignoreFetchAbort:N,status:d,signal:C},R=e(this,O).get(e$1);if(R===void 0){d&&(d.fetch="miss");let A=h(this,o,Ot).call(this,e$1,R,L,y);return A.__returned=A}else {let A=e(this,c)[R];if(h(this,o,S).call(this,A)){let ut=s&&A.__staleWhileFetching!==void 0;return d&&(d.fetch="inflight",ut&&(d.returnedStale=true)),ut?A.__staleWhileFetching:A.__returned=A}let mt=e(this,I).call(this,R);if(!v&&!mt)return d&&(d.fetch="hit"),h(this,o,vt).call(this,R),h$1&&e(this,rt).call(this,R),d&&e(this,Q).call(this,d,R),A;let lt=h(this,o,Ot).call(this,e$1,R,L,y),at=lt.__staleWhileFetching!==void 0&&s;return d&&(d.fetch=mt?"stale":"refresh",at&&mt&&(d.returnedStale=true)),at?lt.__staleWhileFetching:lt.__returned=lt}}async forceFetch(e,i={}){let s=await this.fetch(e,i);if(s===void 0)throw new Error("fetch() returned undefined");return s}memo(e$1,i={}){let s=e(this,dt);if(!s)throw new Error("no memoMethod provided to constructor");let{context:h,forceRefresh:n,...r}=i,a=this.get(e$1,r);if(!n&&a!==void 0)return a;let u=s(e$1,a,{options:r,context:h});return this.set(e$1,u,r),u}get(e$1,i={}){let{allowStale:s=this.allowStale,updateAgeOnGet:h$1=this.updateAgeOnGet,noDeleteOnStaleGet:n=this.noDeleteOnStaleGet,status:r}=i,a=e(this,O).get(e$1);if(a!==void 0){let u=e(this,c)[a],p=h(this,o,S).call(this,u);return r&&e(this,Q).call(this,r,a),e(this,I).call(this,a)?(r&&(r.get="stale"),p?(r&&s&&u.__staleWhileFetching!==void 0&&(r.returnedStale=true),s?u.__staleWhileFetching:void 0):(n||h(this,o,st).call(this,e$1,"expire"),r&&s&&(r.returnedStale=true),s?u:void 0)):(r&&(r.get="hit"),p?u.__staleWhileFetching:(h(this,o,vt).call(this,a),h$1&&e(this,rt).call(this,a),u))}else r&&(r.get="miss");}delete(e){return h(this,o,st).call(this,e,"delete")}clear(){return h(this,o,Wt).call(this,"delete")}},k=new WeakMap,U=new WeakMap,H=new WeakMap,ot=new WeakMap,V=new WeakMap,ct=new WeakMap,dt=new WeakMap,K=new WeakMap,F=new WeakMap,P=new WeakMap,O=new WeakMap,b=new WeakMap,c=new WeakMap,W=new WeakMap,G=new WeakMap,x=new WeakMap,E=new WeakMap,B=new WeakMap,T=new WeakMap,$=new WeakMap,q=new WeakMap,M=new WeakMap,j=new WeakMap,X=new WeakMap,ht=new WeakMap,D=new WeakMap,gt=new WeakMap,o=new WeakSet,xt=function(){let e$1=new yt(e(this,k)),i=new yt(e(this,k));g(this,M,e$1),g(this,q,i);let s=this.ttlAutopurge?new Array(e(this,k)):void 0;g(this,j,s),g(this,St,(a,u,p=e(this,K).now())=>{i[a]=u!==0?p:0,e$1[a]=u,h$1(a,u);}),g(this,rt,a=>{i[a]=e$1[a]!==0?e(this,K).now():0,h$1(a,e$1[a]);});let h$1=this.ttlAutopurge?(a,u)=>{if(s?.[a]&&(clearTimeout(s[a]),s[a]=void 0),u&&u!==0&&s){let p=setTimeout(()=>{e(this,I).call(this,a)&&h(this,o,st).call(this,e(this,b)[a],"expire");},u+1);p.unref&&p.unref(),s[a]=p;}}:()=>{};g(this,Q,(a,u)=>{if(e$1[u]){let p=e$1[u],z=i[u];if(!p||!z)return;a.ttl=p,a.start=z,a.now=n||r();let w=a.now-z;a.remainingTTL=p-w;}});let n=0,r=()=>{let a=e(this,K).now();if(this.ttlResolution>0){n=a;let u=setTimeout(()=>n=0,this.ttlResolution);u.unref&&u.unref();}return a};this.getRemainingTTL=a=>{let u=e(this,O).get(a);if(u===void 0)return 0;let p=e$1[u],z=i[u];if(!p||!z)return 1/0;let w=(n||r())-z;return p-w},g(this,I,a=>{let u=i[a],p=e$1[a];return !!p&&!!u&&(n||r())-u>p});},rt=new WeakMap,Q=new WeakMap,St=new WeakMap,I=new WeakMap,Nt=function(){let e$1=new yt(e(this,k));g(this,P,0),g(this,$,e$1),g(this,nt,i=>{g(this,P,e(this,P)-e$1[i]),e$1[i]=0;}),g(this,bt,(i,s,h$1,n)=>{if(h(this,o,S).call(this,s))return 0;if(!tt(h$1))if(n){if(typeof n!="function")throw new TypeError("sizeCalculation must be a function");if(h$1=n(s,i),!tt(h$1))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 h$1}),g(this,pt,(i,s,h$1)=>{if(e$1[i]=s,e(this,U)){let n=e(this,U)-e$1[i];for(;e(this,P)>n;)h(this,o,At).call(this,true);}g(this,P,e(this,P)+e$1[i]),h$1&&(h$1.entrySize=s,h$1.totalCalculatedSize=e(this,P));});},nt=new WeakMap,pt=new WeakMap,bt=new WeakMap,et=function*({allowStale:e$1=this.allowStale}={}){if(e(this,F))for(let i=e(this,E);!(!h(this,o,Ct).call(this,i)||((e$1||!e(this,I).call(this,i))&&(yield i),i===e(this,x)));)i=e(this,G)[i];},it=function*({allowStale:e$1=this.allowStale}={}){if(e(this,F))for(let i=e(this,x);!(!h(this,o,Ct).call(this,i)||((e$1||!e(this,I).call(this,i))&&(yield i),i===e(this,E)));)i=e(this,W)[i];},Ct=function(e$1){return e$1!==void 0&&e(this,O).get(e(this,b)[e$1])===e$1},At=function(e$1){var n;let i$1=e(this,x),s=e(this,b)[i$1],h$1=e(this,c)[i$1];return e(this,ht)&&h(this,o,S).call(this,h$1)?h$1.__abortController.abort(new Error("evicted")):(e(this,X)||e(this,D))&&(e(this,X)&&((n=e(this,H))==null||n.call(this,h$1,s,"evict")),e(this,D)&&e(this,T)?.push([h$1,s,"evict"])),e(this,nt).call(this,i$1),e(this,j)?.[i$1]&&(clearTimeout(e(this,j)[i$1]),e(this,j)[i$1]=void 0),e$1&&(e(this,b)[i$1]=void 0,e(this,c)[i$1]=void 0,e(this,B).push(i$1)),e(this,F)===1?(g(this,x,g(this,E,0)),e(this,B).length=0):g(this,x,e(this,W)[i$1]),e(this,O).delete(s),i(this,F)._--,i$1},Ot=function(e$1,i,s,h$1){let n=i===void 0?void 0:e(this,c)[i];if(h(this,o,S).call(this,n))return n;let r=new Ft,{signal:a}=s;a?.addEventListener("abort",()=>r.abort(a.reason),{signal:r.signal});let u={signal:r.signal,options:s,context:h$1},p=(y,v=false)=>{let{aborted:d}=r.signal,C=s.ignoreFetchAbort&&y!==void 0,L=s.ignoreFetchAbort||!!(s.allowStaleOnFetchAbort&&y!==void 0);if(s.status&&(d&&!v?(s.status.fetchAborted=true,s.status.fetchError=r.signal.reason,C&&(s.status.fetchAbortIgnored=true)):s.status.fetchResolved=true),d&&!C&&!v)return w(r.signal.reason,L);let R=N,A=e(this,c)[i];return (A===N||C&&v&&A===void 0)&&(y===void 0?R.__staleWhileFetching!==void 0?e(this,c)[i]=R.__staleWhileFetching:h(this,o,st).call(this,e$1,"fetch"):(s.status&&(s.status.fetchUpdated=true),this.set(e$1,y,u.options))),y},z=y=>(s.status&&(s.status.fetchRejected=true,s.status.fetchError=y),w(y,false)),w=(y,v)=>{let{aborted:d}=r.signal,C=d&&s.allowStaleOnFetchAbort,L=C||s.allowStaleOnFetchRejection,R=L||s.noDeleteOnFetchRejection,A=N;if(e(this,c)[i]===N&&(!R||!v&&A.__staleWhileFetching===void 0?h(this,o,st).call(this,e$1,"fetch"):C||(e(this,c)[i]=A.__staleWhileFetching)),L)return s.status&&A.__staleWhileFetching!==void 0&&(s.status.returnedStale=true),A.__staleWhileFetching;if(A.__returned===A)throw y},Z=(y,v)=>{var C;let d=(C=e(this,ct))==null?void 0:C.call(this,e$1,n,u);d&&d instanceof Promise&&d.then(L=>y(L===void 0?void 0:L),v),r.signal.addEventListener("abort",()=>{(!s.ignoreFetchAbort||s.allowStaleOnFetchAbort)&&(y(void 0),s.allowStaleOnFetchAbort&&(y=L=>p(L,true)));});};s.status&&(s.status.fetchDispatched=true);let N=new Promise(Z).then(p,z),Y=Object.assign(N,{__abortController:r,__staleWhileFetching:n,__returned:void 0});return i===void 0?(this.set(e$1,Y,{...u.options,status:void 0}),i=e(this,O).get(e$1)):e(this,c)[i]=Y,Y},S=function(e$1){if(!e(this,ht))return false;let i=e$1;return !!i&&i instanceof Promise&&i.hasOwnProperty("__staleWhileFetching")&&i.__abortController instanceof Ft},Rt=function(e$1,i){e(this,G)[i]=e$1,e(this,W)[e$1]=i;},vt=function(e$1){e$1!==e(this,E)&&(e$1===e(this,x)?g(this,x,e(this,W)[e$1]):h(this,o,Rt).call(this,e(this,G)[e$1],e(this,W)[e$1]),h(this,o,Rt).call(this,e(this,E),e$1),g(this,E,e$1));},st=function(e$1,i$1){var h$1,n;let s=false;if(e(this,F)!==0){let r=e(this,O).get(e$1);if(r!==void 0)if(e(this,j)?.[r]&&(clearTimeout(e(this,j)?.[r]),e(this,j)[r]=void 0),s=true,e(this,F)===1)h(this,o,Wt).call(this,i$1);else {e(this,nt).call(this,r);let a=e(this,c)[r];if(h(this,o,S).call(this,a)?a.__abortController.abort(new Error("deleted")):(e(this,X)||e(this,D))&&(e(this,X)&&((h$1=e(this,H))==null||h$1.call(this,a,e$1,i$1)),e(this,D)&&e(this,T)?.push([a,e$1,i$1])),e(this,O).delete(e$1),e(this,b)[r]=void 0,e(this,c)[r]=void 0,r===e(this,E))g(this,E,e(this,G)[r]);else if(r===e(this,x))g(this,x,e(this,W)[r]);else {let u=e(this,G)[r];e(this,W)[u]=e(this,W)[r];let p=e(this,W)[r];e(this,G)[p]=e(this,G)[r];}i(this,F)._--,e(this,B).push(r);}}if(e(this,D)&&e(this,T)?.length){let r=e(this,T),a;for(;a=r?.shift();)(n=e(this,V))==null||n.call(this,...a);}return s},Wt=function(e$1){var i,s;for(let h$1 of h(this,o,it).call(this,{allowStale:true})){let n=e(this,c)[h$1];if(h(this,o,S).call(this,n))n.__abortController.abort(new Error("deleted"));else {let r=e(this,b)[h$1];e(this,X)&&((i=e(this,H))==null||i.call(this,n,r,e$1)),e(this,D)&&e(this,T)?.push([n,r,e$1]);}}if(e(this,O).clear(),e(this,c).fill(void 0),e(this,b).fill(void 0),e(this,M)&&e(this,q)){e(this,M).fill(0),e(this,q).fill(0);for(let h of e(this,j)??[])h!==void 0&&clearTimeout(h);e(this,j)?.fill(void 0);}if(e(this,$)&&e(this,$).fill(0),g(this,x,0),g(this,E,0),e(this,B).length=0,g(this,P,0),g(this,F,0),e(this,D)&&e(this,T)){let h=e(this,T),n;for(;n=h?.shift();)(s=e(this,V))==null||s.call(this,...n);}},wt);var Et=class{constructor(e){d(this,"cache");d(this,"map",new Map);this.cache=new It({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 i=this.map.delete(e);return i&&this.cache.delete(e),i}get forEach(){return this.map.forEach}get(e){let i=this.cache.get(e);return i||this.map.get(e)}has(e){return this.map.has(e)}set(e,i){return this.map.set(e,i),this.cache.set(e,i),this}get size(){return this.map.size}entries(){return this.map.entries()}keys(){return this.map.keys()}values(){return this.map.values()}};export{Et as a};
|
|
1
|
+
import {d,f,e,g,h,i}from'./chunk-HNGW4ITF.mjs';var kt=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,Gt=new Set,Tt=typeof process=="object"&&process?process:{},Mt=(_,e,i,s)=>{typeof Tt.emitWarning=="function"?Tt.emitWarning(_,e,i,s):console.error(`[${i}] ${e}: ${_}`);},Ft=globalThis.AbortController,Dt=globalThis.AbortSignal;if(typeof Ft>"u"){Dt=class{constructor(){d(this,"onabort");d(this,"_onabort",[]);d(this,"reason");d(this,"aborted",false);}addEventListener(i,s){this._onabort.push(s);}},Ft=class{constructor(){d(this,"signal",new Dt);e();}abort(i){if(!this.signal.aborted){this.signal.reason=i,this.signal.aborted=true;for(let s of this.signal._onabort)s(i);this.signal.onabort?.(i);}}};let _=Tt.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",e=()=>{_&&(_=false,Mt("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 Ht=_=>!Gt.has(_);var tt=_=>_&&_===Math.floor(_)&&_>0&&isFinite(_),jt=_=>tt(_)?_<=Math.pow(2,8)?Uint8Array:_<=Math.pow(2,16)?Uint16Array:_<=Math.pow(2,32)?Uint32Array:_<=Number.MAX_SAFE_INTEGER?yt:null:null,yt=class extends Array{constructor(_){super(_),this.fill(0);}},J,ft,Vt=(J=class{constructor(e$1,i){d(this,"heap");d(this,"length");if(!e(J,ft))throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new i(e$1),this.length=0;}static create(e){let i=jt(e);if(!i)return [];g(J,ft,true);let s=new J(e,i);return g(J,ft,false),s}push(e){this.heap[this.length++]=e;}pop(){return this.heap[--this.length]}},ft=new WeakMap,f(J,ft,false),J),Lt,Ut,k,U,H,ot,V,ct,dt,K,F,P,O,b,c,W,G,x,E,B,T,$,q,M,j,X,ht,D,gt,o,zt,rt,Q,St,I,Nt,nt,pt,bt,et,it,xt,At,Ot,S,Rt,vt,st,Ct,wt,It=(wt=class{constructor(e$1){f(this,o);f(this,k);f(this,U);f(this,H);f(this,ot);f(this,V);f(this,ct);f(this,dt);f(this,K);d(this,"ttl");d(this,"ttlResolution");d(this,"ttlAutopurge");d(this,"updateAgeOnGet");d(this,"updateAgeOnHas");d(this,"allowStale");d(this,"noDisposeOnSet");d(this,"noUpdateTTL");d(this,"maxEntrySize");d(this,"sizeCalculation");d(this,"noDeleteOnFetchRejection");d(this,"noDeleteOnStaleGet");d(this,"allowStaleOnFetchAbort");d(this,"allowStaleOnFetchRejection");d(this,"ignoreFetchAbort");f(this,F);f(this,P);f(this,O);f(this,b);f(this,c);f(this,W);f(this,G);f(this,x);f(this,E);f(this,B);f(this,T);f(this,$);f(this,q);f(this,M);f(this,j);f(this,X);f(this,ht);f(this,D);f(this,gt);f(this,rt,()=>{});f(this,Q,()=>{});f(this,St,()=>{});f(this,I,()=>false);f(this,nt,e=>{});f(this,pt,(e,i,s)=>{});f(this,bt,(e,i,s,h)=>{if(s||h)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0});d(this,Lt,"LRUCache");let{max:i=0,ttl:s,ttlResolution:h$1=1,ttlAutopurge:n,updateAgeOnGet:r,updateAgeOnHas:a,allowStale:u,dispose:p,onInsert:z,disposeAfter:w,noDisposeOnSet:Z,noUpdateTTL:N,maxSize:Y=0,maxEntrySize:y=0,sizeCalculation:v,fetchMethod:d$1,memoMethod:R,noDeleteOnFetchRejection:L,noDeleteOnStaleGet:C,allowStaleOnFetchRejection:A,allowStaleOnFetchAbort:mt,ignoreFetchAbort:lt,perf:at}=e$1;if(at!==void 0&&typeof at?.now!="function")throw new TypeError("perf option must have a now() method if specified");if(g(this,K,at??kt),i!==0&&!tt(i))throw new TypeError("max option must be a nonnegative integer");let ut=i?jt(i):Array;if(!ut)throw new Error("invalid max value: "+i);if(g(this,k,i),g(this,U,Y),this.maxEntrySize=y||e(this,U),this.sizeCalculation=v,this.sizeCalculation){if(!e(this,U)&&!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(R!==void 0&&typeof R!="function")throw new TypeError("memoMethod must be a function if defined");if(g(this,dt,R),d$1!==void 0&&typeof d$1!="function")throw new TypeError("fetchMethod must be a function if specified");if(g(this,ct,d$1),g(this,ht,!!d$1),g(this,O,new Map),g(this,b,new Array(i).fill(void 0)),g(this,c,new Array(i).fill(void 0)),g(this,W,new ut(i)),g(this,G,new ut(i)),g(this,x,0),g(this,E,0),g(this,B,Vt.create(i)),g(this,F,0),g(this,P,0),typeof p=="function"&&g(this,H,p),typeof z=="function"&&g(this,ot,z),typeof w=="function"?(g(this,V,w),g(this,T,[])):(g(this,V,void 0),g(this,T,void 0)),g(this,X,!!e(this,H)),g(this,gt,!!e(this,ot)),g(this,D,!!e(this,V)),this.noDisposeOnSet=!!Z,this.noUpdateTTL=!!N,this.noDeleteOnFetchRejection=!!L,this.allowStaleOnFetchRejection=!!A,this.allowStaleOnFetchAbort=!!mt,this.ignoreFetchAbort=!!lt,this.maxEntrySize!==0){if(e(this,U)!==0&&!tt(e(this,U)))throw new TypeError("maxSize must be a positive integer if specified");if(!tt(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");h(this,o,Nt).call(this);}if(this.allowStale=!!u,this.noDeleteOnStaleGet=!!C,this.updateAgeOnGet=!!r,this.updateAgeOnHas=!!a,this.ttlResolution=tt(h$1)||h$1===0?h$1:1,this.ttlAutopurge=!!n,this.ttl=s||0,this.ttl){if(!tt(this.ttl))throw new TypeError("ttl must be a positive integer if specified");h(this,o,zt).call(this);}if(e(this,k)===0&&this.ttl===0&&e(this,U)===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!e(this,k)&&!e(this,U)){let Et="LRU_CACHE_UNBOUNDED";Ht(Et)&&(Gt.add(Et),Mt("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",Et,wt));}}get perf(){return e(this,K)}static unsafeExposeInternals(e$1){return {starts:e(e$1,q),ttls:e(e$1,M),autopurgeTimers:e(e$1,j),sizes:e(e$1,$),keyMap:e(e$1,O),keyList:e(e$1,b),valList:e(e$1,c),next:e(e$1,W),prev:e(e$1,G),get head(){return e(e$1,x)},get tail(){return e(e$1,E)},free:e(e$1,B),isBackgroundFetch:i=>{var s;return h(s=e$1,o,S).call(s,i)},backgroundFetch:(i,s,h$1,n)=>{var r;return h(r=e$1,o,Ot).call(r,i,s,h$1,n)},moveToTail:i=>{var s;return h(s=e$1,o,vt).call(s,i)},indexes:i=>{var s;return h(s=e$1,o,et).call(s,i)},rindexes:i=>{var s;return h(s=e$1,o,it).call(s,i)},isStale:i=>{var s;return e(s=e$1,I).call(s,i)}}}get max(){return e(this,k)}get maxSize(){return e(this,U)}get calculatedSize(){return e(this,P)}get size(){return e(this,F)}get fetchMethod(){return e(this,ct)}get memoMethod(){return e(this,dt)}get dispose(){return e(this,H)}get onInsert(){return e(this,ot)}get disposeAfter(){return e(this,V)}getRemainingTTL(e$1){return e(this,O).has(e$1)?1/0:0}*entries(){for(let e$1 of h(this,o,et).call(this))e(this,c)[e$1]!==void 0&&e(this,b)[e$1]!==void 0&&!h(this,o,S).call(this,e(this,c)[e$1])&&(yield [e(this,b)[e$1],e(this,c)[e$1]]);}*rentries(){for(let e$1 of h(this,o,it).call(this))e(this,c)[e$1]!==void 0&&e(this,b)[e$1]!==void 0&&!h(this,o,S).call(this,e(this,c)[e$1])&&(yield [e(this,b)[e$1],e(this,c)[e$1]]);}*keys(){for(let e$1 of h(this,o,et).call(this)){let i=e(this,b)[e$1];i!==void 0&&!h(this,o,S).call(this,e(this,c)[e$1])&&(yield i);}}*rkeys(){for(let e$1 of h(this,o,it).call(this)){let i=e(this,b)[e$1];i!==void 0&&!h(this,o,S).call(this,e(this,c)[e$1])&&(yield i);}}*values(){for(let e$1 of h(this,o,et).call(this))e(this,c)[e$1]!==void 0&&!h(this,o,S).call(this,e(this,c)[e$1])&&(yield e(this,c)[e$1]);}*rvalues(){for(let e$1 of h(this,o,it).call(this))e(this,c)[e$1]!==void 0&&!h(this,o,S).call(this,e(this,c)[e$1])&&(yield e(this,c)[e$1]);}[(Ut=Symbol.iterator,Lt=Symbol.toStringTag,Ut)](){return this.entries()}find(e$1,i={}){for(let s of h(this,o,et).call(this)){let h$1=e(this,c)[s],n=h(this,o,S).call(this,h$1)?h$1.__staleWhileFetching:h$1;if(n!==void 0&&e$1(n,e(this,b)[s],this))return this.get(e(this,b)[s],i)}}forEach(e$1,i=this){for(let s of h(this,o,et).call(this)){let h$1=e(this,c)[s],n=h(this,o,S).call(this,h$1)?h$1.__staleWhileFetching:h$1;n!==void 0&&e$1.call(i,n,e(this,b)[s],this);}}rforEach(e$1,i=this){for(let s of h(this,o,it).call(this)){let h$1=e(this,c)[s],n=h(this,o,S).call(this,h$1)?h$1.__staleWhileFetching:h$1;n!==void 0&&e$1.call(i,n,e(this,b)[s],this);}}purgeStale(){let e$1=false;for(let i of h(this,o,it).call(this,{allowStale:true}))e(this,I).call(this,i)&&(h(this,o,st).call(this,e(this,b)[i],"expire"),e$1=true);return e$1}info(e$1){let i=e(this,O).get(e$1);if(i===void 0)return;let s=e(this,c)[i],h$1=h(this,o,S).call(this,s)?s.__staleWhileFetching:s;if(h$1===void 0)return;let n={value:h$1};if(e(this,M)&&e(this,q)){let r=e(this,M)[i],a=e(this,q)[i];if(r&&a){let u=r-(e(this,K).now()-a);n.ttl=u,n.start=Date.now();}}return e(this,$)&&(n.size=e(this,$)[i]),n}dump(){let e$1=[];for(let i of h(this,o,et).call(this,{allowStale:true})){let s=e(this,b)[i],h$1=e(this,c)[i],n=h(this,o,S).call(this,h$1)?h$1.__staleWhileFetching:h$1;if(n===void 0||s===void 0)continue;let r={value:n};if(e(this,M)&&e(this,q)){r.ttl=e(this,M)[i];let a=e(this,K).now()-e(this,q)[i];r.start=Math.floor(Date.now()-a);}e(this,$)&&(r.size=e(this,$)[i]),e$1.unshift([s,r]);}return e$1}load(e$1){this.clear();for(let[i,s]of e$1){if(s.start){let h=Date.now()-s.start;s.start=e(this,K).now()-h;}this.set(i,s.value,s);}}set(e$1,i$1,s={}){var Z,N,Y,y;if(i$1===void 0)return this.delete(e$1),this;let{ttl:h$1=this.ttl,start:n,noDisposeOnSet:r=this.noDisposeOnSet,sizeCalculation:a=this.sizeCalculation,status:u}=s,{noUpdateTTL:p=this.noUpdateTTL}=s,z=e(this,bt).call(this,e$1,i$1,s.size||0,a);if(this.maxEntrySize&&z>this.maxEntrySize)return u&&(u.set="miss",u.maxEntrySizeExceeded=true),h(this,o,st).call(this,e$1,"set"),this;let w=e(this,F)===0?void 0:e(this,O).get(e$1);if(w===void 0)w=e(this,F)===0?e(this,E):e(this,B).length!==0?e(this,B).pop():e(this,F)===e(this,k)?h(this,o,At).call(this,false):e(this,F),e(this,b)[w]=e$1,e(this,c)[w]=i$1,e(this,O).set(e$1,w),e(this,W)[e(this,E)]=w,e(this,G)[w]=e(this,E),g(this,E,w),i(this,F)._++,e(this,pt).call(this,w,z,u),u&&(u.set="add"),p=false,e(this,gt)&&((Z=e(this,ot))==null||Z.call(this,i$1,e$1,"add"));else {h(this,o,vt).call(this,w);let v=e(this,c)[w];if(i$1!==v){if(e(this,ht)&&h(this,o,S).call(this,v)){v.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:d}=v;d!==void 0&&!r&&(e(this,X)&&((N=e(this,H))==null||N.call(this,d,e$1,"set")),e(this,D)&&e(this,T)?.push([d,e$1,"set"]));}else r||(e(this,X)&&((Y=e(this,H))==null||Y.call(this,v,e$1,"set")),e(this,D)&&e(this,T)?.push([v,e$1,"set"]));if(e(this,nt).call(this,w),e(this,pt).call(this,w,z,u),e(this,c)[w]=i$1,u){u.set="replace";let d=v&&h(this,o,S).call(this,v)?v.__staleWhileFetching:v;d!==void 0&&(u.oldValue=d);}}else u&&(u.set="update");e(this,gt)&&this.onInsert?.(i$1,e$1,i$1===v?"update":"replace");}if(h$1!==0&&!e(this,M)&&h(this,o,zt).call(this),e(this,M)&&(p||e(this,St).call(this,w,h$1,n),u&&e(this,Q).call(this,u,w)),!r&&e(this,D)&&e(this,T)){let v=e(this,T),d;for(;d=v?.shift();)(y=e(this,V))==null||y.call(this,...d);}return this}pop(){var e$1;try{for(;e(this,F);){let i=e(this,c)[e(this,x)];if(h(this,o,At).call(this,!0),h(this,o,S).call(this,i)){if(i.__staleWhileFetching)return i.__staleWhileFetching}else if(i!==void 0)return i}}finally{if(e(this,D)&&e(this,T)){let i=e(this,T),s;for(;s=i?.shift();)(e$1=e(this,V))==null||e$1.call(this,...s);}}}has(e$1,i={}){let{updateAgeOnHas:s=this.updateAgeOnHas,status:h$1}=i,n=e(this,O).get(e$1);if(n!==void 0){let r=e(this,c)[n];if(h(this,o,S).call(this,r)&&r.__staleWhileFetching===void 0)return false;if(e(this,I).call(this,n))h$1&&(h$1.has="stale",e(this,Q).call(this,h$1,n));else return s&&e(this,rt).call(this,n),h$1&&(h$1.has="hit",e(this,Q).call(this,h$1,n)),true}else h$1&&(h$1.has="miss");return false}peek(e$1,i={}){let{allowStale:s=this.allowStale}=i,h$1=e(this,O).get(e$1);if(h$1===void 0||!s&&e(this,I).call(this,h$1))return;let n=e(this,c)[h$1];return h(this,o,S).call(this,n)?n.__staleWhileFetching:n}async fetch(e$1,i={}){let{allowStale:s=this.allowStale,updateAgeOnGet:h$1=this.updateAgeOnGet,noDeleteOnStaleGet:n=this.noDeleteOnStaleGet,ttl:r=this.ttl,noDisposeOnSet:a=this.noDisposeOnSet,size:u=0,sizeCalculation:p=this.sizeCalculation,noUpdateTTL:z=this.noUpdateTTL,noDeleteOnFetchRejection:w=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:Z=this.allowStaleOnFetchRejection,ignoreFetchAbort:N=this.ignoreFetchAbort,allowStaleOnFetchAbort:Y=this.allowStaleOnFetchAbort,context:y,forceRefresh:v=false,status:d,signal:R}=i;if(!e(this,ht))return d&&(d.fetch="get"),this.get(e$1,{allowStale:s,updateAgeOnGet:h$1,noDeleteOnStaleGet:n,status:d});let L={allowStale:s,updateAgeOnGet:h$1,noDeleteOnStaleGet:n,ttl:r,noDisposeOnSet:a,size:u,sizeCalculation:p,noUpdateTTL:z,noDeleteOnFetchRejection:w,allowStaleOnFetchRejection:Z,allowStaleOnFetchAbort:Y,ignoreFetchAbort:N,status:d,signal:R},C=e(this,O).get(e$1);if(C===void 0){d&&(d.fetch="miss");let A=h(this,o,Ot).call(this,e$1,C,L,y);return A.__returned=A}else {let A=e(this,c)[C];if(h(this,o,S).call(this,A)){let ut=s&&A.__staleWhileFetching!==void 0;return d&&(d.fetch="inflight",ut&&(d.returnedStale=true)),ut?A.__staleWhileFetching:A.__returned=A}let mt=e(this,I).call(this,C);if(!v&&!mt)return d&&(d.fetch="hit"),h(this,o,vt).call(this,C),h$1&&e(this,rt).call(this,C),d&&e(this,Q).call(this,d,C),A;let lt=h(this,o,Ot).call(this,e$1,C,L,y),at=lt.__staleWhileFetching!==void 0&&s;return d&&(d.fetch=mt?"stale":"refresh",at&&mt&&(d.returnedStale=true)),at?lt.__staleWhileFetching:lt.__returned=lt}}async forceFetch(e,i={}){let s=await this.fetch(e,i);if(s===void 0)throw new Error("fetch() returned undefined");return s}memo(e$1,i={}){let s=e(this,dt);if(!s)throw new Error("no memoMethod provided to constructor");let{context:h,forceRefresh:n,...r}=i,a=this.get(e$1,r);if(!n&&a!==void 0)return a;let u=s(e$1,a,{options:r,context:h});return this.set(e$1,u,r),u}get(e$1,i={}){let{allowStale:s=this.allowStale,updateAgeOnGet:h$1=this.updateAgeOnGet,noDeleteOnStaleGet:n=this.noDeleteOnStaleGet,status:r}=i,a=e(this,O).get(e$1);if(a!==void 0){let u=e(this,c)[a],p=h(this,o,S).call(this,u);return r&&e(this,Q).call(this,r,a),e(this,I).call(this,a)?(r&&(r.get="stale"),p?(r&&s&&u.__staleWhileFetching!==void 0&&(r.returnedStale=true),s?u.__staleWhileFetching:void 0):(n||h(this,o,st).call(this,e$1,"expire"),r&&s&&(r.returnedStale=true),s?u:void 0)):(r&&(r.get="hit"),p?u.__staleWhileFetching:(h(this,o,vt).call(this,a),h$1&&e(this,rt).call(this,a),u))}else r&&(r.get="miss");}delete(e){return h(this,o,st).call(this,e,"delete")}clear(){return h(this,o,Ct).call(this,"delete")}},k=new WeakMap,U=new WeakMap,H=new WeakMap,ot=new WeakMap,V=new WeakMap,ct=new WeakMap,dt=new WeakMap,K=new WeakMap,F=new WeakMap,P=new WeakMap,O=new WeakMap,b=new WeakMap,c=new WeakMap,W=new WeakMap,G=new WeakMap,x=new WeakMap,E=new WeakMap,B=new WeakMap,T=new WeakMap,$=new WeakMap,q=new WeakMap,M=new WeakMap,j=new WeakMap,X=new WeakMap,ht=new WeakMap,D=new WeakMap,gt=new WeakMap,o=new WeakSet,zt=function(){let e$1=new yt(e(this,k)),i=new yt(e(this,k));g(this,M,e$1),g(this,q,i);let s=this.ttlAutopurge?new Array(e(this,k)):void 0;g(this,j,s),g(this,St,(a,u,p=e(this,K).now())=>{i[a]=u!==0?p:0,e$1[a]=u,h$1(a,u);}),g(this,rt,a=>{i[a]=e$1[a]!==0?e(this,K).now():0,h$1(a,e$1[a]);});let h$1=this.ttlAutopurge?(a,u)=>{if(s?.[a]&&(clearTimeout(s[a]),s[a]=void 0),u&&u!==0&&s){let p=setTimeout(()=>{e(this,I).call(this,a)&&h(this,o,st).call(this,e(this,b)[a],"expire");},u+1);p.unref&&p.unref(),s[a]=p;}}:()=>{};g(this,Q,(a,u)=>{if(e$1[u]){let p=e$1[u],z=i[u];if(!p||!z)return;a.ttl=p,a.start=z,a.now=n||r();let w=a.now-z;a.remainingTTL=p-w;}});let n=0,r=()=>{let a=e(this,K).now();if(this.ttlResolution>0){n=a;let u=setTimeout(()=>n=0,this.ttlResolution);u.unref&&u.unref();}return a};this.getRemainingTTL=a=>{let u=e(this,O).get(a);if(u===void 0)return 0;let p=e$1[u],z=i[u];if(!p||!z)return 1/0;let w=(n||r())-z;return p-w},g(this,I,a=>{let u=i[a],p=e$1[a];return !!p&&!!u&&(n||r())-u>p});},rt=new WeakMap,Q=new WeakMap,St=new WeakMap,I=new WeakMap,Nt=function(){let e$1=new yt(e(this,k));g(this,P,0),g(this,$,e$1),g(this,nt,i=>{g(this,P,e(this,P)-e$1[i]),e$1[i]=0;}),g(this,bt,(i,s,h$1,n)=>{if(h(this,o,S).call(this,s))return 0;if(!tt(h$1))if(n){if(typeof n!="function")throw new TypeError("sizeCalculation must be a function");if(h$1=n(s,i),!tt(h$1))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 h$1}),g(this,pt,(i,s,h$1)=>{if(e$1[i]=s,e(this,U)){let n=e(this,U)-e$1[i];for(;e(this,P)>n;)h(this,o,At).call(this,true);}g(this,P,e(this,P)+e$1[i]),h$1&&(h$1.entrySize=s,h$1.totalCalculatedSize=e(this,P));});},nt=new WeakMap,pt=new WeakMap,bt=new WeakMap,et=function*({allowStale:e$1=this.allowStale}={}){if(e(this,F))for(let i=e(this,E);!(!h(this,o,xt).call(this,i)||((e$1||!e(this,I).call(this,i))&&(yield i),i===e(this,x)));)i=e(this,G)[i];},it=function*({allowStale:e$1=this.allowStale}={}){if(e(this,F))for(let i=e(this,x);!(!h(this,o,xt).call(this,i)||((e$1||!e(this,I).call(this,i))&&(yield i),i===e(this,E)));)i=e(this,W)[i];},xt=function(e$1){return e$1!==void 0&&e(this,O).get(e(this,b)[e$1])===e$1},At=function(e$1){var n;let i$1=e(this,x),s=e(this,b)[i$1],h$1=e(this,c)[i$1];return e(this,ht)&&h(this,o,S).call(this,h$1)?h$1.__abortController.abort(new Error("evicted")):(e(this,X)||e(this,D))&&(e(this,X)&&((n=e(this,H))==null||n.call(this,h$1,s,"evict")),e(this,D)&&e(this,T)?.push([h$1,s,"evict"])),e(this,nt).call(this,i$1),e(this,j)?.[i$1]&&(clearTimeout(e(this,j)[i$1]),e(this,j)[i$1]=void 0),e$1&&(e(this,b)[i$1]=void 0,e(this,c)[i$1]=void 0,e(this,B).push(i$1)),e(this,F)===1?(g(this,x,g(this,E,0)),e(this,B).length=0):g(this,x,e(this,W)[i$1]),e(this,O).delete(s),i(this,F)._--,i$1},Ot=function(e$1,i,s,h$1){let n=i===void 0?void 0:e(this,c)[i];if(h(this,o,S).call(this,n))return n;let r=new Ft,{signal:a}=s;a?.addEventListener("abort",()=>r.abort(a.reason),{signal:r.signal});let u={signal:r.signal,options:s,context:h$1},p=(y,v=false)=>{let{aborted:d}=r.signal,R=s.ignoreFetchAbort&&y!==void 0,L=s.ignoreFetchAbort||!!(s.allowStaleOnFetchAbort&&y!==void 0);if(s.status&&(d&&!v?(s.status.fetchAborted=true,s.status.fetchError=r.signal.reason,R&&(s.status.fetchAbortIgnored=true)):s.status.fetchResolved=true),d&&!R&&!v)return w(r.signal.reason,L);let C=N,A=e(this,c)[i];return (A===N||R&&v&&A===void 0)&&(y===void 0?C.__staleWhileFetching!==void 0?e(this,c)[i]=C.__staleWhileFetching:h(this,o,st).call(this,e$1,"fetch"):(s.status&&(s.status.fetchUpdated=true),this.set(e$1,y,u.options))),y},z=y=>(s.status&&(s.status.fetchRejected=true,s.status.fetchError=y),w(y,false)),w=(y,v)=>{let{aborted:d}=r.signal,R=d&&s.allowStaleOnFetchAbort,L=R||s.allowStaleOnFetchRejection,C=L||s.noDeleteOnFetchRejection,A=N;if(e(this,c)[i]===N&&(!C||!v&&A.__staleWhileFetching===void 0?h(this,o,st).call(this,e$1,"fetch"):R||(e(this,c)[i]=A.__staleWhileFetching)),L)return s.status&&A.__staleWhileFetching!==void 0&&(s.status.returnedStale=true),A.__staleWhileFetching;if(A.__returned===A)throw y},Z=(y,v)=>{var R;let d=(R=e(this,ct))==null?void 0:R.call(this,e$1,n,u);d&&d instanceof Promise&&d.then(L=>y(L===void 0?void 0:L),v),r.signal.addEventListener("abort",()=>{(!s.ignoreFetchAbort||s.allowStaleOnFetchAbort)&&(y(void 0),s.allowStaleOnFetchAbort&&(y=L=>p(L,true)));});};s.status&&(s.status.fetchDispatched=true);let N=new Promise(Z).then(p,z),Y=Object.assign(N,{__abortController:r,__staleWhileFetching:n,__returned:void 0});return i===void 0?(this.set(e$1,Y,{...u.options,status:void 0}),i=e(this,O).get(e$1)):e(this,c)[i]=Y,Y},S=function(e$1){if(!e(this,ht))return false;let i=e$1;return !!i&&i instanceof Promise&&i.hasOwnProperty("__staleWhileFetching")&&i.__abortController instanceof Ft},Rt=function(e$1,i){e(this,G)[i]=e$1,e(this,W)[e$1]=i;},vt=function(e$1){e$1!==e(this,E)&&(e$1===e(this,x)?g(this,x,e(this,W)[e$1]):h(this,o,Rt).call(this,e(this,G)[e$1],e(this,W)[e$1]),h(this,o,Rt).call(this,e(this,E),e$1),g(this,E,e$1));},st=function(e$1,i$1){var h$1,n;let s=false;if(e(this,F)!==0){let r=e(this,O).get(e$1);if(r!==void 0)if(e(this,j)?.[r]&&(clearTimeout(e(this,j)?.[r]),e(this,j)[r]=void 0),s=true,e(this,F)===1)h(this,o,Ct).call(this,i$1);else {e(this,nt).call(this,r);let a=e(this,c)[r];if(h(this,o,S).call(this,a)?a.__abortController.abort(new Error("deleted")):(e(this,X)||e(this,D))&&(e(this,X)&&((h$1=e(this,H))==null||h$1.call(this,a,e$1,i$1)),e(this,D)&&e(this,T)?.push([a,e$1,i$1])),e(this,O).delete(e$1),e(this,b)[r]=void 0,e(this,c)[r]=void 0,r===e(this,E))g(this,E,e(this,G)[r]);else if(r===e(this,x))g(this,x,e(this,W)[r]);else {let u=e(this,G)[r];e(this,W)[u]=e(this,W)[r];let p=e(this,W)[r];e(this,G)[p]=e(this,G)[r];}i(this,F)._--,e(this,B).push(r);}}if(e(this,D)&&e(this,T)?.length){let r=e(this,T),a;for(;a=r?.shift();)(n=e(this,V))==null||n.call(this,...a);}return s},Ct=function(e$1){var i,s;for(let h$1 of h(this,o,it).call(this,{allowStale:true})){let n=e(this,c)[h$1];if(h(this,o,S).call(this,n))n.__abortController.abort(new Error("deleted"));else {let r=e(this,b)[h$1];e(this,X)&&((i=e(this,H))==null||i.call(this,n,r,e$1)),e(this,D)&&e(this,T)?.push([n,r,e$1]);}}if(e(this,O).clear(),e(this,c).fill(void 0),e(this,b).fill(void 0),e(this,M)&&e(this,q)){e(this,M).fill(0),e(this,q).fill(0);for(let h of e(this,j)??[])h!==void 0&&clearTimeout(h);e(this,j)?.fill(void 0);}if(e(this,$)&&e(this,$).fill(0),g(this,x,0),g(this,E,0),e(this,B).length=0,g(this,P,0),g(this,F,0),e(this,D)&&e(this,T)){let h=e(this,T),n;for(;n=h?.shift();)(s=e(this,V))==null||s.call(this,...n);}},wt);var Wt=class{constructor(e){d(this,"cache");d(this,"map",new Map);this.cache=new It({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 i=this.map.delete(e);return i&&this.cache.delete(e),i}get forEach(){return this.map.forEach}get(e){let i=this.cache.get(e);return i||this.map.get(e)}has(e){return this.map.has(e)}set(e,i){return this.map.set(e,i),this.cache.set(e,i),this}get size(){return this.map.size}entries(){return this.map.entries()}keys(){return this.map.keys()}values(){return this.map.values()}};export{Wt as a};
|
package/dist/history.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
'use strict';var core=require('@drincs/pixi-vn/core');var Xt=Object.defineProperty;var Vt=f=>{throw TypeError(f)};var Qt=(f,t,i)=>t in f?Xt(f,t,{enumerable:true,configurable:true,writable:true,value:i}):f[t]=i;var w=(f,t,i)=>Qt(f,typeof t!="symbol"?t+"":t,i),Rt=(f,t,i)=>t.has(f)||Vt("Cannot "+i);var e=(f,t,i)=>(Rt(f,t,"read from private field"),i?i.call(f):t.get(f)),b=(f,t,i)=>t.has(f)?Vt("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(f):t.set(f,i),c=(f,t,i,s)=>(Rt(f,t,"write to private field"),t.set(f,i),i),u=(f,t,i)=>(Rt(f,t,"access private method"),i);var Tt=(f,t,i,s)=>({set _(r){c(f,t,r);},get _(){return e(f,t,s)}});var Zt={Date:true,RegExp:true,String:true,Number:true};function Ft(f,t,i={cyclesFix:true},s=[]){let r=[],o=Array.isArray(f);for(let a in f){let h=f[a],d=o?+a:a;if(!(a in t)){r.push({type:"REMOVE",path:[d],oldValue:f[a]});continue}let g=t[a],m=typeof h=="object"&&typeof g=="object"&&Array.isArray(h)===Array.isArray(g);h&&g&&m&&!Zt[Object.getPrototypeOf(h)?.constructor?.name]&&(!i.cyclesFix||!s.includes(h))?r.push.apply(r,Ft(h,g,i,i.cyclesFix?s.concat([h]):[]).map(v=>(v.path.unshift(d),v))):h!==g&&!(Number.isNaN(h)&&Number.isNaN(g))&&!(m&&(isNaN(h)?h+""==g+"":+h==+g))&&r.push({path:[d],type:"CHANGE",value:g,oldValue:h});}let n=Array.isArray(t);for(let a in t)a in f||r.push({type:"CREATE",path:[n?+a:a],value:t[a]});return r}var O;(r=>(r.log=(o,...n)=>console.log(`[Pixi\u2019VN] ${o}`,...n),r.warn=(o,...n)=>console.warn(`[Pixi\u2019VN] ${o}`,...n),r.error=(o,...n)=>console.error(`[Pixi\u2019VN] ${o}`,...n),r.info=(o,...n)=>console.info(`[Pixi\u2019VN] ${o}`,...n)))(O||(O={}));function et(f){try{if(typeof f>"u")return f;let t=JSON.stringify(f);return JSON.parse(t)}catch(t){throw O.error("Error creating exportable element",f,t),new core.PixiError("not_json_serializable","Error creating exportable element")}}function jt(f,t){let i=et(f);return t.length>1&&"type"in t[0]&&(t=t.slice().reverse()),t.forEach(s=>{ee(i,s);}),i}function ee(f,t){let i=f;t.path&&t.path.length>0?t.path.forEach((s,r)=>{if(t.path&&r===t.path.length-1)switch(t.type){case "CHANGE":case "REMOVE":i[s]=t.oldValue;break;case "CREATE":Array.isArray(i)&&typeof s=="number"?i.splice(s,1):delete i[s];break}else i=i[s];}):O.warn("No path found, skipping diff",t);}var ie=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,$t=new Set,Gt=typeof process=="object"&&process?process:{},Bt=(f,t,i,s)=>{typeof Gt.emitWarning=="function"?Gt.emitWarning(f,t,i,s):console.error(`[${i}] ${t}: ${f}`);},It=globalThis.AbortController,Ut=globalThis.AbortSignal;if(typeof It>"u"){Ut=class{constructor(){w(this,"onabort");w(this,"_onabort",[]);w(this,"reason");w(this,"aborted",false);}addEventListener(i,s){this._onabort.push(s);}},It=class{constructor(){w(this,"signal",new Ut);t();}abort(i){if(!this.signal.aborted){this.signal.reason=i,this.signal.aborted=true;for(let s of this.signal._onabort)s(i);this.signal.onabort?.(i);}}};let f=Gt.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",t=()=>{f&&(f=false,Bt("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",t));};}var se=f=>!$t.has(f);var ot=f=>f&&f===Math.floor(f)&&f>0&&isFinite(f),qt=f=>ot(f)?f<=Math.pow(2,8)?Uint8Array:f<=Math.pow(2,16)?Uint16Array:f<=Math.pow(2,32)?Uint32Array:f<=Number.MAX_SAFE_INTEGER?Ct:null:null,Ct=class extends Array{constructor(f){super(f),this.fill(0);}},it,mt,re=(it=class{constructor(t,i){w(this,"heap");w(this,"length");if(!e(it,mt))throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new i(t),this.length=0;}static create(t){let i=qt(t);if(!i)return [];c(it,mt,true);let s=new it(t,i);return c(it,mt,false),s}push(t){this.heap[this.length++]=t;}pop(){return this.heap[--this.length]}},mt=new WeakMap,b(it,mt,false),it),Kt,Pt,P,k,$,ut,B,St,bt,q,F,J,T,A,y,R,W,z,C,Y,D,X,Q,V,j,Z,lt,G,wt,l,Lt,ct,rt,Et,U,Yt,pt,vt,Ht,nt,at,Mt,Dt,zt,x,kt,At,ht,Wt,_t,Jt=(_t=class{constructor(t){b(this,l);b(this,P);b(this,k);b(this,$);b(this,ut);b(this,B);b(this,St);b(this,bt);b(this,q);w(this,"ttl");w(this,"ttlResolution");w(this,"ttlAutopurge");w(this,"updateAgeOnGet");w(this,"updateAgeOnHas");w(this,"allowStale");w(this,"noDisposeOnSet");w(this,"noUpdateTTL");w(this,"maxEntrySize");w(this,"sizeCalculation");w(this,"noDeleteOnFetchRejection");w(this,"noDeleteOnStaleGet");w(this,"allowStaleOnFetchAbort");w(this,"allowStaleOnFetchRejection");w(this,"ignoreFetchAbort");b(this,F);b(this,J);b(this,T);b(this,A);b(this,y);b(this,R);b(this,W);b(this,z);b(this,C);b(this,Y);b(this,D);b(this,X);b(this,Q);b(this,V);b(this,j);b(this,Z);b(this,lt);b(this,G);b(this,wt);b(this,ct,()=>{});b(this,rt,()=>{});b(this,Et,()=>{});b(this,U,()=>false);b(this,pt,t=>{});b(this,vt,(t,i,s)=>{});b(this,Ht,(t,i,s,r)=>{if(s||r)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0});w(this,Kt,"LRUCache");let{max:i=0,ttl:s,ttlResolution:r=1,ttlAutopurge:o,updateAgeOnGet:n,updateAgeOnHas:a,allowStale:h,dispose:d,onInsert:g,disposeAfter:m,noDisposeOnSet:v,noUpdateTTL:K,maxSize:tt=0,maxEntrySize:E=0,sizeCalculation:_,fetchMethod:S,memoMethod:I,noDeleteOnFetchRejection:L,noDeleteOnStaleGet:N,allowStaleOnFetchRejection:H,allowStaleOnFetchAbort:xt,ignoreFetchAbort:dt,perf:yt}=t;if(yt!==void 0&&typeof yt?.now!="function")throw new TypeError("perf option must have a now() method if specified");if(c(this,q,yt??ie),i!==0&&!ot(i))throw new TypeError("max option must be a nonnegative integer");let gt=i?qt(i):Array;if(!gt)throw new Error("invalid max value: "+i);if(c(this,P,i),c(this,k,tt),this.maxEntrySize=E||e(this,k),this.sizeCalculation=_,this.sizeCalculation){if(!e(this,k)&&!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(I!==void 0&&typeof I!="function")throw new TypeError("memoMethod must be a function if defined");if(c(this,bt,I),S!==void 0&&typeof S!="function")throw new TypeError("fetchMethod must be a function if specified");if(c(this,St,S),c(this,lt,!!S),c(this,T,new Map),c(this,A,new Array(i).fill(void 0)),c(this,y,new Array(i).fill(void 0)),c(this,R,new gt(i)),c(this,W,new gt(i)),c(this,z,0),c(this,C,0),c(this,Y,re.create(i)),c(this,F,0),c(this,J,0),typeof d=="function"&&c(this,$,d),typeof g=="function"&&c(this,ut,g),typeof m=="function"?(c(this,B,m),c(this,D,[])):(c(this,B,void 0),c(this,D,void 0)),c(this,Z,!!e(this,$)),c(this,wt,!!e(this,ut)),c(this,G,!!e(this,B)),this.noDisposeOnSet=!!v,this.noUpdateTTL=!!K,this.noDeleteOnFetchRejection=!!L,this.allowStaleOnFetchRejection=!!H,this.allowStaleOnFetchAbort=!!xt,this.ignoreFetchAbort=!!dt,this.maxEntrySize!==0){if(e(this,k)!==0&&!ot(e(this,k)))throw new TypeError("maxSize must be a positive integer if specified");if(!ot(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");u(this,l,Yt).call(this);}if(this.allowStale=!!h,this.noDeleteOnStaleGet=!!N,this.updateAgeOnGet=!!n,this.updateAgeOnHas=!!a,this.ttlResolution=ot(r)||r===0?r:1,this.ttlAutopurge=!!o,this.ttl=s||0,this.ttl){if(!ot(this.ttl))throw new TypeError("ttl must be a positive integer if specified");u(this,l,Lt).call(this);}if(e(this,P)===0&&this.ttl===0&&e(this,k)===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!e(this,P)&&!e(this,k)){let Nt="LRU_CACHE_UNBOUNDED";se(Nt)&&($t.add(Nt),Bt("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",Nt,_t));}}get perf(){return e(this,q)}static unsafeExposeInternals(t){return {starts:e(t,Q),ttls:e(t,V),autopurgeTimers:e(t,j),sizes:e(t,X),keyMap:e(t,T),keyList:e(t,A),valList:e(t,y),next:e(t,R),prev:e(t,W),get head(){return e(t,z)},get tail(){return e(t,C)},free:e(t,Y),isBackgroundFetch:i=>{var s;return u(s=t,l,x).call(s,i)},backgroundFetch:(i,s,r,o)=>{var n;return u(n=t,l,zt).call(n,i,s,r,o)},moveToTail:i=>{var s;return u(s=t,l,At).call(s,i)},indexes:i=>{var s;return u(s=t,l,nt).call(s,i)},rindexes:i=>{var s;return u(s=t,l,at).call(s,i)},isStale:i=>{var s;return e(s=t,U).call(s,i)}}}get max(){return e(this,P)}get maxSize(){return e(this,k)}get calculatedSize(){return e(this,J)}get size(){return e(this,F)}get fetchMethod(){return e(this,St)}get memoMethod(){return e(this,bt)}get dispose(){return e(this,$)}get onInsert(){return e(this,ut)}get disposeAfter(){return e(this,B)}getRemainingTTL(t){return e(this,T).has(t)?1/0:0}*entries(){for(let t of u(this,l,nt).call(this))e(this,y)[t]!==void 0&&e(this,A)[t]!==void 0&&!u(this,l,x).call(this,e(this,y)[t])&&(yield [e(this,A)[t],e(this,y)[t]]);}*rentries(){for(let t of u(this,l,at).call(this))e(this,y)[t]!==void 0&&e(this,A)[t]!==void 0&&!u(this,l,x).call(this,e(this,y)[t])&&(yield [e(this,A)[t],e(this,y)[t]]);}*keys(){for(let t of u(this,l,nt).call(this)){let i=e(this,A)[t];i!==void 0&&!u(this,l,x).call(this,e(this,y)[t])&&(yield i);}}*rkeys(){for(let t of u(this,l,at).call(this)){let i=e(this,A)[t];i!==void 0&&!u(this,l,x).call(this,e(this,y)[t])&&(yield i);}}*values(){for(let t of u(this,l,nt).call(this))e(this,y)[t]!==void 0&&!u(this,l,x).call(this,e(this,y)[t])&&(yield e(this,y)[t]);}*rvalues(){for(let t of u(this,l,at).call(this))e(this,y)[t]!==void 0&&!u(this,l,x).call(this,e(this,y)[t])&&(yield e(this,y)[t]);}[(Pt=Symbol.iterator,Kt=Symbol.toStringTag,Pt)](){return this.entries()}find(t,i={}){for(let s of u(this,l,nt).call(this)){let r=e(this,y)[s],o=u(this,l,x).call(this,r)?r.__staleWhileFetching:r;if(o!==void 0&&t(o,e(this,A)[s],this))return this.get(e(this,A)[s],i)}}forEach(t,i=this){for(let s of u(this,l,nt).call(this)){let r=e(this,y)[s],o=u(this,l,x).call(this,r)?r.__staleWhileFetching:r;o!==void 0&&t.call(i,o,e(this,A)[s],this);}}rforEach(t,i=this){for(let s of u(this,l,at).call(this)){let r=e(this,y)[s],o=u(this,l,x).call(this,r)?r.__staleWhileFetching:r;o!==void 0&&t.call(i,o,e(this,A)[s],this);}}purgeStale(){let t=false;for(let i of u(this,l,at).call(this,{allowStale:true}))e(this,U).call(this,i)&&(u(this,l,ht).call(this,e(this,A)[i],"expire"),t=true);return t}info(t){let i=e(this,T).get(t);if(i===void 0)return;let s=e(this,y)[i],r=u(this,l,x).call(this,s)?s.__staleWhileFetching:s;if(r===void 0)return;let o={value:r};if(e(this,V)&&e(this,Q)){let n=e(this,V)[i],a=e(this,Q)[i];if(n&&a){let h=n-(e(this,q).now()-a);o.ttl=h,o.start=Date.now();}}return e(this,X)&&(o.size=e(this,X)[i]),o}dump(){let t=[];for(let i of u(this,l,nt).call(this,{allowStale:true})){let s=e(this,A)[i],r=e(this,y)[i],o=u(this,l,x).call(this,r)?r.__staleWhileFetching:r;if(o===void 0||s===void 0)continue;let n={value:o};if(e(this,V)&&e(this,Q)){n.ttl=e(this,V)[i];let a=e(this,q).now()-e(this,Q)[i];n.start=Math.floor(Date.now()-a);}e(this,X)&&(n.size=e(this,X)[i]),t.unshift([s,n]);}return t}load(t){this.clear();for(let[i,s]of t){if(s.start){let r=Date.now()-s.start;s.start=e(this,q).now()-r;}this.set(i,s.value,s);}}set(t,i,s={}){var v,K,tt,E;if(i===void 0)return this.delete(t),this;let{ttl:r=this.ttl,start:o,noDisposeOnSet:n=this.noDisposeOnSet,sizeCalculation:a=this.sizeCalculation,status:h}=s,{noUpdateTTL:d=this.noUpdateTTL}=s,g=e(this,Ht).call(this,t,i,s.size||0,a);if(this.maxEntrySize&&g>this.maxEntrySize)return h&&(h.set="miss",h.maxEntrySizeExceeded=true),u(this,l,ht).call(this,t,"set"),this;let m=e(this,F)===0?void 0:e(this,T).get(t);if(m===void 0)m=e(this,F)===0?e(this,C):e(this,Y).length!==0?e(this,Y).pop():e(this,F)===e(this,P)?u(this,l,Dt).call(this,false):e(this,F),e(this,A)[m]=t,e(this,y)[m]=i,e(this,T).set(t,m),e(this,R)[e(this,C)]=m,e(this,W)[m]=e(this,C),c(this,C,m),Tt(this,F)._++,e(this,vt).call(this,m,g,h),h&&(h.set="add"),d=false,e(this,wt)&&((v=e(this,ut))==null||v.call(this,i,t,"add"));else {u(this,l,At).call(this,m);let _=e(this,y)[m];if(i!==_){if(e(this,lt)&&u(this,l,x).call(this,_)){_.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:S}=_;S!==void 0&&!n&&(e(this,Z)&&((K=e(this,$))==null||K.call(this,S,t,"set")),e(this,G)&&e(this,D)?.push([S,t,"set"]));}else n||(e(this,Z)&&((tt=e(this,$))==null||tt.call(this,_,t,"set")),e(this,G)&&e(this,D)?.push([_,t,"set"]));if(e(this,pt).call(this,m),e(this,vt).call(this,m,g,h),e(this,y)[m]=i,h){h.set="replace";let S=_&&u(this,l,x).call(this,_)?_.__staleWhileFetching:_;S!==void 0&&(h.oldValue=S);}}else h&&(h.set="update");e(this,wt)&&this.onInsert?.(i,t,i===_?"update":"replace");}if(r!==0&&!e(this,V)&&u(this,l,Lt).call(this),e(this,V)&&(d||e(this,Et).call(this,m,r,o),h&&e(this,rt).call(this,h,m)),!n&&e(this,G)&&e(this,D)){let _=e(this,D),S;for(;S=_?.shift();)(E=e(this,B))==null||E.call(this,...S);}return this}pop(){var t;try{for(;e(this,F);){let i=e(this,y)[e(this,z)];if(u(this,l,Dt).call(this,!0),u(this,l,x).call(this,i)){if(i.__staleWhileFetching)return i.__staleWhileFetching}else if(i!==void 0)return i}}finally{if(e(this,G)&&e(this,D)){let i=e(this,D),s;for(;s=i?.shift();)(t=e(this,B))==null||t.call(this,...s);}}}has(t,i={}){let{updateAgeOnHas:s=this.updateAgeOnHas,status:r}=i,o=e(this,T).get(t);if(o!==void 0){let n=e(this,y)[o];if(u(this,l,x).call(this,n)&&n.__staleWhileFetching===void 0)return false;if(e(this,U).call(this,o))r&&(r.has="stale",e(this,rt).call(this,r,o));else return s&&e(this,ct).call(this,o),r&&(r.has="hit",e(this,rt).call(this,r,o)),true}else r&&(r.has="miss");return false}peek(t,i={}){let{allowStale:s=this.allowStale}=i,r=e(this,T).get(t);if(r===void 0||!s&&e(this,U).call(this,r))return;let o=e(this,y)[r];return u(this,l,x).call(this,o)?o.__staleWhileFetching:o}async fetch(t,i={}){let{allowStale:s=this.allowStale,updateAgeOnGet:r=this.updateAgeOnGet,noDeleteOnStaleGet:o=this.noDeleteOnStaleGet,ttl:n=this.ttl,noDisposeOnSet:a=this.noDisposeOnSet,size:h=0,sizeCalculation:d=this.sizeCalculation,noUpdateTTL:g=this.noUpdateTTL,noDeleteOnFetchRejection:m=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:v=this.allowStaleOnFetchRejection,ignoreFetchAbort:K=this.ignoreFetchAbort,allowStaleOnFetchAbort:tt=this.allowStaleOnFetchAbort,context:E,forceRefresh:_=false,status:S,signal:I}=i;if(!e(this,lt))return S&&(S.fetch="get"),this.get(t,{allowStale:s,updateAgeOnGet:r,noDeleteOnStaleGet:o,status:S});let L={allowStale:s,updateAgeOnGet:r,noDeleteOnStaleGet:o,ttl:n,noDisposeOnSet:a,size:h,sizeCalculation:d,noUpdateTTL:g,noDeleteOnFetchRejection:m,allowStaleOnFetchRejection:v,allowStaleOnFetchAbort:tt,ignoreFetchAbort:K,status:S,signal:I},N=e(this,T).get(t);if(N===void 0){S&&(S.fetch="miss");let H=u(this,l,zt).call(this,t,N,L,E);return H.__returned=H}else {let H=e(this,y)[N];if(u(this,l,x).call(this,H)){let gt=s&&H.__staleWhileFetching!==void 0;return S&&(S.fetch="inflight",gt&&(S.returnedStale=true)),gt?H.__staleWhileFetching:H.__returned=H}let xt=e(this,U).call(this,N);if(!_&&!xt)return S&&(S.fetch="hit"),u(this,l,At).call(this,N),r&&e(this,ct).call(this,N),S&&e(this,rt).call(this,S,N),H;let dt=u(this,l,zt).call(this,t,N,L,E),yt=dt.__staleWhileFetching!==void 0&&s;return S&&(S.fetch=xt?"stale":"refresh",yt&&xt&&(S.returnedStale=true)),yt?dt.__staleWhileFetching:dt.__returned=dt}}async forceFetch(t,i={}){let s=await this.fetch(t,i);if(s===void 0)throw new Error("fetch() returned undefined");return s}memo(t,i={}){let s=e(this,bt);if(!s)throw new Error("no memoMethod provided to constructor");let{context:r,forceRefresh:o,...n}=i,a=this.get(t,n);if(!o&&a!==void 0)return a;let h=s(t,a,{options:n,context:r});return this.set(t,h,n),h}get(t,i={}){let{allowStale:s=this.allowStale,updateAgeOnGet:r=this.updateAgeOnGet,noDeleteOnStaleGet:o=this.noDeleteOnStaleGet,status:n}=i,a=e(this,T).get(t);if(a!==void 0){let h=e(this,y)[a],d=u(this,l,x).call(this,h);return n&&e(this,rt).call(this,n,a),e(this,U).call(this,a)?(n&&(n.get="stale"),d?(n&&s&&h.__staleWhileFetching!==void 0&&(n.returnedStale=true),s?h.__staleWhileFetching:void 0):(o||u(this,l,ht).call(this,t,"expire"),n&&s&&(n.returnedStale=true),s?h:void 0)):(n&&(n.get="hit"),d?h.__staleWhileFetching:(u(this,l,At).call(this,a),r&&e(this,ct).call(this,a),h))}else n&&(n.get="miss");}delete(t){return u(this,l,ht).call(this,t,"delete")}clear(){return u(this,l,Wt).call(this,"delete")}},P=new WeakMap,k=new WeakMap,$=new WeakMap,ut=new WeakMap,B=new WeakMap,St=new WeakMap,bt=new WeakMap,q=new WeakMap,F=new WeakMap,J=new WeakMap,T=new WeakMap,A=new WeakMap,y=new WeakMap,R=new WeakMap,W=new WeakMap,z=new WeakMap,C=new WeakMap,Y=new WeakMap,D=new WeakMap,X=new WeakMap,Q=new WeakMap,V=new WeakMap,j=new WeakMap,Z=new WeakMap,lt=new WeakMap,G=new WeakMap,wt=new WeakMap,l=new WeakSet,Lt=function(){let t=new Ct(e(this,P)),i=new Ct(e(this,P));c(this,V,t),c(this,Q,i);let s=this.ttlAutopurge?new Array(e(this,P)):void 0;c(this,j,s),c(this,Et,(a,h,d=e(this,q).now())=>{i[a]=h!==0?d:0,t[a]=h,r(a,h);}),c(this,ct,a=>{i[a]=t[a]!==0?e(this,q).now():0,r(a,t[a]);});let r=this.ttlAutopurge?(a,h)=>{if(s?.[a]&&(clearTimeout(s[a]),s[a]=void 0),h&&h!==0&&s){let d=setTimeout(()=>{e(this,U).call(this,a)&&u(this,l,ht).call(this,e(this,A)[a],"expire");},h+1);d.unref&&d.unref(),s[a]=d;}}:()=>{};c(this,rt,(a,h)=>{if(t[h]){let d=t[h],g=i[h];if(!d||!g)return;a.ttl=d,a.start=g,a.now=o||n();let m=a.now-g;a.remainingTTL=d-m;}});let o=0,n=()=>{let a=e(this,q).now();if(this.ttlResolution>0){o=a;let h=setTimeout(()=>o=0,this.ttlResolution);h.unref&&h.unref();}return a};this.getRemainingTTL=a=>{let h=e(this,T).get(a);if(h===void 0)return 0;let d=t[h],g=i[h];if(!d||!g)return 1/0;let m=(o||n())-g;return d-m},c(this,U,a=>{let h=i[a],d=t[a];return !!d&&!!h&&(o||n())-h>d});},ct=new WeakMap,rt=new WeakMap,Et=new WeakMap,U=new WeakMap,Yt=function(){let t=new Ct(e(this,P));c(this,J,0),c(this,X,t),c(this,pt,i=>{c(this,J,e(this,J)-t[i]),t[i]=0;}),c(this,Ht,(i,s,r,o)=>{if(u(this,l,x).call(this,s))return 0;if(!ot(r))if(o){if(typeof o!="function")throw new TypeError("sizeCalculation must be a function");if(r=o(s,i),!ot(r))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 r}),c(this,vt,(i,s,r)=>{if(t[i]=s,e(this,k)){let o=e(this,k)-t[i];for(;e(this,J)>o;)u(this,l,Dt).call(this,true);}c(this,J,e(this,J)+t[i]),r&&(r.entrySize=s,r.totalCalculatedSize=e(this,J));});},pt=new WeakMap,vt=new WeakMap,Ht=new WeakMap,nt=function*({allowStale:t=this.allowStale}={}){if(e(this,F))for(let i=e(this,C);!(!u(this,l,Mt).call(this,i)||((t||!e(this,U).call(this,i))&&(yield i),i===e(this,z)));)i=e(this,W)[i];},at=function*({allowStale:t=this.allowStale}={}){if(e(this,F))for(let i=e(this,z);!(!u(this,l,Mt).call(this,i)||((t||!e(this,U).call(this,i))&&(yield i),i===e(this,C)));)i=e(this,R)[i];},Mt=function(t){return t!==void 0&&e(this,T).get(e(this,A)[t])===t},Dt=function(t){var o;let i=e(this,z),s=e(this,A)[i],r=e(this,y)[i];return e(this,lt)&&u(this,l,x).call(this,r)?r.__abortController.abort(new Error("evicted")):(e(this,Z)||e(this,G))&&(e(this,Z)&&((o=e(this,$))==null||o.call(this,r,s,"evict")),e(this,G)&&e(this,D)?.push([r,s,"evict"])),e(this,pt).call(this,i),e(this,j)?.[i]&&(clearTimeout(e(this,j)[i]),e(this,j)[i]=void 0),t&&(e(this,A)[i]=void 0,e(this,y)[i]=void 0,e(this,Y).push(i)),e(this,F)===1?(c(this,z,c(this,C,0)),e(this,Y).length=0):c(this,z,e(this,R)[i]),e(this,T).delete(s),Tt(this,F)._--,i},zt=function(t,i,s,r){let o=i===void 0?void 0:e(this,y)[i];if(u(this,l,x).call(this,o))return o;let n=new It,{signal:a}=s;a?.addEventListener("abort",()=>n.abort(a.reason),{signal:n.signal});let h={signal:n.signal,options:s,context:r},d=(E,_=false)=>{let{aborted:S}=n.signal,I=s.ignoreFetchAbort&&E!==void 0,L=s.ignoreFetchAbort||!!(s.allowStaleOnFetchAbort&&E!==void 0);if(s.status&&(S&&!_?(s.status.fetchAborted=true,s.status.fetchError=n.signal.reason,I&&(s.status.fetchAbortIgnored=true)):s.status.fetchResolved=true),S&&!I&&!_)return m(n.signal.reason,L);let N=K,H=e(this,y)[i];return (H===K||I&&_&&H===void 0)&&(E===void 0?N.__staleWhileFetching!==void 0?e(this,y)[i]=N.__staleWhileFetching:u(this,l,ht).call(this,t,"fetch"):(s.status&&(s.status.fetchUpdated=true),this.set(t,E,h.options))),E},g=E=>(s.status&&(s.status.fetchRejected=true,s.status.fetchError=E),m(E,false)),m=(E,_)=>{let{aborted:S}=n.signal,I=S&&s.allowStaleOnFetchAbort,L=I||s.allowStaleOnFetchRejection,N=L||s.noDeleteOnFetchRejection,H=K;if(e(this,y)[i]===K&&(!N||!_&&H.__staleWhileFetching===void 0?u(this,l,ht).call(this,t,"fetch"):I||(e(this,y)[i]=H.__staleWhileFetching)),L)return s.status&&H.__staleWhileFetching!==void 0&&(s.status.returnedStale=true),H.__staleWhileFetching;if(H.__returned===H)throw E},v=(E,_)=>{var I;let S=(I=e(this,St))==null?void 0:I.call(this,t,o,h);S&&S instanceof Promise&&S.then(L=>E(L===void 0?void 0:L),_),n.signal.addEventListener("abort",()=>{(!s.ignoreFetchAbort||s.allowStaleOnFetchAbort)&&(E(void 0),s.allowStaleOnFetchAbort&&(E=L=>d(L,true)));});};s.status&&(s.status.fetchDispatched=true);let K=new Promise(v).then(d,g),tt=Object.assign(K,{__abortController:n,__staleWhileFetching:o,__returned:void 0});return i===void 0?(this.set(t,tt,{...h.options,status:void 0}),i=e(this,T).get(t)):e(this,y)[i]=tt,tt},x=function(t){if(!e(this,lt))return false;let i=t;return !!i&&i instanceof Promise&&i.hasOwnProperty("__staleWhileFetching")&&i.__abortController instanceof It},kt=function(t,i){e(this,W)[i]=t,e(this,R)[t]=i;},At=function(t){t!==e(this,C)&&(t===e(this,z)?c(this,z,e(this,R)[t]):u(this,l,kt).call(this,e(this,W)[t],e(this,R)[t]),u(this,l,kt).call(this,e(this,C),t),c(this,C,t));},ht=function(t,i){var r,o;let s=false;if(e(this,F)!==0){let n=e(this,T).get(t);if(n!==void 0)if(e(this,j)?.[n]&&(clearTimeout(e(this,j)?.[n]),e(this,j)[n]=void 0),s=true,e(this,F)===1)u(this,l,Wt).call(this,i);else {e(this,pt).call(this,n);let a=e(this,y)[n];if(u(this,l,x).call(this,a)?a.__abortController.abort(new Error("deleted")):(e(this,Z)||e(this,G))&&(e(this,Z)&&((r=e(this,$))==null||r.call(this,a,t,i)),e(this,G)&&e(this,D)?.push([a,t,i])),e(this,T).delete(t),e(this,A)[n]=void 0,e(this,y)[n]=void 0,n===e(this,C))c(this,C,e(this,W)[n]);else if(n===e(this,z))c(this,z,e(this,R)[n]);else {let h=e(this,W)[n];e(this,R)[h]=e(this,R)[n];let d=e(this,R)[n];e(this,W)[d]=e(this,W)[n];}Tt(this,F)._--,e(this,Y).push(n);}}if(e(this,G)&&e(this,D)?.length){let n=e(this,D),a;for(;a=n?.shift();)(o=e(this,B))==null||o.call(this,...a);}return s},Wt=function(t){var i,s;for(let r of u(this,l,at).call(this,{allowStale:true})){let o=e(this,y)[r];if(u(this,l,x).call(this,o))o.__abortController.abort(new Error("deleted"));else {let n=e(this,A)[r];e(this,Z)&&((i=e(this,$))==null||i.call(this,o,n,t)),e(this,G)&&e(this,D)?.push([o,n,t]);}}if(e(this,T).clear(),e(this,y).fill(void 0),e(this,A).fill(void 0),e(this,V)&&e(this,Q)){e(this,V).fill(0),e(this,Q).fill(0);for(let r of e(this,j)??[])r!==void 0&&clearTimeout(r);e(this,j)?.fill(void 0);}if(e(this,X)&&e(this,X).fill(0),c(this,z,0),c(this,C,0),e(this,Y).length=0,c(this,J,0),c(this,F,0),e(this,G)&&e(this,D)){let r=e(this,D),o;for(;o=r?.shift();)(s=e(this,B))==null||s.call(this,...o);}},_t);var ft=class{constructor(t){w(this,"cache");w(this,"map",new Map);this.cache=new Jt({max:t.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(t){let i=this.map.delete(t);return i&&this.cache.delete(t),i}get forEach(){return this.map.forEach}get(t){let i=this.cache.get(t);return i||this.map.get(t)}has(t){return this.map.has(t)}set(t,i){return this.map.set(t,i),this.cache.set(t,i),this}get size(){return this.map.size}entries(){return this.map.entries()}keys(){return this.map.keys()}values(){return this.map.values()}};var st=class st{static get originalStepData(){return st._originalStepData?et(st._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(t){st._originalStepData=et(t);}};w(st,"_diffHistory",new ft({cacheSize:5})),w(st,"_stepsInfoHistory",new ft({cacheSize:5})),w(st,"_narrationHistory",new ft({cacheSize:50})),w(st,"stepLimitSaved",20),w(st,"_originalStepData");var p=st;var Ot=class{get stepsInfoMap(){return p._stepsInfoHistory}get diffMap(){return p._diffHistory}get narrationMap(){return p._narrationHistory}get size(){return p._stepsInfoHistory.size}get lastKey(){return this.size===0?null:Math.max(...Array.from(this.keys()))}keys(){return p._stepsInfoHistory.keys()}get(t){let i=p._narrationHistory.get(t);if(!(i&&Object.keys(i).length===1&&i.stepIndex!==void 0))return i}delete(t){p._stepsInfoHistory.delete(t),p._diffHistory.delete(t),p._narrationHistory.delete(t);}getOldGameState(t,i){if(t<=0||this.size==0)return i;let s=this.lastKey;if(typeof s!="number")return O.warn("You can't go back, there is no step to go back"),i;let r=p._diffHistory.get(s);if(r)try{let o=jt(i,r);return core.GameUnifier.stepCounter=s,this.delete(s),this.getOldGameState(t-1,o)}catch(o){return O.error("Error applying diff",o),i}else return O.warn("No diff found for the last step, cannot go back"),i}async back(t,i={}){let{steps:s=1}=i;if(!Number.isFinite(s)){O.warn(`[back] The parameter steps must be a valid finite number, received: ${s}`);return}if(s<=0){O.warn(`[back] The parameter steps must be greater than 0, received: ${s}`);return}if(core.GameUnifier.runningStepsCount>0){core.GameUnifier.increaseBackRequest(s);return}if(p._diffHistory.size<1){O.warn("You can't go back, there is no step to go back");return}core.GameUnifier.runningStepsCount++;try{let r=et(this.getOldGameState(s,p.originalStepData));if(r){await core.GameUnifier.restoreGameStepState(r,core.GameUnifier.navigate);let o=core.GameUnifier.stepCounter-1,n=p._narrationHistory.get(o);if(n&&Object.keys(n).length===1&&n.stepIndex!==void 0){let a=p._stepsInfoHistory.get(o);if(a){let h=this.itemMapper({step:a});p._narrationHistory.set(a.index,h);}}}else O.error("Error going back");p.originalStepData=r;}catch(r){O.error("Error going back",r);}finally{if(core.GameUnifier.runningStepsCount--,core.GameUnifier.runningStepsCount===0&&core.GameUnifier.backRequestsCount!==0)return await core.GameUnifier.processNavigationRequests(t)}}add(t,i={}){let s=p.originalStepData,{ignoreSameStep:r}=i,o=core.GameUnifier.currentGameStepState;if(!r&&this.isSameStep(s,o))return;let n=this.lastKey;(async()=>{try{let h,d;if(typeof n=="number"&&(h=p._stepsInfoHistory.get(n),d=p._narrationHistory.get(n)),p._stepsInfoHistory.set(t.index,t),t.index!==0){let v=Ft(s,o);v?p._diffHistory.set(t.index,v):O.warn("It was not possible to create the difference between the two steps");}let g={},m=this.itemMapper({step:t},g);if(p._narrationHistory.set(t.index,m),h&&d&&typeof n=="number"){let v=this.itemMapper({...g,step:h},{});p._narrationHistory.set(n,v);}}catch(h){O.error("Error adding history step",h);}})(),p.originalStepData=o;}itemMapper(t,i){let{step:s,choiceIndexMade:r,inputValue:o,removeDialogue:n}=t,a=s.dialogue;i&&s.isGlued&&(i.removeDialogue=true),n&&(a=void 0);let h=s.choices;if(i&&s.currentLabel&&s.choiceIndexMade!==void 0&&(i.choiceIndexMade=s.choiceIndexMade),s.inputValue&&i&&(i.inputValue=s.inputValue),a||h||o){let d=h?.map((g,m)=>{let v=false;return g.oneTime&&s.alreadyMadeChoices&&s.alreadyMadeChoices.includes(m)&&(v=true),{text:g.text,type:g.type,isResponse:false,hidden:v}});if(d){if(d.every(g=>g.hidden)){let g=d.find(m=>m.hidden===false);g&&(g.hidden=false);}r!==void 0&&(d[r].isResponse=true);}return {dialogue:a?{...a,character:a.character?core.GameUnifier.getCharacter(a.character)||a.character:void 0}:void 0,playerMadeChoice:typeof r=="number",choices:d,stepIndex:s.index,inputValue:o}}return {stepIndex:s.index}}get narrativeHistory(){let t=[];return Array.from(this.keys()).sort((s,r)=>s-r).forEach(s=>{let r=this.get(s);r&&t.push(r);}),t}get currentLabelHistory(){let t=[],i=Array.from(this.keys()).sort((h,d)=>d-h);if(i.length===0)return t;let s=i[0];if(typeof s!="number")return t;let r=p._stepsInfoHistory.get(s);if(!r)return t;let o=r.openedLabels;if(!o||!Array.isArray(o)||o.length===0)return t;let n=o[0].currentStepIndex,a=o[0].label;return i.every((h,d)=>{let g=this.get(h);if(g){if(d===0)return t.push(g),true;let m=p._stepsInfoHistory.get(h);if(!m)return true;let v=m.openedLabels;if(!v||!Array.isArray(v)||v.length===0||v[0].label!==a||v[0].currentStepIndex>=n)return false;n=v[0].currentStepIndex,t.push(g);}return true}),t.reverse()}removeNarrativeHistory(t){if(t){let i=Array.from(this.keys()).sort((s,r)=>s-r);i=i.slice(0,t),i.forEach(s=>{p._narrationHistory.delete(s),p._stepsInfoHistory.delete(s),p._diffHistory.delete(s);});}else p._stepsInfoHistory.clear(),p._diffHistory.clear(),p._narrationHistory.clear();}get canGoBack(){let t=this.lastKey;return typeof t!="number"?false:p._diffHistory.has(t)}blockGoBack(){core.GameUnifier.runningStepsCount===0&&p._diffHistory.clear();}isSameStep(t,i){if(t.openedLabels.length===i.openedLabels.length)try{let s=JSON.stringify(t.openedLabels),r=JSON.stringify(i.openedLabels);if(s===r&&t.path===i.path&&t.labelIndex===i.labelIndex)return !0}catch(s){return O.error("Error comparing opened labels",s),true}return false}clear(){p._stepsInfoHistory.clear(),p._diffHistory.clear(),p._narrationHistory.clear(),p._originalStepData=void 0;}get stepLimitSaved(){return p.stepLimitSaved}set stepLimitSaved(t){p.stepLimitSaved=t;}export(){let t=Array.from(this.keys()).sort((s,r)=>s-r);t.length>this.stepLimitSaved&&(t=t.slice(t.length-this.stepLimitSaved));let i=[];return t.forEach(s=>{let r=p._stepsInfoHistory.get(s);if(r){let o=p._diffHistory.get(s);i.push({...r,diff:o});}}),{stepsHistory:et(i),originalStepData:et(p._originalStepData)}}restoreNarrativeHistory(){let t=Array.from(this.keys()).sort((s,r)=>s-r),i={};t.forEach(s=>{let r=p._stepsInfoHistory.get(s);if(r){let o={...i};i={};let n=this.itemMapper({step:r,choiceIndexMade:o.choiceIndexMade,inputValue:o.inputValue,removeDialogue:o.removeDialogue},i);n&&p._narrationHistory.set(s,n);}});}async restore(t){this.clear();try{t.hasOwnProperty("stepsHistory")?(t.stepsHistory.forEach(s=>{s.diff&&p._diffHistory.set(s.index,s.diff);let r={...s,diff:void 0};p._stepsInfoHistory.set(s.index,r);}),this.restoreNarrativeHistory()):O.warn("Could not import stepsHistory data, so will be ignored"),t.hasOwnProperty("originalStepData")?p._originalStepData=t.originalStepData:O.warn("Could not import originalStepData data, so will be ignored");}catch(i){O.error("Error importing data",i);}}};var Me=new Ot;exports.HistoryManagerStatic=p;exports.stepHistory=Me;
|
|
1
|
+
'use strict';var core=require('@drincs/pixi-vn/core');var Xt=Object.defineProperty;var jt=c=>{throw TypeError(c)};var Qt=(c,t,i)=>t in c?Xt(c,t,{enumerable:true,configurable:true,writable:true,value:i}):c[t]=i;var v=(c,t,i)=>Qt(c,typeof t!="symbol"?t+"":t,i),Nt=(c,t,i)=>t.has(c)||jt("Cannot "+i);var e=(c,t,i)=>(Nt(c,t,"read from private field"),i?i.call(c):t.get(c)),b=(c,t,i)=>t.has(c)?jt("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(c):t.set(c,i),u=(c,t,i,s)=>(Nt(c,t,"write to private field"),t.set(c,i),i),f=(c,t,i)=>(Nt(c,t,"access private method"),i);var Tt=(c,t,i,s)=>({set _(r){u(c,t,r);},get _(){return e(c,t,s)}});var Zt=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,Pt=new Set,Rt=typeof process=="object"&&process?process:{},$t=(c,t,i,s)=>{typeof Rt.emitWarning=="function"?Rt.emitWarning(c,t,i,s):console.error(`[${i}] ${t}: ${c}`);},zt=globalThis.AbortController,Vt=globalThis.AbortSignal;if(typeof zt>"u"){Vt=class{constructor(){v(this,"onabort");v(this,"_onabort",[]);v(this,"reason");v(this,"aborted",false);}addEventListener(i,s){this._onabort.push(s);}},zt=class{constructor(){v(this,"signal",new Vt);t();}abort(i){if(!this.signal.aborted){this.signal.reason=i,this.signal.aborted=true;for(let s of this.signal._onabort)s(i);this.signal.onabort?.(i);}}};let c=Rt.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",t=()=>{c&&(c=false,$t("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",t));};}var te=c=>!Pt.has(c);var ot=c=>c&&c===Math.floor(c)&&c>0&&isFinite(c),Bt=c=>ot(c)?c<=Math.pow(2,8)?Uint8Array:c<=Math.pow(2,16)?Uint16Array:c<=Math.pow(2,32)?Uint32Array:c<=Number.MAX_SAFE_INTEGER?Ft:null:null,Ft=class extends Array{constructor(c){super(c),this.fill(0);}},et,mt,ee=(et=class{constructor(t,i){v(this,"heap");v(this,"length");if(!e(et,mt))throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new i(t),this.length=0;}static create(t){let i=Bt(t);if(!i)return [];u(et,mt,true);let s=new et(t,i);return u(et,mt,false),s}push(t){this.heap[this.length++]=t;}pop(){return this.heap[--this.length]}},mt=new WeakMap,b(et,mt,false),et),Ut,Kt,P,k,$,ft,B,St,bt,q,F,J,T,H,y,N,W,z,C,Y,D,X,Q,j,V,Z,lt,R,vt,l,Lt,ut,rt,At,U,Jt,pt,wt,Et,nt,at,Mt,Ct,Dt,x,kt,Ht,ht,Wt,_t,qt=(_t=class{constructor(t){b(this,l);b(this,P);b(this,k);b(this,$);b(this,ft);b(this,B);b(this,St);b(this,bt);b(this,q);v(this,"ttl");v(this,"ttlResolution");v(this,"ttlAutopurge");v(this,"updateAgeOnGet");v(this,"updateAgeOnHas");v(this,"allowStale");v(this,"noDisposeOnSet");v(this,"noUpdateTTL");v(this,"maxEntrySize");v(this,"sizeCalculation");v(this,"noDeleteOnFetchRejection");v(this,"noDeleteOnStaleGet");v(this,"allowStaleOnFetchAbort");v(this,"allowStaleOnFetchRejection");v(this,"ignoreFetchAbort");b(this,F);b(this,J);b(this,T);b(this,H);b(this,y);b(this,N);b(this,W);b(this,z);b(this,C);b(this,Y);b(this,D);b(this,X);b(this,Q);b(this,j);b(this,V);b(this,Z);b(this,lt);b(this,R);b(this,vt);b(this,ut,()=>{});b(this,rt,()=>{});b(this,At,()=>{});b(this,U,()=>false);b(this,pt,t=>{});b(this,wt,(t,i,s)=>{});b(this,Et,(t,i,s,r)=>{if(s||r)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0});v(this,Ut,"LRUCache");let{max:i=0,ttl:s,ttlResolution:r=1,ttlAutopurge:o,updateAgeOnGet:n,updateAgeOnHas:a,allowStale:h,dispose:d,onInsert:g,disposeAfter:m,noDisposeOnSet:w,noUpdateTTL:K,maxSize:tt=0,maxEntrySize:A=0,sizeCalculation:_,fetchMethod:S,memoMethod:I,noDeleteOnFetchRejection:L,noDeleteOnStaleGet:G,allowStaleOnFetchRejection:E,allowStaleOnFetchAbort:xt,ignoreFetchAbort:dt,perf:yt}=t;if(yt!==void 0&&typeof yt?.now!="function")throw new TypeError("perf option must have a now() method if specified");if(u(this,q,yt??Zt),i!==0&&!ot(i))throw new TypeError("max option must be a nonnegative integer");let gt=i?Bt(i):Array;if(!gt)throw new Error("invalid max value: "+i);if(u(this,P,i),u(this,k,tt),this.maxEntrySize=A||e(this,k),this.sizeCalculation=_,this.sizeCalculation){if(!e(this,k)&&!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(I!==void 0&&typeof I!="function")throw new TypeError("memoMethod must be a function if defined");if(u(this,bt,I),S!==void 0&&typeof S!="function")throw new TypeError("fetchMethod must be a function if specified");if(u(this,St,S),u(this,lt,!!S),u(this,T,new Map),u(this,H,new Array(i).fill(void 0)),u(this,y,new Array(i).fill(void 0)),u(this,N,new gt(i)),u(this,W,new gt(i)),u(this,z,0),u(this,C,0),u(this,Y,ee.create(i)),u(this,F,0),u(this,J,0),typeof d=="function"&&u(this,$,d),typeof g=="function"&&u(this,ft,g),typeof m=="function"?(u(this,B,m),u(this,D,[])):(u(this,B,void 0),u(this,D,void 0)),u(this,Z,!!e(this,$)),u(this,vt,!!e(this,ft)),u(this,R,!!e(this,B)),this.noDisposeOnSet=!!w,this.noUpdateTTL=!!K,this.noDeleteOnFetchRejection=!!L,this.allowStaleOnFetchRejection=!!E,this.allowStaleOnFetchAbort=!!xt,this.ignoreFetchAbort=!!dt,this.maxEntrySize!==0){if(e(this,k)!==0&&!ot(e(this,k)))throw new TypeError("maxSize must be a positive integer if specified");if(!ot(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");f(this,l,Jt).call(this);}if(this.allowStale=!!h,this.noDeleteOnStaleGet=!!G,this.updateAgeOnGet=!!n,this.updateAgeOnHas=!!a,this.ttlResolution=ot(r)||r===0?r:1,this.ttlAutopurge=!!o,this.ttl=s||0,this.ttl){if(!ot(this.ttl))throw new TypeError("ttl must be a positive integer if specified");f(this,l,Lt).call(this);}if(e(this,P)===0&&this.ttl===0&&e(this,k)===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!e(this,P)&&!e(this,k)){let Gt="LRU_CACHE_UNBOUNDED";te(Gt)&&(Pt.add(Gt),$t("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",Gt,_t));}}get perf(){return e(this,q)}static unsafeExposeInternals(t){return {starts:e(t,Q),ttls:e(t,j),autopurgeTimers:e(t,V),sizes:e(t,X),keyMap:e(t,T),keyList:e(t,H),valList:e(t,y),next:e(t,N),prev:e(t,W),get head(){return e(t,z)},get tail(){return e(t,C)},free:e(t,Y),isBackgroundFetch:i=>{var s;return f(s=t,l,x).call(s,i)},backgroundFetch:(i,s,r,o)=>{var n;return f(n=t,l,Dt).call(n,i,s,r,o)},moveToTail:i=>{var s;return f(s=t,l,Ht).call(s,i)},indexes:i=>{var s;return f(s=t,l,nt).call(s,i)},rindexes:i=>{var s;return f(s=t,l,at).call(s,i)},isStale:i=>{var s;return e(s=t,U).call(s,i)}}}get max(){return e(this,P)}get maxSize(){return e(this,k)}get calculatedSize(){return e(this,J)}get size(){return e(this,F)}get fetchMethod(){return e(this,St)}get memoMethod(){return e(this,bt)}get dispose(){return e(this,$)}get onInsert(){return e(this,ft)}get disposeAfter(){return e(this,B)}getRemainingTTL(t){return e(this,T).has(t)?1/0:0}*entries(){for(let t of f(this,l,nt).call(this))e(this,y)[t]!==void 0&&e(this,H)[t]!==void 0&&!f(this,l,x).call(this,e(this,y)[t])&&(yield [e(this,H)[t],e(this,y)[t]]);}*rentries(){for(let t of f(this,l,at).call(this))e(this,y)[t]!==void 0&&e(this,H)[t]!==void 0&&!f(this,l,x).call(this,e(this,y)[t])&&(yield [e(this,H)[t],e(this,y)[t]]);}*keys(){for(let t of f(this,l,nt).call(this)){let i=e(this,H)[t];i!==void 0&&!f(this,l,x).call(this,e(this,y)[t])&&(yield i);}}*rkeys(){for(let t of f(this,l,at).call(this)){let i=e(this,H)[t];i!==void 0&&!f(this,l,x).call(this,e(this,y)[t])&&(yield i);}}*values(){for(let t of f(this,l,nt).call(this))e(this,y)[t]!==void 0&&!f(this,l,x).call(this,e(this,y)[t])&&(yield e(this,y)[t]);}*rvalues(){for(let t of f(this,l,at).call(this))e(this,y)[t]!==void 0&&!f(this,l,x).call(this,e(this,y)[t])&&(yield e(this,y)[t]);}[(Kt=Symbol.iterator,Ut=Symbol.toStringTag,Kt)](){return this.entries()}find(t,i={}){for(let s of f(this,l,nt).call(this)){let r=e(this,y)[s],o=f(this,l,x).call(this,r)?r.__staleWhileFetching:r;if(o!==void 0&&t(o,e(this,H)[s],this))return this.get(e(this,H)[s],i)}}forEach(t,i=this){for(let s of f(this,l,nt).call(this)){let r=e(this,y)[s],o=f(this,l,x).call(this,r)?r.__staleWhileFetching:r;o!==void 0&&t.call(i,o,e(this,H)[s],this);}}rforEach(t,i=this){for(let s of f(this,l,at).call(this)){let r=e(this,y)[s],o=f(this,l,x).call(this,r)?r.__staleWhileFetching:r;o!==void 0&&t.call(i,o,e(this,H)[s],this);}}purgeStale(){let t=false;for(let i of f(this,l,at).call(this,{allowStale:true}))e(this,U).call(this,i)&&(f(this,l,ht).call(this,e(this,H)[i],"expire"),t=true);return t}info(t){let i=e(this,T).get(t);if(i===void 0)return;let s=e(this,y)[i],r=f(this,l,x).call(this,s)?s.__staleWhileFetching:s;if(r===void 0)return;let o={value:r};if(e(this,j)&&e(this,Q)){let n=e(this,j)[i],a=e(this,Q)[i];if(n&&a){let h=n-(e(this,q).now()-a);o.ttl=h,o.start=Date.now();}}return e(this,X)&&(o.size=e(this,X)[i]),o}dump(){let t=[];for(let i of f(this,l,nt).call(this,{allowStale:true})){let s=e(this,H)[i],r=e(this,y)[i],o=f(this,l,x).call(this,r)?r.__staleWhileFetching:r;if(o===void 0||s===void 0)continue;let n={value:o};if(e(this,j)&&e(this,Q)){n.ttl=e(this,j)[i];let a=e(this,q).now()-e(this,Q)[i];n.start=Math.floor(Date.now()-a);}e(this,X)&&(n.size=e(this,X)[i]),t.unshift([s,n]);}return t}load(t){this.clear();for(let[i,s]of t){if(s.start){let r=Date.now()-s.start;s.start=e(this,q).now()-r;}this.set(i,s.value,s);}}set(t,i,s={}){var w,K,tt,A;if(i===void 0)return this.delete(t),this;let{ttl:r=this.ttl,start:o,noDisposeOnSet:n=this.noDisposeOnSet,sizeCalculation:a=this.sizeCalculation,status:h}=s,{noUpdateTTL:d=this.noUpdateTTL}=s,g=e(this,Et).call(this,t,i,s.size||0,a);if(this.maxEntrySize&&g>this.maxEntrySize)return h&&(h.set="miss",h.maxEntrySizeExceeded=true),f(this,l,ht).call(this,t,"set"),this;let m=e(this,F)===0?void 0:e(this,T).get(t);if(m===void 0)m=e(this,F)===0?e(this,C):e(this,Y).length!==0?e(this,Y).pop():e(this,F)===e(this,P)?f(this,l,Ct).call(this,false):e(this,F),e(this,H)[m]=t,e(this,y)[m]=i,e(this,T).set(t,m),e(this,N)[e(this,C)]=m,e(this,W)[m]=e(this,C),u(this,C,m),Tt(this,F)._++,e(this,wt).call(this,m,g,h),h&&(h.set="add"),d=false,e(this,vt)&&((w=e(this,ft))==null||w.call(this,i,t,"add"));else {f(this,l,Ht).call(this,m);let _=e(this,y)[m];if(i!==_){if(e(this,lt)&&f(this,l,x).call(this,_)){_.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:S}=_;S!==void 0&&!n&&(e(this,Z)&&((K=e(this,$))==null||K.call(this,S,t,"set")),e(this,R)&&e(this,D)?.push([S,t,"set"]));}else n||(e(this,Z)&&((tt=e(this,$))==null||tt.call(this,_,t,"set")),e(this,R)&&e(this,D)?.push([_,t,"set"]));if(e(this,pt).call(this,m),e(this,wt).call(this,m,g,h),e(this,y)[m]=i,h){h.set="replace";let S=_&&f(this,l,x).call(this,_)?_.__staleWhileFetching:_;S!==void 0&&(h.oldValue=S);}}else h&&(h.set="update");e(this,vt)&&this.onInsert?.(i,t,i===_?"update":"replace");}if(r!==0&&!e(this,j)&&f(this,l,Lt).call(this),e(this,j)&&(d||e(this,At).call(this,m,r,o),h&&e(this,rt).call(this,h,m)),!n&&e(this,R)&&e(this,D)){let _=e(this,D),S;for(;S=_?.shift();)(A=e(this,B))==null||A.call(this,...S);}return this}pop(){var t;try{for(;e(this,F);){let i=e(this,y)[e(this,z)];if(f(this,l,Ct).call(this,!0),f(this,l,x).call(this,i)){if(i.__staleWhileFetching)return i.__staleWhileFetching}else if(i!==void 0)return i}}finally{if(e(this,R)&&e(this,D)){let i=e(this,D),s;for(;s=i?.shift();)(t=e(this,B))==null||t.call(this,...s);}}}has(t,i={}){let{updateAgeOnHas:s=this.updateAgeOnHas,status:r}=i,o=e(this,T).get(t);if(o!==void 0){let n=e(this,y)[o];if(f(this,l,x).call(this,n)&&n.__staleWhileFetching===void 0)return false;if(e(this,U).call(this,o))r&&(r.has="stale",e(this,rt).call(this,r,o));else return s&&e(this,ut).call(this,o),r&&(r.has="hit",e(this,rt).call(this,r,o)),true}else r&&(r.has="miss");return false}peek(t,i={}){let{allowStale:s=this.allowStale}=i,r=e(this,T).get(t);if(r===void 0||!s&&e(this,U).call(this,r))return;let o=e(this,y)[r];return f(this,l,x).call(this,o)?o.__staleWhileFetching:o}async fetch(t,i={}){let{allowStale:s=this.allowStale,updateAgeOnGet:r=this.updateAgeOnGet,noDeleteOnStaleGet:o=this.noDeleteOnStaleGet,ttl:n=this.ttl,noDisposeOnSet:a=this.noDisposeOnSet,size:h=0,sizeCalculation:d=this.sizeCalculation,noUpdateTTL:g=this.noUpdateTTL,noDeleteOnFetchRejection:m=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:w=this.allowStaleOnFetchRejection,ignoreFetchAbort:K=this.ignoreFetchAbort,allowStaleOnFetchAbort:tt=this.allowStaleOnFetchAbort,context:A,forceRefresh:_=false,status:S,signal:I}=i;if(!e(this,lt))return S&&(S.fetch="get"),this.get(t,{allowStale:s,updateAgeOnGet:r,noDeleteOnStaleGet:o,status:S});let L={allowStale:s,updateAgeOnGet:r,noDeleteOnStaleGet:o,ttl:n,noDisposeOnSet:a,size:h,sizeCalculation:d,noUpdateTTL:g,noDeleteOnFetchRejection:m,allowStaleOnFetchRejection:w,allowStaleOnFetchAbort:tt,ignoreFetchAbort:K,status:S,signal:I},G=e(this,T).get(t);if(G===void 0){S&&(S.fetch="miss");let E=f(this,l,Dt).call(this,t,G,L,A);return E.__returned=E}else {let E=e(this,y)[G];if(f(this,l,x).call(this,E)){let gt=s&&E.__staleWhileFetching!==void 0;return S&&(S.fetch="inflight",gt&&(S.returnedStale=true)),gt?E.__staleWhileFetching:E.__returned=E}let xt=e(this,U).call(this,G);if(!_&&!xt)return S&&(S.fetch="hit"),f(this,l,Ht).call(this,G),r&&e(this,ut).call(this,G),S&&e(this,rt).call(this,S,G),E;let dt=f(this,l,Dt).call(this,t,G,L,A),yt=dt.__staleWhileFetching!==void 0&&s;return S&&(S.fetch=xt?"stale":"refresh",yt&&xt&&(S.returnedStale=true)),yt?dt.__staleWhileFetching:dt.__returned=dt}}async forceFetch(t,i={}){let s=await this.fetch(t,i);if(s===void 0)throw new Error("fetch() returned undefined");return s}memo(t,i={}){let s=e(this,bt);if(!s)throw new Error("no memoMethod provided to constructor");let{context:r,forceRefresh:o,...n}=i,a=this.get(t,n);if(!o&&a!==void 0)return a;let h=s(t,a,{options:n,context:r});return this.set(t,h,n),h}get(t,i={}){let{allowStale:s=this.allowStale,updateAgeOnGet:r=this.updateAgeOnGet,noDeleteOnStaleGet:o=this.noDeleteOnStaleGet,status:n}=i,a=e(this,T).get(t);if(a!==void 0){let h=e(this,y)[a],d=f(this,l,x).call(this,h);return n&&e(this,rt).call(this,n,a),e(this,U).call(this,a)?(n&&(n.get="stale"),d?(n&&s&&h.__staleWhileFetching!==void 0&&(n.returnedStale=true),s?h.__staleWhileFetching:void 0):(o||f(this,l,ht).call(this,t,"expire"),n&&s&&(n.returnedStale=true),s?h:void 0)):(n&&(n.get="hit"),d?h.__staleWhileFetching:(f(this,l,Ht).call(this,a),r&&e(this,ut).call(this,a),h))}else n&&(n.get="miss");}delete(t){return f(this,l,ht).call(this,t,"delete")}clear(){return f(this,l,Wt).call(this,"delete")}},P=new WeakMap,k=new WeakMap,$=new WeakMap,ft=new WeakMap,B=new WeakMap,St=new WeakMap,bt=new WeakMap,q=new WeakMap,F=new WeakMap,J=new WeakMap,T=new WeakMap,H=new WeakMap,y=new WeakMap,N=new WeakMap,W=new WeakMap,z=new WeakMap,C=new WeakMap,Y=new WeakMap,D=new WeakMap,X=new WeakMap,Q=new WeakMap,j=new WeakMap,V=new WeakMap,Z=new WeakMap,lt=new WeakMap,R=new WeakMap,vt=new WeakMap,l=new WeakSet,Lt=function(){let t=new Ft(e(this,P)),i=new Ft(e(this,P));u(this,j,t),u(this,Q,i);let s=this.ttlAutopurge?new Array(e(this,P)):void 0;u(this,V,s),u(this,At,(a,h,d=e(this,q).now())=>{i[a]=h!==0?d:0,t[a]=h,r(a,h);}),u(this,ut,a=>{i[a]=t[a]!==0?e(this,q).now():0,r(a,t[a]);});let r=this.ttlAutopurge?(a,h)=>{if(s?.[a]&&(clearTimeout(s[a]),s[a]=void 0),h&&h!==0&&s){let d=setTimeout(()=>{e(this,U).call(this,a)&&f(this,l,ht).call(this,e(this,H)[a],"expire");},h+1);d.unref&&d.unref(),s[a]=d;}}:()=>{};u(this,rt,(a,h)=>{if(t[h]){let d=t[h],g=i[h];if(!d||!g)return;a.ttl=d,a.start=g,a.now=o||n();let m=a.now-g;a.remainingTTL=d-m;}});let o=0,n=()=>{let a=e(this,q).now();if(this.ttlResolution>0){o=a;let h=setTimeout(()=>o=0,this.ttlResolution);h.unref&&h.unref();}return a};this.getRemainingTTL=a=>{let h=e(this,T).get(a);if(h===void 0)return 0;let d=t[h],g=i[h];if(!d||!g)return 1/0;let m=(o||n())-g;return d-m},u(this,U,a=>{let h=i[a],d=t[a];return !!d&&!!h&&(o||n())-h>d});},ut=new WeakMap,rt=new WeakMap,At=new WeakMap,U=new WeakMap,Jt=function(){let t=new Ft(e(this,P));u(this,J,0),u(this,X,t),u(this,pt,i=>{u(this,J,e(this,J)-t[i]),t[i]=0;}),u(this,Et,(i,s,r,o)=>{if(f(this,l,x).call(this,s))return 0;if(!ot(r))if(o){if(typeof o!="function")throw new TypeError("sizeCalculation must be a function");if(r=o(s,i),!ot(r))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 r}),u(this,wt,(i,s,r)=>{if(t[i]=s,e(this,k)){let o=e(this,k)-t[i];for(;e(this,J)>o;)f(this,l,Ct).call(this,true);}u(this,J,e(this,J)+t[i]),r&&(r.entrySize=s,r.totalCalculatedSize=e(this,J));});},pt=new WeakMap,wt=new WeakMap,Et=new WeakMap,nt=function*({allowStale:t=this.allowStale}={}){if(e(this,F))for(let i=e(this,C);!(!f(this,l,Mt).call(this,i)||((t||!e(this,U).call(this,i))&&(yield i),i===e(this,z)));)i=e(this,W)[i];},at=function*({allowStale:t=this.allowStale}={}){if(e(this,F))for(let i=e(this,z);!(!f(this,l,Mt).call(this,i)||((t||!e(this,U).call(this,i))&&(yield i),i===e(this,C)));)i=e(this,N)[i];},Mt=function(t){return t!==void 0&&e(this,T).get(e(this,H)[t])===t},Ct=function(t){var o;let i=e(this,z),s=e(this,H)[i],r=e(this,y)[i];return e(this,lt)&&f(this,l,x).call(this,r)?r.__abortController.abort(new Error("evicted")):(e(this,Z)||e(this,R))&&(e(this,Z)&&((o=e(this,$))==null||o.call(this,r,s,"evict")),e(this,R)&&e(this,D)?.push([r,s,"evict"])),e(this,pt).call(this,i),e(this,V)?.[i]&&(clearTimeout(e(this,V)[i]),e(this,V)[i]=void 0),t&&(e(this,H)[i]=void 0,e(this,y)[i]=void 0,e(this,Y).push(i)),e(this,F)===1?(u(this,z,u(this,C,0)),e(this,Y).length=0):u(this,z,e(this,N)[i]),e(this,T).delete(s),Tt(this,F)._--,i},Dt=function(t,i,s,r){let o=i===void 0?void 0:e(this,y)[i];if(f(this,l,x).call(this,o))return o;let n=new zt,{signal:a}=s;a?.addEventListener("abort",()=>n.abort(a.reason),{signal:n.signal});let h={signal:n.signal,options:s,context:r},d=(A,_=false)=>{let{aborted:S}=n.signal,I=s.ignoreFetchAbort&&A!==void 0,L=s.ignoreFetchAbort||!!(s.allowStaleOnFetchAbort&&A!==void 0);if(s.status&&(S&&!_?(s.status.fetchAborted=true,s.status.fetchError=n.signal.reason,I&&(s.status.fetchAbortIgnored=true)):s.status.fetchResolved=true),S&&!I&&!_)return m(n.signal.reason,L);let G=K,E=e(this,y)[i];return (E===K||I&&_&&E===void 0)&&(A===void 0?G.__staleWhileFetching!==void 0?e(this,y)[i]=G.__staleWhileFetching:f(this,l,ht).call(this,t,"fetch"):(s.status&&(s.status.fetchUpdated=true),this.set(t,A,h.options))),A},g=A=>(s.status&&(s.status.fetchRejected=true,s.status.fetchError=A),m(A,false)),m=(A,_)=>{let{aborted:S}=n.signal,I=S&&s.allowStaleOnFetchAbort,L=I||s.allowStaleOnFetchRejection,G=L||s.noDeleteOnFetchRejection,E=K;if(e(this,y)[i]===K&&(!G||!_&&E.__staleWhileFetching===void 0?f(this,l,ht).call(this,t,"fetch"):I||(e(this,y)[i]=E.__staleWhileFetching)),L)return s.status&&E.__staleWhileFetching!==void 0&&(s.status.returnedStale=true),E.__staleWhileFetching;if(E.__returned===E)throw A},w=(A,_)=>{var I;let S=(I=e(this,St))==null?void 0:I.call(this,t,o,h);S&&S instanceof Promise&&S.then(L=>A(L===void 0?void 0:L),_),n.signal.addEventListener("abort",()=>{(!s.ignoreFetchAbort||s.allowStaleOnFetchAbort)&&(A(void 0),s.allowStaleOnFetchAbort&&(A=L=>d(L,true)));});};s.status&&(s.status.fetchDispatched=true);let K=new Promise(w).then(d,g),tt=Object.assign(K,{__abortController:n,__staleWhileFetching:o,__returned:void 0});return i===void 0?(this.set(t,tt,{...h.options,status:void 0}),i=e(this,T).get(t)):e(this,y)[i]=tt,tt},x=function(t){if(!e(this,lt))return false;let i=t;return !!i&&i instanceof Promise&&i.hasOwnProperty("__staleWhileFetching")&&i.__abortController instanceof zt},kt=function(t,i){e(this,W)[i]=t,e(this,N)[t]=i;},Ht=function(t){t!==e(this,C)&&(t===e(this,z)?u(this,z,e(this,N)[t]):f(this,l,kt).call(this,e(this,W)[t],e(this,N)[t]),f(this,l,kt).call(this,e(this,C),t),u(this,C,t));},ht=function(t,i){var r,o;let s=false;if(e(this,F)!==0){let n=e(this,T).get(t);if(n!==void 0)if(e(this,V)?.[n]&&(clearTimeout(e(this,V)?.[n]),e(this,V)[n]=void 0),s=true,e(this,F)===1)f(this,l,Wt).call(this,i);else {e(this,pt).call(this,n);let a=e(this,y)[n];if(f(this,l,x).call(this,a)?a.__abortController.abort(new Error("deleted")):(e(this,Z)||e(this,R))&&(e(this,Z)&&((r=e(this,$))==null||r.call(this,a,t,i)),e(this,R)&&e(this,D)?.push([a,t,i])),e(this,T).delete(t),e(this,H)[n]=void 0,e(this,y)[n]=void 0,n===e(this,C))u(this,C,e(this,W)[n]);else if(n===e(this,z))u(this,z,e(this,N)[n]);else {let h=e(this,W)[n];e(this,N)[h]=e(this,N)[n];let d=e(this,N)[n];e(this,W)[d]=e(this,W)[n];}Tt(this,F)._--,e(this,Y).push(n);}}if(e(this,R)&&e(this,D)?.length){let n=e(this,D),a;for(;a=n?.shift();)(o=e(this,B))==null||o.call(this,...a);}return s},Wt=function(t){var i,s;for(let r of f(this,l,at).call(this,{allowStale:true})){let o=e(this,y)[r];if(f(this,l,x).call(this,o))o.__abortController.abort(new Error("deleted"));else {let n=e(this,H)[r];e(this,Z)&&((i=e(this,$))==null||i.call(this,o,n,t)),e(this,R)&&e(this,D)?.push([o,n,t]);}}if(e(this,T).clear(),e(this,y).fill(void 0),e(this,H).fill(void 0),e(this,j)&&e(this,Q)){e(this,j).fill(0),e(this,Q).fill(0);for(let r of e(this,V)??[])r!==void 0&&clearTimeout(r);e(this,V)?.fill(void 0);}if(e(this,X)&&e(this,X).fill(0),u(this,z,0),u(this,C,0),e(this,Y).length=0,u(this,J,0),u(this,F,0),e(this,R)&&e(this,D)){let r=e(this,D),o;for(;o=r?.shift();)(s=e(this,B))==null||s.call(this,...o);}},_t);var ct=class{constructor(t){v(this,"cache");v(this,"map",new Map);this.cache=new qt({max:t.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(t){let i=this.map.delete(t);return i&&this.cache.delete(t),i}get forEach(){return this.map.forEach}get(t){let i=this.cache.get(t);return i||this.map.get(t)}has(t){return this.map.has(t)}set(t,i){return this.map.set(t,i),this.cache.set(t,i),this}get size(){return this.map.size}entries(){return this.map.entries()}keys(){return this.map.keys()}values(){return this.map.values()}};var O;(r=>(r.log=(o,...n)=>console.log(`[Pixi\u2019VN] ${o}`,...n),r.warn=(o,...n)=>console.warn(`[Pixi\u2019VN] ${o}`,...n),r.error=(o,...n)=>console.error(`[Pixi\u2019VN] ${o}`,...n),r.info=(o,...n)=>console.info(`[Pixi\u2019VN] ${o}`,...n)))(O||(O={}));function it(c){try{if(typeof c>"u")return c;let t=JSON.stringify(c);return JSON.parse(t)}catch(t){throw O.error("Error creating exportable element",c,t),new core.PixiError("not_json_serializable","Error creating exportable element")}}var st=class st{static get originalStepData(){return st._originalStepData?it(st._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(t){st._originalStepData=it(t);}};v(st,"_diffHistory",new ct({cacheSize:5})),v(st,"_stepsInfoHistory",new ct({cacheSize:5})),v(st,"_narrationHistory",new ct({cacheSize:50})),v(st,"stepLimitSaved",20),v(st,"_originalStepData");var p=st;function Yt(c,t){let i=it(c);return t.length>1&&"type"in t[0]&&(t=t.slice().reverse()),t.forEach(s=>{se(i,s);}),i}function se(c,t){let i=c;t.path&&t.path.length>0?t.path.forEach((s,r)=>{if(t.path&&r===t.path.length-1)switch(t.type){case "CHANGE":case "REMOVE":i[s]=t.oldValue;break;case "CREATE":Array.isArray(i)&&typeof s=="number"?i.splice(s,1):delete i[s];break}else i=i[s];}):O.warn("No path found, skipping diff",t);}var re={Date:true,RegExp:true,String:true,Number:true};function It(c,t,i={cyclesFix:true},s=[]){let r=[],o=Array.isArray(c);for(let a in c){let h=c[a],d=o?+a:a;if(!(a in t)){r.push({type:"REMOVE",path:[d],oldValue:c[a]});continue}let g=t[a],m=typeof h=="object"&&typeof g=="object"&&Array.isArray(h)===Array.isArray(g);h&&g&&m&&!re[Object.getPrototypeOf(h)?.constructor?.name]&&(!i.cyclesFix||!s.includes(h))?r.push.apply(r,It(h,g,i,i.cyclesFix?s.concat([h]):[]).map(w=>(w.path.unshift(d),w))):h!==g&&!(Number.isNaN(h)&&Number.isNaN(g))&&!(m&&(isNaN(h)?h+""==g+"":+h==+g))&&r.push({path:[d],type:"CHANGE",value:g,oldValue:h});}let n=Array.isArray(t);for(let a in t)a in c||r.push({type:"CREATE",path:[n?+a:a],value:t[a]});return r}var Ot=class{get stepsInfoMap(){return p._stepsInfoHistory}get diffMap(){return p._diffHistory}get narrationMap(){return p._narrationHistory}get size(){return p._stepsInfoHistory.size}get lastKey(){return this.size===0?null:Math.max(...Array.from(this.keys()))}keys(){return p._stepsInfoHistory.keys()}get(t){let i=p._narrationHistory.get(t);if(!(i&&Object.keys(i).length===1&&i.stepIndex!==void 0))return i}delete(t){p._stepsInfoHistory.delete(t),p._diffHistory.delete(t),p._narrationHistory.delete(t);}getOldGameState(t,i){if(t<=0||this.size===0)return i;let s=this.lastKey;if(typeof s!="number")return O.warn("You can't go back, there is no step to go back"),i;let r=p._diffHistory.get(s);if(r)try{let o=Yt(i,r);return core.GameUnifier.stepCounter=s,this.delete(s),this.getOldGameState(t-1,o)}catch(o){return O.error("Error applying diff",o),i}else return O.warn("No diff found for the last step, cannot go back"),i}async back(t,i={}){let{steps:s=1}=i;if(!Number.isFinite(s)){O.warn(`[back] The parameter steps must be a valid finite number, received: ${s}`);return}if(s<=0){O.warn(`[back] The parameter steps must be greater than 0, received: ${s}`);return}if(core.GameUnifier.runningStepsCount>0){core.GameUnifier.increaseBackRequest(s);return}if(p._diffHistory.size<1){O.warn("You can't go back, there is no step to go back");return}core.GameUnifier.runningStepsCount++;try{let r=it(this.getOldGameState(s,p.originalStepData));if(r){await core.GameUnifier.restoreGameStepState(r,core.GameUnifier.navigate);let o=core.GameUnifier.stepCounter-1,n=p._narrationHistory.get(o);if(n&&Object.keys(n).length===1&&n.stepIndex!==void 0){let a=p._stepsInfoHistory.get(o);if(a){let h=this.itemMapper({step:a});p._narrationHistory.set(a.index,h);}}}else O.error("Error going back");p.originalStepData=r;}catch(r){O.error("Error going back",r);}if(core.GameUnifier.runningStepsCount--,core.GameUnifier.runningStepsCount===0&&core.GameUnifier.backRequestsCount!==0)return await core.GameUnifier.processNavigationRequests(t)}add(t,i={}){let s=p.originalStepData,{ignoreSameStep:r}=i,o=core.GameUnifier.currentGameStepState;if(!r&&this.isSameStep(s,o))return;let n=this.lastKey;(async()=>{try{let h,d;if(typeof n=="number"&&(h=p._stepsInfoHistory.get(n),d=p._narrationHistory.get(n)),p._stepsInfoHistory.set(t.index,t),t.index!==0){let w=It(s,o);w?p._diffHistory.set(t.index,w):O.warn("It was not possible to create the difference between the two steps");}let g={},m=this.itemMapper({step:t},g);if(p._narrationHistory.set(t.index,m),h&&d&&typeof n=="number"){let w=this.itemMapper({...g,step:h},{});p._narrationHistory.set(n,w);}}catch(h){O.error("Error adding history step",h);}})(),p.originalStepData=o;}itemMapper(t,i){let{step:s,choiceIndexMade:r,inputValue:o,removeDialogue:n}=t,a=s.dialogue;i&&s.isGlued&&(i.removeDialogue=true),n&&(a=void 0);let h=s.choices;if(i&&s.currentLabel&&s.choiceIndexMade!==void 0&&(i.choiceIndexMade=s.choiceIndexMade),s.inputValue&&i&&(i.inputValue=s.inputValue),a||h||o){let d=h?.map((g,m)=>{let w=false;return g.oneTime&&s.alreadyMadeChoices?.includes(m)&&(w=true),{text:g.text,type:g.type,isResponse:false,hidden:w}});if(d){if(d.every(g=>g.hidden)){let g=d.find(m=>m.hidden===false);g&&(g.hidden=false);}r!==void 0&&(d[r].isResponse=true);}return {dialogue:a?{...a,character:a.character?core.GameUnifier.getCharacter(a.character)||a.character:void 0}:void 0,playerMadeChoice:typeof r=="number",choices:d,stepIndex:s.index,inputValue:o}}return {stepIndex:s.index}}get narrativeHistory(){let t=[];return Array.from(this.keys()).sort((s,r)=>s-r).forEach(s=>{let r=this.get(s);r&&t.push(r);}),t}get currentLabelHistory(){let t=[],i=Array.from(this.keys()).sort((h,d)=>d-h);if(i.length===0)return t;let s=i[0];if(typeof s!="number")return t;let r=p._stepsInfoHistory.get(s);if(!r)return t;let o=r.openedLabels;if(!o||!Array.isArray(o)||o.length===0)return t;let n=o[0].currentStepIndex,a=o[0].label;return i.every((h,d)=>{let g=this.get(h);if(g){if(d===0)return t.push(g),true;let m=p._stepsInfoHistory.get(h);if(!m)return true;let w=m.openedLabels;if(!w||!Array.isArray(w)||w.length===0||w[0].label!==a||w[0].currentStepIndex>=n)return false;n=w[0].currentStepIndex,t.push(g);}return true}),t.reverse()}removeNarrativeHistory(t){if(t){let i=Array.from(this.keys()).sort((s,r)=>s-r);i=i.slice(0,t),i.forEach(s=>{p._narrationHistory.delete(s),p._stepsInfoHistory.delete(s),p._diffHistory.delete(s);});}else p._stepsInfoHistory.clear(),p._diffHistory.clear(),p._narrationHistory.clear();}get canGoBack(){let t=this.lastKey;return typeof t!="number"?false:p._diffHistory.has(t)}blockGoBack(){core.GameUnifier.runningStepsCount===0&&p._diffHistory.clear();}isSameStep(t,i){if(t.openedLabels.length===i.openedLabels.length)try{let s=JSON.stringify(t.openedLabels),r=JSON.stringify(i.openedLabels);if(s===r&&t.path===i.path&&t.labelIndex===i.labelIndex)return !0}catch(s){return O.error("Error comparing opened labels",s),true}return false}clear(){p._stepsInfoHistory.clear(),p._diffHistory.clear(),p._narrationHistory.clear(),p._originalStepData=void 0;}get stepLimitSaved(){return p.stepLimitSaved}set stepLimitSaved(t){p.stepLimitSaved=t;}export(){let t=Array.from(this.keys()).sort((s,r)=>s-r);t.length>this.stepLimitSaved&&(t=t.slice(t.length-this.stepLimitSaved));let i=[];return t.forEach(s=>{let r=p._stepsInfoHistory.get(s);if(r){let o=p._diffHistory.get(s);i.push({...r,diff:o});}}),{stepsHistory:it(i),originalStepData:it(p._originalStepData)}}restoreNarrativeHistory(){let t=Array.from(this.keys()).sort((s,r)=>s-r),i={};t.forEach(s=>{let r=p._stepsInfoHistory.get(s);if(r){let o={...i};i={};let n=this.itemMapper({step:r,choiceIndexMade:o.choiceIndexMade,inputValue:o.inputValue,removeDialogue:o.removeDialogue},i);n&&p._narrationHistory.set(s,n);}});}async restore(t){this.clear();try{Object.hasOwn(t,"stepsHistory")?(t.stepsHistory.forEach(s=>{s.diff&&p._diffHistory.set(s.index,s.diff);let r={...s,diff:void 0};p._stepsInfoHistory.set(s.index,r);}),this.restoreNarrativeHistory()):O.warn("Could not import stepsHistory data, so will be ignored"),Object.hasOwn(t,"originalStepData")?p._originalStepData=t.originalStepData:O.warn("Could not import originalStepData data, so will be ignored");}catch(i){O.error("Error importing data",i);}}};var Me=new Ot;exports.HistoryManagerStatic=p;exports.stepHistory=Me;
|
package/dist/history.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import'./chunk-
|
|
1
|
+
import'./chunk-JMOSOAGB.mjs';import {a}from'./chunk-YDNEIPJP.mjs';import {d,k,j}from'./chunk-HNGW4ITF.mjs';import {GameUnifier}from'@drincs/pixi-vn/core';var h=class h{static get originalStepData(){return h._originalStepData?k(h._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){h._originalStepData=k(e);}};d(h,"_diffHistory",new a({cacheSize:5})),d(h,"_stepsInfoHistory",new a({cacheSize:5})),d(h,"_narrationHistory",new a({cacheSize:50})),d(h,"stepLimitSaved",20),d(h,"_originalStepData");var i=h;function I(m,e){let r=k(m);return e.length>1&&"type"in e[0]&&(e=e.slice().reverse()),e.forEach(t=>{v(r,t);}),r}function v(m,e){let r=m;e.path&&e.path.length>0?e.path.forEach((t,a)=>{if(e.path&&a===e.path.length-1)switch(e.type){case "CHANGE":case "REMOVE":r[t]=e.oldValue;break;case "CREATE":Array.isArray(r)&&typeof t=="number"?r.splice(t,1):delete r[t];break}else r=r[t];}):j.warn("No path found, skipping diff",e);}var _={Date:true,RegExp:true,String:true,Number:true};function x(m,e,r={cyclesFix:true},t=[]){let a=[],s=Array.isArray(m);for(let o in m){let n=m[o],u=s?+o:o;if(!(o in e)){a.push({type:"REMOVE",path:[u],oldValue:m[o]});continue}let p=e[o],d=typeof n=="object"&&typeof p=="object"&&Array.isArray(n)===Array.isArray(p);n&&p&&d&&!_[Object.getPrototypeOf(n)?.constructor?.name]&&(!r.cyclesFix||!t.includes(n))?a.push.apply(a,x(n,p,r,r.cyclesFix?t.concat([n]):[]).map(f=>(f.path.unshift(u),f))):n!==p&&!(Number.isNaN(n)&&Number.isNaN(p))&&!(d&&(isNaN(n)?n+""==p+"":+n==+p))&&a.push({path:[u],type:"CHANGE",value:p,oldValue:n});}let c=Array.isArray(e);for(let o in e)o in m||a.push({type:"CREATE",path:[c?+o:o],value:e[o]});return a}var b=class{get stepsInfoMap(){return i._stepsInfoHistory}get diffMap(){return i._diffHistory}get narrationMap(){return i._narrationHistory}get size(){return i._stepsInfoHistory.size}get lastKey(){return this.size===0?null:Math.max(...Array.from(this.keys()))}keys(){return i._stepsInfoHistory.keys()}get(e){let r=i._narrationHistory.get(e);if(!(r&&Object.keys(r).length===1&&r.stepIndex!==void 0))return r}delete(e){i._stepsInfoHistory.delete(e),i._diffHistory.delete(e),i._narrationHistory.delete(e);}getOldGameState(e,r){if(e<=0||this.size===0)return r;let t=this.lastKey;if(typeof t!="number")return j.warn("You can't go back, there is no step to go back"),r;let a=i._diffHistory.get(t);if(a)try{let s=I(r,a);return GameUnifier.stepCounter=t,this.delete(t),this.getOldGameState(e-1,s)}catch(s){return j.error("Error applying diff",s),r}else return j.warn("No diff found for the last step, cannot go back"),r}async back(e,r={}){let{steps:t=1}=r;if(!Number.isFinite(t)){j.warn(`[back] The parameter steps must be a valid finite number, received: ${t}`);return}if(t<=0){j.warn(`[back] The parameter steps must be greater than 0, received: ${t}`);return}if(GameUnifier.runningStepsCount>0){GameUnifier.increaseBackRequest(t);return}if(i._diffHistory.size<1){j.warn("You can't go back, there is no step to go back");return}GameUnifier.runningStepsCount++;try{let a=k(this.getOldGameState(t,i.originalStepData));if(a){await GameUnifier.restoreGameStepState(a,GameUnifier.navigate);let s=GameUnifier.stepCounter-1,c=i._narrationHistory.get(s);if(c&&Object.keys(c).length===1&&c.stepIndex!==void 0){let o=i._stepsInfoHistory.get(s);if(o){let n=this.itemMapper({step:o});i._narrationHistory.set(o.index,n);}}}else j.error("Error going back");i.originalStepData=a;}catch(a){j.error("Error going back",a);}if(GameUnifier.runningStepsCount--,GameUnifier.runningStepsCount===0&&GameUnifier.backRequestsCount!==0)return await GameUnifier.processNavigationRequests(e)}add(e,r={}){let t=i.originalStepData,{ignoreSameStep:a}=r,s=GameUnifier.currentGameStepState;if(!a&&this.isSameStep(t,s))return;let c=this.lastKey;(async()=>{try{let n,u;if(typeof c=="number"&&(n=i._stepsInfoHistory.get(c),u=i._narrationHistory.get(c)),i._stepsInfoHistory.set(e.index,e),e.index!==0){let f=x(t,s);f?i._diffHistory.set(e.index,f):j.warn("It was not possible to create the difference between the two steps");}let p={},d=this.itemMapper({step:e},p);if(i._narrationHistory.set(e.index,d),n&&u&&typeof c=="number"){let f=this.itemMapper({...p,step:n},{});i._narrationHistory.set(c,f);}}catch(n){j.error("Error adding history step",n);}})(),i.originalStepData=s;}itemMapper(e,r){let{step:t,choiceIndexMade:a,inputValue:s,removeDialogue:c}=e,o=t.dialogue;r&&t.isGlued&&(r.removeDialogue=true),c&&(o=void 0);let n=t.choices;if(r&&t.currentLabel&&t.choiceIndexMade!==void 0&&(r.choiceIndexMade=t.choiceIndexMade),t.inputValue&&r&&(r.inputValue=t.inputValue),o||n||s){let u=n?.map((p,d)=>{let f=false;return p.oneTime&&t.alreadyMadeChoices?.includes(d)&&(f=true),{text:p.text,type:p.type,isResponse:false,hidden:f}});if(u){if(u.every(p=>p.hidden)){let p=u.find(d=>d.hidden===false);p&&(p.hidden=false);}a!==void 0&&(u[a].isResponse=true);}return {dialogue:o?{...o,character:o.character?GameUnifier.getCharacter(o.character)||o.character:void 0}:void 0,playerMadeChoice:typeof a=="number",choices:u,stepIndex:t.index,inputValue:s}}return {stepIndex:t.index}}get narrativeHistory(){let e=[];return Array.from(this.keys()).sort((t,a)=>t-a).forEach(t=>{let a=this.get(t);a&&e.push(a);}),e}get currentLabelHistory(){let e=[],r=Array.from(this.keys()).sort((n,u)=>u-n);if(r.length===0)return e;let t=r[0];if(typeof t!="number")return e;let a=i._stepsInfoHistory.get(t);if(!a)return e;let s=a.openedLabels;if(!s||!Array.isArray(s)||s.length===0)return e;let c=s[0].currentStepIndex,o=s[0].label;return r.every((n,u)=>{let p=this.get(n);if(p){if(u===0)return e.push(p),true;let d=i._stepsInfoHistory.get(n);if(!d)return true;let f=d.openedLabels;if(!f||!Array.isArray(f)||f.length===0||f[0].label!==o||f[0].currentStepIndex>=c)return false;c=f[0].currentStepIndex,e.push(p);}return true}),e.reverse()}removeNarrativeHistory(e){if(e){let r=Array.from(this.keys()).sort((t,a)=>t-a);r=r.slice(0,e),r.forEach(t=>{i._narrationHistory.delete(t),i._stepsInfoHistory.delete(t),i._diffHistory.delete(t);});}else i._stepsInfoHistory.clear(),i._diffHistory.clear(),i._narrationHistory.clear();}get canGoBack(){let e=this.lastKey;return typeof e!="number"?false:i._diffHistory.has(e)}blockGoBack(){GameUnifier.runningStepsCount===0&&i._diffHistory.clear();}isSameStep(e,r){if(e.openedLabels.length===r.openedLabels.length)try{let t=JSON.stringify(e.openedLabels),a=JSON.stringify(r.openedLabels);if(t===a&&e.path===r.path&&e.labelIndex===r.labelIndex)return !0}catch(t){return j.error("Error comparing opened labels",t),true}return false}clear(){i._stepsInfoHistory.clear(),i._diffHistory.clear(),i._narrationHistory.clear(),i._originalStepData=void 0;}get stepLimitSaved(){return i.stepLimitSaved}set stepLimitSaved(e){i.stepLimitSaved=e;}export(){let e=Array.from(this.keys()).sort((t,a)=>t-a);e.length>this.stepLimitSaved&&(e=e.slice(e.length-this.stepLimitSaved));let r=[];return e.forEach(t=>{let a=i._stepsInfoHistory.get(t);if(a){let s=i._diffHistory.get(t);r.push({...a,diff:s});}}),{stepsHistory:k(r),originalStepData:k(i._originalStepData)}}restoreNarrativeHistory(){let e=Array.from(this.keys()).sort((t,a)=>t-a),r={};e.forEach(t=>{let a=i._stepsInfoHistory.get(t);if(a){let s={...r};r={};let c=this.itemMapper({step:a,choiceIndexMade:s.choiceIndexMade,inputValue:s.inputValue,removeDialogue:s.removeDialogue},r);c&&i._narrationHistory.set(t,c);}});}async restore(e){this.clear();try{Object.hasOwn(e,"stepsHistory")?(e.stepsHistory.forEach(t=>{t.diff&&i._diffHistory.set(t.index,t.diff);let a={...t,diff:void 0};i._stepsInfoHistory.set(t.index,a);}),this.restoreNarrativeHistory()):j.warn("Could not import stepsHistory data, so will be ignored"),Object.hasOwn(e,"originalStepData")?i._originalStepData=e.originalStepData:j.warn("Could not import originalStepData data, so will be ignored");}catch(r){j.error("Error importing data",r);}}};var P=new b;export{i as HistoryManagerStatic,P as stepHistory};
|