@drincs/pixi-vn 1.2.0 → 1.2.1
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/constants.cjs +1 -1
- package/dist/constants.d.cts +1 -1
- package/dist/constants.d.ts +1 -1
- package/dist/constants.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/narration/types/HistoryChoiceMenuOption.d.cts +1 -1
- package/dist/narration/types/HistoryChoiceMenuOption.d.ts +1 -1
- package/dist/pixi-vn.d.d.cts +1 -1
- package/dist/pixi-vn.d.d.ts +1 -1
- package/package.json +1 -1
package/dist/constants.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 sh,oh,po,Zp=p(()=>{Q();Ps();Xp();Bs();ti();pe();ft();qp();po=class extends Zt{constructor(){sh??(sh=rr({name:"tiling-sprite-shader",bits:[_i,jp,sr]})),oh??(oh=ir({name:"tiling-sprite-shader",bits:[$p,Kp,or]}));let t=new Tt({uMapCoord:{value:new M,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 M,type:"mat3x3<f32>"},uSizeAnchor:{value:new Float32Array([100,100,.5,.5]),type:"vec4<f32>"}});super({glProgram:oh,gpuProgram:sh,resources:{localUniforms:new Tt({uTransformMatrix:{value:new M,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 mo,Qp=p(()=>{fo();mo=class extends yr{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 Jp(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 tm=p(()=>{});function em(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 rm=p(()=>{});function im(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=M.shared;a.copyFrom(i._tileTransform.matrix),a.tx/=i.width,a.ty/=i.height,a.invert(),a.scale(i.width/r,i.height/s),em(t,2,0,a);}var sm=p(()=>{Q();rm();});var xo,yi,om=p(()=>{k();qr();Hs();Jr();si();zs();fo();Zp();Qp();tm();sm();xo=new mo,yi=class{constructor(t){this._state=Ie.default2d,this._tilingSpriteDataHash=Object.create(null),this._destroyRenderableBound=this.destroyRenderable.bind(this),this._renderer=t,this._renderer.renderableGC.addManagedHash(this,"_tilingSpriteDataHash");}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 xe);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 po),this.updateRenderable(t),e.add(t);}execute(t){let{shader:e}=this._tilingSpriteDataHash[t.uid];e.groups[0]=this._renderer.globalUniforms.bindGroup;let r=e.resources.localUniforms.uniforms;r.uTransformMatrix=t.groupTransform,r.uRound=this._renderer._roundPixels|t._roundPixels,me(t.groupColorAlpha,r.uColor,0),this._state.blendMode=se(t.groupBlendMode,t.texture._source),this._renderer.encoder.draw({geometry:xo,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);}}destroyRenderable(t){let e=this._getTilingSpriteData(t);e.batchableMesh=null,e.shader?.destroy(),this._tilingSpriteDataHash[t.uid]=null,t.off("destroyed",this._destroyRenderableBound);}_getTilingSpriteData(t){return this._tilingSpriteDataHash[t.uid]||this._initTilingSpriteData(t)}_initTilingSpriteData(t){let e=new yr({indices:xo.indices,positions:xo.positions.slice(),uvs:xo.uvs.slice()});return this._tilingSpriteDataHash[t.uid]={canBatch:true,renderable:t,geometry:e},t.on("destroyed",this._destroyRenderableBound),this._tilingSpriteDataHash[t.uid]}_updateBatchableMesh(t){let e=this._getTilingSpriteData(t),{geometry:r}=e,s=t.texture.source.style;s.addressMode!=="repeat"&&(s.addressMode="repeat",s.update()),im(t,r.uvs),Jp(t,r.positions);}destroy(){for(let t in this._tilingSpriteDataHash)this.destroyRenderable(this._tilingSpriteDataHash[t].renderable);this._tilingSpriteDataHash=null,this._renderer=null;}_updateCanBatch(t){let e=this._getTilingSpriteData(t),r=t.texture,s=true;return this._renderer.type===qt.WEBGL&&(s=this._renderer.context.supports.nonPowOf2wrapping),e.canBatch=r.textureMatrix.isSimple&&(s||r.source.isPowerOfTwo),e.canBatch}};yi.extension={type:[T.WebGLPipes,T.WebGPUPipes,T.CanvasPipes],name:"tilingSprite"};});var nh=p(()=>{k();om();I.add(yi);});var nm,hm,lm=p(()=>{ht();fo();nm=class am extends yr{constructor(...t){super({});let e=t[0]??{};typeof e=="number"&&(G(H,"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={...am.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,m=d*this.verticesX+f,g=d*this.verticesX+f+1,x=(d+1)*this.verticesX+f,_=(d+1)*this.verticesX+f+1;o.push(m,g,x,g,_,x);}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();}};nm.defaultOptions={width:100,height:100,verticesX:10,verticesY:10};hm=nm;});var cm,dm,fm=p(()=>{lm();cm=class um extends hm{constructor(t={}){t={...um.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,m=Math.min(u,d),g=h*e,x=l*r;t[0]=t[8]=t[16]=t[24]=-g,t[2]=t[10]=t[18]=t[26]=s*m-g,t[4]=t[12]=t[20]=t[28]=e-o*m-g,t[6]=t[14]=t[22]=t[30]=e-g,t[1]=t[3]=t[5]=t[7]=-x,t[9]=t[11]=t[13]=t[15]=n*m-x,t[17]=t[19]=t[21]=t[23]=r-a*m-x,t[25]=t[27]=t[29]=t[31]=r-x,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();}};cm.defaultOptions={width:100,height:100,leftWidth:10,topHeight:10,rightWidth:10,bottomHeight:10,originalWidth:100,originalHeight:100};dm=cm;});var bi,pm=p(()=>{k();Ft();zs();fm();bi=class{constructor(t){this._gpuSpriteHash=Object.create(null),this._destroyRenderableBound=this.destroyRenderable.bind(this),this._renderer=t,this._renderer.renderableGC.addManagedHash(this,"_gpuSpriteHash");}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._gpuSpriteHash[t.uid];t.didViewUpdate&&this._updateBatchableSprite(t,e),e._batcher.updateElement(e);}validateRenderable(t){let e=this._getGpuSprite(t);return !e._batcher.checkAndUpdateTexture(e,t._texture)}destroyRenderable(t){let e=this._gpuSpriteHash[t.uid];z.return(e.geometry),z.return(e),this._gpuSpriteHash[t.uid]=null,t.off("destroyed",this._destroyRenderableBound);}_updateBatchableSprite(t,e){e.geometry.update(t),e.setTexture(t._texture);}_getGpuSprite(t){return this._gpuSpriteHash[t.uid]||this._initGPUSprite(t)}_initGPUSprite(t){let e=z.get(xe);return e.geometry=z.get(dm),e.renderable=t,e.transform=t.groupTransform,e.texture=t._texture,e.roundPixels=this._renderer._roundPixels|t._roundPixels,this._gpuSpriteHash[t.uid]=e,t.didViewUpdate||this._updateBatchableSprite(t,e),t.on("destroyed",this._destroyRenderableBound),e}destroy(){for(let t in this._gpuSpriteHash)this._gpuSpriteHash[t].geometry.destroy();this._gpuSpriteHash=null,this._renderer=null;}};bi.extension={type:[T.WebGLPipes,T.WebGPUPipes,T.CanvasPipes],name:"nineSliceSprite"};});var ah=p(()=>{k();pm();I.add(bi);});var vi,mm=p(()=>{k();vi=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;}};vi.extension={type:[T.WebGLPipes,T.WebGPUPipes,T.CanvasPipes],name:"filter"};});function xm(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 gm=p(()=>{});var Ng,Ti,_m=p(()=>{k();Q();Ut();Kr();Qr();pe();ft();Ve();Jr();Lt();gm();xt();Ng=new Kt({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])}),Ti=class{constructor(t){this._filterStackIndex=0,this._filterStack=[],this._filterGlobalUniforms=new Tt({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 It({}),this.renderer=t;}get activeBackTexture(){return this._activeFilterData?.backTexture}push(t){let e=this.renderer,r=t.filterEffect.filters;this._filterStack[this._filterStackIndex]||(this._filterStack[this._filterStackIndex]=this._getFilterData());let s=this._filterStack[this._filterStackIndex];if(this._filterStackIndex++,r.length===0){s.skip=true;return}let o=s.bounds;if(t.renderables?xm(t.renderables,o):t.filterEffect.filterArea?(o.clear(),o.addRect(t.filterEffect.filterArea),o.applyMatrix(t.container.worldTransform)):t.container.getFastGlobalBounds(true,o),t.container){let m=(t.container.renderGroup||t.container.parentRenderGroup).cacheToLocalTransform;m&&o.applyMatrix(m);}let n=e.renderTarget.renderTarget.colorTexture.source,a=1/0,h=0,l=true,c=false,u=false,f=true;for(let d=0;d<r.length;d++){let m=r[d];if(a=Math.min(a,m.resolution==="inherit"?n._resolution:m.resolution),h+=m.padding,m.antialias==="off"?l=false:m.antialias==="inherit"&&l&&(l=n.antialias),m.clipToViewport||(f=false),!!!(m.compatibleRenderers&e.type)){u=false;break}if(m.blendRequired&&!(e.backBuffer?.useBackBuffer??true)){L("Blend filter requires backBuffer on WebGL renderer to be enabled. Set `useBackBuffer: true` in the renderer options."),u=false;break}u=m.enabled||u,c||(c=m.blendRequired);}if(!u){s.skip=true;return}if(f){let d=e.renderTarget.rootViewPort,m=e.renderTarget.renderTarget.resolution;o.fitBounds(0,d.width/m,0,d.height/m);}if(o.scale(a).ceil().scale(1/a).pad(h|0),!o.isPositive){s.skip=true;return}s.skip=false,s.bounds=o,s.blendRequired=c,s.container=t.container,s.filterEffect=t.filterEffect,s.previousRenderSurface=e.renderTarget.renderSurface,s.inputTexture=gt.getOptimalTexture(o.width,o.height,a,l),e.renderTarget.bind(s.inputTexture,true),e.globalUniforms.push({offset:o});}pop(){let t=this.renderer;this._filterStackIndex--;let e=this._filterStack[this._filterStackIndex];if(e.skip)return;this._activeFilterData=e;let r=e.inputTexture,s=e.bounds,o=R.EMPTY;if(t.renderTarget.finishRenderPass(),e.blendRequired){let a=this._filterStackIndex>0?this._filterStack[this._filterStackIndex-1].bounds:null,h=t.renderTarget.getRenderTarget(e.previousRenderSurface);o=this.getBackTexture(h,s,a);}e.backTexture=o;let n=e.filterEffect.filters;if(this._globalFilterBindGroup.setResource(r.source.style,2),this._globalFilterBindGroup.setResource(o.source,3),t.globalUniforms.pop(),n.length===1)n[0].apply(this,r,e.previousRenderSurface,false),gt.returnTexture(r);else {let a=e.inputTexture,h=gt.getOptimalTexture(s.width,s.height,a.source._resolution,false),l=0;for(l=0;l<n.length-1;++l){n[l].apply(this,a,h,true);let u=a;a=h,h=u;}n[l].apply(this,a,e.previousRenderSurface,false),gt.returnTexture(a),gt.returnTexture(h);}e.blendRequired&>.returnTexture(o);}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._filterStack[this._filterStackIndex],a=n.bounds,h=V.shared,c=n.previousRenderSurface===r,u=this.renderer.renderTarget.rootRenderTarget.colorTexture.source._resolution,f=this._filterStackIndex-1;for(;f>0&&this._filterStack[f].skip;)--f;f>0&&(u=this._filterStack[f].inputTexture.source._resolution);let d=this._filterGlobalUniforms,m=d.uniforms,g=m.uOutputFrame,x=m.uInputSize,_=m.uInputPixel,y=m.uInputClamp,b=m.uGlobalFrame,v=m.uOutputTexture;if(c){let w=this._filterStackIndex;for(;w>0;){w--;let E=this._filterStack[this._filterStackIndex-1];if(!E.skip){h.x=E.bounds.minX,h.y=E.bounds.minY;break}}g[0]=a.minX-h.x,g[1]=a.minY-h.y;}else g[0]=0,g[1]=0;g[2]=e.frame.width,g[3]=e.frame.height,x[0]=e.source.width,x[1]=e.source.height,x[2]=1/x[0],x[3]=1/x[1],_[0]=e.source.pixelWidth,_[1]=e.source.pixelHeight,_[2]=1/_[0],_[3]=1/_[1],y[0]=.5*_[2],y[1]=.5*_[3],y[2]=e.frame.width*x[2]-.5*_[2],y[3]=e.frame.height*x[3]-.5*_[3];let P=this.renderer.renderTarget.rootRenderTarget.colorTexture;b[0]=h.x*u,b[1]=h.y*u,b[2]=P.source.width*u,b[3]=P.source.height*u;let S=this.renderer.renderTarget.getRenderTarget(r);if(o.renderTarget.bind(r,!!s),r instanceof R?(v[0]=r.frame.width,v[1]=r.frame.height):(v[0]=S.width,v[1]=S.height),v[2]=S.isRoot?-1:1,d.update(),o.renderPipes.uniformBatch){let w=o.renderPipes.uniformBatch.getUboResource(d);this._globalFilterBindGroup.setResource(w,0);}else this._globalFilterBindGroup.setResource(d,0);this._globalFilterBindGroup.setResource(e.source,1),this._globalFilterBindGroup.setResource(e.source.style,2),t.groups[0]=this._globalFilterBindGroup,o.encoder.draw({geometry:Ng,shader:t,state:t._state,topology:"triangle-list"}),o.type===qt.WEBGL&&o.renderTarget.finishRenderPass();}_getFilterData(){return {skip:false,inputTexture:null,bounds:new et,container:null,filterEffect:null,blendRequired:false,previousRenderSurface:null}}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(M.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}};Ti.extension={type:[T.WebGLSystem,T.WebGPUSystem],name:"filter"};});var hh=p(()=>{k();mm();_m();I.add(Ti);I.add(vi);});var Yg={};var ym=p(()=>{Jl();nn();ac();lc();ns();ds();ga();_a();Ta();Xa();th();ih();nh();ah();hh();});var $g={};var vm=p(()=>{nn();ns();ds();ga();_a();Ta();Xa();th();ih();nh();ah();hh();});var Nt={};Gm(Nt,{DistortionFilter:()=>ki,EqualizerFilter:()=>kt,Filter:()=>at,MonoFilter:()=>Ri,ReverbFilter:()=>Fi,StereoFilter:()=>Ii,StreamFilter:()=>Gi,TelephoneFilter:()=>Di});var mh;function xh(i){return mh=i,i}function $(){return mh}var at=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 ki=class extends at{constructor(t=0){let e;if(!$().useLegacy){let{audioContext:r}=$().context;e=r.createWaveShaper();}super(e),this._distortion=e,this.amount=t;}set amount(t){if(this._amount=t,$().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 st=class{static setParamValue(t,e){if(t.setValueAtTime){let r=$().context;t.setValueAtTime(e,r.audioContext.currentTime);}else t.value=e;return e}};var X=class extends at{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:X.F32,type:"lowshelf",gain:i},{f:X.F64,type:"peaking",gain:t},{f:X.F125,type:"peaking",gain:e},{f:X.F250,type:"peaking",gain:r},{f:X.F500,type:"peaking",gain:s},{f:X.F1K,type:"peaking",gain:o},{f:X.F2K,type:"peaking",gain:n},{f:X.F4K,type:"peaking",gain:a},{f:X.F8K,type:"peaking",gain:h},{f:X.F16K,type:"highshelf",gain:l}];$().useLegacy||(c=u.map(f=>{let d=$().context.audioContext.createBiquadFilter();return d.type=f.type,st.setParamValue(d.Q,1),d.frequency.value=f.f,st.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}`);st.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(X.F32,i);}get f32(){return this.getGain(X.F32)}set f64(i){this.setGain(X.F64,i);}get f64(){return this.getGain(X.F64)}set f125(i){this.setGain(X.F125,i);}get f125(){return this.getGain(X.F125)}set f250(i){this.setGain(X.F250,i);}get f250(){return this.getGain(X.F250)}set f500(i){this.setGain(X.F500,i);}get f500(){return this.getGain(X.F500)}set f1k(i){this.setGain(X.F1K,i);}get f1k(){return this.getGain(X.F1K)}set f2k(i){this.setGain(X.F2K,i);}get f2k(){return this.getGain(X.F2K)}set f4k(i){this.setGain(X.F4K,i);}get f4k(){return this.getGain(X.F4K)}set f8k(i){this.setGain(X.F8K,i);}get f8k(){return this.getGain(X.F8K)}set f16k(i){this.setGain(X.F16K,i);}get f16k(){return this.getGain(X.F16K)}reset(){this.bands.forEach(i=>{st.setParamValue(i.gain,0);});}destroy(){this.bands.forEach(i=>{i.disconnect();}),this.bands=null,this.bandsMap=null;}},kt=X;kt.F32=32;kt.F64=64;kt.F125=125;kt.F250=250;kt.F500=500;kt.F1K=1e3;kt.F2K=2e3;kt.F4K=4e3;kt.F8K=8e3;kt.F16K=16e3;var Ri=class extends at{constructor(){let t,e;if(!$().useLegacy){let{audioContext:r}=$().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 Fi=class extends at{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($().useLegacy)return;let{audioContext:t}=$().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 Ii=class extends at{constructor(t=0){let e,r,s;if(!$().useLegacy){let{audioContext:o}=$().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?st.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 Gi=class extends at{constructor(){let t,e;if(!$().useLegacy){let{audioContext:r}=$().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 Di=class extends at{constructor(){let t,e;if(!$().useLegacy){let{audioContext:r}=$().context,s=r.createBiquadFilter(),o=r.createBiquadFilter(),n=r.createBiquadFilter(),a=r.createBiquadFilter();s.type="lowpass",st.setParamValue(s.frequency,2e3),o.type="lowpass",st.setParamValue(o.frequency,2e3),n.type="highpass",st.setParamValue(n.frequency,500),a.type="highpass",st.setParamValue(a.frequency,500),s.connect(o),o.connect(n),n.connect(a),t=s,e=a;}super(t,e);}};k();var bm={extension:{type:T.Environment,name:"browser",priority:-1},test:()=>true,load:async()=>{await Promise.resolve().then(()=>(ym(),Yg));}};k();var Tm={extension:{type:T.Environment,name:"webworker",priority:0},test:()=>typeof self<"u"&&self.WorkerGlobalScope!==void 0,load:async()=>{await Promise.resolve().then(()=>(vm(),$g));}};k();k();ds();ns();mn();Ht();Mn();Ur();Mt();os();Bi(ra());I.add(bm,Tm);var Si=class extends Y{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 jg=0,lh=class extends Y{constructor(i){super(),this.id=jg++,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-lh.PADDING),this._end=Math.min(this._end+lh.PADDING,this._duration),this._source.onloadedmetadata=()=>{this._source&&(this._source.currentTime=t,this._source.onloadedmetadata=null,this.emit("progress",t/this._duration,this._duration),lt.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(){lt.shared.remove(this._onUpdate,this),this._internalStop(),this.emit("progress",1,this._duration),this.emit("end",this);}destroy(){lt.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}]`}},go=lh;go.PADDING=.1;var wi=class extends Y{init(t){this.parent=t,this._source=t.options.source||new Audio,t.url&&(this._source.src=t.url);}create(){return new go(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 Pi=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 Ue=["ogg","oga","opus","m4a","mp3","mpeg","wav","aiff","wma","mid","caf"],ch=["audio/mpeg","audio/ogg"],Le={};function Sm(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$/;Ue.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(Le,r);}Sm();var qg=0,Mi=class extends Y{constructor(t){super(),this.id=qg++,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);st.setParamValue(this._gain.gain,o*s*r),st.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){lt.shared.remove(this._updateListener,this),t&<.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 Oe=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 wm=class extends Oe{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(wm.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,st.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}},_o=wm;_o.BUFFER_SIZE=0;var He=class{init(t){this.parent=t,this._nodes=new _o(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 Mi(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 rt.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 br=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=$().useLegacy?new wi:new He;return new br(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:wt.extname(e).slice(1)})).filter(({ext:e})=>Le[e]).sort((e,r)=>Ue.indexOf(e.ext)-Ue.indexOf(r.ext));if(!t)throw new Error("No supported file type found");return t.url}get context(){return $().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 Pi(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(br._pool.length>0){let i=br._pool.pop();return i.init(this.media),i}return this.media.create()}_poolInstance(i){i.destroy(),br._pool.indexOf(i)<0&&br._pool.push(i);}},_e=br;_e._pool=[];var vr=class i extends Oe{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 Y,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 yo=class{constructor(){this.init();}init(){return this.supported&&(this._webAudioContext=new vr),this._htmlAudioContext=new Si,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 vr.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 _e)return this._sounds[t]=e,e;let r=this._getOptions(e),s=_e.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 Pm=i=>{let t=i.src,e=i?.alias?.[0];return (!e||i.src===e)&&(e=wt.basename(t,wt.extname(t))),e},Mm={extension:T.Asset,detection:{test:async()=>true,add:async i=>[...i,...Ue.filter(t=>Le[t])],remove:async i=>i.filter(t=>i.includes(t))},loader:{name:"sound",extension:{type:[T.LoadParser],priority:Xe.High},test(i){let t=wt.extname(i).slice(1);return !!Le[t]||ch.some(e=>i.startsWith(`data:${e}`))},async load(i,t){let e=await new Promise((r,s)=>_e.from({...t.data,url:i,preload:true,loaded(o,n){o?s(o):r(n),t.data?.loaded?.(o,n);}}));return $().add(Pm(t),e),e},async unload(i,t){$().remove(Pm(t));}}};I.add(Mm);xh(new yo);var t_="1.2.0";var qF="repeat";function ZF(i){return {type:"pause",duration:i}}var QF={DistortionFilter:Nt.DistortionFilter,EqualizerFilter:Nt.EqualizerFilter,MonoFilter:Nt.MonoFilter,ReverbFilter:Nt.ReverbFilter,StereoFilter:Nt.StereoFilter,StreamFilter:Nt.StreamFilter,TelephoneFilter:Nt.TelephoneFilter},JF=["webm","mp4","ogv","mov","avi","wmv","flv","mkv","3gp","mpg","mpeg","m4v","f4v","m2v","asf","vob","ts","m2ts","mts","divx","xvid","rm","rmvb","dat","swf","mpv","mxf","vcd","svcd","dvd","dv","3g2","m2p","m2ts","m2v","m4v","mpe","mpg","mpv2","ogm","qt","rm","ts","vob","wmv","xvid","flv","mkv","mov","mp4","webm","avi","ogv","m4v","f4v","m2v","asf","vob","ts","m2ts","mts","divx","xvid","rm","rmvb","dat","swf","mpv","mxf","vcd","svcd","dvd","dv","3g2","m2p","m2ts","m2v","m4v","mpe","mpg","mpv2","ogm","qt","rm","ts","vob","wmv","xvid","flv","mkv","mov","mp4","webm","avi","ogv","m4v","f4v","m2v","asf","vob"],tI="__game_layer__",eI="Container",rI="ImageContainer",iI="Image",sI="Sprite",oI="Text",nI="Video",aI={CURRENT_DIALOGUE_MEMORY_KEY:"___current_dialogue_memory___",LAST_DIALOGUE_ADDED_IN_STEP_MEMORY_KEY:"___last_dialogue_added_in_step_memory___",CURRENT_MENU_OPTIONS_MEMORY_KEY:"___current_menu_options_memory___",LAST_MENU_OPTIONS_ADDED_IN_STEP_MEMORY_KEY:"___last_menu_options_added_in_step_memory___",CURRENT_INPUT_VALUE_MEMORY_KEY:"_input_value_",LAST_INPUT_ADDED_IN_STEP_MEMORY_KEY:"___last_input_added_in_step_memory___",CURRENT_INPUT_INFO_MEMORY_KEY:"___current_input_info_memory___",CHARACTER_CATEGORY_KEY:"___character___",ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY:"___glue___",OPENED_LABELS_COUNTER_KEY:"___opened_labels_counter___",ALL_CHOICES_MADE_KEY:"___all_choices_made___",CURRENT_STEP_TIMES_COUNTER_KEY:"___current_step_times_counter___",LAST_STEP_GLUED:"___last_step_glued___"};exports.CANVAS_APP_GAME_LAYER_ALIAS=tI;exports.CANVAS_CONTAINER_ID=eI;exports.CANVAS_IMAGE_CONTAINER_ID=rI;exports.CANVAS_IMAGE_ID=iI;exports.CANVAS_SPRITE_ID=sI;exports.CANVAS_TEXT_ID=oI;exports.CANVAS_VIDEO_ID=nI;exports.PIXIVN_VERSION=t_;exports.Pause=ZF;exports.Repeat=qF;exports.SYSTEM_RESERVED_STORAGE_KEYS=aI;exports.filters=QF;exports.videoFormats=JF;
|
|
569
|
+
`}};});var sh,oh,po,Zp=p(()=>{Q();Ps();Xp();Bs();ti();pe();ft();qp();po=class extends Zt{constructor(){sh??(sh=rr({name:"tiling-sprite-shader",bits:[_i,jp,sr]})),oh??(oh=ir({name:"tiling-sprite-shader",bits:[$p,Kp,or]}));let t=new Tt({uMapCoord:{value:new M,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 M,type:"mat3x3<f32>"},uSizeAnchor:{value:new Float32Array([100,100,.5,.5]),type:"vec4<f32>"}});super({glProgram:oh,gpuProgram:sh,resources:{localUniforms:new Tt({uTransformMatrix:{value:new M,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 mo,Qp=p(()=>{fo();mo=class extends yr{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 Jp(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 tm=p(()=>{});function em(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 rm=p(()=>{});function im(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=M.shared;a.copyFrom(i._tileTransform.matrix),a.tx/=i.width,a.ty/=i.height,a.invert(),a.scale(i.width/r,i.height/s),em(t,2,0,a);}var sm=p(()=>{Q();rm();});var xo,yi,om=p(()=>{k();qr();Hs();Jr();si();zs();fo();Zp();Qp();tm();sm();xo=new mo,yi=class{constructor(t){this._state=Ie.default2d,this._tilingSpriteDataHash=Object.create(null),this._destroyRenderableBound=this.destroyRenderable.bind(this),this._renderer=t,this._renderer.renderableGC.addManagedHash(this,"_tilingSpriteDataHash");}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 xe);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 po),this.updateRenderable(t),e.add(t);}execute(t){let{shader:e}=this._tilingSpriteDataHash[t.uid];e.groups[0]=this._renderer.globalUniforms.bindGroup;let r=e.resources.localUniforms.uniforms;r.uTransformMatrix=t.groupTransform,r.uRound=this._renderer._roundPixels|t._roundPixels,me(t.groupColorAlpha,r.uColor,0),this._state.blendMode=se(t.groupBlendMode,t.texture._source),this._renderer.encoder.draw({geometry:xo,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);}}destroyRenderable(t){let e=this._getTilingSpriteData(t);e.batchableMesh=null,e.shader?.destroy(),this._tilingSpriteDataHash[t.uid]=null,t.off("destroyed",this._destroyRenderableBound);}_getTilingSpriteData(t){return this._tilingSpriteDataHash[t.uid]||this._initTilingSpriteData(t)}_initTilingSpriteData(t){let e=new yr({indices:xo.indices,positions:xo.positions.slice(),uvs:xo.uvs.slice()});return this._tilingSpriteDataHash[t.uid]={canBatch:true,renderable:t,geometry:e},t.on("destroyed",this._destroyRenderableBound),this._tilingSpriteDataHash[t.uid]}_updateBatchableMesh(t){let e=this._getTilingSpriteData(t),{geometry:r}=e,s=t.texture.source.style;s.addressMode!=="repeat"&&(s.addressMode="repeat",s.update()),im(t,r.uvs),Jp(t,r.positions);}destroy(){for(let t in this._tilingSpriteDataHash)this.destroyRenderable(this._tilingSpriteDataHash[t].renderable);this._tilingSpriteDataHash=null,this._renderer=null;}_updateCanBatch(t){let e=this._getTilingSpriteData(t),r=t.texture,s=true;return this._renderer.type===qt.WEBGL&&(s=this._renderer.context.supports.nonPowOf2wrapping),e.canBatch=r.textureMatrix.isSimple&&(s||r.source.isPowerOfTwo),e.canBatch}};yi.extension={type:[T.WebGLPipes,T.WebGPUPipes,T.CanvasPipes],name:"tilingSprite"};});var nh=p(()=>{k();om();I.add(yi);});var nm,hm,lm=p(()=>{ht();fo();nm=class am extends yr{constructor(...t){super({});let e=t[0]??{};typeof e=="number"&&(G(H,"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={...am.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,m=d*this.verticesX+f,g=d*this.verticesX+f+1,x=(d+1)*this.verticesX+f,_=(d+1)*this.verticesX+f+1;o.push(m,g,x,g,_,x);}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();}};nm.defaultOptions={width:100,height:100,verticesX:10,verticesY:10};hm=nm;});var cm,dm,fm=p(()=>{lm();cm=class um extends hm{constructor(t={}){t={...um.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,m=Math.min(u,d),g=h*e,x=l*r;t[0]=t[8]=t[16]=t[24]=-g,t[2]=t[10]=t[18]=t[26]=s*m-g,t[4]=t[12]=t[20]=t[28]=e-o*m-g,t[6]=t[14]=t[22]=t[30]=e-g,t[1]=t[3]=t[5]=t[7]=-x,t[9]=t[11]=t[13]=t[15]=n*m-x,t[17]=t[19]=t[21]=t[23]=r-a*m-x,t[25]=t[27]=t[29]=t[31]=r-x,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();}};cm.defaultOptions={width:100,height:100,leftWidth:10,topHeight:10,rightWidth:10,bottomHeight:10,originalWidth:100,originalHeight:100};dm=cm;});var bi,pm=p(()=>{k();Ft();zs();fm();bi=class{constructor(t){this._gpuSpriteHash=Object.create(null),this._destroyRenderableBound=this.destroyRenderable.bind(this),this._renderer=t,this._renderer.renderableGC.addManagedHash(this,"_gpuSpriteHash");}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._gpuSpriteHash[t.uid];t.didViewUpdate&&this._updateBatchableSprite(t,e),e._batcher.updateElement(e);}validateRenderable(t){let e=this._getGpuSprite(t);return !e._batcher.checkAndUpdateTexture(e,t._texture)}destroyRenderable(t){let e=this._gpuSpriteHash[t.uid];z.return(e.geometry),z.return(e),this._gpuSpriteHash[t.uid]=null,t.off("destroyed",this._destroyRenderableBound);}_updateBatchableSprite(t,e){e.geometry.update(t),e.setTexture(t._texture);}_getGpuSprite(t){return this._gpuSpriteHash[t.uid]||this._initGPUSprite(t)}_initGPUSprite(t){let e=z.get(xe);return e.geometry=z.get(dm),e.renderable=t,e.transform=t.groupTransform,e.texture=t._texture,e.roundPixels=this._renderer._roundPixels|t._roundPixels,this._gpuSpriteHash[t.uid]=e,t.didViewUpdate||this._updateBatchableSprite(t,e),t.on("destroyed",this._destroyRenderableBound),e}destroy(){for(let t in this._gpuSpriteHash)this._gpuSpriteHash[t].geometry.destroy();this._gpuSpriteHash=null,this._renderer=null;}};bi.extension={type:[T.WebGLPipes,T.WebGPUPipes,T.CanvasPipes],name:"nineSliceSprite"};});var ah=p(()=>{k();pm();I.add(bi);});var vi,mm=p(()=>{k();vi=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;}};vi.extension={type:[T.WebGLPipes,T.WebGPUPipes,T.CanvasPipes],name:"filter"};});function xm(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 gm=p(()=>{});var Ng,Ti,_m=p(()=>{k();Q();Ut();Kr();Qr();pe();ft();Ve();Jr();Lt();gm();xt();Ng=new Kt({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])}),Ti=class{constructor(t){this._filterStackIndex=0,this._filterStack=[],this._filterGlobalUniforms=new Tt({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 It({}),this.renderer=t;}get activeBackTexture(){return this._activeFilterData?.backTexture}push(t){let e=this.renderer,r=t.filterEffect.filters;this._filterStack[this._filterStackIndex]||(this._filterStack[this._filterStackIndex]=this._getFilterData());let s=this._filterStack[this._filterStackIndex];if(this._filterStackIndex++,r.length===0){s.skip=true;return}let o=s.bounds;if(t.renderables?xm(t.renderables,o):t.filterEffect.filterArea?(o.clear(),o.addRect(t.filterEffect.filterArea),o.applyMatrix(t.container.worldTransform)):t.container.getFastGlobalBounds(true,o),t.container){let m=(t.container.renderGroup||t.container.parentRenderGroup).cacheToLocalTransform;m&&o.applyMatrix(m);}let n=e.renderTarget.renderTarget.colorTexture.source,a=1/0,h=0,l=true,c=false,u=false,f=true;for(let d=0;d<r.length;d++){let m=r[d];if(a=Math.min(a,m.resolution==="inherit"?n._resolution:m.resolution),h+=m.padding,m.antialias==="off"?l=false:m.antialias==="inherit"&&l&&(l=n.antialias),m.clipToViewport||(f=false),!!!(m.compatibleRenderers&e.type)){u=false;break}if(m.blendRequired&&!(e.backBuffer?.useBackBuffer??true)){L("Blend filter requires backBuffer on WebGL renderer to be enabled. Set `useBackBuffer: true` in the renderer options."),u=false;break}u=m.enabled||u,c||(c=m.blendRequired);}if(!u){s.skip=true;return}if(f){let d=e.renderTarget.rootViewPort,m=e.renderTarget.renderTarget.resolution;o.fitBounds(0,d.width/m,0,d.height/m);}if(o.scale(a).ceil().scale(1/a).pad(h|0),!o.isPositive){s.skip=true;return}s.skip=false,s.bounds=o,s.blendRequired=c,s.container=t.container,s.filterEffect=t.filterEffect,s.previousRenderSurface=e.renderTarget.renderSurface,s.inputTexture=gt.getOptimalTexture(o.width,o.height,a,l),e.renderTarget.bind(s.inputTexture,true),e.globalUniforms.push({offset:o});}pop(){let t=this.renderer;this._filterStackIndex--;let e=this._filterStack[this._filterStackIndex];if(e.skip)return;this._activeFilterData=e;let r=e.inputTexture,s=e.bounds,o=R.EMPTY;if(t.renderTarget.finishRenderPass(),e.blendRequired){let a=this._filterStackIndex>0?this._filterStack[this._filterStackIndex-1].bounds:null,h=t.renderTarget.getRenderTarget(e.previousRenderSurface);o=this.getBackTexture(h,s,a);}e.backTexture=o;let n=e.filterEffect.filters;if(this._globalFilterBindGroup.setResource(r.source.style,2),this._globalFilterBindGroup.setResource(o.source,3),t.globalUniforms.pop(),n.length===1)n[0].apply(this,r,e.previousRenderSurface,false),gt.returnTexture(r);else {let a=e.inputTexture,h=gt.getOptimalTexture(s.width,s.height,a.source._resolution,false),l=0;for(l=0;l<n.length-1;++l){n[l].apply(this,a,h,true);let u=a;a=h,h=u;}n[l].apply(this,a,e.previousRenderSurface,false),gt.returnTexture(a),gt.returnTexture(h);}e.blendRequired&>.returnTexture(o);}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._filterStack[this._filterStackIndex],a=n.bounds,h=V.shared,c=n.previousRenderSurface===r,u=this.renderer.renderTarget.rootRenderTarget.colorTexture.source._resolution,f=this._filterStackIndex-1;for(;f>0&&this._filterStack[f].skip;)--f;f>0&&(u=this._filterStack[f].inputTexture.source._resolution);let d=this._filterGlobalUniforms,m=d.uniforms,g=m.uOutputFrame,x=m.uInputSize,_=m.uInputPixel,y=m.uInputClamp,b=m.uGlobalFrame,v=m.uOutputTexture;if(c){let w=this._filterStackIndex;for(;w>0;){w--;let E=this._filterStack[this._filterStackIndex-1];if(!E.skip){h.x=E.bounds.minX,h.y=E.bounds.minY;break}}g[0]=a.minX-h.x,g[1]=a.minY-h.y;}else g[0]=0,g[1]=0;g[2]=e.frame.width,g[3]=e.frame.height,x[0]=e.source.width,x[1]=e.source.height,x[2]=1/x[0],x[3]=1/x[1],_[0]=e.source.pixelWidth,_[1]=e.source.pixelHeight,_[2]=1/_[0],_[3]=1/_[1],y[0]=.5*_[2],y[1]=.5*_[3],y[2]=e.frame.width*x[2]-.5*_[2],y[3]=e.frame.height*x[3]-.5*_[3];let P=this.renderer.renderTarget.rootRenderTarget.colorTexture;b[0]=h.x*u,b[1]=h.y*u,b[2]=P.source.width*u,b[3]=P.source.height*u;let S=this.renderer.renderTarget.getRenderTarget(r);if(o.renderTarget.bind(r,!!s),r instanceof R?(v[0]=r.frame.width,v[1]=r.frame.height):(v[0]=S.width,v[1]=S.height),v[2]=S.isRoot?-1:1,d.update(),o.renderPipes.uniformBatch){let w=o.renderPipes.uniformBatch.getUboResource(d);this._globalFilterBindGroup.setResource(w,0);}else this._globalFilterBindGroup.setResource(d,0);this._globalFilterBindGroup.setResource(e.source,1),this._globalFilterBindGroup.setResource(e.source.style,2),t.groups[0]=this._globalFilterBindGroup,o.encoder.draw({geometry:Ng,shader:t,state:t._state,topology:"triangle-list"}),o.type===qt.WEBGL&&o.renderTarget.finishRenderPass();}_getFilterData(){return {skip:false,inputTexture:null,bounds:new et,container:null,filterEffect:null,blendRequired:false,previousRenderSurface:null}}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(M.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}};Ti.extension={type:[T.WebGLSystem,T.WebGPUSystem],name:"filter"};});var hh=p(()=>{k();mm();_m();I.add(Ti);I.add(vi);});var Yg={};var ym=p(()=>{Jl();nn();ac();lc();ns();ds();ga();_a();Ta();Xa();th();ih();nh();ah();hh();});var $g={};var vm=p(()=>{nn();ns();ds();ga();_a();Ta();Xa();th();ih();nh();ah();hh();});var Nt={};Gm(Nt,{DistortionFilter:()=>ki,EqualizerFilter:()=>kt,Filter:()=>at,MonoFilter:()=>Ri,ReverbFilter:()=>Fi,StereoFilter:()=>Ii,StreamFilter:()=>Gi,TelephoneFilter:()=>Di});var mh;function xh(i){return mh=i,i}function $(){return mh}var at=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 ki=class extends at{constructor(t=0){let e;if(!$().useLegacy){let{audioContext:r}=$().context;e=r.createWaveShaper();}super(e),this._distortion=e,this.amount=t;}set amount(t){if(this._amount=t,$().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 st=class{static setParamValue(t,e){if(t.setValueAtTime){let r=$().context;t.setValueAtTime(e,r.audioContext.currentTime);}else t.value=e;return e}};var X=class extends at{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:X.F32,type:"lowshelf",gain:i},{f:X.F64,type:"peaking",gain:t},{f:X.F125,type:"peaking",gain:e},{f:X.F250,type:"peaking",gain:r},{f:X.F500,type:"peaking",gain:s},{f:X.F1K,type:"peaking",gain:o},{f:X.F2K,type:"peaking",gain:n},{f:X.F4K,type:"peaking",gain:a},{f:X.F8K,type:"peaking",gain:h},{f:X.F16K,type:"highshelf",gain:l}];$().useLegacy||(c=u.map(f=>{let d=$().context.audioContext.createBiquadFilter();return d.type=f.type,st.setParamValue(d.Q,1),d.frequency.value=f.f,st.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}`);st.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(X.F32,i);}get f32(){return this.getGain(X.F32)}set f64(i){this.setGain(X.F64,i);}get f64(){return this.getGain(X.F64)}set f125(i){this.setGain(X.F125,i);}get f125(){return this.getGain(X.F125)}set f250(i){this.setGain(X.F250,i);}get f250(){return this.getGain(X.F250)}set f500(i){this.setGain(X.F500,i);}get f500(){return this.getGain(X.F500)}set f1k(i){this.setGain(X.F1K,i);}get f1k(){return this.getGain(X.F1K)}set f2k(i){this.setGain(X.F2K,i);}get f2k(){return this.getGain(X.F2K)}set f4k(i){this.setGain(X.F4K,i);}get f4k(){return this.getGain(X.F4K)}set f8k(i){this.setGain(X.F8K,i);}get f8k(){return this.getGain(X.F8K)}set f16k(i){this.setGain(X.F16K,i);}get f16k(){return this.getGain(X.F16K)}reset(){this.bands.forEach(i=>{st.setParamValue(i.gain,0);});}destroy(){this.bands.forEach(i=>{i.disconnect();}),this.bands=null,this.bandsMap=null;}},kt=X;kt.F32=32;kt.F64=64;kt.F125=125;kt.F250=250;kt.F500=500;kt.F1K=1e3;kt.F2K=2e3;kt.F4K=4e3;kt.F8K=8e3;kt.F16K=16e3;var Ri=class extends at{constructor(){let t,e;if(!$().useLegacy){let{audioContext:r}=$().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 Fi=class extends at{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($().useLegacy)return;let{audioContext:t}=$().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 Ii=class extends at{constructor(t=0){let e,r,s;if(!$().useLegacy){let{audioContext:o}=$().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?st.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 Gi=class extends at{constructor(){let t,e;if(!$().useLegacy){let{audioContext:r}=$().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 Di=class extends at{constructor(){let t,e;if(!$().useLegacy){let{audioContext:r}=$().context,s=r.createBiquadFilter(),o=r.createBiquadFilter(),n=r.createBiquadFilter(),a=r.createBiquadFilter();s.type="lowpass",st.setParamValue(s.frequency,2e3),o.type="lowpass",st.setParamValue(o.frequency,2e3),n.type="highpass",st.setParamValue(n.frequency,500),a.type="highpass",st.setParamValue(a.frequency,500),s.connect(o),o.connect(n),n.connect(a),t=s,e=a;}super(t,e);}};k();var bm={extension:{type:T.Environment,name:"browser",priority:-1},test:()=>true,load:async()=>{await Promise.resolve().then(()=>(ym(),Yg));}};k();var Tm={extension:{type:T.Environment,name:"webworker",priority:0},test:()=>typeof self<"u"&&self.WorkerGlobalScope!==void 0,load:async()=>{await Promise.resolve().then(()=>(vm(),$g));}};k();k();ds();ns();mn();Ht();Mn();Ur();Mt();os();Bi(ra());I.add(bm,Tm);var Si=class extends Y{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 jg=0,lh=class extends Y{constructor(i){super(),this.id=jg++,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-lh.PADDING),this._end=Math.min(this._end+lh.PADDING,this._duration),this._source.onloadedmetadata=()=>{this._source&&(this._source.currentTime=t,this._source.onloadedmetadata=null,this.emit("progress",t/this._duration,this._duration),lt.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(){lt.shared.remove(this._onUpdate,this),this._internalStop(),this.emit("progress",1,this._duration),this.emit("end",this);}destroy(){lt.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}]`}},go=lh;go.PADDING=.1;var wi=class extends Y{init(t){this.parent=t,this._source=t.options.source||new Audio,t.url&&(this._source.src=t.url);}create(){return new go(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 Pi=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 Ue=["ogg","oga","opus","m4a","mp3","mpeg","wav","aiff","wma","mid","caf"],ch=["audio/mpeg","audio/ogg"],Le={};function Sm(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$/;Ue.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(Le,r);}Sm();var qg=0,Mi=class extends Y{constructor(t){super(),this.id=qg++,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);st.setParamValue(this._gain.gain,o*s*r),st.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){lt.shared.remove(this._updateListener,this),t&<.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 Oe=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 wm=class extends Oe{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(wm.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,st.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}},_o=wm;_o.BUFFER_SIZE=0;var He=class{init(t){this.parent=t,this._nodes=new _o(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 Mi(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 rt.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 br=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=$().useLegacy?new wi:new He;return new br(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:wt.extname(e).slice(1)})).filter(({ext:e})=>Le[e]).sort((e,r)=>Ue.indexOf(e.ext)-Ue.indexOf(r.ext));if(!t)throw new Error("No supported file type found");return t.url}get context(){return $().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 Pi(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(br._pool.length>0){let i=br._pool.pop();return i.init(this.media),i}return this.media.create()}_poolInstance(i){i.destroy(),br._pool.indexOf(i)<0&&br._pool.push(i);}},_e=br;_e._pool=[];var vr=class i extends Oe{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 Y,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 yo=class{constructor(){this.init();}init(){return this.supported&&(this._webAudioContext=new vr),this._htmlAudioContext=new Si,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 vr.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 _e)return this._sounds[t]=e,e;let r=this._getOptions(e),s=_e.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 Pm=i=>{let t=i.src,e=i?.alias?.[0];return (!e||i.src===e)&&(e=wt.basename(t,wt.extname(t))),e},Mm={extension:T.Asset,detection:{test:async()=>true,add:async i=>[...i,...Ue.filter(t=>Le[t])],remove:async i=>i.filter(t=>i.includes(t))},loader:{name:"sound",extension:{type:[T.LoadParser],priority:Xe.High},test(i){let t=wt.extname(i).slice(1);return !!Le[t]||ch.some(e=>i.startsWith(`data:${e}`))},async load(i,t){let e=await new Promise((r,s)=>_e.from({...t.data,url:i,preload:true,loaded(o,n){o?s(o):r(n),t.data?.loaded?.(o,n);}}));return $().add(Pm(t),e),e},async unload(i,t){$().remove(Pm(t));}}};I.add(Mm);xh(new yo);var t_="1.2.1";var qF="repeat";function ZF(i){return {type:"pause",duration:i}}var QF={DistortionFilter:Nt.DistortionFilter,EqualizerFilter:Nt.EqualizerFilter,MonoFilter:Nt.MonoFilter,ReverbFilter:Nt.ReverbFilter,StereoFilter:Nt.StereoFilter,StreamFilter:Nt.StreamFilter,TelephoneFilter:Nt.TelephoneFilter},JF=["webm","mp4","ogv","mov","avi","wmv","flv","mkv","3gp","mpg","mpeg","m4v","f4v","m2v","asf","vob","ts","m2ts","mts","divx","xvid","rm","rmvb","dat","swf","mpv","mxf","vcd","svcd","dvd","dv","3g2","m2p","m2ts","m2v","m4v","mpe","mpg","mpv2","ogm","qt","rm","ts","vob","wmv","xvid","flv","mkv","mov","mp4","webm","avi","ogv","m4v","f4v","m2v","asf","vob","ts","m2ts","mts","divx","xvid","rm","rmvb","dat","swf","mpv","mxf","vcd","svcd","dvd","dv","3g2","m2p","m2ts","m2v","m4v","mpe","mpg","mpv2","ogm","qt","rm","ts","vob","wmv","xvid","flv","mkv","mov","mp4","webm","avi","ogv","m4v","f4v","m2v","asf","vob"],tI="__game_layer__",eI="Container",rI="ImageContainer",iI="Image",sI="Sprite",oI="Text",nI="Video",aI={CURRENT_DIALOGUE_MEMORY_KEY:"___current_dialogue_memory___",LAST_DIALOGUE_ADDED_IN_STEP_MEMORY_KEY:"___last_dialogue_added_in_step_memory___",CURRENT_MENU_OPTIONS_MEMORY_KEY:"___current_menu_options_memory___",LAST_MENU_OPTIONS_ADDED_IN_STEP_MEMORY_KEY:"___last_menu_options_added_in_step_memory___",CURRENT_INPUT_VALUE_MEMORY_KEY:"_input_value_",LAST_INPUT_ADDED_IN_STEP_MEMORY_KEY:"___last_input_added_in_step_memory___",CURRENT_INPUT_INFO_MEMORY_KEY:"___current_input_info_memory___",CHARACTER_CATEGORY_KEY:"___character___",ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY:"___glue___",OPENED_LABELS_COUNTER_KEY:"___opened_labels_counter___",ALL_CHOICES_MADE_KEY:"___all_choices_made___",CURRENT_STEP_TIMES_COUNTER_KEY:"___current_step_times_counter___",LAST_STEP_GLUED:"___last_step_glued___"};exports.CANVAS_APP_GAME_LAYER_ALIAS=tI;exports.CANVAS_CONTAINER_ID=eI;exports.CANVAS_IMAGE_CONTAINER_ID=rI;exports.CANVAS_IMAGE_ID=iI;exports.CANVAS_SPRITE_ID=sI;exports.CANVAS_TEXT_ID=oI;exports.CANVAS_VIDEO_ID=nI;exports.PIXIVN_VERSION=t_;exports.Pause=ZF;exports.Repeat=qF;exports.SYSTEM_RESERVED_STORAGE_KEYS=aI;exports.filters=QF;exports.videoFormats=JF;
|
package/dist/constants.d.cts
CHANGED
|
@@ -2,7 +2,7 @@ import { filters as filters$1 } from '@pixi/sound';
|
|
|
2
2
|
import { PauseType } from './canvas/types/PauseType.cjs';
|
|
3
3
|
import { RepeatType } from './canvas/types/RepeatType.cjs';
|
|
4
4
|
|
|
5
|
-
var version = "1.2.
|
|
5
|
+
var version = "1.2.1";
|
|
6
6
|
|
|
7
7
|
declare const Repeat: RepeatType;
|
|
8
8
|
/**
|
package/dist/constants.d.ts
CHANGED
package/dist/constants.js
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 sh,oh,po,Zp=p(()=>{Q();Ps();Xp();Bs();ti();pe();ft();qp();po=class extends Zt{constructor(){sh??(sh=rr({name:"tiling-sprite-shader",bits:[_i,jp,sr]})),oh??(oh=ir({name:"tiling-sprite-shader",bits:[$p,Kp,or]}));let t=new Tt({uMapCoord:{value:new M,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 M,type:"mat3x3<f32>"},uSizeAnchor:{value:new Float32Array([100,100,.5,.5]),type:"vec4<f32>"}});super({glProgram:oh,gpuProgram:sh,resources:{localUniforms:new Tt({uTransformMatrix:{value:new M,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 mo,Qp=p(()=>{fo();mo=class extends yr{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 Jp(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 tm=p(()=>{});function em(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 rm=p(()=>{});function im(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=M.shared;a.copyFrom(i._tileTransform.matrix),a.tx/=i.width,a.ty/=i.height,a.invert(),a.scale(i.width/r,i.height/s),em(t,2,0,a);}var sm=p(()=>{Q();rm();});var xo,yi,om=p(()=>{k();qr();Hs();Jr();si();zs();fo();Zp();Qp();tm();sm();xo=new mo,yi=class{constructor(t){this._state=Ie.default2d,this._tilingSpriteDataHash=Object.create(null),this._destroyRenderableBound=this.destroyRenderable.bind(this),this._renderer=t,this._renderer.renderableGC.addManagedHash(this,"_tilingSpriteDataHash");}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 xe);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 po),this.updateRenderable(t),e.add(t);}execute(t){let{shader:e}=this._tilingSpriteDataHash[t.uid];e.groups[0]=this._renderer.globalUniforms.bindGroup;let r=e.resources.localUniforms.uniforms;r.uTransformMatrix=t.groupTransform,r.uRound=this._renderer._roundPixels|t._roundPixels,me(t.groupColorAlpha,r.uColor,0),this._state.blendMode=se(t.groupBlendMode,t.texture._source),this._renderer.encoder.draw({geometry:xo,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);}}destroyRenderable(t){let e=this._getTilingSpriteData(t);e.batchableMesh=null,e.shader?.destroy(),this._tilingSpriteDataHash[t.uid]=null,t.off("destroyed",this._destroyRenderableBound);}_getTilingSpriteData(t){return this._tilingSpriteDataHash[t.uid]||this._initTilingSpriteData(t)}_initTilingSpriteData(t){let e=new yr({indices:xo.indices,positions:xo.positions.slice(),uvs:xo.uvs.slice()});return this._tilingSpriteDataHash[t.uid]={canBatch:true,renderable:t,geometry:e},t.on("destroyed",this._destroyRenderableBound),this._tilingSpriteDataHash[t.uid]}_updateBatchableMesh(t){let e=this._getTilingSpriteData(t),{geometry:r}=e,s=t.texture.source.style;s.addressMode!=="repeat"&&(s.addressMode="repeat",s.update()),im(t,r.uvs),Jp(t,r.positions);}destroy(){for(let t in this._tilingSpriteDataHash)this.destroyRenderable(this._tilingSpriteDataHash[t].renderable);this._tilingSpriteDataHash=null,this._renderer=null;}_updateCanBatch(t){let e=this._getTilingSpriteData(t),r=t.texture,s=true;return this._renderer.type===qt.WEBGL&&(s=this._renderer.context.supports.nonPowOf2wrapping),e.canBatch=r.textureMatrix.isSimple&&(s||r.source.isPowerOfTwo),e.canBatch}};yi.extension={type:[T.WebGLPipes,T.WebGPUPipes,T.CanvasPipes],name:"tilingSprite"};});var nh=p(()=>{k();om();I.add(yi);});var nm,hm,lm=p(()=>{ht();fo();nm=class am extends yr{constructor(...t){super({});let e=t[0]??{};typeof e=="number"&&(G(H,"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={...am.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,m=d*this.verticesX+f,g=d*this.verticesX+f+1,x=(d+1)*this.verticesX+f,_=(d+1)*this.verticesX+f+1;o.push(m,g,x,g,_,x);}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();}};nm.defaultOptions={width:100,height:100,verticesX:10,verticesY:10};hm=nm;});var cm,dm,fm=p(()=>{lm();cm=class um extends hm{constructor(t={}){t={...um.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,m=Math.min(u,d),g=h*e,x=l*r;t[0]=t[8]=t[16]=t[24]=-g,t[2]=t[10]=t[18]=t[26]=s*m-g,t[4]=t[12]=t[20]=t[28]=e-o*m-g,t[6]=t[14]=t[22]=t[30]=e-g,t[1]=t[3]=t[5]=t[7]=-x,t[9]=t[11]=t[13]=t[15]=n*m-x,t[17]=t[19]=t[21]=t[23]=r-a*m-x,t[25]=t[27]=t[29]=t[31]=r-x,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();}};cm.defaultOptions={width:100,height:100,leftWidth:10,topHeight:10,rightWidth:10,bottomHeight:10,originalWidth:100,originalHeight:100};dm=cm;});var bi,pm=p(()=>{k();Ft();zs();fm();bi=class{constructor(t){this._gpuSpriteHash=Object.create(null),this._destroyRenderableBound=this.destroyRenderable.bind(this),this._renderer=t,this._renderer.renderableGC.addManagedHash(this,"_gpuSpriteHash");}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._gpuSpriteHash[t.uid];t.didViewUpdate&&this._updateBatchableSprite(t,e),e._batcher.updateElement(e);}validateRenderable(t){let e=this._getGpuSprite(t);return !e._batcher.checkAndUpdateTexture(e,t._texture)}destroyRenderable(t){let e=this._gpuSpriteHash[t.uid];z.return(e.geometry),z.return(e),this._gpuSpriteHash[t.uid]=null,t.off("destroyed",this._destroyRenderableBound);}_updateBatchableSprite(t,e){e.geometry.update(t),e.setTexture(t._texture);}_getGpuSprite(t){return this._gpuSpriteHash[t.uid]||this._initGPUSprite(t)}_initGPUSprite(t){let e=z.get(xe);return e.geometry=z.get(dm),e.renderable=t,e.transform=t.groupTransform,e.texture=t._texture,e.roundPixels=this._renderer._roundPixels|t._roundPixels,this._gpuSpriteHash[t.uid]=e,t.didViewUpdate||this._updateBatchableSprite(t,e),t.on("destroyed",this._destroyRenderableBound),e}destroy(){for(let t in this._gpuSpriteHash)this._gpuSpriteHash[t].geometry.destroy();this._gpuSpriteHash=null,this._renderer=null;}};bi.extension={type:[T.WebGLPipes,T.WebGPUPipes,T.CanvasPipes],name:"nineSliceSprite"};});var ah=p(()=>{k();pm();I.add(bi);});var vi,mm=p(()=>{k();vi=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;}};vi.extension={type:[T.WebGLPipes,T.WebGPUPipes,T.CanvasPipes],name:"filter"};});function xm(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 gm=p(()=>{});var Ng,Ti,_m=p(()=>{k();Q();Ut();Kr();Qr();pe();ft();Ve();Jr();Lt();gm();xt();Ng=new Kt({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])}),Ti=class{constructor(t){this._filterStackIndex=0,this._filterStack=[],this._filterGlobalUniforms=new Tt({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 It({}),this.renderer=t;}get activeBackTexture(){return this._activeFilterData?.backTexture}push(t){let e=this.renderer,r=t.filterEffect.filters;this._filterStack[this._filterStackIndex]||(this._filterStack[this._filterStackIndex]=this._getFilterData());let s=this._filterStack[this._filterStackIndex];if(this._filterStackIndex++,r.length===0){s.skip=true;return}let o=s.bounds;if(t.renderables?xm(t.renderables,o):t.filterEffect.filterArea?(o.clear(),o.addRect(t.filterEffect.filterArea),o.applyMatrix(t.container.worldTransform)):t.container.getFastGlobalBounds(true,o),t.container){let m=(t.container.renderGroup||t.container.parentRenderGroup).cacheToLocalTransform;m&&o.applyMatrix(m);}let n=e.renderTarget.renderTarget.colorTexture.source,a=1/0,h=0,l=true,c=false,u=false,f=true;for(let d=0;d<r.length;d++){let m=r[d];if(a=Math.min(a,m.resolution==="inherit"?n._resolution:m.resolution),h+=m.padding,m.antialias==="off"?l=false:m.antialias==="inherit"&&l&&(l=n.antialias),m.clipToViewport||(f=false),!!!(m.compatibleRenderers&e.type)){u=false;break}if(m.blendRequired&&!(e.backBuffer?.useBackBuffer??true)){L("Blend filter requires backBuffer on WebGL renderer to be enabled. Set `useBackBuffer: true` in the renderer options."),u=false;break}u=m.enabled||u,c||(c=m.blendRequired);}if(!u){s.skip=true;return}if(f){let d=e.renderTarget.rootViewPort,m=e.renderTarget.renderTarget.resolution;o.fitBounds(0,d.width/m,0,d.height/m);}if(o.scale(a).ceil().scale(1/a).pad(h|0),!o.isPositive){s.skip=true;return}s.skip=false,s.bounds=o,s.blendRequired=c,s.container=t.container,s.filterEffect=t.filterEffect,s.previousRenderSurface=e.renderTarget.renderSurface,s.inputTexture=gt.getOptimalTexture(o.width,o.height,a,l),e.renderTarget.bind(s.inputTexture,true),e.globalUniforms.push({offset:o});}pop(){let t=this.renderer;this._filterStackIndex--;let e=this._filterStack[this._filterStackIndex];if(e.skip)return;this._activeFilterData=e;let r=e.inputTexture,s=e.bounds,o=R.EMPTY;if(t.renderTarget.finishRenderPass(),e.blendRequired){let a=this._filterStackIndex>0?this._filterStack[this._filterStackIndex-1].bounds:null,h=t.renderTarget.getRenderTarget(e.previousRenderSurface);o=this.getBackTexture(h,s,a);}e.backTexture=o;let n=e.filterEffect.filters;if(this._globalFilterBindGroup.setResource(r.source.style,2),this._globalFilterBindGroup.setResource(o.source,3),t.globalUniforms.pop(),n.length===1)n[0].apply(this,r,e.previousRenderSurface,false),gt.returnTexture(r);else {let a=e.inputTexture,h=gt.getOptimalTexture(s.width,s.height,a.source._resolution,false),l=0;for(l=0;l<n.length-1;++l){n[l].apply(this,a,h,true);let u=a;a=h,h=u;}n[l].apply(this,a,e.previousRenderSurface,false),gt.returnTexture(a),gt.returnTexture(h);}e.blendRequired&>.returnTexture(o);}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._filterStack[this._filterStackIndex],a=n.bounds,h=V.shared,c=n.previousRenderSurface===r,u=this.renderer.renderTarget.rootRenderTarget.colorTexture.source._resolution,f=this._filterStackIndex-1;for(;f>0&&this._filterStack[f].skip;)--f;f>0&&(u=this._filterStack[f].inputTexture.source._resolution);let d=this._filterGlobalUniforms,m=d.uniforms,g=m.uOutputFrame,x=m.uInputSize,_=m.uInputPixel,y=m.uInputClamp,b=m.uGlobalFrame,v=m.uOutputTexture;if(c){let w=this._filterStackIndex;for(;w>0;){w--;let E=this._filterStack[this._filterStackIndex-1];if(!E.skip){h.x=E.bounds.minX,h.y=E.bounds.minY;break}}g[0]=a.minX-h.x,g[1]=a.minY-h.y;}else g[0]=0,g[1]=0;g[2]=e.frame.width,g[3]=e.frame.height,x[0]=e.source.width,x[1]=e.source.height,x[2]=1/x[0],x[3]=1/x[1],_[0]=e.source.pixelWidth,_[1]=e.source.pixelHeight,_[2]=1/_[0],_[3]=1/_[1],y[0]=.5*_[2],y[1]=.5*_[3],y[2]=e.frame.width*x[2]-.5*_[2],y[3]=e.frame.height*x[3]-.5*_[3];let P=this.renderer.renderTarget.rootRenderTarget.colorTexture;b[0]=h.x*u,b[1]=h.y*u,b[2]=P.source.width*u,b[3]=P.source.height*u;let S=this.renderer.renderTarget.getRenderTarget(r);if(o.renderTarget.bind(r,!!s),r instanceof R?(v[0]=r.frame.width,v[1]=r.frame.height):(v[0]=S.width,v[1]=S.height),v[2]=S.isRoot?-1:1,d.update(),o.renderPipes.uniformBatch){let w=o.renderPipes.uniformBatch.getUboResource(d);this._globalFilterBindGroup.setResource(w,0);}else this._globalFilterBindGroup.setResource(d,0);this._globalFilterBindGroup.setResource(e.source,1),this._globalFilterBindGroup.setResource(e.source.style,2),t.groups[0]=this._globalFilterBindGroup,o.encoder.draw({geometry:Ng,shader:t,state:t._state,topology:"triangle-list"}),o.type===qt.WEBGL&&o.renderTarget.finishRenderPass();}_getFilterData(){return {skip:false,inputTexture:null,bounds:new et,container:null,filterEffect:null,blendRequired:false,previousRenderSurface:null}}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(M.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}};Ti.extension={type:[T.WebGLSystem,T.WebGPUSystem],name:"filter"};});var hh=p(()=>{k();mm();_m();I.add(Ti);I.add(vi);});var Yg={};var ym=p(()=>{Jl();nn();ac();lc();ns();ds();ga();_a();Ta();Xa();th();ih();nh();ah();hh();});var $g={};var vm=p(()=>{nn();ns();ds();ga();_a();Ta();Xa();th();ih();nh();ah();hh();});var Nt={};Gm(Nt,{DistortionFilter:()=>ki,EqualizerFilter:()=>kt,Filter:()=>at,MonoFilter:()=>Ri,ReverbFilter:()=>Fi,StereoFilter:()=>Ii,StreamFilter:()=>Gi,TelephoneFilter:()=>Di});var mh;function xh(i){return mh=i,i}function $(){return mh}var at=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 ki=class extends at{constructor(t=0){let e;if(!$().useLegacy){let{audioContext:r}=$().context;e=r.createWaveShaper();}super(e),this._distortion=e,this.amount=t;}set amount(t){if(this._amount=t,$().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 st=class{static setParamValue(t,e){if(t.setValueAtTime){let r=$().context;t.setValueAtTime(e,r.audioContext.currentTime);}else t.value=e;return e}};var X=class extends at{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:X.F32,type:"lowshelf",gain:i},{f:X.F64,type:"peaking",gain:t},{f:X.F125,type:"peaking",gain:e},{f:X.F250,type:"peaking",gain:r},{f:X.F500,type:"peaking",gain:s},{f:X.F1K,type:"peaking",gain:o},{f:X.F2K,type:"peaking",gain:n},{f:X.F4K,type:"peaking",gain:a},{f:X.F8K,type:"peaking",gain:h},{f:X.F16K,type:"highshelf",gain:l}];$().useLegacy||(c=u.map(f=>{let d=$().context.audioContext.createBiquadFilter();return d.type=f.type,st.setParamValue(d.Q,1),d.frequency.value=f.f,st.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}`);st.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(X.F32,i);}get f32(){return this.getGain(X.F32)}set f64(i){this.setGain(X.F64,i);}get f64(){return this.getGain(X.F64)}set f125(i){this.setGain(X.F125,i);}get f125(){return this.getGain(X.F125)}set f250(i){this.setGain(X.F250,i);}get f250(){return this.getGain(X.F250)}set f500(i){this.setGain(X.F500,i);}get f500(){return this.getGain(X.F500)}set f1k(i){this.setGain(X.F1K,i);}get f1k(){return this.getGain(X.F1K)}set f2k(i){this.setGain(X.F2K,i);}get f2k(){return this.getGain(X.F2K)}set f4k(i){this.setGain(X.F4K,i);}get f4k(){return this.getGain(X.F4K)}set f8k(i){this.setGain(X.F8K,i);}get f8k(){return this.getGain(X.F8K)}set f16k(i){this.setGain(X.F16K,i);}get f16k(){return this.getGain(X.F16K)}reset(){this.bands.forEach(i=>{st.setParamValue(i.gain,0);});}destroy(){this.bands.forEach(i=>{i.disconnect();}),this.bands=null,this.bandsMap=null;}},kt=X;kt.F32=32;kt.F64=64;kt.F125=125;kt.F250=250;kt.F500=500;kt.F1K=1e3;kt.F2K=2e3;kt.F4K=4e3;kt.F8K=8e3;kt.F16K=16e3;var Ri=class extends at{constructor(){let t,e;if(!$().useLegacy){let{audioContext:r}=$().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 Fi=class extends at{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($().useLegacy)return;let{audioContext:t}=$().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 Ii=class extends at{constructor(t=0){let e,r,s;if(!$().useLegacy){let{audioContext:o}=$().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?st.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 Gi=class extends at{constructor(){let t,e;if(!$().useLegacy){let{audioContext:r}=$().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 Di=class extends at{constructor(){let t,e;if(!$().useLegacy){let{audioContext:r}=$().context,s=r.createBiquadFilter(),o=r.createBiquadFilter(),n=r.createBiquadFilter(),a=r.createBiquadFilter();s.type="lowpass",st.setParamValue(s.frequency,2e3),o.type="lowpass",st.setParamValue(o.frequency,2e3),n.type="highpass",st.setParamValue(n.frequency,500),a.type="highpass",st.setParamValue(a.frequency,500),s.connect(o),o.connect(n),n.connect(a),t=s,e=a;}super(t,e);}};k();var bm={extension:{type:T.Environment,name:"browser",priority:-1},test:()=>true,load:async()=>{await Promise.resolve().then(()=>(ym(),Yg));}};k();var Tm={extension:{type:T.Environment,name:"webworker",priority:0},test:()=>typeof self<"u"&&self.WorkerGlobalScope!==void 0,load:async()=>{await Promise.resolve().then(()=>(vm(),$g));}};k();k();ds();ns();mn();Ht();Mn();Ur();Mt();os();Bi(ra());I.add(bm,Tm);var Si=class extends Y{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 jg=0,lh=class extends Y{constructor(i){super(),this.id=jg++,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-lh.PADDING),this._end=Math.min(this._end+lh.PADDING,this._duration),this._source.onloadedmetadata=()=>{this._source&&(this._source.currentTime=t,this._source.onloadedmetadata=null,this.emit("progress",t/this._duration,this._duration),lt.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(){lt.shared.remove(this._onUpdate,this),this._internalStop(),this.emit("progress",1,this._duration),this.emit("end",this);}destroy(){lt.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}]`}},go=lh;go.PADDING=.1;var wi=class extends Y{init(t){this.parent=t,this._source=t.options.source||new Audio,t.url&&(this._source.src=t.url);}create(){return new go(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 Pi=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 Ue=["ogg","oga","opus","m4a","mp3","mpeg","wav","aiff","wma","mid","caf"],ch=["audio/mpeg","audio/ogg"],Le={};function Sm(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$/;Ue.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(Le,r);}Sm();var qg=0,Mi=class extends Y{constructor(t){super(),this.id=qg++,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);st.setParamValue(this._gain.gain,o*s*r),st.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){lt.shared.remove(this._updateListener,this),t&<.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 Oe=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 wm=class extends Oe{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(wm.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,st.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}},_o=wm;_o.BUFFER_SIZE=0;var He=class{init(t){this.parent=t,this._nodes=new _o(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 Mi(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 rt.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 br=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=$().useLegacy?new wi:new He;return new br(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:wt.extname(e).slice(1)})).filter(({ext:e})=>Le[e]).sort((e,r)=>Ue.indexOf(e.ext)-Ue.indexOf(r.ext));if(!t)throw new Error("No supported file type found");return t.url}get context(){return $().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 Pi(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(br._pool.length>0){let i=br._pool.pop();return i.init(this.media),i}return this.media.create()}_poolInstance(i){i.destroy(),br._pool.indexOf(i)<0&&br._pool.push(i);}},_e=br;_e._pool=[];var vr=class i extends Oe{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 Y,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 yo=class{constructor(){this.init();}init(){return this.supported&&(this._webAudioContext=new vr),this._htmlAudioContext=new Si,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 vr.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 _e)return this._sounds[t]=e,e;let r=this._getOptions(e),s=_e.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 Pm=i=>{let t=i.src,e=i?.alias?.[0];return (!e||i.src===e)&&(e=wt.basename(t,wt.extname(t))),e},Mm={extension:T.Asset,detection:{test:async()=>true,add:async i=>[...i,...Ue.filter(t=>Le[t])],remove:async i=>i.filter(t=>i.includes(t))},loader:{name:"sound",extension:{type:[T.LoadParser],priority:Xe.High},test(i){let t=wt.extname(i).slice(1);return !!Le[t]||ch.some(e=>i.startsWith(`data:${e}`))},async load(i,t){let e=await new Promise((r,s)=>_e.from({...t.data,url:i,preload:true,loaded(o,n){o?s(o):r(n),t.data?.loaded?.(o,n);}}));return $().add(Pm(t),e),e},async unload(i,t){$().remove(Pm(t));}}};I.add(Mm);xh(new yo);var t_="1.2.0";var qF="repeat";function ZF(i){return {type:"pause",duration:i}}var QF={DistortionFilter:Nt.DistortionFilter,EqualizerFilter:Nt.EqualizerFilter,MonoFilter:Nt.MonoFilter,ReverbFilter:Nt.ReverbFilter,StereoFilter:Nt.StereoFilter,StreamFilter:Nt.StreamFilter,TelephoneFilter:Nt.TelephoneFilter},JF=["webm","mp4","ogv","mov","avi","wmv","flv","mkv","3gp","mpg","mpeg","m4v","f4v","m2v","asf","vob","ts","m2ts","mts","divx","xvid","rm","rmvb","dat","swf","mpv","mxf","vcd","svcd","dvd","dv","3g2","m2p","m2ts","m2v","m4v","mpe","mpg","mpv2","ogm","qt","rm","ts","vob","wmv","xvid","flv","mkv","mov","mp4","webm","avi","ogv","m4v","f4v","m2v","asf","vob","ts","m2ts","mts","divx","xvid","rm","rmvb","dat","swf","mpv","mxf","vcd","svcd","dvd","dv","3g2","m2p","m2ts","m2v","m4v","mpe","mpg","mpv2","ogm","qt","rm","ts","vob","wmv","xvid","flv","mkv","mov","mp4","webm","avi","ogv","m4v","f4v","m2v","asf","vob"],tI="__game_layer__",eI="Container",rI="ImageContainer",iI="Image",sI="Sprite",oI="Text",nI="Video",aI={CURRENT_DIALOGUE_MEMORY_KEY:"___current_dialogue_memory___",LAST_DIALOGUE_ADDED_IN_STEP_MEMORY_KEY:"___last_dialogue_added_in_step_memory___",CURRENT_MENU_OPTIONS_MEMORY_KEY:"___current_menu_options_memory___",LAST_MENU_OPTIONS_ADDED_IN_STEP_MEMORY_KEY:"___last_menu_options_added_in_step_memory___",CURRENT_INPUT_VALUE_MEMORY_KEY:"_input_value_",LAST_INPUT_ADDED_IN_STEP_MEMORY_KEY:"___last_input_added_in_step_memory___",CURRENT_INPUT_INFO_MEMORY_KEY:"___current_input_info_memory___",CHARACTER_CATEGORY_KEY:"___character___",ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY:"___glue___",OPENED_LABELS_COUNTER_KEY:"___opened_labels_counter___",ALL_CHOICES_MADE_KEY:"___all_choices_made___",CURRENT_STEP_TIMES_COUNTER_KEY:"___current_step_times_counter___",LAST_STEP_GLUED:"___last_step_glued___"};export{tI as CANVAS_APP_GAME_LAYER_ALIAS,eI as CANVAS_CONTAINER_ID,rI as CANVAS_IMAGE_CONTAINER_ID,iI as CANVAS_IMAGE_ID,sI as CANVAS_SPRITE_ID,oI as CANVAS_TEXT_ID,nI as CANVAS_VIDEO_ID,t_ as PIXIVN_VERSION,ZF as Pause,qF as Repeat,aI as SYSTEM_RESERVED_STORAGE_KEYS,QF as filters,JF as videoFormats};
|
|
569
|
+
`}};});var sh,oh,po,Zp=p(()=>{Q();Ps();Xp();Bs();ti();pe();ft();qp();po=class extends Zt{constructor(){sh??(sh=rr({name:"tiling-sprite-shader",bits:[_i,jp,sr]})),oh??(oh=ir({name:"tiling-sprite-shader",bits:[$p,Kp,or]}));let t=new Tt({uMapCoord:{value:new M,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 M,type:"mat3x3<f32>"},uSizeAnchor:{value:new Float32Array([100,100,.5,.5]),type:"vec4<f32>"}});super({glProgram:oh,gpuProgram:sh,resources:{localUniforms:new Tt({uTransformMatrix:{value:new M,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 mo,Qp=p(()=>{fo();mo=class extends yr{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 Jp(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 tm=p(()=>{});function em(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 rm=p(()=>{});function im(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=M.shared;a.copyFrom(i._tileTransform.matrix),a.tx/=i.width,a.ty/=i.height,a.invert(),a.scale(i.width/r,i.height/s),em(t,2,0,a);}var sm=p(()=>{Q();rm();});var xo,yi,om=p(()=>{k();qr();Hs();Jr();si();zs();fo();Zp();Qp();tm();sm();xo=new mo,yi=class{constructor(t){this._state=Ie.default2d,this._tilingSpriteDataHash=Object.create(null),this._destroyRenderableBound=this.destroyRenderable.bind(this),this._renderer=t,this._renderer.renderableGC.addManagedHash(this,"_tilingSpriteDataHash");}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 xe);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 po),this.updateRenderable(t),e.add(t);}execute(t){let{shader:e}=this._tilingSpriteDataHash[t.uid];e.groups[0]=this._renderer.globalUniforms.bindGroup;let r=e.resources.localUniforms.uniforms;r.uTransformMatrix=t.groupTransform,r.uRound=this._renderer._roundPixels|t._roundPixels,me(t.groupColorAlpha,r.uColor,0),this._state.blendMode=se(t.groupBlendMode,t.texture._source),this._renderer.encoder.draw({geometry:xo,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);}}destroyRenderable(t){let e=this._getTilingSpriteData(t);e.batchableMesh=null,e.shader?.destroy(),this._tilingSpriteDataHash[t.uid]=null,t.off("destroyed",this._destroyRenderableBound);}_getTilingSpriteData(t){return this._tilingSpriteDataHash[t.uid]||this._initTilingSpriteData(t)}_initTilingSpriteData(t){let e=new yr({indices:xo.indices,positions:xo.positions.slice(),uvs:xo.uvs.slice()});return this._tilingSpriteDataHash[t.uid]={canBatch:true,renderable:t,geometry:e},t.on("destroyed",this._destroyRenderableBound),this._tilingSpriteDataHash[t.uid]}_updateBatchableMesh(t){let e=this._getTilingSpriteData(t),{geometry:r}=e,s=t.texture.source.style;s.addressMode!=="repeat"&&(s.addressMode="repeat",s.update()),im(t,r.uvs),Jp(t,r.positions);}destroy(){for(let t in this._tilingSpriteDataHash)this.destroyRenderable(this._tilingSpriteDataHash[t].renderable);this._tilingSpriteDataHash=null,this._renderer=null;}_updateCanBatch(t){let e=this._getTilingSpriteData(t),r=t.texture,s=true;return this._renderer.type===qt.WEBGL&&(s=this._renderer.context.supports.nonPowOf2wrapping),e.canBatch=r.textureMatrix.isSimple&&(s||r.source.isPowerOfTwo),e.canBatch}};yi.extension={type:[T.WebGLPipes,T.WebGPUPipes,T.CanvasPipes],name:"tilingSprite"};});var nh=p(()=>{k();om();I.add(yi);});var nm,hm,lm=p(()=>{ht();fo();nm=class am extends yr{constructor(...t){super({});let e=t[0]??{};typeof e=="number"&&(G(H,"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={...am.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,m=d*this.verticesX+f,g=d*this.verticesX+f+1,x=(d+1)*this.verticesX+f,_=(d+1)*this.verticesX+f+1;o.push(m,g,x,g,_,x);}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();}};nm.defaultOptions={width:100,height:100,verticesX:10,verticesY:10};hm=nm;});var cm,dm,fm=p(()=>{lm();cm=class um extends hm{constructor(t={}){t={...um.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,m=Math.min(u,d),g=h*e,x=l*r;t[0]=t[8]=t[16]=t[24]=-g,t[2]=t[10]=t[18]=t[26]=s*m-g,t[4]=t[12]=t[20]=t[28]=e-o*m-g,t[6]=t[14]=t[22]=t[30]=e-g,t[1]=t[3]=t[5]=t[7]=-x,t[9]=t[11]=t[13]=t[15]=n*m-x,t[17]=t[19]=t[21]=t[23]=r-a*m-x,t[25]=t[27]=t[29]=t[31]=r-x,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();}};cm.defaultOptions={width:100,height:100,leftWidth:10,topHeight:10,rightWidth:10,bottomHeight:10,originalWidth:100,originalHeight:100};dm=cm;});var bi,pm=p(()=>{k();Ft();zs();fm();bi=class{constructor(t){this._gpuSpriteHash=Object.create(null),this._destroyRenderableBound=this.destroyRenderable.bind(this),this._renderer=t,this._renderer.renderableGC.addManagedHash(this,"_gpuSpriteHash");}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._gpuSpriteHash[t.uid];t.didViewUpdate&&this._updateBatchableSprite(t,e),e._batcher.updateElement(e);}validateRenderable(t){let e=this._getGpuSprite(t);return !e._batcher.checkAndUpdateTexture(e,t._texture)}destroyRenderable(t){let e=this._gpuSpriteHash[t.uid];z.return(e.geometry),z.return(e),this._gpuSpriteHash[t.uid]=null,t.off("destroyed",this._destroyRenderableBound);}_updateBatchableSprite(t,e){e.geometry.update(t),e.setTexture(t._texture);}_getGpuSprite(t){return this._gpuSpriteHash[t.uid]||this._initGPUSprite(t)}_initGPUSprite(t){let e=z.get(xe);return e.geometry=z.get(dm),e.renderable=t,e.transform=t.groupTransform,e.texture=t._texture,e.roundPixels=this._renderer._roundPixels|t._roundPixels,this._gpuSpriteHash[t.uid]=e,t.didViewUpdate||this._updateBatchableSprite(t,e),t.on("destroyed",this._destroyRenderableBound),e}destroy(){for(let t in this._gpuSpriteHash)this._gpuSpriteHash[t].geometry.destroy();this._gpuSpriteHash=null,this._renderer=null;}};bi.extension={type:[T.WebGLPipes,T.WebGPUPipes,T.CanvasPipes],name:"nineSliceSprite"};});var ah=p(()=>{k();pm();I.add(bi);});var vi,mm=p(()=>{k();vi=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;}};vi.extension={type:[T.WebGLPipes,T.WebGPUPipes,T.CanvasPipes],name:"filter"};});function xm(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 gm=p(()=>{});var Ng,Ti,_m=p(()=>{k();Q();Ut();Kr();Qr();pe();ft();Ve();Jr();Lt();gm();xt();Ng=new Kt({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])}),Ti=class{constructor(t){this._filterStackIndex=0,this._filterStack=[],this._filterGlobalUniforms=new Tt({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 It({}),this.renderer=t;}get activeBackTexture(){return this._activeFilterData?.backTexture}push(t){let e=this.renderer,r=t.filterEffect.filters;this._filterStack[this._filterStackIndex]||(this._filterStack[this._filterStackIndex]=this._getFilterData());let s=this._filterStack[this._filterStackIndex];if(this._filterStackIndex++,r.length===0){s.skip=true;return}let o=s.bounds;if(t.renderables?xm(t.renderables,o):t.filterEffect.filterArea?(o.clear(),o.addRect(t.filterEffect.filterArea),o.applyMatrix(t.container.worldTransform)):t.container.getFastGlobalBounds(true,o),t.container){let m=(t.container.renderGroup||t.container.parentRenderGroup).cacheToLocalTransform;m&&o.applyMatrix(m);}let n=e.renderTarget.renderTarget.colorTexture.source,a=1/0,h=0,l=true,c=false,u=false,f=true;for(let d=0;d<r.length;d++){let m=r[d];if(a=Math.min(a,m.resolution==="inherit"?n._resolution:m.resolution),h+=m.padding,m.antialias==="off"?l=false:m.antialias==="inherit"&&l&&(l=n.antialias),m.clipToViewport||(f=false),!!!(m.compatibleRenderers&e.type)){u=false;break}if(m.blendRequired&&!(e.backBuffer?.useBackBuffer??true)){L("Blend filter requires backBuffer on WebGL renderer to be enabled. Set `useBackBuffer: true` in the renderer options."),u=false;break}u=m.enabled||u,c||(c=m.blendRequired);}if(!u){s.skip=true;return}if(f){let d=e.renderTarget.rootViewPort,m=e.renderTarget.renderTarget.resolution;o.fitBounds(0,d.width/m,0,d.height/m);}if(o.scale(a).ceil().scale(1/a).pad(h|0),!o.isPositive){s.skip=true;return}s.skip=false,s.bounds=o,s.blendRequired=c,s.container=t.container,s.filterEffect=t.filterEffect,s.previousRenderSurface=e.renderTarget.renderSurface,s.inputTexture=gt.getOptimalTexture(o.width,o.height,a,l),e.renderTarget.bind(s.inputTexture,true),e.globalUniforms.push({offset:o});}pop(){let t=this.renderer;this._filterStackIndex--;let e=this._filterStack[this._filterStackIndex];if(e.skip)return;this._activeFilterData=e;let r=e.inputTexture,s=e.bounds,o=R.EMPTY;if(t.renderTarget.finishRenderPass(),e.blendRequired){let a=this._filterStackIndex>0?this._filterStack[this._filterStackIndex-1].bounds:null,h=t.renderTarget.getRenderTarget(e.previousRenderSurface);o=this.getBackTexture(h,s,a);}e.backTexture=o;let n=e.filterEffect.filters;if(this._globalFilterBindGroup.setResource(r.source.style,2),this._globalFilterBindGroup.setResource(o.source,3),t.globalUniforms.pop(),n.length===1)n[0].apply(this,r,e.previousRenderSurface,false),gt.returnTexture(r);else {let a=e.inputTexture,h=gt.getOptimalTexture(s.width,s.height,a.source._resolution,false),l=0;for(l=0;l<n.length-1;++l){n[l].apply(this,a,h,true);let u=a;a=h,h=u;}n[l].apply(this,a,e.previousRenderSurface,false),gt.returnTexture(a),gt.returnTexture(h);}e.blendRequired&>.returnTexture(o);}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._filterStack[this._filterStackIndex],a=n.bounds,h=V.shared,c=n.previousRenderSurface===r,u=this.renderer.renderTarget.rootRenderTarget.colorTexture.source._resolution,f=this._filterStackIndex-1;for(;f>0&&this._filterStack[f].skip;)--f;f>0&&(u=this._filterStack[f].inputTexture.source._resolution);let d=this._filterGlobalUniforms,m=d.uniforms,g=m.uOutputFrame,x=m.uInputSize,_=m.uInputPixel,y=m.uInputClamp,b=m.uGlobalFrame,v=m.uOutputTexture;if(c){let w=this._filterStackIndex;for(;w>0;){w--;let E=this._filterStack[this._filterStackIndex-1];if(!E.skip){h.x=E.bounds.minX,h.y=E.bounds.minY;break}}g[0]=a.minX-h.x,g[1]=a.minY-h.y;}else g[0]=0,g[1]=0;g[2]=e.frame.width,g[3]=e.frame.height,x[0]=e.source.width,x[1]=e.source.height,x[2]=1/x[0],x[3]=1/x[1],_[0]=e.source.pixelWidth,_[1]=e.source.pixelHeight,_[2]=1/_[0],_[3]=1/_[1],y[0]=.5*_[2],y[1]=.5*_[3],y[2]=e.frame.width*x[2]-.5*_[2],y[3]=e.frame.height*x[3]-.5*_[3];let P=this.renderer.renderTarget.rootRenderTarget.colorTexture;b[0]=h.x*u,b[1]=h.y*u,b[2]=P.source.width*u,b[3]=P.source.height*u;let S=this.renderer.renderTarget.getRenderTarget(r);if(o.renderTarget.bind(r,!!s),r instanceof R?(v[0]=r.frame.width,v[1]=r.frame.height):(v[0]=S.width,v[1]=S.height),v[2]=S.isRoot?-1:1,d.update(),o.renderPipes.uniformBatch){let w=o.renderPipes.uniformBatch.getUboResource(d);this._globalFilterBindGroup.setResource(w,0);}else this._globalFilterBindGroup.setResource(d,0);this._globalFilterBindGroup.setResource(e.source,1),this._globalFilterBindGroup.setResource(e.source.style,2),t.groups[0]=this._globalFilterBindGroup,o.encoder.draw({geometry:Ng,shader:t,state:t._state,topology:"triangle-list"}),o.type===qt.WEBGL&&o.renderTarget.finishRenderPass();}_getFilterData(){return {skip:false,inputTexture:null,bounds:new et,container:null,filterEffect:null,blendRequired:false,previousRenderSurface:null}}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(M.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}};Ti.extension={type:[T.WebGLSystem,T.WebGPUSystem],name:"filter"};});var hh=p(()=>{k();mm();_m();I.add(Ti);I.add(vi);});var Yg={};var ym=p(()=>{Jl();nn();ac();lc();ns();ds();ga();_a();Ta();Xa();th();ih();nh();ah();hh();});var $g={};var vm=p(()=>{nn();ns();ds();ga();_a();Ta();Xa();th();ih();nh();ah();hh();});var Nt={};Gm(Nt,{DistortionFilter:()=>ki,EqualizerFilter:()=>kt,Filter:()=>at,MonoFilter:()=>Ri,ReverbFilter:()=>Fi,StereoFilter:()=>Ii,StreamFilter:()=>Gi,TelephoneFilter:()=>Di});var mh;function xh(i){return mh=i,i}function $(){return mh}var at=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 ki=class extends at{constructor(t=0){let e;if(!$().useLegacy){let{audioContext:r}=$().context;e=r.createWaveShaper();}super(e),this._distortion=e,this.amount=t;}set amount(t){if(this._amount=t,$().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 st=class{static setParamValue(t,e){if(t.setValueAtTime){let r=$().context;t.setValueAtTime(e,r.audioContext.currentTime);}else t.value=e;return e}};var X=class extends at{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:X.F32,type:"lowshelf",gain:i},{f:X.F64,type:"peaking",gain:t},{f:X.F125,type:"peaking",gain:e},{f:X.F250,type:"peaking",gain:r},{f:X.F500,type:"peaking",gain:s},{f:X.F1K,type:"peaking",gain:o},{f:X.F2K,type:"peaking",gain:n},{f:X.F4K,type:"peaking",gain:a},{f:X.F8K,type:"peaking",gain:h},{f:X.F16K,type:"highshelf",gain:l}];$().useLegacy||(c=u.map(f=>{let d=$().context.audioContext.createBiquadFilter();return d.type=f.type,st.setParamValue(d.Q,1),d.frequency.value=f.f,st.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}`);st.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(X.F32,i);}get f32(){return this.getGain(X.F32)}set f64(i){this.setGain(X.F64,i);}get f64(){return this.getGain(X.F64)}set f125(i){this.setGain(X.F125,i);}get f125(){return this.getGain(X.F125)}set f250(i){this.setGain(X.F250,i);}get f250(){return this.getGain(X.F250)}set f500(i){this.setGain(X.F500,i);}get f500(){return this.getGain(X.F500)}set f1k(i){this.setGain(X.F1K,i);}get f1k(){return this.getGain(X.F1K)}set f2k(i){this.setGain(X.F2K,i);}get f2k(){return this.getGain(X.F2K)}set f4k(i){this.setGain(X.F4K,i);}get f4k(){return this.getGain(X.F4K)}set f8k(i){this.setGain(X.F8K,i);}get f8k(){return this.getGain(X.F8K)}set f16k(i){this.setGain(X.F16K,i);}get f16k(){return this.getGain(X.F16K)}reset(){this.bands.forEach(i=>{st.setParamValue(i.gain,0);});}destroy(){this.bands.forEach(i=>{i.disconnect();}),this.bands=null,this.bandsMap=null;}},kt=X;kt.F32=32;kt.F64=64;kt.F125=125;kt.F250=250;kt.F500=500;kt.F1K=1e3;kt.F2K=2e3;kt.F4K=4e3;kt.F8K=8e3;kt.F16K=16e3;var Ri=class extends at{constructor(){let t,e;if(!$().useLegacy){let{audioContext:r}=$().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 Fi=class extends at{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($().useLegacy)return;let{audioContext:t}=$().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 Ii=class extends at{constructor(t=0){let e,r,s;if(!$().useLegacy){let{audioContext:o}=$().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?st.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 Gi=class extends at{constructor(){let t,e;if(!$().useLegacy){let{audioContext:r}=$().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 Di=class extends at{constructor(){let t,e;if(!$().useLegacy){let{audioContext:r}=$().context,s=r.createBiquadFilter(),o=r.createBiquadFilter(),n=r.createBiquadFilter(),a=r.createBiquadFilter();s.type="lowpass",st.setParamValue(s.frequency,2e3),o.type="lowpass",st.setParamValue(o.frequency,2e3),n.type="highpass",st.setParamValue(n.frequency,500),a.type="highpass",st.setParamValue(a.frequency,500),s.connect(o),o.connect(n),n.connect(a),t=s,e=a;}super(t,e);}};k();var bm={extension:{type:T.Environment,name:"browser",priority:-1},test:()=>true,load:async()=>{await Promise.resolve().then(()=>(ym(),Yg));}};k();var Tm={extension:{type:T.Environment,name:"webworker",priority:0},test:()=>typeof self<"u"&&self.WorkerGlobalScope!==void 0,load:async()=>{await Promise.resolve().then(()=>(vm(),$g));}};k();k();ds();ns();mn();Ht();Mn();Ur();Mt();os();Bi(ra());I.add(bm,Tm);var Si=class extends Y{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 jg=0,lh=class extends Y{constructor(i){super(),this.id=jg++,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-lh.PADDING),this._end=Math.min(this._end+lh.PADDING,this._duration),this._source.onloadedmetadata=()=>{this._source&&(this._source.currentTime=t,this._source.onloadedmetadata=null,this.emit("progress",t/this._duration,this._duration),lt.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(){lt.shared.remove(this._onUpdate,this),this._internalStop(),this.emit("progress",1,this._duration),this.emit("end",this);}destroy(){lt.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}]`}},go=lh;go.PADDING=.1;var wi=class extends Y{init(t){this.parent=t,this._source=t.options.source||new Audio,t.url&&(this._source.src=t.url);}create(){return new go(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 Pi=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 Ue=["ogg","oga","opus","m4a","mp3","mpeg","wav","aiff","wma","mid","caf"],ch=["audio/mpeg","audio/ogg"],Le={};function Sm(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$/;Ue.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(Le,r);}Sm();var qg=0,Mi=class extends Y{constructor(t){super(),this.id=qg++,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);st.setParamValue(this._gain.gain,o*s*r),st.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){lt.shared.remove(this._updateListener,this),t&<.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 Oe=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 wm=class extends Oe{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(wm.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,st.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}},_o=wm;_o.BUFFER_SIZE=0;var He=class{init(t){this.parent=t,this._nodes=new _o(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 Mi(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 rt.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 br=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=$().useLegacy?new wi:new He;return new br(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:wt.extname(e).slice(1)})).filter(({ext:e})=>Le[e]).sort((e,r)=>Ue.indexOf(e.ext)-Ue.indexOf(r.ext));if(!t)throw new Error("No supported file type found");return t.url}get context(){return $().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 Pi(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(br._pool.length>0){let i=br._pool.pop();return i.init(this.media),i}return this.media.create()}_poolInstance(i){i.destroy(),br._pool.indexOf(i)<0&&br._pool.push(i);}},_e=br;_e._pool=[];var vr=class i extends Oe{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 Y,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 yo=class{constructor(){this.init();}init(){return this.supported&&(this._webAudioContext=new vr),this._htmlAudioContext=new Si,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 vr.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 _e)return this._sounds[t]=e,e;let r=this._getOptions(e),s=_e.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 Pm=i=>{let t=i.src,e=i?.alias?.[0];return (!e||i.src===e)&&(e=wt.basename(t,wt.extname(t))),e},Mm={extension:T.Asset,detection:{test:async()=>true,add:async i=>[...i,...Ue.filter(t=>Le[t])],remove:async i=>i.filter(t=>i.includes(t))},loader:{name:"sound",extension:{type:[T.LoadParser],priority:Xe.High},test(i){let t=wt.extname(i).slice(1);return !!Le[t]||ch.some(e=>i.startsWith(`data:${e}`))},async load(i,t){let e=await new Promise((r,s)=>_e.from({...t.data,url:i,preload:true,loaded(o,n){o?s(o):r(n),t.data?.loaded?.(o,n);}}));return $().add(Pm(t),e),e},async unload(i,t){$().remove(Pm(t));}}};I.add(Mm);xh(new yo);var t_="1.2.1";var qF="repeat";function ZF(i){return {type:"pause",duration:i}}var QF={DistortionFilter:Nt.DistortionFilter,EqualizerFilter:Nt.EqualizerFilter,MonoFilter:Nt.MonoFilter,ReverbFilter:Nt.ReverbFilter,StereoFilter:Nt.StereoFilter,StreamFilter:Nt.StreamFilter,TelephoneFilter:Nt.TelephoneFilter},JF=["webm","mp4","ogv","mov","avi","wmv","flv","mkv","3gp","mpg","mpeg","m4v","f4v","m2v","asf","vob","ts","m2ts","mts","divx","xvid","rm","rmvb","dat","swf","mpv","mxf","vcd","svcd","dvd","dv","3g2","m2p","m2ts","m2v","m4v","mpe","mpg","mpv2","ogm","qt","rm","ts","vob","wmv","xvid","flv","mkv","mov","mp4","webm","avi","ogv","m4v","f4v","m2v","asf","vob","ts","m2ts","mts","divx","xvid","rm","rmvb","dat","swf","mpv","mxf","vcd","svcd","dvd","dv","3g2","m2p","m2ts","m2v","m4v","mpe","mpg","mpv2","ogm","qt","rm","ts","vob","wmv","xvid","flv","mkv","mov","mp4","webm","avi","ogv","m4v","f4v","m2v","asf","vob"],tI="__game_layer__",eI="Container",rI="ImageContainer",iI="Image",sI="Sprite",oI="Text",nI="Video",aI={CURRENT_DIALOGUE_MEMORY_KEY:"___current_dialogue_memory___",LAST_DIALOGUE_ADDED_IN_STEP_MEMORY_KEY:"___last_dialogue_added_in_step_memory___",CURRENT_MENU_OPTIONS_MEMORY_KEY:"___current_menu_options_memory___",LAST_MENU_OPTIONS_ADDED_IN_STEP_MEMORY_KEY:"___last_menu_options_added_in_step_memory___",CURRENT_INPUT_VALUE_MEMORY_KEY:"_input_value_",LAST_INPUT_ADDED_IN_STEP_MEMORY_KEY:"___last_input_added_in_step_memory___",CURRENT_INPUT_INFO_MEMORY_KEY:"___current_input_info_memory___",CHARACTER_CATEGORY_KEY:"___character___",ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY:"___glue___",OPENED_LABELS_COUNTER_KEY:"___opened_labels_counter___",ALL_CHOICES_MADE_KEY:"___all_choices_made___",CURRENT_STEP_TIMES_COUNTER_KEY:"___current_step_times_counter___",LAST_STEP_GLUED:"___last_step_glued___"};export{tI as CANVAS_APP_GAME_LAYER_ALIAS,eI as CANVAS_CONTAINER_ID,rI as CANVAS_IMAGE_CONTAINER_ID,iI as CANVAS_IMAGE_ID,sI as CANVAS_SPRITE_ID,oI as CANVAS_TEXT_ID,nI as CANVAS_VIDEO_ID,t_ as PIXIVN_VERSION,ZF as Pause,qF as Repeat,aI as SYSTEM_RESERVED_STORAGE_KEYS,QF as filters,JF as videoFormats};
|