@drincs/pixi-vn
Version:
Pixi'VN is a npm package that provides various features for creating visual novels.
2 lines • 26.2 kB
JavaScript
'use strict';var core=require('@drincs/pixi-vn/core');var re=Object.defineProperty;var Xt=u=>{throw TypeError(u)};var ae=(u,e,t)=>e in u?re(u,e,{enumerable:true,configurable:true,writable:true,value:t}):u[e]=t;var g=(u,e,t)=>ae(u,typeof e!="symbol"?e+"":e,t),Kt=(u,e,t)=>e.has(u)||Xt("Cannot "+t);var i=(u,e,t)=>(Kt(u,e,"read from private field"),t?t.call(u):e.get(u)),m=(u,e,t)=>e.has(u)?Xt("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(u):e.set(u,t),f=(u,e,t,s)=>(Kt(u,e,"write to private field"),e.set(u,t),t),l=(u,e,t)=>(Kt(u,e,"access private method"),t);var Ft=(u,e,t,s)=>({set _(a){f(u,e,a);},get _(){return i(u,e,s)}});var ot="storage",ft="temp",Gt="flags",V={CHARACTER_CATEGORY_KEY:"character"};var k;(a=>(a.log=(o,...r)=>console.log(`[Pixi\u2019VN] ${o}`,...r),a.warn=(o,...r)=>console.warn(`[Pixi\u2019VN] ${o}`,...r),a.error=(o,...r)=>console.error(`[Pixi\u2019VN] ${o}`,...r),a.info=(o,...r)=>console.info(`[Pixi\u2019VN] ${o}`,...r)))(k||(k={}));function Ct(u){try{if(typeof u>"u")return u;let e=JSON.stringify(u);return JSON.parse(e)}catch(e){throw k.error("Error creating exportable element",u,e),new core.PixiError("not_json_serializable","Error creating exportable element")}}var ne=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,Zt=new Set,Wt=typeof process=="object"&&process?process:{},te=(u,e,t,s)=>{typeof Wt.emitWarning=="function"?Wt.emitWarning(u,e,t,s):console.error(`[${t}] ${e}: ${u}`);},zt=globalThis.AbortController,Jt=globalThis.AbortSignal;if(typeof zt>"u"){Jt=class{constructor(){g(this,"onabort");g(this,"_onabort",[]);g(this,"reason");g(this,"aborted",false);}addEventListener(t,s){this._onabort.push(s);}},zt=class{constructor(){g(this,"signal",new Jt);e();}abort(t){if(!this.signal.aborted){this.signal.reason=t,this.signal.aborted=true;for(let s of this.signal._onabort)s(t);this.signal.onabort?.(t);}}};let u=Wt.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",e=()=>{u&&(u=false,te("AbortController is not defined. If using lru-cache in node 14, load an AbortController polyfill from the `node-abort-controller` package. A minimal polyfill is provided for use by LRUCache.fetch(), but it should not be relied upon in other contexts (eg, passing it to other APIs that use AbortController/AbortSignal might have undesirable effects). You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.","NO_ABORT_CONTROLLER","ENOTSUP",e));};}var he=u=>!Zt.has(u);var nt=u=>u&&u===Math.floor(u)&&u>0&&isFinite(u),ee=u=>nt(u)?u<=Math.pow(2,8)?Uint8Array:u<=Math.pow(2,16)?Uint16Array:u<=Math.pow(2,32)?Uint32Array:u<=Number.MAX_SAFE_INTEGER?Lt:null:null,Lt=class extends Array{constructor(u){super(u),this.fill(0);}},it,Et,le=(it=class{constructor(e,t){g(this,"heap");g(this,"length");if(!i(it,Et))throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new t(e),this.length=0;}static create(e){let t=ee(e);if(!t)return [];f(it,Et,true);let s=new it(e,t);return f(it,Et,false),s}push(e){this.heap[this.length++]=e;}pop(){return this.heap[--this.length]}},Et=new WeakMap,m(it,Et,false),it),qt,Qt,$,U,H,dt,B,Tt,bt,X,O,J,w,A,d,M,z,I,R,q,x,Q,Z,P,Y,tt,ct,F,At,n,jt,gt,st,Dt,K,se,pt,yt,Nt,ht,lt,$t,Vt,Ut,b,kt,It,ut,Ht,vt,ie=(vt=class{constructor(e){m(this,n);m(this,$);m(this,U);m(this,H);m(this,dt);m(this,B);m(this,Tt);m(this,bt);m(this,X);g(this,"ttl");g(this,"ttlResolution");g(this,"ttlAutopurge");g(this,"updateAgeOnGet");g(this,"updateAgeOnHas");g(this,"allowStale");g(this,"noDisposeOnSet");g(this,"noUpdateTTL");g(this,"maxEntrySize");g(this,"sizeCalculation");g(this,"noDeleteOnFetchRejection");g(this,"noDeleteOnStaleGet");g(this,"allowStaleOnFetchAbort");g(this,"allowStaleOnFetchRejection");g(this,"ignoreFetchAbort");m(this,O);m(this,J);m(this,w);m(this,A);m(this,d);m(this,M);m(this,z);m(this,I);m(this,R);m(this,q);m(this,x);m(this,Q);m(this,Z);m(this,P);m(this,Y);m(this,tt);m(this,ct);m(this,F);m(this,At);m(this,gt,()=>{});m(this,st,()=>{});m(this,Dt,()=>{});m(this,K,()=>false);m(this,pt,e=>{});m(this,yt,(e,t,s)=>{});m(this,Nt,(e,t,s,a)=>{if(s||a)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0});g(this,qt,"LRUCache");let{max:t=0,ttl:s,ttlResolution:a=1,ttlAutopurge:o,updateAgeOnGet:r,updateAgeOnHas:h,allowStale:c,dispose:S,onInsert:C,disposeAfter:E,noDisposeOnSet:at,noUpdateTTL:W,maxSize:et=0,maxEntrySize:y=0,sizeCalculation:T,fetchMethod:p,memoMethod:D,noDeleteOnFetchRejection:L,noDeleteOnStaleGet:N,allowStaleOnFetchRejection:v,allowStaleOnFetchAbort:xt,ignoreFetchAbort:_t,perf:mt}=e;if(mt!==void 0&&typeof mt?.now!="function")throw new TypeError("perf option must have a now() method if specified");if(f(this,X,mt??ne),t!==0&&!nt(t))throw new TypeError("max option must be a nonnegative integer");let St=t?ee(t):Array;if(!St)throw new Error("invalid max value: "+t);if(f(this,$,t),f(this,U,et),this.maxEntrySize=y||i(this,U),this.sizeCalculation=T,this.sizeCalculation){if(!i(this,U)&&!this.maxEntrySize)throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");if(typeof this.sizeCalculation!="function")throw new TypeError("sizeCalculation set to non-function")}if(D!==void 0&&typeof D!="function")throw new TypeError("memoMethod must be a function if defined");if(f(this,bt,D),p!==void 0&&typeof p!="function")throw new TypeError("fetchMethod must be a function if specified");if(f(this,Tt,p),f(this,ct,!!p),f(this,w,new Map),f(this,A,new Array(t).fill(void 0)),f(this,d,new Array(t).fill(void 0)),f(this,M,new St(t)),f(this,z,new St(t)),f(this,I,0),f(this,R,0),f(this,q,le.create(t)),f(this,O,0),f(this,J,0),typeof S=="function"&&f(this,H,S),typeof C=="function"&&f(this,dt,C),typeof E=="function"?(f(this,B,E),f(this,x,[])):(f(this,B,void 0),f(this,x,void 0)),f(this,tt,!!i(this,H)),f(this,At,!!i(this,dt)),f(this,F,!!i(this,B)),this.noDisposeOnSet=!!at,this.noUpdateTTL=!!W,this.noDeleteOnFetchRejection=!!L,this.allowStaleOnFetchRejection=!!v,this.allowStaleOnFetchAbort=!!xt,this.ignoreFetchAbort=!!_t,this.maxEntrySize!==0){if(i(this,U)!==0&&!nt(i(this,U)))throw new TypeError("maxSize must be a positive integer if specified");if(!nt(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");l(this,n,se).call(this);}if(this.allowStale=!!c,this.noDeleteOnStaleGet=!!N,this.updateAgeOnGet=!!r,this.updateAgeOnHas=!!h,this.ttlResolution=nt(a)||a===0?a:1,this.ttlAutopurge=!!o,this.ttl=s||0,this.ttl){if(!nt(this.ttl))throw new TypeError("ttl must be a positive integer if specified");l(this,n,jt).call(this);}if(i(this,$)===0&&this.ttl===0&&i(this,U)===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!i(this,$)&&!i(this,U)){let Yt="LRU_CACHE_UNBOUNDED";he(Yt)&&(Zt.add(Yt),te("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",Yt,vt));}}get perf(){return i(this,X)}static unsafeExposeInternals(e){return {starts:i(e,Z),ttls:i(e,P),autopurgeTimers:i(e,Y),sizes:i(e,Q),keyMap:i(e,w),keyList:i(e,A),valList:i(e,d),next:i(e,M),prev:i(e,z),get head(){return i(e,I)},get tail(){return i(e,R)},free:i(e,q),isBackgroundFetch:t=>{var s;return l(s=e,n,b).call(s,t)},backgroundFetch:(t,s,a,o)=>{var r;return l(r=e,n,Ut).call(r,t,s,a,o)},moveToTail:t=>{var s;return l(s=e,n,It).call(s,t)},indexes:t=>{var s;return l(s=e,n,ht).call(s,t)},rindexes:t=>{var s;return l(s=e,n,lt).call(s,t)},isStale:t=>{var s;return i(s=e,K).call(s,t)}}}get max(){return i(this,$)}get maxSize(){return i(this,U)}get calculatedSize(){return i(this,J)}get size(){return i(this,O)}get fetchMethod(){return i(this,Tt)}get memoMethod(){return i(this,bt)}get dispose(){return i(this,H)}get onInsert(){return i(this,dt)}get disposeAfter(){return i(this,B)}getRemainingTTL(e){return i(this,w).has(e)?1/0:0}*entries(){for(let e of l(this,n,ht).call(this))i(this,d)[e]!==void 0&&i(this,A)[e]!==void 0&&!l(this,n,b).call(this,i(this,d)[e])&&(yield [i(this,A)[e],i(this,d)[e]]);}*rentries(){for(let e of l(this,n,lt).call(this))i(this,d)[e]!==void 0&&i(this,A)[e]!==void 0&&!l(this,n,b).call(this,i(this,d)[e])&&(yield [i(this,A)[e],i(this,d)[e]]);}*keys(){for(let e of l(this,n,ht).call(this)){let t=i(this,A)[e];t!==void 0&&!l(this,n,b).call(this,i(this,d)[e])&&(yield t);}}*rkeys(){for(let e of l(this,n,lt).call(this)){let t=i(this,A)[e];t!==void 0&&!l(this,n,b).call(this,i(this,d)[e])&&(yield t);}}*values(){for(let e of l(this,n,ht).call(this))i(this,d)[e]!==void 0&&!l(this,n,b).call(this,i(this,d)[e])&&(yield i(this,d)[e]);}*rvalues(){for(let e of l(this,n,lt).call(this))i(this,d)[e]!==void 0&&!l(this,n,b).call(this,i(this,d)[e])&&(yield i(this,d)[e]);}[(Qt=Symbol.iterator,qt=Symbol.toStringTag,Qt)](){return this.entries()}find(e,t={}){for(let s of l(this,n,ht).call(this)){let a=i(this,d)[s],o=l(this,n,b).call(this,a)?a.__staleWhileFetching:a;if(o!==void 0&&e(o,i(this,A)[s],this))return this.get(i(this,A)[s],t)}}forEach(e,t=this){for(let s of l(this,n,ht).call(this)){let a=i(this,d)[s],o=l(this,n,b).call(this,a)?a.__staleWhileFetching:a;o!==void 0&&e.call(t,o,i(this,A)[s],this);}}rforEach(e,t=this){for(let s of l(this,n,lt).call(this)){let a=i(this,d)[s],o=l(this,n,b).call(this,a)?a.__staleWhileFetching:a;o!==void 0&&e.call(t,o,i(this,A)[s],this);}}purgeStale(){let e=false;for(let t of l(this,n,lt).call(this,{allowStale:true}))i(this,K).call(this,t)&&(l(this,n,ut).call(this,i(this,A)[t],"expire"),e=true);return e}info(e){let t=i(this,w).get(e);if(t===void 0)return;let s=i(this,d)[t],a=l(this,n,b).call(this,s)?s.__staleWhileFetching:s;if(a===void 0)return;let o={value:a};if(i(this,P)&&i(this,Z)){let r=i(this,P)[t],h=i(this,Z)[t];if(r&&h){let c=r-(i(this,X).now()-h);o.ttl=c,o.start=Date.now();}}return i(this,Q)&&(o.size=i(this,Q)[t]),o}dump(){let e=[];for(let t of l(this,n,ht).call(this,{allowStale:true})){let s=i(this,A)[t],a=i(this,d)[t],o=l(this,n,b).call(this,a)?a.__staleWhileFetching:a;if(o===void 0||s===void 0)continue;let r={value:o};if(i(this,P)&&i(this,Z)){r.ttl=i(this,P)[t];let h=i(this,X).now()-i(this,Z)[t];r.start=Math.floor(Date.now()-h);}i(this,Q)&&(r.size=i(this,Q)[t]),e.unshift([s,r]);}return e}load(e){this.clear();for(let[t,s]of e){if(s.start){let a=Date.now()-s.start;s.start=i(this,X).now()-a;}this.set(t,s.value,s);}}set(e,t,s={}){var at,W,et,y;if(t===void 0)return this.delete(e),this;let{ttl:a=this.ttl,start:o,noDisposeOnSet:r=this.noDisposeOnSet,sizeCalculation:h=this.sizeCalculation,status:c}=s,{noUpdateTTL:S=this.noUpdateTTL}=s,C=i(this,Nt).call(this,e,t,s.size||0,h);if(this.maxEntrySize&&C>this.maxEntrySize)return c&&(c.set="miss",c.maxEntrySizeExceeded=true),l(this,n,ut).call(this,e,"set"),this;let E=i(this,O)===0?void 0:i(this,w).get(e);if(E===void 0)E=i(this,O)===0?i(this,R):i(this,q).length!==0?i(this,q).pop():i(this,O)===i(this,$)?l(this,n,Vt).call(this,false):i(this,O),i(this,A)[E]=e,i(this,d)[E]=t,i(this,w).set(e,E),i(this,M)[i(this,R)]=E,i(this,z)[E]=i(this,R),f(this,R,E),Ft(this,O)._++,i(this,yt).call(this,E,C,c),c&&(c.set="add"),S=false,i(this,At)&&((at=i(this,dt))==null||at.call(this,t,e,"add"));else {l(this,n,It).call(this,E);let T=i(this,d)[E];if(t!==T){if(i(this,ct)&&l(this,n,b).call(this,T)){T.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:p}=T;p!==void 0&&!r&&(i(this,tt)&&((W=i(this,H))==null||W.call(this,p,e,"set")),i(this,F)&&i(this,x)?.push([p,e,"set"]));}else r||(i(this,tt)&&((et=i(this,H))==null||et.call(this,T,e,"set")),i(this,F)&&i(this,x)?.push([T,e,"set"]));if(i(this,pt).call(this,E),i(this,yt).call(this,E,C,c),i(this,d)[E]=t,c){c.set="replace";let p=T&&l(this,n,b).call(this,T)?T.__staleWhileFetching:T;p!==void 0&&(c.oldValue=p);}}else c&&(c.set="update");i(this,At)&&this.onInsert?.(t,e,t===T?"update":"replace");}if(a!==0&&!i(this,P)&&l(this,n,jt).call(this),i(this,P)&&(S||i(this,Dt).call(this,E,a,o),c&&i(this,st).call(this,c,E)),!r&&i(this,F)&&i(this,x)){let T=i(this,x),p;for(;p=T?.shift();)(y=i(this,B))==null||y.call(this,...p);}return this}pop(){var e;try{for(;i(this,O);){let t=i(this,d)[i(this,I)];if(l(this,n,Vt).call(this,!0),l(this,n,b).call(this,t)){if(t.__staleWhileFetching)return t.__staleWhileFetching}else if(t!==void 0)return t}}finally{if(i(this,F)&&i(this,x)){let t=i(this,x),s;for(;s=t?.shift();)(e=i(this,B))==null||e.call(this,...s);}}}has(e,t={}){let{updateAgeOnHas:s=this.updateAgeOnHas,status:a}=t,o=i(this,w).get(e);if(o!==void 0){let r=i(this,d)[o];if(l(this,n,b).call(this,r)&&r.__staleWhileFetching===void 0)return false;if(i(this,K).call(this,o))a&&(a.has="stale",i(this,st).call(this,a,o));else return s&&i(this,gt).call(this,o),a&&(a.has="hit",i(this,st).call(this,a,o)),true}else a&&(a.has="miss");return false}peek(e,t={}){let{allowStale:s=this.allowStale}=t,a=i(this,w).get(e);if(a===void 0||!s&&i(this,K).call(this,a))return;let o=i(this,d)[a];return l(this,n,b).call(this,o)?o.__staleWhileFetching:o}async fetch(e,t={}){let{allowStale:s=this.allowStale,updateAgeOnGet:a=this.updateAgeOnGet,noDeleteOnStaleGet:o=this.noDeleteOnStaleGet,ttl:r=this.ttl,noDisposeOnSet:h=this.noDisposeOnSet,size:c=0,sizeCalculation:S=this.sizeCalculation,noUpdateTTL:C=this.noUpdateTTL,noDeleteOnFetchRejection:E=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:at=this.allowStaleOnFetchRejection,ignoreFetchAbort:W=this.ignoreFetchAbort,allowStaleOnFetchAbort:et=this.allowStaleOnFetchAbort,context:y,forceRefresh:T=false,status:p,signal:D}=t;if(!i(this,ct))return p&&(p.fetch="get"),this.get(e,{allowStale:s,updateAgeOnGet:a,noDeleteOnStaleGet:o,status:p});let L={allowStale:s,updateAgeOnGet:a,noDeleteOnStaleGet:o,ttl:r,noDisposeOnSet:h,size:c,sizeCalculation:S,noUpdateTTL:C,noDeleteOnFetchRejection:E,allowStaleOnFetchRejection:at,allowStaleOnFetchAbort:et,ignoreFetchAbort:W,status:p,signal:D},N=i(this,w).get(e);if(N===void 0){p&&(p.fetch="miss");let v=l(this,n,Ut).call(this,e,N,L,y);return v.__returned=v}else {let v=i(this,d)[N];if(l(this,n,b).call(this,v)){let St=s&&v.__staleWhileFetching!==void 0;return p&&(p.fetch="inflight",St&&(p.returnedStale=true)),St?v.__staleWhileFetching:v.__returned=v}let xt=i(this,K).call(this,N);if(!T&&!xt)return p&&(p.fetch="hit"),l(this,n,It).call(this,N),a&&i(this,gt).call(this,N),p&&i(this,st).call(this,p,N),v;let _t=l(this,n,Ut).call(this,e,N,L,y),mt=_t.__staleWhileFetching!==void 0&&s;return p&&(p.fetch=xt?"stale":"refresh",mt&&xt&&(p.returnedStale=true)),mt?_t.__staleWhileFetching:_t.__returned=_t}}async forceFetch(e,t={}){let s=await this.fetch(e,t);if(s===void 0)throw new Error("fetch() returned undefined");return s}memo(e,t={}){let s=i(this,bt);if(!s)throw new Error("no memoMethod provided to constructor");let{context:a,forceRefresh:o,...r}=t,h=this.get(e,r);if(!o&&h!==void 0)return h;let c=s(e,h,{options:r,context:a});return this.set(e,c,r),c}get(e,t={}){let{allowStale:s=this.allowStale,updateAgeOnGet:a=this.updateAgeOnGet,noDeleteOnStaleGet:o=this.noDeleteOnStaleGet,status:r}=t,h=i(this,w).get(e);if(h!==void 0){let c=i(this,d)[h],S=l(this,n,b).call(this,c);return r&&i(this,st).call(this,r,h),i(this,K).call(this,h)?(r&&(r.get="stale"),S?(r&&s&&c.__staleWhileFetching!==void 0&&(r.returnedStale=true),s?c.__staleWhileFetching:void 0):(o||l(this,n,ut).call(this,e,"expire"),r&&s&&(r.returnedStale=true),s?c:void 0)):(r&&(r.get="hit"),S?c.__staleWhileFetching:(l(this,n,It).call(this,h),a&&i(this,gt).call(this,h),c))}else r&&(r.get="miss");}delete(e){return l(this,n,ut).call(this,e,"delete")}clear(){return l(this,n,Ht).call(this,"delete")}},$=new WeakMap,U=new WeakMap,H=new WeakMap,dt=new WeakMap,B=new WeakMap,Tt=new WeakMap,bt=new WeakMap,X=new WeakMap,O=new WeakMap,J=new WeakMap,w=new WeakMap,A=new WeakMap,d=new WeakMap,M=new WeakMap,z=new WeakMap,I=new WeakMap,R=new WeakMap,q=new WeakMap,x=new WeakMap,Q=new WeakMap,Z=new WeakMap,P=new WeakMap,Y=new WeakMap,tt=new WeakMap,ct=new WeakMap,F=new WeakMap,At=new WeakMap,n=new WeakSet,jt=function(){let e=new Lt(i(this,$)),t=new Lt(i(this,$));f(this,P,e),f(this,Z,t);let s=this.ttlAutopurge?new Array(i(this,$)):void 0;f(this,Y,s),f(this,Dt,(h,c,S=i(this,X).now())=>{t[h]=c!==0?S:0,e[h]=c,a(h,c);}),f(this,gt,h=>{t[h]=e[h]!==0?i(this,X).now():0,a(h,e[h]);});let a=this.ttlAutopurge?(h,c)=>{if(s?.[h]&&(clearTimeout(s[h]),s[h]=void 0),c&&c!==0&&s){let S=setTimeout(()=>{i(this,K).call(this,h)&&l(this,n,ut).call(this,i(this,A)[h],"expire");},c+1);S.unref&&S.unref(),s[h]=S;}}:()=>{};f(this,st,(h,c)=>{if(e[c]){let S=e[c],C=t[c];if(!S||!C)return;h.ttl=S,h.start=C,h.now=o||r();let E=h.now-C;h.remainingTTL=S-E;}});let o=0,r=()=>{let h=i(this,X).now();if(this.ttlResolution>0){o=h;let c=setTimeout(()=>o=0,this.ttlResolution);c.unref&&c.unref();}return h};this.getRemainingTTL=h=>{let c=i(this,w).get(h);if(c===void 0)return 0;let S=e[c],C=t[c];if(!S||!C)return 1/0;let E=(o||r())-C;return S-E},f(this,K,h=>{let c=t[h],S=e[h];return !!S&&!!c&&(o||r())-c>S});},gt=new WeakMap,st=new WeakMap,Dt=new WeakMap,K=new WeakMap,se=function(){let e=new Lt(i(this,$));f(this,J,0),f(this,Q,e),f(this,pt,t=>{f(this,J,i(this,J)-e[t]),e[t]=0;}),f(this,Nt,(t,s,a,o)=>{if(l(this,n,b).call(this,s))return 0;if(!nt(a))if(o){if(typeof o!="function")throw new TypeError("sizeCalculation must be a function");if(a=o(s,t),!nt(a))throw new TypeError("sizeCalculation return invalid (expect positive integer)")}else throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");return a}),f(this,yt,(t,s,a)=>{if(e[t]=s,i(this,U)){let o=i(this,U)-e[t];for(;i(this,J)>o;)l(this,n,Vt).call(this,true);}f(this,J,i(this,J)+e[t]),a&&(a.entrySize=s,a.totalCalculatedSize=i(this,J));});},pt=new WeakMap,yt=new WeakMap,Nt=new WeakMap,ht=function*({allowStale:e=this.allowStale}={}){if(i(this,O))for(let t=i(this,R);!(!l(this,n,$t).call(this,t)||((e||!i(this,K).call(this,t))&&(yield t),t===i(this,I)));)t=i(this,z)[t];},lt=function*({allowStale:e=this.allowStale}={}){if(i(this,O))for(let t=i(this,I);!(!l(this,n,$t).call(this,t)||((e||!i(this,K).call(this,t))&&(yield t),t===i(this,R)));)t=i(this,M)[t];},$t=function(e){return e!==void 0&&i(this,w).get(i(this,A)[e])===e},Vt=function(e){var o;let t=i(this,I),s=i(this,A)[t],a=i(this,d)[t];return i(this,ct)&&l(this,n,b).call(this,a)?a.__abortController.abort(new Error("evicted")):(i(this,tt)||i(this,F))&&(i(this,tt)&&((o=i(this,H))==null||o.call(this,a,s,"evict")),i(this,F)&&i(this,x)?.push([a,s,"evict"])),i(this,pt).call(this,t),i(this,Y)?.[t]&&(clearTimeout(i(this,Y)[t]),i(this,Y)[t]=void 0),e&&(i(this,A)[t]=void 0,i(this,d)[t]=void 0,i(this,q).push(t)),i(this,O)===1?(f(this,I,f(this,R,0)),i(this,q).length=0):f(this,I,i(this,M)[t]),i(this,w).delete(s),Ft(this,O)._--,t},Ut=function(e,t,s,a){let o=t===void 0?void 0:i(this,d)[t];if(l(this,n,b).call(this,o))return o;let r=new zt,{signal:h}=s;h?.addEventListener("abort",()=>r.abort(h.reason),{signal:r.signal});let c={signal:r.signal,options:s,context:a},S=(y,T=false)=>{let{aborted:p}=r.signal,D=s.ignoreFetchAbort&&y!==void 0,L=s.ignoreFetchAbort||!!(s.allowStaleOnFetchAbort&&y!==void 0);if(s.status&&(p&&!T?(s.status.fetchAborted=true,s.status.fetchError=r.signal.reason,D&&(s.status.fetchAbortIgnored=true)):s.status.fetchResolved=true),p&&!D&&!T)return E(r.signal.reason,L);let N=W,v=i(this,d)[t];return (v===W||D&&T&&v===void 0)&&(y===void 0?N.__staleWhileFetching!==void 0?i(this,d)[t]=N.__staleWhileFetching:l(this,n,ut).call(this,e,"fetch"):(s.status&&(s.status.fetchUpdated=true),this.set(e,y,c.options))),y},C=y=>(s.status&&(s.status.fetchRejected=true,s.status.fetchError=y),E(y,false)),E=(y,T)=>{let{aborted:p}=r.signal,D=p&&s.allowStaleOnFetchAbort,L=D||s.allowStaleOnFetchRejection,N=L||s.noDeleteOnFetchRejection,v=W;if(i(this,d)[t]===W&&(!N||!T&&v.__staleWhileFetching===void 0?l(this,n,ut).call(this,e,"fetch"):D||(i(this,d)[t]=v.__staleWhileFetching)),L)return s.status&&v.__staleWhileFetching!==void 0&&(s.status.returnedStale=true),v.__staleWhileFetching;if(v.__returned===v)throw y},at=(y,T)=>{var D;let p=(D=i(this,Tt))==null?void 0:D.call(this,e,o,c);p&&p instanceof Promise&&p.then(L=>y(L===void 0?void 0:L),T),r.signal.addEventListener("abort",()=>{(!s.ignoreFetchAbort||s.allowStaleOnFetchAbort)&&(y(void 0),s.allowStaleOnFetchAbort&&(y=L=>S(L,true)));});};s.status&&(s.status.fetchDispatched=true);let W=new Promise(at).then(S,C),et=Object.assign(W,{__abortController:r,__staleWhileFetching:o,__returned:void 0});return t===void 0?(this.set(e,et,{...c.options,status:void 0}),t=i(this,w).get(e)):i(this,d)[t]=et,et},b=function(e){if(!i(this,ct))return false;let t=e;return !!t&&t instanceof Promise&&t.hasOwnProperty("__staleWhileFetching")&&t.__abortController instanceof zt},kt=function(e,t){i(this,z)[t]=e,i(this,M)[e]=t;},It=function(e){e!==i(this,R)&&(e===i(this,I)?f(this,I,i(this,M)[e]):l(this,n,kt).call(this,i(this,z)[e],i(this,M)[e]),l(this,n,kt).call(this,i(this,R),e),f(this,R,e));},ut=function(e,t){var a,o;let s=false;if(i(this,O)!==0){let r=i(this,w).get(e);if(r!==void 0)if(i(this,Y)?.[r]&&(clearTimeout(i(this,Y)?.[r]),i(this,Y)[r]=void 0),s=true,i(this,O)===1)l(this,n,Ht).call(this,t);else {i(this,pt).call(this,r);let h=i(this,d)[r];if(l(this,n,b).call(this,h)?h.__abortController.abort(new Error("deleted")):(i(this,tt)||i(this,F))&&(i(this,tt)&&((a=i(this,H))==null||a.call(this,h,e,t)),i(this,F)&&i(this,x)?.push([h,e,t])),i(this,w).delete(e),i(this,A)[r]=void 0,i(this,d)[r]=void 0,r===i(this,R))f(this,R,i(this,z)[r]);else if(r===i(this,I))f(this,I,i(this,M)[r]);else {let c=i(this,z)[r];i(this,M)[c]=i(this,M)[r];let S=i(this,M)[r];i(this,z)[S]=i(this,z)[r];}Ft(this,O)._--,i(this,q).push(r);}}if(i(this,F)&&i(this,x)?.length){let r=i(this,x),h;for(;h=r?.shift();)(o=i(this,B))==null||o.call(this,...h);}return s},Ht=function(e){var t,s;for(let a of l(this,n,lt).call(this,{allowStale:true})){let o=i(this,d)[a];if(l(this,n,b).call(this,o))o.__abortController.abort(new Error("deleted"));else {let r=i(this,A)[a];i(this,tt)&&((t=i(this,H))==null||t.call(this,o,r,e)),i(this,F)&&i(this,x)?.push([o,r,e]);}}if(i(this,w).clear(),i(this,d).fill(void 0),i(this,A).fill(void 0),i(this,P)&&i(this,Z)){i(this,P).fill(0),i(this,Z).fill(0);for(let a of i(this,Y)??[])a!==void 0&&clearTimeout(a);i(this,Y)?.fill(void 0);}if(i(this,Q)&&i(this,Q).fill(0),f(this,I,0),f(this,R,0),i(this,q).length=0,f(this,J,0),f(this,O,0),i(this,F)&&i(this,x)){let a=i(this,x),o;for(;o=a?.shift();)(s=i(this,B))==null||s.call(this,...o);}},vt);var rt=class{constructor(e){g(this,"cache");g(this,"map",new Map);this.cache=new ie({max:e.cacheSize}),this.map=new Map;}get[Symbol.iterator](){return this.map[Symbol.iterator]}get[Symbol.toStringTag](){return this.map[Symbol.toStringTag]}clear(){return this.cache.clear(),this.map.clear()}delete(e){let t=this.map.delete(e);return t&&this.cache.delete(e),t}get forEach(){return this.map.forEach}get(e){let t=this.cache.get(e);return t||this.map.get(e)}has(e){return this.map.has(e)}set(e,t){return this.map.set(e,t),this.cache.set(e,t),this}get size(){return this.map.size}entries(){return this.map.entries()}keys(){return this.map.keys()}values(){return this.map.values()}};var G=class G{constructor(){}static clearOldTempVariables(e){G.tempStorageDeadlines.forEach((t,s)=>{t>e&&(G.removeVariable(ft,s),G.tempStorageDeadlines.delete(s));});}static setVariable(e,t,s){s==null?G.storage.delete(`${e}:${t}`):G.storage.set(`${e}:${t}`,s);}static getVariable(e,t){let s=G.storage.get(`${e}:${t}`);return Ct(s)}static removeVariable(e,t){G.storage.delete(`${e}:${t}`);}static setFlag(e,t){let s=G.storage.get(Gt)||[];if(t)s.includes(e)||s.push(e);else {let a=s.indexOf(e);a>-1&&s.splice(a,1);}G.storage.set(Gt,s);}static getFlag(e){return (G.storage.get(Gt)||[]).includes(e)}};g(G,"storage",new rt({cacheSize:50})),g(G,"default",new rt({cacheSize:10})),g(G,"tempStorageDeadlines",new Map);var _=G;var wt=class{constructor(e,t){g(this,"id");g(this,"categoryId");this.categoryId=e,this.id=t,this.migrateOldStorage();}migrateOldStorage(e=this.categoryId){let t=_.getVariable(ot,e);t&&(Object.entries(t).forEach(([s,a])=>{typeof a=="object"&&a!==null&&Object.entries(a).forEach(([o,r])=>{_.setVariable(this.categoryId,`${s}:${o}`,r);});}),_.removeVariable(ot,e));}setStorageProperty(e,t){_.setVariable(this.categoryId,`${this.id}:${e}`,t);}getStorageProperty(e,t=this.id){return _.getVariable(this.categoryId,`${t}:${e}`)}};var ce="@",Ot=class extends wt{constructor(t,s=""){super(V.CHARACTER_CATEGORY_KEY,t+(s?ce+s:""));g(this,"sourceId");this.sourceId=t,this.migrateOldStorage("___character___");}getStorageProperty(t){let s=super.getStorageProperty(t);return s===void 0&&(s=super.getStorageProperty(t,this.sourceId)),s}};var Pt=class extends Ot{constructor(t,s){super(typeof t=="string"?t:t.id,typeof t=="string"?"":t.emotion);g(this,"defaultName");g(this,"defaultSurname");g(this,"defaultAge");g(this,"_icon");g(this,"_color");this.defaultName=s.name,this.defaultSurname=s.surname,this.defaultAge=s.age,this._icon=s.icon,this._color=s.color;}get name(){return this.getStorageProperty("name")||this.defaultName||this.id}set name(t){this.setStorageProperty("name",t);}get surname(){return this.getStorageProperty("surname")||this.defaultSurname}set surname(t){this.setStorageProperty("surname",t);}get age(){return this.getStorageProperty("age")||this.defaultAge}set age(t){this.setStorageProperty("age",t);}get icon(){return this._icon}get color(){return this._color}};var Rt=new rt({cacheSize:10}),Bt;(o=>{function u(r){try{let h=Rt.get(r);if(!h){k.warn(`Character "${r}" not found, did you forget to register it with the RegisteredCharacters.add?`);return}return h}catch(h){k.error(`Error while getting Character "${r}"`,h);return}}o.get=u;function e(r){if(Array.isArray(r)){r.forEach(h=>e(h));return}Rt.get(r.id)&&k.info(`Character id "${r.id}" already exists, it will be overwritten`),Rt.set(r.id,r);}o.add=e;function t(){return Array.from(Rt.values())}o.values=t;function s(r){return Rt.has(r)}o.has=s;function a(){return Array.from(Rt.keys())}o.keys=a;})(Bt||(Bt={}));var fe=Bt;exports.CharacterBaseModel=Pt;exports.CharacterStoredClass=Ot;exports.RegisteredCharacters=fe;//# sourceMappingURL=characters.cjs.map
//# sourceMappingURL=characters.cjs.map