UNPKG

@drincs/pixi-vn

Version:

Pixi'VN is a npm package that provides various features for creating visual novels.

1 lines 43.8 kB
'use strict';var core=require('@drincs/pixi-vn/core'),kt=require('@drincs/pixi-vn/pixi.js'),B=require('tone');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}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 kt__default=/*#__PURE__*/_interopDefault(kt);var B__namespace=/*#__PURE__*/_interopNamespace(B);var Rt=Object.defineProperty;var Tt=o=>{throw TypeError(o)};var Nt=(o,t,e)=>t in o?Rt(o,t,{enumerable:true,configurable:true,writable:true,value:e}):o[t]=e;var m=(o,t,e)=>Nt(o,typeof t!="symbol"?t+"":t,e),ze=(o,t,e)=>t.has(o)||Tt("Cannot "+e);var i=(o,t,e)=>(ze(o,t,"read from private field"),e?e.call(o):t.get(o)),v=(o,t,e)=>t.has(o)?Tt("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(o):t.set(o,e),c=(o,t,e,n)=>(ze(o,t,"write to private field"),t.set(o,e),e),d=(o,t,e)=>(ze(o,t,"access private method"),e);var De=(o,t,e,n)=>({set _(s){c(o,t,s);},get _(){return i(o,t,n)}});var At="general";var Gt=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,_t=new Set,qe=typeof process=="object"&&process?process:{},Ct=(o,t,e,n)=>{typeof qe.emitWarning=="function"?qe.emitWarning(o,t,e,n):console.error(`[${e}] ${t}: ${o}`);},Re=globalThis.AbortController,St=globalThis.AbortSignal;if(typeof Re>"u"){St=class{constructor(){m(this,"onabort");m(this,"_onabort",[]);m(this,"reason");m(this,"aborted",false);}addEventListener(e,n){this._onabort.push(n);}},Re=class{constructor(){m(this,"signal",new St);t();}abort(e){if(!this.signal.aborted){this.signal.reason=e,this.signal.aborted=true;for(let n of this.signal._onabort)n(e);this.signal.onabort?.(e);}}};let o=qe.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",t=()=>{o&&(o=false,Ct("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 Lt=o=>!_t.has(o);var se=o=>o&&o===Math.floor(o)&&o>0&&isFinite(o),Et=o=>se(o)?o<=Math.pow(2,8)?Uint8Array:o<=Math.pow(2,16)?Uint16Array:o<=Math.pow(2,32)?Uint32Array:o<=Number.MAX_SAFE_INTEGER?Ie:null:null,Ie=class extends Array{constructor(o){super(o),this.fill(0);}},te,fe,zt=(te=class{constructor(t,e){m(this,"heap");m(this,"length");if(!i(te,fe))throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new e(t),this.length=0;}static create(t){let e=Et(t);if(!e)return [];c(te,fe,true);let n=new te(t,e);return c(te,fe,false),n}push(t){this.heap[this.length++]=t;}pop(){return this.heap[--this.length]}},fe=new WeakMap,v(te,fe,false),te),Ft,Ot,j,q,K,he,$,ye,ge,H,E,X,C,S,f,N,U,I,P,Q,x,Z,J,W,V,ee,le,G,ve,h,Ue,ue,ie,Fe,Y,xt,de,be,Oe,ae,re,We,Me,ke,A,Ve,Se,oe,Ye,we,Pt=(we=class{constructor(t){v(this,h);v(this,j);v(this,q);v(this,K);v(this,he);v(this,$);v(this,ye);v(this,ge);v(this,H);m(this,"ttl");m(this,"ttlResolution");m(this,"ttlAutopurge");m(this,"updateAgeOnGet");m(this,"updateAgeOnHas");m(this,"allowStale");m(this,"noDisposeOnSet");m(this,"noUpdateTTL");m(this,"maxEntrySize");m(this,"sizeCalculation");m(this,"noDeleteOnFetchRejection");m(this,"noDeleteOnStaleGet");m(this,"allowStaleOnFetchAbort");m(this,"allowStaleOnFetchRejection");m(this,"ignoreFetchAbort");v(this,E);v(this,X);v(this,C);v(this,S);v(this,f);v(this,N);v(this,U);v(this,I);v(this,P);v(this,Q);v(this,x);v(this,Z);v(this,J);v(this,W);v(this,V);v(this,ee);v(this,le);v(this,G);v(this,ve);v(this,ue,()=>{});v(this,ie,()=>{});v(this,Fe,()=>{});v(this,Y,()=>false);v(this,de,t=>{});v(this,be,(t,e,n)=>{});v(this,Oe,(t,e,n,s)=>{if(n||s)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0});m(this,Ft,"LRUCache");let{max:e=0,ttl:n,ttlResolution:s=1,ttlAutopurge:r,updateAgeOnGet:a,updateAgeOnHas:l,allowStale:u,dispose:g,onInsert:w,disposeAfter:b,noDisposeOnSet:M,noUpdateTTL:D,maxSize:z=0,maxEntrySize:F=0,sizeCalculation:T,fetchMethod:y,memoMethod:k,noDeleteOnFetchRejection:L,noDeleteOnStaleGet:R,allowStaleOnFetchRejection:O,allowStaleOnFetchAbort:Ae,ignoreFetchAbort:ce,perf:pe}=t;if(pe!==void 0&&typeof pe?.now!="function")throw new TypeError("perf option must have a now() method if specified");if(c(this,H,pe??Gt),e!==0&&!se(e))throw new TypeError("max option must be a nonnegative integer");let me=e?Et(e):Array;if(!me)throw new Error("invalid max value: "+e);if(c(this,j,e),c(this,q,z),this.maxEntrySize=F||i(this,q),this.sizeCalculation=T,this.sizeCalculation){if(!i(this,q)&&!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(k!==void 0&&typeof k!="function")throw new TypeError("memoMethod must be a function if defined");if(c(this,ge,k),y!==void 0&&typeof y!="function")throw new TypeError("fetchMethod must be a function if specified");if(c(this,ye,y),c(this,le,!!y),c(this,C,new Map),c(this,S,new Array(e).fill(void 0)),c(this,f,new Array(e).fill(void 0)),c(this,N,new me(e)),c(this,U,new me(e)),c(this,I,0),c(this,P,0),c(this,Q,zt.create(e)),c(this,E,0),c(this,X,0),typeof g=="function"&&c(this,K,g),typeof w=="function"&&c(this,he,w),typeof b=="function"?(c(this,$,b),c(this,x,[])):(c(this,$,void 0),c(this,x,void 0)),c(this,ee,!!i(this,K)),c(this,ve,!!i(this,he)),c(this,G,!!i(this,$)),this.noDisposeOnSet=!!M,this.noUpdateTTL=!!D,this.noDeleteOnFetchRejection=!!L,this.allowStaleOnFetchRejection=!!O,this.allowStaleOnFetchAbort=!!Ae,this.ignoreFetchAbort=!!ce,this.maxEntrySize!==0){if(i(this,q)!==0&&!se(i(this,q)))throw new TypeError("maxSize must be a positive integer if specified");if(!se(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");d(this,h,xt).call(this);}if(this.allowStale=!!u,this.noDeleteOnStaleGet=!!R,this.updateAgeOnGet=!!a,this.updateAgeOnHas=!!l,this.ttlResolution=se(s)||s===0?s:1,this.ttlAutopurge=!!r,this.ttl=n||0,this.ttl){if(!se(this.ttl))throw new TypeError("ttl must be a positive integer if specified");d(this,h,Ue).call(this);}if(i(this,j)===0&&this.ttl===0&&i(this,q)===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!i(this,j)&&!i(this,q)){let Le="LRU_CACHE_UNBOUNDED";Lt(Le)&&(_t.add(Le),Ct("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",Le,we));}}get perf(){return i(this,H)}static unsafeExposeInternals(t){return {starts:i(t,J),ttls:i(t,W),autopurgeTimers:i(t,V),sizes:i(t,Z),keyMap:i(t,C),keyList:i(t,S),valList:i(t,f),next:i(t,N),prev:i(t,U),get head(){return i(t,I)},get tail(){return i(t,P)},free:i(t,Q),isBackgroundFetch:e=>{var n;return d(n=t,h,A).call(n,e)},backgroundFetch:(e,n,s,r)=>{var a;return d(a=t,h,ke).call(a,e,n,s,r)},moveToTail:e=>{var n;return d(n=t,h,Se).call(n,e)},indexes:e=>{var n;return d(n=t,h,ae).call(n,e)},rindexes:e=>{var n;return d(n=t,h,re).call(n,e)},isStale:e=>{var n;return i(n=t,Y).call(n,e)}}}get max(){return i(this,j)}get maxSize(){return i(this,q)}get calculatedSize(){return i(this,X)}get size(){return i(this,E)}get fetchMethod(){return i(this,ye)}get memoMethod(){return i(this,ge)}get dispose(){return i(this,K)}get onInsert(){return i(this,he)}get disposeAfter(){return i(this,$)}getRemainingTTL(t){return i(this,C).has(t)?1/0:0}*entries(){for(let t of d(this,h,ae).call(this))i(this,f)[t]!==void 0&&i(this,S)[t]!==void 0&&!d(this,h,A).call(this,i(this,f)[t])&&(yield [i(this,S)[t],i(this,f)[t]]);}*rentries(){for(let t of d(this,h,re).call(this))i(this,f)[t]!==void 0&&i(this,S)[t]!==void 0&&!d(this,h,A).call(this,i(this,f)[t])&&(yield [i(this,S)[t],i(this,f)[t]]);}*keys(){for(let t of d(this,h,ae).call(this)){let e=i(this,S)[t];e!==void 0&&!d(this,h,A).call(this,i(this,f)[t])&&(yield e);}}*rkeys(){for(let t of d(this,h,re).call(this)){let e=i(this,S)[t];e!==void 0&&!d(this,h,A).call(this,i(this,f)[t])&&(yield e);}}*values(){for(let t of d(this,h,ae).call(this))i(this,f)[t]!==void 0&&!d(this,h,A).call(this,i(this,f)[t])&&(yield i(this,f)[t]);}*rvalues(){for(let t of d(this,h,re).call(this))i(this,f)[t]!==void 0&&!d(this,h,A).call(this,i(this,f)[t])&&(yield i(this,f)[t]);}[(Ot=Symbol.iterator,Ft=Symbol.toStringTag,Ot)](){return this.entries()}find(t,e={}){for(let n of d(this,h,ae).call(this)){let s=i(this,f)[n],r=d(this,h,A).call(this,s)?s.__staleWhileFetching:s;if(r!==void 0&&t(r,i(this,S)[n],this))return this.get(i(this,S)[n],e)}}forEach(t,e=this){for(let n of d(this,h,ae).call(this)){let s=i(this,f)[n],r=d(this,h,A).call(this,s)?s.__staleWhileFetching:s;r!==void 0&&t.call(e,r,i(this,S)[n],this);}}rforEach(t,e=this){for(let n of d(this,h,re).call(this)){let s=i(this,f)[n],r=d(this,h,A).call(this,s)?s.__staleWhileFetching:s;r!==void 0&&t.call(e,r,i(this,S)[n],this);}}purgeStale(){let t=false;for(let e of d(this,h,re).call(this,{allowStale:true}))i(this,Y).call(this,e)&&(d(this,h,oe).call(this,i(this,S)[e],"expire"),t=true);return t}info(t){let e=i(this,C).get(t);if(e===void 0)return;let n=i(this,f)[e],s=d(this,h,A).call(this,n)?n.__staleWhileFetching:n;if(s===void 0)return;let r={value:s};if(i(this,W)&&i(this,J)){let a=i(this,W)[e],l=i(this,J)[e];if(a&&l){let u=a-(i(this,H).now()-l);r.ttl=u,r.start=Date.now();}}return i(this,Z)&&(r.size=i(this,Z)[e]),r}dump(){let t=[];for(let e of d(this,h,ae).call(this,{allowStale:true})){let n=i(this,S)[e],s=i(this,f)[e],r=d(this,h,A).call(this,s)?s.__staleWhileFetching:s;if(r===void 0||n===void 0)continue;let a={value:r};if(i(this,W)&&i(this,J)){a.ttl=i(this,W)[e];let l=i(this,H).now()-i(this,J)[e];a.start=Math.floor(Date.now()-l);}i(this,Z)&&(a.size=i(this,Z)[e]),t.unshift([n,a]);}return t}load(t){this.clear();for(let[e,n]of t){if(n.start){let s=Date.now()-n.start;n.start=i(this,H).now()-s;}this.set(e,n.value,n);}}set(t,e,n={}){var M,D,z,F;if(e===void 0)return this.delete(t),this;let{ttl:s=this.ttl,start:r,noDisposeOnSet:a=this.noDisposeOnSet,sizeCalculation:l=this.sizeCalculation,status:u}=n,{noUpdateTTL:g=this.noUpdateTTL}=n,w=i(this,Oe).call(this,t,e,n.size||0,l);if(this.maxEntrySize&&w>this.maxEntrySize)return u&&(u.set="miss",u.maxEntrySizeExceeded=true),d(this,h,oe).call(this,t,"set"),this;let b=i(this,E)===0?void 0:i(this,C).get(t);if(b===void 0)b=i(this,E)===0?i(this,P):i(this,Q).length!==0?i(this,Q).pop():i(this,E)===i(this,j)?d(this,h,Me).call(this,false):i(this,E),i(this,S)[b]=t,i(this,f)[b]=e,i(this,C).set(t,b),i(this,N)[i(this,P)]=b,i(this,U)[b]=i(this,P),c(this,P,b),De(this,E)._++,i(this,be).call(this,b,w,u),u&&(u.set="add"),g=false,i(this,ve)&&((M=i(this,he))==null||M.call(this,e,t,"add"));else {d(this,h,Se).call(this,b);let T=i(this,f)[b];if(e!==T){if(i(this,le)&&d(this,h,A).call(this,T)){T.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:y}=T;y!==void 0&&!a&&(i(this,ee)&&((D=i(this,K))==null||D.call(this,y,t,"set")),i(this,G)&&i(this,x)?.push([y,t,"set"]));}else a||(i(this,ee)&&((z=i(this,K))==null||z.call(this,T,t,"set")),i(this,G)&&i(this,x)?.push([T,t,"set"]));if(i(this,de).call(this,b),i(this,be).call(this,b,w,u),i(this,f)[b]=e,u){u.set="replace";let y=T&&d(this,h,A).call(this,T)?T.__staleWhileFetching:T;y!==void 0&&(u.oldValue=y);}}else u&&(u.set="update");i(this,ve)&&this.onInsert?.(e,t,e===T?"update":"replace");}if(s!==0&&!i(this,W)&&d(this,h,Ue).call(this),i(this,W)&&(g||i(this,Fe).call(this,b,s,r),u&&i(this,ie).call(this,u,b)),!a&&i(this,G)&&i(this,x)){let T=i(this,x),y;for(;y=T?.shift();)(F=i(this,$))==null||F.call(this,...y);}return this}pop(){var t;try{for(;i(this,E);){let e=i(this,f)[i(this,I)];if(d(this,h,Me).call(this,!0),d(this,h,A).call(this,e)){if(e.__staleWhileFetching)return e.__staleWhileFetching}else if(e!==void 0)return e}}finally{if(i(this,G)&&i(this,x)){let e=i(this,x),n;for(;n=e?.shift();)(t=i(this,$))==null||t.call(this,...n);}}}has(t,e={}){let{updateAgeOnHas:n=this.updateAgeOnHas,status:s}=e,r=i(this,C).get(t);if(r!==void 0){let a=i(this,f)[r];if(d(this,h,A).call(this,a)&&a.__staleWhileFetching===void 0)return false;if(i(this,Y).call(this,r))s&&(s.has="stale",i(this,ie).call(this,s,r));else return n&&i(this,ue).call(this,r),s&&(s.has="hit",i(this,ie).call(this,s,r)),true}else s&&(s.has="miss");return false}peek(t,e={}){let{allowStale:n=this.allowStale}=e,s=i(this,C).get(t);if(s===void 0||!n&&i(this,Y).call(this,s))return;let r=i(this,f)[s];return d(this,h,A).call(this,r)?r.__staleWhileFetching:r}async fetch(t,e={}){let{allowStale:n=this.allowStale,updateAgeOnGet:s=this.updateAgeOnGet,noDeleteOnStaleGet:r=this.noDeleteOnStaleGet,ttl:a=this.ttl,noDisposeOnSet:l=this.noDisposeOnSet,size:u=0,sizeCalculation:g=this.sizeCalculation,noUpdateTTL:w=this.noUpdateTTL,noDeleteOnFetchRejection:b=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:M=this.allowStaleOnFetchRejection,ignoreFetchAbort:D=this.ignoreFetchAbort,allowStaleOnFetchAbort:z=this.allowStaleOnFetchAbort,context:F,forceRefresh:T=false,status:y,signal:k}=e;if(!i(this,le))return y&&(y.fetch="get"),this.get(t,{allowStale:n,updateAgeOnGet:s,noDeleteOnStaleGet:r,status:y});let L={allowStale:n,updateAgeOnGet:s,noDeleteOnStaleGet:r,ttl:a,noDisposeOnSet:l,size:u,sizeCalculation:g,noUpdateTTL:w,noDeleteOnFetchRejection:b,allowStaleOnFetchRejection:M,allowStaleOnFetchAbort:z,ignoreFetchAbort:D,status:y,signal:k},R=i(this,C).get(t);if(R===void 0){y&&(y.fetch="miss");let O=d(this,h,ke).call(this,t,R,L,F);return O.__returned=O}else {let O=i(this,f)[R];if(d(this,h,A).call(this,O)){let me=n&&O.__staleWhileFetching!==void 0;return y&&(y.fetch="inflight",me&&(y.returnedStale=true)),me?O.__staleWhileFetching:O.__returned=O}let Ae=i(this,Y).call(this,R);if(!T&&!Ae)return y&&(y.fetch="hit"),d(this,h,Se).call(this,R),s&&i(this,ue).call(this,R),y&&i(this,ie).call(this,y,R),O;let ce=d(this,h,ke).call(this,t,R,L,F),pe=ce.__staleWhileFetching!==void 0&&n;return y&&(y.fetch=Ae?"stale":"refresh",pe&&Ae&&(y.returnedStale=true)),pe?ce.__staleWhileFetching:ce.__returned=ce}}async forceFetch(t,e={}){let n=await this.fetch(t,e);if(n===void 0)throw new Error("fetch() returned undefined");return n}memo(t,e={}){let n=i(this,ge);if(!n)throw new Error("no memoMethod provided to constructor");let{context:s,forceRefresh:r,...a}=e,l=this.get(t,a);if(!r&&l!==void 0)return l;let u=n(t,l,{options:a,context:s});return this.set(t,u,a),u}get(t,e={}){let{allowStale:n=this.allowStale,updateAgeOnGet:s=this.updateAgeOnGet,noDeleteOnStaleGet:r=this.noDeleteOnStaleGet,status:a}=e,l=i(this,C).get(t);if(l!==void 0){let u=i(this,f)[l],g=d(this,h,A).call(this,u);return a&&i(this,ie).call(this,a,l),i(this,Y).call(this,l)?(a&&(a.get="stale"),g?(a&&n&&u.__staleWhileFetching!==void 0&&(a.returnedStale=true),n?u.__staleWhileFetching:void 0):(r||d(this,h,oe).call(this,t,"expire"),a&&n&&(a.returnedStale=true),n?u:void 0)):(a&&(a.get="hit"),g?u.__staleWhileFetching:(d(this,h,Se).call(this,l),s&&i(this,ue).call(this,l),u))}else a&&(a.get="miss");}delete(t){return d(this,h,oe).call(this,t,"delete")}clear(){return d(this,h,Ye).call(this,"delete")}},j=new WeakMap,q=new WeakMap,K=new WeakMap,he=new WeakMap,$=new WeakMap,ye=new WeakMap,ge=new WeakMap,H=new WeakMap,E=new WeakMap,X=new WeakMap,C=new WeakMap,S=new WeakMap,f=new WeakMap,N=new WeakMap,U=new WeakMap,I=new WeakMap,P=new WeakMap,Q=new WeakMap,x=new WeakMap,Z=new WeakMap,J=new WeakMap,W=new WeakMap,V=new WeakMap,ee=new WeakMap,le=new WeakMap,G=new WeakMap,ve=new WeakMap,h=new WeakSet,Ue=function(){let t=new Ie(i(this,j)),e=new Ie(i(this,j));c(this,W,t),c(this,J,e);let n=this.ttlAutopurge?new Array(i(this,j)):void 0;c(this,V,n),c(this,Fe,(l,u,g=i(this,H).now())=>{e[l]=u!==0?g:0,t[l]=u,s(l,u);}),c(this,ue,l=>{e[l]=t[l]!==0?i(this,H).now():0,s(l,t[l]);});let s=this.ttlAutopurge?(l,u)=>{if(n?.[l]&&(clearTimeout(n[l]),n[l]=void 0),u&&u!==0&&n){let g=setTimeout(()=>{i(this,Y).call(this,l)&&d(this,h,oe).call(this,i(this,S)[l],"expire");},u+1);g.unref&&g.unref(),n[l]=g;}}:()=>{};c(this,ie,(l,u)=>{if(t[u]){let g=t[u],w=e[u];if(!g||!w)return;l.ttl=g,l.start=w,l.now=r||a();let b=l.now-w;l.remainingTTL=g-b;}});let r=0,a=()=>{let l=i(this,H).now();if(this.ttlResolution>0){r=l;let u=setTimeout(()=>r=0,this.ttlResolution);u.unref&&u.unref();}return l};this.getRemainingTTL=l=>{let u=i(this,C).get(l);if(u===void 0)return 0;let g=t[u],w=e[u];if(!g||!w)return 1/0;let b=(r||a())-w;return g-b},c(this,Y,l=>{let u=e[l],g=t[l];return !!g&&!!u&&(r||a())-u>g});},ue=new WeakMap,ie=new WeakMap,Fe=new WeakMap,Y=new WeakMap,xt=function(){let t=new Ie(i(this,j));c(this,X,0),c(this,Z,t),c(this,de,e=>{c(this,X,i(this,X)-t[e]),t[e]=0;}),c(this,Oe,(e,n,s,r)=>{if(d(this,h,A).call(this,n))return 0;if(!se(s))if(r){if(typeof r!="function")throw new TypeError("sizeCalculation must be a function");if(s=r(n,e),!se(s))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 s}),c(this,be,(e,n,s)=>{if(t[e]=n,i(this,q)){let r=i(this,q)-t[e];for(;i(this,X)>r;)d(this,h,Me).call(this,true);}c(this,X,i(this,X)+t[e]),s&&(s.entrySize=n,s.totalCalculatedSize=i(this,X));});},de=new WeakMap,be=new WeakMap,Oe=new WeakMap,ae=function*({allowStale:t=this.allowStale}={}){if(i(this,E))for(let e=i(this,P);!(!d(this,h,We).call(this,e)||((t||!i(this,Y).call(this,e))&&(yield e),e===i(this,I)));)e=i(this,U)[e];},re=function*({allowStale:t=this.allowStale}={}){if(i(this,E))for(let e=i(this,I);!(!d(this,h,We).call(this,e)||((t||!i(this,Y).call(this,e))&&(yield e),e===i(this,P)));)e=i(this,N)[e];},We=function(t){return t!==void 0&&i(this,C).get(i(this,S)[t])===t},Me=function(t){var r;let e=i(this,I),n=i(this,S)[e],s=i(this,f)[e];return i(this,le)&&d(this,h,A).call(this,s)?s.__abortController.abort(new Error("evicted")):(i(this,ee)||i(this,G))&&(i(this,ee)&&((r=i(this,K))==null||r.call(this,s,n,"evict")),i(this,G)&&i(this,x)?.push([s,n,"evict"])),i(this,de).call(this,e),i(this,V)?.[e]&&(clearTimeout(i(this,V)[e]),i(this,V)[e]=void 0),t&&(i(this,S)[e]=void 0,i(this,f)[e]=void 0,i(this,Q).push(e)),i(this,E)===1?(c(this,I,c(this,P,0)),i(this,Q).length=0):c(this,I,i(this,N)[e]),i(this,C).delete(n),De(this,E)._--,e},ke=function(t,e,n,s){let r=e===void 0?void 0:i(this,f)[e];if(d(this,h,A).call(this,r))return r;let a=new Re,{signal:l}=n;l?.addEventListener("abort",()=>a.abort(l.reason),{signal:a.signal});let u={signal:a.signal,options:n,context:s},g=(F,T=false)=>{let{aborted:y}=a.signal,k=n.ignoreFetchAbort&&F!==void 0,L=n.ignoreFetchAbort||!!(n.allowStaleOnFetchAbort&&F!==void 0);if(n.status&&(y&&!T?(n.status.fetchAborted=true,n.status.fetchError=a.signal.reason,k&&(n.status.fetchAbortIgnored=true)):n.status.fetchResolved=true),y&&!k&&!T)return b(a.signal.reason,L);let R=D,O=i(this,f)[e];return (O===D||k&&T&&O===void 0)&&(F===void 0?R.__staleWhileFetching!==void 0?i(this,f)[e]=R.__staleWhileFetching:d(this,h,oe).call(this,t,"fetch"):(n.status&&(n.status.fetchUpdated=true),this.set(t,F,u.options))),F},w=F=>(n.status&&(n.status.fetchRejected=true,n.status.fetchError=F),b(F,false)),b=(F,T)=>{let{aborted:y}=a.signal,k=y&&n.allowStaleOnFetchAbort,L=k||n.allowStaleOnFetchRejection,R=L||n.noDeleteOnFetchRejection,O=D;if(i(this,f)[e]===D&&(!R||!T&&O.__staleWhileFetching===void 0?d(this,h,oe).call(this,t,"fetch"):k||(i(this,f)[e]=O.__staleWhileFetching)),L)return n.status&&O.__staleWhileFetching!==void 0&&(n.status.returnedStale=true),O.__staleWhileFetching;if(O.__returned===O)throw F},M=(F,T)=>{var k;let y=(k=i(this,ye))==null?void 0:k.call(this,t,r,u);y&&y instanceof Promise&&y.then(L=>F(L===void 0?void 0:L),T),a.signal.addEventListener("abort",()=>{(!n.ignoreFetchAbort||n.allowStaleOnFetchAbort)&&(F(void 0),n.allowStaleOnFetchAbort&&(F=L=>g(L,true)));});};n.status&&(n.status.fetchDispatched=true);let D=new Promise(M).then(g,w),z=Object.assign(D,{__abortController:a,__staleWhileFetching:r,__returned:void 0});return e===void 0?(this.set(t,z,{...u.options,status:void 0}),e=i(this,C).get(t)):i(this,f)[e]=z,z},A=function(t){if(!i(this,le))return false;let e=t;return !!e&&e instanceof Promise&&e.hasOwnProperty("__staleWhileFetching")&&e.__abortController instanceof Re},Ve=function(t,e){i(this,U)[e]=t,i(this,N)[t]=e;},Se=function(t){t!==i(this,P)&&(t===i(this,I)?c(this,I,i(this,N)[t]):d(this,h,Ve).call(this,i(this,U)[t],i(this,N)[t]),d(this,h,Ve).call(this,i(this,P),t),c(this,P,t));},oe=function(t,e){var s,r;let n=false;if(i(this,E)!==0){let a=i(this,C).get(t);if(a!==void 0)if(i(this,V)?.[a]&&(clearTimeout(i(this,V)?.[a]),i(this,V)[a]=void 0),n=true,i(this,E)===1)d(this,h,Ye).call(this,e);else {i(this,de).call(this,a);let l=i(this,f)[a];if(d(this,h,A).call(this,l)?l.__abortController.abort(new Error("deleted")):(i(this,ee)||i(this,G))&&(i(this,ee)&&((s=i(this,K))==null||s.call(this,l,t,e)),i(this,G)&&i(this,x)?.push([l,t,e])),i(this,C).delete(t),i(this,S)[a]=void 0,i(this,f)[a]=void 0,a===i(this,P))c(this,P,i(this,U)[a]);else if(a===i(this,I))c(this,I,i(this,N)[a]);else {let u=i(this,U)[a];i(this,N)[u]=i(this,N)[a];let g=i(this,N)[a];i(this,U)[g]=i(this,U)[a];}De(this,E)._--,i(this,Q).push(a);}}if(i(this,G)&&i(this,x)?.length){let a=i(this,x),l;for(;l=a?.shift();)(r=i(this,$))==null||r.call(this,...l);}return n},Ye=function(t){var e,n;for(let s of d(this,h,re).call(this,{allowStale:true})){let r=i(this,f)[s];if(d(this,h,A).call(this,r))r.__abortController.abort(new Error("deleted"));else {let a=i(this,S)[s];i(this,ee)&&((e=i(this,K))==null||e.call(this,r,a,t)),i(this,G)&&i(this,x)?.push([r,a,t]);}}if(i(this,C).clear(),i(this,f).fill(void 0),i(this,S).fill(void 0),i(this,W)&&i(this,J)){i(this,W).fill(0),i(this,J).fill(0);for(let s of i(this,V)??[])s!==void 0&&clearTimeout(s);i(this,V)?.fill(void 0);}if(i(this,Z)&&i(this,Z).fill(0),c(this,I,0),c(this,P,0),i(this,Q).length=0,c(this,X,0),c(this,E,0),i(this,G)&&i(this,x)){let s=i(this,x),r;for(;r=s?.shift();)(n=i(this,$))==null||n.call(this,...r);}},we);var _e=class{constructor(t){m(this,"cache");m(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(){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 je;(r=>(r.mediaInstances=new Map,r.channels=new Map,r.transients=new Set,r.systemPausedAliases=new Set,r.bufferRegistry=new _e({cacheSize:10})))(je||(je={}));var p=je;var _;(s=>(s.log=(r,...a)=>console.log(`[Pixi\u2019VN] ${r}`,...a),s.warn=(r,...a)=>console.warn(`[Pixi\u2019VN] ${r}`,...a),s.error=(r,...a)=>console.error(`[Pixi\u2019VN] ${r}`,...a),s.info=(r,...a)=>console.info(`[Pixi\u2019VN] ${r}`,...a)))(_||(_={}));function Ne(o){return o.reduce((t,e)=>{switch(e.filterType){case "ReverbFilter":t.push(new B.Reverb({decay:e.decay,preDelay:e.preDelay,wet:e.wet}).toDestination());break;case "FeedbackDelayFilter":t.push(new B.FeedbackDelay({feedback:e.feedback,delayTime:e.delayTime,wet:e.wet}).toDestination());break;case "BitCrusherFilter":t.push(new B.BitCrusher({bits:e.bits}).toDestination());break;case "CompressorFilter":t.push(new B.Compressor({attack:e.attack,knee:e.knee,ratio:e.ratio,release:e.release,threshold:e.threshold}).toDestination());break;case "DelayFilter":t.push(new B.Delay({delayTime:e.delayTime,maxDelay:e.maxDelay}).toDestination());break;case "DistortionFilter":t.push(new B.Distortion({distortion:e.distortion,oversample:e.oversample,wet:e.wet}).toDestination());break;case "FeedbackCombFilterFilter":t.push(new B.FeedbackCombFilter({delayTime:e.delayTime,resonance:e.resonance}).toDestination());break;case "FreeverbFilter":t.push(new B.Freeverb({roomSize:e.roomSize,dampening:e.dampening,wet:e.wet}).toDestination());break;case "GateFilter":t.push(new B.Gate({threshold:e.threshold,smoothing:e.smoothing}).toDestination());break;case "GreaterThanFilter":t.push(new B.GreaterThan({value:e.value,convert:e.convert,maxValue:e.maxValue,minValue:e.minValue,units:e.units}).toDestination());break;case "GreaterThanZeroFilter":t.push(new B.GreaterThanZero);break;case "LimiterFilter":t.push(new B.Limiter({threshold:e.threshold}).toDestination());break;case "MidSideCompressorFilter":t.push(new B.MidSideCompressor({mid:e.mid,side:e.side}).toDestination());break;case "MultibandCompressorFilter":t.push(new B.MultibandCompressor({lowFrequency:e.lowFrequency,highFrequency:e.highFrequency,low:e.low,mid:e.mid,high:e.high}).toDestination());break;case "Panner3DFilter":t.push(new B.Panner3D({positionX:e.positionX,positionY:e.positionY,positionZ:e.positionZ,orientationX:e.orientationX,orientationY:e.orientationY,orientationZ:e.orientationZ,coneInnerAngle:e.coneInnerAngle,coneOuterAngle:e.coneOuterAngle,coneOuterGain:e.coneOuterGain,distanceModel:e.distanceModel,maxDistance:e.maxDistance,refDistance:e.refDistance,rolloffFactor:e.rolloffFactor,panningModel:e.panningModel}).toDestination());break;case "PhaserFilter":t.push(new B.Phaser({frequency:e.frequency,octaves:e.octaves,baseFrequency:e.baseFrequency,wet:e.wet,Q:e.Q,stages:e.stages}).toDestination());break;case "StereoWidenerFilter":t.push(new B.StereoWidener({width:e.width,wet:e.wet}).toDestination());break;case "PingPongDelayFilter":t.push(new B.PingPongDelay({wet:e.wet,delayTime:e.delayTime,feedback:e.feedback,maxDelay:e.maxDelay}).toDestination());break;case "AutoFilterFilter":t.push(new B.AutoFilter({frequency:e.frequency,depth:e.depth,baseFrequency:e.baseFrequency,octaves:e.octaves,filter:e.filter,wet:e.wet,type:e.type}).toDestination());break;case "BiquadFilterFilter":t.push(new B.BiquadFilter({frequency:e.frequency,detune:e.detune,Q:e.Q,type:e.type,gain:e.gain}).toDestination());break;case "OnePoleFilterFilter":t.push(new B.OnePoleFilter({type:e.type}).toDestination());break;case "CustomFilter":t.push(new B.Filter({frequency:e.frequency,Q:e.Q,type:e.type,detune:e.detune,gain:e.gain,rolloff:e.rolloff}).toDestination());break;case "ChorusFilter":t.push(new B.Chorus({frequency:e.frequency,delayTime:e.delayTime,depth:e.depth,type:e.type,spread:e.spread,feedback:e.feedback,wet:e.wet}).toDestination());break;case "TremoloFilter":t.push(new B.Tremolo({frequency:e.frequency,type:e.type,depth:e.depth,spread:e.spread,wet:e.wet}).toDestination());break;case "VibratoFilter":t.push(new B.Vibrato({maxDelay:e.maxDelay,frequency:e.frequency,depth:e.depth,type:e.type,wet:e.wet}).toDestination());break;case "AutoPannerFilter":t.push(new B.AutoPanner({frequency:e.frequency,type:e.type,depth:e.depth,channelCount:e.channelCount,wet:e.wet}).toDestination());break}return t},[])}function It(o){if(o)return Array.from(o).reduce((t,e)=>(e instanceof B.Reverb?t.push({filterType:"ReverbFilter",wet:e.wet.value,decay:B.Time(e.decay).toSeconds(),preDelay:B.Time(e.preDelay).toSeconds()}):e instanceof B.PingPongDelay?t.push({filterType:"PingPongDelayFilter",wet:e.wet.value,delayTime:e.delayTime.value,feedback:e.feedback.value}):e instanceof B.FeedbackDelay?t.push({filterType:"FeedbackDelayFilter",feedback:e.feedback.value,delayTime:e.delayTime.value,wet:e.wet.value}):e instanceof B.BitCrusher?t.push({filterType:"BitCrusherFilter",bits:e.bits.value,wet:e.wet.value}):e instanceof B.Compressor?t.push({filterType:"CompressorFilter",attack:e.attack.value,knee:e.knee.value,ratio:e.ratio.value,release:e.release.value,threshold:e.threshold.value}):e instanceof B.Delay?t.push({filterType:"DelayFilter",delayTime:e.delayTime.value,maxDelay:e.maxDelay}):e instanceof B.Distortion?t.push({filterType:"DistortionFilter",distortion:e.distortion,oversample:e.oversample,wet:e.wet.value}):e instanceof B.FeedbackCombFilter?t.push({filterType:"FeedbackCombFilterFilter",delayTime:e.delayTime.value,resonance:e.resonance.value}):e instanceof B.Freeverb?t.push({filterType:"FreeverbFilter",roomSize:e.roomSize.value,dampening:e.dampening,wet:e.wet.value}):e instanceof B.Gate?t.push({filterType:"GateFilter",threshold:e.threshold,smoothing:e.smoothing}):e instanceof B.GreaterThan?t.push({filterType:"GreaterThanFilter",value:e.comparator.value,convert:e.convert,maxValue:e.maxValue,minValue:e.minValue}):e instanceof B.GreaterThanZero?t.push({filterType:"GreaterThanZeroFilter"}):e instanceof B.Limiter?t.push({filterType:"LimiterFilter",threshold:e.threshold.value}):e instanceof B.MidSideCompressor?t.push({filterType:"MidSideCompressorFilter",mid:{attack:e.mid.attack.value,knee:e.mid.knee.value,ratio:e.mid.ratio.value,release:e.mid.release.value,threshold:e.mid.threshold.value},side:{attack:e.side.attack.value,knee:e.side.knee.value,ratio:e.side.ratio.value,release:e.side.release.value,threshold:e.side.threshold.value}}):e instanceof B.MultibandCompressor?t.push({filterType:"MultibandCompressorFilter",lowFrequency:e.lowFrequency.value,highFrequency:e.highFrequency.value,low:{attack:e.low.attack.value,knee:e.low.knee.value,ratio:e.low.ratio.value,release:e.low.release.value,threshold:e.low.threshold.value},mid:{attack:e.mid.attack.value,knee:e.mid.knee.value,ratio:e.mid.ratio.value,release:e.mid.release.value,threshold:e.mid.threshold.value},high:{attack:e.high.attack.value,knee:e.high.knee.value,ratio:e.high.ratio.value,release:e.high.release.value,threshold:e.high.threshold.value}}):e instanceof B.Panner3D?t.push({filterType:"Panner3DFilter",positionX:e.positionX.value,positionY:e.positionY.value,positionZ:e.positionZ.value,orientationX:e.orientationX.value,orientationY:e.orientationY.value,orientationZ:e.orientationZ.value,coneInnerAngle:e.coneInnerAngle,coneOuterAngle:e.coneOuterAngle,coneOuterGain:e.coneOuterGain,distanceModel:e.distanceModel,maxDistance:e.maxDistance,refDistance:e.refDistance,rolloffFactor:e.rolloffFactor,panningModel:e.panningModel}):e instanceof B.Phaser?t.push({filterType:"PhaserFilter",frequency:e.frequency.value,octaves:e.octaves,baseFrequency:e.baseFrequency,wet:e.wet.value,Q:e.Q.value}):e instanceof B.StereoWidener?t.push({filterType:"StereoWidenerFilter",width:e.width.value,wet:e.wet.value}):e instanceof B.AutoFilter?t.push({filterType:"AutoFilterFilter",type:e.type,frequency:e.frequency.value,depth:e.depth.value,baseFrequency:e.baseFrequency,octaves:e.octaves,filter:{Q:e.filter.Q.value,type:e.filter.type,rolloff:e.filter.rolloff},wet:e.wet.value}):e instanceof B.Chorus?t.push({filterType:"ChorusFilter",type:e.type,frequency:e.frequency.value,delayTime:e.delayTime,depth:e.depth,spread:e.spread,feedback:e.feedback.value,wet:e.wet.value}):e instanceof B.Tremolo?t.push({filterType:"TremoloFilter",type:e.type,frequency:e.frequency.value,depth:e.depth.value,spread:e.spread,wet:e.wet.value}):e instanceof B.Vibrato?t.push({filterType:"VibratoFilter",type:e.type,frequency:e.frequency.value,depth:e.depth.value,wet:e.wet.value}):e instanceof B.AutoPanner?t.push({filterType:"AutoPannerFilter",type:e.type,frequency:e.frequency.value,depth:e.depth.value,channelCount:e.channelCount,wet:e.wet.value}):e instanceof B.BiquadFilter?t.push({filterType:"BiquadFilterFilter",type:e.type,frequency:e.frequency.value,detune:e.detune.value,Q:e.Q.value,gain:e.gain.value}):e instanceof B.OnePoleFilter?t.push({filterType:"OnePoleFilterFilter",type:e.type}):e instanceof B.Filter?t.push({filterType:"CustomFilter",type:e.type,frequency:e.frequency.value,Q:e.Q.value,detune:e.detune.value,gain:e.gain.value,rolloff:e.rolloff}):_.warn(`Unsupported filter type for serialisation: ${e?.constructor?.name??e}, please report this to the developers if you encounter it.`),t),[])}function vt(o){return o instanceof B.Reverb||o instanceof B.FeedbackDelay||o instanceof B.PingPongDelay||o instanceof B.BitCrusher||o instanceof B.Compressor||o instanceof B.Delay||o instanceof B.Distortion||o instanceof B.FeedbackCombFilter||o instanceof B.Freeverb||o instanceof B.Gate||o instanceof B.GreaterThan||o instanceof B.GreaterThanZero||o instanceof B.Limiter||o instanceof B.MidSideCompressor||o instanceof B.MultibandCompressor||o instanceof B.Panner3D||o instanceof B.Phaser||o instanceof B.StereoWidener||o instanceof B.AutoFilter||o instanceof B.Chorus||o instanceof B.Vibrato||o instanceof B.Tremolo||o instanceof B.AutoPanner||o instanceof B.BiquadFilter||o instanceof B.OnePoleFilter||o instanceof B.Filter}function ne(o){return o<=0?-1/0:20*Math.log10(o)}function Te(o){return o<=-1/0?0:10**(o/20)}async function Ge(o){if(p.bufferRegistry.has(o))return;let t=o;try{let e=kt__default.default.Assets.resolver.resolve(o);e?.src&&(t=e.src);}catch{}try{let e=await B.ToneAudioBuffer.load(t),n=new B.ToneAudioBuffer(e);p.bufferRegistry.set(o,n);}catch(e){_.warn(`Failed to load audio buffer for "${o}" (url: "${t}"): ${e instanceof Error?e.message:e}`),p.bufferRegistry.set(o,new B.ToneAudioBuffer);}}var Ee=class extends B.Player{constructor(e,n,s,r,a={},l){super(a);m(this,"alias",e);m(this,"channelAlias",n);m(this,"soundAlias",s);m(this,"stepCounter",r);m(this,"delay",l);m(this,"options");m(this,"filters",new Set);m(this,"pausedAt");m(this,"playStartTime",B.now());this.options=a,this.playStartTime=B.now()+(l??0);}get memory(){let e=Math.max(0,this.pausedAt?this.pausedAt-this.playStartTime:B.now()-this.playStartTime),n=this.paused;return n&&p.systemPausedAliases.has(this.alias)&&(n=false),{...this.options,fadeIn:this.fadeIn,loop:this.loop,loopEnd:this.loopEnd,loopStart:this.loopStart,mute:this.mute,playbackRate:this.playbackRate,reverse:this.reverse,volume:Te(this.volume.value),autostart:!this.paused,elapsed:e,paused:n,delay:this.delay}}set memory(e){this.paused=e.paused,this.loop!==(e.loop||false)&&(this.loop=e.loop||false),this.volume.value!==ne(e.volume??1)&&(this.volume.value=ne(e.volume??1)),this.mute!==(e.mute||false)&&(this.mute=e.mute||false),this.playbackRate!==(e.playbackRate??1)&&(this.playbackRate=e.playbackRate??1),this.reverse!==(e.reverse||false)&&(this.reverse=e.reverse||false),this.fadeIn!==(e.fadeIn||0)&&(this.fadeIn=e.fadeIn||0),this.loopStart!==(e.loopStart||0)&&(this.loopStart=e.loopStart||0),this.loopEnd!==(e.loopEnd||0)&&(this.loopEnd=e.loopEnd||0);}get paused(){return typeof this.pausedAt=="number"}set paused(e){let n=this.state;if(e)this.pausedAt=B.now(),n==="started"&&super.stop();else {let s;typeof this.pausedAt=="number"&&(s=this.pausedAt-this.playStartTime,this.pausedAt=void 0),n==="stopped"&&(this.delay?this.start(`+${this.delay}`,s):this.start(void 0,s));}}get muted(){return this.mute}set muted(e){this.mute=e;}get speed(){return this.playbackRate}set speed(e){this.playbackRate=e;}stop(e){return p.mediaInstances.delete(this.alias),super.stop(e)}start(e,n,s){let r=B.now(),a=r;if(typeof e=="number")a=e;else if(typeof e=="string"&&e.startsWith("+")){let u=Number(e.slice(1));Number.isNaN(u)||(a=r+u);}let l=typeof n=="number"?n:0;return this.playStartTime=a-l,super.start(e,n,s)}chain(...e){return e.forEach(n=>{vt(n)&&(n.toDestination(),this.filters.add(n));}),super.chain(...e)}disconnect(e){return vt(e)&&(e.disconnect(),this.filters.delete(e)),super.disconnect(e)}};var Pe=class{constructor(t,e={}){m(this,"alias",t);m(this,"toneChannel");m(this,"background");this.background=e.background??false,this.toneChannel=new B.Channel({volume:ne(e.volume??1),mute:e.muted??false,pan:e.pan??0}).toDestination(),e.filters&&this.toneChannel.chain(...e.filters);}get volume(){return Te(this.toneChannel.volume.value)}set volume(t){this.toneChannel.volume.value=ne(t);}get volumeParam(){return this.toneChannel.volume}get pan(){return this.toneChannel.pan.value}set pan(t){this.toneChannel.pan.value=t;}get panParam(){return this.toneChannel.pan}get muted(){return this.toneChannel.mute}set muted(t){this.toneChannel.mute=t;}pauseAll(){for(let t of p.mediaInstances.values())t.channelAlias===this.alias&&!t.paused&&(t.paused=true);return this}resumeAll(){for(let t of p.mediaInstances.values())t.channelAlias===this.alias&&t.paused&&(t.paused=false);return this}chain(...t){return this.toneChannel.chain(...t),this}_createPlayer(t,e,n={}){let s=p.bufferRegistry.get(e);if(!s)throw new core.PixiError("unregistered_asset",`Sound buffer for alias "${e}" is not loaded. Call sound.load() first.`);let{delay:r,elapsed:a,filters:l=[],muted:u,autostart:g=true,speed:w,volume:b,...M}=n;u!==void 0&&(_.warn(`MediaInstance "${t}" is being created with muted=${u}. This will override the channel's muted state (${this.muted}).`),M.mute=u),w!==void 0&&(_.warn(`MediaInstance "${t}" is being created with speed=${w}. This will override the default playback speed of 1.`),M.playbackRate=w);let D=new Ee(t,this.alias,e,core.GameUnifier.stepCounter,{...M,volume:b!==void 0?ne(b):void 0,url:s},r).chain(...l,this.toneChannel),z=a!==void 0?Math.max(0,a):void 0;return g&&(r?D.start(`+${r}`,z):D.start(void 0,z)),D}async play(t,e,n){let s,r;if(typeof e=="string"?(s=t,r=e):(s=t,r=t,n=e),p.mediaInstances.has(s)){let l=p.mediaInstances.get(s);l&&(l.stop(),n={...l.memory,...n,filters:[...l.filters,...n?.filters||[]]});}await Ge(r);let a=this._createPlayer(s,r,n);return p.mediaInstances.set(s,a),a}toggleMuteAll(){return this.muted=!this.muted,this.muted}get mediaInstances(){return Array.from(p.mediaInstances.values()).reduce((t,e)=>(e.channelAlias===this.alias&&t.push(e),t),[])}stopAll(){let t=[];for(let[e,n]of p.mediaInstances.entries())n.channelAlias===this.alias&&(n.stop(),t.push(e));return t.forEach(e=>{p.mediaInstances.delete(e);}),this}};function Mt(o){try{if(typeof o>"u")return o;let t=JSON.stringify(o);return JSON.parse(t)}catch(t){throw _.error("Error creating exportable element",o,t),new core.PixiError("not_json_serializable","Error creating exportable element")}}var xe=class{constructor(){m(this,"_speedAll",1);m(this,"_defaultChannelAlias",At);}get volumeAll(){return Te(B__namespace.getDestination().volume.value)}set volumeAll(t){B__namespace.getDestination().volume.value=ne(t);}get speedAll(){return this._speedAll}set speedAll(t){this._speedAll=t;for(let e of p.mediaInstances.values())e.speed=t;}get defaultChannelAlias(){return this._defaultChannelAlias}set defaultChannelAlias(t){this._defaultChannelAlias=t;}add(t,e){if(!p.bufferRegistry.has(t)){let n=new B__namespace.ToneAudioBuffer(e);p.bufferRegistry.set(t,n);}}pauseAll(){for(let t of p.mediaInstances.values())t.paused||(t.paused=true);return this}resumeAll(){for(let t of p.mediaInstances.values())t.paused&&(t.paused=false);return this}get muted(){return B__namespace.getDestination().mute}toggleMuteAll(){let t=!B__namespace.getDestination().mute;return B__namespace.getDestination().mute=t,t}muteAll(){return B__namespace.getDestination().mute=true,this}unmuteAll(){return B__namespace.getDestination().mute=false,this}stopAll(){for(let t of p.mediaInstances.values())t.stop();return p.mediaInstances.clear(),this}pauseUnsavedAll(t){for(let[e,n]of p.mediaInstances.entries())t&&n.channelAlias!==t||n.paused||(n.paused=true,p.systemPausedAliases.add(e));if(!t){for(let e of p.transients)e.stop();p.transients.clear();}return this}resumeUnsavedAll(t){let e=[];for(let n of p.systemPausedAliases){let s=p.mediaInstances.get(n);if(!s){e.push(n);continue}t&&s.channelAlias!==t||(s.paused=false,e.push(n));}for(let n of e)p.systemPausedAliases.delete(n);return this}stopTransientAll(){for(let t of p.transients)t.stop();return p.transients.clear(),this}async play(t,e,n){let s,r;typeof e=="string"?(s=t,r=e):(s=t,r=t,n=e),p.bufferRegistry.has(r)||await this.load(r);let{channel:a=this.defaultChannelAlias,...l}=n??{};return await this.findChannel(a).play(s,r,l)}async playTransient(t,e){p.bufferRegistry.has(t)||await this.load(t);let n=p.bufferRegistry.get(t);if(!n)throw new core.PixiError("unregistered_asset",`Sound buffer for alias "${t}" is not loaded. Call sound.load() first.`);let{autostart:s=true,...r}=e??{},a=new B__namespace.Player({...r,url:n}).toDestination();return s&&a.start(),p.transients.add(a),a.onstop=()=>{a.dispose(),p.transients.delete(a);},a}find(t){return p.mediaInstances.get(t)}stop(t){let e=this.find(t);e?(e.stop(),p.mediaInstances.delete(t)):_.warn(`No media instance found with alias ${t} to stop.`);}pause(t){let e=this.find(t);if(!e){_.warn(`No media instance found with alias ${t} to pause.`);return}return e.paused=true,e}resume(t){let e=this.find(t);if(!e){_.warn(`No media instance found with alias ${t} to resume.`);return}return e.paused=false,e}duration(t){return p.bufferRegistry.get(t)?.duration??0}async load(...t){let e=t.map(Ge);await Promise.all(e);}backgroundLoad(...t){return this.load(...t).catch(e=>{_.error("Error background-loading sound",e);})}backgroundLoadBundle(t){let e=kt__default.default.Assets.backgroundLoadBundle(t);return e.then(async()=>{try{let n=await kt__default.default.Assets.loadBundle(t),s=[];for(let r in n)p.bufferRegistry.has(r)||s.push(this.load(r));await Promise.all(s);}catch(n){_.error("Error loading sound bundle",n);}}).catch(n=>{_.error("Error background-loading sound bundle",n);}),e}clear(){this.stopAll();}addChannel(t,e={}){if(typeof t!="string"){t.forEach(s=>{let r={...e,filters:e.filters?[...e.filters]:e.filters};this.addChannel(s,r);});return}if(p.channels.has(t)){_.warn(`Channel with alias ${t} already exists.`);return}let n=new Pe(t,e);return p.channels.set(t,n),n}findChannel(t){let e=p.channels.get(t);return e||this.addChannel(t)}get channels(){return Array.from(p.channels.values())}export(){let t=Array.from(p.mediaInstances.entries()).reduce((e,[n,s])=>(e[n]={channelAlias:s.channelAlias,soundAlias:s.soundAlias,stepCounter:s.stepCounter,paused:s.paused,options:{...s.memory,filters:It(s.filters)}},e),{});return {mediaInstances:Mt(t)}}async restore(t){try{if(Object.hasOwn(t,"soundsPlaying")){let e=t.soundsPlaying;if(e){let n=Object.keys(e).map(async s=>{await this.load(s),await this.play(s);});await Promise.all(n);}}if(Object.hasOwn(t,"mediaInstances")){let e=t.mediaInstances;if(e){let n=new Set,s=Object.values(e).map(async({soundAlias:a,channelAlias:l})=>(n.add(l),await this.load(a)));await Promise.all(s),this.channels.forEach(a=>{(!a.background||!n.has(a.alias))&&a.stopAll();});let r=Object.keys(e).map(async a=>{let l=e[a],u=this.findChannel(l.channelAlias),g=l.options.paused??l.paused??!1;if(u.background)if(l.stepCounter===core.GameUnifier.stepCounter||!this.find(a)){let w=await u.play(a,l.soundAlias,{...l.options,autostart:!g,filters:Ne(l.options.filters||[]),delay:l.options.delay});w.paused=g;}else {let w=p.mediaInstances.get(a);if(!w){_.warn(`No media instance found with alias ${a} while restoring background state.`);return}w.memory={...l.options,paused:g},[...w.filters].forEach(M=>{w.disconnect(M),M.dispose();}),w.chain(...Ne(l.options.filters||[]));}else {let w=await u.play(a,l.soundAlias,{...l.options,autostart:!g,filters:Ne(l.options.filters||[]),delay:l.options.delay});w.paused=g;}});await Promise.all(r);}}}catch(e){_.error("Error importing data",e);}}};var wt=new xe;core.GameUnifier.addOnPreContinue(async()=>{try{p.channels.forEach(o=>{o.background||o.stopAll();});}catch{}});if(typeof document<"u"){let o=false;document.addEventListener("visibilitychange",()=>{document.hidden?wt.muted||(wt.muteAll(),o=true):o&&(wt.unmuteAll(),o=false);});}exports.SoundRegistry=p;exports.sound=wt;