@drincs/pixi-vn 1.4.2 → 1.4.4
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/dist/canvas.cjs +2 -2
- package/dist/canvas.mjs +1 -1
- package/dist/characters.cjs +1 -1
- package/dist/characters.mjs +1 -1
- package/dist/chunk-GFG3MDHE.mjs +1 -0
- package/dist/{chunk-IKZP57DP.mjs → chunk-TIA4D2N7.mjs} +1 -1
- package/dist/history.cjs +1 -1
- package/dist/history.d.cts +1 -1
- package/dist/history.d.ts +1 -1
- package/dist/history.mjs +1 -1
- package/dist/index.cjs +2 -2
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.mjs +2 -2
- package/dist/narration.cjs +1 -1
- package/dist/narration.mjs +1 -1
- package/dist/pixi.d.ts +3 -0
- package/dist/{pixi.js.mjs → pixi.js} +143 -143
- package/dist/storage.cjs +1 -1
- package/dist/storage.mjs +1 -1
- package/package.json +6 -6
- package/dist/chunk-YDXQLPAR.mjs +0 -1
- package/dist/pixi.js.cjs +0 -3395
- package/dist/pixi.js.d.cts +0 -1
- package/dist/pixi.js.d.ts +0 -1
package/dist/characters.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
'use strict';require('@drincs/pixi-vn/unifier');var ee=Object.defineProperty;var Bt=l=>{throw TypeError(l)};var ie=(l,t,e)=>t in l?ee(l,t,{enumerable:true,configurable:true,writable:true,value:e}):l[t]=e;var d=(l,t,e)=>ie(l,typeof t!="symbol"?t+"":t,e),Nt=(l,t,e)=>t.has(l)||Bt("Cannot "+e);var i=(l,t,e)=>(Nt(l,t,"read from private field"),e?e.call(l):t.get(l)),_=(l,t,e)=>t.has(l)?Bt("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(l):t.set(l,e),c=(l,t,e,s)=>(Nt(l,t,"write to private field"),t.set(l,e),e),h=(l,t,e)=>(Nt(l,t,"access private method"),e);var Ft=(l,t,e,s)=>({set _(r){c(l,t,r);},get _(){return i(l,t,s)}});var j;(r=>(r.log=(a,...n)=>console.log(`[Pixi\u2019VN] ${a}`,...n),r.warn=(a,...n)=>console.warn(`[Pixi\u2019VN] ${a}`,...n),r.error=(a,...n)=>console.error(`[Pixi\u2019VN] ${a}`,...n),r.info=(a,...n)=>console.info(`[Pixi\u2019VN] ${a}`,...n)))(j||(j={}));function It(l){try{if(typeof l>"u")return l;let t=JSON.stringify(l);return JSON.parse(t)}catch(t){throw j.error("Error creating exportable element",l,t),new Error("[Pixi\u2019VN] Error creating exportable element")}}var se=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,Qt=new Set,Gt=typeof process=="object"&&process?process:{},Zt=(l,t,e,s)=>{typeof Gt.emitWarning=="function"?Gt.emitWarning(l,t,e,s):console.error(`[${e}] ${t}: ${l}`);},Mt=globalThis.AbortController,Xt=globalThis.AbortSignal;if(typeof Mt>"u"){Xt=class{constructor(){d(this,"onabort");d(this,"_onabort",[]);d(this,"reason");d(this,"aborted",false);}addEventListener(s,r){this._onabort.push(r);}},Mt=class{constructor(){d(this,"signal",new Xt);t();}abort(s){if(!this.signal.aborted){this.signal.reason=s,this.signal.aborted=true;for(let r of this.signal._onabort)r(s);this.signal.onabort?.(s);}}};let l=Gt.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",t=()=>{l&&(l=false,Zt("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 re=l=>!Qt.has(l);var st=l=>l&&l===Math.floor(l)&&l>0&&isFinite(l),kt=l=>st(l)?l<=Math.pow(2,8)?Uint8Array:l<=Math.pow(2,16)?Uint16Array:l<=Math.pow(2,32)?Uint32Array:l<=Number.MAX_SAFE_INTEGER?pt:null:null,pt=class extends Array{constructor(t){super(t),this.fill(0);}},mt,ht=class ht{constructor(t,e){d(this,"heap");d(this,"length");if(!i(ht,mt))throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new e(t),this.length=0;}static create(t){let e=kt(t);if(!e)return [];c(ht,mt,true);let s=new ht(t,e);return c(ht,mt,false),s}push(t){this.heap[this.length++]=t;}pop(){return this.heap[--this.length]}};mt=new WeakMap,_(ht,mt,false);var Ut=ht,qt,Jt,K,L,H,lt,$,_t,St,B,v,X,R,b,g,D,N,F,C,q,x,J,Q,G,U,Z,ot,z,Et,o,Vt,ft,tt,Rt,V,te,ct,yt,vt,rt,nt,Wt,Dt,zt,y,Yt,Ot,at,Kt,jt=class jt{constructor(t){_(this,o);_(this,K);_(this,L);_(this,H);_(this,lt);_(this,$);_(this,_t);_(this,St);_(this,B);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");_(this,v);_(this,X);_(this,R);_(this,b);_(this,g);_(this,D);_(this,N);_(this,F);_(this,C);_(this,q);_(this,x);_(this,J);_(this,Q);_(this,G);_(this,U);_(this,Z);_(this,ot);_(this,z);_(this,Et);_(this,ft,()=>{});_(this,tt,()=>{});_(this,Rt,()=>{});_(this,V,()=>false);_(this,ct,t=>{});_(this,yt,(t,e,s)=>{});_(this,vt,(t,e,s,r)=>{if(s||r)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0});d(this,qt,"LRUCache");let{max:e=0,ttl:s,ttlResolution:r=1,ttlAutopurge:a,updateAgeOnGet:n,updateAgeOnHas:f,allowStale:u,dispose:S,onInsert:M,disposeAfter:T,noDisposeOnSet:it,noUpdateTTL:W,maxSize:k=0,maxEntrySize:w=0,sizeCalculation:E,fetchMethod:m,memoMethod:I,noDeleteOnFetchRejection:P,noDeleteOnStaleGet:O,allowStaleOnFetchRejection:Y,allowStaleOnFetchAbort:At,ignoreFetchAbort:ut,perf:xt}=t;if(xt!==void 0&&typeof xt?.now!="function")throw new TypeError("perf option must have a now() method if specified");if(c(this,B,xt??se),e!==0&&!st(e))throw new TypeError("max option must be a nonnegative integer");let dt=e?kt(e):Array;if(!dt)throw new Error("invalid max value: "+e);if(c(this,K,e),c(this,L,k),this.maxEntrySize=w||i(this,L),this.sizeCalculation=E,this.sizeCalculation){if(!i(this,L)&&!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,St,I),m!==void 0&&typeof m!="function")throw new TypeError("fetchMethod must be a function if specified");if(c(this,_t,m),c(this,ot,!!m),c(this,R,new Map),c(this,b,new Array(e).fill(void 0)),c(this,g,new Array(e).fill(void 0)),c(this,D,new dt(e)),c(this,N,new dt(e)),c(this,F,0),c(this,C,0),c(this,q,Ut.create(e)),c(this,v,0),c(this,X,0),typeof S=="function"&&c(this,H,S),typeof M=="function"&&c(this,lt,M),typeof T=="function"?(c(this,$,T),c(this,x,[])):(c(this,$,void 0),c(this,x,void 0)),c(this,Z,!!i(this,H)),c(this,Et,!!i(this,lt)),c(this,z,!!i(this,$)),this.noDisposeOnSet=!!it,this.noUpdateTTL=!!W,this.noDeleteOnFetchRejection=!!P,this.allowStaleOnFetchRejection=!!Y,this.allowStaleOnFetchAbort=!!At,this.ignoreFetchAbort=!!ut,this.maxEntrySize!==0){if(i(this,L)!==0&&!st(i(this,L)))throw new TypeError("maxSize must be a positive integer if specified");if(!st(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");h(this,o,te).call(this);}if(this.allowStale=!!u,this.noDeleteOnStaleGet=!!O,this.updateAgeOnGet=!!n,this.updateAgeOnHas=!!f,this.ttlResolution=st(r)||r===0?r:1,this.ttlAutopurge=!!a,this.ttl=s||0,this.ttl){if(!st(this.ttl))throw new TypeError("ttl must be a positive integer if specified");h(this,o,Vt).call(this);}if(i(this,K)===0&&this.ttl===0&&i(this,L)===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!i(this,K)&&!i(this,L)){let gt="LRU_CACHE_UNBOUNDED";re(gt)&&(Qt.add(gt),Zt("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",gt,jt));}}get perf(){return i(this,B)}static unsafeExposeInternals(t){return {starts:i(t,Q),ttls:i(t,G),autopurgeTimers:i(t,U),sizes:i(t,J),keyMap:i(t,R),keyList:i(t,b),valList:i(t,g),next:i(t,D),prev:i(t,N),get head(){return i(t,F)},get tail(){return i(t,C)},free:i(t,q),isBackgroundFetch:e=>{var s;return h(s=t,o,y).call(s,e)},backgroundFetch:(e,s,r,a)=>{var n;return h(n=t,o,zt).call(n,e,s,r,a)},moveToTail:e=>{var s;return h(s=t,o,Ot).call(s,e)},indexes:e=>{var s;return h(s=t,o,rt).call(s,e)},rindexes:e=>{var s;return h(s=t,o,nt).call(s,e)},isStale:e=>{var s;return i(s=t,V).call(s,e)}}}get max(){return i(this,K)}get maxSize(){return i(this,L)}get calculatedSize(){return i(this,X)}get size(){return i(this,v)}get fetchMethod(){return i(this,_t)}get memoMethod(){return i(this,St)}get dispose(){return i(this,H)}get onInsert(){return i(this,lt)}get disposeAfter(){return i(this,$)}getRemainingTTL(t){return i(this,R).has(t)?1/0:0}*entries(){for(let t of h(this,o,rt).call(this))i(this,g)[t]!==void 0&&i(this,b)[t]!==void 0&&!h(this,o,y).call(this,i(this,g)[t])&&(yield [i(this,b)[t],i(this,g)[t]]);}*rentries(){for(let t of h(this,o,nt).call(this))i(this,g)[t]!==void 0&&i(this,b)[t]!==void 0&&!h(this,o,y).call(this,i(this,g)[t])&&(yield [i(this,b)[t],i(this,g)[t]]);}*keys(){for(let t of h(this,o,rt).call(this)){let e=i(this,b)[t];e!==void 0&&!h(this,o,y).call(this,i(this,g)[t])&&(yield e);}}*rkeys(){for(let t of h(this,o,nt).call(this)){let e=i(this,b)[t];e!==void 0&&!h(this,o,y).call(this,i(this,g)[t])&&(yield e);}}*values(){for(let t of h(this,o,rt).call(this))i(this,g)[t]!==void 0&&!h(this,o,y).call(this,i(this,g)[t])&&(yield i(this,g)[t]);}*rvalues(){for(let t of h(this,o,nt).call(this))i(this,g)[t]!==void 0&&!h(this,o,y).call(this,i(this,g)[t])&&(yield i(this,g)[t]);}[(Jt=Symbol.iterator,qt=Symbol.toStringTag,Jt)](){return this.entries()}find(t,e={}){for(let s of h(this,o,rt).call(this)){let r=i(this,g)[s],a=h(this,o,y).call(this,r)?r.__staleWhileFetching:r;if(a!==void 0&&t(a,i(this,b)[s],this))return this.get(i(this,b)[s],e)}}forEach(t,e=this){for(let s of h(this,o,rt).call(this)){let r=i(this,g)[s],a=h(this,o,y).call(this,r)?r.__staleWhileFetching:r;a!==void 0&&t.call(e,a,i(this,b)[s],this);}}rforEach(t,e=this){for(let s of h(this,o,nt).call(this)){let r=i(this,g)[s],a=h(this,o,y).call(this,r)?r.__staleWhileFetching:r;a!==void 0&&t.call(e,a,i(this,b)[s],this);}}purgeStale(){let t=false;for(let e of h(this,o,nt).call(this,{allowStale:true}))i(this,V).call(this,e)&&(h(this,o,at).call(this,i(this,b)[e],"expire"),t=true);return t}info(t){let e=i(this,R).get(t);if(e===void 0)return;let s=i(this,g)[e],r=h(this,o,y).call(this,s)?s.__staleWhileFetching:s;if(r===void 0)return;let a={value:r};if(i(this,G)&&i(this,Q)){let n=i(this,G)[e],f=i(this,Q)[e];if(n&&f){let u=n-(i(this,B).now()-f);a.ttl=u,a.start=Date.now();}}return i(this,J)&&(a.size=i(this,J)[e]),a}dump(){let t=[];for(let e of h(this,o,rt).call(this,{allowStale:true})){let s=i(this,b)[e],r=i(this,g)[e],a=h(this,o,y).call(this,r)?r.__staleWhileFetching:r;if(a===void 0||s===void 0)continue;let n={value:a};if(i(this,G)&&i(this,Q)){n.ttl=i(this,G)[e];let f=i(this,B).now()-i(this,Q)[e];n.start=Math.floor(Date.now()-f);}i(this,J)&&(n.size=i(this,J)[e]),t.unshift([s,n]);}return t}load(t){this.clear();for(let[e,s]of t){if(s.start){let r=Date.now()-s.start;s.start=i(this,B).now()-r;}this.set(e,s.value,s);}}set(t,e,s={}){var it,W,k,w;if(e===void 0)return this.delete(t),this;let{ttl:r=this.ttl,start:a,noDisposeOnSet:n=this.noDisposeOnSet,sizeCalculation:f=this.sizeCalculation,status:u}=s,{noUpdateTTL:S=this.noUpdateTTL}=s,M=i(this,vt).call(this,t,e,s.size||0,f);if(this.maxEntrySize&&M>this.maxEntrySize)return u&&(u.set="miss",u.maxEntrySizeExceeded=true),h(this,o,at).call(this,t,"set"),this;let T=i(this,v)===0?void 0:i(this,R).get(t);if(T===void 0)T=i(this,v)===0?i(this,C):i(this,q).length!==0?i(this,q).pop():i(this,v)===i(this,K)?h(this,o,Dt).call(this,false):i(this,v),i(this,b)[T]=t,i(this,g)[T]=e,i(this,R).set(t,T),i(this,D)[i(this,C)]=T,i(this,N)[T]=i(this,C),c(this,C,T),Ft(this,v)._++,i(this,yt).call(this,T,M,u),u&&(u.set="add"),S=false,i(this,Et)&&((it=i(this,lt))==null||it.call(this,e,t,"add"));else {h(this,o,Ot).call(this,T);let E=i(this,g)[T];if(e!==E){if(i(this,ot)&&h(this,o,y).call(this,E)){E.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:m}=E;m!==void 0&&!n&&(i(this,Z)&&((W=i(this,H))==null||W.call(this,m,t,"set")),i(this,z)&&i(this,x)?.push([m,t,"set"]));}else n||(i(this,Z)&&((k=i(this,H))==null||k.call(this,E,t,"set")),i(this,z)&&i(this,x)?.push([E,t,"set"]));if(i(this,ct).call(this,T),i(this,yt).call(this,T,M,u),i(this,g)[T]=e,u){u.set="replace";let m=E&&h(this,o,y).call(this,E)?E.__staleWhileFetching:E;m!==void 0&&(u.oldValue=m);}}else u&&(u.set="update");i(this,Et)&&this.onInsert?.(e,t,e===E?"update":"replace");}if(r!==0&&!i(this,G)&&h(this,o,Vt).call(this),i(this,G)&&(S||i(this,Rt).call(this,T,r,a),u&&i(this,tt).call(this,u,T)),!n&&i(this,z)&&i(this,x)){let E=i(this,x),m;for(;m=E?.shift();)(w=i(this,$))==null||w.call(this,...m);}return this}pop(){var t;try{for(;i(this,v);){let e=i(this,g)[i(this,F)];if(h(this,o,Dt).call(this,!0),h(this,o,y).call(this,e)){if(e.__staleWhileFetching)return e.__staleWhileFetching}else if(e!==void 0)return e}}finally{if(i(this,z)&&i(this,x)){let e=i(this,x),s;for(;s=e?.shift();)(t=i(this,$))==null||t.call(this,...s);}}}has(t,e={}){let{updateAgeOnHas:s=this.updateAgeOnHas,status:r}=e,a=i(this,R).get(t);if(a!==void 0){let n=i(this,g)[a];if(h(this,o,y).call(this,n)&&n.__staleWhileFetching===void 0)return false;if(i(this,V).call(this,a))r&&(r.has="stale",i(this,tt).call(this,r,a));else return s&&i(this,ft).call(this,a),r&&(r.has="hit",i(this,tt).call(this,r,a)),true}else r&&(r.has="miss");return false}peek(t,e={}){let{allowStale:s=this.allowStale}=e,r=i(this,R).get(t);if(r===void 0||!s&&i(this,V).call(this,r))return;let a=i(this,g)[r];return h(this,o,y).call(this,a)?a.__staleWhileFetching:a}async fetch(t,e={}){let{allowStale:s=this.allowStale,updateAgeOnGet:r=this.updateAgeOnGet,noDeleteOnStaleGet:a=this.noDeleteOnStaleGet,ttl:n=this.ttl,noDisposeOnSet:f=this.noDisposeOnSet,size:u=0,sizeCalculation:S=this.sizeCalculation,noUpdateTTL:M=this.noUpdateTTL,noDeleteOnFetchRejection:T=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:it=this.allowStaleOnFetchRejection,ignoreFetchAbort:W=this.ignoreFetchAbort,allowStaleOnFetchAbort:k=this.allowStaleOnFetchAbort,context:w,forceRefresh:E=false,status:m,signal:I}=e;if(!i(this,ot))return m&&(m.fetch="get"),this.get(t,{allowStale:s,updateAgeOnGet:r,noDeleteOnStaleGet:a,status:m});let P={allowStale:s,updateAgeOnGet:r,noDeleteOnStaleGet:a,ttl:n,noDisposeOnSet:f,size:u,sizeCalculation:S,noUpdateTTL:M,noDeleteOnFetchRejection:T,allowStaleOnFetchRejection:it,allowStaleOnFetchAbort:k,ignoreFetchAbort:W,status:m,signal:I},O=i(this,R).get(t);if(O===void 0){m&&(m.fetch="miss");let Y=h(this,o,zt).call(this,t,O,P,w);return Y.__returned=Y}else {let Y=i(this,g)[O];if(h(this,o,y).call(this,Y)){let gt=s&&Y.__staleWhileFetching!==void 0;return m&&(m.fetch="inflight",gt&&(m.returnedStale=true)),gt?Y.__staleWhileFetching:Y.__returned=Y}let At=i(this,V).call(this,O);if(!E&&!At)return m&&(m.fetch="hit"),h(this,o,Ot).call(this,O),r&&i(this,ft).call(this,O),m&&i(this,tt).call(this,m,O),Y;let ut=h(this,o,zt).call(this,t,O,P,w),dt=ut.__staleWhileFetching!==void 0&&s;return m&&(m.fetch=At?"stale":"refresh",dt&&At&&(m.returnedStale=true)),dt?ut.__staleWhileFetching:ut.__returned=ut}}async forceFetch(t,e={}){let s=await this.fetch(t,e);if(s===void 0)throw new Error("fetch() returned undefined");return s}memo(t,e={}){let s=i(this,St);if(!s)throw new Error("no memoMethod provided to constructor");let{context:r,forceRefresh:a,...n}=e,f=this.get(t,n);if(!a&&f!==void 0)return f;let u=s(t,f,{options:n,context:r});return this.set(t,u,n),u}get(t,e={}){let{allowStale:s=this.allowStale,updateAgeOnGet:r=this.updateAgeOnGet,noDeleteOnStaleGet:a=this.noDeleteOnStaleGet,status:n}=e,f=i(this,R).get(t);if(f!==void 0){let u=i(this,g)[f],S=h(this,o,y).call(this,u);return n&&i(this,tt).call(this,n,f),i(this,V).call(this,f)?(n&&(n.get="stale"),S?(n&&s&&u.__staleWhileFetching!==void 0&&(n.returnedStale=true),s?u.__staleWhileFetching:void 0):(a||h(this,o,at).call(this,t,"expire"),n&&s&&(n.returnedStale=true),s?u:void 0)):(n&&(n.get="hit"),S?u.__staleWhileFetching:(h(this,o,Ot).call(this,f),r&&i(this,ft).call(this,f),u))}else n&&(n.get="miss");}delete(t){return h(this,o,at).call(this,t,"delete")}clear(){return h(this,o,Kt).call(this,"delete")}};K=new WeakMap,L=new WeakMap,H=new WeakMap,lt=new WeakMap,$=new WeakMap,_t=new WeakMap,St=new WeakMap,B=new WeakMap,v=new WeakMap,X=new WeakMap,R=new WeakMap,b=new WeakMap,g=new WeakMap,D=new WeakMap,N=new WeakMap,F=new WeakMap,C=new WeakMap,q=new WeakMap,x=new WeakMap,J=new WeakMap,Q=new WeakMap,G=new WeakMap,U=new WeakMap,Z=new WeakMap,ot=new WeakMap,z=new WeakMap,Et=new WeakMap,o=new WeakSet,Vt=function(){let t=new pt(i(this,K)),e=new pt(i(this,K));c(this,G,t),c(this,Q,e);let s=this.ttlAutopurge?new Array(i(this,K)):void 0;c(this,U,s),c(this,Rt,(n,f,u=i(this,B).now())=>{if(e[n]=f!==0?u:0,t[n]=f,s?.[n]&&(clearTimeout(s[n]),s[n]=void 0),f!==0&&s){let S=setTimeout(()=>{i(this,V).call(this,n)&&h(this,o,at).call(this,i(this,b)[n],"expire");},f+1);S.unref&&S.unref(),s[n]=S;}}),c(this,ft,n=>{e[n]=t[n]!==0?i(this,B).now():0;}),c(this,tt,(n,f)=>{if(t[f]){let u=t[f],S=e[f];if(!u||!S)return;n.ttl=u,n.start=S,n.now=r||a();let M=n.now-S;n.remainingTTL=u-M;}});let r=0,a=()=>{let n=i(this,B).now();if(this.ttlResolution>0){r=n;let f=setTimeout(()=>r=0,this.ttlResolution);f.unref&&f.unref();}return n};this.getRemainingTTL=n=>{let f=i(this,R).get(n);if(f===void 0)return 0;let u=t[f],S=e[f];if(!u||!S)return 1/0;let M=(r||a())-S;return u-M},c(this,V,n=>{let f=e[n],u=t[n];return !!u&&!!f&&(r||a())-f>u});},ft=new WeakMap,tt=new WeakMap,Rt=new WeakMap,V=new WeakMap,te=function(){let t=new pt(i(this,K));c(this,X,0),c(this,J,t),c(this,ct,e=>{c(this,X,i(this,X)-t[e]),t[e]=0;}),c(this,vt,(e,s,r,a)=>{if(h(this,o,y).call(this,s))return 0;if(!st(r))if(a){if(typeof a!="function")throw new TypeError("sizeCalculation must be a function");if(r=a(s,e),!st(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,yt,(e,s,r)=>{if(t[e]=s,i(this,L)){let a=i(this,L)-t[e];for(;i(this,X)>a;)h(this,o,Dt).call(this,true);}c(this,X,i(this,X)+t[e]),r&&(r.entrySize=s,r.totalCalculatedSize=i(this,X));});},ct=new WeakMap,yt=new WeakMap,vt=new WeakMap,rt=function*({allowStale:t=this.allowStale}={}){if(i(this,v))for(let e=i(this,C);!(!h(this,o,Wt).call(this,e)||((t||!i(this,V).call(this,e))&&(yield e),e===i(this,F)));)e=i(this,N)[e];},nt=function*({allowStale:t=this.allowStale}={}){if(i(this,v))for(let e=i(this,F);!(!h(this,o,Wt).call(this,e)||((t||!i(this,V).call(this,e))&&(yield e),e===i(this,C)));)e=i(this,D)[e];},Wt=function(t){return t!==void 0&&i(this,R).get(i(this,b)[t])===t},Dt=function(t){var a;let e=i(this,F),s=i(this,b)[e],r=i(this,g)[e];return i(this,ot)&&h(this,o,y).call(this,r)?r.__abortController.abort(new Error("evicted")):(i(this,Z)||i(this,z))&&(i(this,Z)&&((a=i(this,H))==null||a.call(this,r,s,"evict")),i(this,z)&&i(this,x)?.push([r,s,"evict"])),i(this,ct).call(this,e),i(this,U)?.[e]&&(clearTimeout(i(this,U)[e]),i(this,U)[e]=void 0),t&&(i(this,b)[e]=void 0,i(this,g)[e]=void 0,i(this,q).push(e)),i(this,v)===1?(c(this,F,c(this,C,0)),i(this,q).length=0):c(this,F,i(this,D)[e]),i(this,R).delete(s),Ft(this,v)._--,e},zt=function(t,e,s,r){let a=e===void 0?void 0:i(this,g)[e];if(h(this,o,y).call(this,a))return a;let n=new Mt,{signal:f}=s;f?.addEventListener("abort",()=>n.abort(f.reason),{signal:n.signal});let u={signal:n.signal,options:s,context:r},S=(w,E=false)=>{let{aborted:m}=n.signal,I=s.ignoreFetchAbort&&w!==void 0;if(s.status&&(m&&!E?(s.status.fetchAborted=true,s.status.fetchError=n.signal.reason,I&&(s.status.fetchAbortIgnored=true)):s.status.fetchResolved=true),m&&!I&&!E)return T(n.signal.reason);let P=W,O=i(this,g)[e];return (O===W||I&&E&&O===void 0)&&(w===void 0?P.__staleWhileFetching!==void 0?i(this,g)[e]=P.__staleWhileFetching:h(this,o,at).call(this,t,"fetch"):(s.status&&(s.status.fetchUpdated=true),this.set(t,w,u.options))),w},M=w=>(s.status&&(s.status.fetchRejected=true,s.status.fetchError=w),T(w)),T=w=>{let{aborted:E}=n.signal,m=E&&s.allowStaleOnFetchAbort,I=m||s.allowStaleOnFetchRejection,P=I||s.noDeleteOnFetchRejection,O=W;if(i(this,g)[e]===W&&(!P||O.__staleWhileFetching===void 0?h(this,o,at).call(this,t,"fetch"):m||(i(this,g)[e]=O.__staleWhileFetching)),I)return s.status&&O.__staleWhileFetching!==void 0&&(s.status.returnedStale=true),O.__staleWhileFetching;if(O.__returned===O)throw w},it=(w,E)=>{var I;let m=(I=i(this,_t))==null?void 0:I.call(this,t,a,u);m&&m instanceof Promise&&m.then(P=>w(P===void 0?void 0:P),E),n.signal.addEventListener("abort",()=>{(!s.ignoreFetchAbort||s.allowStaleOnFetchAbort)&&(w(void 0),s.allowStaleOnFetchAbort&&(w=P=>S(P,true)));});};s.status&&(s.status.fetchDispatched=true);let W=new Promise(it).then(S,M),k=Object.assign(W,{__abortController:n,__staleWhileFetching:a,__returned:void 0});return e===void 0?(this.set(t,k,{...u.options,status:void 0}),e=i(this,R).get(t)):i(this,g)[e]=k,k},y=function(t){if(!i(this,ot))return false;let e=t;return !!e&&e instanceof Promise&&e.hasOwnProperty("__staleWhileFetching")&&e.__abortController instanceof Mt},Yt=function(t,e){i(this,N)[e]=t,i(this,D)[t]=e;},Ot=function(t){t!==i(this,C)&&(t===i(this,F)?c(this,F,i(this,D)[t]):h(this,o,Yt).call(this,i(this,N)[t],i(this,D)[t]),h(this,o,Yt).call(this,i(this,C),t),c(this,C,t));},at=function(t,e){var r,a;let s=false;if(i(this,v)!==0){let n=i(this,R).get(t);if(n!==void 0)if(i(this,U)?.[n]&&(clearTimeout(i(this,U)?.[n]),i(this,U)[n]=void 0),s=true,i(this,v)===1)h(this,o,Kt).call(this,e);else {i(this,ct).call(this,n);let f=i(this,g)[n];if(h(this,o,y).call(this,f)?f.__abortController.abort(new Error("deleted")):(i(this,Z)||i(this,z))&&(i(this,Z)&&((r=i(this,H))==null||r.call(this,f,t,e)),i(this,z)&&i(this,x)?.push([f,t,e])),i(this,R).delete(t),i(this,b)[n]=void 0,i(this,g)[n]=void 0,n===i(this,C))c(this,C,i(this,N)[n]);else if(n===i(this,F))c(this,F,i(this,D)[n]);else {let u=i(this,N)[n];i(this,D)[u]=i(this,D)[n];let S=i(this,D)[n];i(this,N)[S]=i(this,N)[n];}Ft(this,v)._--,i(this,q).push(n);}}if(i(this,z)&&i(this,x)?.length){let n=i(this,x),f;for(;f=n?.shift();)(a=i(this,$))==null||a.call(this,...f);}return s},Kt=function(t){var e,s;for(let r of h(this,o,nt).call(this,{allowStale:true})){let a=i(this,g)[r];if(h(this,o,y).call(this,a))a.__abortController.abort(new Error("deleted"));else {let n=i(this,b)[r];i(this,Z)&&((e=i(this,H))==null||e.call(this,a,n,t)),i(this,z)&&i(this,x)?.push([a,n,t]);}}if(i(this,R).clear(),i(this,g).fill(void 0),i(this,b).fill(void 0),i(this,G)&&i(this,Q)){i(this,G).fill(0),i(this,Q).fill(0);for(let r of i(this,U)??[])r!==void 0&&clearTimeout(r);i(this,U)?.fill(void 0);}if(i(this,J)&&i(this,J).fill(0),c(this,F,0),c(this,C,0),i(this,q).length=0,c(this,X,0),c(this,v,0),i(this,z)&&i(this,x)){let r=i(this,x),a;for(;a=r?.shift();)(s=i(this,$))==null||s.call(this,...a);}};var Pt=jt;var et=class{constructor(t){d(this,"cache");d(this,"map",new Map);this.cache=new Pt({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 e=this.map.delete(t);return e&&this.cache.delete(t),e}get forEach(){return this.map.forEach}get(t){let e=this.cache.get(t);return e||this.map.get(t)}has(t){return this.map.has(t)}set(t,e){return this.map.set(t,e),this.cache.set(t,e),this}get size(){return this.map.size}entries(){return this.map.entries()}keys(){return this.map.keys()}values(){return this.map.values()}};var A=class A{constructor(){}static clearOldTempVariables(t){A.tempStorageDeadlines.forEach((e,s)=>{e>t&&(A.tempStorage.delete(s),A.tempStorageDeadlines.delete(s),A.storage.cache.delete(s));});}static setVariable(t,e){let s=A.tempStorage.has(t);e==null?(A.storage.map.delete(t),!s&&A.storage.cache.delete(t)):(A.storage.map.set(t,e),!s&&A.storage.cache.set(t,e));}static getVariable(t){let e=A.storage.cache.get(t);return e===void 0&&(e=A.tempStorage.get(t)),e===void 0&&(e=A.storage.map.get(t)),e===void 0&&(e=A.default.get(t)),It(e)}static removeVariable(t){A.storage.delete(t);}static setFlag(t,e){if(e)this.flags.includes(t)||this.flags.push(t);else {let s=this.flags.indexOf(t);s>-1&&this.flags.splice(s,1);}}static getFlag(t){return this.flags.includes(t)}};d(A,"storage",new et({cacheSize:20})),d(A,"default",new et({cacheSize:20})),d(A,"flags",Array()),d(A,"tempStorage",new Map),d(A,"tempStorageDeadlines",new Map);var p=A;var bt=class{constructor(t,e){d(this,"id");d(this,"categoryId");this.categoryId=t,this.id=e;}setStorageProperty(t,e){let s=p.getVariable(this.categoryId);s||(s={}),s.hasOwnProperty(this.id)||(s[this.id]={}),e==null?s[this.id].hasOwnProperty(t)&&delete s[this.id][t]:s[this.id]={...s[this.id],[t]:e},Object.keys(s[this.id]).length===0&&delete s[this.id],p.setVariable(this.categoryId,s);}getStorageProperty(t,e=this.id){let s=p.getVariable(this.categoryId);if(s&&s.hasOwnProperty(e)&&s[e].hasOwnProperty(t))return s[e][t]}};var Ht={CHARACTER_CATEGORY_KEY:"___character___"};var ae="@",Tt=class extends bt{constructor(e,s=""){super(Ht.CHARACTER_CATEGORY_KEY,e+(s?ae+s:""));d(this,"sourceId");this.sourceId=e;}getStorageProperty(e){let s=super.getStorageProperty(e);return s===void 0&&(s=super.getStorageProperty(e,this.sourceId)),s}};var Lt=class extends Tt{constructor(e,s){super(typeof e=="string"?e:e.id,typeof e=="string"?"":e.emotion);d(this,"defaultName");d(this,"defaultSurname");d(this,"defaultAge");d(this,"_icon");d(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(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 et({cacheSize:10}),$t;(a=>{function l(n){try{let f=wt.get(n);if(!f){j.warn(`Character "${n}" not found, did you forget to register it with the RegisteredCharacters.add?`);return}return f}catch(f){j.error(`Error while getting Character "${n}"`,f);return}}a.get=l;function t(n){if(Array.isArray(n)){n.forEach(f=>t(f));return}wt.get(n.id)&&j.info(`Character id "${n.id}" already exists, it will be overwritten`),wt.set(n.id,n);}a.add=t;function e(){return Array.from(wt.values())}a.values=e;function s(n){return wt.has(n)}a.has=s;function r(){return Array.from(wt.keys())}a.keys=r;})($t||($t={}));var oe=$t;exports.CharacterBaseModel=Lt;exports.CharacterStoredClass=Tt;exports.RegisteredCharacters=oe;
|
|
1
|
+
'use strict';require('@drincs/pixi-vn/unifier');var ee=Object.defineProperty;var Bt=l=>{throw TypeError(l)};var ie=(l,t,e)=>t in l?ee(l,t,{enumerable:true,configurable:true,writable:true,value:e}):l[t]=e;var d=(l,t,e)=>ie(l,typeof t!="symbol"?t+"":t,e),Nt=(l,t,e)=>t.has(l)||Bt("Cannot "+e);var i=(l,t,e)=>(Nt(l,t,"read from private field"),e?e.call(l):t.get(l)),_=(l,t,e)=>t.has(l)?Bt("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(l):t.set(l,e),c=(l,t,e,s)=>(Nt(l,t,"write to private field"),t.set(l,e),e),h=(l,t,e)=>(Nt(l,t,"access private method"),e);var Ft=(l,t,e,s)=>({set _(r){c(l,t,r);},get _(){return i(l,t,s)}});var j;(r=>(r.log=(a,...n)=>console.log(`[Pixi\u2019VN] ${a}`,...n),r.warn=(a,...n)=>console.warn(`[Pixi\u2019VN] ${a}`,...n),r.error=(a,...n)=>console.error(`[Pixi\u2019VN] ${a}`,...n),r.info=(a,...n)=>console.info(`[Pixi\u2019VN] ${a}`,...n)))(j||(j={}));function It(l){try{if(typeof l>"u")return l;let t=JSON.stringify(l);return JSON.parse(t)}catch(t){throw j.error("Error creating exportable element",l,t),new Error("[Pixi\u2019VN] Error creating exportable element")}}var se=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,Qt=new Set,Gt=typeof process=="object"&&process?process:{},Zt=(l,t,e,s)=>{typeof Gt.emitWarning=="function"?Gt.emitWarning(l,t,e,s):console.error(`[${e}] ${t}: ${l}`);},Mt=globalThis.AbortController,Xt=globalThis.AbortSignal;if(typeof Mt>"u"){Xt=class{constructor(){d(this,"onabort");d(this,"_onabort",[]);d(this,"reason");d(this,"aborted",false);}addEventListener(s,r){this._onabort.push(r);}},Mt=class{constructor(){d(this,"signal",new Xt);t();}abort(s){if(!this.signal.aborted){this.signal.reason=s,this.signal.aborted=true;for(let r of this.signal._onabort)r(s);this.signal.onabort?.(s);}}};let l=Gt.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",t=()=>{l&&(l=false,Zt("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 re=l=>!Qt.has(l);var st=l=>l&&l===Math.floor(l)&&l>0&&isFinite(l),kt=l=>st(l)?l<=Math.pow(2,8)?Uint8Array:l<=Math.pow(2,16)?Uint16Array:l<=Math.pow(2,32)?Uint32Array:l<=Number.MAX_SAFE_INTEGER?mt:null:null,mt=class extends Array{constructor(t){super(t),this.fill(0);}},_t,ht=class ht{constructor(t,e){d(this,"heap");d(this,"length");if(!i(ht,_t))throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new e(t),this.length=0;}static create(t){let e=kt(t);if(!e)return [];c(ht,_t,true);let s=new ht(t,e);return c(ht,_t,false),s}push(t){this.heap[this.length++]=t;}pop(){return this.heap[--this.length]}};_t=new WeakMap,_(ht,_t,false);var Ut=ht,qt,Jt,K,N,H,lt,$,St,Et,B,C,X,R,b,g,z,G,F,v,q,x,J,Q,U,V,Z,ot,M,yt,o,Vt,ft,tt,Rt,W,te,ct,bt,Ct,rt,nt,Wt,Dt,zt,y,Yt,Ot,at,Kt,jt=class jt{constructor(t){_(this,o);_(this,K);_(this,N);_(this,H);_(this,lt);_(this,$);_(this,St);_(this,Et);_(this,B);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");_(this,C);_(this,X);_(this,R);_(this,b);_(this,g);_(this,z);_(this,G);_(this,F);_(this,v);_(this,q);_(this,x);_(this,J);_(this,Q);_(this,U);_(this,V);_(this,Z);_(this,ot);_(this,M);_(this,yt);_(this,ft,()=>{});_(this,tt,()=>{});_(this,Rt,()=>{});_(this,W,()=>false);_(this,ct,t=>{});_(this,bt,(t,e,s)=>{});_(this,Ct,(t,e,s,r)=>{if(s||r)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0});d(this,qt,"LRUCache");let{max:e=0,ttl:s,ttlResolution:r=1,ttlAutopurge:a,updateAgeOnGet:n,updateAgeOnHas:f,allowStale:u,dispose:S,onInsert:P,disposeAfter:T,noDisposeOnSet:it,noUpdateTTL:Y,maxSize:k=0,maxEntrySize:w=0,sizeCalculation:E,fetchMethod:m,memoMethod:I,noDeleteOnFetchRejection:L,noDeleteOnStaleGet:D,allowStaleOnFetchRejection:A,allowStaleOnFetchAbort:ut,ignoreFetchAbort:dt,perf:xt}=t;if(xt!==void 0&&typeof xt?.now!="function")throw new TypeError("perf option must have a now() method if specified");if(c(this,B,xt??se),e!==0&&!st(e))throw new TypeError("max option must be a nonnegative integer");let gt=e?kt(e):Array;if(!gt)throw new Error("invalid max value: "+e);if(c(this,K,e),c(this,N,k),this.maxEntrySize=w||i(this,N),this.sizeCalculation=E,this.sizeCalculation){if(!i(this,N)&&!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,Et,I),m!==void 0&&typeof m!="function")throw new TypeError("fetchMethod must be a function if specified");if(c(this,St,m),c(this,ot,!!m),c(this,R,new Map),c(this,b,new Array(e).fill(void 0)),c(this,g,new Array(e).fill(void 0)),c(this,z,new gt(e)),c(this,G,new gt(e)),c(this,F,0),c(this,v,0),c(this,q,Ut.create(e)),c(this,C,0),c(this,X,0),typeof S=="function"&&c(this,H,S),typeof P=="function"&&c(this,lt,P),typeof T=="function"?(c(this,$,T),c(this,x,[])):(c(this,$,void 0),c(this,x,void 0)),c(this,Z,!!i(this,H)),c(this,yt,!!i(this,lt)),c(this,M,!!i(this,$)),this.noDisposeOnSet=!!it,this.noUpdateTTL=!!Y,this.noDeleteOnFetchRejection=!!L,this.allowStaleOnFetchRejection=!!A,this.allowStaleOnFetchAbort=!!ut,this.ignoreFetchAbort=!!dt,this.maxEntrySize!==0){if(i(this,N)!==0&&!st(i(this,N)))throw new TypeError("maxSize must be a positive integer if specified");if(!st(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");h(this,o,te).call(this);}if(this.allowStale=!!u,this.noDeleteOnStaleGet=!!D,this.updateAgeOnGet=!!n,this.updateAgeOnHas=!!f,this.ttlResolution=st(r)||r===0?r:1,this.ttlAutopurge=!!a,this.ttl=s||0,this.ttl){if(!st(this.ttl))throw new TypeError("ttl must be a positive integer if specified");h(this,o,Vt).call(this);}if(i(this,K)===0&&this.ttl===0&&i(this,N)===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!i(this,K)&&!i(this,N)){let pt="LRU_CACHE_UNBOUNDED";re(pt)&&(Qt.add(pt),Zt("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",pt,jt));}}get perf(){return i(this,B)}static unsafeExposeInternals(t){return {starts:i(t,Q),ttls:i(t,U),autopurgeTimers:i(t,V),sizes:i(t,J),keyMap:i(t,R),keyList:i(t,b),valList:i(t,g),next:i(t,z),prev:i(t,G),get head(){return i(t,F)},get tail(){return i(t,v)},free:i(t,q),isBackgroundFetch:e=>{var s;return h(s=t,o,y).call(s,e)},backgroundFetch:(e,s,r,a)=>{var n;return h(n=t,o,zt).call(n,e,s,r,a)},moveToTail:e=>{var s;return h(s=t,o,Ot).call(s,e)},indexes:e=>{var s;return h(s=t,o,rt).call(s,e)},rindexes:e=>{var s;return h(s=t,o,nt).call(s,e)},isStale:e=>{var s;return i(s=t,W).call(s,e)}}}get max(){return i(this,K)}get maxSize(){return i(this,N)}get calculatedSize(){return i(this,X)}get size(){return i(this,C)}get fetchMethod(){return i(this,St)}get memoMethod(){return i(this,Et)}get dispose(){return i(this,H)}get onInsert(){return i(this,lt)}get disposeAfter(){return i(this,$)}getRemainingTTL(t){return i(this,R).has(t)?1/0:0}*entries(){for(let t of h(this,o,rt).call(this))i(this,g)[t]!==void 0&&i(this,b)[t]!==void 0&&!h(this,o,y).call(this,i(this,g)[t])&&(yield [i(this,b)[t],i(this,g)[t]]);}*rentries(){for(let t of h(this,o,nt).call(this))i(this,g)[t]!==void 0&&i(this,b)[t]!==void 0&&!h(this,o,y).call(this,i(this,g)[t])&&(yield [i(this,b)[t],i(this,g)[t]]);}*keys(){for(let t of h(this,o,rt).call(this)){let e=i(this,b)[t];e!==void 0&&!h(this,o,y).call(this,i(this,g)[t])&&(yield e);}}*rkeys(){for(let t of h(this,o,nt).call(this)){let e=i(this,b)[t];e!==void 0&&!h(this,o,y).call(this,i(this,g)[t])&&(yield e);}}*values(){for(let t of h(this,o,rt).call(this))i(this,g)[t]!==void 0&&!h(this,o,y).call(this,i(this,g)[t])&&(yield i(this,g)[t]);}*rvalues(){for(let t of h(this,o,nt).call(this))i(this,g)[t]!==void 0&&!h(this,o,y).call(this,i(this,g)[t])&&(yield i(this,g)[t]);}[(Jt=Symbol.iterator,qt=Symbol.toStringTag,Jt)](){return this.entries()}find(t,e={}){for(let s of h(this,o,rt).call(this)){let r=i(this,g)[s],a=h(this,o,y).call(this,r)?r.__staleWhileFetching:r;if(a!==void 0&&t(a,i(this,b)[s],this))return this.get(i(this,b)[s],e)}}forEach(t,e=this){for(let s of h(this,o,rt).call(this)){let r=i(this,g)[s],a=h(this,o,y).call(this,r)?r.__staleWhileFetching:r;a!==void 0&&t.call(e,a,i(this,b)[s],this);}}rforEach(t,e=this){for(let s of h(this,o,nt).call(this)){let r=i(this,g)[s],a=h(this,o,y).call(this,r)?r.__staleWhileFetching:r;a!==void 0&&t.call(e,a,i(this,b)[s],this);}}purgeStale(){let t=false;for(let e of h(this,o,nt).call(this,{allowStale:true}))i(this,W).call(this,e)&&(h(this,o,at).call(this,i(this,b)[e],"expire"),t=true);return t}info(t){let e=i(this,R).get(t);if(e===void 0)return;let s=i(this,g)[e],r=h(this,o,y).call(this,s)?s.__staleWhileFetching:s;if(r===void 0)return;let a={value:r};if(i(this,U)&&i(this,Q)){let n=i(this,U)[e],f=i(this,Q)[e];if(n&&f){let u=n-(i(this,B).now()-f);a.ttl=u,a.start=Date.now();}}return i(this,J)&&(a.size=i(this,J)[e]),a}dump(){let t=[];for(let e of h(this,o,rt).call(this,{allowStale:true})){let s=i(this,b)[e],r=i(this,g)[e],a=h(this,o,y).call(this,r)?r.__staleWhileFetching:r;if(a===void 0||s===void 0)continue;let n={value:a};if(i(this,U)&&i(this,Q)){n.ttl=i(this,U)[e];let f=i(this,B).now()-i(this,Q)[e];n.start=Math.floor(Date.now()-f);}i(this,J)&&(n.size=i(this,J)[e]),t.unshift([s,n]);}return t}load(t){this.clear();for(let[e,s]of t){if(s.start){let r=Date.now()-s.start;s.start=i(this,B).now()-r;}this.set(e,s.value,s);}}set(t,e,s={}){var it,Y,k,w;if(e===void 0)return this.delete(t),this;let{ttl:r=this.ttl,start:a,noDisposeOnSet:n=this.noDisposeOnSet,sizeCalculation:f=this.sizeCalculation,status:u}=s,{noUpdateTTL:S=this.noUpdateTTL}=s,P=i(this,Ct).call(this,t,e,s.size||0,f);if(this.maxEntrySize&&P>this.maxEntrySize)return u&&(u.set="miss",u.maxEntrySizeExceeded=true),h(this,o,at).call(this,t,"set"),this;let T=i(this,C)===0?void 0:i(this,R).get(t);if(T===void 0)T=i(this,C)===0?i(this,v):i(this,q).length!==0?i(this,q).pop():i(this,C)===i(this,K)?h(this,o,Dt).call(this,false):i(this,C),i(this,b)[T]=t,i(this,g)[T]=e,i(this,R).set(t,T),i(this,z)[i(this,v)]=T,i(this,G)[T]=i(this,v),c(this,v,T),Ft(this,C)._++,i(this,bt).call(this,T,P,u),u&&(u.set="add"),S=false,i(this,yt)&&((it=i(this,lt))==null||it.call(this,e,t,"add"));else {h(this,o,Ot).call(this,T);let E=i(this,g)[T];if(e!==E){if(i(this,ot)&&h(this,o,y).call(this,E)){E.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:m}=E;m!==void 0&&!n&&(i(this,Z)&&((Y=i(this,H))==null||Y.call(this,m,t,"set")),i(this,M)&&i(this,x)?.push([m,t,"set"]));}else n||(i(this,Z)&&((k=i(this,H))==null||k.call(this,E,t,"set")),i(this,M)&&i(this,x)?.push([E,t,"set"]));if(i(this,ct).call(this,T),i(this,bt).call(this,T,P,u),i(this,g)[T]=e,u){u.set="replace";let m=E&&h(this,o,y).call(this,E)?E.__staleWhileFetching:E;m!==void 0&&(u.oldValue=m);}}else u&&(u.set="update");i(this,yt)&&this.onInsert?.(e,t,e===E?"update":"replace");}if(r!==0&&!i(this,U)&&h(this,o,Vt).call(this),i(this,U)&&(S||i(this,Rt).call(this,T,r,a),u&&i(this,tt).call(this,u,T)),!n&&i(this,M)&&i(this,x)){let E=i(this,x),m;for(;m=E?.shift();)(w=i(this,$))==null||w.call(this,...m);}return this}pop(){var t;try{for(;i(this,C);){let e=i(this,g)[i(this,F)];if(h(this,o,Dt).call(this,!0),h(this,o,y).call(this,e)){if(e.__staleWhileFetching)return e.__staleWhileFetching}else if(e!==void 0)return e}}finally{if(i(this,M)&&i(this,x)){let e=i(this,x),s;for(;s=e?.shift();)(t=i(this,$))==null||t.call(this,...s);}}}has(t,e={}){let{updateAgeOnHas:s=this.updateAgeOnHas,status:r}=e,a=i(this,R).get(t);if(a!==void 0){let n=i(this,g)[a];if(h(this,o,y).call(this,n)&&n.__staleWhileFetching===void 0)return false;if(i(this,W).call(this,a))r&&(r.has="stale",i(this,tt).call(this,r,a));else return s&&i(this,ft).call(this,a),r&&(r.has="hit",i(this,tt).call(this,r,a)),true}else r&&(r.has="miss");return false}peek(t,e={}){let{allowStale:s=this.allowStale}=e,r=i(this,R).get(t);if(r===void 0||!s&&i(this,W).call(this,r))return;let a=i(this,g)[r];return h(this,o,y).call(this,a)?a.__staleWhileFetching:a}async fetch(t,e={}){let{allowStale:s=this.allowStale,updateAgeOnGet:r=this.updateAgeOnGet,noDeleteOnStaleGet:a=this.noDeleteOnStaleGet,ttl:n=this.ttl,noDisposeOnSet:f=this.noDisposeOnSet,size:u=0,sizeCalculation:S=this.sizeCalculation,noUpdateTTL:P=this.noUpdateTTL,noDeleteOnFetchRejection:T=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:it=this.allowStaleOnFetchRejection,ignoreFetchAbort:Y=this.ignoreFetchAbort,allowStaleOnFetchAbort:k=this.allowStaleOnFetchAbort,context:w,forceRefresh:E=false,status:m,signal:I}=e;if(!i(this,ot))return m&&(m.fetch="get"),this.get(t,{allowStale:s,updateAgeOnGet:r,noDeleteOnStaleGet:a,status:m});let L={allowStale:s,updateAgeOnGet:r,noDeleteOnStaleGet:a,ttl:n,noDisposeOnSet:f,size:u,sizeCalculation:S,noUpdateTTL:P,noDeleteOnFetchRejection:T,allowStaleOnFetchRejection:it,allowStaleOnFetchAbort:k,ignoreFetchAbort:Y,status:m,signal:I},D=i(this,R).get(t);if(D===void 0){m&&(m.fetch="miss");let A=h(this,o,zt).call(this,t,D,L,w);return A.__returned=A}else {let A=i(this,g)[D];if(h(this,o,y).call(this,A)){let pt=s&&A.__staleWhileFetching!==void 0;return m&&(m.fetch="inflight",pt&&(m.returnedStale=true)),pt?A.__staleWhileFetching:A.__returned=A}let ut=i(this,W).call(this,D);if(!E&&!ut)return m&&(m.fetch="hit"),h(this,o,Ot).call(this,D),r&&i(this,ft).call(this,D),m&&i(this,tt).call(this,m,D),A;let dt=h(this,o,zt).call(this,t,D,L,w),gt=dt.__staleWhileFetching!==void 0&&s;return m&&(m.fetch=ut?"stale":"refresh",gt&&ut&&(m.returnedStale=true)),gt?dt.__staleWhileFetching:dt.__returned=dt}}async forceFetch(t,e={}){let s=await this.fetch(t,e);if(s===void 0)throw new Error("fetch() returned undefined");return s}memo(t,e={}){let s=i(this,Et);if(!s)throw new Error("no memoMethod provided to constructor");let{context:r,forceRefresh:a,...n}=e,f=this.get(t,n);if(!a&&f!==void 0)return f;let u=s(t,f,{options:n,context:r});return this.set(t,u,n),u}get(t,e={}){let{allowStale:s=this.allowStale,updateAgeOnGet:r=this.updateAgeOnGet,noDeleteOnStaleGet:a=this.noDeleteOnStaleGet,status:n}=e,f=i(this,R).get(t);if(f!==void 0){let u=i(this,g)[f],S=h(this,o,y).call(this,u);return n&&i(this,tt).call(this,n,f),i(this,W).call(this,f)?(n&&(n.get="stale"),S?(n&&s&&u.__staleWhileFetching!==void 0&&(n.returnedStale=true),s?u.__staleWhileFetching:void 0):(a||h(this,o,at).call(this,t,"expire"),n&&s&&(n.returnedStale=true),s?u:void 0)):(n&&(n.get="hit"),S?u.__staleWhileFetching:(h(this,o,Ot).call(this,f),r&&i(this,ft).call(this,f),u))}else n&&(n.get="miss");}delete(t){return h(this,o,at).call(this,t,"delete")}clear(){return h(this,o,Kt).call(this,"delete")}};K=new WeakMap,N=new WeakMap,H=new WeakMap,lt=new WeakMap,$=new WeakMap,St=new WeakMap,Et=new WeakMap,B=new WeakMap,C=new WeakMap,X=new WeakMap,R=new WeakMap,b=new WeakMap,g=new WeakMap,z=new WeakMap,G=new WeakMap,F=new WeakMap,v=new WeakMap,q=new WeakMap,x=new WeakMap,J=new WeakMap,Q=new WeakMap,U=new WeakMap,V=new WeakMap,Z=new WeakMap,ot=new WeakMap,M=new WeakMap,yt=new WeakMap,o=new WeakSet,Vt=function(){let t=new mt(i(this,K)),e=new mt(i(this,K));c(this,U,t),c(this,Q,e);let s=this.ttlAutopurge?new Array(i(this,K)):void 0;c(this,V,s),c(this,Rt,(n,f,u=i(this,B).now())=>{if(e[n]=f!==0?u:0,t[n]=f,s?.[n]&&(clearTimeout(s[n]),s[n]=void 0),f!==0&&s){let S=setTimeout(()=>{i(this,W).call(this,n)&&h(this,o,at).call(this,i(this,b)[n],"expire");},f+1);S.unref&&S.unref(),s[n]=S;}}),c(this,ft,n=>{e[n]=t[n]!==0?i(this,B).now():0;}),c(this,tt,(n,f)=>{if(t[f]){let u=t[f],S=e[f];if(!u||!S)return;n.ttl=u,n.start=S,n.now=r||a();let P=n.now-S;n.remainingTTL=u-P;}});let r=0,a=()=>{let n=i(this,B).now();if(this.ttlResolution>0){r=n;let f=setTimeout(()=>r=0,this.ttlResolution);f.unref&&f.unref();}return n};this.getRemainingTTL=n=>{let f=i(this,R).get(n);if(f===void 0)return 0;let u=t[f],S=e[f];if(!u||!S)return 1/0;let P=(r||a())-S;return u-P},c(this,W,n=>{let f=e[n],u=t[n];return !!u&&!!f&&(r||a())-f>u});},ft=new WeakMap,tt=new WeakMap,Rt=new WeakMap,W=new WeakMap,te=function(){let t=new mt(i(this,K));c(this,X,0),c(this,J,t),c(this,ct,e=>{c(this,X,i(this,X)-t[e]),t[e]=0;}),c(this,Ct,(e,s,r,a)=>{if(h(this,o,y).call(this,s))return 0;if(!st(r))if(a){if(typeof a!="function")throw new TypeError("sizeCalculation must be a function");if(r=a(s,e),!st(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,bt,(e,s,r)=>{if(t[e]=s,i(this,N)){let a=i(this,N)-t[e];for(;i(this,X)>a;)h(this,o,Dt).call(this,true);}c(this,X,i(this,X)+t[e]),r&&(r.entrySize=s,r.totalCalculatedSize=i(this,X));});},ct=new WeakMap,bt=new WeakMap,Ct=new WeakMap,rt=function*({allowStale:t=this.allowStale}={}){if(i(this,C))for(let e=i(this,v);!(!h(this,o,Wt).call(this,e)||((t||!i(this,W).call(this,e))&&(yield e),e===i(this,F)));)e=i(this,G)[e];},nt=function*({allowStale:t=this.allowStale}={}){if(i(this,C))for(let e=i(this,F);!(!h(this,o,Wt).call(this,e)||((t||!i(this,W).call(this,e))&&(yield e),e===i(this,v)));)e=i(this,z)[e];},Wt=function(t){return t!==void 0&&i(this,R).get(i(this,b)[t])===t},Dt=function(t){var a;let e=i(this,F),s=i(this,b)[e],r=i(this,g)[e];return i(this,ot)&&h(this,o,y).call(this,r)?r.__abortController.abort(new Error("evicted")):(i(this,Z)||i(this,M))&&(i(this,Z)&&((a=i(this,H))==null||a.call(this,r,s,"evict")),i(this,M)&&i(this,x)?.push([r,s,"evict"])),i(this,ct).call(this,e),i(this,V)?.[e]&&(clearTimeout(i(this,V)[e]),i(this,V)[e]=void 0),t&&(i(this,b)[e]=void 0,i(this,g)[e]=void 0,i(this,q).push(e)),i(this,C)===1?(c(this,F,c(this,v,0)),i(this,q).length=0):c(this,F,i(this,z)[e]),i(this,R).delete(s),Ft(this,C)._--,e},zt=function(t,e,s,r){let a=e===void 0?void 0:i(this,g)[e];if(h(this,o,y).call(this,a))return a;let n=new Mt,{signal:f}=s;f?.addEventListener("abort",()=>n.abort(f.reason),{signal:n.signal});let u={signal:n.signal,options:s,context:r},S=(w,E=false)=>{let{aborted:m}=n.signal,I=s.ignoreFetchAbort&&w!==void 0,L=s.ignoreFetchAbort||!!(s.allowStaleOnFetchAbort&&w!==void 0);if(s.status&&(m&&!E?(s.status.fetchAborted=true,s.status.fetchError=n.signal.reason,I&&(s.status.fetchAbortIgnored=true)):s.status.fetchResolved=true),m&&!I&&!E)return T(n.signal.reason,L);let D=Y,A=i(this,g)[e];return (A===Y||I&&E&&A===void 0)&&(w===void 0?D.__staleWhileFetching!==void 0?i(this,g)[e]=D.__staleWhileFetching:h(this,o,at).call(this,t,"fetch"):(s.status&&(s.status.fetchUpdated=true),this.set(t,w,u.options))),w},P=w=>(s.status&&(s.status.fetchRejected=true,s.status.fetchError=w),T(w,false)),T=(w,E)=>{let{aborted:m}=n.signal,I=m&&s.allowStaleOnFetchAbort,L=I||s.allowStaleOnFetchRejection,D=L||s.noDeleteOnFetchRejection,A=Y;if(i(this,g)[e]===Y&&(!D||!E&&A.__staleWhileFetching===void 0?h(this,o,at).call(this,t,"fetch"):I||(i(this,g)[e]=A.__staleWhileFetching)),L)return s.status&&A.__staleWhileFetching!==void 0&&(s.status.returnedStale=true),A.__staleWhileFetching;if(A.__returned===A)throw w},it=(w,E)=>{var I;let m=(I=i(this,St))==null?void 0:I.call(this,t,a,u);m&&m instanceof Promise&&m.then(L=>w(L===void 0?void 0:L),E),n.signal.addEventListener("abort",()=>{(!s.ignoreFetchAbort||s.allowStaleOnFetchAbort)&&(w(void 0),s.allowStaleOnFetchAbort&&(w=L=>S(L,true)));});};s.status&&(s.status.fetchDispatched=true);let Y=new Promise(it).then(S,P),k=Object.assign(Y,{__abortController:n,__staleWhileFetching:a,__returned:void 0});return e===void 0?(this.set(t,k,{...u.options,status:void 0}),e=i(this,R).get(t)):i(this,g)[e]=k,k},y=function(t){if(!i(this,ot))return false;let e=t;return !!e&&e instanceof Promise&&e.hasOwnProperty("__staleWhileFetching")&&e.__abortController instanceof Mt},Yt=function(t,e){i(this,G)[e]=t,i(this,z)[t]=e;},Ot=function(t){t!==i(this,v)&&(t===i(this,F)?c(this,F,i(this,z)[t]):h(this,o,Yt).call(this,i(this,G)[t],i(this,z)[t]),h(this,o,Yt).call(this,i(this,v),t),c(this,v,t));},at=function(t,e){var r,a;let s=false;if(i(this,C)!==0){let n=i(this,R).get(t);if(n!==void 0)if(i(this,V)?.[n]&&(clearTimeout(i(this,V)?.[n]),i(this,V)[n]=void 0),s=true,i(this,C)===1)h(this,o,Kt).call(this,e);else {i(this,ct).call(this,n);let f=i(this,g)[n];if(h(this,o,y).call(this,f)?f.__abortController.abort(new Error("deleted")):(i(this,Z)||i(this,M))&&(i(this,Z)&&((r=i(this,H))==null||r.call(this,f,t,e)),i(this,M)&&i(this,x)?.push([f,t,e])),i(this,R).delete(t),i(this,b)[n]=void 0,i(this,g)[n]=void 0,n===i(this,v))c(this,v,i(this,G)[n]);else if(n===i(this,F))c(this,F,i(this,z)[n]);else {let u=i(this,G)[n];i(this,z)[u]=i(this,z)[n];let S=i(this,z)[n];i(this,G)[S]=i(this,G)[n];}Ft(this,C)._--,i(this,q).push(n);}}if(i(this,M)&&i(this,x)?.length){let n=i(this,x),f;for(;f=n?.shift();)(a=i(this,$))==null||a.call(this,...f);}return s},Kt=function(t){var e,s;for(let r of h(this,o,nt).call(this,{allowStale:true})){let a=i(this,g)[r];if(h(this,o,y).call(this,a))a.__abortController.abort(new Error("deleted"));else {let n=i(this,b)[r];i(this,Z)&&((e=i(this,H))==null||e.call(this,a,n,t)),i(this,M)&&i(this,x)?.push([a,n,t]);}}if(i(this,R).clear(),i(this,g).fill(void 0),i(this,b).fill(void 0),i(this,U)&&i(this,Q)){i(this,U).fill(0),i(this,Q).fill(0);for(let r of i(this,V)??[])r!==void 0&&clearTimeout(r);i(this,V)?.fill(void 0);}if(i(this,J)&&i(this,J).fill(0),c(this,F,0),c(this,v,0),i(this,q).length=0,c(this,X,0),c(this,C,0),i(this,M)&&i(this,x)){let r=i(this,x),a;for(;a=r?.shift();)(s=i(this,$))==null||s.call(this,...a);}};var Pt=jt;var et=class{constructor(t){d(this,"cache");d(this,"map",new Map);this.cache=new Pt({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 e=this.map.delete(t);return e&&this.cache.delete(t),e}get forEach(){return this.map.forEach}get(t){let e=this.cache.get(t);return e||this.map.get(t)}has(t){return this.map.has(t)}set(t,e){return this.map.set(t,e),this.cache.set(t,e),this}get size(){return this.map.size}entries(){return this.map.entries()}keys(){return this.map.keys()}values(){return this.map.values()}};var O=class O{constructor(){}static clearOldTempVariables(t){O.tempStorageDeadlines.forEach((e,s)=>{e>t&&(O.tempStorage.delete(s),O.tempStorageDeadlines.delete(s),O.storage.cache.delete(s));});}static setVariable(t,e){let s=O.tempStorage.has(t);e==null?(O.storage.map.delete(t),!s&&O.storage.cache.delete(t)):(O.storage.map.set(t,e),!s&&O.storage.cache.set(t,e));}static getVariable(t){let e=O.storage.cache.get(t);return e===void 0&&(e=O.tempStorage.get(t)),e===void 0&&(e=O.storage.map.get(t)),e===void 0&&(e=O.default.get(t)),It(e)}static removeVariable(t){O.storage.delete(t);}static setFlag(t,e){if(e)this.flags.includes(t)||this.flags.push(t);else {let s=this.flags.indexOf(t);s>-1&&this.flags.splice(s,1);}}static getFlag(t){return this.flags.includes(t)}};d(O,"storage",new et({cacheSize:20})),d(O,"default",new et({cacheSize:20})),d(O,"flags",Array()),d(O,"tempStorage",new Map),d(O,"tempStorageDeadlines",new Map);var p=O;var Tt=class{constructor(t,e){d(this,"id");d(this,"categoryId");this.categoryId=t,this.id=e;}setStorageProperty(t,e){let s=p.getVariable(this.categoryId);s||(s={}),s.hasOwnProperty(this.id)||(s[this.id]={}),e==null?s[this.id].hasOwnProperty(t)&&delete s[this.id][t]:s[this.id]={...s[this.id],[t]:e},Object.keys(s[this.id]).length===0&&delete s[this.id],p.setVariable(this.categoryId,s);}getStorageProperty(t,e=this.id){let s=p.getVariable(this.categoryId);if(s&&s.hasOwnProperty(e)&&s[e].hasOwnProperty(t))return s[e][t]}};var Ht={CHARACTER_CATEGORY_KEY:"___character___"};var ae="@",wt=class extends Tt{constructor(e,s=""){super(Ht.CHARACTER_CATEGORY_KEY,e+(s?ae+s:""));d(this,"sourceId");this.sourceId=e;}getStorageProperty(e){let s=super.getStorageProperty(e);return s===void 0&&(s=super.getStorageProperty(e,this.sourceId)),s}};var Lt=class extends wt{constructor(e,s){super(typeof e=="string"?e:e.id,typeof e=="string"?"":e.emotion);d(this,"defaultName");d(this,"defaultSurname");d(this,"defaultAge");d(this,"_icon");d(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(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 At=new et({cacheSize:10}),$t;(a=>{function l(n){try{let f=At.get(n);if(!f){j.warn(`Character "${n}" not found, did you forget to register it with the RegisteredCharacters.add?`);return}return f}catch(f){j.error(`Error while getting Character "${n}"`,f);return}}a.get=l;function t(n){if(Array.isArray(n)){n.forEach(f=>t(f));return}At.get(n.id)&&j.info(`Character id "${n.id}" already exists, it will be overwritten`),At.set(n.id,n);}a.add=t;function e(){return Array.from(At.values())}a.values=e;function s(n){return At.has(n)}a.has=s;function r(){return Array.from(At.keys())}a.keys=r;})($t||($t={}));var oe=$t;exports.CharacterBaseModel=Lt;exports.CharacterStoredClass=wt;exports.RegisteredCharacters=oe;
|
package/dist/characters.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import {b}from'./chunk-
|
|
1
|
+
import {b}from'./chunk-TIA4D2N7.mjs';import {a as a$1}from'./chunk-6GO4XVS7.mjs';import {a}from'./chunk-GFG3MDHE.mjs';import {j,d}from'./chunk-GNJIUFU2.mjs';var l="@",s=class extends b{constructor(e,r=""){super(a$1.CHARACTER_CATEGORY_KEY,e+(r?l+r:""));d(this,"sourceId");this.sourceId=e;}getStorageProperty(e){let r=super.getStorageProperty(e);return r===void 0&&(r=super.getStorageProperty(e,this.sourceId)),r}};var u=class extends s{constructor(e,r){super(typeof e=="string"?e:e.id,typeof e=="string"?"":e.emotion);d(this,"defaultName");d(this,"defaultSurname");d(this,"defaultAge");d(this,"_icon");d(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 i=new a({cacheSize:10}),f;(S=>{function d(t){try{let a=i.get(t);if(!a){j.warn(`Character "${t}" not found, did you forget to register it with the RegisteredCharacters.add?`);return}return a}catch(a){j.error(`Error while getting Character "${t}"`,a);return}}S.get=d;function g(t){if(Array.isArray(t)){t.forEach(a=>g(a));return}i.get(t.id)&&j.info(`Character id "${t.id}" already exists, it will be overwritten`),i.set(t.id,t);}S.add=g;function e(){return Array.from(i.values())}S.values=e;function r(t){return i.has(t)}S.has=r;function C(){return Array.from(i.keys())}S.keys=C;})(f||(f={}));var p=f;export{u as CharacterBaseModel,s as CharacterStoredClass,p as RegisteredCharacters};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import {d,f,e,g,h,i}from'./chunk-GNJIUFU2.mjs';var Pt=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,Gt=new Set,vt=typeof process=="object"&&process?process:{},jt=(A,e,i,s)=>{typeof vt.emitWarning=="function"?vt.emitWarning(A,e,i,s):console.error(`[${i}] ${e}: ${A}`);},Et=globalThis.AbortController,Mt=globalThis.AbortSignal;if(typeof Et>"u"){Mt=class{constructor(){d(this,"onabort");d(this,"_onabort",[]);d(this,"reason");d(this,"aborted",false);}addEventListener(s,h){this._onabort.push(h);}},Et=class{constructor(){d(this,"signal",new Mt);e();}abort(s){if(!this.signal.aborted){this.signal.reason=s,this.signal.aborted=true;for(let h of this.signal._onabort)h(s);this.signal.onabort?.(s);}}};let A=vt.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",e=()=>{A&&(A=false,jt("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=A=>!Gt.has(A);var Z=A=>A&&A===Math.floor(A)&&A>0&&isFinite(A),Nt=A=>Z(A)?A<=Math.pow(2,8)?Uint8Array:A<=Math.pow(2,16)?Uint16Array:A<=Math.pow(2,32)?Uint32Array:A<=Number.MAX_SAFE_INTEGER?ut:null:null,ut=class extends Array{constructor(e){super(e),this.fill(0);}},dt,nt=class nt{constructor(e$1,i){d(this,"heap");d(this,"length");if(!e(nt,dt))throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new i(e$1),this.length=0;}static create(e){let i=Nt(e);if(!i)return [];g(nt,dt,true);let s=new nt(e,i);return g(nt,dt,false),s}push(e){this.heap[this.length++]=e;}pop(){return this.heap[--this.length]}};dt=new WeakMap,f(nt,dt,false);var Ct=nt,Ut,It,V,M,P,ht,H,gt,pt,K,E,B,F,b,u,W,U,v,z,k,O,$,q,I,G,Y,st,D,mt,r,Rt,rt,J,bt,j,Vt,ot,wt,yt,tt,et,Wt,Tt,Ft,S,Dt,St,it,Lt,xt=class xt{constructor(e$1){f(this,r);f(this,V);f(this,M);f(this,P);f(this,ht);f(this,H);f(this,gt);f(this,pt);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,E);f(this,B);f(this,F);f(this,b);f(this,u);f(this,W);f(this,U);f(this,v);f(this,z);f(this,k);f(this,O);f(this,$);f(this,q);f(this,I);f(this,G);f(this,Y);f(this,st);f(this,D);f(this,mt);f(this,rt,()=>{});f(this,J,()=>{});f(this,bt,()=>{});f(this,j,()=>false);f(this,ot,e=>{});f(this,wt,(e,i,s)=>{});f(this,yt,(e,i,s,h)=>{if(s||h)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0});d(this,Ut,"LRUCache");let{max:i=0,ttl:s,ttlResolution:h$1=1,ttlAutopurge:o,updateAgeOnGet:n,updateAgeOnHas:f$1,allowStale:c,dispose:m,onInsert:L,disposeAfter:y,noDisposeOnSet:Q,noUpdateTTL:N,maxSize:X=0,maxEntrySize:_=0,sizeCalculation:w,fetchMethod:d$1,memoMethod:C,noDeleteOnFetchRejection:x,noDeleteOnStaleGet:R,allowStaleOnFetchRejection:T,allowStaleOnFetchAbort:at,ignoreFetchAbort:lt,perf:_t}=e$1;if(_t!==void 0&&typeof _t?.now!="function")throw new TypeError("perf option must have a now() method if specified");if(g(this,K,_t??Pt),i!==0&&!Z(i))throw new TypeError("max option must be a nonnegative integer");let ft=i?Nt(i):Array;if(!ft)throw new Error("invalid max value: "+i);if(g(this,V,i),g(this,M,X),this.maxEntrySize=_||e(this,M),this.sizeCalculation=w,this.sizeCalculation){if(!e(this,M)&&!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,pt,C),d$1!==void 0&&typeof d$1!="function")throw new TypeError("fetchMethod must be a function if specified");if(g(this,gt,d$1),g(this,st,!!d$1),g(this,F,new Map),g(this,b,new Array(i).fill(void 0)),g(this,u,new Array(i).fill(void 0)),g(this,W,new ft(i)),g(this,U,new ft(i)),g(this,v,0),g(this,z,0),g(this,k,Ct.create(i)),g(this,E,0),g(this,B,0),typeof m=="function"&&g(this,P,m),typeof L=="function"&&g(this,ht,L),typeof y=="function"?(g(this,H,y),g(this,O,[])):(g(this,H,void 0),g(this,O,void 0)),g(this,Y,!!e(this,P)),g(this,mt,!!e(this,ht)),g(this,D,!!e(this,H)),this.noDisposeOnSet=!!Q,this.noUpdateTTL=!!N,this.noDeleteOnFetchRejection=!!x,this.allowStaleOnFetchRejection=!!T,this.allowStaleOnFetchAbort=!!at,this.ignoreFetchAbort=!!lt,this.maxEntrySize!==0){if(e(this,M)!==0&&!Z(e(this,M)))throw new TypeError("maxSize must be a positive integer if specified");if(!Z(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");h(this,r,Vt).call(this);}if(this.allowStale=!!c,this.noDeleteOnStaleGet=!!R,this.updateAgeOnGet=!!n,this.updateAgeOnHas=!!f$1,this.ttlResolution=Z(h$1)||h$1===0?h$1:1,this.ttlAutopurge=!!o,this.ttl=s||0,this.ttl){if(!Z(this.ttl))throw new TypeError("ttl must be a positive integer if specified");h(this,r,Rt).call(this);}if(e(this,V)===0&&this.ttl===0&&e(this,M)===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!e(this,V)&&!e(this,M)){let ct="LRU_CACHE_UNBOUNDED";Ht(ct)&&(Gt.add(ct),jt("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",ct,xt));}}get perf(){return e(this,K)}static unsafeExposeInternals(e$1){return {starts:e(e$1,q),ttls:e(e$1,I),autopurgeTimers:e(e$1,G),sizes:e(e$1,$),keyMap:e(e$1,F),keyList:e(e$1,b),valList:e(e$1,u),next:e(e$1,W),prev:e(e$1,U),get head(){return e(e$1,v)},get tail(){return e(e$1,z)},free:e(e$1,k),isBackgroundFetch:i=>{var s;return h(s=e$1,r,S).call(s,i)},backgroundFetch:(i,s,h$1,o)=>{var n;return h(n=e$1,r,Ft).call(n,i,s,h$1,o)},moveToTail:i=>{var s;return h(s=e$1,r,St).call(s,i)},indexes:i=>{var s;return h(s=e$1,r,tt).call(s,i)},rindexes:i=>{var s;return h(s=e$1,r,et).call(s,i)},isStale:i=>{var s;return e(s=e$1,j).call(s,i)}}}get max(){return e(this,V)}get maxSize(){return e(this,M)}get calculatedSize(){return e(this,B)}get size(){return e(this,E)}get fetchMethod(){return e(this,gt)}get memoMethod(){return e(this,pt)}get dispose(){return e(this,P)}get onInsert(){return e(this,ht)}get disposeAfter(){return e(this,H)}getRemainingTTL(e$1){return e(this,F).has(e$1)?1/0:0}*entries(){for(let e$1 of h(this,r,tt).call(this))e(this,u)[e$1]!==void 0&&e(this,b)[e$1]!==void 0&&!h(this,r,S).call(this,e(this,u)[e$1])&&(yield [e(this,b)[e$1],e(this,u)[e$1]]);}*rentries(){for(let e$1 of h(this,r,et).call(this))e(this,u)[e$1]!==void 0&&e(this,b)[e$1]!==void 0&&!h(this,r,S).call(this,e(this,u)[e$1])&&(yield [e(this,b)[e$1],e(this,u)[e$1]]);}*keys(){for(let e$1 of h(this,r,tt).call(this)){let i=e(this,b)[e$1];i!==void 0&&!h(this,r,S).call(this,e(this,u)[e$1])&&(yield i);}}*rkeys(){for(let e$1 of h(this,r,et).call(this)){let i=e(this,b)[e$1];i!==void 0&&!h(this,r,S).call(this,e(this,u)[e$1])&&(yield i);}}*values(){for(let e$1 of h(this,r,tt).call(this))e(this,u)[e$1]!==void 0&&!h(this,r,S).call(this,e(this,u)[e$1])&&(yield e(this,u)[e$1]);}*rvalues(){for(let e$1 of h(this,r,et).call(this))e(this,u)[e$1]!==void 0&&!h(this,r,S).call(this,e(this,u)[e$1])&&(yield e(this,u)[e$1]);}[(It=Symbol.iterator,Ut=Symbol.toStringTag,It)](){return this.entries()}find(e$1,i={}){for(let s of h(this,r,tt).call(this)){let h$1=e(this,u)[s],o=h(this,r,S).call(this,h$1)?h$1.__staleWhileFetching:h$1;if(o!==void 0&&e$1(o,e(this,b)[s],this))return this.get(e(this,b)[s],i)}}forEach(e$1,i=this){for(let s of h(this,r,tt).call(this)){let h$1=e(this,u)[s],o=h(this,r,S).call(this,h$1)?h$1.__staleWhileFetching:h$1;o!==void 0&&e$1.call(i,o,e(this,b)[s],this);}}rforEach(e$1,i=this){for(let s of h(this,r,et).call(this)){let h$1=e(this,u)[s],o=h(this,r,S).call(this,h$1)?h$1.__staleWhileFetching:h$1;o!==void 0&&e$1.call(i,o,e(this,b)[s],this);}}purgeStale(){let e$1=false;for(let i of h(this,r,et).call(this,{allowStale:true}))e(this,j).call(this,i)&&(h(this,r,it).call(this,e(this,b)[i],"expire"),e$1=true);return e$1}info(e$1){let i=e(this,F).get(e$1);if(i===void 0)return;let s=e(this,u)[i],h$1=h(this,r,S).call(this,s)?s.__staleWhileFetching:s;if(h$1===void 0)return;let o={value:h$1};if(e(this,I)&&e(this,q)){let n=e(this,I)[i],f=e(this,q)[i];if(n&&f){let c=n-(e(this,K).now()-f);o.ttl=c,o.start=Date.now();}}return e(this,$)&&(o.size=e(this,$)[i]),o}dump(){let e$1=[];for(let i of h(this,r,tt).call(this,{allowStale:true})){let s=e(this,b)[i],h$1=e(this,u)[i],o=h(this,r,S).call(this,h$1)?h$1.__staleWhileFetching:h$1;if(o===void 0||s===void 0)continue;let n={value:o};if(e(this,I)&&e(this,q)){n.ttl=e(this,I)[i];let f=e(this,K).now()-e(this,q)[i];n.start=Math.floor(Date.now()-f);}e(this,$)&&(n.size=e(this,$)[i]),e$1.unshift([s,n]);}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 Q,N,X,_;if(i$1===void 0)return this.delete(e$1),this;let{ttl:h$1=this.ttl,start:o,noDisposeOnSet:n=this.noDisposeOnSet,sizeCalculation:f=this.sizeCalculation,status:c}=s,{noUpdateTTL:m=this.noUpdateTTL}=s,L=e(this,yt).call(this,e$1,i$1,s.size||0,f);if(this.maxEntrySize&&L>this.maxEntrySize)return c&&(c.set="miss",c.maxEntrySizeExceeded=true),h(this,r,it).call(this,e$1,"set"),this;let y=e(this,E)===0?void 0:e(this,F).get(e$1);if(y===void 0)y=e(this,E)===0?e(this,z):e(this,k).length!==0?e(this,k).pop():e(this,E)===e(this,V)?h(this,r,Tt).call(this,false):e(this,E),e(this,b)[y]=e$1,e(this,u)[y]=i$1,e(this,F).set(e$1,y),e(this,W)[e(this,z)]=y,e(this,U)[y]=e(this,z),g(this,z,y),i(this,E)._++,e(this,wt).call(this,y,L,c),c&&(c.set="add"),m=false,e(this,mt)&&((Q=e(this,ht))==null||Q.call(this,i$1,e$1,"add"));else {h(this,r,St).call(this,y);let w=e(this,u)[y];if(i$1!==w){if(e(this,st)&&h(this,r,S).call(this,w)){w.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:d}=w;d!==void 0&&!n&&(e(this,Y)&&((N=e(this,P))==null||N.call(this,d,e$1,"set")),e(this,D)&&e(this,O)?.push([d,e$1,"set"]));}else n||(e(this,Y)&&((X=e(this,P))==null||X.call(this,w,e$1,"set")),e(this,D)&&e(this,O)?.push([w,e$1,"set"]));if(e(this,ot).call(this,y),e(this,wt).call(this,y,L,c),e(this,u)[y]=i$1,c){c.set="replace";let d=w&&h(this,r,S).call(this,w)?w.__staleWhileFetching:w;d!==void 0&&(c.oldValue=d);}}else c&&(c.set="update");e(this,mt)&&this.onInsert?.(i$1,e$1,i$1===w?"update":"replace");}if(h$1!==0&&!e(this,I)&&h(this,r,Rt).call(this),e(this,I)&&(m||e(this,bt).call(this,y,h$1,o),c&&e(this,J).call(this,c,y)),!n&&e(this,D)&&e(this,O)){let w=e(this,O),d;for(;d=w?.shift();)(_=e(this,H))==null||_.call(this,...d);}return this}pop(){var e$1;try{for(;e(this,E);){let i=e(this,u)[e(this,v)];if(h(this,r,Tt).call(this,!0),h(this,r,S).call(this,i)){if(i.__staleWhileFetching)return i.__staleWhileFetching}else if(i!==void 0)return i}}finally{if(e(this,D)&&e(this,O)){let i=e(this,O),s;for(;s=i?.shift();)(e$1=e(this,H))==null||e$1.call(this,...s);}}}has(e$1,i={}){let{updateAgeOnHas:s=this.updateAgeOnHas,status:h$1}=i,o=e(this,F).get(e$1);if(o!==void 0){let n=e(this,u)[o];if(h(this,r,S).call(this,n)&&n.__staleWhileFetching===void 0)return false;if(e(this,j).call(this,o))h$1&&(h$1.has="stale",e(this,J).call(this,h$1,o));else return s&&e(this,rt).call(this,o),h$1&&(h$1.has="hit",e(this,J).call(this,h$1,o)),true}else h$1&&(h$1.has="miss");return false}peek(e$1,i={}){let{allowStale:s=this.allowStale}=i,h$1=e(this,F).get(e$1);if(h$1===void 0||!s&&e(this,j).call(this,h$1))return;let o=e(this,u)[h$1];return h(this,r,S).call(this,o)?o.__staleWhileFetching:o}async fetch(e$1,i={}){let{allowStale:s=this.allowStale,updateAgeOnGet:h$1=this.updateAgeOnGet,noDeleteOnStaleGet:o=this.noDeleteOnStaleGet,ttl:n=this.ttl,noDisposeOnSet:f=this.noDisposeOnSet,size:c=0,sizeCalculation:m=this.sizeCalculation,noUpdateTTL:L=this.noUpdateTTL,noDeleteOnFetchRejection:y=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:Q=this.allowStaleOnFetchRejection,ignoreFetchAbort:N=this.ignoreFetchAbort,allowStaleOnFetchAbort:X=this.allowStaleOnFetchAbort,context:_,forceRefresh:w=false,status:d,signal:C}=i;if(!e(this,st))return d&&(d.fetch="get"),this.get(e$1,{allowStale:s,updateAgeOnGet:h$1,noDeleteOnStaleGet:o,status:d});let x={allowStale:s,updateAgeOnGet:h$1,noDeleteOnStaleGet:o,ttl:n,noDisposeOnSet:f,size:c,sizeCalculation:m,noUpdateTTL:L,noDeleteOnFetchRejection:y,allowStaleOnFetchRejection:Q,allowStaleOnFetchAbort:X,ignoreFetchAbort:N,status:d,signal:C},R=e(this,F).get(e$1);if(R===void 0){d&&(d.fetch="miss");let T=h(this,r,Ft).call(this,e$1,R,x,_);return T.__returned=T}else {let T=e(this,u)[R];if(h(this,r,S).call(this,T)){let ct=s&&T.__staleWhileFetching!==void 0;return d&&(d.fetch="inflight",ct&&(d.returnedStale=true)),ct?T.__staleWhileFetching:T.__returned=T}let at=e(this,j).call(this,R);if(!w&&!at)return d&&(d.fetch="hit"),h(this,r,St).call(this,R),h$1&&e(this,rt).call(this,R),d&&e(this,J).call(this,d,R),T;let lt=h(this,r,Ft).call(this,e$1,R,x,_),ft=lt.__staleWhileFetching!==void 0&&s;return d&&(d.fetch=at?"stale":"refresh",ft&&at&&(d.returnedStale=true)),ft?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,pt);if(!s)throw new Error("no memoMethod provided to constructor");let{context:h,forceRefresh:o,...n}=i,f=this.get(e$1,n);if(!o&&f!==void 0)return f;let c=s(e$1,f,{options:n,context:h});return this.set(e$1,c,n),c}get(e$1,i={}){let{allowStale:s=this.allowStale,updateAgeOnGet:h$1=this.updateAgeOnGet,noDeleteOnStaleGet:o=this.noDeleteOnStaleGet,status:n}=i,f=e(this,F).get(e$1);if(f!==void 0){let c=e(this,u)[f],m=h(this,r,S).call(this,c);return n&&e(this,J).call(this,n,f),e(this,j).call(this,f)?(n&&(n.get="stale"),m?(n&&s&&c.__staleWhileFetching!==void 0&&(n.returnedStale=true),s?c.__staleWhileFetching:void 0):(o||h(this,r,it).call(this,e$1,"expire"),n&&s&&(n.returnedStale=true),s?c:void 0)):(n&&(n.get="hit"),m?c.__staleWhileFetching:(h(this,r,St).call(this,f),h$1&&e(this,rt).call(this,f),c))}else n&&(n.get="miss");}delete(e){return h(this,r,it).call(this,e,"delete")}clear(){return h(this,r,Lt).call(this,"delete")}};V=new WeakMap,M=new WeakMap,P=new WeakMap,ht=new WeakMap,H=new WeakMap,gt=new WeakMap,pt=new WeakMap,K=new WeakMap,E=new WeakMap,B=new WeakMap,F=new WeakMap,b=new WeakMap,u=new WeakMap,W=new WeakMap,U=new WeakMap,v=new WeakMap,z=new WeakMap,k=new WeakMap,O=new WeakMap,$=new WeakMap,q=new WeakMap,I=new WeakMap,G=new WeakMap,Y=new WeakMap,st=new WeakMap,D=new WeakMap,mt=new WeakMap,r=new WeakSet,Rt=function(){let e$1=new ut(e(this,V)),i=new ut(e(this,V));g(this,I,e$1),g(this,q,i);let s=this.ttlAutopurge?new Array(e(this,V)):void 0;g(this,G,s),g(this,bt,(n,f,c=e(this,K).now())=>{if(i[n]=f!==0?c:0,e$1[n]=f,s?.[n]&&(clearTimeout(s[n]),s[n]=void 0),f!==0&&s){let m=setTimeout(()=>{e(this,j).call(this,n)&&h(this,r,it).call(this,e(this,b)[n],"expire");},f+1);m.unref&&m.unref(),s[n]=m;}}),g(this,rt,n=>{i[n]=e$1[n]!==0?e(this,K).now():0;}),g(this,J,(n,f)=>{if(e$1[f]){let c=e$1[f],m=i[f];if(!c||!m)return;n.ttl=c,n.start=m,n.now=h$1||o();let L=n.now-m;n.remainingTTL=c-L;}});let h$1=0,o=()=>{let n=e(this,K).now();if(this.ttlResolution>0){h$1=n;let f=setTimeout(()=>h$1=0,this.ttlResolution);f.unref&&f.unref();}return n};this.getRemainingTTL=n=>{let f=e(this,F).get(n);if(f===void 0)return 0;let c=e$1[f],m=i[f];if(!c||!m)return 1/0;let L=(h$1||o())-m;return c-L},g(this,j,n=>{let f=i[n],c=e$1[n];return !!c&&!!f&&(h$1||o())-f>c});},rt=new WeakMap,J=new WeakMap,bt=new WeakMap,j=new WeakMap,Vt=function(){let e$1=new ut(e(this,V));g(this,B,0),g(this,$,e$1),g(this,ot,i=>{g(this,B,e(this,B)-e$1[i]),e$1[i]=0;}),g(this,yt,(i,s,h$1,o)=>{if(h(this,r,S).call(this,s))return 0;if(!Z(h$1))if(o){if(typeof o!="function")throw new TypeError("sizeCalculation must be a function");if(h$1=o(s,i),!Z(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,wt,(i,s,h$1)=>{if(e$1[i]=s,e(this,M)){let o=e(this,M)-e$1[i];for(;e(this,B)>o;)h(this,r,Tt).call(this,true);}g(this,B,e(this,B)+e$1[i]),h$1&&(h$1.entrySize=s,h$1.totalCalculatedSize=e(this,B));});},ot=new WeakMap,wt=new WeakMap,yt=new WeakMap,tt=function*({allowStale:e$1=this.allowStale}={}){if(e(this,E))for(let i=e(this,z);!(!h(this,r,Wt).call(this,i)||((e$1||!e(this,j).call(this,i))&&(yield i),i===e(this,v)));)i=e(this,U)[i];},et=function*({allowStale:e$1=this.allowStale}={}){if(e(this,E))for(let i=e(this,v);!(!h(this,r,Wt).call(this,i)||((e$1||!e(this,j).call(this,i))&&(yield i),i===e(this,z)));)i=e(this,W)[i];},Wt=function(e$1){return e$1!==void 0&&e(this,F).get(e(this,b)[e$1])===e$1},Tt=function(e$1){var o;let i$1=e(this,v),s=e(this,b)[i$1],h$1=e(this,u)[i$1];return e(this,st)&&h(this,r,S).call(this,h$1)?h$1.__abortController.abort(new Error("evicted")):(e(this,Y)||e(this,D))&&(e(this,Y)&&((o=e(this,P))==null||o.call(this,h$1,s,"evict")),e(this,D)&&e(this,O)?.push([h$1,s,"evict"])),e(this,ot).call(this,i$1),e(this,G)?.[i$1]&&(clearTimeout(e(this,G)[i$1]),e(this,G)[i$1]=void 0),e$1&&(e(this,b)[i$1]=void 0,e(this,u)[i$1]=void 0,e(this,k).push(i$1)),e(this,E)===1?(g(this,v,g(this,z,0)),e(this,k).length=0):g(this,v,e(this,W)[i$1]),e(this,F).delete(s),i(this,E)._--,i$1},Ft=function(e$1,i,s,h$1){let o=i===void 0?void 0:e(this,u)[i];if(h(this,r,S).call(this,o))return o;let n=new Et,{signal:f}=s;f?.addEventListener("abort",()=>n.abort(f.reason),{signal:n.signal});let c={signal:n.signal,options:s,context:h$1},m=(_,w=false)=>{let{aborted:d}=n.signal,C=s.ignoreFetchAbort&&_!==void 0,x=s.ignoreFetchAbort||!!(s.allowStaleOnFetchAbort&&_!==void 0);if(s.status&&(d&&!w?(s.status.fetchAborted=true,s.status.fetchError=n.signal.reason,C&&(s.status.fetchAbortIgnored=true)):s.status.fetchResolved=true),d&&!C&&!w)return y(n.signal.reason,x);let R=N,T=e(this,u)[i];return (T===N||C&&w&&T===void 0)&&(_===void 0?R.__staleWhileFetching!==void 0?e(this,u)[i]=R.__staleWhileFetching:h(this,r,it).call(this,e$1,"fetch"):(s.status&&(s.status.fetchUpdated=true),this.set(e$1,_,c.options))),_},L=_=>(s.status&&(s.status.fetchRejected=true,s.status.fetchError=_),y(_,false)),y=(_,w)=>{let{aborted:d}=n.signal,C=d&&s.allowStaleOnFetchAbort,x=C||s.allowStaleOnFetchRejection,R=x||s.noDeleteOnFetchRejection,T=N;if(e(this,u)[i]===N&&(!R||!w&&T.__staleWhileFetching===void 0?h(this,r,it).call(this,e$1,"fetch"):C||(e(this,u)[i]=T.__staleWhileFetching)),x)return s.status&&T.__staleWhileFetching!==void 0&&(s.status.returnedStale=true),T.__staleWhileFetching;if(T.__returned===T)throw _},Q=(_,w)=>{var C;let d=(C=e(this,gt))==null?void 0:C.call(this,e$1,o,c);d&&d instanceof Promise&&d.then(x=>_(x===void 0?void 0:x),w),n.signal.addEventListener("abort",()=>{(!s.ignoreFetchAbort||s.allowStaleOnFetchAbort)&&(_(void 0),s.allowStaleOnFetchAbort&&(_=x=>m(x,true)));});};s.status&&(s.status.fetchDispatched=true);let N=new Promise(Q).then(m,L),X=Object.assign(N,{__abortController:n,__staleWhileFetching:o,__returned:void 0});return i===void 0?(this.set(e$1,X,{...c.options,status:void 0}),i=e(this,F).get(e$1)):e(this,u)[i]=X,X},S=function(e$1){if(!e(this,st))return false;let i=e$1;return !!i&&i instanceof Promise&&i.hasOwnProperty("__staleWhileFetching")&&i.__abortController instanceof Et},Dt=function(e$1,i){e(this,U)[i]=e$1,e(this,W)[e$1]=i;},St=function(e$1){e$1!==e(this,z)&&(e$1===e(this,v)?g(this,v,e(this,W)[e$1]):h(this,r,Dt).call(this,e(this,U)[e$1],e(this,W)[e$1]),h(this,r,Dt).call(this,e(this,z),e$1),g(this,z,e$1));},it=function(e$1,i$1){var h$1,o;let s=false;if(e(this,E)!==0){let n=e(this,F).get(e$1);if(n!==void 0)if(e(this,G)?.[n]&&(clearTimeout(e(this,G)?.[n]),e(this,G)[n]=void 0),s=true,e(this,E)===1)h(this,r,Lt).call(this,i$1);else {e(this,ot).call(this,n);let f=e(this,u)[n];if(h(this,r,S).call(this,f)?f.__abortController.abort(new Error("deleted")):(e(this,Y)||e(this,D))&&(e(this,Y)&&((h$1=e(this,P))==null||h$1.call(this,f,e$1,i$1)),e(this,D)&&e(this,O)?.push([f,e$1,i$1])),e(this,F).delete(e$1),e(this,b)[n]=void 0,e(this,u)[n]=void 0,n===e(this,z))g(this,z,e(this,U)[n]);else if(n===e(this,v))g(this,v,e(this,W)[n]);else {let c=e(this,U)[n];e(this,W)[c]=e(this,W)[n];let m=e(this,W)[n];e(this,U)[m]=e(this,U)[n];}i(this,E)._--,e(this,k).push(n);}}if(e(this,D)&&e(this,O)?.length){let n=e(this,O),f;for(;f=n?.shift();)(o=e(this,H))==null||o.call(this,...f);}return s},Lt=function(e$1){var i,s;for(let h$1 of h(this,r,et).call(this,{allowStale:true})){let o=e(this,u)[h$1];if(h(this,r,S).call(this,o))o.__abortController.abort(new Error("deleted"));else {let n=e(this,b)[h$1];e(this,Y)&&((i=e(this,P))==null||i.call(this,o,n,e$1)),e(this,D)&&e(this,O)?.push([o,n,e$1]);}}if(e(this,F).clear(),e(this,u).fill(void 0),e(this,b).fill(void 0),e(this,I)&&e(this,q)){e(this,I).fill(0),e(this,q).fill(0);for(let h of e(this,G)??[])h!==void 0&&clearTimeout(h);e(this,G)?.fill(void 0);}if(e(this,$)&&e(this,$).fill(0),g(this,v,0),g(this,z,0),e(this,k).length=0,g(this,B,0),g(this,E,0),e(this,D)&&e(this,O)){let h=e(this,O),o;for(;o=h?.shift();)(s=e(this,H))==null||s.call(this,...o);}};var zt=xt;var Ot=class{constructor(e){d(this,"cache");d(this,"map",new Map);this.cache=new zt({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{Ot as a};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import {a}from'./chunk-
|
|
1
|
+
import {a}from'./chunk-GFG3MDHE.mjs';import {d,k,j}from'./chunk-GNJIUFU2.mjs';import {GameUnifier}from'@drincs/pixi-vn/unifier';var s=class s{constructor(){}static clearOldTempVariables(e){s.tempStorageDeadlines.forEach((t,a)=>{t>e&&(s.tempStorage.delete(a),s.tempStorageDeadlines.delete(a),s.storage.cache.delete(a));});}static setVariable(e,t){let a=s.tempStorage.has(e);t==null?(s.storage.map.delete(e),!a&&s.storage.cache.delete(e)):(s.storage.map.set(e,t),!a&&s.storage.cache.set(e,t));}static getVariable(e){let t=s.storage.cache.get(e);return t===void 0&&(t=s.tempStorage.get(e)),t===void 0&&(t=s.storage.map.get(e)),t===void 0&&(t=s.default.get(e)),k(t)}static removeVariable(e){s.storage.delete(e);}static setFlag(e,t){if(t)this.flags.includes(e)||this.flags.push(e);else {let a=this.flags.indexOf(e);a>-1&&this.flags.splice(a,1);}}static getFlag(e){return this.flags.includes(e)}};d(s,"storage",new a({cacheSize:20})),d(s,"default",new a({cacheSize:20})),d(s,"flags",Array()),d(s,"tempStorage",new Map),d(s,"tempStorageDeadlines",new Map);var r=s;var n=class{get storage(){return r.storage.map}get cache(){return r.storage.cache}get flags(){return r.flags}get tempStorage(){return r.tempStorage}get tempStorageDeadlines(){return r.tempStorageDeadlines}set default(e){Object.entries(e).forEach(([t,a])=>{r.default.set(t,a);});}set(e,t){return r.setVariable(e,t)}get(e){return r.getVariable(e)}remove(e){return r.removeVariable(e)}setTempVariable(e,t){if(t==null){this.removeTempVariable(e);return}else r.tempStorage.set(e,t),r.storage.cache.set(e,t),r.tempStorageDeadlines.has(e)||r.tempStorageDeadlines.set(e,GameUnifier.openedLabels);}removeTempVariable(e){r.tempStorage.has(e)&&(r.tempStorage.delete(e),r.tempStorageDeadlines.delete(e),r.storage.cache.delete(e));}setFlag(e,t){return r.setFlag(e,t)}getFlag(e){return r.getFlag(e)}clear(){this.storage.clear(),this.cache.clear(),r.flags=[],r.tempStorage.clear(),r.tempStorageDeadlines.clear();}export(){let e=[];[...this.storage.keys()].forEach(o=>{e.push({key:o,value:this.storage.get(o)});});let t=[];[...r.tempStorage.keys()].forEach(o=>{t.push({key:o,value:r.tempStorage.get(o)});});let a=[];return [...r.tempStorageDeadlines.keys()].forEach(o=>{a.push({key:o,value:r.tempStorageDeadlines.get(o)});}),k({base:e,temp:t,tempDeadlines:a,flags:r.flags})}restore(e){this.clear();try{e?(Array.isArray(e)&&e.forEach(t=>{if(t.key==="___temp_storage___"){let a=t.value;Object.entries(a).forEach(([o,g])=>{r.tempStorage.set(o,g);});}else if(t.key==="___temp_storage_deadlines___"){let a=t.value;Object.entries(a).forEach(([o,g])=>{r.tempStorageDeadlines.set(o,g);});}else t.key==="___flags___"?t.value.forEach(o=>{r.flags.push(o);}):this.storage.set(t.key,t.value);}),"base"in e&&"temp"in e&&"tempDeadlines"in e?(e.base?.forEach(t=>{this.storage.set(t.key,t.value);}),e.temp?.forEach(t=>{r.tempStorage.set(t.key,t.value);}),e.tempDeadlines?.forEach(t=>{r.tempStorageDeadlines.set(t.key,t.value);})):Object.entries(e).forEach(([t,a])=>{t==="___temp_storage___"?Object.entries(a).forEach(([o,g])=>{r.tempStorage.set(o,g);}):t==="___temp_storage_deadlines___"?Object.entries(a).forEach(([o,g])=>{r.tempStorageDeadlines.set(o,g);}):t==="___flags___"?a.forEach(o=>{r.flags.push(o);}):this.storage.set(t,a);})):j.warn("No storage data found");}catch(t){j.error("Error importing data",t);}}};var p=class{constructor(e,t){d(this,"id");d(this,"categoryId");this.categoryId=e,this.id=t;}setStorageProperty(e,t){let a=r.getVariable(this.categoryId);a||(a={}),a.hasOwnProperty(this.id)||(a[this.id]={}),t==null?a[this.id].hasOwnProperty(e)&&delete a[this.id][e]:a[this.id]={...a[this.id],[e]:t},Object.keys(a[this.id]).length===0&&delete a[this.id],r.setVariable(this.categoryId,a);}getStorageProperty(e,t=this.id){let a=r.getVariable(this.categoryId);if(a&&a.hasOwnProperty(t)&&a[t].hasOwnProperty(e))return a[t][e]}};var v=new n;export{r as a,p as b,v as c};
|
package/dist/history.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
'use strict';var unifier=require('@drincs/pixi-vn/unifier');var Qt=Object.defineProperty;var Pt=f=>{throw TypeError(f)};var Zt=(f,t,i)=>t in f?Qt(f,t,{enumerable:true,configurable:true,writable:true,value:i}):f[t]=i;var w=(f,t,i)=>Zt(f,typeof t!="symbol"?t+"":t,i),Mt=(f,t,i)=>t.has(f)||Pt("Cannot "+i);var e=(f,t,i)=>(Mt(f,t,"read from private field"),i?i.call(f):t.get(f)),S=(f,t,i)=>t.has(f)?Pt("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(f):t.set(f,i),u=(f,t,i,s)=>(Mt(f,t,"write to private field"),t.set(f,i),i),c=(f,t,i)=>(Mt(f,t,"access private method"),i);var Dt=(f,t,i,s)=>({set _(r){u(f,t,r);},get _(){return e(f,t,s)}});var te={Date:true,RegExp:true,String:true,Number:true};function Ct(f,t,i={cyclesFix:true},s=[]){let r=[],o=Array.isArray(f);for(let a in f){let h=f[a],y=o?+a:a;if(!(a in t)){r.push({type:"REMOVE",path:[y],oldValue:f[a]});continue}let g=t[a],b=typeof h=="object"&&typeof g=="object"&&Array.isArray(h)===Array.isArray(g);h&&g&&b&&!te[Object.getPrototypeOf(h)?.constructor?.name]&&(!i.cyclesFix||!s.includes(h))?r.push.apply(r,Ct(h,g,i,i.cyclesFix?s.concat([h]):[]).map(_=>(_.path.unshift(y),_))):h!==g&&!(Number.isNaN(h)&&Number.isNaN(g))&&!(b&&(isNaN(h)?h+""==g+"":+h==+g))&&r.push({path:[y],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 T;(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)))(T||(T={}));function et(f){try{if(typeof f>"u")return f;let t=JSON.stringify(f);return JSON.parse(t)}catch(t){throw T.error("Error creating exportable element",f,t),new Error("[Pixi\u2019VN] Error creating exportable element")}}function Ut(f,t){let i=et(f);return t.length>1&&"type"in t[0]&&(t=t.reverse()),t.forEach(s=>{"type"in s?ee(i,s):ie(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];}):T.warn("No path found, skipping diff",t);}function ie(f,t){let i=f;t.path&&t.path.length>0?t.path.forEach((s,r)=>{if(t.path&&r===t.path.length-1){if(t.kind==="E"||t.kind==="D")i[s]=t.lhs;else if(t.kind==="N")Number.isInteger(s)?Array.isArray(i)&&i.splice(s,1):typeof s=="string"&&delete i[s];else if(t.kind==="A"){let o=t.index;t.item.kind==="N"?i[s].splice(o,1):t.item.kind==="E"||t.item.kind==="D"?i[s][o]=t.item.lhs:t.item.kind==="A"?T.warn("Nested array found, skipping diff",t):T.warn("No array found, skipping diff",t);}}else i=i[s];}):T.warn("No path found, skipping diff",t);}var se=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,qt=new Set,Lt=typeof process=="object"&&process?process:{},Jt=(f,t,i,s)=>{typeof Lt.emitWarning=="function"?Lt.emitWarning(f,t,i,s):console.error(`[${i}] ${t}: ${f}`);},It=globalThis.AbortController,Kt=globalThis.AbortSignal;if(typeof It>"u"){Kt=class{constructor(){w(this,"onabort");w(this,"_onabort",[]);w(this,"reason");w(this,"aborted",false);}addEventListener(s,r){this._onabort.push(r);}},It=class{constructor(){w(this,"signal",new Kt);t();}abort(s){if(!this.signal.aborted){this.signal.reason=s,this.signal.aborted=true;for(let r of this.signal._onabort)r(s);this.signal.onabort?.(s);}}};let f=Lt.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",t=()=>{f&&(f=false,Jt("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 re=f=>!qt.has(f);var rt=f=>f&&f===Math.floor(f)&&f>0&&isFinite(f),Yt=f=>rt(f)?f<=Math.pow(2,8)?Uint8Array:f<=Math.pow(2,16)?Uint16Array:f<=Math.pow(2,32)?Uint32Array:f<=Number.MAX_SAFE_INTEGER?gt:null:null,gt=class extends Array{constructor(t){super(t),this.fill(0);}},St,ft=class ft{constructor(t,i){w(this,"heap");w(this,"length");if(!e(ft,St))throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new i(t),this.length=0;}static create(t){let i=Yt(t);if(!i)return [];u(ft,St,true);let s=new ft(t,i);return u(ft,St,false),s}push(t){this.heap[this.length++]=t;}pop(){return this.heap[--this.length]}};St=new WeakMap,S(ft,St,false);var kt=ft,$t,Bt,K,G,$,ct,B,bt,wt,q,D,J,O,H,p,N,R,z,C,Y,F,X,Q,W,V,Z,ht,M,_t,l,Gt,ut,st,Tt,j,Xt,dt,At,xt,nt,ot,Rt,Ft,zt,E,Wt,Ht,at,Vt,jt=class jt{constructor(t){S(this,l);S(this,K);S(this,G);S(this,$);S(this,ct);S(this,B);S(this,bt);S(this,wt);S(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");S(this,D);S(this,J);S(this,O);S(this,H);S(this,p);S(this,N);S(this,R);S(this,z);S(this,C);S(this,Y);S(this,F);S(this,X);S(this,Q);S(this,W);S(this,V);S(this,Z);S(this,ht);S(this,M);S(this,_t);S(this,ut,()=>{});S(this,st,()=>{});S(this,Tt,()=>{});S(this,j,()=>false);S(this,dt,t=>{});S(this,At,(t,i,s)=>{});S(this,xt,(t,i,s,r)=>{if(s||r)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0});w(this,$t,"LRUCache");let{max:i=0,ttl:s,ttlResolution:r=1,ttlAutopurge:o,updateAgeOnGet:n,updateAgeOnHas:a,allowStale:h,dispose:y,onInsert:g,disposeAfter:b,noDisposeOnSet:_,noUpdateTTL:P,maxSize:tt=0,maxEntrySize:x=0,sizeCalculation:A,fetchMethod:m,memoMethod:I,noDeleteOnFetchRejection:L,noDeleteOnStaleGet:v,allowStaleOnFetchRejection:U,allowStaleOnFetchAbort:Et,ignoreFetchAbort:pt,perf:Ot}=t;if(Ot!==void 0&&typeof Ot?.now!="function")throw new TypeError("perf option must have a now() method if specified");if(u(this,q,Ot??se),i!==0&&!rt(i))throw new TypeError("max option must be a nonnegative integer");let yt=i?Yt(i):Array;if(!yt)throw new Error("invalid max value: "+i);if(u(this,K,i),u(this,G,tt),this.maxEntrySize=x||e(this,G),this.sizeCalculation=A,this.sizeCalculation){if(!e(this,G)&&!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,wt,I),m!==void 0&&typeof m!="function")throw new TypeError("fetchMethod must be a function if specified");if(u(this,bt,m),u(this,ht,!!m),u(this,O,new Map),u(this,H,new Array(i).fill(void 0)),u(this,p,new Array(i).fill(void 0)),u(this,N,new yt(i)),u(this,R,new yt(i)),u(this,z,0),u(this,C,0),u(this,Y,kt.create(i)),u(this,D,0),u(this,J,0),typeof y=="function"&&u(this,$,y),typeof g=="function"&&u(this,ct,g),typeof b=="function"?(u(this,B,b),u(this,F,[])):(u(this,B,void 0),u(this,F,void 0)),u(this,Z,!!e(this,$)),u(this,_t,!!e(this,ct)),u(this,M,!!e(this,B)),this.noDisposeOnSet=!!_,this.noUpdateTTL=!!P,this.noDeleteOnFetchRejection=!!L,this.allowStaleOnFetchRejection=!!U,this.allowStaleOnFetchAbort=!!Et,this.ignoreFetchAbort=!!pt,this.maxEntrySize!==0){if(e(this,G)!==0&&!rt(e(this,G)))throw new TypeError("maxSize must be a positive integer if specified");if(!rt(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");c(this,l,Xt).call(this);}if(this.allowStale=!!h,this.noDeleteOnStaleGet=!!v,this.updateAgeOnGet=!!n,this.updateAgeOnHas=!!a,this.ttlResolution=rt(r)||r===0?r:1,this.ttlAutopurge=!!o,this.ttl=s||0,this.ttl){if(!rt(this.ttl))throw new TypeError("ttl must be a positive integer if specified");c(this,l,Gt).call(this);}if(e(this,K)===0&&this.ttl===0&&e(this,G)===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!e(this,K)&&!e(this,G)){let mt="LRU_CACHE_UNBOUNDED";re(mt)&&(qt.add(mt),Jt("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",mt,jt));}}get perf(){return e(this,q)}static unsafeExposeInternals(t){return {starts:e(t,Q),ttls:e(t,W),autopurgeTimers:e(t,V),sizes:e(t,X),keyMap:e(t,O),keyList:e(t,H),valList:e(t,p),next:e(t,N),prev:e(t,R),get head(){return e(t,z)},get tail(){return e(t,C)},free:e(t,Y),isBackgroundFetch:i=>{var s;return c(s=t,l,E).call(s,i)},backgroundFetch:(i,s,r,o)=>{var n;return c(n=t,l,zt).call(n,i,s,r,o)},moveToTail:i=>{var s;return c(s=t,l,Ht).call(s,i)},indexes:i=>{var s;return c(s=t,l,nt).call(s,i)},rindexes:i=>{var s;return c(s=t,l,ot).call(s,i)},isStale:i=>{var s;return e(s=t,j).call(s,i)}}}get max(){return e(this,K)}get maxSize(){return e(this,G)}get calculatedSize(){return e(this,J)}get size(){return e(this,D)}get fetchMethod(){return e(this,bt)}get memoMethod(){return e(this,wt)}get dispose(){return e(this,$)}get onInsert(){return e(this,ct)}get disposeAfter(){return e(this,B)}getRemainingTTL(t){return e(this,O).has(t)?1/0:0}*entries(){for(let t of c(this,l,nt).call(this))e(this,p)[t]!==void 0&&e(this,H)[t]!==void 0&&!c(this,l,E).call(this,e(this,p)[t])&&(yield [e(this,H)[t],e(this,p)[t]]);}*rentries(){for(let t of c(this,l,ot).call(this))e(this,p)[t]!==void 0&&e(this,H)[t]!==void 0&&!c(this,l,E).call(this,e(this,p)[t])&&(yield [e(this,H)[t],e(this,p)[t]]);}*keys(){for(let t of c(this,l,nt).call(this)){let i=e(this,H)[t];i!==void 0&&!c(this,l,E).call(this,e(this,p)[t])&&(yield i);}}*rkeys(){for(let t of c(this,l,ot).call(this)){let i=e(this,H)[t];i!==void 0&&!c(this,l,E).call(this,e(this,p)[t])&&(yield i);}}*values(){for(let t of c(this,l,nt).call(this))e(this,p)[t]!==void 0&&!c(this,l,E).call(this,e(this,p)[t])&&(yield e(this,p)[t]);}*rvalues(){for(let t of c(this,l,ot).call(this))e(this,p)[t]!==void 0&&!c(this,l,E).call(this,e(this,p)[t])&&(yield e(this,p)[t]);}[(Bt=Symbol.iterator,$t=Symbol.toStringTag,Bt)](){return this.entries()}find(t,i={}){for(let s of c(this,l,nt).call(this)){let r=e(this,p)[s],o=c(this,l,E).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 c(this,l,nt).call(this)){let r=e(this,p)[s],o=c(this,l,E).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 c(this,l,ot).call(this)){let r=e(this,p)[s],o=c(this,l,E).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 c(this,l,ot).call(this,{allowStale:true}))e(this,j).call(this,i)&&(c(this,l,at).call(this,e(this,H)[i],"expire"),t=true);return t}info(t){let i=e(this,O).get(t);if(i===void 0)return;let s=e(this,p)[i],r=c(this,l,E).call(this,s)?s.__staleWhileFetching:s;if(r===void 0)return;let o={value:r};if(e(this,W)&&e(this,Q)){let n=e(this,W)[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 c(this,l,nt).call(this,{allowStale:true})){let s=e(this,H)[i],r=e(this,p)[i],o=c(this,l,E).call(this,r)?r.__staleWhileFetching:r;if(o===void 0||s===void 0)continue;let n={value:o};if(e(this,W)&&e(this,Q)){n.ttl=e(this,W)[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 _,P,tt,x;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:y=this.noUpdateTTL}=s,g=e(this,xt).call(this,t,i,s.size||0,a);if(this.maxEntrySize&&g>this.maxEntrySize)return h&&(h.set="miss",h.maxEntrySizeExceeded=true),c(this,l,at).call(this,t,"set"),this;let b=e(this,D)===0?void 0:e(this,O).get(t);if(b===void 0)b=e(this,D)===0?e(this,C):e(this,Y).length!==0?e(this,Y).pop():e(this,D)===e(this,K)?c(this,l,Ft).call(this,false):e(this,D),e(this,H)[b]=t,e(this,p)[b]=i,e(this,O).set(t,b),e(this,N)[e(this,C)]=b,e(this,R)[b]=e(this,C),u(this,C,b),Dt(this,D)._++,e(this,At).call(this,b,g,h),h&&(h.set="add"),y=false,e(this,_t)&&((_=e(this,ct))==null||_.call(this,i,t,"add"));else {c(this,l,Ht).call(this,b);let A=e(this,p)[b];if(i!==A){if(e(this,ht)&&c(this,l,E).call(this,A)){A.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:m}=A;m!==void 0&&!n&&(e(this,Z)&&((P=e(this,$))==null||P.call(this,m,t,"set")),e(this,M)&&e(this,F)?.push([m,t,"set"]));}else n||(e(this,Z)&&((tt=e(this,$))==null||tt.call(this,A,t,"set")),e(this,M)&&e(this,F)?.push([A,t,"set"]));if(e(this,dt).call(this,b),e(this,At).call(this,b,g,h),e(this,p)[b]=i,h){h.set="replace";let m=A&&c(this,l,E).call(this,A)?A.__staleWhileFetching:A;m!==void 0&&(h.oldValue=m);}}else h&&(h.set="update");e(this,_t)&&this.onInsert?.(i,t,i===A?"update":"replace");}if(r!==0&&!e(this,W)&&c(this,l,Gt).call(this),e(this,W)&&(y||e(this,Tt).call(this,b,r,o),h&&e(this,st).call(this,h,b)),!n&&e(this,M)&&e(this,F)){let A=e(this,F),m;for(;m=A?.shift();)(x=e(this,B))==null||x.call(this,...m);}return this}pop(){var t;try{for(;e(this,D);){let i=e(this,p)[e(this,z)];if(c(this,l,Ft).call(this,!0),c(this,l,E).call(this,i)){if(i.__staleWhileFetching)return i.__staleWhileFetching}else if(i!==void 0)return i}}finally{if(e(this,M)&&e(this,F)){let i=e(this,F),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,O).get(t);if(o!==void 0){let n=e(this,p)[o];if(c(this,l,E).call(this,n)&&n.__staleWhileFetching===void 0)return false;if(e(this,j).call(this,o))r&&(r.has="stale",e(this,st).call(this,r,o));else return s&&e(this,ut).call(this,o),r&&(r.has="hit",e(this,st).call(this,r,o)),true}else r&&(r.has="miss");return false}peek(t,i={}){let{allowStale:s=this.allowStale}=i,r=e(this,O).get(t);if(r===void 0||!s&&e(this,j).call(this,r))return;let o=e(this,p)[r];return c(this,l,E).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:y=this.sizeCalculation,noUpdateTTL:g=this.noUpdateTTL,noDeleteOnFetchRejection:b=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:_=this.allowStaleOnFetchRejection,ignoreFetchAbort:P=this.ignoreFetchAbort,allowStaleOnFetchAbort:tt=this.allowStaleOnFetchAbort,context:x,forceRefresh:A=false,status:m,signal:I}=i;if(!e(this,ht))return m&&(m.fetch="get"),this.get(t,{allowStale:s,updateAgeOnGet:r,noDeleteOnStaleGet:o,status:m});let L={allowStale:s,updateAgeOnGet:r,noDeleteOnStaleGet:o,ttl:n,noDisposeOnSet:a,size:h,sizeCalculation:y,noUpdateTTL:g,noDeleteOnFetchRejection:b,allowStaleOnFetchRejection:_,allowStaleOnFetchAbort:tt,ignoreFetchAbort:P,status:m,signal:I},v=e(this,O).get(t);if(v===void 0){m&&(m.fetch="miss");let U=c(this,l,zt).call(this,t,v,L,x);return U.__returned=U}else {let U=e(this,p)[v];if(c(this,l,E).call(this,U)){let mt=s&&U.__staleWhileFetching!==void 0;return m&&(m.fetch="inflight",mt&&(m.returnedStale=true)),mt?U.__staleWhileFetching:U.__returned=U}let Et=e(this,j).call(this,v);if(!A&&!Et)return m&&(m.fetch="hit"),c(this,l,Ht).call(this,v),r&&e(this,ut).call(this,v),m&&e(this,st).call(this,m,v),U;let pt=c(this,l,zt).call(this,t,v,L,x),yt=pt.__staleWhileFetching!==void 0&&s;return m&&(m.fetch=Et?"stale":"refresh",yt&&Et&&(m.returnedStale=true)),yt?pt.__staleWhileFetching:pt.__returned=pt}}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,wt);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,O).get(t);if(a!==void 0){let h=e(this,p)[a],y=c(this,l,E).call(this,h);return n&&e(this,st).call(this,n,a),e(this,j).call(this,a)?(n&&(n.get="stale"),y?(n&&s&&h.__staleWhileFetching!==void 0&&(n.returnedStale=true),s?h.__staleWhileFetching:void 0):(o||c(this,l,at).call(this,t,"expire"),n&&s&&(n.returnedStale=true),s?h:void 0)):(n&&(n.get="hit"),y?h.__staleWhileFetching:(c(this,l,Ht).call(this,a),r&&e(this,ut).call(this,a),h))}else n&&(n.get="miss");}delete(t){return c(this,l,at).call(this,t,"delete")}clear(){return c(this,l,Vt).call(this,"delete")}};K=new WeakMap,G=new WeakMap,$=new WeakMap,ct=new WeakMap,B=new WeakMap,bt=new WeakMap,wt=new WeakMap,q=new WeakMap,D=new WeakMap,J=new WeakMap,O=new WeakMap,H=new WeakMap,p=new WeakMap,N=new WeakMap,R=new WeakMap,z=new WeakMap,C=new WeakMap,Y=new WeakMap,F=new WeakMap,X=new WeakMap,Q=new WeakMap,W=new WeakMap,V=new WeakMap,Z=new WeakMap,ht=new WeakMap,M=new WeakMap,_t=new WeakMap,l=new WeakSet,Gt=function(){let t=new gt(e(this,K)),i=new gt(e(this,K));u(this,W,t),u(this,Q,i);let s=this.ttlAutopurge?new Array(e(this,K)):void 0;u(this,V,s),u(this,Tt,(n,a,h=e(this,q).now())=>{if(i[n]=a!==0?h:0,t[n]=a,s?.[n]&&(clearTimeout(s[n]),s[n]=void 0),a!==0&&s){let y=setTimeout(()=>{e(this,j).call(this,n)&&c(this,l,at).call(this,e(this,H)[n],"expire");},a+1);y.unref&&y.unref(),s[n]=y;}}),u(this,ut,n=>{i[n]=t[n]!==0?e(this,q).now():0;}),u(this,st,(n,a)=>{if(t[a]){let h=t[a],y=i[a];if(!h||!y)return;n.ttl=h,n.start=y,n.now=r||o();let g=n.now-y;n.remainingTTL=h-g;}});let r=0,o=()=>{let n=e(this,q).now();if(this.ttlResolution>0){r=n;let a=setTimeout(()=>r=0,this.ttlResolution);a.unref&&a.unref();}return n};this.getRemainingTTL=n=>{let a=e(this,O).get(n);if(a===void 0)return 0;let h=t[a],y=i[a];if(!h||!y)return 1/0;let g=(r||o())-y;return h-g},u(this,j,n=>{let a=i[n],h=t[n];return !!h&&!!a&&(r||o())-a>h});},ut=new WeakMap,st=new WeakMap,Tt=new WeakMap,j=new WeakMap,Xt=function(){let t=new gt(e(this,K));u(this,J,0),u(this,X,t),u(this,dt,i=>{u(this,J,e(this,J)-t[i]),t[i]=0;}),u(this,xt,(i,s,r,o)=>{if(c(this,l,E).call(this,s))return 0;if(!rt(r))if(o){if(typeof o!="function")throw new TypeError("sizeCalculation must be a function");if(r=o(s,i),!rt(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,At,(i,s,r)=>{if(t[i]=s,e(this,G)){let o=e(this,G)-t[i];for(;e(this,J)>o;)c(this,l,Ft).call(this,true);}u(this,J,e(this,J)+t[i]),r&&(r.entrySize=s,r.totalCalculatedSize=e(this,J));});},dt=new WeakMap,At=new WeakMap,xt=new WeakMap,nt=function*({allowStale:t=this.allowStale}={}){if(e(this,D))for(let i=e(this,C);!(!c(this,l,Rt).call(this,i)||((t||!e(this,j).call(this,i))&&(yield i),i===e(this,z)));)i=e(this,R)[i];},ot=function*({allowStale:t=this.allowStale}={}){if(e(this,D))for(let i=e(this,z);!(!c(this,l,Rt).call(this,i)||((t||!e(this,j).call(this,i))&&(yield i),i===e(this,C)));)i=e(this,N)[i];},Rt=function(t){return t!==void 0&&e(this,O).get(e(this,H)[t])===t},Ft=function(t){var o;let i=e(this,z),s=e(this,H)[i],r=e(this,p)[i];return e(this,ht)&&c(this,l,E).call(this,r)?r.__abortController.abort(new Error("evicted")):(e(this,Z)||e(this,M))&&(e(this,Z)&&((o=e(this,$))==null||o.call(this,r,s,"evict")),e(this,M)&&e(this,F)?.push([r,s,"evict"])),e(this,dt).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,p)[i]=void 0,e(this,Y).push(i)),e(this,D)===1?(u(this,z,u(this,C,0)),e(this,Y).length=0):u(this,z,e(this,N)[i]),e(this,O).delete(s),Dt(this,D)._--,i},zt=function(t,i,s,r){let o=i===void 0?void 0:e(this,p)[i];if(c(this,l,E).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},y=(x,A=false)=>{let{aborted:m}=n.signal,I=s.ignoreFetchAbort&&x!==void 0;if(s.status&&(m&&!A?(s.status.fetchAborted=true,s.status.fetchError=n.signal.reason,I&&(s.status.fetchAbortIgnored=true)):s.status.fetchResolved=true),m&&!I&&!A)return b(n.signal.reason);let L=P,v=e(this,p)[i];return (v===P||I&&A&&v===void 0)&&(x===void 0?L.__staleWhileFetching!==void 0?e(this,p)[i]=L.__staleWhileFetching:c(this,l,at).call(this,t,"fetch"):(s.status&&(s.status.fetchUpdated=true),this.set(t,x,h.options))),x},g=x=>(s.status&&(s.status.fetchRejected=true,s.status.fetchError=x),b(x)),b=x=>{let{aborted:A}=n.signal,m=A&&s.allowStaleOnFetchAbort,I=m||s.allowStaleOnFetchRejection,L=I||s.noDeleteOnFetchRejection,v=P;if(e(this,p)[i]===P&&(!L||v.__staleWhileFetching===void 0?c(this,l,at).call(this,t,"fetch"):m||(e(this,p)[i]=v.__staleWhileFetching)),I)return s.status&&v.__staleWhileFetching!==void 0&&(s.status.returnedStale=true),v.__staleWhileFetching;if(v.__returned===v)throw x},_=(x,A)=>{var I;let m=(I=e(this,bt))==null?void 0:I.call(this,t,o,h);m&&m instanceof Promise&&m.then(L=>x(L===void 0?void 0:L),A),n.signal.addEventListener("abort",()=>{(!s.ignoreFetchAbort||s.allowStaleOnFetchAbort)&&(x(void 0),s.allowStaleOnFetchAbort&&(x=L=>y(L,true)));});};s.status&&(s.status.fetchDispatched=true);let P=new Promise(_).then(y,g),tt=Object.assign(P,{__abortController:n,__staleWhileFetching:o,__returned:void 0});return i===void 0?(this.set(t,tt,{...h.options,status:void 0}),i=e(this,O).get(t)):e(this,p)[i]=tt,tt},E=function(t){if(!e(this,ht))return false;let i=t;return !!i&&i instanceof Promise&&i.hasOwnProperty("__staleWhileFetching")&&i.__abortController instanceof It},Wt=function(t,i){e(this,R)[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]):c(this,l,Wt).call(this,e(this,R)[t],e(this,N)[t]),c(this,l,Wt).call(this,e(this,C),t),u(this,C,t));},at=function(t,i){var r,o;let s=false;if(e(this,D)!==0){let n=e(this,O).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,D)===1)c(this,l,Vt).call(this,i);else {e(this,dt).call(this,n);let a=e(this,p)[n];if(c(this,l,E).call(this,a)?a.__abortController.abort(new Error("deleted")):(e(this,Z)||e(this,M))&&(e(this,Z)&&((r=e(this,$))==null||r.call(this,a,t,i)),e(this,M)&&e(this,F)?.push([a,t,i])),e(this,O).delete(t),e(this,H)[n]=void 0,e(this,p)[n]=void 0,n===e(this,C))u(this,C,e(this,R)[n]);else if(n===e(this,z))u(this,z,e(this,N)[n]);else {let h=e(this,R)[n];e(this,N)[h]=e(this,N)[n];let y=e(this,N)[n];e(this,R)[y]=e(this,R)[n];}Dt(this,D)._--,e(this,Y).push(n);}}if(e(this,M)&&e(this,F)?.length){let n=e(this,F),a;for(;a=n?.shift();)(o=e(this,B))==null||o.call(this,...a);}return s},Vt=function(t){var i,s;for(let r of c(this,l,ot).call(this,{allowStale:true})){let o=e(this,p)[r];if(c(this,l,E).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,M)&&e(this,F)?.push([o,n,t]);}}if(e(this,O).clear(),e(this,p).fill(void 0),e(this,H).fill(void 0),e(this,W)&&e(this,Q)){e(this,W).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,D,0),e(this,M)&&e(this,F)){let r=e(this,F),o;for(;o=r?.shift();)(s=e(this,B))==null||s.call(this,...o);}};var Nt=jt;var lt=class{constructor(t){w(this,"cache");w(this,"map",new Map);this.cache=new Nt({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 it=class it{static get originalStepData(){return it._originalStepData?et(it._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){it._originalStepData=et(t);}};w(it,"_diffHistory",new lt({cacheSize:5})),w(it,"_stepsInfoHistory",new lt({cacheSize:5})),w(it,"_narrationHistory",new lt({cacheSize:50})),w(it,"stepLimitSaved",20),w(it,"_originalStepData");var d=it;var vt=class{get stepsInfoMap(){return d._stepsInfoHistory}get diffMap(){return d._diffHistory}get narrationMap(){return d._narrationHistory}get size(){return d._stepsInfoHistory.size}get lastKey(){return this.size===0?null:Math.max(...Array.from(this.keys()))}keys(){return d._stepsInfoHistory.keys()}get(t){let i=d._narrationHistory.get(t);if(!(i&&Object.keys(i).length===1&&i.stepIndex!==void 0))return i}delete(t){d._stepsInfoHistory.delete(t),d._diffHistory.delete(t),d._narrationHistory.delete(t);}getOldGameState(t,i){if(t<=0||this.size==0)return i;let s=this.lastKey;if(typeof s!="number")return T.warn("You can't go back, there is no step to go back"),i;let r=d._diffHistory.get(s);if(r)try{let o=Ut(i,r);return unifier.GameUnifier.stepCounter=s,this.delete(s),this.getOldGameState(t-1,o)}catch(o){return T.error("Error applying diff",o),i}else return T.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)){T.warn(`[back] The parameter steps must be a valid finite number, received: ${s}`);return}if(s<=0){T.warn(`[back] The parameter steps must be greater than 0, received: ${s}`);return}if(unifier.GameUnifier.runningStepsCount>0){unifier.GameUnifier.increaseBackRequest(s);return}if(d._diffHistory.size<1){T.warn("You can't go back, there is no step to go back");return}unifier.GameUnifier.runningStepsCount++;try{let r=et(this.getOldGameState(s,d.originalStepData));if(r){await unifier.GameUnifier.restoreGameStepState(r,unifier.GameUnifier.navigate);let o=unifier.GameUnifier.stepCounter-1,n=d._narrationHistory.get(o);if(n&&Object.keys(n).length===1&&n.stepIndex!==void 0){let a=d._stepsInfoHistory.get(o);if(a){let h=this.itemMapper({step:a});d._narrationHistory.set(a.index,h);}}}else T.error("Error going back");d.originalStepData=r;}catch(r){T.error("Error going back",r);}finally{if(unifier.GameUnifier.runningStepsCount--,unifier.GameUnifier.runningStepsCount===0&&unifier.GameUnifier.backRequestsCount!==0)return await unifier.GameUnifier.processNavigationRequests()}}add(t,i={}){let s=d.originalStepData,{ignoreSameStep:r}=i,o=unifier.GameUnifier.currentGameStepState;if(!r&&this.isSameStep(s,o))return;let n=this.lastKey;(async()=>{try{let h,y;if(typeof n=="number"&&(h=d._stepsInfoHistory.get(n),y=d._narrationHistory.get(n)),d._stepsInfoHistory.set(t.index,t),t.index!==0){let _=Ct(s,o);_?d._diffHistory.set(t.index,_):T.warn("It was not possible to create the difference between the two steps");}let g={},b=this.itemMapper({step:t},g);if(d._narrationHistory.set(t.index,b),h&&y&&typeof n=="number"){let _=this.itemMapper({...g,step:h},{});d._narrationHistory.set(n,_);}}catch(h){T.error("Error adding history step",h);}})(),d.originalStepData=o;}itemMapper(t,i){let{step:s,choiceIndexMade:r,inputValue:o,removeDialogue:n}=t,a=s.dialogue||s.dialoge;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 y=h?.map((g,b)=>{let _=false;return g.oneTime&&s.alreadyMadeChoices&&s.alreadyMadeChoices.includes(b)&&(_=true),{text:g.text,type:g.type,isResponse:false,hidden:_}});if(y){if(y.every(g=>g.hidden)){let g=y.find(b=>b.hidden===false);g&&(g.hidden=false);}r!==void 0&&(y[r].isResponse=true);}return {dialogue:a?{...a,character:a.character?unifier.GameUnifier.getCharacter(a.character)||a.character:void 0}:void 0,playerMadeChoice:typeof r=="number",choices:y,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,y)=>y-h);if(i.length===0)return t;let s=i[0];if(typeof s!="number")return t;let r=d._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,y)=>{let g=this.get(h);if(g){if(y===0)return t.push(g),true;let b=d._stepsInfoHistory.get(h);if(!b)return true;let _=b.openedLabels;if(!_||!Array.isArray(_)||_.length===0||_[0].label!==a||_[0].currentStepIndex>=n)return false;n=_[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=>{d._narrationHistory.delete(s),d._stepsInfoHistory.delete(s),d._diffHistory.delete(s);});}else d._stepsInfoHistory.clear(),d._diffHistory.clear(),d._narrationHistory.clear();}get canGoBack(){let t=this.lastKey;return typeof t!="number"?false:d._diffHistory.has(t)}blockGoBack(){unifier.GameUnifier.runningStepsCount===0&&d._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 T.error("Error comparing opened labels",s),true}return false}clear(){d._stepsInfoHistory.clear(),d._diffHistory.clear(),d._narrationHistory.clear(),d._originalStepData=void 0;}get stepLimitSaved(){return d.stepLimitSaved}set stepLimitSaved(t){d.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=d._stepsInfoHistory.get(s);if(r){let o=d._diffHistory.get(s);i.push({...r,diff:o});}}),{stepsHistory:et(i),originalStepData:et(d._originalStepData)}}restoreNarrativeHistory(){let t=Array.from(this.keys()).sort((s,r)=>s-r),i={};t.forEach(s=>{let r=d._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&&d._narrationHistory.set(s,n);}});}async restore(t){this.clear();try{t.hasOwnProperty("stepsHistory")?(t.stepsHistory.forEach(s=>{s.diff&&d._diffHistory.set(s.index,s.diff);let r={...s,diff:void 0};d._stepsInfoHistory.set(s.index,r);}),this.restoreNarrativeHistory()):T.warn("Could not import stepsHistory data, so will be ignored"),t.hasOwnProperty("originalStepData")?d._originalStepData=t.originalStepData:T.warn("Could not import originalStepData data, so will be ignored");}catch(i){T.error("Error importing data",i);}}};var ke=new vt;exports.HistoryManagerStatic=d;exports.stepHistory=ke;
|
|
1
|
+
'use strict';var unifier=require('@drincs/pixi-vn/unifier');var Qt=Object.defineProperty;var Pt=f=>{throw TypeError(f)};var Zt=(f,t,i)=>t in f?Qt(f,t,{enumerable:true,configurable:true,writable:true,value:i}):f[t]=i;var w=(f,t,i)=>Zt(f,typeof t!="symbol"?t+"":t,i),Mt=(f,t,i)=>t.has(f)||Pt("Cannot "+i);var e=(f,t,i)=>(Mt(f,t,"read from private field"),i?i.call(f):t.get(f)),S=(f,t,i)=>t.has(f)?Pt("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(f):t.set(f,i),u=(f,t,i,s)=>(Mt(f,t,"write to private field"),t.set(f,i),i),c=(f,t,i)=>(Mt(f,t,"access private method"),i);var Dt=(f,t,i,s)=>({set _(r){u(f,t,r);},get _(){return e(f,t,s)}});var te={Date:true,RegExp:true,String:true,Number:true};function Ct(f,t,i={cyclesFix:true},s=[]){let r=[],o=Array.isArray(f);for(let a in f){let h=f[a],y=o?+a:a;if(!(a in t)){r.push({type:"REMOVE",path:[y],oldValue:f[a]});continue}let m=t[a],b=typeof h=="object"&&typeof m=="object"&&Array.isArray(h)===Array.isArray(m);h&&m&&b&&!te[Object.getPrototypeOf(h)?.constructor?.name]&&(!i.cyclesFix||!s.includes(h))?r.push.apply(r,Ct(h,m,i,i.cyclesFix?s.concat([h]):[]).map(_=>(_.path.unshift(y),_))):h!==m&&!(Number.isNaN(h)&&Number.isNaN(m))&&!(b&&(isNaN(h)?h+""==m+"":+h==+m))&&r.push({path:[y],type:"CHANGE",value:m,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 T;(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)))(T||(T={}));function et(f){try{if(typeof f>"u")return f;let t=JSON.stringify(f);return JSON.parse(t)}catch(t){throw T.error("Error creating exportable element",f,t),new Error("[Pixi\u2019VN] Error creating exportable element")}}function Ut(f,t){let i=et(f);return t.length>1&&"type"in t[0]&&(t=t.reverse()),t.forEach(s=>{"type"in s?ee(i,s):ie(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];}):T.warn("No path found, skipping diff",t);}function ie(f,t){let i=f;t.path&&t.path.length>0?t.path.forEach((s,r)=>{if(t.path&&r===t.path.length-1){if(t.kind==="E"||t.kind==="D")i[s]=t.lhs;else if(t.kind==="N")Number.isInteger(s)?Array.isArray(i)&&i.splice(s,1):typeof s=="string"&&delete i[s];else if(t.kind==="A"){let o=t.index;t.item.kind==="N"?i[s].splice(o,1):t.item.kind==="E"||t.item.kind==="D"?i[s][o]=t.item.lhs:t.item.kind==="A"?T.warn("Nested array found, skipping diff",t):T.warn("No array found, skipping diff",t);}}else i=i[s];}):T.warn("No path found, skipping diff",t);}var se=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,qt=new Set,Lt=typeof process=="object"&&process?process:{},Jt=(f,t,i,s)=>{typeof Lt.emitWarning=="function"?Lt.emitWarning(f,t,i,s):console.error(`[${i}] ${t}: ${f}`);},It=globalThis.AbortController,Kt=globalThis.AbortSignal;if(typeof It>"u"){Kt=class{constructor(){w(this,"onabort");w(this,"_onabort",[]);w(this,"reason");w(this,"aborted",false);}addEventListener(s,r){this._onabort.push(r);}},It=class{constructor(){w(this,"signal",new Kt);t();}abort(s){if(!this.signal.aborted){this.signal.reason=s,this.signal.aborted=true;for(let r of this.signal._onabort)r(s);this.signal.onabort?.(s);}}};let f=Lt.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",t=()=>{f&&(f=false,Jt("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 re=f=>!qt.has(f);var rt=f=>f&&f===Math.floor(f)&&f>0&&isFinite(f),Yt=f=>rt(f)?f<=Math.pow(2,8)?Uint8Array:f<=Math.pow(2,16)?Uint16Array:f<=Math.pow(2,32)?Uint32Array:f<=Number.MAX_SAFE_INTEGER?St:null:null,St=class extends Array{constructor(t){super(t),this.fill(0);}},bt,ft=class ft{constructor(t,i){w(this,"heap");w(this,"length");if(!e(ft,bt))throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new i(t),this.length=0;}static create(t){let i=Yt(t);if(!i)return [];u(ft,bt,true);let s=new ft(t,i);return u(ft,bt,false),s}push(t){this.heap[this.length++]=t;}pop(){return this.heap[--this.length]}};bt=new WeakMap,S(ft,bt,false);var kt=ft,$t,Bt,K,R,$,ct,B,wt,_t,q,D,J,O,H,p,M,W,z,C,Y,F,X,Q,V,j,Z,ht,L,At,l,Gt,ut,st,Tt,P,Xt,dt,Et,xt,nt,ot,Rt,Ft,zt,E,Wt,Ht,at,Vt,jt=class jt{constructor(t){S(this,l);S(this,K);S(this,R);S(this,$);S(this,ct);S(this,B);S(this,wt);S(this,_t);S(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");S(this,D);S(this,J);S(this,O);S(this,H);S(this,p);S(this,M);S(this,W);S(this,z);S(this,C);S(this,Y);S(this,F);S(this,X);S(this,Q);S(this,V);S(this,j);S(this,Z);S(this,ht);S(this,L);S(this,At);S(this,ut,()=>{});S(this,st,()=>{});S(this,Tt,()=>{});S(this,P,()=>false);S(this,dt,t=>{});S(this,Et,(t,i,s)=>{});S(this,xt,(t,i,s,r)=>{if(s||r)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0});w(this,$t,"LRUCache");let{max:i=0,ttl:s,ttlResolution:r=1,ttlAutopurge:o,updateAgeOnGet:n,updateAgeOnHas:a,allowStale:h,dispose:y,onInsert:m,disposeAfter:b,noDisposeOnSet:_,noUpdateTTL:U,maxSize:tt=0,maxEntrySize:x=0,sizeCalculation:A,fetchMethod:g,memoMethod:I,noDeleteOnFetchRejection:k,noDeleteOnStaleGet:N,allowStaleOnFetchRejection:v,allowStaleOnFetchAbort:pt,ignoreFetchAbort:yt,perf:Ot}=t;if(Ot!==void 0&&typeof Ot?.now!="function")throw new TypeError("perf option must have a now() method if specified");if(u(this,q,Ot??se),i!==0&&!rt(i))throw new TypeError("max option must be a nonnegative integer");let mt=i?Yt(i):Array;if(!mt)throw new Error("invalid max value: "+i);if(u(this,K,i),u(this,R,tt),this.maxEntrySize=x||e(this,R),this.sizeCalculation=A,this.sizeCalculation){if(!e(this,R)&&!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,_t,I),g!==void 0&&typeof g!="function")throw new TypeError("fetchMethod must be a function if specified");if(u(this,wt,g),u(this,ht,!!g),u(this,O,new Map),u(this,H,new Array(i).fill(void 0)),u(this,p,new Array(i).fill(void 0)),u(this,M,new mt(i)),u(this,W,new mt(i)),u(this,z,0),u(this,C,0),u(this,Y,kt.create(i)),u(this,D,0),u(this,J,0),typeof y=="function"&&u(this,$,y),typeof m=="function"&&u(this,ct,m),typeof b=="function"?(u(this,B,b),u(this,F,[])):(u(this,B,void 0),u(this,F,void 0)),u(this,Z,!!e(this,$)),u(this,At,!!e(this,ct)),u(this,L,!!e(this,B)),this.noDisposeOnSet=!!_,this.noUpdateTTL=!!U,this.noDeleteOnFetchRejection=!!k,this.allowStaleOnFetchRejection=!!v,this.allowStaleOnFetchAbort=!!pt,this.ignoreFetchAbort=!!yt,this.maxEntrySize!==0){if(e(this,R)!==0&&!rt(e(this,R)))throw new TypeError("maxSize must be a positive integer if specified");if(!rt(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");c(this,l,Xt).call(this);}if(this.allowStale=!!h,this.noDeleteOnStaleGet=!!N,this.updateAgeOnGet=!!n,this.updateAgeOnHas=!!a,this.ttlResolution=rt(r)||r===0?r:1,this.ttlAutopurge=!!o,this.ttl=s||0,this.ttl){if(!rt(this.ttl))throw new TypeError("ttl must be a positive integer if specified");c(this,l,Gt).call(this);}if(e(this,K)===0&&this.ttl===0&&e(this,R)===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!e(this,K)&&!e(this,R)){let gt="LRU_CACHE_UNBOUNDED";re(gt)&&(qt.add(gt),Jt("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",gt,jt));}}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,O),keyList:e(t,H),valList:e(t,p),next:e(t,M),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 c(s=t,l,E).call(s,i)},backgroundFetch:(i,s,r,o)=>{var n;return c(n=t,l,zt).call(n,i,s,r,o)},moveToTail:i=>{var s;return c(s=t,l,Ht).call(s,i)},indexes:i=>{var s;return c(s=t,l,nt).call(s,i)},rindexes:i=>{var s;return c(s=t,l,ot).call(s,i)},isStale:i=>{var s;return e(s=t,P).call(s,i)}}}get max(){return e(this,K)}get maxSize(){return e(this,R)}get calculatedSize(){return e(this,J)}get size(){return e(this,D)}get fetchMethod(){return e(this,wt)}get memoMethod(){return e(this,_t)}get dispose(){return e(this,$)}get onInsert(){return e(this,ct)}get disposeAfter(){return e(this,B)}getRemainingTTL(t){return e(this,O).has(t)?1/0:0}*entries(){for(let t of c(this,l,nt).call(this))e(this,p)[t]!==void 0&&e(this,H)[t]!==void 0&&!c(this,l,E).call(this,e(this,p)[t])&&(yield [e(this,H)[t],e(this,p)[t]]);}*rentries(){for(let t of c(this,l,ot).call(this))e(this,p)[t]!==void 0&&e(this,H)[t]!==void 0&&!c(this,l,E).call(this,e(this,p)[t])&&(yield [e(this,H)[t],e(this,p)[t]]);}*keys(){for(let t of c(this,l,nt).call(this)){let i=e(this,H)[t];i!==void 0&&!c(this,l,E).call(this,e(this,p)[t])&&(yield i);}}*rkeys(){for(let t of c(this,l,ot).call(this)){let i=e(this,H)[t];i!==void 0&&!c(this,l,E).call(this,e(this,p)[t])&&(yield i);}}*values(){for(let t of c(this,l,nt).call(this))e(this,p)[t]!==void 0&&!c(this,l,E).call(this,e(this,p)[t])&&(yield e(this,p)[t]);}*rvalues(){for(let t of c(this,l,ot).call(this))e(this,p)[t]!==void 0&&!c(this,l,E).call(this,e(this,p)[t])&&(yield e(this,p)[t]);}[(Bt=Symbol.iterator,$t=Symbol.toStringTag,Bt)](){return this.entries()}find(t,i={}){for(let s of c(this,l,nt).call(this)){let r=e(this,p)[s],o=c(this,l,E).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 c(this,l,nt).call(this)){let r=e(this,p)[s],o=c(this,l,E).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 c(this,l,ot).call(this)){let r=e(this,p)[s],o=c(this,l,E).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 c(this,l,ot).call(this,{allowStale:true}))e(this,P).call(this,i)&&(c(this,l,at).call(this,e(this,H)[i],"expire"),t=true);return t}info(t){let i=e(this,O).get(t);if(i===void 0)return;let s=e(this,p)[i],r=c(this,l,E).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 c(this,l,nt).call(this,{allowStale:true})){let s=e(this,H)[i],r=e(this,p)[i],o=c(this,l,E).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 _,U,tt,x;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:y=this.noUpdateTTL}=s,m=e(this,xt).call(this,t,i,s.size||0,a);if(this.maxEntrySize&&m>this.maxEntrySize)return h&&(h.set="miss",h.maxEntrySizeExceeded=true),c(this,l,at).call(this,t,"set"),this;let b=e(this,D)===0?void 0:e(this,O).get(t);if(b===void 0)b=e(this,D)===0?e(this,C):e(this,Y).length!==0?e(this,Y).pop():e(this,D)===e(this,K)?c(this,l,Ft).call(this,false):e(this,D),e(this,H)[b]=t,e(this,p)[b]=i,e(this,O).set(t,b),e(this,M)[e(this,C)]=b,e(this,W)[b]=e(this,C),u(this,C,b),Dt(this,D)._++,e(this,Et).call(this,b,m,h),h&&(h.set="add"),y=false,e(this,At)&&((_=e(this,ct))==null||_.call(this,i,t,"add"));else {c(this,l,Ht).call(this,b);let A=e(this,p)[b];if(i!==A){if(e(this,ht)&&c(this,l,E).call(this,A)){A.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:g}=A;g!==void 0&&!n&&(e(this,Z)&&((U=e(this,$))==null||U.call(this,g,t,"set")),e(this,L)&&e(this,F)?.push([g,t,"set"]));}else n||(e(this,Z)&&((tt=e(this,$))==null||tt.call(this,A,t,"set")),e(this,L)&&e(this,F)?.push([A,t,"set"]));if(e(this,dt).call(this,b),e(this,Et).call(this,b,m,h),e(this,p)[b]=i,h){h.set="replace";let g=A&&c(this,l,E).call(this,A)?A.__staleWhileFetching:A;g!==void 0&&(h.oldValue=g);}}else h&&(h.set="update");e(this,At)&&this.onInsert?.(i,t,i===A?"update":"replace");}if(r!==0&&!e(this,V)&&c(this,l,Gt).call(this),e(this,V)&&(y||e(this,Tt).call(this,b,r,o),h&&e(this,st).call(this,h,b)),!n&&e(this,L)&&e(this,F)){let A=e(this,F),g;for(;g=A?.shift();)(x=e(this,B))==null||x.call(this,...g);}return this}pop(){var t;try{for(;e(this,D);){let i=e(this,p)[e(this,z)];if(c(this,l,Ft).call(this,!0),c(this,l,E).call(this,i)){if(i.__staleWhileFetching)return i.__staleWhileFetching}else if(i!==void 0)return i}}finally{if(e(this,L)&&e(this,F)){let i=e(this,F),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,O).get(t);if(o!==void 0){let n=e(this,p)[o];if(c(this,l,E).call(this,n)&&n.__staleWhileFetching===void 0)return false;if(e(this,P).call(this,o))r&&(r.has="stale",e(this,st).call(this,r,o));else return s&&e(this,ut).call(this,o),r&&(r.has="hit",e(this,st).call(this,r,o)),true}else r&&(r.has="miss");return false}peek(t,i={}){let{allowStale:s=this.allowStale}=i,r=e(this,O).get(t);if(r===void 0||!s&&e(this,P).call(this,r))return;let o=e(this,p)[r];return c(this,l,E).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:y=this.sizeCalculation,noUpdateTTL:m=this.noUpdateTTL,noDeleteOnFetchRejection:b=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:_=this.allowStaleOnFetchRejection,ignoreFetchAbort:U=this.ignoreFetchAbort,allowStaleOnFetchAbort:tt=this.allowStaleOnFetchAbort,context:x,forceRefresh:A=false,status:g,signal:I}=i;if(!e(this,ht))return g&&(g.fetch="get"),this.get(t,{allowStale:s,updateAgeOnGet:r,noDeleteOnStaleGet:o,status:g});let k={allowStale:s,updateAgeOnGet:r,noDeleteOnStaleGet:o,ttl:n,noDisposeOnSet:a,size:h,sizeCalculation:y,noUpdateTTL:m,noDeleteOnFetchRejection:b,allowStaleOnFetchRejection:_,allowStaleOnFetchAbort:tt,ignoreFetchAbort:U,status:g,signal:I},N=e(this,O).get(t);if(N===void 0){g&&(g.fetch="miss");let v=c(this,l,zt).call(this,t,N,k,x);return v.__returned=v}else {let v=e(this,p)[N];if(c(this,l,E).call(this,v)){let gt=s&&v.__staleWhileFetching!==void 0;return g&&(g.fetch="inflight",gt&&(g.returnedStale=true)),gt?v.__staleWhileFetching:v.__returned=v}let pt=e(this,P).call(this,N);if(!A&&!pt)return g&&(g.fetch="hit"),c(this,l,Ht).call(this,N),r&&e(this,ut).call(this,N),g&&e(this,st).call(this,g,N),v;let yt=c(this,l,zt).call(this,t,N,k,x),mt=yt.__staleWhileFetching!==void 0&&s;return g&&(g.fetch=pt?"stale":"refresh",mt&&pt&&(g.returnedStale=true)),mt?yt.__staleWhileFetching:yt.__returned=yt}}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,_t);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,O).get(t);if(a!==void 0){let h=e(this,p)[a],y=c(this,l,E).call(this,h);return n&&e(this,st).call(this,n,a),e(this,P).call(this,a)?(n&&(n.get="stale"),y?(n&&s&&h.__staleWhileFetching!==void 0&&(n.returnedStale=true),s?h.__staleWhileFetching:void 0):(o||c(this,l,at).call(this,t,"expire"),n&&s&&(n.returnedStale=true),s?h:void 0)):(n&&(n.get="hit"),y?h.__staleWhileFetching:(c(this,l,Ht).call(this,a),r&&e(this,ut).call(this,a),h))}else n&&(n.get="miss");}delete(t){return c(this,l,at).call(this,t,"delete")}clear(){return c(this,l,Vt).call(this,"delete")}};K=new WeakMap,R=new WeakMap,$=new WeakMap,ct=new WeakMap,B=new WeakMap,wt=new WeakMap,_t=new WeakMap,q=new WeakMap,D=new WeakMap,J=new WeakMap,O=new WeakMap,H=new WeakMap,p=new WeakMap,M=new WeakMap,W=new WeakMap,z=new WeakMap,C=new WeakMap,Y=new WeakMap,F=new WeakMap,X=new WeakMap,Q=new WeakMap,V=new WeakMap,j=new WeakMap,Z=new WeakMap,ht=new WeakMap,L=new WeakMap,At=new WeakMap,l=new WeakSet,Gt=function(){let t=new St(e(this,K)),i=new St(e(this,K));u(this,V,t),u(this,Q,i);let s=this.ttlAutopurge?new Array(e(this,K)):void 0;u(this,j,s),u(this,Tt,(n,a,h=e(this,q).now())=>{if(i[n]=a!==0?h:0,t[n]=a,s?.[n]&&(clearTimeout(s[n]),s[n]=void 0),a!==0&&s){let y=setTimeout(()=>{e(this,P).call(this,n)&&c(this,l,at).call(this,e(this,H)[n],"expire");},a+1);y.unref&&y.unref(),s[n]=y;}}),u(this,ut,n=>{i[n]=t[n]!==0?e(this,q).now():0;}),u(this,st,(n,a)=>{if(t[a]){let h=t[a],y=i[a];if(!h||!y)return;n.ttl=h,n.start=y,n.now=r||o();let m=n.now-y;n.remainingTTL=h-m;}});let r=0,o=()=>{let n=e(this,q).now();if(this.ttlResolution>0){r=n;let a=setTimeout(()=>r=0,this.ttlResolution);a.unref&&a.unref();}return n};this.getRemainingTTL=n=>{let a=e(this,O).get(n);if(a===void 0)return 0;let h=t[a],y=i[a];if(!h||!y)return 1/0;let m=(r||o())-y;return h-m},u(this,P,n=>{let a=i[n],h=t[n];return !!h&&!!a&&(r||o())-a>h});},ut=new WeakMap,st=new WeakMap,Tt=new WeakMap,P=new WeakMap,Xt=function(){let t=new St(e(this,K));u(this,J,0),u(this,X,t),u(this,dt,i=>{u(this,J,e(this,J)-t[i]),t[i]=0;}),u(this,xt,(i,s,r,o)=>{if(c(this,l,E).call(this,s))return 0;if(!rt(r))if(o){if(typeof o!="function")throw new TypeError("sizeCalculation must be a function");if(r=o(s,i),!rt(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,Et,(i,s,r)=>{if(t[i]=s,e(this,R)){let o=e(this,R)-t[i];for(;e(this,J)>o;)c(this,l,Ft).call(this,true);}u(this,J,e(this,J)+t[i]),r&&(r.entrySize=s,r.totalCalculatedSize=e(this,J));});},dt=new WeakMap,Et=new WeakMap,xt=new WeakMap,nt=function*({allowStale:t=this.allowStale}={}){if(e(this,D))for(let i=e(this,C);!(!c(this,l,Rt).call(this,i)||((t||!e(this,P).call(this,i))&&(yield i),i===e(this,z)));)i=e(this,W)[i];},ot=function*({allowStale:t=this.allowStale}={}){if(e(this,D))for(let i=e(this,z);!(!c(this,l,Rt).call(this,i)||((t||!e(this,P).call(this,i))&&(yield i),i===e(this,C)));)i=e(this,M)[i];},Rt=function(t){return t!==void 0&&e(this,O).get(e(this,H)[t])===t},Ft=function(t){var o;let i=e(this,z),s=e(this,H)[i],r=e(this,p)[i];return e(this,ht)&&c(this,l,E).call(this,r)?r.__abortController.abort(new Error("evicted")):(e(this,Z)||e(this,L))&&(e(this,Z)&&((o=e(this,$))==null||o.call(this,r,s,"evict")),e(this,L)&&e(this,F)?.push([r,s,"evict"])),e(this,dt).call(this,i),e(this,j)?.[i]&&(clearTimeout(e(this,j)[i]),e(this,j)[i]=void 0),t&&(e(this,H)[i]=void 0,e(this,p)[i]=void 0,e(this,Y).push(i)),e(this,D)===1?(u(this,z,u(this,C,0)),e(this,Y).length=0):u(this,z,e(this,M)[i]),e(this,O).delete(s),Dt(this,D)._--,i},zt=function(t,i,s,r){let o=i===void 0?void 0:e(this,p)[i];if(c(this,l,E).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},y=(x,A=false)=>{let{aborted:g}=n.signal,I=s.ignoreFetchAbort&&x!==void 0,k=s.ignoreFetchAbort||!!(s.allowStaleOnFetchAbort&&x!==void 0);if(s.status&&(g&&!A?(s.status.fetchAborted=true,s.status.fetchError=n.signal.reason,I&&(s.status.fetchAbortIgnored=true)):s.status.fetchResolved=true),g&&!I&&!A)return b(n.signal.reason,k);let N=U,v=e(this,p)[i];return (v===U||I&&A&&v===void 0)&&(x===void 0?N.__staleWhileFetching!==void 0?e(this,p)[i]=N.__staleWhileFetching:c(this,l,at).call(this,t,"fetch"):(s.status&&(s.status.fetchUpdated=true),this.set(t,x,h.options))),x},m=x=>(s.status&&(s.status.fetchRejected=true,s.status.fetchError=x),b(x,false)),b=(x,A)=>{let{aborted:g}=n.signal,I=g&&s.allowStaleOnFetchAbort,k=I||s.allowStaleOnFetchRejection,N=k||s.noDeleteOnFetchRejection,v=U;if(e(this,p)[i]===U&&(!N||!A&&v.__staleWhileFetching===void 0?c(this,l,at).call(this,t,"fetch"):I||(e(this,p)[i]=v.__staleWhileFetching)),k)return s.status&&v.__staleWhileFetching!==void 0&&(s.status.returnedStale=true),v.__staleWhileFetching;if(v.__returned===v)throw x},_=(x,A)=>{var I;let g=(I=e(this,wt))==null?void 0:I.call(this,t,o,h);g&&g instanceof Promise&&g.then(k=>x(k===void 0?void 0:k),A),n.signal.addEventListener("abort",()=>{(!s.ignoreFetchAbort||s.allowStaleOnFetchAbort)&&(x(void 0),s.allowStaleOnFetchAbort&&(x=k=>y(k,true)));});};s.status&&(s.status.fetchDispatched=true);let U=new Promise(_).then(y,m),tt=Object.assign(U,{__abortController:n,__staleWhileFetching:o,__returned:void 0});return i===void 0?(this.set(t,tt,{...h.options,status:void 0}),i=e(this,O).get(t)):e(this,p)[i]=tt,tt},E=function(t){if(!e(this,ht))return false;let i=t;return !!i&&i instanceof Promise&&i.hasOwnProperty("__staleWhileFetching")&&i.__abortController instanceof It},Wt=function(t,i){e(this,W)[i]=t,e(this,M)[t]=i;},Ht=function(t){t!==e(this,C)&&(t===e(this,z)?u(this,z,e(this,M)[t]):c(this,l,Wt).call(this,e(this,W)[t],e(this,M)[t]),c(this,l,Wt).call(this,e(this,C),t),u(this,C,t));},at=function(t,i){var r,o;let s=false;if(e(this,D)!==0){let n=e(this,O).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,D)===1)c(this,l,Vt).call(this,i);else {e(this,dt).call(this,n);let a=e(this,p)[n];if(c(this,l,E).call(this,a)?a.__abortController.abort(new Error("deleted")):(e(this,Z)||e(this,L))&&(e(this,Z)&&((r=e(this,$))==null||r.call(this,a,t,i)),e(this,L)&&e(this,F)?.push([a,t,i])),e(this,O).delete(t),e(this,H)[n]=void 0,e(this,p)[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,M)[n]);else {let h=e(this,W)[n];e(this,M)[h]=e(this,M)[n];let y=e(this,M)[n];e(this,W)[y]=e(this,W)[n];}Dt(this,D)._--,e(this,Y).push(n);}}if(e(this,L)&&e(this,F)?.length){let n=e(this,F),a;for(;a=n?.shift();)(o=e(this,B))==null||o.call(this,...a);}return s},Vt=function(t){var i,s;for(let r of c(this,l,ot).call(this,{allowStale:true})){let o=e(this,p)[r];if(c(this,l,E).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,L)&&e(this,F)?.push([o,n,t]);}}if(e(this,O).clear(),e(this,p).fill(void 0),e(this,H).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),u(this,z,0),u(this,C,0),e(this,Y).length=0,u(this,J,0),u(this,D,0),e(this,L)&&e(this,F)){let r=e(this,F),o;for(;o=r?.shift();)(s=e(this,B))==null||s.call(this,...o);}};var Nt=jt;var lt=class{constructor(t){w(this,"cache");w(this,"map",new Map);this.cache=new Nt({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 it=class it{static get originalStepData(){return it._originalStepData?et(it._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){it._originalStepData=et(t);}};w(it,"_diffHistory",new lt({cacheSize:5})),w(it,"_stepsInfoHistory",new lt({cacheSize:5})),w(it,"_narrationHistory",new lt({cacheSize:50})),w(it,"stepLimitSaved",20),w(it,"_originalStepData");var d=it;var vt=class{get stepsInfoMap(){return d._stepsInfoHistory}get diffMap(){return d._diffHistory}get narrationMap(){return d._narrationHistory}get size(){return d._stepsInfoHistory.size}get lastKey(){return this.size===0?null:Math.max(...Array.from(this.keys()))}keys(){return d._stepsInfoHistory.keys()}get(t){let i=d._narrationHistory.get(t);if(!(i&&Object.keys(i).length===1&&i.stepIndex!==void 0))return i}delete(t){d._stepsInfoHistory.delete(t),d._diffHistory.delete(t),d._narrationHistory.delete(t);}getOldGameState(t,i){if(t<=0||this.size==0)return i;let s=this.lastKey;if(typeof s!="number")return T.warn("You can't go back, there is no step to go back"),i;let r=d._diffHistory.get(s);if(r)try{let o=Ut(i,r);return unifier.GameUnifier.stepCounter=s,this.delete(s),this.getOldGameState(t-1,o)}catch(o){return T.error("Error applying diff",o),i}else return T.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)){T.warn(`[back] The parameter steps must be a valid finite number, received: ${s}`);return}if(s<=0){T.warn(`[back] The parameter steps must be greater than 0, received: ${s}`);return}if(unifier.GameUnifier.runningStepsCount>0){unifier.GameUnifier.increaseBackRequest(s);return}if(d._diffHistory.size<1){T.warn("You can't go back, there is no step to go back");return}unifier.GameUnifier.runningStepsCount++;try{let r=et(this.getOldGameState(s,d.originalStepData));if(r){await unifier.GameUnifier.restoreGameStepState(r,unifier.GameUnifier.navigate);let o=unifier.GameUnifier.stepCounter-1,n=d._narrationHistory.get(o);if(n&&Object.keys(n).length===1&&n.stepIndex!==void 0){let a=d._stepsInfoHistory.get(o);if(a){let h=this.itemMapper({step:a});d._narrationHistory.set(a.index,h);}}}else T.error("Error going back");d.originalStepData=r;}catch(r){T.error("Error going back",r);}finally{if(unifier.GameUnifier.runningStepsCount--,unifier.GameUnifier.runningStepsCount===0&&unifier.GameUnifier.backRequestsCount!==0)return await unifier.GameUnifier.processNavigationRequests()}}add(t,i={}){let s=d.originalStepData,{ignoreSameStep:r}=i,o=unifier.GameUnifier.currentGameStepState;if(!r&&this.isSameStep(s,o))return;let n=this.lastKey;(async()=>{try{let h,y;if(typeof n=="number"&&(h=d._stepsInfoHistory.get(n),y=d._narrationHistory.get(n)),d._stepsInfoHistory.set(t.index,t),t.index!==0){let _=Ct(s,o);_?d._diffHistory.set(t.index,_):T.warn("It was not possible to create the difference between the two steps");}let m={},b=this.itemMapper({step:t},m);if(d._narrationHistory.set(t.index,b),h&&y&&typeof n=="number"){let _=this.itemMapper({...m,step:h},{});d._narrationHistory.set(n,_);}}catch(h){T.error("Error adding history step",h);}})(),d.originalStepData=o;}itemMapper(t,i){let{step:s,choiceIndexMade:r,inputValue:o,removeDialogue:n}=t,a=s.dialogue||s.dialoge;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 y=h?.map((m,b)=>{let _=false;return m.oneTime&&s.alreadyMadeChoices&&s.alreadyMadeChoices.includes(b)&&(_=true),{text:m.text,type:m.type,isResponse:false,hidden:_}});if(y){if(y.every(m=>m.hidden)){let m=y.find(b=>b.hidden===false);m&&(m.hidden=false);}r!==void 0&&(y[r].isResponse=true);}return {dialogue:a?{...a,character:a.character?unifier.GameUnifier.getCharacter(a.character)||a.character:void 0}:void 0,playerMadeChoice:typeof r=="number",choices:y,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,y)=>y-h);if(i.length===0)return t;let s=i[0];if(typeof s!="number")return t;let r=d._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,y)=>{let m=this.get(h);if(m){if(y===0)return t.push(m),true;let b=d._stepsInfoHistory.get(h);if(!b)return true;let _=b.openedLabels;if(!_||!Array.isArray(_)||_.length===0||_[0].label!==a||_[0].currentStepIndex>=n)return false;n=_[0].currentStepIndex,t.push(m);}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=>{d._narrationHistory.delete(s),d._stepsInfoHistory.delete(s),d._diffHistory.delete(s);});}else d._stepsInfoHistory.clear(),d._diffHistory.clear(),d._narrationHistory.clear();}get canGoBack(){let t=this.lastKey;return typeof t!="number"?false:d._diffHistory.has(t)}blockGoBack(){unifier.GameUnifier.runningStepsCount===0&&d._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 T.error("Error comparing opened labels",s),true}return false}clear(){d._stepsInfoHistory.clear(),d._diffHistory.clear(),d._narrationHistory.clear(),d._originalStepData=void 0;}get stepLimitSaved(){return d.stepLimitSaved}set stepLimitSaved(t){d.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=d._stepsInfoHistory.get(s);if(r){let o=d._diffHistory.get(s);i.push({...r,diff:o});}}),{stepsHistory:et(i),originalStepData:et(d._originalStepData)}}restoreNarrativeHistory(){let t=Array.from(this.keys()).sort((s,r)=>s-r),i={};t.forEach(s=>{let r=d._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&&d._narrationHistory.set(s,n);}});}async restore(t){this.clear();try{t.hasOwnProperty("stepsHistory")?(t.stepsHistory.forEach(s=>{s.diff&&d._diffHistory.set(s.index,s.diff);let r={...s,diff:void 0};d._stepsInfoHistory.set(s.index,r);}),this.restoreNarrativeHistory()):T.warn("Could not import stepsHistory data, so will be ignored"),t.hasOwnProperty("originalStepData")?d._originalStepData=t.originalStepData:T.warn("Could not import originalStepData data, so will be ignored");}catch(i){T.error("Error importing data",i);}}};var ke=new vt;exports.HistoryManagerStatic=d;exports.stepHistory=ke;
|
package/dist/history.d.cts
CHANGED
|
@@ -135,7 +135,7 @@ interface HistoryManagerInterface {
|
|
|
135
135
|
}
|
|
136
136
|
|
|
137
137
|
declare class HistoryManagerStatic {
|
|
138
|
-
static _diffHistory: CachedMap<number, deepDiff.Diff<GameStepState, GameStepState>[]
|
|
138
|
+
static _diffHistory: CachedMap<number, Difference[] | deepDiff.Diff<GameStepState, GameStepState>[]>;
|
|
139
139
|
static _stepsInfoHistory: CachedMap<number, Omit<HistoryStep, "diff">>;
|
|
140
140
|
static _narrationHistory: CachedMap<number, NarrationHistory>;
|
|
141
141
|
static stepLimitSaved: number;
|
package/dist/history.d.ts
CHANGED
|
@@ -135,7 +135,7 @@ interface HistoryManagerInterface {
|
|
|
135
135
|
}
|
|
136
136
|
|
|
137
137
|
declare class HistoryManagerStatic {
|
|
138
|
-
static _diffHistory: CachedMap<number, deepDiff.Diff<GameStepState, GameStepState>[]
|
|
138
|
+
static _diffHistory: CachedMap<number, Difference[] | deepDiff.Diff<GameStepState, GameStepState>[]>;
|
|
139
139
|
static _stepsInfoHistory: CachedMap<number, Omit<HistoryStep, "diff">>;
|
|
140
140
|
static _narrationHistory: CachedMap<number, NarrationHistory>;
|
|
141
141
|
static stepLimitSaved: number;
|
package/dist/history.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import'./chunk-XSN6P5JL.mjs';import {a}from'./chunk-
|
|
1
|
+
import'./chunk-XSN6P5JL.mjs';import {a}from'./chunk-GFG3MDHE.mjs';import {d,k as k$1,j}from'./chunk-GNJIUFU2.mjs';import {GameUnifier}from'@drincs/pixi-vn/unifier';var k={Date:true,RegExp:true,String:true,Number:true};function x(d,e,r={cyclesFix:true},t=[]){let a=[],n=Array.isArray(d);for(let o in d){let s=d[o],u=n?+o:o;if(!(o in e)){a.push({type:"REMOVE",path:[u],oldValue:d[o]});continue}let p=e[o],m=typeof s=="object"&&typeof p=="object"&&Array.isArray(s)===Array.isArray(p);s&&p&&m&&!k[Object.getPrototypeOf(s)?.constructor?.name]&&(!r.cyclesFix||!t.includes(s))?a.push.apply(a,x(s,p,r,r.cyclesFix?t.concat([s]):[]).map(c=>(c.path.unshift(u),c))):s!==p&&!(Number.isNaN(s)&&Number.isNaN(p))&&!(m&&(isNaN(s)?s+""==p+"":+s==+p))&&a.push({path:[u],type:"CHANGE",value:p,oldValue:s});}let f=Array.isArray(e);for(let o in e)o in d||a.push({type:"CREATE",path:[f?+o:o],value:e[o]});return a}function D(d,e){let r=k$1(d);return e.length>1&&"type"in e[0]&&(e=e.reverse()),e.forEach(t=>{"type"in t?I(r,t):E(r,t);}),r}function I(d,e){let r=d;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);}function E(d,e){let r=d;e.path&&e.path.length>0?e.path.forEach((t,a)=>{if(e.path&&a===e.path.length-1){if(e.kind==="E"||e.kind==="D")r[t]=e.lhs;else if(e.kind==="N")Number.isInteger(t)?Array.isArray(r)&&r.splice(t,1):typeof t=="string"&&delete r[t];else if(e.kind==="A"){let n=e.index;e.item.kind==="N"?r[t].splice(n,1):e.item.kind==="E"||e.item.kind==="D"?r[t][n]=e.item.lhs:e.item.kind==="A"?j.warn("Nested array found, skipping diff",e):j.warn("No array found, skipping diff",e);}}else r=r[t];}):j.warn("No path found, skipping diff",e);}var g=class g{static get originalStepData(){return g._originalStepData?k$1(g._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){g._originalStepData=k$1(e);}};d(g,"_diffHistory",new a({cacheSize:5})),d(g,"_stepsInfoHistory",new a({cacheSize:5})),d(g,"_narrationHistory",new a({cacheSize:50})),d(g,"stepLimitSaved",20),d(g,"_originalStepData");var i=g;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 n=D(r,a);return GameUnifier.stepCounter=t,this.delete(t),this.getOldGameState(e-1,n)}catch(n){return j.error("Error applying diff",n),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$1(this.getOldGameState(t,i.originalStepData));if(a){await GameUnifier.restoreGameStepState(a,GameUnifier.navigate);let n=GameUnifier.stepCounter-1,f=i._narrationHistory.get(n);if(f&&Object.keys(f).length===1&&f.stepIndex!==void 0){let o=i._stepsInfoHistory.get(n);if(o){let s=this.itemMapper({step:o});i._narrationHistory.set(o.index,s);}}}else j.error("Error going back");i.originalStepData=a;}catch(a){j.error("Error going back",a);}finally{if(GameUnifier.runningStepsCount--,GameUnifier.runningStepsCount===0&&GameUnifier.backRequestsCount!==0)return await GameUnifier.processNavigationRequests()}}add(e,r={}){let t=i.originalStepData,{ignoreSameStep:a}=r,n=GameUnifier.currentGameStepState;if(!a&&this.isSameStep(t,n))return;let f=this.lastKey;(async()=>{try{let s,u;if(typeof f=="number"&&(s=i._stepsInfoHistory.get(f),u=i._narrationHistory.get(f)),i._stepsInfoHistory.set(e.index,e),e.index!==0){let c=x(t,n);c?i._diffHistory.set(e.index,c):j.warn("It was not possible to create the difference between the two steps");}let p={},m=this.itemMapper({step:e},p);if(i._narrationHistory.set(e.index,m),s&&u&&typeof f=="number"){let c=this.itemMapper({...p,step:s},{});i._narrationHistory.set(f,c);}}catch(s){j.error("Error adding history step",s);}})(),i.originalStepData=n;}itemMapper(e,r){let{step:t,choiceIndexMade:a,inputValue:n,removeDialogue:f}=e,o=t.dialogue||t.dialoge;r&&t.isGlued&&(r.removeDialogue=true),f&&(o=void 0);let s=t.choices;if(r&&t.currentLabel&&t.choiceIndexMade!==void 0&&(r.choiceIndexMade=t.choiceIndexMade),t.inputValue&&r&&(r.inputValue=t.inputValue),o||s||n){let u=s?.map((p,m)=>{let c=false;return p.oneTime&&t.alreadyMadeChoices&&t.alreadyMadeChoices.includes(m)&&(c=true),{text:p.text,type:p.type,isResponse:false,hidden:c}});if(u){if(u.every(p=>p.hidden)){let p=u.find(m=>m.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:n}}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((s,u)=>u-s);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 n=a.openedLabels;if(!n||!Array.isArray(n)||n.length===0)return e;let f=n[0].currentStepIndex,o=n[0].label;return r.every((s,u)=>{let p=this.get(s);if(p){if(u===0)return e.push(p),true;let m=i._stepsInfoHistory.get(s);if(!m)return true;let c=m.openedLabels;if(!c||!Array.isArray(c)||c.length===0||c[0].label!==o||c[0].currentStepIndex>=f)return false;f=c[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 n=i._diffHistory.get(t);r.push({...a,diff:n});}}),{stepsHistory:k$1(r),originalStepData:k$1(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 n={...r};r={};let f=this.itemMapper({step:a,choiceIndexMade:n.choiceIndexMade,inputValue:n.inputValue,removeDialogue:n.removeDialogue},r);f&&i._narrationHistory.set(t,f);}});}async restore(e){this.clear();try{e.hasOwnProperty("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"),e.hasOwnProperty("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};
|