@drincs/pixi-vn
Version:
Pixi'VN is a npm package that provides various features for creating visual novels.
9 lines (8 loc) • 31.2 kB
JavaScript
'use strict';Object.defineProperty(exports,'__esModule',{value:true});var et=require('@drincs/pixi-vn/canvas'),Xt=require('@drincs/pixi-vn/characters'),core=require('@drincs/pixi-vn/core'),it=require('@drincs/pixi-vn/history'),C=require('@drincs/pixi-vn/narration'),at=require('@drincs/pixi-vn/sound'),I=require('@drincs/pixi-vn/storage'),motion=require('@drincs/pixi-vn/motion');function _interopNamespace(e){if(e&&e.__esModule)return e;var n=Object.create(null);if(e){Object.keys(e).forEach(function(k){if(k!=='default'){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:function(){return e[k]}});}})}n.default=e;return Object.freeze(n)}var et__namespace=/*#__PURE__*/_interopNamespace(et);var Xt__namespace=/*#__PURE__*/_interopNamespace(Xt);var it__namespace=/*#__PURE__*/_interopNamespace(it);var C__namespace=/*#__PURE__*/_interopNamespace(C);var at__namespace=/*#__PURE__*/_interopNamespace(at);var I__namespace=/*#__PURE__*/_interopNamespace(I);var $t=Object.defineProperty;var Bt=h=>{throw TypeError(h)};var le=(h,e,i)=>e in h?$t(h,e,{enumerable:true,configurable:true,writable:true,value:i}):h[e]=i;var he=(h,e)=>{for(var i in e)$t(h,i,{get:e[i],enumerable:true});};var y=(h,e,i)=>le(h,typeof e!="symbol"?e+"":e,i),jt=(h,e,i)=>e.has(h)||Bt("Cannot "+i);var t=(h,e,i)=>(jt(h,e,"read from private field"),i?i.call(h):e.get(h)),g=(h,e,i)=>e.has(h)?Bt("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(h):e.set(h,i),u=(h,e,i,s)=>(jt(h,e,"write to private field"),e.set(h,i),i),d=(h,e,i)=>(jt(h,e,"access private method"),i);var Rt=(h,e,i,s)=>({set _(r){u(h,e,r);},get _(){return t(h,e,s)}});var de=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,te=new Set,It=typeof process=="object"&&process?process:{},ee=(h,e,i,s)=>{typeof It.emitWarning=="function"?It.emitWarning(h,e,i,s):console.error(`[${i}] ${e}: ${h}`);},Nt=globalThis.AbortController,Jt=globalThis.AbortSignal;if(typeof Nt>"u"){Jt=class{constructor(){y(this,"onabort");y(this,"_onabort",[]);y(this,"reason");y(this,"aborted",false);}addEventListener(i,s){this._onabort.push(s);}},Nt=class{constructor(){y(this,"signal",new Jt);e();}abort(i){if(!this.signal.aborted){this.signal.reason=i,this.signal.aborted=true;for(let s of this.signal._onabort)s(i);this.signal.onabort?.(i);}}};let h=It.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",e=()=>{h&&(h=false,ee("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 ce=h=>!te.has(h);var lt=h=>h&&h===Math.floor(h)&&h>0&&isFinite(h),ie=h=>lt(h)?h<=Math.pow(2,8)?Uint8Array:h<=Math.pow(2,16)?Uint16Array:h<=Math.pow(2,32)?Uint32Array:h<=Number.MAX_SAFE_INTEGER?Dt:null:null,Dt=class extends Array{constructor(h){super(h),this.fill(0);}},st,St,pe=(st=class{constructor(e,i){y(this,"heap");y(this,"length");if(!t(st,St))throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new i(e),this.length=0;}static create(e){let i=ie(e);if(!i)return [];u(st,St,true);let s=new st(e,i);return u(st,St,false),s}push(e){this.heap[this.length++]=e;}pop(){return this.heap[--this.length]}},St=new WeakMap,g(st,St,false),st),Qt,Zt,K,G,q,ut,X,yt,Et,$,U,B,T,b,m,F,z,N,D,J,L,Q,Z,V,W,tt,pt,P,xt,l,Mt,ft,ot,Ot,Y,re,mt,At,Tt,ht,dt,Gt,Lt,Ct,A,zt,wt,ct,Vt,bt,se=(bt=class{constructor(e){g(this,l);g(this,K);g(this,G);g(this,q);g(this,ut);g(this,X);g(this,yt);g(this,Et);g(this,$);y(this,"ttl");y(this,"ttlResolution");y(this,"ttlAutopurge");y(this,"updateAgeOnGet");y(this,"updateAgeOnHas");y(this,"allowStale");y(this,"noDisposeOnSet");y(this,"noUpdateTTL");y(this,"maxEntrySize");y(this,"sizeCalculation");y(this,"noDeleteOnFetchRejection");y(this,"noDeleteOnStaleGet");y(this,"allowStaleOnFetchAbort");y(this,"allowStaleOnFetchRejection");y(this,"ignoreFetchAbort");g(this,U);g(this,B);g(this,T);g(this,b);g(this,m);g(this,F);g(this,z);g(this,N);g(this,D);g(this,J);g(this,L);g(this,Q);g(this,Z);g(this,V);g(this,W);g(this,tt);g(this,pt);g(this,P);g(this,xt);g(this,ft,()=>{});g(this,ot,()=>{});g(this,Ot,()=>{});g(this,Y,()=>false);g(this,mt,e=>{});g(this,At,(e,i,s)=>{});g(this,Tt,(e,i,s,r)=>{if(s||r)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0});y(this,Qt,"LRUCache");let{max:i=0,ttl:s,ttlResolution:r=1,ttlAutopurge:n,updateAgeOnGet:o,updateAgeOnHas:c,allowStale:p,dispose:v,onInsert:R,disposeAfter:S,noDisposeOnSet:rt,noUpdateTTL:M,maxSize:k=0,maxEntrySize:w=0,sizeCalculation:E,fetchMethod:a,memoMethod:x,noDeleteOnFetchRejection:O,noDeleteOnStaleGet:f,allowStaleOnFetchRejection:_,allowStaleOnFetchAbort:j,ignoreFetchAbort:H,perf:gt}=e;if(gt!==void 0&&typeof gt?.now!="function")throw new TypeError("perf option must have a now() method if specified");if(u(this,$,gt??de),i!==0&&!lt(i))throw new TypeError("max option must be a nonnegative integer");let vt=i?ie(i):Array;if(!vt)throw new Error("invalid max value: "+i);if(u(this,K,i),u(this,G,k),this.maxEntrySize=w||t(this,G),this.sizeCalculation=E,this.sizeCalculation){if(!t(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(x!==void 0&&typeof x!="function")throw new TypeError("memoMethod must be a function if defined");if(u(this,Et,x),a!==void 0&&typeof a!="function")throw new TypeError("fetchMethod must be a function if specified");if(u(this,yt,a),u(this,pt,!!a),u(this,T,new Map),u(this,b,new Array(i).fill(void 0)),u(this,m,new Array(i).fill(void 0)),u(this,F,new vt(i)),u(this,z,new vt(i)),u(this,N,0),u(this,D,0),u(this,J,pe.create(i)),u(this,U,0),u(this,B,0),typeof v=="function"&&u(this,q,v),typeof R=="function"&&u(this,ut,R),typeof S=="function"?(u(this,X,S),u(this,L,[])):(u(this,X,void 0),u(this,L,void 0)),u(this,tt,!!t(this,q)),u(this,xt,!!t(this,ut)),u(this,P,!!t(this,X)),this.noDisposeOnSet=!!rt,this.noUpdateTTL=!!M,this.noDeleteOnFetchRejection=!!O,this.allowStaleOnFetchRejection=!!_,this.allowStaleOnFetchAbort=!!j,this.ignoreFetchAbort=!!H,this.maxEntrySize!==0){if(t(this,G)!==0&&!lt(t(this,G)))throw new TypeError("maxSize must be a positive integer if specified");if(!lt(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");d(this,l,re).call(this);}if(this.allowStale=!!p,this.noDeleteOnStaleGet=!!f,this.updateAgeOnGet=!!o,this.updateAgeOnHas=!!c,this.ttlResolution=lt(r)||r===0?r:1,this.ttlAutopurge=!!n,this.ttl=s||0,this.ttl){if(!lt(this.ttl))throw new TypeError("ttl must be a positive integer if specified");d(this,l,Mt).call(this);}if(t(this,K)===0&&this.ttl===0&&t(this,G)===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!t(this,K)&&!t(this,G)){let Pt="LRU_CACHE_UNBOUNDED";ce(Pt)&&(te.add(Pt),ee("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",Pt,bt));}}get perf(){return t(this,$)}static unsafeExposeInternals(e){return {starts:t(e,Z),ttls:t(e,V),autopurgeTimers:t(e,W),sizes:t(e,Q),keyMap:t(e,T),keyList:t(e,b),valList:t(e,m),next:t(e,F),prev:t(e,z),get head(){return t(e,N)},get tail(){return t(e,D)},free:t(e,J),isBackgroundFetch:i=>{var s;return d(s=e,l,A).call(s,i)},backgroundFetch:(i,s,r,n)=>{var o;return d(o=e,l,Ct).call(o,i,s,r,n)},moveToTail:i=>{var s;return d(s=e,l,wt).call(s,i)},indexes:i=>{var s;return d(s=e,l,ht).call(s,i)},rindexes:i=>{var s;return d(s=e,l,dt).call(s,i)},isStale:i=>{var s;return t(s=e,Y).call(s,i)}}}get max(){return t(this,K)}get maxSize(){return t(this,G)}get calculatedSize(){return t(this,B)}get size(){return t(this,U)}get fetchMethod(){return t(this,yt)}get memoMethod(){return t(this,Et)}get dispose(){return t(this,q)}get onInsert(){return t(this,ut)}get disposeAfter(){return t(this,X)}getRemainingTTL(e){return t(this,T).has(e)?1/0:0}*entries(){for(let e of d(this,l,ht).call(this))t(this,m)[e]!==void 0&&t(this,b)[e]!==void 0&&!d(this,l,A).call(this,t(this,m)[e])&&(yield [t(this,b)[e],t(this,m)[e]]);}*rentries(){for(let e of d(this,l,dt).call(this))t(this,m)[e]!==void 0&&t(this,b)[e]!==void 0&&!d(this,l,A).call(this,t(this,m)[e])&&(yield [t(this,b)[e],t(this,m)[e]]);}*keys(){for(let e of d(this,l,ht).call(this)){let i=t(this,b)[e];i!==void 0&&!d(this,l,A).call(this,t(this,m)[e])&&(yield i);}}*rkeys(){for(let e of d(this,l,dt).call(this)){let i=t(this,b)[e];i!==void 0&&!d(this,l,A).call(this,t(this,m)[e])&&(yield i);}}*values(){for(let e of d(this,l,ht).call(this))t(this,m)[e]!==void 0&&!d(this,l,A).call(this,t(this,m)[e])&&(yield t(this,m)[e]);}*rvalues(){for(let e of d(this,l,dt).call(this))t(this,m)[e]!==void 0&&!d(this,l,A).call(this,t(this,m)[e])&&(yield t(this,m)[e]);}[(Zt=Symbol.iterator,Qt=Symbol.toStringTag,Zt)](){return this.entries()}find(e,i={}){for(let s of d(this,l,ht).call(this)){let r=t(this,m)[s],n=d(this,l,A).call(this,r)?r.__staleWhileFetching:r;if(n!==void 0&&e(n,t(this,b)[s],this))return this.get(t(this,b)[s],i)}}forEach(e,i=this){for(let s of d(this,l,ht).call(this)){let r=t(this,m)[s],n=d(this,l,A).call(this,r)?r.__staleWhileFetching:r;n!==void 0&&e.call(i,n,t(this,b)[s],this);}}rforEach(e,i=this){for(let s of d(this,l,dt).call(this)){let r=t(this,m)[s],n=d(this,l,A).call(this,r)?r.__staleWhileFetching:r;n!==void 0&&e.call(i,n,t(this,b)[s],this);}}purgeStale(){let e=false;for(let i of d(this,l,dt).call(this,{allowStale:true}))t(this,Y).call(this,i)&&(d(this,l,ct).call(this,t(this,b)[i],"expire"),e=true);return e}info(e){let i=t(this,T).get(e);if(i===void 0)return;let s=t(this,m)[i],r=d(this,l,A).call(this,s)?s.__staleWhileFetching:s;if(r===void 0)return;let n={value:r};if(t(this,V)&&t(this,Z)){let o=t(this,V)[i],c=t(this,Z)[i];if(o&&c){let p=o-(t(this,$).now()-c);n.ttl=p,n.start=Date.now();}}return t(this,Q)&&(n.size=t(this,Q)[i]),n}dump(){let e=[];for(let i of d(this,l,ht).call(this,{allowStale:true})){let s=t(this,b)[i],r=t(this,m)[i],n=d(this,l,A).call(this,r)?r.__staleWhileFetching:r;if(n===void 0||s===void 0)continue;let o={value:n};if(t(this,V)&&t(this,Z)){o.ttl=t(this,V)[i];let c=t(this,$).now()-t(this,Z)[i];o.start=Math.floor(Date.now()-c);}t(this,Q)&&(o.size=t(this,Q)[i]),e.unshift([s,o]);}return e}load(e){this.clear();for(let[i,s]of e){if(s.start){let r=Date.now()-s.start;s.start=t(this,$).now()-r;}this.set(i,s.value,s);}}set(e,i,s={}){var rt,M,k,w;if(i===void 0)return this.delete(e),this;let{ttl:r=this.ttl,start:n,noDisposeOnSet:o=this.noDisposeOnSet,sizeCalculation:c=this.sizeCalculation,status:p}=s,{noUpdateTTL:v=this.noUpdateTTL}=s,R=t(this,Tt).call(this,e,i,s.size||0,c);if(this.maxEntrySize&&R>this.maxEntrySize)return p&&(p.set="miss",p.maxEntrySizeExceeded=true),d(this,l,ct).call(this,e,"set"),this;let S=t(this,U)===0?void 0:t(this,T).get(e);if(S===void 0)S=t(this,U)===0?t(this,D):t(this,J).length!==0?t(this,J).pop():t(this,U)===t(this,K)?d(this,l,Lt).call(this,false):t(this,U),t(this,b)[S]=e,t(this,m)[S]=i,t(this,T).set(e,S),t(this,F)[t(this,D)]=S,t(this,z)[S]=t(this,D),u(this,D,S),Rt(this,U)._++,t(this,At).call(this,S,R,p),p&&(p.set="add"),v=false,t(this,xt)&&((rt=t(this,ut))==null||rt.call(this,i,e,"add"));else {d(this,l,wt).call(this,S);let E=t(this,m)[S];if(i!==E){if(t(this,pt)&&d(this,l,A).call(this,E)){E.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:a}=E;a!==void 0&&!o&&(t(this,tt)&&((M=t(this,q))==null||M.call(this,a,e,"set")),t(this,P)&&t(this,L)?.push([a,e,"set"]));}else o||(t(this,tt)&&((k=t(this,q))==null||k.call(this,E,e,"set")),t(this,P)&&t(this,L)?.push([E,e,"set"]));if(t(this,mt).call(this,S),t(this,At).call(this,S,R,p),t(this,m)[S]=i,p){p.set="replace";let a=E&&d(this,l,A).call(this,E)?E.__staleWhileFetching:E;a!==void 0&&(p.oldValue=a);}}else p&&(p.set="update");t(this,xt)&&this.onInsert?.(i,e,i===E?"update":"replace");}if(r!==0&&!t(this,V)&&d(this,l,Mt).call(this),t(this,V)&&(v||t(this,Ot).call(this,S,r,n),p&&t(this,ot).call(this,p,S)),!o&&t(this,P)&&t(this,L)){let E=t(this,L),a;for(;a=E?.shift();)(w=t(this,X))==null||w.call(this,...a);}return this}pop(){var e;try{for(;t(this,U);){let i=t(this,m)[t(this,N)];if(d(this,l,Lt).call(this,!0),d(this,l,A).call(this,i)){if(i.__staleWhileFetching)return i.__staleWhileFetching}else if(i!==void 0)return i}}finally{if(t(this,P)&&t(this,L)){let i=t(this,L),s;for(;s=i?.shift();)(e=t(this,X))==null||e.call(this,...s);}}}has(e,i={}){let{updateAgeOnHas:s=this.updateAgeOnHas,status:r}=i,n=t(this,T).get(e);if(n!==void 0){let o=t(this,m)[n];if(d(this,l,A).call(this,o)&&o.__staleWhileFetching===void 0)return false;if(t(this,Y).call(this,n))r&&(r.has="stale",t(this,ot).call(this,r,n));else return s&&t(this,ft).call(this,n),r&&(r.has="hit",t(this,ot).call(this,r,n)),true}else r&&(r.has="miss");return false}peek(e,i={}){let{allowStale:s=this.allowStale}=i,r=t(this,T).get(e);if(r===void 0||!s&&t(this,Y).call(this,r))return;let n=t(this,m)[r];return d(this,l,A).call(this,n)?n.__staleWhileFetching:n}async fetch(e,i={}){let{allowStale:s=this.allowStale,updateAgeOnGet:r=this.updateAgeOnGet,noDeleteOnStaleGet:n=this.noDeleteOnStaleGet,ttl:o=this.ttl,noDisposeOnSet:c=this.noDisposeOnSet,size:p=0,sizeCalculation:v=this.sizeCalculation,noUpdateTTL:R=this.noUpdateTTL,noDeleteOnFetchRejection:S=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:rt=this.allowStaleOnFetchRejection,ignoreFetchAbort:M=this.ignoreFetchAbort,allowStaleOnFetchAbort:k=this.allowStaleOnFetchAbort,context:w,forceRefresh:E=false,status:a,signal:x}=i;if(!t(this,pt))return a&&(a.fetch="get"),this.get(e,{allowStale:s,updateAgeOnGet:r,noDeleteOnStaleGet:n,status:a});let O={allowStale:s,updateAgeOnGet:r,noDeleteOnStaleGet:n,ttl:o,noDisposeOnSet:c,size:p,sizeCalculation:v,noUpdateTTL:R,noDeleteOnFetchRejection:S,allowStaleOnFetchRejection:rt,allowStaleOnFetchAbort:k,ignoreFetchAbort:M,status:a,signal:x},f=t(this,T).get(e);if(f===void 0){a&&(a.fetch="miss");let _=d(this,l,Ct).call(this,e,f,O,w);return _.__returned=_}else {let _=t(this,m)[f];if(d(this,l,A).call(this,_)){let vt=s&&_.__staleWhileFetching!==void 0;return a&&(a.fetch="inflight",vt&&(a.returnedStale=true)),vt?_.__staleWhileFetching:_.__returned=_}let j=t(this,Y).call(this,f);if(!E&&!j)return a&&(a.fetch="hit"),d(this,l,wt).call(this,f),r&&t(this,ft).call(this,f),a&&t(this,ot).call(this,a,f),_;let H=d(this,l,Ct).call(this,e,f,O,w),gt=H.__staleWhileFetching!==void 0&&s;return a&&(a.fetch=j?"stale":"refresh",gt&&j&&(a.returnedStale=true)),gt?H.__staleWhileFetching:H.__returned=H}}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,i={}){let s=t(this,Et);if(!s)throw new Error("no memoMethod provided to constructor");let{context:r,forceRefresh:n,...o}=i,c=this.get(e,o);if(!n&&c!==void 0)return c;let p=s(e,c,{options:o,context:r});return this.set(e,p,o),p}get(e,i={}){let{allowStale:s=this.allowStale,updateAgeOnGet:r=this.updateAgeOnGet,noDeleteOnStaleGet:n=this.noDeleteOnStaleGet,status:o}=i,c=t(this,T).get(e);if(c!==void 0){let p=t(this,m)[c],v=d(this,l,A).call(this,p);return o&&t(this,ot).call(this,o,c),t(this,Y).call(this,c)?(o&&(o.get="stale"),v?(o&&s&&p.__staleWhileFetching!==void 0&&(o.returnedStale=true),s?p.__staleWhileFetching:void 0):(n||d(this,l,ct).call(this,e,"expire"),o&&s&&(o.returnedStale=true),s?p:void 0)):(o&&(o.get="hit"),v?p.__staleWhileFetching:(d(this,l,wt).call(this,c),r&&t(this,ft).call(this,c),p))}else o&&(o.get="miss");}delete(e){return d(this,l,ct).call(this,e,"delete")}clear(){return d(this,l,Vt).call(this,"delete")}},K=new WeakMap,G=new WeakMap,q=new WeakMap,ut=new WeakMap,X=new WeakMap,yt=new WeakMap,Et=new WeakMap,$=new WeakMap,U=new WeakMap,B=new WeakMap,T=new WeakMap,b=new WeakMap,m=new WeakMap,F=new WeakMap,z=new WeakMap,N=new WeakMap,D=new WeakMap,J=new WeakMap,L=new WeakMap,Q=new WeakMap,Z=new WeakMap,V=new WeakMap,W=new WeakMap,tt=new WeakMap,pt=new WeakMap,P=new WeakMap,xt=new WeakMap,l=new WeakSet,Mt=function(){let e=new Dt(t(this,K)),i=new Dt(t(this,K));u(this,V,e),u(this,Z,i);let s=this.ttlAutopurge?new Array(t(this,K)):void 0;u(this,W,s),u(this,Ot,(c,p,v=t(this,$).now())=>{i[c]=p!==0?v:0,e[c]=p,r(c,p);}),u(this,ft,c=>{i[c]=e[c]!==0?t(this,$).now():0,r(c,e[c]);});let r=this.ttlAutopurge?(c,p)=>{if(s?.[c]&&(clearTimeout(s[c]),s[c]=void 0),p&&p!==0&&s){let v=setTimeout(()=>{t(this,Y).call(this,c)&&d(this,l,ct).call(this,t(this,b)[c],"expire");},p+1);v.unref&&v.unref(),s[c]=v;}}:()=>{};u(this,ot,(c,p)=>{if(e[p]){let v=e[p],R=i[p];if(!v||!R)return;c.ttl=v,c.start=R,c.now=n||o();let S=c.now-R;c.remainingTTL=v-S;}});let n=0,o=()=>{let c=t(this,$).now();if(this.ttlResolution>0){n=c;let p=setTimeout(()=>n=0,this.ttlResolution);p.unref&&p.unref();}return c};this.getRemainingTTL=c=>{let p=t(this,T).get(c);if(p===void 0)return 0;let v=e[p],R=i[p];if(!v||!R)return 1/0;let S=(n||o())-R;return v-S},u(this,Y,c=>{let p=i[c],v=e[c];return !!v&&!!p&&(n||o())-p>v});},ft=new WeakMap,ot=new WeakMap,Ot=new WeakMap,Y=new WeakMap,re=function(){let e=new Dt(t(this,K));u(this,B,0),u(this,Q,e),u(this,mt,i=>{u(this,B,t(this,B)-e[i]),e[i]=0;}),u(this,Tt,(i,s,r,n)=>{if(d(this,l,A).call(this,s))return 0;if(!lt(r))if(n){if(typeof n!="function")throw new TypeError("sizeCalculation must be a function");if(r=n(s,i),!lt(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(e[i]=s,t(this,G)){let n=t(this,G)-e[i];for(;t(this,B)>n;)d(this,l,Lt).call(this,true);}u(this,B,t(this,B)+e[i]),r&&(r.entrySize=s,r.totalCalculatedSize=t(this,B));});},mt=new WeakMap,At=new WeakMap,Tt=new WeakMap,ht=function*({allowStale:e=this.allowStale}={}){if(t(this,U))for(let i=t(this,D);!(!d(this,l,Gt).call(this,i)||((e||!t(this,Y).call(this,i))&&(yield i),i===t(this,N)));)i=t(this,z)[i];},dt=function*({allowStale:e=this.allowStale}={}){if(t(this,U))for(let i=t(this,N);!(!d(this,l,Gt).call(this,i)||((e||!t(this,Y).call(this,i))&&(yield i),i===t(this,D)));)i=t(this,F)[i];},Gt=function(e){return e!==void 0&&t(this,T).get(t(this,b)[e])===e},Lt=function(e){var n;let i=t(this,N),s=t(this,b)[i],r=t(this,m)[i];return t(this,pt)&&d(this,l,A).call(this,r)?r.__abortController.abort(new Error("evicted")):(t(this,tt)||t(this,P))&&(t(this,tt)&&((n=t(this,q))==null||n.call(this,r,s,"evict")),t(this,P)&&t(this,L)?.push([r,s,"evict"])),t(this,mt).call(this,i),t(this,W)?.[i]&&(clearTimeout(t(this,W)[i]),t(this,W)[i]=void 0),e&&(t(this,b)[i]=void 0,t(this,m)[i]=void 0,t(this,J).push(i)),t(this,U)===1?(u(this,N,u(this,D,0)),t(this,J).length=0):u(this,N,t(this,F)[i]),t(this,T).delete(s),Rt(this,U)._--,i},Ct=function(e,i,s,r){let n=i===void 0?void 0:t(this,m)[i];if(d(this,l,A).call(this,n))return n;let o=new Nt,{signal:c}=s;c?.addEventListener("abort",()=>o.abort(c.reason),{signal:o.signal});let p={signal:o.signal,options:s,context:r},v=(w,E=false)=>{let{aborted:a}=o.signal,x=s.ignoreFetchAbort&&w!==void 0,O=s.ignoreFetchAbort||!!(s.allowStaleOnFetchAbort&&w!==void 0);if(s.status&&(a&&!E?(s.status.fetchAborted=true,s.status.fetchError=o.signal.reason,x&&(s.status.fetchAbortIgnored=true)):s.status.fetchResolved=true),a&&!x&&!E)return S(o.signal.reason,O);let f=M,_=t(this,m)[i];return (_===M||x&&E&&_===void 0)&&(w===void 0?f.__staleWhileFetching!==void 0?t(this,m)[i]=f.__staleWhileFetching:d(this,l,ct).call(this,e,"fetch"):(s.status&&(s.status.fetchUpdated=true),this.set(e,w,p.options))),w},R=w=>(s.status&&(s.status.fetchRejected=true,s.status.fetchError=w),S(w,false)),S=(w,E)=>{let{aborted:a}=o.signal,x=a&&s.allowStaleOnFetchAbort,O=x||s.allowStaleOnFetchRejection,f=O||s.noDeleteOnFetchRejection,_=M;if(t(this,m)[i]===M&&(!f||!E&&_.__staleWhileFetching===void 0?d(this,l,ct).call(this,e,"fetch"):x||(t(this,m)[i]=_.__staleWhileFetching)),O)return s.status&&_.__staleWhileFetching!==void 0&&(s.status.returnedStale=true),_.__staleWhileFetching;if(_.__returned===_)throw w},rt=(w,E)=>{var x;let a=(x=t(this,yt))==null?void 0:x.call(this,e,n,p);a&&a instanceof Promise&&a.then(O=>w(O===void 0?void 0:O),E),o.signal.addEventListener("abort",()=>{(!s.ignoreFetchAbort||s.allowStaleOnFetchAbort)&&(w(void 0),s.allowStaleOnFetchAbort&&(w=O=>v(O,true)));});};s.status&&(s.status.fetchDispatched=true);let M=new Promise(rt).then(v,R),k=Object.assign(M,{__abortController:o,__staleWhileFetching:n,__returned:void 0});return i===void 0?(this.set(e,k,{...p.options,status:void 0}),i=t(this,T).get(e)):t(this,m)[i]=k,k},A=function(e){if(!t(this,pt))return false;let i=e;return !!i&&i instanceof Promise&&i.hasOwnProperty("__staleWhileFetching")&&i.__abortController instanceof Nt},zt=function(e,i){t(this,z)[i]=e,t(this,F)[e]=i;},wt=function(e){e!==t(this,D)&&(e===t(this,N)?u(this,N,t(this,F)[e]):d(this,l,zt).call(this,t(this,z)[e],t(this,F)[e]),d(this,l,zt).call(this,t(this,D),e),u(this,D,e));},ct=function(e,i){var r,n;let s=false;if(t(this,U)!==0){let o=t(this,T).get(e);if(o!==void 0)if(t(this,W)?.[o]&&(clearTimeout(t(this,W)?.[o]),t(this,W)[o]=void 0),s=true,t(this,U)===1)d(this,l,Vt).call(this,i);else {t(this,mt).call(this,o);let c=t(this,m)[o];if(d(this,l,A).call(this,c)?c.__abortController.abort(new Error("deleted")):(t(this,tt)||t(this,P))&&(t(this,tt)&&((r=t(this,q))==null||r.call(this,c,e,i)),t(this,P)&&t(this,L)?.push([c,e,i])),t(this,T).delete(e),t(this,b)[o]=void 0,t(this,m)[o]=void 0,o===t(this,D))u(this,D,t(this,z)[o]);else if(o===t(this,N))u(this,N,t(this,F)[o]);else {let p=t(this,z)[o];t(this,F)[p]=t(this,F)[o];let v=t(this,F)[o];t(this,z)[v]=t(this,z)[o];}Rt(this,U)._--,t(this,J).push(o);}}if(t(this,P)&&t(this,L)?.length){let o=t(this,L),c;for(;c=o?.shift();)(n=t(this,X))==null||n.call(this,...c);}return s},Vt=function(e){var i,s;for(let r of d(this,l,dt).call(this,{allowStale:true})){let n=t(this,m)[r];if(d(this,l,A).call(this,n))n.__abortController.abort(new Error("deleted"));else {let o=t(this,b)[r];t(this,tt)&&((i=t(this,q))==null||i.call(this,n,o,e)),t(this,P)&&t(this,L)?.push([n,o,e]);}}if(t(this,T).clear(),t(this,m).fill(void 0),t(this,b).fill(void 0),t(this,V)&&t(this,Z)){t(this,V).fill(0),t(this,Z).fill(0);for(let r of t(this,W)??[])r!==void 0&&clearTimeout(r);t(this,W)?.fill(void 0);}if(t(this,Q)&&t(this,Q).fill(0),u(this,N,0),u(this,D,0),t(this,J).length=0,u(this,B,0),u(this,U,0),t(this,P)&&t(this,L)){let r=t(this,L),n;for(;n=r?.shift();)(s=t(this,X))==null||s.call(this,...n);}},bt);var Ft=class{constructor(e){y(this,"cache");y(this,"map",new Map);this.cache=new se({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()}};var Ut="1.6.1";var Wt="repeat";function Yt(h){return {type:"pause",duration:h}}var Ht="__game_layer__";var fe="general";var me={CURRENT_DIALOGUE_MEMORY_KEY:"dialogue",LAST_DIALOGUE_ADDED_IN_STEP_MEMORY_KEY:"dialogue:step_counter",CURRENT_MENU_OPTIONS_MEMORY_KEY:"choice:options",LAST_MENU_OPTIONS_ADDED_IN_STEP_MEMORY_KEY:"choice:step_counter",CURRENT_INPUT_VALUE_MEMORY_KEY:"input:value",LAST_INPUT_ADDED_IN_STEP_MEMORY_KEY:"input:step_counter",CURRENT_INPUT_INFO_MEMORY_KEY:"input:info",CHARACTER_CATEGORY_KEY:"character",ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY:"___glue___",OPENED_LABELS_COUNTER_KEY:"label:opened",ALL_CHOICES_MADE_KEY:"choices:made",CURRENT_STEP_TIMES_COUNTER_KEY:"label:history",LAST_STEP_GLUED:"glue:last_step"};var oe={};var Kt={};he(Kt,{createExportableElement:()=>ne});var _t;(r=>(r.log=(n,...o)=>console.log(`[Pixi\u2019VN] ${n}`,...o),r.warn=(n,...o)=>console.warn(`[Pixi\u2019VN] ${n}`,...o),r.error=(n,...o)=>console.error(`[Pixi\u2019VN] ${n}`,...o),r.info=(n,...o)=>console.info(`[Pixi\u2019VN] ${n}`,...o)))(_t||(_t={}));function ne(h){try{if(typeof h>"u")return h;let e=JSON.stringify(h);return JSON.parse(e)}catch(e){throw _t.error("Error creating exportable element",h,e),new core.PixiError("not_json_serializable","Error creating exportable element")}}function ae(){console.info(`
_______ _ _ _ ____ ____ ____ _____
|_ __ \\ (_) (_) | | |_ _| |_ _||_ \\|_ _|
| |__) |__ _ __ __ \\_| \\ \\ / / | \\ | |
| ___/[ | [ \\ [ ][ | \\ \\ / / | |\\ \\| |
_| |_ | | > ' < | | \\ ' / _| |_\\ |_
|_____| [___][__]\`\\_][___] \\_/ |_____|\\____|
`);}function kt(){let h=window.location.pathname+window.location.hash;return h.includes("#")&&(h=h.split("#")[1]),h}exports.Game=void 0;(E=>{async function h(a,x,O){if(core.GameUnifier.init({navigate:x?.navigate,getCurrentGameStepState:()=>{let f={};try{f=et__namespace.canvas.export();}catch{}return {path:kt(),storage:I__namespace.storage.export(),canvas:f,sound:at__namespace.sound.export(),labelIndex:C__namespace.NarrationManagerStatic.currentLabelStepIndex||0,openedLabels:C__namespace.narration.openedLabels}},restoreGameStepState:async(f,_)=>{it__namespace.HistoryManagerStatic._originalStepData=f,C__namespace.NarrationManagerStatic.openedLabels=f.openedLabels,I__namespace.storage.restore(f.storage);try{await et__namespace.canvas.restore(f.canvas),await at__namespace.sound.restore(f.sound);}catch{}_(f.path);},getStepCounter:()=>C__namespace.narration.stepCounter,setStepCounter:f=>{C__namespace.NarrationManagerStatic._stepCounter=f;},getOpenedLabels:()=>C__namespace.narration.openedLabels.length,addHistoryItem:(f,_)=>it__namespace.stepHistory.add(f,_),getCharacter:f=>Xt__namespace.RegisteredCharacters.get(f),processNavigationRequests:(f,_)=>{let j=f,H=Promise.resolve();return f>0?(j--,H=C__namespace.narration.continue(_)):f<0&&(j=0,H=it__namespace.stepHistory.back(_,{steps:f*-1})),{newValue:j,result:H}},animate:(f,_,j,H)=>motion.motion.animate(f,_,j,H),getVariable:(f,_)=>I__namespace.StorageManagerStatic.getVariable(f,_),setVariable:(f,_,j)=>I__namespace.StorageManagerStatic.setVariable(f,_,j),removeVariable:(f,_)=>I__namespace.StorageManagerStatic.removeVariable(f,_),getFlag:f=>I__namespace.storage.getFlag(f),setFlag:(f,_)=>I__namespace.storage.setFlag(f,_),onLabelClosing:f=>I__namespace.StorageManagerStatic.clearOldTempVariables(f)}),ae(),!a||!x){_t.warn("The canvas element or options are not defined. The canvas will not be initialized.");return}return await et__namespace.canvas.init(a,x,O)}E.init=h;function e(){I__namespace.storage.clear();try{et__namespace.canvas.clear();}catch{}at__namespace.sound.clear(),C__namespace.narration.clear(),it__namespace.stepHistory.clear();}E.clear=e;function i(){let a={};try{a=et__namespace.canvas.export();}catch{}return {pixivn_version:Ut,stepData:C__namespace.narration.export(),storageData:I__namespace.storage.export(),canvasData:a,soundData:at__namespace.sound.export(),historyData:it__namespace.stepHistory.export(),path:kt()}}E.exportGameState=i;async function s(a,x){it__namespace.stepHistory.restore(a.historyData);let O=it__namespace.stepHistory.lastKey;if(typeof O=="number"){let f=it__namespace.stepHistory.stepsInfoMap.get(O)||null;await C__namespace.narration.restore(a.stepData,f);}I__namespace.storage.restore(a.storageData);try{await et__namespace.canvas.restore(a.canvasData),await at__namespace.sound.restore(a.soundData);}catch{}await x(a.path);}E.restoreGameState=s;async function r(a,x){return et__namespace.canvas.removeAll(),et__namespace.canvas.clear(),at__namespace.sound.stopAll(),await C__namespace.narration.call(a,x)}E.start=r;function n(a){return JSON.parse(a)}E.jsonToGameState=n;function o(a){core.GameUnifier.onEnd=a;}E.onEnd=o;function c(a){return _t.warn("Game.onError is deprecated. Use Game.addOnError / Game.removeOnError to register multiple handlers."),core.GameUnifier.addOnError((x,O)=>a("step",x,O))}E.onError=c;function p(a){return core.GameUnifier.addOnError(a)}E.addOnError=p;function v(a){return core.GameUnifier.removeOnError(a)}E.removeOnError=v;function R(a){C__namespace.NarrationManagerStatic.onStepStart=a;}E.onStepStart=R;function S(a){C__namespace.NarrationManagerStatic.onLoadingLabel=a;}E.onLoadingLabel=S;function rt(a){C__namespace.NarrationManagerStatic.onStepEnd=a;}E.onStepEnd=rt;function M(a){core.GameUnifier.navigate=a;}E.onNavigate=M;function k(a){return core.GameUnifier.addOnPreContinue(a)}E.addOnPreContinue=k;function w(a){return core.GameUnifier.removeOnPreContinue(a)}E.removeOnPreContinue=w;})(exports.Game||(exports.Game={}));var Ke={characterUtils:Xt__namespace,canvasUtils:et__namespace,narrationUtils:C__namespace,soundUtils:at__namespace,CANVAS_APP_GAME_LAYER_ALIAS:Ht,Pause:Yt,Repeat:Wt,PIXIVN_VERSION:Ut,...Kt,...oe,canvas:et__namespace.canvas,narration:C__namespace.narration,sound:at__namespace.sound,storage:I__namespace.storage,history:it__namespace.stepHistory,Game:exports.Game,GameUnifier:core.GameUnifier};exports.CANVAS_APP_GAME_LAYER_ALIAS=Ht;exports.CachedMap=Ft;exports.GENERAL_CHANNEL=fe;exports.PIXIVN_VERSION=Ut;exports.Pause=Yt;exports.Repeat=Wt;exports.SYSTEM_RESERVED_STORAGE_KEYS=me;exports.createExportableElement=ne;exports.default=Ke;Object.keys(et).forEach(function(k){if(k!=='default'&&!Object.prototype.hasOwnProperty.call(exports,k))Object.defineProperty(exports,k,{enumerable:true,get:function(){return et[k]}})});Object.keys(Xt).forEach(function(k){if(k!=='default'&&!Object.prototype.hasOwnProperty.call(exports,k))Object.defineProperty(exports,k,{enumerable:true,get:function(){return Xt[k]}})});Object.keys(core).forEach(function(k){if(k!=='default'&&!Object.prototype.hasOwnProperty.call(exports,k))Object.defineProperty(exports,k,{enumerable:true,get:function(){return core[k]}})});Object.keys(it).forEach(function(k){if(k!=='default'&&!Object.prototype.hasOwnProperty.call(exports,k))Object.defineProperty(exports,k,{enumerable:true,get:function(){return it[k]}})});Object.keys(C).forEach(function(k){if(k!=='default'&&!Object.prototype.hasOwnProperty.call(exports,k))Object.defineProperty(exports,k,{enumerable:true,get:function(){return C[k]}})});Object.keys(at).forEach(function(k){if(k!=='default'&&!Object.prototype.hasOwnProperty.call(exports,k))Object.defineProperty(exports,k,{enumerable:true,get:function(){return at[k]}})});Object.keys(I).forEach(function(k){if(k!=='default'&&!Object.prototype.hasOwnProperty.call(exports,k))Object.defineProperty(exports,k,{enumerable:true,get:function(){return I[k]}})});