@drincs/pixi-vn 1.2.16 → 1.2.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/canvas/index.cjs +52 -52
- package/dist/canvas/index.d.cts +1 -1
- package/dist/canvas/index.d.ts +1 -1
- package/dist/canvas/index.mjs +52 -52
- package/dist/canvas/tickers/index.cjs +2 -2
- package/dist/canvas/tickers/index.mjs +2 -2
- package/dist/character/index.cjs +1 -1
- package/dist/character/index.mjs +1 -1
- package/dist/{index-1w4bBKAx.d.cts → index-DbaokgZ8.d.cts} +24 -8
- package/dist/{index-xaLEzplg.d.ts → index-DiRMyOsp.d.ts} +24 -8
- package/dist/index.cjs +101 -101
- package/dist/index.d.cts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.mjs +101 -101
- package/dist/narration/index.cjs +29 -29
- package/dist/narration/index.mjs +29 -29
- package/dist/sound/index.cjs +20 -20
- package/dist/sound/index.mjs +20 -20
- package/package.json +1 -1
package/dist/character/index.cjs
CHANGED
|
@@ -566,4 +566,4 @@ fn mainFragment(
|
|
|
566
566
|
|
|
567
567
|
outColor = texture(uTexture, coord, unclamped == coord ? 0.0 : -32.0);// lod-bias very negative to force lod 0
|
|
568
568
|
|
|
569
|
-
`}};});var pl,ml,wn,Gg=p(()=>{nt();Ro();Eg();Oo();es();je();Ft();kg();wn=class extends Ae{constructor(){pl??(pl=jr({name:"tiling-sprite-shader",bits:[Ss,Fg,qr]})),ml??(ml=Kr({name:"tiling-sprite-shader",bits:[Ag,Bg,Zr]}));let t=new zt({uMapCoord:{value:new F,type:"mat3x3<f32>"},uClampFrame:{value:new Float32Array([0,0,1,1]),type:"vec4<f32>"},uClampOffset:{value:new Float32Array([0,0]),type:"vec2<f32>"},uTextureTransform:{value:new F,type:"mat3x3<f32>"},uSizeAnchor:{value:new Float32Array([100,100,.5,.5]),type:"vec4<f32>"}});super({glProgram:ml,gpuProgram:pl,resources:{localUniforms:new zt({uTransformMatrix:{value:new F,type:"mat3x3<f32>"},uColor:{value:new Float32Array([1,1,1,1]),type:"vec4<f32>"},uRound:{value:0,type:"f32"}}),tilingUniforms:t,uTexture:R.EMPTY.source,uSampler:R.EMPTY.source.style}});}updateUniforms(t,e,r,s,o,n){let a=this.resources.tilingUniforms,h=n.width,l=n.height,c=n.textureMatrix,u=a.uniforms.uTextureTransform;u.set(r.a*h/t,r.b*h/e,r.c*l/t,r.d*l/e,r.tx/t,r.ty/e),u.invert(),a.uniforms.uMapCoord=c.mapCoord,a.uniforms.uClampFrame=c.uClampFrame,a.uniforms.uClampOffset=c.uClampOffset,a.uniforms.uTextureTransform=u,a.uniforms.uSizeAnchor[0]=t,a.uniforms.uSizeAnchor[1]=e,a.uniforms.uSizeAnchor[2]=s,a.uniforms.uSizeAnchor[3]=o,n&&(this.resources.uTexture=n.source,this.resources.uSampler=n.source.style);}};});var Pn,Rg=p(()=>{Tn();Pn=class extends ci{constructor(){super({positions:new Float32Array([0,0,1,0,1,1,0,1]),uvs:new Float32Array([0,0,1,0,1,1,0,1]),indices:new Uint32Array([0,1,2,0,2,3])});}};});function Ig(i,t){let e=i.anchor.x,r=i.anchor.y;t[0]=-e*i.width,t[1]=-r*i.height,t[2]=(1-e)*i.width,t[3]=-r*i.height,t[4]=(1-e)*i.width,t[5]=(1-r)*i.height,t[6]=-e*i.width,t[7]=(1-r)*i.height;}var Dg=p(()=>{});function Lg(i,t,e,r){let s=0,o=i.length/(t),n=r.a,a=r.b,h=r.c,l=r.d,c=r.tx,u=r.ty;for(e*=t;s<o;){let f=i[e],d=i[e+1];i[e]=n*f+h*d+c,i[e+1]=a*f+l*d+u,e+=t,s++;}}var Ug=p(()=>{});function Og(i,t){let e=i.texture,r=e.frame.width,s=e.frame.height,o=0,n=0;i.applyAnchorToTexture&&(o=i.anchor.x,n=i.anchor.y),t[0]=t[6]=-o,t[2]=t[4]=1-o,t[1]=t[3]=-n,t[5]=t[7]=1-n;let a=F.shared;a.copyFrom(i._tileTransform.matrix),a.tx/=i.width,a.ty/=i.height,a.invert(),a.scale(i.width/r,i.height/s),Lg(t,2,0,a);}var zg=p(()=>{nt();Ug();});var Mn,gl,Ts,Wg=p(()=>{I();Zi();jo();ts();ns();Ko();Tn();Gg();Rg();Dg();zg();Mn=new Pn,gl=class{constructor(){this.canBatch=true,this.geometry=new ci({indices:Mn.indices.slice(),positions:Mn.positions.slice(),uvs:Mn.uvs.slice()});}destroy(){this.geometry.destroy(),this.shader?.destroy();}},Ts=class{constructor(t){this._state=vr.default2d,this._renderer=t;}validateRenderable(t){let e=this._getTilingSpriteData(t),r=e.canBatch;this._updateCanBatch(t);let s=e.canBatch;if(s&&s===r){let{batchableMesh:o}=e;return !o._batcher.checkAndUpdateTexture(o,t.texture)}return r!==s}addRenderable(t,e){let r=this._renderer.renderPipes.batch;this._updateCanBatch(t);let s=this._getTilingSpriteData(t),{geometry:o,canBatch:n}=s;if(n){s.batchableMesh||(s.batchableMesh=new qe);let a=s.batchableMesh;t.didViewUpdate&&(this._updateBatchableMesh(t),a.geometry=o,a.renderable=t,a.transform=t.groupTransform,a.setTexture(t._texture)),a.roundPixels=this._renderer._roundPixels|t._roundPixels,r.addToBatch(a,e);}else r.break(e),s.shader||(s.shader=new wn),this.updateRenderable(t),e.add(t);}execute(t){let{shader:e}=this._getTilingSpriteData(t);e.groups[0]=this._renderer.globalUniforms.bindGroup;let r=e.resources.localUniforms.uniforms;r.uTransformMatrix=t.groupTransform,r.uRound=this._renderer._roundPixels|t._roundPixels,Ke(t.groupColorAlpha,r.uColor,0),this._state.blendMode=Le(t.groupBlendMode,t.texture._source),this._renderer.encoder.draw({geometry:Mn,shader:e,state:this._state});}updateRenderable(t){let e=this._getTilingSpriteData(t),{canBatch:r}=e;if(r){let{batchableMesh:s}=e;t.didViewUpdate&&this._updateBatchableMesh(t),s._batcher.updateElement(s);}else if(t.didViewUpdate){let{shader:s}=e;s.updateUniforms(t.width,t.height,t._tileTransform.matrix,t.anchor.x,t.anchor.y,t.texture);}}_getTilingSpriteData(t){return t._gpuData[this._renderer.uid]||this._initTilingSpriteData(t)}_initTilingSpriteData(t){let e=new gl;return e.renderable=t,t._gpuData[this._renderer.uid]=e,e}_updateBatchableMesh(t){let e=this._getTilingSpriteData(t),{geometry:r}=e,s=t.texture.source.style;s.addressMode!=="repeat"&&(s.addressMode="repeat",s.update()),Og(t,r.uvs),Ig(t,r.positions);}destroy(){this._renderer=null;}_updateCanBatch(t){let e=this._getTilingSpriteData(t),r=t.texture,s=true;return this._renderer.type===Ce.WEBGL&&(s=this._renderer.context.supports.nonPowOf2wrapping),e.canBatch=r.textureMatrix.isSimple&&(s||r.source.isPowerOfTwo),e.canBatch}};Ts.extension={type:[T.WebGLPipes,T.WebGPUPipes,T.CanvasPipes],name:"tilingSprite"};});var xl=p(()=>{I();Wg();O.add(Ts);});var Vg,Hg,Yg=p(()=>{gt();Tn();Vg=class Ng extends ci{constructor(...t){super({});let e=t[0]??{};typeof e=="number"&&(L(X,"PlaneGeometry constructor changed please use { width, height, verticesX, verticesY } instead"),e={width:e,height:t[1],verticesX:t[2],verticesY:t[3]}),this.build(e);}build(t){t={...Ng.defaultOptions,...t},this.verticesX=this.verticesX??t.verticesX,this.verticesY=this.verticesY??t.verticesY,this.width=this.width??t.width,this.height=this.height??t.height;let e=this.verticesX*this.verticesY,r=[],s=[],o=[],n=this.verticesX-1,a=this.verticesY-1,h=this.width/n,l=this.height/a;for(let u=0;u<e;u++){let f=u%this.verticesX,d=u/this.verticesX|0;r.push(f*h,d*l),s.push(f/n,d/a);}let c=n*a;for(let u=0;u<c;u++){let f=u%n,d=u/n|0,g=d*this.verticesX+f,_=d*this.verticesX+f+1,m=(d+1)*this.verticesX+f,y=(d+1)*this.verticesX+f+1;o.push(g,_,m,_,y,m);}this.buffers[0].data=new Float32Array(r),this.buffers[1].data=new Float32Array(s),this.indexBuffer.data=new Uint32Array(o),this.buffers[0].update(),this.buffers[1].update(),this.indexBuffer.update();}};Vg.defaultOptions={width:100,height:100,verticesX:10,verticesY:10};Hg=Vg;});var $g,jg,Kg=p(()=>{Yg();$g=class Xg extends Hg{constructor(t={}){t={...Xg.defaultOptions,...t},super({width:t.width,height:t.height,verticesX:4,verticesY:4}),this.update(t);}update(t){this.width=t.width??this.width,this.height=t.height??this.height,this._originalWidth=t.originalWidth??this._originalWidth,this._originalHeight=t.originalHeight??this._originalHeight,this._leftWidth=t.leftWidth??this._leftWidth,this._rightWidth=t.rightWidth??this._rightWidth,this._topHeight=t.topHeight??this._topHeight,this._bottomHeight=t.bottomHeight??this._bottomHeight,this._anchorX=t.anchor?.x,this._anchorY=t.anchor?.y,this.updateUvs(),this.updatePositions();}updatePositions(){let t=this.positions,{width:e,height:r,_leftWidth:s,_rightWidth:o,_topHeight:n,_bottomHeight:a,_anchorX:h,_anchorY:l}=this,c=s+o,u=e>c?1:e/c,f=n+a,d=r>f?1:r/f,g=Math.min(u,d),_=h*e,m=l*r;t[0]=t[8]=t[16]=t[24]=-_,t[2]=t[10]=t[18]=t[26]=s*g-_,t[4]=t[12]=t[20]=t[28]=e-o*g-_,t[6]=t[14]=t[22]=t[30]=e-_,t[1]=t[3]=t[5]=t[7]=-m,t[9]=t[11]=t[13]=t[15]=n*g-m,t[17]=t[19]=t[21]=t[23]=r-a*g-m,t[25]=t[27]=t[29]=t[31]=r-m,this.getBuffer("aPosition").update();}updateUvs(){let t=this.uvs;t[0]=t[8]=t[16]=t[24]=0,t[1]=t[3]=t[5]=t[7]=0,t[6]=t[14]=t[22]=t[30]=1,t[25]=t[27]=t[29]=t[31]=1;let e=1/this._originalWidth,r=1/this._originalHeight;t[2]=t[10]=t[18]=t[26]=e*this._leftWidth,t[9]=t[11]=t[13]=t[15]=r*this._topHeight,t[4]=t[12]=t[20]=t[28]=1-e*this._rightWidth,t[17]=t[19]=t[21]=t[23]=1-r*this._bottomHeight,this.getBuffer("aUV").update();}};$g.defaultOptions={width:100,height:100,leftWidth:10,topHeight:10,rightWidth:10,bottomHeight:10,originalWidth:100,originalHeight:100};jg=$g;});var _l,ws,qg=p(()=>{I();Ko();Kg();_l=class extends qe{constructor(){super(),this.geometry=new jg;}destroy(){this.geometry.destroy();}},ws=class{constructor(t){this._renderer=t;}addRenderable(t,e){let r=this._getGpuSprite(t);t.didViewUpdate&&this._updateBatchableSprite(t,r),this._renderer.renderPipes.batch.addToBatch(r,e);}updateRenderable(t){let e=this._getGpuSprite(t);t.didViewUpdate&&this._updateBatchableSprite(t,e),e._batcher.updateElement(e);}validateRenderable(t){let e=this._getGpuSprite(t);return !e._batcher.checkAndUpdateTexture(e,t._texture)}_updateBatchableSprite(t,e){e.geometry.update(t),e.setTexture(t._texture);}_getGpuSprite(t){return t._gpuData[this._renderer.uid]||this._initGPUSprite(t)}_initGPUSprite(t){let e=t._gpuData[this._renderer.uid]=new _l,r=e;return r.renderable=t,r.transform=t.groupTransform,r.texture=t._texture,r.roundPixels=this._renderer._roundPixels|t._roundPixels,t.didViewUpdate||this._updateBatchableSprite(t,r),e}destroy(){this._renderer=null;}};ws.extension={type:[T.WebGLPipes,T.WebGPUPipes,T.CanvasPipes],name:"nineSliceSprite"};});var yl=p(()=>{I();qg();O.add(ws);});var Ps,Zg=p(()=>{I();Ps=class{constructor(t){this._renderer=t;}push(t,e,r){this._renderer.renderPipes.batch.break(r),r.add({renderPipeId:"filter",canBundle:false,action:"pushFilter",container:e,filterEffect:t});}pop(t,e,r){this._renderer.renderPipes.batch.break(r),r.add({renderPipeId:"filter",action:"popFilter",canBundle:false});}execute(t){t.action==="pushFilter"?this._renderer.filter.push(t):t.action==="popFilter"&&this._renderer.filter.pop();}destroy(){this._renderer=null;}};Ps.extension={type:[T.WebGLPipes,T.WebGPUPipes,T.CanvasPipes],name:"filter"};});function Qg(i,t){t.clear();let e=t.matrix;for(let r=0;r<i.length;r++){let s=i[r];s.globalDisplayStatus<7||(t.matrix=s.worldTransform,t.addBounds(s.bounds));}return t.matrix=e,t}var Jg=p(()=>{});var Uy,bl,Ms,tx=p(()=>{I();nt();qi();Ji();je();Ft();Dr();ts();he();Jg();Ut();Uy=new Me({attributes:{aPosition:{buffer:new Float32Array([0,0,1,0,1,1,0,1]),format:"float32x2",stride:2*4,offset:0}},indexBuffer:new Uint32Array([0,1,2,0,2,3])}),bl=class{constructor(){this.skip=false,this.inputTexture=null,this.backTexture=null,this.filters=null,this.bounds=new dt,this.container=null,this.blendRequired=false,this.outputRenderSurface=null,this.outputOffset={x:0,y:0},this.globalFrame={x:0,y:0,width:0,height:0};}},Ms=class{constructor(t){this._filterStackIndex=0,this._filterStack=[],this._filterGlobalUniforms=new zt({uInputSize:{value:new Float32Array(4),type:"vec4<f32>"},uInputPixel:{value:new Float32Array(4),type:"vec4<f32>"},uInputClamp:{value:new Float32Array(4),type:"vec4<f32>"},uOutputFrame:{value:new Float32Array(4),type:"vec4<f32>"},uGlobalFrame:{value:new Float32Array(4),type:"vec4<f32>"},uOutputTexture:{value:new Float32Array(4),type:"vec4<f32>"}}),this._globalFilterBindGroup=new oe({}),this.renderer=t;}get activeBackTexture(){return this._activeFilterData?.backTexture}push(t){let e=this.renderer,r=t.filterEffect.filters,s=this._pushFilterData();s.skip=false,s.filters=r,s.container=t.container,s.outputRenderSurface=e.renderTarget.renderSurface;let o=e.renderTarget.renderTarget.colorTexture.source,n=o.resolution,a=o.antialias;if(r.length===0){s.skip=true;return}let h=s.bounds;if(t.renderables?Qg(t.renderables,h):t.filterEffect.filterArea?(h.clear(),h.addRect(t.filterEffect.filterArea),h.applyMatrix(t.container.worldTransform)):t.container.getFastGlobalBounds(true,h),t.container){let _=(t.container.renderGroup||t.container.parentRenderGroup).cacheToLocalTransform;_&&h.applyMatrix(_);}if(this._calculateFilterBounds(s,e.renderTarget.rootViewPort,a,n,1),s.skip)return;let l=this._getPreviousFilterData(),c=n,u=0,f=0;l&&(u=l.bounds.minX,f=l.bounds.minY,c=l.inputTexture.source._resolution),s.outputOffset.x=h.minX-u,s.outputOffset.y=h.minY-f;let d=s.globalFrame;if(d.x=u*c,d.y=f*c,d.width=o.width*c,d.height=o.height*c,s.backTexture=R.EMPTY,s.blendRequired){e.renderTarget.finishRenderPass();let g=e.renderTarget.getRenderTarget(s.outputRenderSurface);s.backTexture=this.getBackTexture(g,h,l?.bounds);}s.inputTexture=Gt.getOptimalTexture(h.width,h.height,s.resolution,s.antialias),e.renderTarget.bind(s.inputTexture,true),e.globalUniforms.push({offset:h});}generateFilteredTexture({texture:t,filters:e}){let r=this._pushFilterData();this._activeFilterData=r,r.skip=false,r.filters=e;let s=t.source,o=s.resolution,n=s.antialias;if(e.length===0)return r.skip=true,t;let a=r.bounds;if(a.addRect(t.frame),this._calculateFilterBounds(r,a.rectangle,n,o,0),r.skip)return t;let h=o,l=0,c=0;r.outputOffset.x=-a.minX,r.outputOffset.y=-a.minY;let u=r.globalFrame;u.x=l*h,u.y=c*h,u.width=s.width*h,u.height=s.height*h,r.outputRenderSurface=Gt.getOptimalTexture(a.width,a.height,r.resolution,r.antialias),r.backTexture=R.EMPTY,r.inputTexture=t,this.renderer.renderTarget.finishRenderPass(),this._applyFiltersToTexture(r,true);let d=r.outputRenderSurface;return d.source.alphaMode="premultiplied-alpha",d}pop(){let t=this.renderer,e=this._popFilterData();e.skip||(t.globalUniforms.pop(),t.renderTarget.finishRenderPass(),this._activeFilterData=e,this._applyFiltersToTexture(e,false),e.blendRequired&&Gt.returnTexture(e.backTexture),Gt.returnTexture(e.inputTexture));}getBackTexture(t,e,r){let s=t.colorTexture.source._resolution,o=Gt.getOptimalTexture(e.width,e.height,s,false),n=e.minX,a=e.minY;r&&(n-=r.minX,a-=r.minY),n=Math.floor(n*s),a=Math.floor(a*s);let h=Math.ceil(e.width*s),l=Math.ceil(e.height*s);return this.renderer.renderTarget.copyToTexture(t,o,{x:n,y:a},{width:h,height:l},{x:0,y:0}),o}applyFilter(t,e,r,s){let o=this.renderer,n=this._activeFilterData,a=n.outputRenderSurface,h=this._filterGlobalUniforms,l=h.uniforms,c=l.uOutputFrame,u=l.uInputSize,f=l.uInputPixel,d=l.uInputClamp,g=l.uGlobalFrame,_=l.uOutputTexture;a===r?(c[0]=n.outputOffset.x,c[1]=n.outputOffset.y):(c[0]=0,c[1]=0),c[2]=e.frame.width,c[3]=e.frame.height,u[0]=e.source.width,u[1]=e.source.height,u[2]=1/u[0],u[3]=1/u[1],f[0]=e.source.pixelWidth,f[1]=e.source.pixelHeight,f[2]=1/f[0],f[3]=1/f[1],d[0]=.5*f[2],d[1]=.5*f[3],d[2]=e.frame.width*u[2]-.5*f[2],d[3]=e.frame.height*u[3]-.5*f[3],g[0]=n.globalFrame.x,g[1]=n.globalFrame.y,g[2]=n.globalFrame.width,g[3]=n.globalFrame.height,r instanceof R&&(r.source.resource=null);let m=this.renderer.renderTarget.getRenderTarget(r);if(o.renderTarget.bind(r,!!s),r instanceof R?(_[0]=r.frame.width,_[1]=r.frame.height):(_[0]=m.width,_[1]=m.height),_[2]=m.isRoot?-1:1,h.update(),o.renderPipes.uniformBatch){let y=o.renderPipes.uniformBatch.getUboResource(h);this._globalFilterBindGroup.setResource(y,0);}else this._globalFilterBindGroup.setResource(h,0);this._globalFilterBindGroup.setResource(e.source,1),this._globalFilterBindGroup.setResource(e.source.style,2),t.groups[0]=this._globalFilterBindGroup,o.encoder.draw({geometry:Uy,shader:t,state:t._state,topology:"triangle-list"}),o.type===Ce.WEBGL&&o.renderTarget.finishRenderPass();}calculateSpriteMatrix(t,e){let r=this._activeFilterData,s=t.set(r.inputTexture._source.width,0,0,r.inputTexture._source.height,r.bounds.minX,r.bounds.minY),o=e.worldTransform.copyTo(F.shared),n=e.renderGroup||e.parentRenderGroup;return n&&n.cacheToLocalTransform&&o.prepend(n.cacheToLocalTransform),o.invert(),s.prepend(o),s.scale(1/e.texture.frame.width,1/e.texture.frame.height),s.translate(e.anchor.x,e.anchor.y),s}destroy(){}_applyFiltersToTexture(t,e){let r=t.inputTexture,s=t.bounds,o=t.filters;if(this._globalFilterBindGroup.setResource(r.source.style,2),this._globalFilterBindGroup.setResource(t.backTexture.source,3),o.length===1)o[0].apply(this,r,t.outputRenderSurface,e);else {let n=t.inputTexture,a=Gt.getOptimalTexture(s.width,s.height,n.source._resolution,false),h=a,l=0;for(l=0;l<o.length-1;++l){o[l].apply(this,n,h,true);let u=n;n=h,h=u;}o[l].apply(this,n,t.outputRenderSurface,e),Gt.returnTexture(a);}}_calculateFilterBounds(t,e,r,s,o){let n=this.renderer,a=t.bounds,h=t.filters,l=1/0,c=0,u=true,f=false,d=false,g=true;for(let _=0;_<h.length;_++){let m=h[_];if(l=Math.min(l,m.resolution==="inherit"?s:m.resolution),c+=m.padding,m.antialias==="off"?u=false:m.antialias==="inherit"&&u&&(u=r),m.clipToViewport||(g=false),!!!(m.compatibleRenderers&n.type)){d=false;break}if(m.blendRequired&&!(n.backBuffer?.useBackBuffer??true)){j("Blend filter requires backBuffer on WebGL renderer to be enabled. Set `useBackBuffer: true` in the renderer options."),d=false;break}d=m.enabled||d,f||(f=m.blendRequired);}if(!d){t.skip=true;return}if(g&&a.fitBounds(0,e.width/s,0,e.height/s),a.scale(l).ceil().scale(1/l).pad((c|0)*o),!a.isPositive){t.skip=true;return}t.antialias=u,t.resolution=l,t.blendRequired=f;}_popFilterData(){return this._filterStackIndex--,this._filterStack[this._filterStackIndex]}_getPreviousFilterData(){let t,e=this._filterStackIndex-1;for(;e>1&&(e--,t=this._filterStack[e],!!t.skip););return t}_pushFilterData(){let t=this._filterStack[this._filterStackIndex];return t||(t=this._filterStack[this._filterStackIndex]=new bl),this._filterStackIndex++,t}};Ms.extension={type:[T.WebGLSystem,T.WebGPUSystem],name:"filter"};});var vl=p(()=>{I();Zg();tx();O.add(Ms);O.add(Ps);});var Oy={};var ex=p(()=>{vu();_a();Fu();ku();xo();To();Ah();Eh();Gh();il();cl();fl();xl();yl();vl();});var zy={};var ix=p(()=>{_a();xo();To();Ah();Eh();Gh();il();cl();fl();xl();yl();vl();});var be={};Mx(be,{DistortionFilter:()=>Vs,EqualizerFilter:()=>re,Filter:()=>vt,MonoFilter:()=>Ns,ReverbFilter:()=>Hs,StereoFilter:()=>Ys,StreamFilter:()=>$s,TelephoneFilter:()=>Xs});var Ul;function Ol(i){return Ul=i,i}function rt(){return Ul}var vt=class{constructor(t,e){this.init(t,e);}init(t,e){this.destination=t,this.source=e||t;}connect(t){this.source?.connect(t);}disconnect(){this.source?.disconnect();}destroy(){this.disconnect(),this.destination=null,this.source=null;}};var Vs=class extends vt{constructor(t=0){let e;if(!rt().useLegacy){let{audioContext:r}=rt().context;e=r.createWaveShaper();}super(e),this._distortion=e,this.amount=t;}set amount(t){if(this._amount=t,rt().useLegacy)return;let e=t*1e3,r=44100,s=new Float32Array(r),o=Math.PI/180,n=0,a;for(;n<r;++n)a=n*2/r-1,s[n]=(3+e)*a*20*o/(Math.PI+e*Math.abs(a));this._distortion.curve=s,this._distortion.oversample="4x";}get amount(){return this._amount}destroy(){this._distortion=null,super.destroy();}};var mt=class{static setParamValue(t,e){if(t.setValueAtTime){let r=rt().context;t.setValueAtTime(e,r.audioContext.currentTime);}else t.value=e;return e}};var it=class extends vt{constructor(i=0,t=0,e=0,r=0,s=0,o=0,n=0,a=0,h=0,l=0){let c=[],u=[{f:it.F32,type:"lowshelf",gain:i},{f:it.F64,type:"peaking",gain:t},{f:it.F125,type:"peaking",gain:e},{f:it.F250,type:"peaking",gain:r},{f:it.F500,type:"peaking",gain:s},{f:it.F1K,type:"peaking",gain:o},{f:it.F2K,type:"peaking",gain:n},{f:it.F4K,type:"peaking",gain:a},{f:it.F8K,type:"peaking",gain:h},{f:it.F16K,type:"highshelf",gain:l}];rt().useLegacy||(c=u.map(f=>{let d=rt().context.audioContext.createBiquadFilter();return d.type=f.type,mt.setParamValue(d.Q,1),d.frequency.value=f.f,mt.setParamValue(d.gain,f.gain),d})),super(c[0],c[c.length-1]),this.bands=c,this.bandsMap={};for(let f=0;f<this.bands.length;f++){let d=this.bands[f];f>0&&this.bands[f-1].connect(d),this.bandsMap[d.frequency.value]=d;}}setGain(i,t=0){if(!this.bandsMap[i])throw new Error(`No band found for frequency ${i}`);mt.setParamValue(this.bandsMap[i].gain,t);}getGain(i){if(!this.bandsMap[i])throw new Error(`No band found for frequency ${i}`);return this.bandsMap[i].gain.value}set f32(i){this.setGain(it.F32,i);}get f32(){return this.getGain(it.F32)}set f64(i){this.setGain(it.F64,i);}get f64(){return this.getGain(it.F64)}set f125(i){this.setGain(it.F125,i);}get f125(){return this.getGain(it.F125)}set f250(i){this.setGain(it.F250,i);}get f250(){return this.getGain(it.F250)}set f500(i){this.setGain(it.F500,i);}get f500(){return this.getGain(it.F500)}set f1k(i){this.setGain(it.F1K,i);}get f1k(){return this.getGain(it.F1K)}set f2k(i){this.setGain(it.F2K,i);}get f2k(){return this.getGain(it.F2K)}set f4k(i){this.setGain(it.F4K,i);}get f4k(){return this.getGain(it.F4K)}set f8k(i){this.setGain(it.F8K,i);}get f8k(){return this.getGain(it.F8K)}set f16k(i){this.setGain(it.F16K,i);}get f16k(){return this.getGain(it.F16K)}reset(){this.bands.forEach(i=>{mt.setParamValue(i.gain,0);});}destroy(){this.bands.forEach(i=>{i.disconnect();}),this.bands=null,this.bandsMap=null;}},re=it;re.F32=32;re.F64=64;re.F125=125;re.F250=250;re.F500=500;re.F1K=1e3;re.F2K=2e3;re.F4K=4e3;re.F8K=8e3;re.F16K=16e3;var Ns=class extends vt{constructor(){let t,e;if(!rt().useLegacy){let{audioContext:r}=rt().context;e=r.createChannelSplitter(),t=r.createChannelMerger(),t.connect(e);}super(t,e),this._merger=t;}destroy(){this._merger?.disconnect(),this._merger=null,super.destroy();}};var Hs=class extends vt{constructor(t=3,e=2,r=false){super(null),this._seconds=this._clamp(t,1,50),this._decay=this._clamp(e,0,100),this._reverse=r,this._rebuild();}_clamp(t,e,r){return Math.min(r,Math.max(e,t))}get seconds(){return this._seconds}set seconds(t){this._seconds=this._clamp(t,1,50),this._rebuild();}get decay(){return this._decay}set decay(t){this._decay=this._clamp(t,0,100),this._rebuild();}get reverse(){return this._reverse}set reverse(t){this._reverse=t,this._rebuild();}_rebuild(){if(rt().useLegacy)return;let{audioContext:t}=rt().context,e=t.sampleRate,r=e*this._seconds,s=t.createBuffer(2,r,e),o=s.getChannelData(0),n=s.getChannelData(1),a;for(let l=0;l<r;l++)a=this._reverse?r-l:l,o[l]=(Math.random()*2-1)*Math.pow(1-a/r,this._decay),n[l]=(Math.random()*2-1)*Math.pow(1-a/r,this._decay);let h=t.createConvolver();h.buffer=s,this.init(h);}};var Ys=class extends vt{constructor(t=0){let e,r,s;if(!rt().useLegacy){let{audioContext:o}=rt().context;o.createStereoPanner?(e=o.createStereoPanner(),s=e):(r=o.createPanner(),r.panningModel="equalpower",s=r);}super(s),this._stereo=e,this._panner=r,this.pan=t;}set pan(t){this._pan=t,this._stereo?mt.setParamValue(this._stereo.pan,t):this._panner&&this._panner.setPosition(t,0,1-Math.abs(t));}get pan(){return this._pan}destroy(){super.destroy(),this._stereo=null,this._panner=null;}};var $s=class extends vt{constructor(){let t,e;if(!rt().useLegacy){let{audioContext:r}=rt().context;t=r.createMediaStreamDestination(),e=r.createMediaStreamSource(t.stream);}super(t,e),this._stream=t?.stream;}get stream(){return this._stream}destroy(){this._stream=null,super.destroy();}};var Xs=class extends vt{constructor(){let t,e;if(!rt().useLegacy){let{audioContext:r}=rt().context,s=r.createBiquadFilter(),o=r.createBiquadFilter(),n=r.createBiquadFilter(),a=r.createBiquadFilter();s.type="lowpass",mt.setParamValue(s.frequency,2e3),o.type="lowpass",mt.setParamValue(o.frequency,2e3),n.type="highpass",mt.setParamValue(n.frequency,500),a.type="highpass",mt.setParamValue(a.frequency,500),s.connect(o),o.connect(n),n.connect(a),t=s,e=a;}super(t,e);}};I();var rx={extension:{type:T.Environment,name:"browser",priority:-1},test:()=>true,load:async()=>{await Promise.resolve().then(()=>(ex(),Oy));}};I();var sx={extension:{type:T.Environment,name:"webworker",priority:0},test:()=>typeof self<"u"&&self.WorkerGlobalScope!==void 0,load:async()=>{await Promise.resolve().then(()=>(ix(),zy));}};I();I();To();xo();Aa();ce();Oa();Ui();Nt();go();O.add(rx,sx);var Cs=class extends Z{constructor(){super(...arguments),this.speed=1,this.muted=false,this.volume=1,this.paused=false;}refresh(){this.emit("refresh");}refreshPaused(){this.emit("refreshPaused");}get filters(){return console.warn("HTML Audio does not support filters"),null}set filters(t){console.warn("HTML Audio does not support filters");}get audioContext(){return console.warn("HTML Audio does not support audioContext"),null}toggleMute(){return this.muted=!this.muted,this.refresh(),this.muted}togglePause(){return this.paused=!this.paused,this.refreshPaused(),this.paused}destroy(){this.removeAllListeners();}};var Wy=0,Sl=class extends Z{constructor(i){super(),this.id=Wy++,this.init(i);}set(i,t){if(this[i]===void 0)throw new Error(`Property with name ${i} does not exist.`);switch(i){case "speed":this.speed=t;break;case "volume":this.volume=t;break;case "paused":this.paused=t;break;case "loop":this.loop=t;break;case "muted":this.muted=t;break}return this}get progress(){let{currentTime:i}=this._source;return i/this._duration}get paused(){return this._paused}set paused(i){this._paused=i,this.refreshPaused();}_onPlay(){this._playing=true;}_onPause(){this._playing=false;}init(i){this._playing=false,this._duration=i.source.duration;let t=this._source=i.source.cloneNode(false);t.src=i.parent.url,t.onplay=this._onPlay.bind(this),t.onpause=this._onPause.bind(this),i.context.on("refresh",this.refresh,this),i.context.on("refreshPaused",this.refreshPaused,this),this._media=i;}_internalStop(){this._source&&this._playing&&(this._source.onended=null,this._source.pause());}stop(){this._internalStop(),this._source&&this.emit("stop");}get speed(){return this._speed}set speed(i){this._speed=i,this.refresh();}get volume(){return this._volume}set volume(i){this._volume=i,this.refresh();}get loop(){return this._loop}set loop(i){this._loop=i,this.refresh();}get muted(){return this._muted}set muted(i){this._muted=i,this.refresh();}get filters(){return console.warn("HTML Audio does not support filters"),null}set filters(i){console.warn("HTML Audio does not support filters");}refresh(){let i=this._media.context,t=this._media.parent;this._source.loop=this._loop||t.loop;let e=i.volume*(i.muted?0:1),r=t.volume*(t.muted?0:1),s=this._volume*(this._muted?0:1);this._source.volume=s*e*r,this._source.playbackRate=this._speed*i.speed*t.speed;}refreshPaused(){let i=this._media.context,t=this._media.parent,e=this._paused||t.paused||i.paused;e!==this._pausedReal&&(this._pausedReal=e,e?(this._internalStop(),this.emit("paused")):(this.emit("resumed"),this.play({start:this._source.currentTime,end:this._end,volume:this._volume,speed:this._speed,loop:this._loop})),this.emit("pause",e));}play(i){let{start:t,end:e,speed:r,loop:s,volume:o,muted:n}=i;e&&console.assert(e>t,"End time is before start time"),this._speed=r,this._volume=o,this._loop=!!s,this._muted=n,this.refresh(),this.loop&&e!==null&&(console.warn('Looping not support when specifying an "end" time'),this.loop=false),this._start=t,this._end=e||this._duration,this._start=Math.max(0,this._start-Sl.PADDING),this._end=Math.min(this._end+Sl.PADDING,this._duration),this._source.onloadedmetadata=()=>{this._source&&(this._source.currentTime=t,this._source.onloadedmetadata=null,this.emit("progress",t/this._duration,this._duration),wt.shared.add(this._onUpdate,this));},this._source.onended=this._onComplete.bind(this),this._source.play(),this.emit("start");}_onUpdate(){this.emit("progress",this.progress,this._duration),this._source.currentTime>=this._end&&!this._source.loop&&this._onComplete();}_onComplete(){wt.shared.remove(this._onUpdate,this),this._internalStop(),this.emit("progress",1,this._duration),this.emit("end",this);}destroy(){wt.shared.remove(this._onUpdate,this),this.removeAllListeners();let i=this._source;i&&(i.onended=null,i.onplay=null,i.onpause=null,this._internalStop()),this._source=null,this._speed=1,this._volume=1,this._loop=false,this._end=null,this._start=0,this._duration=0,this._playing=false,this._pausedReal=false,this._paused=false,this._muted=false,this._media&&(this._media.context.off("refresh",this.refresh,this),this._media.context.off("refreshPaused",this.refreshPaused,this),this._media=null);}toString(){return `[HTMLAudioInstance id=${this.id}]`}},Cn=Sl;Cn.PADDING=.1;var As=class extends Z{init(t){this.parent=t,this._source=t.options.source||new Audio,t.url&&(this._source.src=t.url);}create(){return new Cn(this)}get isPlayable(){return !!this._source&&this._source.readyState===4}get duration(){return this._source.duration}get context(){return this.parent.context}get filters(){return null}set filters(t){console.warn("HTML Audio does not support filters");}destroy(){this.removeAllListeners(),this.parent=null,this._source&&(this._source.src="",this._source.load(),this._source=null);}get source(){return this._source}load(t){let e=this._source,r=this.parent;if(e.readyState===4){r.isLoaded=true;let h=r.autoPlayStart();t&&setTimeout(()=>{t(null,r,h);},0);return}if(!r.url){t(new Error("sound.url or sound.source must be set"));return}e.src=r.url;let s=()=>{a(),r.isLoaded=true;let h=r.autoPlayStart();t&&t(null,r,h);},o=()=>{a(),t&&t(new Error("Sound loading has been aborted"));},n=()=>{a();let h=`Failed to load audio element (code: ${e.error.code})`;t?t(new Error(h)):console.error(h);},a=()=>{e.removeEventListener("canplaythrough",s),e.removeEventListener("load",s),e.removeEventListener("abort",o),e.removeEventListener("error",n);};e.addEventListener("canplaythrough",s,false),e.addEventListener("load",s,false),e.addEventListener("abort",o,false),e.addEventListener("error",n,false),e.load();}};var Es=class{constructor(t,e){this.parent=t,Object.assign(this,e),this.duration=this.end-this.start,console.assert(this.duration>0,"End time must be after start time");}play(t){return this.parent.play({complete:t,speed:this.speed||this.parent.speed,end:this.end,start:this.start,loop:this.loop})}destroy(){this.parent=null;}};var Pr=["ogg","oga","opus","m4a","mp3","mpeg","wav","aiff","wma","mid","caf"],Tl=["audio/mpeg","audio/ogg"],Mr={};function ox(i){let t={m4a:"audio/mp4",oga:"audio/ogg",opus:'audio/ogg; codecs="opus"',caf:'audio/x-caf; codecs="opus"',...{}},e=document.createElement("audio"),r={},s=/^no$/;Pr.forEach(o=>{let n=e.canPlayType(`audio/${o}`).replace(s,""),a=t[o]?e.canPlayType(t[o]).replace(s,""):"";r[o]=!!n||!!a;}),Object.assign(Mr,r);}ox();var Ny=0,Fs=class extends Z{constructor(t){super(),this.id=Ny++,this._media=null,this._paused=false,this._muted=false,this._elapsed=0,this.init(t);}set(t,e){if(this[t]===void 0)throw new Error(`Property with name ${t} does not exist.`);switch(t){case "speed":this.speed=e;break;case "volume":this.volume=e;break;case "muted":this.muted=e;break;case "loop":this.loop=e;break;case "paused":this.paused=e;break}return this}stop(){this._source&&(this._internalStop(),this.emit("stop"));}get speed(){return this._speed}set speed(t){this._speed=t,this.refresh(),this._update(true);}get volume(){return this._volume}set volume(t){this._volume=t,this.refresh();}get muted(){return this._muted}set muted(t){this._muted=t,this.refresh();}get loop(){return this._loop}set loop(t){this._loop=t,this.refresh();}get filters(){return this._filters}set filters(t){this._filters&&(this._filters?.filter(e=>e).forEach(e=>e.disconnect()),this._filters=null,this._source.connect(this._gain)),this._filters=t?.length?t.slice(0):null,this.refresh();}refresh(){if(!this._source)return;let t=this._media.context,e=this._media.parent;this._source.loop=this._loop||e.loop;let r=t.volume*(t.muted?0:1),s=e.volume*(e.muted?0:1),o=this._volume*(this._muted?0:1);mt.setParamValue(this._gain.gain,o*s*r),mt.setParamValue(this._source.playbackRate,this._speed*e.speed*t.speed),this.applyFilters();}applyFilters(){if(this._filters?.length){this._source.disconnect();let t=this._source;this._filters.forEach(e=>{t.connect(e.destination),t=e;}),t.connect(this._gain);}}refreshPaused(){let t=this._media.context,e=this._media.parent,r=this._paused||e.paused||t.paused;r!==this._pausedReal&&(this._pausedReal=r,r?(this._internalStop(),this.emit("paused")):(this.emit("resumed"),this.play({start:this._elapsed%this._duration,end:this._end,speed:this._speed,loop:this._loop,volume:this._volume})),this.emit("pause",r));}play(t){let{start:e,end:r,speed:s,loop:o,volume:n,muted:a,filters:h}=t;r&&console.assert(r>e,"End time is before start time"),this._paused=false;let{source:l,gain:c}=this._media.nodes.cloneBufferSource();this._source=l,this._gain=c,this._speed=s,this._volume=n,this._loop=!!o,this._muted=a,this._filters=h,this.refresh();let u=this._source.buffer.duration;this._duration=u,this._end=r,this._lastUpdate=this._now(),this._elapsed=e,this._source.onended=this._onComplete.bind(this),this._loop?(this._source.loopEnd=r,this._source.loopStart=e,this._source.start(0,e)):r?this._source.start(0,e,r-e):this._source.start(0,e),this.emit("start"),this._update(true),this.enableTicker(true);}enableTicker(t){wt.shared.remove(this._updateListener,this),t&&wt.shared.add(this._updateListener,this);}get progress(){return this._progress}get paused(){return this._paused}set paused(t){this._paused=t,this.refreshPaused();}destroy(){this.removeAllListeners(),this._internalStop(),this._gain&&(this._gain.disconnect(),this._gain=null),this._media&&(this._media.context.events.off("refresh",this.refresh,this),this._media.context.events.off("refreshPaused",this.refreshPaused,this),this._media=null),this._filters?.forEach(t=>t.disconnect()),this._filters=null,this._end=null,this._speed=1,this._volume=1,this._loop=false,this._elapsed=0,this._duration=0,this._paused=false,this._muted=false,this._pausedReal=false;}toString(){return `[WebAudioInstance id=${this.id}]`}_now(){return this._media.context.audioContext.currentTime}_updateListener(){this._update();}_update(t=false){if(this._source){let e=this._now(),r=e-this._lastUpdate;if(r>0||t){let s=this._source.playbackRate.value;this._elapsed+=r*s,this._lastUpdate=e;let o=this._duration,n;if(this._source.loopStart){let a=this._source.loopEnd-this._source.loopStart;n=(this._source.loopStart+this._elapsed%a)/o;}else n=this._elapsed%o/o;this._progress=n,this.emit("progress",this._progress,o);}}}init(t){this._media=t,t.context.events.on("refresh",this.refresh,this),t.context.events.on("refreshPaused",this.refreshPaused,this);}_internalStop(){if(this._source){this.enableTicker(false),this._source.onended=null,this._source.stop(0),this._source.disconnect();try{this._source.buffer=null;}catch(t){console.warn("Failed to set AudioBufferSourceNode.buffer to null:",t);}this._source=null;}}_onComplete(){if(this._source){this.enableTicker(false),this._source.onended=null,this._source.disconnect();try{this._source.buffer=null;}catch(t){console.warn("Failed to set AudioBufferSourceNode.buffer to null:",t);}}this._source=null,this._progress=1,this.emit("progress",1,this._duration),this.emit("end",this);}};var Cr=class{constructor(t,e){this._output=e,this._input=t;}get destination(){return this._input}get filters(){return this._filters}set filters(t){if(this._filters&&(this._filters.forEach(e=>{e&&e.disconnect();}),this._filters=null,this._input.connect(this._output)),t&&t.length){this._filters=t.slice(0),this._input.disconnect();let e=null;t.forEach(r=>{e===null?this._input.connect(r.destination):e.connect(r.destination),e=r;}),e.connect(this._output);}}destroy(){this.filters=null,this._input=null,this._output=null;}};var nx=class extends Cr{constructor(i){let t=i.audioContext,e=t.createBufferSource(),r=t.createGain(),s=t.createAnalyser();e.connect(s),s.connect(r),r.connect(i.destination),super(s,r),this.context=i,this.bufferSource=e,this.gain=r,this.analyser=s;}get script(){return this._script||(this._script=this.context.audioContext.createScriptProcessor(nx.BUFFER_SIZE),this._script.connect(this.context.destination)),this._script}destroy(){super.destroy(),this.bufferSource.disconnect(),this._script&&this._script.disconnect(),this.gain.disconnect(),this.analyser.disconnect(),this.bufferSource=null,this._script=null,this.gain=null,this.analyser=null,this.context=null;}cloneBufferSource(){let i=this.bufferSource,t=this.context.audioContext.createBufferSource();t.buffer=i.buffer,mt.setParamValue(t.playbackRate,i.playbackRate.value),t.loop=i.loop;let e=this.context.audioContext.createGain();return t.connect(e),e.connect(this.destination),{source:t,gain:e}}get bufferSize(){return this.script.bufferSize}},An=nx;An.BUFFER_SIZE=0;var Ar=class{init(t){this.parent=t,this._nodes=new An(this.context),this._source=this._nodes.bufferSource,this.source=t.options.source;}destroy(){this.parent=null,this._nodes.destroy(),this._nodes=null;try{this._source.buffer=null;}catch(t){console.warn("Failed to set AudioBufferSourceNode.buffer to null:",t);}this._source=null,this.source=null;}create(){return new Fs(this)}get context(){return this.parent.context}get isPlayable(){return !!this._source&&!!this._source.buffer}get filters(){return this._nodes.filters}set filters(t){this._nodes.filters=t;}get duration(){return console.assert(this.isPlayable,"Sound not yet playable, no duration"),this._source.buffer.duration}get buffer(){return this._source.buffer}set buffer(t){this._source.buffer=t;}get nodes(){return this._nodes}load(t){this.source?this._decode(this.source,t):this.parent.url?this._loadUrl(t):t?t(new Error("sound.url or sound.source must be set")):console.error("sound.url or sound.source must be set");}async _loadUrl(t){let e=this.parent.url,r=await ft.get().fetch(e);this._decode(await r.arrayBuffer(),t);}_decode(t,e){let r=(s,o)=>{if(s)e&&e(s);else {this.parent.isLoaded=true,this.buffer=o;let n=this.parent.autoPlayStart();e&&e(null,this.parent,n);}};t instanceof AudioBuffer?r(null,t):this.parent.context.decode(t,r);}};var ui=class{static from(i){let t={};typeof i=="string"?t.url=i:i instanceof ArrayBuffer||i instanceof AudioBuffer||i instanceof HTMLAudioElement?t.source=i:Array.isArray(i)?t.url=i:t=i,t={autoPlay:false,singleInstance:false,url:null,source:null,preload:false,volume:1,speed:1,complete:null,loaded:null,loop:false,...t},Object.freeze(t);let e=rt().useLegacy?new As:new Ar;return new ui(e,t)}constructor(i,t){this.media=i,this.options=t,this._instances=[],this._sprites={},this.media.init(this);let e=t.complete;this._autoPlayOptions=e?{complete:e}:null,this.isLoaded=false,this._preloadQueue=null,this.isPlaying=false,this.autoPlay=t.autoPlay,this.singleInstance=t.singleInstance,this.preload=t.preload||this.autoPlay,this.url=Array.isArray(t.url)?this.preferUrl(t.url):t.url,this.speed=t.speed,this.volume=t.volume,this.loop=t.loop,t.sprites&&this.addSprites(t.sprites),this.preload&&this._preload(t.loaded);}preferUrl(i){let[t]=i.map(e=>({url:e,ext:$t.extname(e).slice(1)})).filter(({ext:e})=>Mr[e]).sort((e,r)=>Pr.indexOf(e.ext)-Pr.indexOf(r.ext));if(!t)throw new Error("No supported file type found");return t.url}get context(){return rt().context}pause(){return this.isPlaying=false,this.paused=true,this}resume(){return this.isPlaying=this._instances.length>0,this.paused=false,this}get paused(){return this._paused}set paused(i){this._paused=i,this.refreshPaused();}get speed(){return this._speed}set speed(i){this._speed=i,this.refresh();}get filters(){return this.media.filters}set filters(i){this.media.filters=i;}addSprites(i,t){if(typeof i=="object"){let r={};for(let s in i)r[s]=this.addSprites(s,i[s]);return r}console.assert(!this._sprites[i],`Alias ${i} is already taken`);let e=new Es(this,t);return this._sprites[i]=e,e}destroy(){this._removeInstances(),this.removeSprites(),this.media.destroy(),this.media=null,this._sprites=null,this._instances=null;}removeSprites(i){if(i){let t=this._sprites[i];t!==void 0&&(t.destroy(),delete this._sprites[i]);}else for(let t in this._sprites)this.removeSprites(t);return this}get isPlayable(){return this.isLoaded&&this.media&&this.media.isPlayable}stop(){if(!this.isPlayable)return this.autoPlay=false,this._autoPlayOptions=null,this;this.isPlaying=false;for(let i=this._instances.length-1;i>=0;i--)this._instances[i].stop();return this}play(i,t){let e;if(typeof i=="string"?e={sprite:i,loop:this.loop,complete:t}:typeof i=="function"?(e={},e.complete=i):e=i,e={complete:null,loaded:null,sprite:null,end:null,start:0,volume:1,speed:1,muted:false,loop:false,...e||{}},e.sprite){let s=e.sprite;console.assert(!!this._sprites[s],`Alias ${s} is not available`);let o=this._sprites[s];e.start=o.start+(e.start||0),e.end=o.end,e.speed=o.speed||1,e.loop=o.loop||e.loop,delete e.sprite;}if(e.offset&&(e.start=e.offset),!this.isLoaded)return this._preloadQueue?new Promise(s=>{this._preloadQueue.push(()=>{s(this.play(e));});}):(this._preloadQueue=[],this.autoPlay=true,this._autoPlayOptions=e,new Promise((s,o)=>{this._preload((n,a,h)=>{this._preloadQueue.forEach(l=>l()),this._preloadQueue=null,n?o(n):(e.loaded&&e.loaded(n,a,h),s(h));});}));(this.singleInstance||e.singleInstance)&&this._removeInstances();let r=this._createInstance();return this._instances.push(r),this.isPlaying=true,r.once("end",()=>{e.complete&&e.complete(this),this._onComplete(r);}),r.once("stop",()=>{this._onComplete(r);}),r.play(e),r}refresh(){let i=this._instances.length;for(let t=0;t<i;t++)this._instances[t].refresh();}refreshPaused(){let i=this._instances.length;for(let t=0;t<i;t++)this._instances[t].refreshPaused();}get volume(){return this._volume}set volume(i){this._volume=i,this.refresh();}get muted(){return this._muted}set muted(i){this._muted=i,this.refresh();}get loop(){return this._loop}set loop(i){this._loop=i,this.refresh();}_preload(i){this.media.load(i);}get instances(){return this._instances}get sprites(){return this._sprites}get duration(){return this.media.duration}autoPlayStart(){let i;return this.autoPlay&&(i=this.play(this._autoPlayOptions)),i}_removeInstances(){for(let i=this._instances.length-1;i>=0;i--)this._poolInstance(this._instances[i]);this._instances.length=0;}_onComplete(i){if(this._instances){let t=this._instances.indexOf(i);t>-1&&this._instances.splice(t,1),this.isPlaying=this._instances.length>0;}this._poolInstance(i);}_createInstance(){if(ui._pool.length>0){let i=ui._pool.pop();return i.init(this.media),i}return this.media.create()}_poolInstance(i){i.destroy(),ui._pool.indexOf(i)<0&&ui._pool.push(i);}},Qe=ui;Qe._pool=[];var di=class i extends Cr{constructor(){let t=window,e=new i.AudioContext,r=e.createDynamicsCompressor(),s=e.createAnalyser();s.connect(r),r.connect(e.destination),super(s,r),this.autoPause=true,this._ctx=e,this._offlineCtx=new i.OfflineAudioContext(1,2,t.OfflineAudioContext?Math.max(8e3,Math.min(96e3,e.sampleRate)):44100),this.compressor=r,this.analyser=s,this.events=new Z,this.volume=1,this.speed=1,this.muted=false,this.paused=false,this._locked=e.state==="suspended"&&("ontouchstart"in globalThis||"onclick"in globalThis),this._locked&&(this._unlock(),this._unlock=this._unlock.bind(this),document.addEventListener("mousedown",this._unlock,true),document.addEventListener("touchstart",this._unlock,true),document.addEventListener("touchend",this._unlock,true)),this.onFocus=this.onFocus.bind(this),this.onBlur=this.onBlur.bind(this),globalThis.addEventListener("focus",this.onFocus),globalThis.addEventListener("blur",this.onBlur);}onFocus(){if(!this.autoPause)return;let t=this._ctx.state;(t==="suspended"||t==="interrupted"||!this._locked)&&(this.paused=this._pausedOnBlur,this.refreshPaused());}onBlur(){this.autoPause&&(this._locked||(this._pausedOnBlur=this._paused,this.paused=true,this.refreshPaused()));}_unlock(){this._locked&&(this.playEmptySound(),this._ctx.state==="running"&&(document.removeEventListener("mousedown",this._unlock,true),document.removeEventListener("touchend",this._unlock,true),document.removeEventListener("touchstart",this._unlock,true),this._locked=false));}playEmptySound(){let t=this._ctx.createBufferSource();t.buffer=this._ctx.createBuffer(1,1,22050),t.connect(this._ctx.destination),t.start(0,0,0),t.context.state==="suspended"&&t.context.resume();}static get AudioContext(){let t=window;return t.AudioContext||t.webkitAudioContext||null}static get OfflineAudioContext(){let t=window;return t.OfflineAudioContext||t.webkitOfflineAudioContext||null}destroy(){super.destroy();let t=this._ctx;typeof t.close<"u"&&t.close(),globalThis.removeEventListener("focus",this.onFocus),globalThis.removeEventListener("blur",this.onBlur),this.events.removeAllListeners(),this.analyser.disconnect(),this.compressor.disconnect(),this.analyser=null,this.compressor=null,this.events=null,this._offlineCtx=null,this._ctx=null;}get audioContext(){return this._ctx}get offlineContext(){return this._offlineCtx}set paused(t){t&&this._ctx.state==="running"?this._ctx.suspend():!t&&this._ctx.state==="suspended"&&this._ctx.resume(),this._paused=t;}get paused(){return this._paused}refresh(){this.events.emit("refresh");}refreshPaused(){this.events.emit("refreshPaused");}toggleMute(){return this.muted=!this.muted,this.refresh(),this.muted}togglePause(){return this.paused=!this.paused,this.refreshPaused(),this._paused}decode(t,e){let r=o=>{e(new Error(o?.message||"Unable to decode file"));},s=this._offlineCtx.decodeAudioData(t,o=>{e(null,o);},r);s&&s.catch(r);}};var En=class{constructor(){this.init();}init(){return this.supported&&(this._webAudioContext=new di),this._htmlAudioContext=new Cs,this._sounds={},this.useLegacy=!this.supported,this}get context(){return this._context}get filtersAll(){return this.useLegacy?[]:this._context.filters}set filtersAll(t){this.useLegacy||(this._context.filters=t);}get supported(){return di.AudioContext!==null}add(t,e){if(typeof t=="object"){let o={};for(let n in t){let a=this._getOptions(t[n],e);o[n]=this.add(n,a);}return o}if(console.assert(!this._sounds[t],`Sound with alias ${t} already exists.`),e instanceof Qe)return this._sounds[t]=e,e;let r=this._getOptions(e),s=Qe.from(r);return this._sounds[t]=s,s}_getOptions(t,e){let r;return typeof t=="string"?r={url:t}:Array.isArray(t)?r={url:t}:t instanceof ArrayBuffer||t instanceof AudioBuffer||t instanceof HTMLAudioElement?r={source:t}:r=t,r={...r,...e||{}},r}get useLegacy(){return this._useLegacy}set useLegacy(t){this._useLegacy=t,this._context=!t&&this.supported?this._webAudioContext:this._htmlAudioContext;}get disableAutoPause(){return !this._webAudioContext.autoPause}set disableAutoPause(t){this._webAudioContext.autoPause=!t;}remove(t){return this.exists(t,true),this._sounds[t].destroy(),delete this._sounds[t],this}get volumeAll(){return this._context.volume}set volumeAll(t){this._context.volume=t,this._context.refresh();}get speedAll(){return this._context.speed}set speedAll(t){this._context.speed=t,this._context.refresh();}togglePauseAll(){return this._context.togglePause()}pauseAll(){return this._context.paused=true,this._context.refreshPaused(),this}resumeAll(){return this._context.paused=false,this._context.refreshPaused(),this}toggleMuteAll(){return this._context.toggleMute()}muteAll(){return this._context.muted=true,this._context.refresh(),this}unmuteAll(){return this._context.muted=false,this._context.refresh(),this}removeAll(){for(let t in this._sounds)this._sounds[t].destroy(),delete this._sounds[t];return this}stopAll(){for(let t in this._sounds)this._sounds[t].stop();return this}exists(t,e=false){let r=!!this._sounds[t];return e&&console.assert(r,`No sound matching alias '${t}'.`),r}isPlaying(){for(let t in this._sounds)if(this._sounds[t].isPlaying)return true;return false}find(t){return this.exists(t,true),this._sounds[t]}play(t,e){return this.find(t).play(e)}stop(t){return this.find(t).stop()}pause(t){return this.find(t).pause()}resume(t){return this.find(t).resume()}volume(t,e){let r=this.find(t);return e!==void 0&&(r.volume=e),r.volume}speed(t,e){let r=this.find(t);return e!==void 0&&(r.speed=e),r.speed}duration(t){return this.find(t).duration}close(){return this.removeAll(),this._sounds=null,this._webAudioContext&&(this._webAudioContext.destroy(),this._webAudioContext=null),this._htmlAudioContext&&(this._htmlAudioContext.destroy(),this._htmlAudioContext=null),this._context=null,this}};var ax=i=>{let t=i.src,e=i?.alias?.[0];return (!e||i.src===e)&&(e=$t.basename(t,$t.extname(t))),e},hx={extension:T.Asset,detection:{test:async()=>true,add:async i=>[...i,...Pr.filter(t=>Mr[t])],remove:async i=>i.filter(t=>i.includes(t))},loader:{name:"sound",extension:{type:[T.LoadParser],priority:zr.High},test(i){let t=$t.extname(i).slice(1);return !!Mr[t]||Tl.some(e=>i.startsWith(`data:${e}`))},async load(i,t){let e=await new Promise((r,s)=>Qe.from({...t.data,url:i,preload:true,loaded(o,n){o?s(o):r(n),t.data?.loaded?.(o,n);}}));return rt().add(ax(t),e),e},async unload(i,t){rt().remove(ax(t));}}};O.add(hx);Ol(new En);({DistortionFilter:be.DistortionFilter,EqualizerFilter:be.EqualizerFilter,MonoFilter:be.MonoFilter,ReverbFilter:be.ReverbFilter,StereoFilter:be.StereoFilter,StreamFilter:be.StreamFilter,TelephoneFilter:be.TelephoneFilter});var lx={CHARACTER_CATEGORY_KEY:"___character___"};var at;(s=>(s.log=(o,...n)=>console.log(`[Pixi\u2019VN] ${o}`,...n),s.warn=(o,...n)=>console.warn(`[Pixi\u2019VN] ${o}`,...n),s.error=(o,...n)=>console.error(`[Pixi\u2019VN] ${o}`,...n),s.info=(o,...n)=>console.info(`[Pixi\u2019VN] ${o}`,...n)))(at||(at={}));var z=class z{static init(t){z._getStepCounter=t.getStepCounter,z._setStepCounter=t.setStepCounter,z._getCurrentGameStepState=t.getCurrentGameStepState,z._restoreGameStepState=t.restoreGameStepState,z._getOpenedLabels=t.getOpenedLabels,t.onGoNextEnd&&(z._onGoNextEnd=t.onGoNextEnd),z._getVariable=t.getVariable,z._setVariable=t.setVariable,z._removeVariable=t.removeVariable,z._getFlag=t.getFlag,z._setFlag=t.setFlag,t.onLabelClosing&&(z._onLabelClosing=t.onLabelClosing),z._addHistoryItem=t.addHistoryItem,z._getCurrentStepsRunningNumber=t.getCurrentStepsRunningNumber,z._getCharacter=t.getCharacter;}static get stepCounter(){return z._getStepCounter()}static set stepCounter(t){z._setStepCounter(t);}static get currentGameStepState(){return z._getCurrentGameStepState()}static get restoreGameStepState(){return z._restoreGameStepState}static get openedLabels(){return z._getOpenedLabels()}static get onGoNextEnd(){return z._onGoNextEnd}static get getVariable(){return z._getVariable}static get setVariable(){return z._setVariable}static get removeVariable(){return z._removeVariable}static get getFlag(){return z._getFlag}static get setFlag(){return z._setFlag}static get onLabelClosing(){return z._onLabelClosing}static get addHistoryItem(){return z._addHistoryItem}static get currentStepsRunningNumber(){return z._getCurrentStepsRunningNumber()}static get getCharacter(){return z._getCharacter}};G(z,"_getStepCounter",()=>{throw at.error("Method not implemented, you should initialize the Game: Game.init()"),new Error("Method not implemented, you should initialize the Game: Game.init()")}),G(z,"_setStepCounter",()=>{throw at.error("Method not implemented, you should initialize the Game: Game.init()"),new Error("Method not implemented, you should initialize the Game: Game.init()")}),G(z,"_getCurrentGameStepState",()=>{throw at.error("Method not implemented, you should initialize the Game: Game.init()"),new Error("Method not implemented, you should initialize the Game: Game.init()")}),G(z,"_restoreGameStepState",()=>{throw at.error("Method not implemented, you should initialize the Game: Game.init()"),new Error("Method not implemented, you should initialize the Game: Game.init()")}),G(z,"_getOpenedLabels",()=>{throw at.error("Method not implemented, you should initialize the Game: Game.init()"),new Error("Method not implemented, you should initialize the Game: Game.init()")}),G(z,"_onGoNextEnd",async()=>{}),G(z,"_getVariable",()=>{throw at.error("Method not implemented, you should initialize the Game: Game.init()"),new Error("Method not implemented, you should initialize the Game: Game.init()")}),G(z,"_setVariable",()=>{throw at.error("Method not implemented, you should initialize the Game: Game.init()"),new Error("Method not implemented, you should initialize the Game: Game.init()")}),G(z,"_removeVariable",()=>{throw at.error("Method not implemented, you should initialize the Game: Game.init()"),new Error("Method not implemented, you should initialize the Game: Game.init()")}),G(z,"_getFlag",()=>{throw at.error("Method not implemented, you should initialize the Game: Game.init()"),new Error("Method not implemented, you should initialize the Game: Game.init()")}),G(z,"_setFlag",()=>{throw at.error("Method not implemented, you should initialize the Game: Game.init()"),new Error("Method not implemented, you should initialize the Game: Game.init()")}),G(z,"_onLabelClosing",()=>{}),G(z,"_addHistoryItem",()=>{throw at.error("Method not implemented, you should initialize the Game: Game.init()"),new Error("Method not implemented, you should initialize the Game: Game.init()")}),G(z,"_getCurrentStepsRunningNumber",()=>{throw at.error("Method not implemented, you should initialize the Game: Game.init()"),new Error("Method not implemented, you should initialize the Game: Game.init()")}),G(z,"_getCharacter",()=>{throw at.error("Method not implemented, you should initialize the Game: Game.init()"),new Error("Method not implemented.")}),G(z,"onEnd"),G(z,"onError");function Fn(i){try{if(typeof i>"u")return i;let t=JSON.stringify(i);return JSON.parse(t)}catch(t){throw at.error("Error creating exportable element",i,t),new Error("[Pixi\u2019VN] Error creating exportable element")}}var fi=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,fx=new Set,wl=typeof process=="object"&&process?process:{},px=(i,t,e,r)=>{typeof wl.emitWarning=="function"?wl.emitWarning(i,t,e,r):console.error(`[${e}] ${t}: ${i}`);},Gn=globalThis.AbortController,cx=globalThis.AbortSignal;if(typeof Gn>"u"){cx=class{constructor(){G(this,"onabort");G(this,"_onabort",[]);G(this,"reason");G(this,"aborted",false);}addEventListener(r,s){this._onabort.push(s);}},Gn=class{constructor(){G(this,"signal",new cx);t();}abort(r){if(!this.signal.aborted){this.signal.reason=r,this.signal.aborted=true;for(let s of this.signal._onabort)s(r);this.signal.onabort?.(r);}}};let i=wl.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",t=()=>{i&&(i=false,px("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 $y=i=>!fx.has(i),Je=i=>i&&i===Math.floor(i)&&i>0&&isFinite(i),mx=i=>Je(i)?i<=Math.pow(2,8)?Uint8Array:i<=Math.pow(2,16)?Uint16Array:i<=Math.pow(2,32)?Uint32Array:i<=Number.MAX_SAFE_INTEGER?pi:null:null,pi=class extends Array{constructor(t){super(t),this.fill(0);}},mi,Er=class Er{constructor(t,e){G(this,"heap");G(this,"length");if(!x(Er,mi))throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new e(t),this.length=0;}static create(t){let e=mx(t);if(!e)return [];U(Er,mi,true);let r=new Er(t,e);return U(Er,mi,false),r}push(t){this.heap[this.length++]=t;}pop(){return this.heap[--this.length]}};mi=new WeakMap,q(Er,mi,false);var Pl=Er,ux,dx,de,Qt,fe,Fr,pe,gi,xi,Pt,me,yt,lt,H,Wt,Jt,Rt,Ct,ge,At,xe,_e,te,ye,ir,Vt,_i,C,Ml,Br,We,Gs,ee,gx,kr,yi,Rs,tr,er,Cl,Bn,kn,ht,Al,ks,rr,El,Fl=class Fl{constructor(t){q(this,C);q(this,de);q(this,Qt);q(this,fe);q(this,Fr);q(this,pe);q(this,gi);q(this,xi);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");q(this,Pt);q(this,me);q(this,yt);q(this,lt);q(this,H);q(this,Wt);q(this,Jt);q(this,Rt);q(this,Ct);q(this,ge);q(this,At);q(this,xe);q(this,_e);q(this,te);q(this,ye);q(this,ir);q(this,Vt);q(this,_i);q(this,Br,()=>{});q(this,We,()=>{});q(this,Gs,()=>{});q(this,ee,()=>false);q(this,kr,t=>{});q(this,yi,(t,e,r)=>{});q(this,Rs,(t,e,r,s)=>{if(r||s)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0});G(this,ux,"LRUCache");let{max:e=0,ttl:r,ttlResolution:s=1,ttlAutopurge:o,updateAgeOnGet:n,updateAgeOnHas:a,allowStale:h,dispose:l,onInsert:c,disposeAfter:u,noDisposeOnSet:f,noUpdateTTL:d,maxSize:g=0,maxEntrySize:_=0,sizeCalculation:m,fetchMethod:y,memoMethod:b,noDeleteOnFetchRejection:v,noDeleteOnStaleGet:S,allowStaleOnFetchRejection:M,allowStaleOnFetchAbort:w,ignoreFetchAbort:P}=t;if(e!==0&&!Je(e))throw new TypeError("max option must be a nonnegative integer");let W=e?mx(e):Array;if(!W)throw new Error("invalid max value: "+e);if(U(this,de,e),U(this,Qt,g),this.maxEntrySize=_||x(this,Qt),this.sizeCalculation=m,this.sizeCalculation){if(!x(this,Qt)&&!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(b!==void 0&&typeof b!="function")throw new TypeError("memoMethod must be a function if defined");if(U(this,xi,b),y!==void 0&&typeof y!="function")throw new TypeError("fetchMethod must be a function if specified");if(U(this,gi,y),U(this,ir,!!y),U(this,yt,new Map),U(this,lt,new Array(e).fill(void 0)),U(this,H,new Array(e).fill(void 0)),U(this,Wt,new W(e)),U(this,Jt,new W(e)),U(this,Rt,0),U(this,Ct,0),U(this,ge,Pl.create(e)),U(this,Pt,0),U(this,me,0),typeof l=="function"&&U(this,fe,l),typeof c=="function"&&U(this,Fr,c),typeof u=="function"?(U(this,pe,u),U(this,At,[])):(U(this,pe,void 0),U(this,At,void 0)),U(this,ye,!!x(this,fe)),U(this,_i,!!x(this,Fr)),U(this,Vt,!!x(this,pe)),this.noDisposeOnSet=!!f,this.noUpdateTTL=!!d,this.noDeleteOnFetchRejection=!!v,this.allowStaleOnFetchRejection=!!M,this.allowStaleOnFetchAbort=!!w,this.ignoreFetchAbort=!!P,this.maxEntrySize!==0){if(x(this,Qt)!==0&&!Je(x(this,Qt)))throw new TypeError("maxSize must be a positive integer if specified");if(!Je(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");k(this,C,gx).call(this);}if(this.allowStale=!!h,this.noDeleteOnStaleGet=!!S,this.updateAgeOnGet=!!n,this.updateAgeOnHas=!!a,this.ttlResolution=Je(s)||s===0?s:1,this.ttlAutopurge=!!o,this.ttl=r||0,this.ttl){if(!Je(this.ttl))throw new TypeError("ttl must be a positive integer if specified");k(this,C,Ml).call(this);}if(x(this,de)===0&&this.ttl===0&&x(this,Qt)===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!x(this,de)&&!x(this,Qt)){let A="LRU_CACHE_UNBOUNDED";$y(A)&&(fx.add(A),px("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",A,Fl));}}static unsafeExposeInternals(t){return {starts:x(t,_e),ttls:x(t,te),sizes:x(t,xe),keyMap:x(t,yt),keyList:x(t,lt),valList:x(t,H),next:x(t,Wt),prev:x(t,Jt),get head(){return x(t,Rt)},get tail(){return x(t,Ct)},free:x(t,ge),isBackgroundFetch:e=>{var r;return k(r=t,C,ht).call(r,e)},backgroundFetch:(e,r,s,o)=>{var n;return k(n=t,C,kn).call(n,e,r,s,o)},moveToTail:e=>{var r;return k(r=t,C,ks).call(r,e)},indexes:e=>{var r;return k(r=t,C,tr).call(r,e)},rindexes:e=>{var r;return k(r=t,C,er).call(r,e)},isStale:e=>{var r;return x(r=t,ee).call(r,e)}}}get max(){return x(this,de)}get maxSize(){return x(this,Qt)}get calculatedSize(){return x(this,me)}get size(){return x(this,Pt)}get fetchMethod(){return x(this,gi)}get memoMethod(){return x(this,xi)}get dispose(){return x(this,fe)}get onInsert(){return x(this,Fr)}get disposeAfter(){return x(this,pe)}getRemainingTTL(t){return x(this,yt).has(t)?1/0:0}*entries(){for(let t of k(this,C,tr).call(this))x(this,H)[t]!==void 0&&x(this,lt)[t]!==void 0&&!k(this,C,ht).call(this,x(this,H)[t])&&(yield [x(this,lt)[t],x(this,H)[t]]);}*rentries(){for(let t of k(this,C,er).call(this))x(this,H)[t]!==void 0&&x(this,lt)[t]!==void 0&&!k(this,C,ht).call(this,x(this,H)[t])&&(yield [x(this,lt)[t],x(this,H)[t]]);}*keys(){for(let t of k(this,C,tr).call(this)){let e=x(this,lt)[t];e!==void 0&&!k(this,C,ht).call(this,x(this,H)[t])&&(yield e);}}*rkeys(){for(let t of k(this,C,er).call(this)){let e=x(this,lt)[t];e!==void 0&&!k(this,C,ht).call(this,x(this,H)[t])&&(yield e);}}*values(){for(let t of k(this,C,tr).call(this))x(this,H)[t]!==void 0&&!k(this,C,ht).call(this,x(this,H)[t])&&(yield x(this,H)[t]);}*rvalues(){for(let t of k(this,C,er).call(this))x(this,H)[t]!==void 0&&!k(this,C,ht).call(this,x(this,H)[t])&&(yield x(this,H)[t]);}[(dx=Symbol.iterator,ux=Symbol.toStringTag,dx)](){return this.entries()}find(t,e={}){for(let r of k(this,C,tr).call(this)){let s=x(this,H)[r],o=k(this,C,ht).call(this,s)?s.__staleWhileFetching:s;if(o!==void 0&&t(o,x(this,lt)[r],this))return this.get(x(this,lt)[r],e)}}forEach(t,e=this){for(let r of k(this,C,tr).call(this)){let s=x(this,H)[r],o=k(this,C,ht).call(this,s)?s.__staleWhileFetching:s;o!==void 0&&t.call(e,o,x(this,lt)[r],this);}}rforEach(t,e=this){for(let r of k(this,C,er).call(this)){let s=x(this,H)[r],o=k(this,C,ht).call(this,s)?s.__staleWhileFetching:s;o!==void 0&&t.call(e,o,x(this,lt)[r],this);}}purgeStale(){let t=false;for(let e of k(this,C,er).call(this,{allowStale:true}))x(this,ee).call(this,e)&&(k(this,C,rr).call(this,x(this,lt)[e],"expire"),t=true);return t}info(t){let e=x(this,yt).get(t);if(e===void 0)return;let r=x(this,H)[e],s=k(this,C,ht).call(this,r)?r.__staleWhileFetching:r;if(s===void 0)return;let o={value:s};if(x(this,te)&&x(this,_e)){let n=x(this,te)[e],a=x(this,_e)[e];if(n&&a){let h=n-(fi.now()-a);o.ttl=h,o.start=Date.now();}}return x(this,xe)&&(o.size=x(this,xe)[e]),o}dump(){let t=[];for(let e of k(this,C,tr).call(this,{allowStale:true})){let r=x(this,lt)[e],s=x(this,H)[e],o=k(this,C,ht).call(this,s)?s.__staleWhileFetching:s;if(o===void 0||r===void 0)continue;let n={value:o};if(x(this,te)&&x(this,_e)){n.ttl=x(this,te)[e];let a=fi.now()-x(this,_e)[e];n.start=Math.floor(Date.now()-a);}x(this,xe)&&(n.size=x(this,xe)[e]),t.unshift([r,n]);}return t}load(t){this.clear();for(let[e,r]of t){if(r.start){let s=Date.now()-r.start;r.start=fi.now()-s;}this.set(e,r.value,r);}}set(t,e,r={}){var f,d,g,_;if(e===void 0)return this.delete(t),this;let{ttl:s=this.ttl,start:o,noDisposeOnSet:n=this.noDisposeOnSet,sizeCalculation:a=this.sizeCalculation,status:h}=r,{noUpdateTTL:l=this.noUpdateTTL}=r,c=x(this,Rs).call(this,t,e,r.size||0,a);if(this.maxEntrySize&&c>this.maxEntrySize)return h&&(h.set="miss",h.maxEntrySizeExceeded=true),k(this,C,rr).call(this,t,"set"),this;let u=x(this,Pt)===0?void 0:x(this,yt).get(t);if(u===void 0)u=x(this,Pt)===0?x(this,Ct):x(this,ge).length!==0?x(this,ge).pop():x(this,Pt)===x(this,de)?k(this,C,Bn).call(this,false):x(this,Pt),x(this,lt)[u]=t,x(this,H)[u]=e,x(this,yt).set(t,u),x(this,Wt)[x(this,Ct)]=u,x(this,Jt)[u]=x(this,Ct),U(this,Ct,u),Ws(this,Pt)._++,x(this,yi).call(this,u,c,h),h&&(h.set="add"),l=false,x(this,_i)&&((f=x(this,Fr))==null||f.call(this,e,t,"add"));else {k(this,C,ks).call(this,u);let m=x(this,H)[u];if(e!==m){if(x(this,ir)&&k(this,C,ht).call(this,m)){m.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:y}=m;y!==void 0&&!n&&(x(this,ye)&&((d=x(this,fe))==null||d.call(this,y,t,"set")),x(this,Vt)&&x(this,At)?.push([y,t,"set"]));}else n||(x(this,ye)&&((g=x(this,fe))==null||g.call(this,m,t,"set")),x(this,Vt)&&x(this,At)?.push([m,t,"set"]));if(x(this,kr).call(this,u),x(this,yi).call(this,u,c,h),x(this,H)[u]=e,h){h.set="replace";let y=m&&k(this,C,ht).call(this,m)?m.__staleWhileFetching:m;y!==void 0&&(h.oldValue=y);}}else h&&(h.set="update");x(this,_i)&&this.onInsert?.(e,t,e===m?"update":"replace");}if(s!==0&&!x(this,te)&&k(this,C,Ml).call(this),x(this,te)&&(l||x(this,Gs).call(this,u,s,o),h&&x(this,We).call(this,h,u)),!n&&x(this,Vt)&&x(this,At)){let m=x(this,At),y;for(;y=m?.shift();)(_=x(this,pe))==null||_.call(this,...y);}return this}pop(){var t;try{for(;x(this,Pt);){let e=x(this,H)[x(this,Rt)];if(k(this,C,Bn).call(this,!0),k(this,C,ht).call(this,e)){if(e.__staleWhileFetching)return e.__staleWhileFetching}else if(e!==void 0)return e}}finally{if(x(this,Vt)&&x(this,At)){let e=x(this,At),r;for(;r=e?.shift();)(t=x(this,pe))==null||t.call(this,...r);}}}has(t,e={}){let{updateAgeOnHas:r=this.updateAgeOnHas,status:s}=e,o=x(this,yt).get(t);if(o!==void 0){let n=x(this,H)[o];if(k(this,C,ht).call(this,n)&&n.__staleWhileFetching===void 0)return false;if(x(this,ee).call(this,o))s&&(s.has="stale",x(this,We).call(this,s,o));else return r&&x(this,Br).call(this,o),s&&(s.has="hit",x(this,We).call(this,s,o)),true}else s&&(s.has="miss");return false}peek(t,e={}){let{allowStale:r=this.allowStale}=e,s=x(this,yt).get(t);if(s===void 0||!r&&x(this,ee).call(this,s))return;let o=x(this,H)[s];return k(this,C,ht).call(this,o)?o.__staleWhileFetching:o}async fetch(t,e={}){let{allowStale:r=this.allowStale,updateAgeOnGet:s=this.updateAgeOnGet,noDeleteOnStaleGet:o=this.noDeleteOnStaleGet,ttl:n=this.ttl,noDisposeOnSet:a=this.noDisposeOnSet,size:h=0,sizeCalculation:l=this.sizeCalculation,noUpdateTTL:c=this.noUpdateTTL,noDeleteOnFetchRejection:u=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:f=this.allowStaleOnFetchRejection,ignoreFetchAbort:d=this.ignoreFetchAbort,allowStaleOnFetchAbort:g=this.allowStaleOnFetchAbort,context:_,forceRefresh:m=false,status:y,signal:b}=e;if(!x(this,ir))return y&&(y.fetch="get"),this.get(t,{allowStale:r,updateAgeOnGet:s,noDeleteOnStaleGet:o,status:y});let v={allowStale:r,updateAgeOnGet:s,noDeleteOnStaleGet:o,ttl:n,noDisposeOnSet:a,size:h,sizeCalculation:l,noUpdateTTL:c,noDeleteOnFetchRejection:u,allowStaleOnFetchRejection:f,allowStaleOnFetchAbort:g,ignoreFetchAbort:d,status:y,signal:b},S=x(this,yt).get(t);if(S===void 0){y&&(y.fetch="miss");let M=k(this,C,kn).call(this,t,S,v,_);return M.__returned=M}else {let M=x(this,H)[S];if(k(this,C,ht).call(this,M)){let E=r&&M.__staleWhileFetching!==void 0;return y&&(y.fetch="inflight",E&&(y.returnedStale=true)),E?M.__staleWhileFetching:M.__returned=M}let w=x(this,ee).call(this,S);if(!m&&!w)return y&&(y.fetch="hit"),k(this,C,ks).call(this,S),s&&x(this,Br).call(this,S),y&&x(this,We).call(this,y,S),M;let P=k(this,C,kn).call(this,t,S,v,_),A=P.__staleWhileFetching!==void 0&&r;return y&&(y.fetch=w?"stale":"refresh",A&&w&&(y.returnedStale=true)),A?P.__staleWhileFetching:P.__returned=P}}async forceFetch(t,e={}){let r=await this.fetch(t,e);if(r===void 0)throw new Error("fetch() returned undefined");return r}memo(t,e={}){let r=x(this,xi);if(!r)throw new Error("no memoMethod provided to constructor");let{context:s,forceRefresh:o,...n}=e,a=this.get(t,n);if(!o&&a!==void 0)return a;let h=r(t,a,{options:n,context:s});return this.set(t,h,n),h}get(t,e={}){let{allowStale:r=this.allowStale,updateAgeOnGet:s=this.updateAgeOnGet,noDeleteOnStaleGet:o=this.noDeleteOnStaleGet,status:n}=e,a=x(this,yt).get(t);if(a!==void 0){let h=x(this,H)[a],l=k(this,C,ht).call(this,h);return n&&x(this,We).call(this,n,a),x(this,ee).call(this,a)?(n&&(n.get="stale"),l?(n&&r&&h.__staleWhileFetching!==void 0&&(n.returnedStale=true),r?h.__staleWhileFetching:void 0):(o||k(this,C,rr).call(this,t,"expire"),n&&r&&(n.returnedStale=true),r?h:void 0)):(n&&(n.get="hit"),l?h.__staleWhileFetching:(k(this,C,ks).call(this,a),s&&x(this,Br).call(this,a),h))}else n&&(n.get="miss");}delete(t){return k(this,C,rr).call(this,t,"delete")}clear(){return k(this,C,El).call(this,"delete")}};de=new WeakMap,Qt=new WeakMap,fe=new WeakMap,Fr=new WeakMap,pe=new WeakMap,gi=new WeakMap,xi=new WeakMap,Pt=new WeakMap,me=new WeakMap,yt=new WeakMap,lt=new WeakMap,H=new WeakMap,Wt=new WeakMap,Jt=new WeakMap,Rt=new WeakMap,Ct=new WeakMap,ge=new WeakMap,At=new WeakMap,xe=new WeakMap,_e=new WeakMap,te=new WeakMap,ye=new WeakMap,ir=new WeakMap,Vt=new WeakMap,_i=new WeakMap,C=new WeakSet,Ml=function(){let t=new pi(x(this,de)),e=new pi(x(this,de));U(this,te,t),U(this,_e,e),U(this,Gs,(o,n,a=fi.now())=>{if(e[o]=n!==0?a:0,t[o]=n,n!==0&&this.ttlAutopurge){let h=setTimeout(()=>{x(this,ee).call(this,o)&&k(this,C,rr).call(this,x(this,lt)[o],"expire");},n+1);h.unref&&h.unref();}}),U(this,Br,o=>{e[o]=t[o]!==0?fi.now():0;}),U(this,We,(o,n)=>{if(t[n]){let a=t[n],h=e[n];if(!a||!h)return;o.ttl=a,o.start=h,o.now=r||s();let l=o.now-h;o.remainingTTL=a-l;}});let r=0,s=()=>{let o=fi.now();if(this.ttlResolution>0){r=o;let n=setTimeout(()=>r=0,this.ttlResolution);n.unref&&n.unref();}return o};this.getRemainingTTL=o=>{let n=x(this,yt).get(o);if(n===void 0)return 0;let a=t[n],h=e[n];if(!a||!h)return 1/0;let l=(r||s())-h;return a-l},U(this,ee,o=>{let n=e[o],a=t[o];return !!a&&!!n&&(r||s())-n>a});},Br=new WeakMap,We=new WeakMap,Gs=new WeakMap,ee=new WeakMap,gx=function(){let t=new pi(x(this,de));U(this,me,0),U(this,xe,t),U(this,kr,e=>{U(this,me,x(this,me)-t[e]),t[e]=0;}),U(this,Rs,(e,r,s,o)=>{if(k(this,C,ht).call(this,r))return 0;if(!Je(s))if(o){if(typeof o!="function")throw new TypeError("sizeCalculation must be a function");if(s=o(r,e),!Je(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}),U(this,yi,(e,r,s)=>{if(t[e]=r,x(this,Qt)){let o=x(this,Qt)-t[e];for(;x(this,me)>o;)k(this,C,Bn).call(this,true);}U(this,me,x(this,me)+t[e]),s&&(s.entrySize=r,s.totalCalculatedSize=x(this,me));});},kr=new WeakMap,yi=new WeakMap,Rs=new WeakMap,tr=function*({allowStale:t=this.allowStale}={}){if(x(this,Pt))for(let e=x(this,Ct);!(!k(this,C,Cl).call(this,e)||((t||!x(this,ee).call(this,e))&&(yield e),e===x(this,Rt)));)e=x(this,Jt)[e];},er=function*({allowStale:t=this.allowStale}={}){if(x(this,Pt))for(let e=x(this,Rt);!(!k(this,C,Cl).call(this,e)||((t||!x(this,ee).call(this,e))&&(yield e),e===x(this,Ct)));)e=x(this,Wt)[e];},Cl=function(t){return t!==void 0&&x(this,yt).get(x(this,lt)[t])===t},Bn=function(t){var o;let e=x(this,Rt),r=x(this,lt)[e],s=x(this,H)[e];return x(this,ir)&&k(this,C,ht).call(this,s)?s.__abortController.abort(new Error("evicted")):(x(this,ye)||x(this,Vt))&&(x(this,ye)&&((o=x(this,fe))==null||o.call(this,s,r,"evict")),x(this,Vt)&&x(this,At)?.push([s,r,"evict"])),x(this,kr).call(this,e),t&&(x(this,lt)[e]=void 0,x(this,H)[e]=void 0,x(this,ge).push(e)),x(this,Pt)===1?(U(this,Rt,U(this,Ct,0)),x(this,ge).length=0):U(this,Rt,x(this,Wt)[e]),x(this,yt).delete(r),Ws(this,Pt)._--,e},kn=function(t,e,r,s){let o=e===void 0?void 0:x(this,H)[e];if(k(this,C,ht).call(this,o))return o;let n=new Gn,{signal:a}=r;a?.addEventListener("abort",()=>n.abort(a.reason),{signal:n.signal});let h={signal:n.signal,options:r,context:s},l=(_,m=false)=>{let{aborted:y}=n.signal,b=r.ignoreFetchAbort&&_!==void 0;if(r.status&&(y&&!m?(r.status.fetchAborted=true,r.status.fetchError=n.signal.reason,b&&(r.status.fetchAbortIgnored=true)):r.status.fetchResolved=true),y&&!b&&!m)return u(n.signal.reason);let v=d;return x(this,H)[e]===d&&(_===void 0?v.__staleWhileFetching?x(this,H)[e]=v.__staleWhileFetching:k(this,C,rr).call(this,t,"fetch"):(r.status&&(r.status.fetchUpdated=true),this.set(t,_,h.options))),_},c=_=>(r.status&&(r.status.fetchRejected=true,r.status.fetchError=_),u(_)),u=_=>{let{aborted:m}=n.signal,y=m&&r.allowStaleOnFetchAbort,b=y||r.allowStaleOnFetchRejection,v=b||r.noDeleteOnFetchRejection,S=d;if(x(this,H)[e]===d&&(!v||S.__staleWhileFetching===void 0?k(this,C,rr).call(this,t,"fetch"):y||(x(this,H)[e]=S.__staleWhileFetching)),b)return r.status&&S.__staleWhileFetching!==void 0&&(r.status.returnedStale=true),S.__staleWhileFetching;if(S.__returned===S)throw _},f=(_,m)=>{var b;let y=(b=x(this,gi))==null?void 0:b.call(this,t,o,h);y&&y instanceof Promise&&y.then(v=>_(v===void 0?void 0:v),m),n.signal.addEventListener("abort",()=>{(!r.ignoreFetchAbort||r.allowStaleOnFetchAbort)&&(_(void 0),r.allowStaleOnFetchAbort&&(_=v=>l(v,true)));});};r.status&&(r.status.fetchDispatched=true);let d=new Promise(f).then(l,c),g=Object.assign(d,{__abortController:n,__staleWhileFetching:o,__returned:void 0});return e===void 0?(this.set(t,g,{...h.options,status:void 0}),e=x(this,yt).get(t)):x(this,H)[e]=g,g},ht=function(t){if(!x(this,ir))return false;let e=t;return !!e&&e instanceof Promise&&e.hasOwnProperty("__staleWhileFetching")&&e.__abortController instanceof Gn},Al=function(t,e){x(this,Jt)[e]=t,x(this,Wt)[t]=e;},ks=function(t){t!==x(this,Ct)&&(t===x(this,Rt)?U(this,Rt,x(this,Wt)[t]):k(this,C,Al).call(this,x(this,Jt)[t],x(this,Wt)[t]),k(this,C,Al).call(this,x(this,Ct),t),U(this,Ct,t));},rr=function(t,e){var s,o;let r=false;if(x(this,Pt)!==0){let n=x(this,yt).get(t);if(n!==void 0)if(r=true,x(this,Pt)===1)k(this,C,El).call(this,e);else {x(this,kr).call(this,n);let a=x(this,H)[n];if(k(this,C,ht).call(this,a)?a.__abortController.abort(new Error("deleted")):(x(this,ye)||x(this,Vt))&&(x(this,ye)&&((s=x(this,fe))==null||s.call(this,a,t,e)),x(this,Vt)&&x(this,At)?.push([a,t,e])),x(this,yt).delete(t),x(this,lt)[n]=void 0,x(this,H)[n]=void 0,n===x(this,Ct))U(this,Ct,x(this,Jt)[n]);else if(n===x(this,Rt))U(this,Rt,x(this,Wt)[n]);else {let h=x(this,Jt)[n];x(this,Wt)[h]=x(this,Wt)[n];let l=x(this,Wt)[n];x(this,Jt)[l]=x(this,Jt)[n];}Ws(this,Pt)._--,x(this,ge).push(n);}}if(x(this,Vt)&&x(this,At)?.length){let n=x(this,At),a;for(;a=n?.shift();)(o=x(this,pe))==null||o.call(this,...a);}return r},El=function(t){var e,r;for(let s of k(this,C,er).call(this,{allowStale:true})){let o=x(this,H)[s];if(k(this,C,ht).call(this,o))o.__abortController.abort(new Error("deleted"));else {let n=x(this,lt)[s];x(this,ye)&&((e=x(this,fe))==null||e.call(this,o,n,t)),x(this,Vt)&&x(this,At)?.push([o,n,t]);}}if(x(this,yt).clear(),x(this,H).fill(void 0),x(this,lt).fill(void 0),x(this,te)&&x(this,_e)&&(x(this,te).fill(0),x(this,_e).fill(0)),x(this,xe)&&x(this,xe).fill(0),U(this,Rt,0),U(this,Ct,0),x(this,ge).length=0,U(this,me,0),U(this,Pt,0),x(this,Vt)&&x(this,At)){let s=x(this,At),o;for(;o=s?.shift();)(r=x(this,pe))==null||r.call(this,...o);}};var Rn=Fl;var sr=class{constructor(t){G(this,"cache");G(this,"map",new Map);this.cache=new Rn({max:t.cacheSize}),this.map=new Map;}get[Symbol.iterator](){return this.map[Symbol.iterator]}get[Symbol.toStringTag](){return this.map[Symbol.toStringTag]}clear(){return this.cache.clear(),this.map.clear()}delete(t){let e=this.map.delete(t);return e&&this.cache.delete(t),e}get forEach(){return this.map.forEach}get(t){let e=this.cache.get(t);return e||this.map.get(t)}has(t){return this.map.has(t)}set(t,e){return this.map.set(t,e),this.cache.set(t,e),this}get size(){return this.map.size}entries(){return this.map.entries()}keys(){return this.map.keys()}values(){return this.map.values()}};var bt=class bt{constructor(){}static clearOldTempVariables(t){bt.tempStorageDeadlines.forEach((e,r)=>{e>t&&(bt.tempStorage.delete(r),bt.tempStorageDeadlines.delete(r),bt.storage.cache.delete(r));});}static setVariable(t,e){let r=bt.tempStorage.has(t);e==null?(bt.storage.map.delete(t),!r&&bt.storage.cache.delete(t)):(bt.storage.map.set(t,e),!r&&bt.storage.cache.set(t,e));}static getVariable(t){let e=bt.storage.cache.get(t);return e===void 0&&(e=bt.tempStorage.get(t)),e===void 0&&(e=bt.storage.map.get(t)),Fn(e)}static removeVariable(t){bt.storage.delete(t);}static setFlag(t,e){if(e)this.flags.includes(t)||this.flags.push(t);else {let r=this.flags.indexOf(t);r>-1&&this.flags.splice(r,1);}}static getFlag(t){return this.flags.includes(t)}};G(bt,"storage",new sr({cacheSize:20})),G(bt,"startingStorage",[]),G(bt,"flags",Array()),G(bt,"tempStorage",new Map),G(bt,"tempStorageDeadlines",new Map);var N=bt;var bi=class{constructor(t,e){G(this,"_id");G(this,"categoryId");this.categoryId=t,this._id=e;}get id(){return this._id}setStorageProperty(t,e){let r=N.getVariable(this.categoryId);r||(r={}),r.hasOwnProperty(this.id)||(r[this.id]={}),e==null?r[this.id].hasOwnProperty(t)&&delete r[this.id][t]:r[this.id]={...r[this.id],[t]:e},Object.keys(r[this.id]).length===0&&delete r[this.id],N.setVariable(this.categoryId,r);}getStorageProperty(t,e=this.id){let r=N.getVariable(this.categoryId);if(r&&r.hasOwnProperty(e)&&r[e].hasOwnProperty(t))return r[e][t]}};var Xy="@",vi=class extends bi{constructor(e,r=""){super(lx.CHARACTER_CATEGORY_KEY,e+(r?Xy+r:""));G(this,"sourceId");this.sourceId=e;}getStorageProperty(e){let r=super.getStorageProperty(e);return r===void 0&&(r=super.getStorageProperty(e,this.sourceId)),r}};var In=class extends vi{constructor(e,r){super(typeof e=="string"?e:e.id,typeof e=="string"?"":e.emotion);G(this,"defaultName");G(this,"defaultSurname");G(this,"defaultAge");G(this,"_icon");G(this,"_color");this.defaultName=r.name,this.defaultSurname=r.surname,this.defaultAge=r.age,this._icon=r.icon,this._color=r.color;}get name(){return this.getStorageProperty("name")||this.defaultName||this.id}set name(e){this.setStorageProperty("name",e);}get surname(){return this.getStorageProperty("surname")||this.defaultSurname}set surname(e){this.setStorageProperty("surname",e);}get age(){return this.getStorageProperty("age")||this.defaultAge}set age(e){this.setStorageProperty("age",e);}get icon(){return this._icon}get color(){return this._color}};var Ds=new sr({cacheSize:10});function jy(i){return Si.add(i)}function Ky(i){return Si.get(i)}function qy(){return Si.values()}var Si;(s=>{function i(o){try{let n=Ds.get(o);if(!n){at.warn(`Character "${o}" not found, did you forget to register it with the RegisteredCharacters.add?`);return}return n}catch(n){at.error(`Error while getting Character "${o}"`,n);return}}s.get=i;function t(o){if(Array.isArray(o)){o.forEach(n=>t(n));return}Ds.get(o.id)&&at.info(`Character id "${o.id}" already exists, it will be overwritten`),Ds.set(o.id,o);}s.add=t;function e(){return Array.from(Ds.values())}s.values=e;function r(o){return Ds.has(o)}s.has=r;})(Si||(Si={}));var Zy=Si;exports.CharacterBaseModel=In;exports.CharacterStoredClass=vi;exports.RegisteredCharacters=Zy;exports.getAllCharacters=qy;exports.getCharacterById=Ky;exports.saveCharacter=jy;
|
|
569
|
+
`}};});var pl,ml,wn,Gg=p(()=>{nt();Ro();Eg();Oo();es();je();Ft();kg();wn=class extends Ae{constructor(){pl??(pl=jr({name:"tiling-sprite-shader",bits:[Ss,Fg,qr]})),ml??(ml=Kr({name:"tiling-sprite-shader",bits:[Ag,Bg,Zr]}));let t=new zt({uMapCoord:{value:new F,type:"mat3x3<f32>"},uClampFrame:{value:new Float32Array([0,0,1,1]),type:"vec4<f32>"},uClampOffset:{value:new Float32Array([0,0]),type:"vec2<f32>"},uTextureTransform:{value:new F,type:"mat3x3<f32>"},uSizeAnchor:{value:new Float32Array([100,100,.5,.5]),type:"vec4<f32>"}});super({glProgram:ml,gpuProgram:pl,resources:{localUniforms:new zt({uTransformMatrix:{value:new F,type:"mat3x3<f32>"},uColor:{value:new Float32Array([1,1,1,1]),type:"vec4<f32>"},uRound:{value:0,type:"f32"}}),tilingUniforms:t,uTexture:R.EMPTY.source,uSampler:R.EMPTY.source.style}});}updateUniforms(t,e,r,s,o,n){let a=this.resources.tilingUniforms,h=n.width,l=n.height,c=n.textureMatrix,u=a.uniforms.uTextureTransform;u.set(r.a*h/t,r.b*h/e,r.c*l/t,r.d*l/e,r.tx/t,r.ty/e),u.invert(),a.uniforms.uMapCoord=c.mapCoord,a.uniforms.uClampFrame=c.uClampFrame,a.uniforms.uClampOffset=c.uClampOffset,a.uniforms.uTextureTransform=u,a.uniforms.uSizeAnchor[0]=t,a.uniforms.uSizeAnchor[1]=e,a.uniforms.uSizeAnchor[2]=s,a.uniforms.uSizeAnchor[3]=o,n&&(this.resources.uTexture=n.source,this.resources.uSampler=n.source.style);}};});var Pn,Rg=p(()=>{Tn();Pn=class extends ci{constructor(){super({positions:new Float32Array([0,0,1,0,1,1,0,1]),uvs:new Float32Array([0,0,1,0,1,1,0,1]),indices:new Uint32Array([0,1,2,0,2,3])});}};});function Ig(i,t){let e=i.anchor.x,r=i.anchor.y;t[0]=-e*i.width,t[1]=-r*i.height,t[2]=(1-e)*i.width,t[3]=-r*i.height,t[4]=(1-e)*i.width,t[5]=(1-r)*i.height,t[6]=-e*i.width,t[7]=(1-r)*i.height;}var Dg=p(()=>{});function Lg(i,t,e,r){let s=0,o=i.length/(t),n=r.a,a=r.b,h=r.c,l=r.d,c=r.tx,u=r.ty;for(e*=t;s<o;){let f=i[e],d=i[e+1];i[e]=n*f+h*d+c,i[e+1]=a*f+l*d+u,e+=t,s++;}}var Ug=p(()=>{});function Og(i,t){let e=i.texture,r=e.frame.width,s=e.frame.height,o=0,n=0;i.applyAnchorToTexture&&(o=i.anchor.x,n=i.anchor.y),t[0]=t[6]=-o,t[2]=t[4]=1-o,t[1]=t[3]=-n,t[5]=t[7]=1-n;let a=F.shared;a.copyFrom(i._tileTransform.matrix),a.tx/=i.width,a.ty/=i.height,a.invert(),a.scale(i.width/r,i.height/s),Lg(t,2,0,a);}var zg=p(()=>{nt();Ug();});var Mn,gl,Ts,Wg=p(()=>{I();Zi();jo();ts();ns();Ko();Tn();Gg();Rg();Dg();zg();Mn=new Pn,gl=class{constructor(){this.canBatch=true,this.geometry=new ci({indices:Mn.indices.slice(),positions:Mn.positions.slice(),uvs:Mn.uvs.slice()});}destroy(){this.geometry.destroy(),this.shader?.destroy();}},Ts=class{constructor(t){this._state=vr.default2d,this._renderer=t;}validateRenderable(t){let e=this._getTilingSpriteData(t),r=e.canBatch;this._updateCanBatch(t);let s=e.canBatch;if(s&&s===r){let{batchableMesh:o}=e;return !o._batcher.checkAndUpdateTexture(o,t.texture)}return r!==s}addRenderable(t,e){let r=this._renderer.renderPipes.batch;this._updateCanBatch(t);let s=this._getTilingSpriteData(t),{geometry:o,canBatch:n}=s;if(n){s.batchableMesh||(s.batchableMesh=new qe);let a=s.batchableMesh;t.didViewUpdate&&(this._updateBatchableMesh(t),a.geometry=o,a.renderable=t,a.transform=t.groupTransform,a.setTexture(t._texture)),a.roundPixels=this._renderer._roundPixels|t._roundPixels,r.addToBatch(a,e);}else r.break(e),s.shader||(s.shader=new wn),this.updateRenderable(t),e.add(t);}execute(t){let{shader:e}=this._getTilingSpriteData(t);e.groups[0]=this._renderer.globalUniforms.bindGroup;let r=e.resources.localUniforms.uniforms;r.uTransformMatrix=t.groupTransform,r.uRound=this._renderer._roundPixels|t._roundPixels,Ke(t.groupColorAlpha,r.uColor,0),this._state.blendMode=Le(t.groupBlendMode,t.texture._source),this._renderer.encoder.draw({geometry:Mn,shader:e,state:this._state});}updateRenderable(t){let e=this._getTilingSpriteData(t),{canBatch:r}=e;if(r){let{batchableMesh:s}=e;t.didViewUpdate&&this._updateBatchableMesh(t),s._batcher.updateElement(s);}else if(t.didViewUpdate){let{shader:s}=e;s.updateUniforms(t.width,t.height,t._tileTransform.matrix,t.anchor.x,t.anchor.y,t.texture);}}_getTilingSpriteData(t){return t._gpuData[this._renderer.uid]||this._initTilingSpriteData(t)}_initTilingSpriteData(t){let e=new gl;return e.renderable=t,t._gpuData[this._renderer.uid]=e,e}_updateBatchableMesh(t){let e=this._getTilingSpriteData(t),{geometry:r}=e,s=t.texture.source.style;s.addressMode!=="repeat"&&(s.addressMode="repeat",s.update()),Og(t,r.uvs),Ig(t,r.positions);}destroy(){this._renderer=null;}_updateCanBatch(t){let e=this._getTilingSpriteData(t),r=t.texture,s=true;return this._renderer.type===Ce.WEBGL&&(s=this._renderer.context.supports.nonPowOf2wrapping),e.canBatch=r.textureMatrix.isSimple&&(s||r.source.isPowerOfTwo),e.canBatch}};Ts.extension={type:[T.WebGLPipes,T.WebGPUPipes,T.CanvasPipes],name:"tilingSprite"};});var xl=p(()=>{I();Wg();O.add(Ts);});var Vg,Hg,Yg=p(()=>{gt();Tn();Vg=class Ng extends ci{constructor(...t){super({});let e=t[0]??{};typeof e=="number"&&(L(X,"PlaneGeometry constructor changed please use { width, height, verticesX, verticesY } instead"),e={width:e,height:t[1],verticesX:t[2],verticesY:t[3]}),this.build(e);}build(t){t={...Ng.defaultOptions,...t},this.verticesX=this.verticesX??t.verticesX,this.verticesY=this.verticesY??t.verticesY,this.width=this.width??t.width,this.height=this.height??t.height;let e=this.verticesX*this.verticesY,r=[],s=[],o=[],n=this.verticesX-1,a=this.verticesY-1,h=this.width/n,l=this.height/a;for(let u=0;u<e;u++){let f=u%this.verticesX,d=u/this.verticesX|0;r.push(f*h,d*l),s.push(f/n,d/a);}let c=n*a;for(let u=0;u<c;u++){let f=u%n,d=u/n|0,g=d*this.verticesX+f,_=d*this.verticesX+f+1,m=(d+1)*this.verticesX+f,y=(d+1)*this.verticesX+f+1;o.push(g,_,m,_,y,m);}this.buffers[0].data=new Float32Array(r),this.buffers[1].data=new Float32Array(s),this.indexBuffer.data=new Uint32Array(o),this.buffers[0].update(),this.buffers[1].update(),this.indexBuffer.update();}};Vg.defaultOptions={width:100,height:100,verticesX:10,verticesY:10};Hg=Vg;});var $g,jg,Kg=p(()=>{Yg();$g=class Xg extends Hg{constructor(t={}){t={...Xg.defaultOptions,...t},super({width:t.width,height:t.height,verticesX:4,verticesY:4}),this.update(t);}update(t){this.width=t.width??this.width,this.height=t.height??this.height,this._originalWidth=t.originalWidth??this._originalWidth,this._originalHeight=t.originalHeight??this._originalHeight,this._leftWidth=t.leftWidth??this._leftWidth,this._rightWidth=t.rightWidth??this._rightWidth,this._topHeight=t.topHeight??this._topHeight,this._bottomHeight=t.bottomHeight??this._bottomHeight,this._anchorX=t.anchor?.x,this._anchorY=t.anchor?.y,this.updateUvs(),this.updatePositions();}updatePositions(){let t=this.positions,{width:e,height:r,_leftWidth:s,_rightWidth:o,_topHeight:n,_bottomHeight:a,_anchorX:h,_anchorY:l}=this,c=s+o,u=e>c?1:e/c,f=n+a,d=r>f?1:r/f,g=Math.min(u,d),_=h*e,m=l*r;t[0]=t[8]=t[16]=t[24]=-_,t[2]=t[10]=t[18]=t[26]=s*g-_,t[4]=t[12]=t[20]=t[28]=e-o*g-_,t[6]=t[14]=t[22]=t[30]=e-_,t[1]=t[3]=t[5]=t[7]=-m,t[9]=t[11]=t[13]=t[15]=n*g-m,t[17]=t[19]=t[21]=t[23]=r-a*g-m,t[25]=t[27]=t[29]=t[31]=r-m,this.getBuffer("aPosition").update();}updateUvs(){let t=this.uvs;t[0]=t[8]=t[16]=t[24]=0,t[1]=t[3]=t[5]=t[7]=0,t[6]=t[14]=t[22]=t[30]=1,t[25]=t[27]=t[29]=t[31]=1;let e=1/this._originalWidth,r=1/this._originalHeight;t[2]=t[10]=t[18]=t[26]=e*this._leftWidth,t[9]=t[11]=t[13]=t[15]=r*this._topHeight,t[4]=t[12]=t[20]=t[28]=1-e*this._rightWidth,t[17]=t[19]=t[21]=t[23]=1-r*this._bottomHeight,this.getBuffer("aUV").update();}};$g.defaultOptions={width:100,height:100,leftWidth:10,topHeight:10,rightWidth:10,bottomHeight:10,originalWidth:100,originalHeight:100};jg=$g;});var _l,ws,qg=p(()=>{I();Ko();Kg();_l=class extends qe{constructor(){super(),this.geometry=new jg;}destroy(){this.geometry.destroy();}},ws=class{constructor(t){this._renderer=t;}addRenderable(t,e){let r=this._getGpuSprite(t);t.didViewUpdate&&this._updateBatchableSprite(t,r),this._renderer.renderPipes.batch.addToBatch(r,e);}updateRenderable(t){let e=this._getGpuSprite(t);t.didViewUpdate&&this._updateBatchableSprite(t,e),e._batcher.updateElement(e);}validateRenderable(t){let e=this._getGpuSprite(t);return !e._batcher.checkAndUpdateTexture(e,t._texture)}_updateBatchableSprite(t,e){e.geometry.update(t),e.setTexture(t._texture);}_getGpuSprite(t){return t._gpuData[this._renderer.uid]||this._initGPUSprite(t)}_initGPUSprite(t){let e=t._gpuData[this._renderer.uid]=new _l,r=e;return r.renderable=t,r.transform=t.groupTransform,r.texture=t._texture,r.roundPixels=this._renderer._roundPixels|t._roundPixels,t.didViewUpdate||this._updateBatchableSprite(t,r),e}destroy(){this._renderer=null;}};ws.extension={type:[T.WebGLPipes,T.WebGPUPipes,T.CanvasPipes],name:"nineSliceSprite"};});var yl=p(()=>{I();qg();O.add(ws);});var Ps,Zg=p(()=>{I();Ps=class{constructor(t){this._renderer=t;}push(t,e,r){this._renderer.renderPipes.batch.break(r),r.add({renderPipeId:"filter",canBundle:false,action:"pushFilter",container:e,filterEffect:t});}pop(t,e,r){this._renderer.renderPipes.batch.break(r),r.add({renderPipeId:"filter",action:"popFilter",canBundle:false});}execute(t){t.action==="pushFilter"?this._renderer.filter.push(t):t.action==="popFilter"&&this._renderer.filter.pop();}destroy(){this._renderer=null;}};Ps.extension={type:[T.WebGLPipes,T.WebGPUPipes,T.CanvasPipes],name:"filter"};});function Qg(i,t){t.clear();let e=t.matrix;for(let r=0;r<i.length;r++){let s=i[r];s.globalDisplayStatus<7||(t.matrix=s.worldTransform,t.addBounds(s.bounds));}return t.matrix=e,t}var Jg=p(()=>{});var Uy,bl,Ms,tx=p(()=>{I();nt();qi();Ji();je();Ft();Dr();ts();he();Jg();Ut();Uy=new Me({attributes:{aPosition:{buffer:new Float32Array([0,0,1,0,1,1,0,1]),format:"float32x2",stride:2*4,offset:0}},indexBuffer:new Uint32Array([0,1,2,0,2,3])}),bl=class{constructor(){this.skip=false,this.inputTexture=null,this.backTexture=null,this.filters=null,this.bounds=new dt,this.container=null,this.blendRequired=false,this.outputRenderSurface=null,this.globalFrame={x:0,y:0,width:0,height:0};}},Ms=class{constructor(t){this._filterStackIndex=0,this._filterStack=[],this._filterGlobalUniforms=new zt({uInputSize:{value:new Float32Array(4),type:"vec4<f32>"},uInputPixel:{value:new Float32Array(4),type:"vec4<f32>"},uInputClamp:{value:new Float32Array(4),type:"vec4<f32>"},uOutputFrame:{value:new Float32Array(4),type:"vec4<f32>"},uGlobalFrame:{value:new Float32Array(4),type:"vec4<f32>"},uOutputTexture:{value:new Float32Array(4),type:"vec4<f32>"}}),this._globalFilterBindGroup=new oe({}),this.renderer=t;}get activeBackTexture(){return this._activeFilterData?.backTexture}push(t){let e=this.renderer,r=t.filterEffect.filters,s=this._pushFilterData();s.skip=false,s.filters=r,s.container=t.container,s.outputRenderSurface=e.renderTarget.renderSurface;let o=e.renderTarget.renderTarget.colorTexture.source,n=o.resolution,a=o.antialias;if(r.length===0){s.skip=true;return}let h=s.bounds;if(this._calculateFilterArea(t,h),this._calculateFilterBounds(s,e.renderTarget.rootViewPort,a,n,1),s.skip)return;let l=this._getPreviousFilterData(),c=this._findFilterResolution(n),u=0,f=0;l&&(u=l.bounds.minX,f=l.bounds.minY),this._calculateGlobalFrame(s,u,f,c,o.width,o.height),this._setupFilterTextures(s,h,e,l);}generateFilteredTexture({texture:t,filters:e}){let r=this._pushFilterData();this._activeFilterData=r,r.skip=false,r.filters=e;let s=t.source,o=s.resolution,n=s.antialias;if(e.length===0)return r.skip=true,t;let a=r.bounds;if(a.addRect(t.frame),this._calculateFilterBounds(r,a.rectangle,n,o,0),r.skip)return t;let h=o;this._calculateGlobalFrame(r,0,0,h,s.width,s.height),r.outputRenderSurface=Gt.getOptimalTexture(a.width,a.height,r.resolution,r.antialias),r.backTexture=R.EMPTY,r.inputTexture=t,this.renderer.renderTarget.finishRenderPass(),this._applyFiltersToTexture(r,true);let f=r.outputRenderSurface;return f.source.alphaMode="premultiplied-alpha",f}pop(){let t=this.renderer,e=this._popFilterData();e.skip||(t.globalUniforms.pop(),t.renderTarget.finishRenderPass(),this._activeFilterData=e,this._applyFiltersToTexture(e,false),e.blendRequired&&Gt.returnTexture(e.backTexture),Gt.returnTexture(e.inputTexture));}getBackTexture(t,e,r){let s=t.colorTexture.source._resolution,o=Gt.getOptimalTexture(e.width,e.height,s,false),n=e.minX,a=e.minY;r&&(n-=r.minX,a-=r.minY),n=Math.floor(n*s),a=Math.floor(a*s);let h=Math.ceil(e.width*s),l=Math.ceil(e.height*s);return this.renderer.renderTarget.copyToTexture(t,o,{x:n,y:a},{width:h,height:l},{x:0,y:0}),o}applyFilter(t,e,r,s){let o=this.renderer,n=this._activeFilterData,h=n.outputRenderSurface===r,l=o.renderTarget.rootRenderTarget.colorTexture.source._resolution,c=this._findFilterResolution(l),u=0,f=0;if(h){let d=this._findPreviousFilterOffset();u=d.x,f=d.y;}this._updateFilterUniforms(e,r,n,u,f,c,h,s),this._setupBindGroupsAndRender(t,e,o);}calculateSpriteMatrix(t,e){let r=this._activeFilterData,s=t.set(r.inputTexture._source.width,0,0,r.inputTexture._source.height,r.bounds.minX,r.bounds.minY),o=e.worldTransform.copyTo(F.shared),n=e.renderGroup||e.parentRenderGroup;return n&&n.cacheToLocalTransform&&o.prepend(n.cacheToLocalTransform),o.invert(),s.prepend(o),s.scale(1/e.texture.frame.width,1/e.texture.frame.height),s.translate(e.anchor.x,e.anchor.y),s}destroy(){}_setupBindGroupsAndRender(t,e,r){if(r.renderPipes.uniformBatch){let s=r.renderPipes.uniformBatch.getUboResource(this._filterGlobalUniforms);this._globalFilterBindGroup.setResource(s,0);}else this._globalFilterBindGroup.setResource(this._filterGlobalUniforms,0);this._globalFilterBindGroup.setResource(e.source,1),this._globalFilterBindGroup.setResource(e.source.style,2),t.groups[0]=this._globalFilterBindGroup,r.encoder.draw({geometry:Uy,shader:t,state:t._state,topology:"triangle-list"}),r.type===Ce.WEBGL&&r.renderTarget.finishRenderPass();}_setupFilterTextures(t,e,r,s){if(t.backTexture=R.EMPTY,t.blendRequired){r.renderTarget.finishRenderPass();let o=r.renderTarget.getRenderTarget(t.outputRenderSurface);t.backTexture=this.getBackTexture(o,e,s?.bounds);}t.inputTexture=Gt.getOptimalTexture(e.width,e.height,t.resolution,t.antialias),r.renderTarget.bind(t.inputTexture,true),r.globalUniforms.push({offset:e});}_calculateGlobalFrame(t,e,r,s,o,n){let a=t.globalFrame;a.x=e*s,a.y=r*s,a.width=o*s,a.height=n*s;}_updateFilterUniforms(t,e,r,s,o,n,a,h){let l=this._filterGlobalUniforms.uniforms,c=l.uOutputFrame,u=l.uInputSize,f=l.uInputPixel,d=l.uInputClamp,g=l.uGlobalFrame,_=l.uOutputTexture;a?(c[0]=r.bounds.minX-s,c[1]=r.bounds.minY-o):(c[0]=0,c[1]=0),c[2]=t.frame.width,c[3]=t.frame.height,u[0]=t.source.width,u[1]=t.source.height,u[2]=1/u[0],u[3]=1/u[1],f[0]=t.source.pixelWidth,f[1]=t.source.pixelHeight,f[2]=1/f[0],f[3]=1/f[1],d[0]=.5*f[2],d[1]=.5*f[3],d[2]=t.frame.width*u[2]-.5*f[2],d[3]=t.frame.height*u[3]-.5*f[3];let m=this.renderer.renderTarget.rootRenderTarget.colorTexture;g[0]=s*n,g[1]=o*n,g[2]=m.source.width*n,g[3]=m.source.height*n,e instanceof R&&(e.source.resource=null);let y=this.renderer.renderTarget.getRenderTarget(e);this.renderer.renderTarget.bind(e,!!h),e instanceof R?(_[0]=e.frame.width,_[1]=e.frame.height):(_[0]=y.width,_[1]=y.height),_[2]=y.isRoot?-1:1,this._filterGlobalUniforms.update();}_findFilterResolution(t){let e=this._filterStackIndex-1;for(;e>0&&this._filterStack[e].skip;)--e;return e>0&&this._filterStack[e].inputTexture?this._filterStack[e].inputTexture.source._resolution:t}_findPreviousFilterOffset(){let t=0,e=0,r=this._filterStackIndex;for(;r>0;){r--;let s=this._filterStack[r];if(!s.skip){t=s.bounds.minX,e=s.bounds.minY;break}}return {x:t,y:e}}_calculateFilterArea(t,e){if(t.renderables?Qg(t.renderables,e):t.filterEffect.filterArea?(e.clear(),e.addRect(t.filterEffect.filterArea),e.applyMatrix(t.container.worldTransform)):t.container.getFastGlobalBounds(true,e),t.container){let s=(t.container.renderGroup||t.container.parentRenderGroup).cacheToLocalTransform;s&&e.applyMatrix(s);}}_applyFiltersToTexture(t,e){let r=t.inputTexture,s=t.bounds,o=t.filters;if(this._globalFilterBindGroup.setResource(r.source.style,2),this._globalFilterBindGroup.setResource(t.backTexture.source,3),o.length===1)o[0].apply(this,r,t.outputRenderSurface,e);else {let n=t.inputTexture,a=Gt.getOptimalTexture(s.width,s.height,n.source._resolution,false),h=a,l=0;for(l=0;l<o.length-1;++l){o[l].apply(this,n,h,true);let u=n;n=h,h=u;}o[l].apply(this,n,t.outputRenderSurface,e),Gt.returnTexture(a);}}_calculateFilterBounds(t,e,r,s,o){let n=this.renderer,a=t.bounds,h=t.filters,l=1/0,c=0,u=true,f=false,d=false,g=true;for(let _=0;_<h.length;_++){let m=h[_];if(l=Math.min(l,m.resolution==="inherit"?s:m.resolution),c+=m.padding,m.antialias==="off"?u=false:m.antialias==="inherit"&&u&&(u=r),m.clipToViewport||(g=false),!!!(m.compatibleRenderers&n.type)){d=false;break}if(m.blendRequired&&!(n.backBuffer?.useBackBuffer??true)){j("Blend filter requires backBuffer on WebGL renderer to be enabled. Set `useBackBuffer: true` in the renderer options."),d=false;break}d=m.enabled||d,f||(f=m.blendRequired);}if(!d){t.skip=true;return}if(g&&a.fitBounds(0,e.width/s,0,e.height/s),a.scale(l).ceil().scale(1/l).pad((c|0)*o),!a.isPositive){t.skip=true;return}t.antialias=u,t.resolution=l,t.blendRequired=f;}_popFilterData(){return this._filterStackIndex--,this._filterStack[this._filterStackIndex]}_getPreviousFilterData(){let t,e=this._filterStackIndex-1;for(;e>1&&(e--,t=this._filterStack[e],!!t.skip););return t}_pushFilterData(){let t=this._filterStack[this._filterStackIndex];return t||(t=this._filterStack[this._filterStackIndex]=new bl),this._filterStackIndex++,t}};Ms.extension={type:[T.WebGLSystem,T.WebGPUSystem],name:"filter"};});var vl=p(()=>{I();Zg();tx();O.add(Ms);O.add(Ps);});var Oy={};var ex=p(()=>{vu();_a();Fu();ku();xo();To();Ah();Eh();Gh();il();cl();fl();xl();yl();vl();});var zy={};var ix=p(()=>{_a();xo();To();Ah();Eh();Gh();il();cl();fl();xl();yl();vl();});var be={};Mx(be,{DistortionFilter:()=>Vs,EqualizerFilter:()=>re,Filter:()=>vt,MonoFilter:()=>Ns,ReverbFilter:()=>Hs,StereoFilter:()=>Ys,StreamFilter:()=>$s,TelephoneFilter:()=>Xs});var Ul;function Ol(i){return Ul=i,i}function rt(){return Ul}var vt=class{constructor(t,e){this.init(t,e);}init(t,e){this.destination=t,this.source=e||t;}connect(t){this.source?.connect(t);}disconnect(){this.source?.disconnect();}destroy(){this.disconnect(),this.destination=null,this.source=null;}};var Vs=class extends vt{constructor(t=0){let e;if(!rt().useLegacy){let{audioContext:r}=rt().context;e=r.createWaveShaper();}super(e),this._distortion=e,this.amount=t;}set amount(t){if(this._amount=t,rt().useLegacy)return;let e=t*1e3,r=44100,s=new Float32Array(r),o=Math.PI/180,n=0,a;for(;n<r;++n)a=n*2/r-1,s[n]=(3+e)*a*20*o/(Math.PI+e*Math.abs(a));this._distortion.curve=s,this._distortion.oversample="4x";}get amount(){return this._amount}destroy(){this._distortion=null,super.destroy();}};var mt=class{static setParamValue(t,e){if(t.setValueAtTime){let r=rt().context;t.setValueAtTime(e,r.audioContext.currentTime);}else t.value=e;return e}};var it=class extends vt{constructor(i=0,t=0,e=0,r=0,s=0,o=0,n=0,a=0,h=0,l=0){let c=[],u=[{f:it.F32,type:"lowshelf",gain:i},{f:it.F64,type:"peaking",gain:t},{f:it.F125,type:"peaking",gain:e},{f:it.F250,type:"peaking",gain:r},{f:it.F500,type:"peaking",gain:s},{f:it.F1K,type:"peaking",gain:o},{f:it.F2K,type:"peaking",gain:n},{f:it.F4K,type:"peaking",gain:a},{f:it.F8K,type:"peaking",gain:h},{f:it.F16K,type:"highshelf",gain:l}];rt().useLegacy||(c=u.map(f=>{let d=rt().context.audioContext.createBiquadFilter();return d.type=f.type,mt.setParamValue(d.Q,1),d.frequency.value=f.f,mt.setParamValue(d.gain,f.gain),d})),super(c[0],c[c.length-1]),this.bands=c,this.bandsMap={};for(let f=0;f<this.bands.length;f++){let d=this.bands[f];f>0&&this.bands[f-1].connect(d),this.bandsMap[d.frequency.value]=d;}}setGain(i,t=0){if(!this.bandsMap[i])throw new Error(`No band found for frequency ${i}`);mt.setParamValue(this.bandsMap[i].gain,t);}getGain(i){if(!this.bandsMap[i])throw new Error(`No band found for frequency ${i}`);return this.bandsMap[i].gain.value}set f32(i){this.setGain(it.F32,i);}get f32(){return this.getGain(it.F32)}set f64(i){this.setGain(it.F64,i);}get f64(){return this.getGain(it.F64)}set f125(i){this.setGain(it.F125,i);}get f125(){return this.getGain(it.F125)}set f250(i){this.setGain(it.F250,i);}get f250(){return this.getGain(it.F250)}set f500(i){this.setGain(it.F500,i);}get f500(){return this.getGain(it.F500)}set f1k(i){this.setGain(it.F1K,i);}get f1k(){return this.getGain(it.F1K)}set f2k(i){this.setGain(it.F2K,i);}get f2k(){return this.getGain(it.F2K)}set f4k(i){this.setGain(it.F4K,i);}get f4k(){return this.getGain(it.F4K)}set f8k(i){this.setGain(it.F8K,i);}get f8k(){return this.getGain(it.F8K)}set f16k(i){this.setGain(it.F16K,i);}get f16k(){return this.getGain(it.F16K)}reset(){this.bands.forEach(i=>{mt.setParamValue(i.gain,0);});}destroy(){this.bands.forEach(i=>{i.disconnect();}),this.bands=null,this.bandsMap=null;}},re=it;re.F32=32;re.F64=64;re.F125=125;re.F250=250;re.F500=500;re.F1K=1e3;re.F2K=2e3;re.F4K=4e3;re.F8K=8e3;re.F16K=16e3;var Ns=class extends vt{constructor(){let t,e;if(!rt().useLegacy){let{audioContext:r}=rt().context;e=r.createChannelSplitter(),t=r.createChannelMerger(),t.connect(e);}super(t,e),this._merger=t;}destroy(){this._merger?.disconnect(),this._merger=null,super.destroy();}};var Hs=class extends vt{constructor(t=3,e=2,r=false){super(null),this._seconds=this._clamp(t,1,50),this._decay=this._clamp(e,0,100),this._reverse=r,this._rebuild();}_clamp(t,e,r){return Math.min(r,Math.max(e,t))}get seconds(){return this._seconds}set seconds(t){this._seconds=this._clamp(t,1,50),this._rebuild();}get decay(){return this._decay}set decay(t){this._decay=this._clamp(t,0,100),this._rebuild();}get reverse(){return this._reverse}set reverse(t){this._reverse=t,this._rebuild();}_rebuild(){if(rt().useLegacy)return;let{audioContext:t}=rt().context,e=t.sampleRate,r=e*this._seconds,s=t.createBuffer(2,r,e),o=s.getChannelData(0),n=s.getChannelData(1),a;for(let l=0;l<r;l++)a=this._reverse?r-l:l,o[l]=(Math.random()*2-1)*Math.pow(1-a/r,this._decay),n[l]=(Math.random()*2-1)*Math.pow(1-a/r,this._decay);let h=t.createConvolver();h.buffer=s,this.init(h);}};var Ys=class extends vt{constructor(t=0){let e,r,s;if(!rt().useLegacy){let{audioContext:o}=rt().context;o.createStereoPanner?(e=o.createStereoPanner(),s=e):(r=o.createPanner(),r.panningModel="equalpower",s=r);}super(s),this._stereo=e,this._panner=r,this.pan=t;}set pan(t){this._pan=t,this._stereo?mt.setParamValue(this._stereo.pan,t):this._panner&&this._panner.setPosition(t,0,1-Math.abs(t));}get pan(){return this._pan}destroy(){super.destroy(),this._stereo=null,this._panner=null;}};var $s=class extends vt{constructor(){let t,e;if(!rt().useLegacy){let{audioContext:r}=rt().context;t=r.createMediaStreamDestination(),e=r.createMediaStreamSource(t.stream);}super(t,e),this._stream=t?.stream;}get stream(){return this._stream}destroy(){this._stream=null,super.destroy();}};var Xs=class extends vt{constructor(){let t,e;if(!rt().useLegacy){let{audioContext:r}=rt().context,s=r.createBiquadFilter(),o=r.createBiquadFilter(),n=r.createBiquadFilter(),a=r.createBiquadFilter();s.type="lowpass",mt.setParamValue(s.frequency,2e3),o.type="lowpass",mt.setParamValue(o.frequency,2e3),n.type="highpass",mt.setParamValue(n.frequency,500),a.type="highpass",mt.setParamValue(a.frequency,500),s.connect(o),o.connect(n),n.connect(a),t=s,e=a;}super(t,e);}};I();var rx={extension:{type:T.Environment,name:"browser",priority:-1},test:()=>true,load:async()=>{await Promise.resolve().then(()=>(ex(),Oy));}};I();var sx={extension:{type:T.Environment,name:"webworker",priority:0},test:()=>typeof self<"u"&&self.WorkerGlobalScope!==void 0,load:async()=>{await Promise.resolve().then(()=>(ix(),zy));}};I();I();To();xo();Aa();ce();Oa();Ui();Nt();go();O.add(rx,sx);var Cs=class extends Z{constructor(){super(...arguments),this.speed=1,this.muted=false,this.volume=1,this.paused=false;}refresh(){this.emit("refresh");}refreshPaused(){this.emit("refreshPaused");}get filters(){return console.warn("HTML Audio does not support filters"),null}set filters(t){console.warn("HTML Audio does not support filters");}get audioContext(){return console.warn("HTML Audio does not support audioContext"),null}toggleMute(){return this.muted=!this.muted,this.refresh(),this.muted}togglePause(){return this.paused=!this.paused,this.refreshPaused(),this.paused}destroy(){this.removeAllListeners();}};var Wy=0,Sl=class extends Z{constructor(i){super(),this.id=Wy++,this.init(i);}set(i,t){if(this[i]===void 0)throw new Error(`Property with name ${i} does not exist.`);switch(i){case "speed":this.speed=t;break;case "volume":this.volume=t;break;case "paused":this.paused=t;break;case "loop":this.loop=t;break;case "muted":this.muted=t;break}return this}get progress(){let{currentTime:i}=this._source;return i/this._duration}get paused(){return this._paused}set paused(i){this._paused=i,this.refreshPaused();}_onPlay(){this._playing=true;}_onPause(){this._playing=false;}init(i){this._playing=false,this._duration=i.source.duration;let t=this._source=i.source.cloneNode(false);t.src=i.parent.url,t.onplay=this._onPlay.bind(this),t.onpause=this._onPause.bind(this),i.context.on("refresh",this.refresh,this),i.context.on("refreshPaused",this.refreshPaused,this),this._media=i;}_internalStop(){this._source&&this._playing&&(this._source.onended=null,this._source.pause());}stop(){this._internalStop(),this._source&&this.emit("stop");}get speed(){return this._speed}set speed(i){this._speed=i,this.refresh();}get volume(){return this._volume}set volume(i){this._volume=i,this.refresh();}get loop(){return this._loop}set loop(i){this._loop=i,this.refresh();}get muted(){return this._muted}set muted(i){this._muted=i,this.refresh();}get filters(){return console.warn("HTML Audio does not support filters"),null}set filters(i){console.warn("HTML Audio does not support filters");}refresh(){let i=this._media.context,t=this._media.parent;this._source.loop=this._loop||t.loop;let e=i.volume*(i.muted?0:1),r=t.volume*(t.muted?0:1),s=this._volume*(this._muted?0:1);this._source.volume=s*e*r,this._source.playbackRate=this._speed*i.speed*t.speed;}refreshPaused(){let i=this._media.context,t=this._media.parent,e=this._paused||t.paused||i.paused;e!==this._pausedReal&&(this._pausedReal=e,e?(this._internalStop(),this.emit("paused")):(this.emit("resumed"),this.play({start:this._source.currentTime,end:this._end,volume:this._volume,speed:this._speed,loop:this._loop})),this.emit("pause",e));}play(i){let{start:t,end:e,speed:r,loop:s,volume:o,muted:n}=i;e&&console.assert(e>t,"End time is before start time"),this._speed=r,this._volume=o,this._loop=!!s,this._muted=n,this.refresh(),this.loop&&e!==null&&(console.warn('Looping not support when specifying an "end" time'),this.loop=false),this._start=t,this._end=e||this._duration,this._start=Math.max(0,this._start-Sl.PADDING),this._end=Math.min(this._end+Sl.PADDING,this._duration),this._source.onloadedmetadata=()=>{this._source&&(this._source.currentTime=t,this._source.onloadedmetadata=null,this.emit("progress",t/this._duration,this._duration),wt.shared.add(this._onUpdate,this));},this._source.onended=this._onComplete.bind(this),this._source.play(),this.emit("start");}_onUpdate(){this.emit("progress",this.progress,this._duration),this._source.currentTime>=this._end&&!this._source.loop&&this._onComplete();}_onComplete(){wt.shared.remove(this._onUpdate,this),this._internalStop(),this.emit("progress",1,this._duration),this.emit("end",this);}destroy(){wt.shared.remove(this._onUpdate,this),this.removeAllListeners();let i=this._source;i&&(i.onended=null,i.onplay=null,i.onpause=null,this._internalStop()),this._source=null,this._speed=1,this._volume=1,this._loop=false,this._end=null,this._start=0,this._duration=0,this._playing=false,this._pausedReal=false,this._paused=false,this._muted=false,this._media&&(this._media.context.off("refresh",this.refresh,this),this._media.context.off("refreshPaused",this.refreshPaused,this),this._media=null);}toString(){return `[HTMLAudioInstance id=${this.id}]`}},Cn=Sl;Cn.PADDING=.1;var As=class extends Z{init(t){this.parent=t,this._source=t.options.source||new Audio,t.url&&(this._source.src=t.url);}create(){return new Cn(this)}get isPlayable(){return !!this._source&&this._source.readyState===4}get duration(){return this._source.duration}get context(){return this.parent.context}get filters(){return null}set filters(t){console.warn("HTML Audio does not support filters");}destroy(){this.removeAllListeners(),this.parent=null,this._source&&(this._source.src="",this._source.load(),this._source=null);}get source(){return this._source}load(t){let e=this._source,r=this.parent;if(e.readyState===4){r.isLoaded=true;let h=r.autoPlayStart();t&&setTimeout(()=>{t(null,r,h);},0);return}if(!r.url){t(new Error("sound.url or sound.source must be set"));return}e.src=r.url;let s=()=>{a(),r.isLoaded=true;let h=r.autoPlayStart();t&&t(null,r,h);},o=()=>{a(),t&&t(new Error("Sound loading has been aborted"));},n=()=>{a();let h=`Failed to load audio element (code: ${e.error.code})`;t?t(new Error(h)):console.error(h);},a=()=>{e.removeEventListener("canplaythrough",s),e.removeEventListener("load",s),e.removeEventListener("abort",o),e.removeEventListener("error",n);};e.addEventListener("canplaythrough",s,false),e.addEventListener("load",s,false),e.addEventListener("abort",o,false),e.addEventListener("error",n,false),e.load();}};var Es=class{constructor(t,e){this.parent=t,Object.assign(this,e),this.duration=this.end-this.start,console.assert(this.duration>0,"End time must be after start time");}play(t){return this.parent.play({complete:t,speed:this.speed||this.parent.speed,end:this.end,start:this.start,loop:this.loop})}destroy(){this.parent=null;}};var Pr=["ogg","oga","opus","m4a","mp3","mpeg","wav","aiff","wma","mid","caf"],Tl=["audio/mpeg","audio/ogg"],Mr={};function ox(i){let t={m4a:"audio/mp4",oga:"audio/ogg",opus:'audio/ogg; codecs="opus"',caf:'audio/x-caf; codecs="opus"',...{}},e=document.createElement("audio"),r={},s=/^no$/;Pr.forEach(o=>{let n=e.canPlayType(`audio/${o}`).replace(s,""),a=t[o]?e.canPlayType(t[o]).replace(s,""):"";r[o]=!!n||!!a;}),Object.assign(Mr,r);}ox();var Ny=0,Fs=class extends Z{constructor(t){super(),this.id=Ny++,this._media=null,this._paused=false,this._muted=false,this._elapsed=0,this.init(t);}set(t,e){if(this[t]===void 0)throw new Error(`Property with name ${t} does not exist.`);switch(t){case "speed":this.speed=e;break;case "volume":this.volume=e;break;case "muted":this.muted=e;break;case "loop":this.loop=e;break;case "paused":this.paused=e;break}return this}stop(){this._source&&(this._internalStop(),this.emit("stop"));}get speed(){return this._speed}set speed(t){this._speed=t,this.refresh(),this._update(true);}get volume(){return this._volume}set volume(t){this._volume=t,this.refresh();}get muted(){return this._muted}set muted(t){this._muted=t,this.refresh();}get loop(){return this._loop}set loop(t){this._loop=t,this.refresh();}get filters(){return this._filters}set filters(t){this._filters&&(this._filters?.filter(e=>e).forEach(e=>e.disconnect()),this._filters=null,this._source.connect(this._gain)),this._filters=t?.length?t.slice(0):null,this.refresh();}refresh(){if(!this._source)return;let t=this._media.context,e=this._media.parent;this._source.loop=this._loop||e.loop;let r=t.volume*(t.muted?0:1),s=e.volume*(e.muted?0:1),o=this._volume*(this._muted?0:1);mt.setParamValue(this._gain.gain,o*s*r),mt.setParamValue(this._source.playbackRate,this._speed*e.speed*t.speed),this.applyFilters();}applyFilters(){if(this._filters?.length){this._source.disconnect();let t=this._source;this._filters.forEach(e=>{t.connect(e.destination),t=e;}),t.connect(this._gain);}}refreshPaused(){let t=this._media.context,e=this._media.parent,r=this._paused||e.paused||t.paused;r!==this._pausedReal&&(this._pausedReal=r,r?(this._internalStop(),this.emit("paused")):(this.emit("resumed"),this.play({start:this._elapsed%this._duration,end:this._end,speed:this._speed,loop:this._loop,volume:this._volume})),this.emit("pause",r));}play(t){let{start:e,end:r,speed:s,loop:o,volume:n,muted:a,filters:h}=t;r&&console.assert(r>e,"End time is before start time"),this._paused=false;let{source:l,gain:c}=this._media.nodes.cloneBufferSource();this._source=l,this._gain=c,this._speed=s,this._volume=n,this._loop=!!o,this._muted=a,this._filters=h,this.refresh();let u=this._source.buffer.duration;this._duration=u,this._end=r,this._lastUpdate=this._now(),this._elapsed=e,this._source.onended=this._onComplete.bind(this),this._loop?(this._source.loopEnd=r,this._source.loopStart=e,this._source.start(0,e)):r?this._source.start(0,e,r-e):this._source.start(0,e),this.emit("start"),this._update(true),this.enableTicker(true);}enableTicker(t){wt.shared.remove(this._updateListener,this),t&&wt.shared.add(this._updateListener,this);}get progress(){return this._progress}get paused(){return this._paused}set paused(t){this._paused=t,this.refreshPaused();}destroy(){this.removeAllListeners(),this._internalStop(),this._gain&&(this._gain.disconnect(),this._gain=null),this._media&&(this._media.context.events.off("refresh",this.refresh,this),this._media.context.events.off("refreshPaused",this.refreshPaused,this),this._media=null),this._filters?.forEach(t=>t.disconnect()),this._filters=null,this._end=null,this._speed=1,this._volume=1,this._loop=false,this._elapsed=0,this._duration=0,this._paused=false,this._muted=false,this._pausedReal=false;}toString(){return `[WebAudioInstance id=${this.id}]`}_now(){return this._media.context.audioContext.currentTime}_updateListener(){this._update();}_update(t=false){if(this._source){let e=this._now(),r=e-this._lastUpdate;if(r>0||t){let s=this._source.playbackRate.value;this._elapsed+=r*s,this._lastUpdate=e;let o=this._duration,n;if(this._source.loopStart){let a=this._source.loopEnd-this._source.loopStart;n=(this._source.loopStart+this._elapsed%a)/o;}else n=this._elapsed%o/o;this._progress=n,this.emit("progress",this._progress,o);}}}init(t){this._media=t,t.context.events.on("refresh",this.refresh,this),t.context.events.on("refreshPaused",this.refreshPaused,this);}_internalStop(){if(this._source){this.enableTicker(false),this._source.onended=null,this._source.stop(0),this._source.disconnect();try{this._source.buffer=null;}catch(t){console.warn("Failed to set AudioBufferSourceNode.buffer to null:",t);}this._source=null;}}_onComplete(){if(this._source){this.enableTicker(false),this._source.onended=null,this._source.disconnect();try{this._source.buffer=null;}catch(t){console.warn("Failed to set AudioBufferSourceNode.buffer to null:",t);}}this._source=null,this._progress=1,this.emit("progress",1,this._duration),this.emit("end",this);}};var Cr=class{constructor(t,e){this._output=e,this._input=t;}get destination(){return this._input}get filters(){return this._filters}set filters(t){if(this._filters&&(this._filters.forEach(e=>{e&&e.disconnect();}),this._filters=null,this._input.connect(this._output)),t&&t.length){this._filters=t.slice(0),this._input.disconnect();let e=null;t.forEach(r=>{e===null?this._input.connect(r.destination):e.connect(r.destination),e=r;}),e.connect(this._output);}}destroy(){this.filters=null,this._input=null,this._output=null;}};var nx=class extends Cr{constructor(i){let t=i.audioContext,e=t.createBufferSource(),r=t.createGain(),s=t.createAnalyser();e.connect(s),s.connect(r),r.connect(i.destination),super(s,r),this.context=i,this.bufferSource=e,this.gain=r,this.analyser=s;}get script(){return this._script||(this._script=this.context.audioContext.createScriptProcessor(nx.BUFFER_SIZE),this._script.connect(this.context.destination)),this._script}destroy(){super.destroy(),this.bufferSource.disconnect(),this._script&&this._script.disconnect(),this.gain.disconnect(),this.analyser.disconnect(),this.bufferSource=null,this._script=null,this.gain=null,this.analyser=null,this.context=null;}cloneBufferSource(){let i=this.bufferSource,t=this.context.audioContext.createBufferSource();t.buffer=i.buffer,mt.setParamValue(t.playbackRate,i.playbackRate.value),t.loop=i.loop;let e=this.context.audioContext.createGain();return t.connect(e),e.connect(this.destination),{source:t,gain:e}}get bufferSize(){return this.script.bufferSize}},An=nx;An.BUFFER_SIZE=0;var Ar=class{init(t){this.parent=t,this._nodes=new An(this.context),this._source=this._nodes.bufferSource,this.source=t.options.source;}destroy(){this.parent=null,this._nodes.destroy(),this._nodes=null;try{this._source.buffer=null;}catch(t){console.warn("Failed to set AudioBufferSourceNode.buffer to null:",t);}this._source=null,this.source=null;}create(){return new Fs(this)}get context(){return this.parent.context}get isPlayable(){return !!this._source&&!!this._source.buffer}get filters(){return this._nodes.filters}set filters(t){this._nodes.filters=t;}get duration(){return console.assert(this.isPlayable,"Sound not yet playable, no duration"),this._source.buffer.duration}get buffer(){return this._source.buffer}set buffer(t){this._source.buffer=t;}get nodes(){return this._nodes}load(t){this.source?this._decode(this.source,t):this.parent.url?this._loadUrl(t):t?t(new Error("sound.url or sound.source must be set")):console.error("sound.url or sound.source must be set");}async _loadUrl(t){let e=this.parent.url,r=await ft.get().fetch(e);this._decode(await r.arrayBuffer(),t);}_decode(t,e){let r=(s,o)=>{if(s)e&&e(s);else {this.parent.isLoaded=true,this.buffer=o;let n=this.parent.autoPlayStart();e&&e(null,this.parent,n);}};t instanceof AudioBuffer?r(null,t):this.parent.context.decode(t,r);}};var ui=class{static from(i){let t={};typeof i=="string"?t.url=i:i instanceof ArrayBuffer||i instanceof AudioBuffer||i instanceof HTMLAudioElement?t.source=i:Array.isArray(i)?t.url=i:t=i,t={autoPlay:false,singleInstance:false,url:null,source:null,preload:false,volume:1,speed:1,complete:null,loaded:null,loop:false,...t},Object.freeze(t);let e=rt().useLegacy?new As:new Ar;return new ui(e,t)}constructor(i,t){this.media=i,this.options=t,this._instances=[],this._sprites={},this.media.init(this);let e=t.complete;this._autoPlayOptions=e?{complete:e}:null,this.isLoaded=false,this._preloadQueue=null,this.isPlaying=false,this.autoPlay=t.autoPlay,this.singleInstance=t.singleInstance,this.preload=t.preload||this.autoPlay,this.url=Array.isArray(t.url)?this.preferUrl(t.url):t.url,this.speed=t.speed,this.volume=t.volume,this.loop=t.loop,t.sprites&&this.addSprites(t.sprites),this.preload&&this._preload(t.loaded);}preferUrl(i){let[t]=i.map(e=>({url:e,ext:$t.extname(e).slice(1)})).filter(({ext:e})=>Mr[e]).sort((e,r)=>Pr.indexOf(e.ext)-Pr.indexOf(r.ext));if(!t)throw new Error("No supported file type found");return t.url}get context(){return rt().context}pause(){return this.isPlaying=false,this.paused=true,this}resume(){return this.isPlaying=this._instances.length>0,this.paused=false,this}get paused(){return this._paused}set paused(i){this._paused=i,this.refreshPaused();}get speed(){return this._speed}set speed(i){this._speed=i,this.refresh();}get filters(){return this.media.filters}set filters(i){this.media.filters=i;}addSprites(i,t){if(typeof i=="object"){let r={};for(let s in i)r[s]=this.addSprites(s,i[s]);return r}console.assert(!this._sprites[i],`Alias ${i} is already taken`);let e=new Es(this,t);return this._sprites[i]=e,e}destroy(){this._removeInstances(),this.removeSprites(),this.media.destroy(),this.media=null,this._sprites=null,this._instances=null;}removeSprites(i){if(i){let t=this._sprites[i];t!==void 0&&(t.destroy(),delete this._sprites[i]);}else for(let t in this._sprites)this.removeSprites(t);return this}get isPlayable(){return this.isLoaded&&this.media&&this.media.isPlayable}stop(){if(!this.isPlayable)return this.autoPlay=false,this._autoPlayOptions=null,this;this.isPlaying=false;for(let i=this._instances.length-1;i>=0;i--)this._instances[i].stop();return this}play(i,t){let e;if(typeof i=="string"?e={sprite:i,loop:this.loop,complete:t}:typeof i=="function"?(e={},e.complete=i):e=i,e={complete:null,loaded:null,sprite:null,end:null,start:0,volume:1,speed:1,muted:false,loop:false,...e||{}},e.sprite){let s=e.sprite;console.assert(!!this._sprites[s],`Alias ${s} is not available`);let o=this._sprites[s];e.start=o.start+(e.start||0),e.end=o.end,e.speed=o.speed||1,e.loop=o.loop||e.loop,delete e.sprite;}if(e.offset&&(e.start=e.offset),!this.isLoaded)return this._preloadQueue?new Promise(s=>{this._preloadQueue.push(()=>{s(this.play(e));});}):(this._preloadQueue=[],this.autoPlay=true,this._autoPlayOptions=e,new Promise((s,o)=>{this._preload((n,a,h)=>{this._preloadQueue.forEach(l=>l()),this._preloadQueue=null,n?o(n):(e.loaded&&e.loaded(n,a,h),s(h));});}));(this.singleInstance||e.singleInstance)&&this._removeInstances();let r=this._createInstance();return this._instances.push(r),this.isPlaying=true,r.once("end",()=>{e.complete&&e.complete(this),this._onComplete(r);}),r.once("stop",()=>{this._onComplete(r);}),r.play(e),r}refresh(){let i=this._instances.length;for(let t=0;t<i;t++)this._instances[t].refresh();}refreshPaused(){let i=this._instances.length;for(let t=0;t<i;t++)this._instances[t].refreshPaused();}get volume(){return this._volume}set volume(i){this._volume=i,this.refresh();}get muted(){return this._muted}set muted(i){this._muted=i,this.refresh();}get loop(){return this._loop}set loop(i){this._loop=i,this.refresh();}_preload(i){this.media.load(i);}get instances(){return this._instances}get sprites(){return this._sprites}get duration(){return this.media.duration}autoPlayStart(){let i;return this.autoPlay&&(i=this.play(this._autoPlayOptions)),i}_removeInstances(){for(let i=this._instances.length-1;i>=0;i--)this._poolInstance(this._instances[i]);this._instances.length=0;}_onComplete(i){if(this._instances){let t=this._instances.indexOf(i);t>-1&&this._instances.splice(t,1),this.isPlaying=this._instances.length>0;}this._poolInstance(i);}_createInstance(){if(ui._pool.length>0){let i=ui._pool.pop();return i.init(this.media),i}return this.media.create()}_poolInstance(i){i.destroy(),ui._pool.indexOf(i)<0&&ui._pool.push(i);}},Qe=ui;Qe._pool=[];var di=class i extends Cr{constructor(){let t=window,e=new i.AudioContext,r=e.createDynamicsCompressor(),s=e.createAnalyser();s.connect(r),r.connect(e.destination),super(s,r),this.autoPause=true,this._ctx=e,this._offlineCtx=new i.OfflineAudioContext(1,2,t.OfflineAudioContext?Math.max(8e3,Math.min(96e3,e.sampleRate)):44100),this.compressor=r,this.analyser=s,this.events=new Z,this.volume=1,this.speed=1,this.muted=false,this.paused=false,this._locked=e.state==="suspended"&&("ontouchstart"in globalThis||"onclick"in globalThis),this._locked&&(this._unlock(),this._unlock=this._unlock.bind(this),document.addEventListener("mousedown",this._unlock,true),document.addEventListener("touchstart",this._unlock,true),document.addEventListener("touchend",this._unlock,true)),this.onFocus=this.onFocus.bind(this),this.onBlur=this.onBlur.bind(this),globalThis.addEventListener("focus",this.onFocus),globalThis.addEventListener("blur",this.onBlur);}onFocus(){if(!this.autoPause)return;let t=this._ctx.state;(t==="suspended"||t==="interrupted"||!this._locked)&&(this.paused=this._pausedOnBlur,this.refreshPaused());}onBlur(){this.autoPause&&(this._locked||(this._pausedOnBlur=this._paused,this.paused=true,this.refreshPaused()));}_unlock(){this._locked&&(this.playEmptySound(),this._ctx.state==="running"&&(document.removeEventListener("mousedown",this._unlock,true),document.removeEventListener("touchend",this._unlock,true),document.removeEventListener("touchstart",this._unlock,true),this._locked=false));}playEmptySound(){let t=this._ctx.createBufferSource();t.buffer=this._ctx.createBuffer(1,1,22050),t.connect(this._ctx.destination),t.start(0,0,0),t.context.state==="suspended"&&t.context.resume();}static get AudioContext(){let t=window;return t.AudioContext||t.webkitAudioContext||null}static get OfflineAudioContext(){let t=window;return t.OfflineAudioContext||t.webkitOfflineAudioContext||null}destroy(){super.destroy();let t=this._ctx;typeof t.close<"u"&&t.close(),globalThis.removeEventListener("focus",this.onFocus),globalThis.removeEventListener("blur",this.onBlur),this.events.removeAllListeners(),this.analyser.disconnect(),this.compressor.disconnect(),this.analyser=null,this.compressor=null,this.events=null,this._offlineCtx=null,this._ctx=null;}get audioContext(){return this._ctx}get offlineContext(){return this._offlineCtx}set paused(t){t&&this._ctx.state==="running"?this._ctx.suspend():!t&&this._ctx.state==="suspended"&&this._ctx.resume(),this._paused=t;}get paused(){return this._paused}refresh(){this.events.emit("refresh");}refreshPaused(){this.events.emit("refreshPaused");}toggleMute(){return this.muted=!this.muted,this.refresh(),this.muted}togglePause(){return this.paused=!this.paused,this.refreshPaused(),this._paused}decode(t,e){let r=o=>{e(new Error(o?.message||"Unable to decode file"));},s=this._offlineCtx.decodeAudioData(t,o=>{e(null,o);},r);s&&s.catch(r);}};var En=class{constructor(){this.init();}init(){return this.supported&&(this._webAudioContext=new di),this._htmlAudioContext=new Cs,this._sounds={},this.useLegacy=!this.supported,this}get context(){return this._context}get filtersAll(){return this.useLegacy?[]:this._context.filters}set filtersAll(t){this.useLegacy||(this._context.filters=t);}get supported(){return di.AudioContext!==null}add(t,e){if(typeof t=="object"){let o={};for(let n in t){let a=this._getOptions(t[n],e);o[n]=this.add(n,a);}return o}if(console.assert(!this._sounds[t],`Sound with alias ${t} already exists.`),e instanceof Qe)return this._sounds[t]=e,e;let r=this._getOptions(e),s=Qe.from(r);return this._sounds[t]=s,s}_getOptions(t,e){let r;return typeof t=="string"?r={url:t}:Array.isArray(t)?r={url:t}:t instanceof ArrayBuffer||t instanceof AudioBuffer||t instanceof HTMLAudioElement?r={source:t}:r=t,r={...r,...e||{}},r}get useLegacy(){return this._useLegacy}set useLegacy(t){this._useLegacy=t,this._context=!t&&this.supported?this._webAudioContext:this._htmlAudioContext;}get disableAutoPause(){return !this._webAudioContext.autoPause}set disableAutoPause(t){this._webAudioContext.autoPause=!t;}remove(t){return this.exists(t,true),this._sounds[t].destroy(),delete this._sounds[t],this}get volumeAll(){return this._context.volume}set volumeAll(t){this._context.volume=t,this._context.refresh();}get speedAll(){return this._context.speed}set speedAll(t){this._context.speed=t,this._context.refresh();}togglePauseAll(){return this._context.togglePause()}pauseAll(){return this._context.paused=true,this._context.refreshPaused(),this}resumeAll(){return this._context.paused=false,this._context.refreshPaused(),this}toggleMuteAll(){return this._context.toggleMute()}muteAll(){return this._context.muted=true,this._context.refresh(),this}unmuteAll(){return this._context.muted=false,this._context.refresh(),this}removeAll(){for(let t in this._sounds)this._sounds[t].destroy(),delete this._sounds[t];return this}stopAll(){for(let t in this._sounds)this._sounds[t].stop();return this}exists(t,e=false){let r=!!this._sounds[t];return e&&console.assert(r,`No sound matching alias '${t}'.`),r}isPlaying(){for(let t in this._sounds)if(this._sounds[t].isPlaying)return true;return false}find(t){return this.exists(t,true),this._sounds[t]}play(t,e){return this.find(t).play(e)}stop(t){return this.find(t).stop()}pause(t){return this.find(t).pause()}resume(t){return this.find(t).resume()}volume(t,e){let r=this.find(t);return e!==void 0&&(r.volume=e),r.volume}speed(t,e){let r=this.find(t);return e!==void 0&&(r.speed=e),r.speed}duration(t){return this.find(t).duration}close(){return this.removeAll(),this._sounds=null,this._webAudioContext&&(this._webAudioContext.destroy(),this._webAudioContext=null),this._htmlAudioContext&&(this._htmlAudioContext.destroy(),this._htmlAudioContext=null),this._context=null,this}};var ax=i=>{let t=i.src,e=i?.alias?.[0];return (!e||i.src===e)&&(e=$t.basename(t,$t.extname(t))),e},hx={extension:T.Asset,detection:{test:async()=>true,add:async i=>[...i,...Pr.filter(t=>Mr[t])],remove:async i=>i.filter(t=>i.includes(t))},loader:{name:"sound",extension:{type:[T.LoadParser],priority:zr.High},test(i){let t=$t.extname(i).slice(1);return !!Mr[t]||Tl.some(e=>i.startsWith(`data:${e}`))},async load(i,t){let e=await new Promise((r,s)=>Qe.from({...t.data,url:i,preload:true,loaded(o,n){o?s(o):r(n),t.data?.loaded?.(o,n);}}));return rt().add(ax(t),e),e},async unload(i,t){rt().remove(ax(t));}}};O.add(hx);Ol(new En);({DistortionFilter:be.DistortionFilter,EqualizerFilter:be.EqualizerFilter,MonoFilter:be.MonoFilter,ReverbFilter:be.ReverbFilter,StereoFilter:be.StereoFilter,StreamFilter:be.StreamFilter,TelephoneFilter:be.TelephoneFilter});var lx={CHARACTER_CATEGORY_KEY:"___character___"};var at;(s=>(s.log=(o,...n)=>console.log(`[Pixi\u2019VN] ${o}`,...n),s.warn=(o,...n)=>console.warn(`[Pixi\u2019VN] ${o}`,...n),s.error=(o,...n)=>console.error(`[Pixi\u2019VN] ${o}`,...n),s.info=(o,...n)=>console.info(`[Pixi\u2019VN] ${o}`,...n)))(at||(at={}));var z=class z{static init(t){z._getStepCounter=t.getStepCounter,z._setStepCounter=t.setStepCounter,z._getCurrentGameStepState=t.getCurrentGameStepState,z._restoreGameStepState=t.restoreGameStepState,z._getOpenedLabels=t.getOpenedLabels,t.onGoNextEnd&&(z._onGoNextEnd=t.onGoNextEnd),z._getVariable=t.getVariable,z._setVariable=t.setVariable,z._removeVariable=t.removeVariable,z._getFlag=t.getFlag,z._setFlag=t.setFlag,t.onLabelClosing&&(z._onLabelClosing=t.onLabelClosing),z._addHistoryItem=t.addHistoryItem,z._getCurrentStepsRunningNumber=t.getCurrentStepsRunningNumber,z._getCharacter=t.getCharacter;}static get stepCounter(){return z._getStepCounter()}static set stepCounter(t){z._setStepCounter(t);}static get currentGameStepState(){return z._getCurrentGameStepState()}static get restoreGameStepState(){return z._restoreGameStepState}static get openedLabels(){return z._getOpenedLabels()}static get onGoNextEnd(){return z._onGoNextEnd}static get getVariable(){return z._getVariable}static get setVariable(){return z._setVariable}static get removeVariable(){return z._removeVariable}static get getFlag(){return z._getFlag}static get setFlag(){return z._setFlag}static get onLabelClosing(){return z._onLabelClosing}static get addHistoryItem(){return z._addHistoryItem}static get currentStepsRunningNumber(){return z._getCurrentStepsRunningNumber()}static get getCharacter(){return z._getCharacter}};G(z,"_getStepCounter",()=>{throw at.error("Method not implemented, you should initialize the Game: Game.init()"),new Error("Method not implemented, you should initialize the Game: Game.init()")}),G(z,"_setStepCounter",()=>{throw at.error("Method not implemented, you should initialize the Game: Game.init()"),new Error("Method not implemented, you should initialize the Game: Game.init()")}),G(z,"_getCurrentGameStepState",()=>{throw at.error("Method not implemented, you should initialize the Game: Game.init()"),new Error("Method not implemented, you should initialize the Game: Game.init()")}),G(z,"_restoreGameStepState",()=>{throw at.error("Method not implemented, you should initialize the Game: Game.init()"),new Error("Method not implemented, you should initialize the Game: Game.init()")}),G(z,"_getOpenedLabels",()=>{throw at.error("Method not implemented, you should initialize the Game: Game.init()"),new Error("Method not implemented, you should initialize the Game: Game.init()")}),G(z,"_onGoNextEnd",async()=>{}),G(z,"_getVariable",()=>{throw at.error("Method not implemented, you should initialize the Game: Game.init()"),new Error("Method not implemented, you should initialize the Game: Game.init()")}),G(z,"_setVariable",()=>{throw at.error("Method not implemented, you should initialize the Game: Game.init()"),new Error("Method not implemented, you should initialize the Game: Game.init()")}),G(z,"_removeVariable",()=>{throw at.error("Method not implemented, you should initialize the Game: Game.init()"),new Error("Method not implemented, you should initialize the Game: Game.init()")}),G(z,"_getFlag",()=>{throw at.error("Method not implemented, you should initialize the Game: Game.init()"),new Error("Method not implemented, you should initialize the Game: Game.init()")}),G(z,"_setFlag",()=>{throw at.error("Method not implemented, you should initialize the Game: Game.init()"),new Error("Method not implemented, you should initialize the Game: Game.init()")}),G(z,"_onLabelClosing",()=>{}),G(z,"_addHistoryItem",()=>{throw at.error("Method not implemented, you should initialize the Game: Game.init()"),new Error("Method not implemented, you should initialize the Game: Game.init()")}),G(z,"_getCurrentStepsRunningNumber",()=>{throw at.error("Method not implemented, you should initialize the Game: Game.init()"),new Error("Method not implemented, you should initialize the Game: Game.init()")}),G(z,"_getCharacter",()=>{throw at.error("Method not implemented, you should initialize the Game: Game.init()"),new Error("Method not implemented.")}),G(z,"onEnd"),G(z,"onError");function Fn(i){try{if(typeof i>"u")return i;let t=JSON.stringify(i);return JSON.parse(t)}catch(t){throw at.error("Error creating exportable element",i,t),new Error("[Pixi\u2019VN] Error creating exportable element")}}var fi=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,fx=new Set,wl=typeof process=="object"&&process?process:{},px=(i,t,e,r)=>{typeof wl.emitWarning=="function"?wl.emitWarning(i,t,e,r):console.error(`[${e}] ${t}: ${i}`);},Gn=globalThis.AbortController,cx=globalThis.AbortSignal;if(typeof Gn>"u"){cx=class{constructor(){G(this,"onabort");G(this,"_onabort",[]);G(this,"reason");G(this,"aborted",false);}addEventListener(r,s){this._onabort.push(s);}},Gn=class{constructor(){G(this,"signal",new cx);t();}abort(r){if(!this.signal.aborted){this.signal.reason=r,this.signal.aborted=true;for(let s of this.signal._onabort)s(r);this.signal.onabort?.(r);}}};let i=wl.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",t=()=>{i&&(i=false,px("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 $y=i=>!fx.has(i),Je=i=>i&&i===Math.floor(i)&&i>0&&isFinite(i),mx=i=>Je(i)?i<=Math.pow(2,8)?Uint8Array:i<=Math.pow(2,16)?Uint16Array:i<=Math.pow(2,32)?Uint32Array:i<=Number.MAX_SAFE_INTEGER?pi:null:null,pi=class extends Array{constructor(t){super(t),this.fill(0);}},mi,Er=class Er{constructor(t,e){G(this,"heap");G(this,"length");if(!x(Er,mi))throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new e(t),this.length=0;}static create(t){let e=mx(t);if(!e)return [];U(Er,mi,true);let r=new Er(t,e);return U(Er,mi,false),r}push(t){this.heap[this.length++]=t;}pop(){return this.heap[--this.length]}};mi=new WeakMap,q(Er,mi,false);var Pl=Er,ux,dx,de,Qt,fe,Fr,pe,gi,xi,Pt,me,yt,lt,H,Wt,Jt,Rt,Ct,ge,At,xe,_e,te,ye,ir,Vt,_i,C,Ml,Br,We,Gs,ee,gx,kr,yi,Rs,tr,er,Cl,Bn,kn,ht,Al,ks,rr,El,Fl=class Fl{constructor(t){q(this,C);q(this,de);q(this,Qt);q(this,fe);q(this,Fr);q(this,pe);q(this,gi);q(this,xi);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");q(this,Pt);q(this,me);q(this,yt);q(this,lt);q(this,H);q(this,Wt);q(this,Jt);q(this,Rt);q(this,Ct);q(this,ge);q(this,At);q(this,xe);q(this,_e);q(this,te);q(this,ye);q(this,ir);q(this,Vt);q(this,_i);q(this,Br,()=>{});q(this,We,()=>{});q(this,Gs,()=>{});q(this,ee,()=>false);q(this,kr,t=>{});q(this,yi,(t,e,r)=>{});q(this,Rs,(t,e,r,s)=>{if(r||s)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0});G(this,ux,"LRUCache");let{max:e=0,ttl:r,ttlResolution:s=1,ttlAutopurge:o,updateAgeOnGet:n,updateAgeOnHas:a,allowStale:h,dispose:l,onInsert:c,disposeAfter:u,noDisposeOnSet:f,noUpdateTTL:d,maxSize:g=0,maxEntrySize:_=0,sizeCalculation:m,fetchMethod:y,memoMethod:b,noDeleteOnFetchRejection:v,noDeleteOnStaleGet:S,allowStaleOnFetchRejection:M,allowStaleOnFetchAbort:w,ignoreFetchAbort:P}=t;if(e!==0&&!Je(e))throw new TypeError("max option must be a nonnegative integer");let W=e?mx(e):Array;if(!W)throw new Error("invalid max value: "+e);if(U(this,de,e),U(this,Qt,g),this.maxEntrySize=_||x(this,Qt),this.sizeCalculation=m,this.sizeCalculation){if(!x(this,Qt)&&!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(b!==void 0&&typeof b!="function")throw new TypeError("memoMethod must be a function if defined");if(U(this,xi,b),y!==void 0&&typeof y!="function")throw new TypeError("fetchMethod must be a function if specified");if(U(this,gi,y),U(this,ir,!!y),U(this,yt,new Map),U(this,lt,new Array(e).fill(void 0)),U(this,H,new Array(e).fill(void 0)),U(this,Wt,new W(e)),U(this,Jt,new W(e)),U(this,Rt,0),U(this,Ct,0),U(this,ge,Pl.create(e)),U(this,Pt,0),U(this,me,0),typeof l=="function"&&U(this,fe,l),typeof c=="function"&&U(this,Fr,c),typeof u=="function"?(U(this,pe,u),U(this,At,[])):(U(this,pe,void 0),U(this,At,void 0)),U(this,ye,!!x(this,fe)),U(this,_i,!!x(this,Fr)),U(this,Vt,!!x(this,pe)),this.noDisposeOnSet=!!f,this.noUpdateTTL=!!d,this.noDeleteOnFetchRejection=!!v,this.allowStaleOnFetchRejection=!!M,this.allowStaleOnFetchAbort=!!w,this.ignoreFetchAbort=!!P,this.maxEntrySize!==0){if(x(this,Qt)!==0&&!Je(x(this,Qt)))throw new TypeError("maxSize must be a positive integer if specified");if(!Je(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");k(this,C,gx).call(this);}if(this.allowStale=!!h,this.noDeleteOnStaleGet=!!S,this.updateAgeOnGet=!!n,this.updateAgeOnHas=!!a,this.ttlResolution=Je(s)||s===0?s:1,this.ttlAutopurge=!!o,this.ttl=r||0,this.ttl){if(!Je(this.ttl))throw new TypeError("ttl must be a positive integer if specified");k(this,C,Ml).call(this);}if(x(this,de)===0&&this.ttl===0&&x(this,Qt)===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!x(this,de)&&!x(this,Qt)){let A="LRU_CACHE_UNBOUNDED";$y(A)&&(fx.add(A),px("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",A,Fl));}}static unsafeExposeInternals(t){return {starts:x(t,_e),ttls:x(t,te),sizes:x(t,xe),keyMap:x(t,yt),keyList:x(t,lt),valList:x(t,H),next:x(t,Wt),prev:x(t,Jt),get head(){return x(t,Rt)},get tail(){return x(t,Ct)},free:x(t,ge),isBackgroundFetch:e=>{var r;return k(r=t,C,ht).call(r,e)},backgroundFetch:(e,r,s,o)=>{var n;return k(n=t,C,kn).call(n,e,r,s,o)},moveToTail:e=>{var r;return k(r=t,C,ks).call(r,e)},indexes:e=>{var r;return k(r=t,C,tr).call(r,e)},rindexes:e=>{var r;return k(r=t,C,er).call(r,e)},isStale:e=>{var r;return x(r=t,ee).call(r,e)}}}get max(){return x(this,de)}get maxSize(){return x(this,Qt)}get calculatedSize(){return x(this,me)}get size(){return x(this,Pt)}get fetchMethod(){return x(this,gi)}get memoMethod(){return x(this,xi)}get dispose(){return x(this,fe)}get onInsert(){return x(this,Fr)}get disposeAfter(){return x(this,pe)}getRemainingTTL(t){return x(this,yt).has(t)?1/0:0}*entries(){for(let t of k(this,C,tr).call(this))x(this,H)[t]!==void 0&&x(this,lt)[t]!==void 0&&!k(this,C,ht).call(this,x(this,H)[t])&&(yield [x(this,lt)[t],x(this,H)[t]]);}*rentries(){for(let t of k(this,C,er).call(this))x(this,H)[t]!==void 0&&x(this,lt)[t]!==void 0&&!k(this,C,ht).call(this,x(this,H)[t])&&(yield [x(this,lt)[t],x(this,H)[t]]);}*keys(){for(let t of k(this,C,tr).call(this)){let e=x(this,lt)[t];e!==void 0&&!k(this,C,ht).call(this,x(this,H)[t])&&(yield e);}}*rkeys(){for(let t of k(this,C,er).call(this)){let e=x(this,lt)[t];e!==void 0&&!k(this,C,ht).call(this,x(this,H)[t])&&(yield e);}}*values(){for(let t of k(this,C,tr).call(this))x(this,H)[t]!==void 0&&!k(this,C,ht).call(this,x(this,H)[t])&&(yield x(this,H)[t]);}*rvalues(){for(let t of k(this,C,er).call(this))x(this,H)[t]!==void 0&&!k(this,C,ht).call(this,x(this,H)[t])&&(yield x(this,H)[t]);}[(dx=Symbol.iterator,ux=Symbol.toStringTag,dx)](){return this.entries()}find(t,e={}){for(let r of k(this,C,tr).call(this)){let s=x(this,H)[r],o=k(this,C,ht).call(this,s)?s.__staleWhileFetching:s;if(o!==void 0&&t(o,x(this,lt)[r],this))return this.get(x(this,lt)[r],e)}}forEach(t,e=this){for(let r of k(this,C,tr).call(this)){let s=x(this,H)[r],o=k(this,C,ht).call(this,s)?s.__staleWhileFetching:s;o!==void 0&&t.call(e,o,x(this,lt)[r],this);}}rforEach(t,e=this){for(let r of k(this,C,er).call(this)){let s=x(this,H)[r],o=k(this,C,ht).call(this,s)?s.__staleWhileFetching:s;o!==void 0&&t.call(e,o,x(this,lt)[r],this);}}purgeStale(){let t=false;for(let e of k(this,C,er).call(this,{allowStale:true}))x(this,ee).call(this,e)&&(k(this,C,rr).call(this,x(this,lt)[e],"expire"),t=true);return t}info(t){let e=x(this,yt).get(t);if(e===void 0)return;let r=x(this,H)[e],s=k(this,C,ht).call(this,r)?r.__staleWhileFetching:r;if(s===void 0)return;let o={value:s};if(x(this,te)&&x(this,_e)){let n=x(this,te)[e],a=x(this,_e)[e];if(n&&a){let h=n-(fi.now()-a);o.ttl=h,o.start=Date.now();}}return x(this,xe)&&(o.size=x(this,xe)[e]),o}dump(){let t=[];for(let e of k(this,C,tr).call(this,{allowStale:true})){let r=x(this,lt)[e],s=x(this,H)[e],o=k(this,C,ht).call(this,s)?s.__staleWhileFetching:s;if(o===void 0||r===void 0)continue;let n={value:o};if(x(this,te)&&x(this,_e)){n.ttl=x(this,te)[e];let a=fi.now()-x(this,_e)[e];n.start=Math.floor(Date.now()-a);}x(this,xe)&&(n.size=x(this,xe)[e]),t.unshift([r,n]);}return t}load(t){this.clear();for(let[e,r]of t){if(r.start){let s=Date.now()-r.start;r.start=fi.now()-s;}this.set(e,r.value,r);}}set(t,e,r={}){var f,d,g,_;if(e===void 0)return this.delete(t),this;let{ttl:s=this.ttl,start:o,noDisposeOnSet:n=this.noDisposeOnSet,sizeCalculation:a=this.sizeCalculation,status:h}=r,{noUpdateTTL:l=this.noUpdateTTL}=r,c=x(this,Rs).call(this,t,e,r.size||0,a);if(this.maxEntrySize&&c>this.maxEntrySize)return h&&(h.set="miss",h.maxEntrySizeExceeded=true),k(this,C,rr).call(this,t,"set"),this;let u=x(this,Pt)===0?void 0:x(this,yt).get(t);if(u===void 0)u=x(this,Pt)===0?x(this,Ct):x(this,ge).length!==0?x(this,ge).pop():x(this,Pt)===x(this,de)?k(this,C,Bn).call(this,false):x(this,Pt),x(this,lt)[u]=t,x(this,H)[u]=e,x(this,yt).set(t,u),x(this,Wt)[x(this,Ct)]=u,x(this,Jt)[u]=x(this,Ct),U(this,Ct,u),Ws(this,Pt)._++,x(this,yi).call(this,u,c,h),h&&(h.set="add"),l=false,x(this,_i)&&((f=x(this,Fr))==null||f.call(this,e,t,"add"));else {k(this,C,ks).call(this,u);let m=x(this,H)[u];if(e!==m){if(x(this,ir)&&k(this,C,ht).call(this,m)){m.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:y}=m;y!==void 0&&!n&&(x(this,ye)&&((d=x(this,fe))==null||d.call(this,y,t,"set")),x(this,Vt)&&x(this,At)?.push([y,t,"set"]));}else n||(x(this,ye)&&((g=x(this,fe))==null||g.call(this,m,t,"set")),x(this,Vt)&&x(this,At)?.push([m,t,"set"]));if(x(this,kr).call(this,u),x(this,yi).call(this,u,c,h),x(this,H)[u]=e,h){h.set="replace";let y=m&&k(this,C,ht).call(this,m)?m.__staleWhileFetching:m;y!==void 0&&(h.oldValue=y);}}else h&&(h.set="update");x(this,_i)&&this.onInsert?.(e,t,e===m?"update":"replace");}if(s!==0&&!x(this,te)&&k(this,C,Ml).call(this),x(this,te)&&(l||x(this,Gs).call(this,u,s,o),h&&x(this,We).call(this,h,u)),!n&&x(this,Vt)&&x(this,At)){let m=x(this,At),y;for(;y=m?.shift();)(_=x(this,pe))==null||_.call(this,...y);}return this}pop(){var t;try{for(;x(this,Pt);){let e=x(this,H)[x(this,Rt)];if(k(this,C,Bn).call(this,!0),k(this,C,ht).call(this,e)){if(e.__staleWhileFetching)return e.__staleWhileFetching}else if(e!==void 0)return e}}finally{if(x(this,Vt)&&x(this,At)){let e=x(this,At),r;for(;r=e?.shift();)(t=x(this,pe))==null||t.call(this,...r);}}}has(t,e={}){let{updateAgeOnHas:r=this.updateAgeOnHas,status:s}=e,o=x(this,yt).get(t);if(o!==void 0){let n=x(this,H)[o];if(k(this,C,ht).call(this,n)&&n.__staleWhileFetching===void 0)return false;if(x(this,ee).call(this,o))s&&(s.has="stale",x(this,We).call(this,s,o));else return r&&x(this,Br).call(this,o),s&&(s.has="hit",x(this,We).call(this,s,o)),true}else s&&(s.has="miss");return false}peek(t,e={}){let{allowStale:r=this.allowStale}=e,s=x(this,yt).get(t);if(s===void 0||!r&&x(this,ee).call(this,s))return;let o=x(this,H)[s];return k(this,C,ht).call(this,o)?o.__staleWhileFetching:o}async fetch(t,e={}){let{allowStale:r=this.allowStale,updateAgeOnGet:s=this.updateAgeOnGet,noDeleteOnStaleGet:o=this.noDeleteOnStaleGet,ttl:n=this.ttl,noDisposeOnSet:a=this.noDisposeOnSet,size:h=0,sizeCalculation:l=this.sizeCalculation,noUpdateTTL:c=this.noUpdateTTL,noDeleteOnFetchRejection:u=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:f=this.allowStaleOnFetchRejection,ignoreFetchAbort:d=this.ignoreFetchAbort,allowStaleOnFetchAbort:g=this.allowStaleOnFetchAbort,context:_,forceRefresh:m=false,status:y,signal:b}=e;if(!x(this,ir))return y&&(y.fetch="get"),this.get(t,{allowStale:r,updateAgeOnGet:s,noDeleteOnStaleGet:o,status:y});let v={allowStale:r,updateAgeOnGet:s,noDeleteOnStaleGet:o,ttl:n,noDisposeOnSet:a,size:h,sizeCalculation:l,noUpdateTTL:c,noDeleteOnFetchRejection:u,allowStaleOnFetchRejection:f,allowStaleOnFetchAbort:g,ignoreFetchAbort:d,status:y,signal:b},S=x(this,yt).get(t);if(S===void 0){y&&(y.fetch="miss");let M=k(this,C,kn).call(this,t,S,v,_);return M.__returned=M}else {let M=x(this,H)[S];if(k(this,C,ht).call(this,M)){let E=r&&M.__staleWhileFetching!==void 0;return y&&(y.fetch="inflight",E&&(y.returnedStale=true)),E?M.__staleWhileFetching:M.__returned=M}let w=x(this,ee).call(this,S);if(!m&&!w)return y&&(y.fetch="hit"),k(this,C,ks).call(this,S),s&&x(this,Br).call(this,S),y&&x(this,We).call(this,y,S),M;let P=k(this,C,kn).call(this,t,S,v,_),A=P.__staleWhileFetching!==void 0&&r;return y&&(y.fetch=w?"stale":"refresh",A&&w&&(y.returnedStale=true)),A?P.__staleWhileFetching:P.__returned=P}}async forceFetch(t,e={}){let r=await this.fetch(t,e);if(r===void 0)throw new Error("fetch() returned undefined");return r}memo(t,e={}){let r=x(this,xi);if(!r)throw new Error("no memoMethod provided to constructor");let{context:s,forceRefresh:o,...n}=e,a=this.get(t,n);if(!o&&a!==void 0)return a;let h=r(t,a,{options:n,context:s});return this.set(t,h,n),h}get(t,e={}){let{allowStale:r=this.allowStale,updateAgeOnGet:s=this.updateAgeOnGet,noDeleteOnStaleGet:o=this.noDeleteOnStaleGet,status:n}=e,a=x(this,yt).get(t);if(a!==void 0){let h=x(this,H)[a],l=k(this,C,ht).call(this,h);return n&&x(this,We).call(this,n,a),x(this,ee).call(this,a)?(n&&(n.get="stale"),l?(n&&r&&h.__staleWhileFetching!==void 0&&(n.returnedStale=true),r?h.__staleWhileFetching:void 0):(o||k(this,C,rr).call(this,t,"expire"),n&&r&&(n.returnedStale=true),r?h:void 0)):(n&&(n.get="hit"),l?h.__staleWhileFetching:(k(this,C,ks).call(this,a),s&&x(this,Br).call(this,a),h))}else n&&(n.get="miss");}delete(t){return k(this,C,rr).call(this,t,"delete")}clear(){return k(this,C,El).call(this,"delete")}};de=new WeakMap,Qt=new WeakMap,fe=new WeakMap,Fr=new WeakMap,pe=new WeakMap,gi=new WeakMap,xi=new WeakMap,Pt=new WeakMap,me=new WeakMap,yt=new WeakMap,lt=new WeakMap,H=new WeakMap,Wt=new WeakMap,Jt=new WeakMap,Rt=new WeakMap,Ct=new WeakMap,ge=new WeakMap,At=new WeakMap,xe=new WeakMap,_e=new WeakMap,te=new WeakMap,ye=new WeakMap,ir=new WeakMap,Vt=new WeakMap,_i=new WeakMap,C=new WeakSet,Ml=function(){let t=new pi(x(this,de)),e=new pi(x(this,de));U(this,te,t),U(this,_e,e),U(this,Gs,(o,n,a=fi.now())=>{if(e[o]=n!==0?a:0,t[o]=n,n!==0&&this.ttlAutopurge){let h=setTimeout(()=>{x(this,ee).call(this,o)&&k(this,C,rr).call(this,x(this,lt)[o],"expire");},n+1);h.unref&&h.unref();}}),U(this,Br,o=>{e[o]=t[o]!==0?fi.now():0;}),U(this,We,(o,n)=>{if(t[n]){let a=t[n],h=e[n];if(!a||!h)return;o.ttl=a,o.start=h,o.now=r||s();let l=o.now-h;o.remainingTTL=a-l;}});let r=0,s=()=>{let o=fi.now();if(this.ttlResolution>0){r=o;let n=setTimeout(()=>r=0,this.ttlResolution);n.unref&&n.unref();}return o};this.getRemainingTTL=o=>{let n=x(this,yt).get(o);if(n===void 0)return 0;let a=t[n],h=e[n];if(!a||!h)return 1/0;let l=(r||s())-h;return a-l},U(this,ee,o=>{let n=e[o],a=t[o];return !!a&&!!n&&(r||s())-n>a});},Br=new WeakMap,We=new WeakMap,Gs=new WeakMap,ee=new WeakMap,gx=function(){let t=new pi(x(this,de));U(this,me,0),U(this,xe,t),U(this,kr,e=>{U(this,me,x(this,me)-t[e]),t[e]=0;}),U(this,Rs,(e,r,s,o)=>{if(k(this,C,ht).call(this,r))return 0;if(!Je(s))if(o){if(typeof o!="function")throw new TypeError("sizeCalculation must be a function");if(s=o(r,e),!Je(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}),U(this,yi,(e,r,s)=>{if(t[e]=r,x(this,Qt)){let o=x(this,Qt)-t[e];for(;x(this,me)>o;)k(this,C,Bn).call(this,true);}U(this,me,x(this,me)+t[e]),s&&(s.entrySize=r,s.totalCalculatedSize=x(this,me));});},kr=new WeakMap,yi=new WeakMap,Rs=new WeakMap,tr=function*({allowStale:t=this.allowStale}={}){if(x(this,Pt))for(let e=x(this,Ct);!(!k(this,C,Cl).call(this,e)||((t||!x(this,ee).call(this,e))&&(yield e),e===x(this,Rt)));)e=x(this,Jt)[e];},er=function*({allowStale:t=this.allowStale}={}){if(x(this,Pt))for(let e=x(this,Rt);!(!k(this,C,Cl).call(this,e)||((t||!x(this,ee).call(this,e))&&(yield e),e===x(this,Ct)));)e=x(this,Wt)[e];},Cl=function(t){return t!==void 0&&x(this,yt).get(x(this,lt)[t])===t},Bn=function(t){var o;let e=x(this,Rt),r=x(this,lt)[e],s=x(this,H)[e];return x(this,ir)&&k(this,C,ht).call(this,s)?s.__abortController.abort(new Error("evicted")):(x(this,ye)||x(this,Vt))&&(x(this,ye)&&((o=x(this,fe))==null||o.call(this,s,r,"evict")),x(this,Vt)&&x(this,At)?.push([s,r,"evict"])),x(this,kr).call(this,e),t&&(x(this,lt)[e]=void 0,x(this,H)[e]=void 0,x(this,ge).push(e)),x(this,Pt)===1?(U(this,Rt,U(this,Ct,0)),x(this,ge).length=0):U(this,Rt,x(this,Wt)[e]),x(this,yt).delete(r),Ws(this,Pt)._--,e},kn=function(t,e,r,s){let o=e===void 0?void 0:x(this,H)[e];if(k(this,C,ht).call(this,o))return o;let n=new Gn,{signal:a}=r;a?.addEventListener("abort",()=>n.abort(a.reason),{signal:n.signal});let h={signal:n.signal,options:r,context:s},l=(_,m=false)=>{let{aborted:y}=n.signal,b=r.ignoreFetchAbort&&_!==void 0;if(r.status&&(y&&!m?(r.status.fetchAborted=true,r.status.fetchError=n.signal.reason,b&&(r.status.fetchAbortIgnored=true)):r.status.fetchResolved=true),y&&!b&&!m)return u(n.signal.reason);let v=d;return x(this,H)[e]===d&&(_===void 0?v.__staleWhileFetching?x(this,H)[e]=v.__staleWhileFetching:k(this,C,rr).call(this,t,"fetch"):(r.status&&(r.status.fetchUpdated=true),this.set(t,_,h.options))),_},c=_=>(r.status&&(r.status.fetchRejected=true,r.status.fetchError=_),u(_)),u=_=>{let{aborted:m}=n.signal,y=m&&r.allowStaleOnFetchAbort,b=y||r.allowStaleOnFetchRejection,v=b||r.noDeleteOnFetchRejection,S=d;if(x(this,H)[e]===d&&(!v||S.__staleWhileFetching===void 0?k(this,C,rr).call(this,t,"fetch"):y||(x(this,H)[e]=S.__staleWhileFetching)),b)return r.status&&S.__staleWhileFetching!==void 0&&(r.status.returnedStale=true),S.__staleWhileFetching;if(S.__returned===S)throw _},f=(_,m)=>{var b;let y=(b=x(this,gi))==null?void 0:b.call(this,t,o,h);y&&y instanceof Promise&&y.then(v=>_(v===void 0?void 0:v),m),n.signal.addEventListener("abort",()=>{(!r.ignoreFetchAbort||r.allowStaleOnFetchAbort)&&(_(void 0),r.allowStaleOnFetchAbort&&(_=v=>l(v,true)));});};r.status&&(r.status.fetchDispatched=true);let d=new Promise(f).then(l,c),g=Object.assign(d,{__abortController:n,__staleWhileFetching:o,__returned:void 0});return e===void 0?(this.set(t,g,{...h.options,status:void 0}),e=x(this,yt).get(t)):x(this,H)[e]=g,g},ht=function(t){if(!x(this,ir))return false;let e=t;return !!e&&e instanceof Promise&&e.hasOwnProperty("__staleWhileFetching")&&e.__abortController instanceof Gn},Al=function(t,e){x(this,Jt)[e]=t,x(this,Wt)[t]=e;},ks=function(t){t!==x(this,Ct)&&(t===x(this,Rt)?U(this,Rt,x(this,Wt)[t]):k(this,C,Al).call(this,x(this,Jt)[t],x(this,Wt)[t]),k(this,C,Al).call(this,x(this,Ct),t),U(this,Ct,t));},rr=function(t,e){var s,o;let r=false;if(x(this,Pt)!==0){let n=x(this,yt).get(t);if(n!==void 0)if(r=true,x(this,Pt)===1)k(this,C,El).call(this,e);else {x(this,kr).call(this,n);let a=x(this,H)[n];if(k(this,C,ht).call(this,a)?a.__abortController.abort(new Error("deleted")):(x(this,ye)||x(this,Vt))&&(x(this,ye)&&((s=x(this,fe))==null||s.call(this,a,t,e)),x(this,Vt)&&x(this,At)?.push([a,t,e])),x(this,yt).delete(t),x(this,lt)[n]=void 0,x(this,H)[n]=void 0,n===x(this,Ct))U(this,Ct,x(this,Jt)[n]);else if(n===x(this,Rt))U(this,Rt,x(this,Wt)[n]);else {let h=x(this,Jt)[n];x(this,Wt)[h]=x(this,Wt)[n];let l=x(this,Wt)[n];x(this,Jt)[l]=x(this,Jt)[n];}Ws(this,Pt)._--,x(this,ge).push(n);}}if(x(this,Vt)&&x(this,At)?.length){let n=x(this,At),a;for(;a=n?.shift();)(o=x(this,pe))==null||o.call(this,...a);}return r},El=function(t){var e,r;for(let s of k(this,C,er).call(this,{allowStale:true})){let o=x(this,H)[s];if(k(this,C,ht).call(this,o))o.__abortController.abort(new Error("deleted"));else {let n=x(this,lt)[s];x(this,ye)&&((e=x(this,fe))==null||e.call(this,o,n,t)),x(this,Vt)&&x(this,At)?.push([o,n,t]);}}if(x(this,yt).clear(),x(this,H).fill(void 0),x(this,lt).fill(void 0),x(this,te)&&x(this,_e)&&(x(this,te).fill(0),x(this,_e).fill(0)),x(this,xe)&&x(this,xe).fill(0),U(this,Rt,0),U(this,Ct,0),x(this,ge).length=0,U(this,me,0),U(this,Pt,0),x(this,Vt)&&x(this,At)){let s=x(this,At),o;for(;o=s?.shift();)(r=x(this,pe))==null||r.call(this,...o);}};var Rn=Fl;var sr=class{constructor(t){G(this,"cache");G(this,"map",new Map);this.cache=new Rn({max:t.cacheSize}),this.map=new Map;}get[Symbol.iterator](){return this.map[Symbol.iterator]}get[Symbol.toStringTag](){return this.map[Symbol.toStringTag]}clear(){return this.cache.clear(),this.map.clear()}delete(t){let e=this.map.delete(t);return e&&this.cache.delete(t),e}get forEach(){return this.map.forEach}get(t){let e=this.cache.get(t);return e||this.map.get(t)}has(t){return this.map.has(t)}set(t,e){return this.map.set(t,e),this.cache.set(t,e),this}get size(){return this.map.size}entries(){return this.map.entries()}keys(){return this.map.keys()}values(){return this.map.values()}};var bt=class bt{constructor(){}static clearOldTempVariables(t){bt.tempStorageDeadlines.forEach((e,r)=>{e>t&&(bt.tempStorage.delete(r),bt.tempStorageDeadlines.delete(r),bt.storage.cache.delete(r));});}static setVariable(t,e){let r=bt.tempStorage.has(t);e==null?(bt.storage.map.delete(t),!r&&bt.storage.cache.delete(t)):(bt.storage.map.set(t,e),!r&&bt.storage.cache.set(t,e));}static getVariable(t){let e=bt.storage.cache.get(t);return e===void 0&&(e=bt.tempStorage.get(t)),e===void 0&&(e=bt.storage.map.get(t)),Fn(e)}static removeVariable(t){bt.storage.delete(t);}static setFlag(t,e){if(e)this.flags.includes(t)||this.flags.push(t);else {let r=this.flags.indexOf(t);r>-1&&this.flags.splice(r,1);}}static getFlag(t){return this.flags.includes(t)}};G(bt,"storage",new sr({cacheSize:20})),G(bt,"startingStorage",[]),G(bt,"flags",Array()),G(bt,"tempStorage",new Map),G(bt,"tempStorageDeadlines",new Map);var N=bt;var bi=class{constructor(t,e){G(this,"_id");G(this,"categoryId");this.categoryId=t,this._id=e;}get id(){return this._id}setStorageProperty(t,e){let r=N.getVariable(this.categoryId);r||(r={}),r.hasOwnProperty(this.id)||(r[this.id]={}),e==null?r[this.id].hasOwnProperty(t)&&delete r[this.id][t]:r[this.id]={...r[this.id],[t]:e},Object.keys(r[this.id]).length===0&&delete r[this.id],N.setVariable(this.categoryId,r);}getStorageProperty(t,e=this.id){let r=N.getVariable(this.categoryId);if(r&&r.hasOwnProperty(e)&&r[e].hasOwnProperty(t))return r[e][t]}};var Xy="@",vi=class extends bi{constructor(e,r=""){super(lx.CHARACTER_CATEGORY_KEY,e+(r?Xy+r:""));G(this,"sourceId");this.sourceId=e;}getStorageProperty(e){let r=super.getStorageProperty(e);return r===void 0&&(r=super.getStorageProperty(e,this.sourceId)),r}};var In=class extends vi{constructor(e,r){super(typeof e=="string"?e:e.id,typeof e=="string"?"":e.emotion);G(this,"defaultName");G(this,"defaultSurname");G(this,"defaultAge");G(this,"_icon");G(this,"_color");this.defaultName=r.name,this.defaultSurname=r.surname,this.defaultAge=r.age,this._icon=r.icon,this._color=r.color;}get name(){return this.getStorageProperty("name")||this.defaultName||this.id}set name(e){this.setStorageProperty("name",e);}get surname(){return this.getStorageProperty("surname")||this.defaultSurname}set surname(e){this.setStorageProperty("surname",e);}get age(){return this.getStorageProperty("age")||this.defaultAge}set age(e){this.setStorageProperty("age",e);}get icon(){return this._icon}get color(){return this._color}};var Ds=new sr({cacheSize:10});function jy(i){return Si.add(i)}function Ky(i){return Si.get(i)}function qy(){return Si.values()}var Si;(s=>{function i(o){try{let n=Ds.get(o);if(!n){at.warn(`Character "${o}" not found, did you forget to register it with the RegisteredCharacters.add?`);return}return n}catch(n){at.error(`Error while getting Character "${o}"`,n);return}}s.get=i;function t(o){if(Array.isArray(o)){o.forEach(n=>t(n));return}Ds.get(o.id)&&at.info(`Character id "${o.id}" already exists, it will be overwritten`),Ds.set(o.id,o);}s.add=t;function e(){return Array.from(Ds.values())}s.values=e;function r(o){return Ds.has(o)}s.has=r;})(Si||(Si={}));var Zy=Si;exports.CharacterBaseModel=In;exports.CharacterStoredClass=vi;exports.RegisteredCharacters=Zy;exports.getAllCharacters=qy;exports.getCharacterById=Ky;exports.saveCharacter=jy;
|