@drincs/pixi-vn 1.0.0 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/canvas/CanvasManager.cjs +1 -1
- package/dist/canvas/CanvasManager.js +1 -1
- package/dist/canvas/CanvasManagerStatic.cjs +1 -1
- package/dist/canvas/CanvasManagerStatic.js +1 -1
- package/dist/canvas/components/Container.cjs +1 -1
- package/dist/canvas/components/Container.js +1 -1
- package/dist/canvas/components/ImageContainer.cjs +1 -1
- package/dist/canvas/components/ImageContainer.js +1 -1
- package/dist/canvas/components/ImageSprite.cjs +1 -1
- package/dist/canvas/components/ImageSprite.js +1 -1
- package/dist/canvas/components/Sprite.cjs +1 -1
- package/dist/canvas/components/Sprite.js +1 -1
- package/dist/canvas/components/Text.cjs +1 -1
- package/dist/canvas/components/Text.js +1 -1
- package/dist/canvas/components/VideoSprite.cjs +1 -1
- package/dist/canvas/components/VideoSprite.js +1 -1
- package/dist/canvas/decorators/canvas-element-decorator.cjs +1 -1
- package/dist/canvas/decorators/canvas-element-decorator.js +1 -1
- package/dist/canvas/decorators/event-decorator.cjs +1 -1
- package/dist/canvas/decorators/event-decorator.d.cts +1 -3
- package/dist/canvas/decorators/event-decorator.d.ts +1 -3
- package/dist/canvas/decorators/event-decorator.js +1 -1
- package/dist/canvas/functions/canvas-effect.cjs +1 -1
- package/dist/canvas/functions/canvas-effect.js +1 -1
- package/dist/canvas/functions/canvas-import-utility.cjs +1 -1
- package/dist/canvas/functions/canvas-import-utility.js +1 -1
- package/dist/canvas/functions/canvas-property-utility.cjs +1 -1
- package/dist/canvas/functions/canvas-property-utility.js +1 -1
- package/dist/canvas/functions/canvas-transition.cjs +1 -1
- package/dist/canvas/functions/canvas-transition.js +1 -1
- package/dist/canvas/functions/image-container-utility.cjs +1 -1
- package/dist/canvas/functions/image-container-utility.js +1 -1
- package/dist/canvas/functions/image-utility.cjs +1 -1
- package/dist/canvas/functions/image-utility.js +1 -1
- package/dist/canvas/functions/ticker-utility.cjs +1 -1
- package/dist/canvas/functions/ticker-utility.js +1 -1
- package/dist/canvas/functions/video-utility.cjs +1 -1
- package/dist/canvas/functions/video-utility.js +1 -1
- package/dist/canvas/index.cjs +1 -1
- package/dist/canvas/index.js +1 -1
- package/dist/canvas/tickers/classes/TickerBase.cjs +1 -1
- package/dist/canvas/tickers/classes/TickerBase.js +1 -1
- package/dist/canvas/tickers/components/FadeAlphaTicker.cjs +1 -1
- package/dist/canvas/tickers/components/FadeAlphaTicker.js +1 -1
- package/dist/canvas/tickers/components/MoveTicker.cjs +1 -1
- package/dist/canvas/tickers/components/MoveTicker.js +1 -1
- package/dist/canvas/tickers/components/RotateTicker.cjs +1 -1
- package/dist/canvas/tickers/components/RotateTicker.js +1 -1
- package/dist/canvas/tickers/components/ZoomTicker.cjs +1 -1
- package/dist/canvas/tickers/components/ZoomTicker.js +1 -1
- package/dist/canvas/tickers/decorators/ticker-decorator.cjs +1 -1
- package/dist/canvas/tickers/decorators/ticker-decorator.d.cts +1 -3
- package/dist/canvas/tickers/decorators/ticker-decorator.d.ts +1 -3
- package/dist/canvas/tickers/decorators/ticker-decorator.js +1 -1
- package/dist/canvas/tickers/index.cjs +1 -1
- package/dist/canvas/tickers/index.js +1 -1
- package/dist/character/decorators/character-decorator.cjs +1 -1
- package/dist/character/decorators/character-decorator.d.cts +1 -3
- package/dist/character/decorators/character-decorator.d.ts +1 -3
- package/dist/character/decorators/character-decorator.js +1 -1
- package/dist/character/index.cjs +1 -1
- package/dist/character/index.js +1 -1
- 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/history/HistoryManager.cjs +1 -1
- package/dist/history/HistoryManager.d.cts +1 -1
- package/dist/history/HistoryManager.d.ts +1 -1
- package/dist/history/HistoryManager.js +1 -1
- package/dist/history/HistoryManagerStatic.d.cts +1 -1
- package/dist/history/HistoryManagerStatic.d.ts +1 -1
- package/dist/history/index.cjs +1 -1
- package/dist/history/index.d.cts +1 -1
- package/dist/history/index.d.ts +1 -1
- package/dist/history/index.js +1 -1
- package/dist/history/interfaces/HistoryGameState.d.cts +1 -1
- package/dist/history/interfaces/HistoryGameState.d.ts +1 -1
- package/dist/history/interfaces/HistoryManagerInterface.d.cts +1 -1
- package/dist/history/interfaces/HistoryManagerInterface.d.ts +1 -1
- package/dist/{index-Bo5b5ojv.d.cts → index-A4Zf-9mB.d.cts} +4 -4
- package/dist/{index-b75SF7z8.d.ts → index-DwELdyJt.d.ts} +4 -4
- package/dist/index.cjs +101 -101
- package/dist/index.d.cts +4 -3
- package/dist/index.d.ts +4 -3
- package/dist/index.js +101 -101
- package/dist/interfaces/GameState.d.cts +1 -1
- package/dist/interfaces/GameState.d.ts +1 -1
- package/dist/interfaces/index.d.cts +1 -1
- package/dist/interfaces/index.d.ts +1 -1
- package/dist/narration/NarrationManager.cjs +32 -32
- package/dist/narration/NarrationManager.d.cts +7 -7
- package/dist/narration/NarrationManager.d.ts +7 -7
- package/dist/narration/NarrationManager.js +32 -32
- package/dist/narration/NarrationManagerStatic.cjs +51 -51
- package/dist/narration/NarrationManagerStatic.d.cts +1 -1
- package/dist/narration/NarrationManagerStatic.d.ts +1 -1
- package/dist/narration/NarrationManagerStatic.js +51 -51
- package/dist/narration/classes/ChoiceMenuOption.cjs +1 -1
- package/dist/narration/classes/ChoiceMenuOption.js +1 -1
- package/dist/narration/classes/CloseLabel.cjs +1 -1
- package/dist/narration/classes/CloseLabel.d.cts +1 -1
- package/dist/narration/classes/CloseLabel.d.ts +1 -1
- package/dist/narration/classes/CloseLabel.js +1 -1
- package/dist/narration/classes/Label.cjs +1 -1
- package/dist/narration/classes/Label.js +1 -1
- package/dist/narration/classes/LabelAbstract.cjs +1 -1
- package/dist/narration/classes/LabelAbstract.d.cts +2 -6
- package/dist/narration/classes/LabelAbstract.d.ts +2 -6
- package/dist/narration/classes/LabelAbstract.js +1 -1
- package/dist/narration/decorators/label-decorator.cjs +1 -1
- package/dist/narration/decorators/label-decorator.d.cts +17 -28
- package/dist/narration/decorators/label-decorator.d.ts +17 -28
- package/dist/narration/decorators/label-decorator.js +1 -1
- package/dist/narration/decorators/newLabel.cjs +1 -0
- package/dist/narration/decorators/newLabel.d.cts +18 -0
- package/dist/narration/decorators/newLabel.d.ts +18 -0
- package/dist/narration/decorators/newLabel.js +1 -0
- package/dist/narration/index.cjs +49 -49
- package/dist/narration/index.d.cts +3 -2
- package/dist/narration/index.d.ts +3 -2
- package/dist/narration/index.js +49 -49
- package/dist/narration/interfaces/HistoryStep.d.cts +1 -1
- package/dist/narration/interfaces/HistoryStep.d.ts +1 -1
- package/dist/narration/interfaces/NarrationGameState.d.cts +1 -1
- package/dist/narration/interfaces/NarrationGameState.d.ts +1 -1
- package/dist/narration/interfaces/NarrationManagerInterface.d.cts +7 -7
- package/dist/narration/interfaces/NarrationManagerInterface.d.ts +7 -7
- package/dist/narration/types/ChoiceMenuOptionsType.d.cts +1 -1
- package/dist/narration/types/ChoiceMenuOptionsType.d.ts +1 -1
- package/dist/pixi-devtools/additionalPositionsProperties.cjs +1 -1
- package/dist/pixi-devtools/additionalPositionsProperties.js +1 -1
- package/dist/sound/SoundManager.cjs +48 -48
- package/dist/sound/SoundManager.js +48 -48
- package/dist/sound/index.cjs +48 -48
- package/dist/sound/index.js +48 -48
- package/package.json +1 -1
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { CharacterInterface } from '@drincs/pixi-vn';
|
|
2
2
|
|
|
3
|
-
declare const registeredCharacters:
|
|
4
|
-
[id: string]: CharacterInterface;
|
|
5
|
-
};
|
|
3
|
+
declare const registeredCharacters: Map<string, CharacterInterface>;
|
|
6
4
|
/**
|
|
7
5
|
* Is a function that saves the character. If the character already exists, it will be overwritten.
|
|
8
6
|
* @param character is the character to save
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var a;(o=>(o.log=(t,...n)=>console.log(`[Pixi\u2019VN] ${t}`,...n),o.warn=(t,...n)=>console.warn(`[Pixi\u2019VN] ${t}`,...n),o.error=(t,...n)=>console.error(`[Pixi\u2019VN] ${t}`,...n),o.info=(t,...n)=>console.info(`[Pixi\u2019VN] ${t}`,...n)))(a||={});var i=
|
|
1
|
+
var a;(o=>(o.log=(t,...n)=>console.log(`[Pixi\u2019VN] ${t}`,...n),o.warn=(t,...n)=>console.warn(`[Pixi\u2019VN] ${t}`,...n),o.error=(t,...n)=>console.error(`[Pixi\u2019VN] ${t}`,...n),o.info=(t,...n)=>console.info(`[Pixi\u2019VN] ${t}`,...n)))(a||={});var i=new Map;function c(r){if(Array.isArray(r)){r.forEach(e=>c(e));return}i.get(r.id)&&a.info(`Character id ${r.id} already exists, it will be overwritten`),i.set(r.id,r);}function y(r){try{let e=i.get(r);if(!e){a.error(`Character ${r} not found, did you forget to register it with the saveCharacter?`);return}return e}catch(e){a.error(`Error while getting Character ${r}`,e);return}}function C(){return Object.values(i)}export{C as getAllCharacters,y as getCharacterById,i as registeredCharacters,c as saveCharacter};
|
package/dist/character/index.cjs
CHANGED
|
@@ -566,4 +566,4 @@ fn mainFragment(
|
|
|
566
566
|
|
|
567
567
|
outColor = texture(uTexture, coord, unclamped == coord ? 0.0 : -32.0);// lod-bias very negative to force lod 0
|
|
568
568
|
|
|
569
|
-
`}};});var ph,mh,So,am=p(()=>{J();ks();im();Ls();si();xe();mt();nm();So=class extends te{constructor(){ph??(ph=or({name:"tiling-sprite-shader",bits:[Ti,sm,ar]})),mh??(mh=nr({name:"tiling-sprite-shader",bits:[rm,om,hr]}));let t=new wt({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:mh,gpuProgram:ph,resources:{localUniforms:new wt({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:F.EMPTY.source,uSampler:F.EMPTY.source.style}});}updateUniforms(t,e,r,s,o,n){let a=this.resources.tilingUniforms,h=n.width,l=n.height,u=n.textureMatrix,c=a.uniforms.uTextureTransform;c.set(r.a*h/t,r.b*h/e,r.c*l/t,r.d*l/e,r.tx/t,r.ty/e),c.invert(),a.uniforms.uMapCoord=u.mapCoord,a.uniforms.uClampFrame=u.uClampFrame,a.uniforms.uClampOffset=u.uClampOffset,a.uniforms.uTextureTransform=c,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 To,hm=p(()=>{vo();To=class extends vr{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 lm(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 um=p(()=>{});function cm(i,t,e,r){let s=0,o=i.length/(t),n=r.a,a=r.b,h=r.c,l=r.d,u=r.tx,c=r.ty;for(e*=t;s<o;){let f=i[e],d=i[e+1];i[e]=n*f+h*d+u,i[e+1]=a*f+l*d+c,e+=t,s++;}}var dm=p(()=>{});function fm(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),cm(t,2,0,a);}var pm=p(()=>{J();dm();});var wo,wi,mm=p(()=>{R();ti();js();ii();hi();Ks();vo();am();hm();um();pm();wo=new To,wi=class{constructor(t){this._state=Ue.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 ye);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 So),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,_e(t.groupColorAlpha,r.uColor,0),this._state.blendMode=ae(t.groupBlendMode,t.texture._source),this._renderer.encoder.draw({geometry:wo,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 vr({indices:wo.indices,positions:wo.positions.slice(),uvs:wo.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()),fm(t,r.uvs),lm(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===Jt.WEBGL&&(s=this._renderer.context.supports.nonPowOf2wrapping),e.canBatch=r.textureMatrix.isSimple&&(s||r.source.isPowerOfTwo),e.canBatch}};wi.extension={type:[S.WebGLPipes,S.WebGPUPipes,S.CanvasPipes],name:"tilingSprite"};});var gh=p(()=>{R();mm();G.add(wi);});var gm,_m,ym=p(()=>{ut();vo();gm=class xm extends vr{constructor(...t){super({});let e=t[0]??{};typeof e=="number"&&(I(V,"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={...xm.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 c=0;c<e;c++){let f=c%this.verticesX,d=c/this.verticesX|0;r.push(f*h,d*l),s.push(f/n,d/a);}let u=n*a;for(let c=0;c<u;c++){let f=c%n,d=c/n|0,m=d*this.verticesX+f,x=d*this.verticesX+f+1,g=(d+1)*this.verticesX+f,_=(d+1)*this.verticesX+f+1;o.push(m,x,g,x,_,g);}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();}};gm.defaultOptions={width:100,height:100,verticesX:10,verticesY:10};_m=gm;});var bm,Sm,Tm=p(()=>{ym();bm=class vm extends _m{constructor(t={}){t={...vm.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,u=s+o,c=e>u?1:e/u,f=n+a,d=r>f?1:r/f,m=Math.min(c,d),x=h*e,g=l*r;t[0]=t[8]=t[16]=t[24]=-x,t[2]=t[10]=t[18]=t[26]=s*m-x,t[4]=t[12]=t[20]=t[28]=e-o*m-x,t[6]=t[14]=t[22]=t[30]=e-x,t[1]=t[3]=t[5]=t[7]=-g,t[9]=t[11]=t[13]=t[15]=n*m-g,t[17]=t[19]=t[21]=t[23]=r-a*m-g,t[25]=t[27]=t[29]=t[31]=r-g,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();}};bm.defaultOptions={width:100,height:100,leftWidth:10,topHeight:10,rightWidth:10,bottomHeight:10,originalWidth:100,originalHeight:100};Sm=bm;});var Pi,wm=p(()=>{R();It();Ks();Tm();Pi=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(ye);return e.geometry=z.get(Sm),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;}};Pi.extension={type:[S.WebGLPipes,S.WebGPUPipes,S.CanvasPipes],name:"nineSliceSprite"};});var xh=p(()=>{R();wm();G.add(Pi);});var Mi,Pm=p(()=>{R();Mi=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;}};Mi.extension={type:[S.WebGLPipes,S.WebGPUPipes,S.CanvasPipes],name:"filter"};});function Mm(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 Cm=p(()=>{});var e_,Ci,Am=p(()=>{R();J();Vt();Jr();ri();xe();mt();$e();ii();zt();Cm();_t();e_=new Qt({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])}),Ci=class{constructor(t){this._filterStackIndex=0,this._filterStack=[],this._filterGlobalUniforms=new wt({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 Dt({}),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?Mm(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,u=false,c=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)){c=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."),c=false;break}c=m.enabled||c,u||(u=m.blendRequired);}if(!c){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=u,s.container=t.container,s.filterEffect=t.filterEffect,s.previousRenderSurface=e.renderTarget.renderSurface,s.inputTexture=yt.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=F.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),yt.returnTexture(r);else {let a=e.inputTexture,h=yt.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 c=a;a=h,h=c;}n[l].apply(this,a,e.previousRenderSurface,false),yt.returnTexture(a),yt.returnTexture(h);}e.blendRequired&&yt.returnTexture(o);}getBackTexture(t,e,r){let s=t.colorTexture.source._resolution,o=yt.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=W.shared,u=n.previousRenderSurface===r,c=this.renderer.renderTarget.rootRenderTarget.colorTexture.source._resolution,f=this._filterStackIndex-1;for(;f>0&&this._filterStack[f].skip;)--f;f>0&&(c=this._filterStack[f].inputTexture.source._resolution);let d=this._filterGlobalUniforms,m=d.uniforms,x=m.uOutputFrame,g=m.uInputSize,_=m.uInputPixel,y=m.uInputClamp,b=m.uGlobalFrame,v=m.uOutputTexture;if(u){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}}x[0]=a.minX-h.x,x[1]=a.minY-h.y;}else x[0]=0,x[1]=0;x[2]=e.frame.width,x[3]=e.frame.height,g[0]=e.source.width,g[1]=e.source.height,g[2]=1/g[0],g[3]=1/g[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*g[2]-.5*_[2],y[3]=e.frame.height*g[3]-.5*_[3];let P=this.renderer.renderTarget.rootRenderTarget.colorTexture;b[0]=h.x*c,b[1]=h.y*c,b[2]=P.source.width*c,b[3]=P.source.height*c;let T=this.renderer.renderTarget.getRenderTarget(r);if(o.renderTarget.bind(r,!!s),r instanceof F?(v[0]=r.frame.width,v[1]=r.frame.height):(v[0]=T.width,v[1]=T.height),v[2]=T.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:e_,shader:t,state:t._state,topology:"triangle-list"}),o.type===Jt.WEBGL&&o.renderTarget.finishRenderPass();}_getFilterData(){return {skip:false,inputTexture:null,bounds:new rt,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}};Ci.extension={type:[S.WebGLSystem,S.WebGPUSystem],name:"filter"};});var _h=p(()=>{R();Pm();Am();G.add(Ci);G.add(Mi);});var r_={};var Em=p(()=>{lu();gn();xu();yu();ps();bs();Pa();Ma();Ba();ih();uh();fh();gh();xh();_h();});var i_={};var Rm=p(()=>{gn();ps();bs();Pa();Ma();Ba();ih();uh();fh();gh();xh();_h();});var Xt={};$m(Xt,{DistortionFilter:()=>Oi,EqualizerFilter:()=>kt,Filter:()=>lt,MonoFilter:()=>Vi,ReverbFilter:()=>zi,StereoFilter:()=>Hi,StreamFilter:()=>Wi,TelephoneFilter:()=>Ni});var Ph;function Mh(i){return Ph=i,i}function $(){return Ph}var lt=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 Oi=class extends lt{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 nt=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 lt{constructor(i=0,t=0,e=0,r=0,s=0,o=0,n=0,a=0,h=0,l=0){let u=[],c=[{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||(u=c.map(f=>{let d=$().context.audioContext.createBiquadFilter();return d.type=f.type,nt.setParamValue(d.Q,1),d.frequency.value=f.f,nt.setParamValue(d.gain,f.gain),d})),super(u[0],u[u.length-1]),this.bands=u,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}`);nt.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=>{nt.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 Vi=class extends lt{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 zi=class extends lt{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 Hi=class extends lt{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?nt.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 Wi=class extends lt{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 Ni=class extends lt{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",nt.setParamValue(s.frequency,2e3),o.type="lowpass",nt.setParamValue(o.frequency,2e3),n.type="highpass",nt.setParamValue(n.frequency,500),a.type="highpass",nt.setParamValue(a.frequency,500),s.connect(o),o.connect(n),n.connect(a),t=s,e=a;}super(t,e);}};R();var Bm={extension:{type:S.Environment,name:"browser",priority:-1},test:()=>true,load:async()=>{await Promise.resolve().then(()=>(Em(),r_));}};R();var Fm={extension:{type:S.Environment,name:"webworker",priority:0},test:()=>typeof self<"u"&&self.WorkerGlobalScope!==void 0,load:async()=>{await Promise.resolve().then(()=>(Rm(),i_));}};R();R();bs();ps();Pn();Wt();Dn();zr();Ct();fs();Li(da());G.add(Bm,Fm);var Ai=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 o_=0,yh=class extends Y{constructor(i){super(),this.id=o_++,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-yh.PADDING),this._end=Math.min(this._end+yh.PADDING,this._duration),this._source.onloadedmetadata=()=>{this._source&&(this._source.currentTime=t,this._source.onloadedmetadata=null,this.emit("progress",t/this._duration,this._duration),ct.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(){ct.shared.remove(this._onUpdate,this),this._internalStop(),this.emit("progress",1,this._duration),this.emit("end",this);}destroy(){ct.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}]`}},Po=yh;Po.PADDING=.1;var Ei=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 Po(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 Bi=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 Ve=["ogg","oga","opus","m4a","mp3","mpeg","wav","aiff","wma","mid","caf"],bh=["audio/mpeg","audio/ogg"],ze={};function km(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$/;Ve.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(ze,r);}km();var a_=0,Ri=class extends Y{constructor(t){super(),this.id=a_++,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);nt.setParamValue(this._gain.gain,o*s*r),nt.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:u}=this._media.nodes.cloneBufferSource();this._source=l,this._gain=u,this._speed=s,this._volume=n,this._loop=!!o,this._muted=a,this._filters=h,this.refresh();let c=this._source.buffer.duration;this._duration=c,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){ct.shared.remove(this._updateListener,this),t&&ct.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 He=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 Gm=class extends He{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(Gm.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,nt.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}},Mo=Gm;Mo.BUFFER_SIZE=0;var We=class{init(t){this.parent=t,this._nodes=new Mo(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 Ri(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 it.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 Sr=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 Ei:new We;return new Sr(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:Mt.extname(e).slice(1)})).filter(({ext:e})=>ze[e]).sort((e,r)=>Ve.indexOf(e.ext)-Ve.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 Bi(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(Sr._pool.length>0){let i=Sr._pool.pop();return i.init(this.media),i}return this.media.create()}_poolInstance(i){i.destroy(),Sr._pool.indexOf(i)<0&&Sr._pool.push(i);}},ve=Sr;ve._pool=[];var Tr=class i extends He{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 Co=class{constructor(){this.init();}init(){return this.supported&&(this._webAudioContext=new Tr),this._htmlAudioContext=new Ai,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 Tr.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 ve)return this._sounds[t]=e,e;let r=this._getOptions(e),s=ve.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 Im=i=>{let t=i.src,e=i?.alias?.[0];return (!e||i.src===e)&&(e=Mt.basename(t,Mt.extname(t))),e},Dm={extension:S.Asset,detection:{test:async()=>true,add:async i=>[...i,...Ve.filter(t=>ze[t])],remove:async i=>i.filter(t=>i.includes(t))},loader:{name:"sound",extension:{type:[S.LoadParser],priority:qe.High},test(i){let t=Mt.extname(i).slice(1);return !!ze[t]||bh.some(e=>i.startsWith(`data:${e}`))},async load(i,t){let e=await new Promise((r,s)=>ve.from({...t.data,url:i,preload:true,loaded(o,n){o?s(o):r(n),t.data?.loaded?.(o,n);}}));return $().add(Im(t),e),e},async unload(i,t){$().remove(Im(t));}}};G.add(Dm);Mh(new Co);({DistortionFilter:Xt.DistortionFilter,EqualizerFilter:Xt.EqualizerFilter,MonoFilter:Xt.MonoFilter,ReverbFilter:Xt.ReverbFilter,StereoFilter:Xt.StereoFilter,StreamFilter:Xt.StreamFilter,TelephoneFilter:Xt.TelephoneFilter});var Ft={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___",FLAGS_CATEGORY_KEY:"___flags___",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___",TEMP_STORAGE_KEY:"___temp_storage___",TEMP_STORAGE_DEADLINES_KEY:"___temp_storage_deadlines___"};var ot;(s=>(s.log=(o,...n)=>console.log(`[Pixi\u2019VN] ${o}`,...n),s.warn=(o,...n)=>console.warn(`[Pixi\u2019VN] ${o}`,...n),s.error=(o,...n)=>console.error(`[Pixi\u2019VN] ${o}`,...n),s.info=(o,...n)=>console.info(`[Pixi\u2019VN] ${o}`,...n)))(ot||={});function ki(i){try{if(typeof i>"u")return i;let t=JSON.stringify(i);return JSON.parse(t)}catch(t){throw ot.error("Error creating exportable element",i,t),new Error("[Pixi\u2019VN] Error creating exportable element")}}var Q=class i{static storage=new Map;static startingStorage=[];constructor(){}static get keysSystem(){return Ft}static get tempStorage(){return i.storage.get(Ft.TEMP_STORAGE_KEY)||{}}static set tempStorage(t){i.storage.set(Ft.TEMP_STORAGE_KEY,t);}static get tempStorageDeadlines(){return i.storage.get(Ft.TEMP_STORAGE_DEADLINES_KEY)||{}}static set tempStorageDeadlines(t){i.storage.set(Ft.TEMP_STORAGE_DEADLINES_KEY,t);}static getTempVariable(t){if(i.tempStorage.hasOwnProperty(t))return ki(i.tempStorage[t])}static clearOldTempVariables(t){let e=i.tempStorage,r=i.tempStorageDeadlines;if(t===0)e={},r={};else for(let s in r)r[s]<t&&(delete e[s],delete r[s]);i.tempStorage=e,i.tempStorageDeadlines=r;}static setVariable(t,e){if(i.storage.has(t.toLowerCase())&&i.storage.delete(t.toLowerCase()),e==null){i.storage.delete(t);return}i.storage.set(t,e);}static getVariable(t){let e=i.getTempVariable(t);return e!==void 0?e:(!i.storage.has(t)&&i.storage.has(t.toLowerCase())&&(t=t.toLowerCase()),ki(i.storage.get(t)))}static removeVariable(t){!i.storage.has(t)&&i.storage.has(t.toLowerCase())&&(t=t.toLowerCase()),i.storage.delete(t);}static setFlag(t,e){let r=i.getVariable(Ft.FLAGS_CATEGORY_KEY)||[];if(e)r.includes(t)||r.push(t);else {let s=r.indexOf(t);s>-1&&r.splice(s,1);}i.setVariable(Ft.FLAGS_CATEGORY_KEY,r);}static getFlag(t){return (i.getVariable(Ft.FLAGS_CATEGORY_KEY)||[]).includes(t)}};var wr=class{constructor(t,e){this.categoryId=t,this._id=e;}_id;get id(){return this._id}categoryId;setStorageProperty(t,e){let r=Q.getVariable(this.categoryId);r||(r={}),r.hasOwnProperty(this.id)||(r[this.id]={}),e==null?r[this.id].hasOwnProperty(t)&&delete r[this.id][t]:r[this.id]={...r[this.id],[t]:e},Object.keys(r[this.id]).length===0&&delete r[this.id],Q.setVariable(this.categoryId,r);}getStorageProperty(t,e=this.id){let r=Q.getVariable(this.categoryId);if(r&&r.hasOwnProperty(e)&&r[e].hasOwnProperty(t))return r[e][t]}};var u_="@",Pr=class extends wr{sourceId;constructor(t,e=""){super(Ft.CHARACTER_CATEGORY_KEY,t+(e?u_+e:"")),this.sourceId=t;}getStorageProperty(t){let e=super.getStorageProperty(t);return e===void 0&&(e=super.getStorageProperty(t,this.sourceId)),e}};var Ao=class extends Pr{constructor(t,e){super(typeof t=="string"?t:t.id,typeof t=="string"?"":t.emotion),this.defaultName=e.name,this.defaultSurname=e.surname,this.defaultAge=e.age,this._icon=e.icon,this._color=e.color;}defaultName;get name(){return this.getStorageProperty("name")||this.defaultName||this.id}set name(t){this.setStorageProperty("name",t);}defaultSurname;get surname(){return this.getStorageProperty("surname")||this.defaultSurname}set surname(t){this.setStorageProperty("surname",t);}defaultAge;get age(){return this.getStorageProperty("age")||this.defaultAge}set age(t){this.setStorageProperty("age",t);}_icon;get icon(){return this._icon}_color;get color(){return this._color}};var Eo={};function Um(i){if(Array.isArray(i)){i.forEach(t=>Um(t));return}Eo[i.id]&&ot.info(`Character id ${i.id} already exists, it will be overwritten`),Eo[i.id]=i;}function c_(i){try{let t=Eo[i];if(!t){ot.error(`Character ${i} not found, did you forget to register it with the saveCharacter?`);return}return t}catch(t){ot.error(`Error while getting Character ${i}`,t);return}}function d_(){return Object.values(Eo)}exports.CharacterBaseModel=Ao;exports.CharacterStoredClass=Pr;exports.getAllCharacters=d_;exports.getCharacterById=c_;exports.saveCharacter=Um;
|
|
569
|
+
`}};});var ph,mh,So,am=p(()=>{J();ks();im();Ls();si();xe();mt();nm();So=class extends te{constructor(){ph??(ph=or({name:"tiling-sprite-shader",bits:[Ti,sm,ar]})),mh??(mh=nr({name:"tiling-sprite-shader",bits:[rm,om,hr]}));let t=new wt({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:mh,gpuProgram:ph,resources:{localUniforms:new wt({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:F.EMPTY.source,uSampler:F.EMPTY.source.style}});}updateUniforms(t,e,r,s,o,n){let a=this.resources.tilingUniforms,h=n.width,l=n.height,u=n.textureMatrix,c=a.uniforms.uTextureTransform;c.set(r.a*h/t,r.b*h/e,r.c*l/t,r.d*l/e,r.tx/t,r.ty/e),c.invert(),a.uniforms.uMapCoord=u.mapCoord,a.uniforms.uClampFrame=u.uClampFrame,a.uniforms.uClampOffset=u.uClampOffset,a.uniforms.uTextureTransform=c,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 To,hm=p(()=>{vo();To=class extends vr{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 lm(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 um=p(()=>{});function cm(i,t,e,r){let s=0,o=i.length/(t),n=r.a,a=r.b,h=r.c,l=r.d,u=r.tx,c=r.ty;for(e*=t;s<o;){let f=i[e],d=i[e+1];i[e]=n*f+h*d+u,i[e+1]=a*f+l*d+c,e+=t,s++;}}var dm=p(()=>{});function fm(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),cm(t,2,0,a);}var pm=p(()=>{J();dm();});var wo,wi,mm=p(()=>{R();ti();js();ii();hi();Ks();vo();am();hm();um();pm();wo=new To,wi=class{constructor(t){this._state=Ue.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 ye);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 So),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,_e(t.groupColorAlpha,r.uColor,0),this._state.blendMode=ae(t.groupBlendMode,t.texture._source),this._renderer.encoder.draw({geometry:wo,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 vr({indices:wo.indices,positions:wo.positions.slice(),uvs:wo.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()),fm(t,r.uvs),lm(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===Jt.WEBGL&&(s=this._renderer.context.supports.nonPowOf2wrapping),e.canBatch=r.textureMatrix.isSimple&&(s||r.source.isPowerOfTwo),e.canBatch}};wi.extension={type:[S.WebGLPipes,S.WebGPUPipes,S.CanvasPipes],name:"tilingSprite"};});var gh=p(()=>{R();mm();G.add(wi);});var gm,_m,ym=p(()=>{ut();vo();gm=class xm extends vr{constructor(...t){super({});let e=t[0]??{};typeof e=="number"&&(I(V,"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={...xm.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 c=0;c<e;c++){let f=c%this.verticesX,d=c/this.verticesX|0;r.push(f*h,d*l),s.push(f/n,d/a);}let u=n*a;for(let c=0;c<u;c++){let f=c%n,d=c/n|0,m=d*this.verticesX+f,x=d*this.verticesX+f+1,g=(d+1)*this.verticesX+f,_=(d+1)*this.verticesX+f+1;o.push(m,x,g,x,_,g);}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();}};gm.defaultOptions={width:100,height:100,verticesX:10,verticesY:10};_m=gm;});var bm,Sm,Tm=p(()=>{ym();bm=class vm extends _m{constructor(t={}){t={...vm.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,u=s+o,c=e>u?1:e/u,f=n+a,d=r>f?1:r/f,m=Math.min(c,d),x=h*e,g=l*r;t[0]=t[8]=t[16]=t[24]=-x,t[2]=t[10]=t[18]=t[26]=s*m-x,t[4]=t[12]=t[20]=t[28]=e-o*m-x,t[6]=t[14]=t[22]=t[30]=e-x,t[1]=t[3]=t[5]=t[7]=-g,t[9]=t[11]=t[13]=t[15]=n*m-g,t[17]=t[19]=t[21]=t[23]=r-a*m-g,t[25]=t[27]=t[29]=t[31]=r-g,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();}};bm.defaultOptions={width:100,height:100,leftWidth:10,topHeight:10,rightWidth:10,bottomHeight:10,originalWidth:100,originalHeight:100};Sm=bm;});var Pi,wm=p(()=>{R();It();Ks();Tm();Pi=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(ye);return e.geometry=z.get(Sm),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;}};Pi.extension={type:[S.WebGLPipes,S.WebGPUPipes,S.CanvasPipes],name:"nineSliceSprite"};});var xh=p(()=>{R();wm();G.add(Pi);});var Mi,Pm=p(()=>{R();Mi=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;}};Mi.extension={type:[S.WebGLPipes,S.WebGPUPipes,S.CanvasPipes],name:"filter"};});function Mm(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 Cm=p(()=>{});var e_,Ci,Am=p(()=>{R();J();Vt();Jr();ri();xe();mt();$e();ii();zt();Cm();_t();e_=new Qt({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])}),Ci=class{constructor(t){this._filterStackIndex=0,this._filterStack=[],this._filterGlobalUniforms=new wt({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 Dt({}),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?Mm(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,u=false,c=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)){c=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."),c=false;break}c=m.enabled||c,u||(u=m.blendRequired);}if(!c){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=u,s.container=t.container,s.filterEffect=t.filterEffect,s.previousRenderSurface=e.renderTarget.renderSurface,s.inputTexture=yt.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=F.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),yt.returnTexture(r);else {let a=e.inputTexture,h=yt.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 c=a;a=h,h=c;}n[l].apply(this,a,e.previousRenderSurface,false),yt.returnTexture(a),yt.returnTexture(h);}e.blendRequired&&yt.returnTexture(o);}getBackTexture(t,e,r){let s=t.colorTexture.source._resolution,o=yt.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=W.shared,u=n.previousRenderSurface===r,c=this.renderer.renderTarget.rootRenderTarget.colorTexture.source._resolution,f=this._filterStackIndex-1;for(;f>0&&this._filterStack[f].skip;)--f;f>0&&(c=this._filterStack[f].inputTexture.source._resolution);let d=this._filterGlobalUniforms,m=d.uniforms,x=m.uOutputFrame,g=m.uInputSize,_=m.uInputPixel,y=m.uInputClamp,b=m.uGlobalFrame,v=m.uOutputTexture;if(u){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}}x[0]=a.minX-h.x,x[1]=a.minY-h.y;}else x[0]=0,x[1]=0;x[2]=e.frame.width,x[3]=e.frame.height,g[0]=e.source.width,g[1]=e.source.height,g[2]=1/g[0],g[3]=1/g[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*g[2]-.5*_[2],y[3]=e.frame.height*g[3]-.5*_[3];let P=this.renderer.renderTarget.rootRenderTarget.colorTexture;b[0]=h.x*c,b[1]=h.y*c,b[2]=P.source.width*c,b[3]=P.source.height*c;let T=this.renderer.renderTarget.getRenderTarget(r);if(o.renderTarget.bind(r,!!s),r instanceof F?(v[0]=r.frame.width,v[1]=r.frame.height):(v[0]=T.width,v[1]=T.height),v[2]=T.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:e_,shader:t,state:t._state,topology:"triangle-list"}),o.type===Jt.WEBGL&&o.renderTarget.finishRenderPass();}_getFilterData(){return {skip:false,inputTexture:null,bounds:new rt,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}};Ci.extension={type:[S.WebGLSystem,S.WebGPUSystem],name:"filter"};});var _h=p(()=>{R();Pm();Am();G.add(Ci);G.add(Mi);});var r_={};var Em=p(()=>{lu();gn();xu();yu();ps();bs();Pa();Ma();Ba();ih();uh();fh();gh();xh();_h();});var i_={};var Rm=p(()=>{gn();ps();bs();Pa();Ma();Ba();ih();uh();fh();gh();xh();_h();});var Xt={};$m(Xt,{DistortionFilter:()=>Oi,EqualizerFilter:()=>kt,Filter:()=>lt,MonoFilter:()=>Vi,ReverbFilter:()=>zi,StereoFilter:()=>Hi,StreamFilter:()=>Wi,TelephoneFilter:()=>Ni});var Ph;function Mh(i){return Ph=i,i}function $(){return Ph}var lt=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 Oi=class extends lt{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 nt=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 lt{constructor(i=0,t=0,e=0,r=0,s=0,o=0,n=0,a=0,h=0,l=0){let u=[],c=[{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||(u=c.map(f=>{let d=$().context.audioContext.createBiquadFilter();return d.type=f.type,nt.setParamValue(d.Q,1),d.frequency.value=f.f,nt.setParamValue(d.gain,f.gain),d})),super(u[0],u[u.length-1]),this.bands=u,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}`);nt.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=>{nt.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 Vi=class extends lt{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 zi=class extends lt{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 Hi=class extends lt{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?nt.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 Wi=class extends lt{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 Ni=class extends lt{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",nt.setParamValue(s.frequency,2e3),o.type="lowpass",nt.setParamValue(o.frequency,2e3),n.type="highpass",nt.setParamValue(n.frequency,500),a.type="highpass",nt.setParamValue(a.frequency,500),s.connect(o),o.connect(n),n.connect(a),t=s,e=a;}super(t,e);}};R();var Bm={extension:{type:S.Environment,name:"browser",priority:-1},test:()=>true,load:async()=>{await Promise.resolve().then(()=>(Em(),r_));}};R();var Fm={extension:{type:S.Environment,name:"webworker",priority:0},test:()=>typeof self<"u"&&self.WorkerGlobalScope!==void 0,load:async()=>{await Promise.resolve().then(()=>(Rm(),i_));}};R();R();bs();ps();Pn();Wt();Dn();zr();Ct();fs();Li(da());G.add(Bm,Fm);var Ai=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 o_=0,yh=class extends Y{constructor(i){super(),this.id=o_++,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-yh.PADDING),this._end=Math.min(this._end+yh.PADDING,this._duration),this._source.onloadedmetadata=()=>{this._source&&(this._source.currentTime=t,this._source.onloadedmetadata=null,this.emit("progress",t/this._duration,this._duration),ct.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(){ct.shared.remove(this._onUpdate,this),this._internalStop(),this.emit("progress",1,this._duration),this.emit("end",this);}destroy(){ct.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}]`}},Po=yh;Po.PADDING=.1;var Ei=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 Po(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 Bi=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 Ve=["ogg","oga","opus","m4a","mp3","mpeg","wav","aiff","wma","mid","caf"],bh=["audio/mpeg","audio/ogg"],ze={};function km(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$/;Ve.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(ze,r);}km();var a_=0,Ri=class extends Y{constructor(t){super(),this.id=a_++,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);nt.setParamValue(this._gain.gain,o*s*r),nt.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:u}=this._media.nodes.cloneBufferSource();this._source=l,this._gain=u,this._speed=s,this._volume=n,this._loop=!!o,this._muted=a,this._filters=h,this.refresh();let c=this._source.buffer.duration;this._duration=c,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){ct.shared.remove(this._updateListener,this),t&&ct.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 He=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 Gm=class extends He{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(Gm.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,nt.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}},Mo=Gm;Mo.BUFFER_SIZE=0;var We=class{init(t){this.parent=t,this._nodes=new Mo(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 Ri(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 it.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 Sr=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 Ei:new We;return new Sr(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:Mt.extname(e).slice(1)})).filter(({ext:e})=>ze[e]).sort((e,r)=>Ve.indexOf(e.ext)-Ve.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 Bi(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(Sr._pool.length>0){let i=Sr._pool.pop();return i.init(this.media),i}return this.media.create()}_poolInstance(i){i.destroy(),Sr._pool.indexOf(i)<0&&Sr._pool.push(i);}},ve=Sr;ve._pool=[];var Tr=class i extends He{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 Co=class{constructor(){this.init();}init(){return this.supported&&(this._webAudioContext=new Tr),this._htmlAudioContext=new Ai,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 Tr.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 ve)return this._sounds[t]=e,e;let r=this._getOptions(e),s=ve.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 Im=i=>{let t=i.src,e=i?.alias?.[0];return (!e||i.src===e)&&(e=Mt.basename(t,Mt.extname(t))),e},Dm={extension:S.Asset,detection:{test:async()=>true,add:async i=>[...i,...Ve.filter(t=>ze[t])],remove:async i=>i.filter(t=>i.includes(t))},loader:{name:"sound",extension:{type:[S.LoadParser],priority:qe.High},test(i){let t=Mt.extname(i).slice(1);return !!ze[t]||bh.some(e=>i.startsWith(`data:${e}`))},async load(i,t){let e=await new Promise((r,s)=>ve.from({...t.data,url:i,preload:true,loaded(o,n){o?s(o):r(n),t.data?.loaded?.(o,n);}}));return $().add(Im(t),e),e},async unload(i,t){$().remove(Im(t));}}};G.add(Dm);Mh(new Co);({DistortionFilter:Xt.DistortionFilter,EqualizerFilter:Xt.EqualizerFilter,MonoFilter:Xt.MonoFilter,ReverbFilter:Xt.ReverbFilter,StereoFilter:Xt.StereoFilter,StreamFilter:Xt.StreamFilter,TelephoneFilter:Xt.TelephoneFilter});var Ft={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___",FLAGS_CATEGORY_KEY:"___flags___",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___",TEMP_STORAGE_KEY:"___temp_storage___",TEMP_STORAGE_DEADLINES_KEY:"___temp_storage_deadlines___"};var ot;(s=>(s.log=(o,...n)=>console.log(`[Pixi\u2019VN] ${o}`,...n),s.warn=(o,...n)=>console.warn(`[Pixi\u2019VN] ${o}`,...n),s.error=(o,...n)=>console.error(`[Pixi\u2019VN] ${o}`,...n),s.info=(o,...n)=>console.info(`[Pixi\u2019VN] ${o}`,...n)))(ot||={});function ki(i){try{if(typeof i>"u")return i;let t=JSON.stringify(i);return JSON.parse(t)}catch(t){throw ot.error("Error creating exportable element",i,t),new Error("[Pixi\u2019VN] Error creating exportable element")}}var Q=class i{static storage=new Map;static startingStorage=[];constructor(){}static get keysSystem(){return Ft}static get tempStorage(){return i.storage.get(Ft.TEMP_STORAGE_KEY)||{}}static set tempStorage(t){i.storage.set(Ft.TEMP_STORAGE_KEY,t);}static get tempStorageDeadlines(){return i.storage.get(Ft.TEMP_STORAGE_DEADLINES_KEY)||{}}static set tempStorageDeadlines(t){i.storage.set(Ft.TEMP_STORAGE_DEADLINES_KEY,t);}static getTempVariable(t){if(i.tempStorage.hasOwnProperty(t))return ki(i.tempStorage[t])}static clearOldTempVariables(t){let e=i.tempStorage,r=i.tempStorageDeadlines;if(t===0)e={},r={};else for(let s in r)r[s]<t&&(delete e[s],delete r[s]);i.tempStorage=e,i.tempStorageDeadlines=r;}static setVariable(t,e){if(i.storage.has(t.toLowerCase())&&i.storage.delete(t.toLowerCase()),e==null){i.storage.delete(t);return}i.storage.set(t,e);}static getVariable(t){let e=i.getTempVariable(t);return e!==void 0?e:(!i.storage.has(t)&&i.storage.has(t.toLowerCase())&&(t=t.toLowerCase()),ki(i.storage.get(t)))}static removeVariable(t){!i.storage.has(t)&&i.storage.has(t.toLowerCase())&&(t=t.toLowerCase()),i.storage.delete(t);}static setFlag(t,e){let r=i.getVariable(Ft.FLAGS_CATEGORY_KEY)||[];if(e)r.includes(t)||r.push(t);else {let s=r.indexOf(t);s>-1&&r.splice(s,1);}i.setVariable(Ft.FLAGS_CATEGORY_KEY,r);}static getFlag(t){return (i.getVariable(Ft.FLAGS_CATEGORY_KEY)||[]).includes(t)}};var wr=class{constructor(t,e){this.categoryId=t,this._id=e;}_id;get id(){return this._id}categoryId;setStorageProperty(t,e){let r=Q.getVariable(this.categoryId);r||(r={}),r.hasOwnProperty(this.id)||(r[this.id]={}),e==null?r[this.id].hasOwnProperty(t)&&delete r[this.id][t]:r[this.id]={...r[this.id],[t]:e},Object.keys(r[this.id]).length===0&&delete r[this.id],Q.setVariable(this.categoryId,r);}getStorageProperty(t,e=this.id){let r=Q.getVariable(this.categoryId);if(r&&r.hasOwnProperty(e)&&r[e].hasOwnProperty(t))return r[e][t]}};var u_="@",Pr=class extends wr{sourceId;constructor(t,e=""){super(Ft.CHARACTER_CATEGORY_KEY,t+(e?u_+e:"")),this.sourceId=t;}getStorageProperty(t){let e=super.getStorageProperty(t);return e===void 0&&(e=super.getStorageProperty(t,this.sourceId)),e}};var Ao=class extends Pr{constructor(t,e){super(typeof t=="string"?t:t.id,typeof t=="string"?"":t.emotion),this.defaultName=e.name,this.defaultSurname=e.surname,this.defaultAge=e.age,this._icon=e.icon,this._color=e.color;}defaultName;get name(){return this.getStorageProperty("name")||this.defaultName||this.id}set name(t){this.setStorageProperty("name",t);}defaultSurname;get surname(){return this.getStorageProperty("surname")||this.defaultSurname}set surname(t){this.setStorageProperty("surname",t);}defaultAge;get age(){return this.getStorageProperty("age")||this.defaultAge}set age(t){this.setStorageProperty("age",t);}_icon;get icon(){return this._icon}_color;get color(){return this._color}};var Eo=new Map;function Um(i){if(Array.isArray(i)){i.forEach(t=>Um(t));return}Eo.get(i.id)&&ot.info(`Character id ${i.id} already exists, it will be overwritten`),Eo.set(i.id,i);}function c_(i){try{let t=Eo.get(i);if(!t){ot.error(`Character ${i} not found, did you forget to register it with the saveCharacter?`);return}return t}catch(t){ot.error(`Error while getting Character ${i}`,t);return}}function d_(){return Object.values(Eo)}exports.CharacterBaseModel=Ao;exports.CharacterStoredClass=Pr;exports.getAllCharacters=d_;exports.getCharacterById=c_;exports.saveCharacter=Um;
|
package/dist/character/index.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 ph,mh,So,am=p(()=>{J();ks();im();Ls();si();xe();mt();nm();So=class extends te{constructor(){ph??(ph=or({name:"tiling-sprite-shader",bits:[Ti,sm,ar]})),mh??(mh=nr({name:"tiling-sprite-shader",bits:[rm,om,hr]}));let t=new wt({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:mh,gpuProgram:ph,resources:{localUniforms:new wt({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:F.EMPTY.source,uSampler:F.EMPTY.source.style}});}updateUniforms(t,e,r,s,o,n){let a=this.resources.tilingUniforms,h=n.width,l=n.height,u=n.textureMatrix,c=a.uniforms.uTextureTransform;c.set(r.a*h/t,r.b*h/e,r.c*l/t,r.d*l/e,r.tx/t,r.ty/e),c.invert(),a.uniforms.uMapCoord=u.mapCoord,a.uniforms.uClampFrame=u.uClampFrame,a.uniforms.uClampOffset=u.uClampOffset,a.uniforms.uTextureTransform=c,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 To,hm=p(()=>{vo();To=class extends vr{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 lm(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 um=p(()=>{});function cm(i,t,e,r){let s=0,o=i.length/(t),n=r.a,a=r.b,h=r.c,l=r.d,u=r.tx,c=r.ty;for(e*=t;s<o;){let f=i[e],d=i[e+1];i[e]=n*f+h*d+u,i[e+1]=a*f+l*d+c,e+=t,s++;}}var dm=p(()=>{});function fm(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),cm(t,2,0,a);}var pm=p(()=>{J();dm();});var wo,wi,mm=p(()=>{R();ti();js();ii();hi();Ks();vo();am();hm();um();pm();wo=new To,wi=class{constructor(t){this._state=Ue.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 ye);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 So),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,_e(t.groupColorAlpha,r.uColor,0),this._state.blendMode=ae(t.groupBlendMode,t.texture._source),this._renderer.encoder.draw({geometry:wo,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 vr({indices:wo.indices,positions:wo.positions.slice(),uvs:wo.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()),fm(t,r.uvs),lm(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===Jt.WEBGL&&(s=this._renderer.context.supports.nonPowOf2wrapping),e.canBatch=r.textureMatrix.isSimple&&(s||r.source.isPowerOfTwo),e.canBatch}};wi.extension={type:[S.WebGLPipes,S.WebGPUPipes,S.CanvasPipes],name:"tilingSprite"};});var gh=p(()=>{R();mm();G.add(wi);});var gm,_m,ym=p(()=>{ut();vo();gm=class xm extends vr{constructor(...t){super({});let e=t[0]??{};typeof e=="number"&&(I(V,"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={...xm.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 c=0;c<e;c++){let f=c%this.verticesX,d=c/this.verticesX|0;r.push(f*h,d*l),s.push(f/n,d/a);}let u=n*a;for(let c=0;c<u;c++){let f=c%n,d=c/n|0,m=d*this.verticesX+f,x=d*this.verticesX+f+1,g=(d+1)*this.verticesX+f,_=(d+1)*this.verticesX+f+1;o.push(m,x,g,x,_,g);}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();}};gm.defaultOptions={width:100,height:100,verticesX:10,verticesY:10};_m=gm;});var bm,Sm,Tm=p(()=>{ym();bm=class vm extends _m{constructor(t={}){t={...vm.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,u=s+o,c=e>u?1:e/u,f=n+a,d=r>f?1:r/f,m=Math.min(c,d),x=h*e,g=l*r;t[0]=t[8]=t[16]=t[24]=-x,t[2]=t[10]=t[18]=t[26]=s*m-x,t[4]=t[12]=t[20]=t[28]=e-o*m-x,t[6]=t[14]=t[22]=t[30]=e-x,t[1]=t[3]=t[5]=t[7]=-g,t[9]=t[11]=t[13]=t[15]=n*m-g,t[17]=t[19]=t[21]=t[23]=r-a*m-g,t[25]=t[27]=t[29]=t[31]=r-g,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();}};bm.defaultOptions={width:100,height:100,leftWidth:10,topHeight:10,rightWidth:10,bottomHeight:10,originalWidth:100,originalHeight:100};Sm=bm;});var Pi,wm=p(()=>{R();It();Ks();Tm();Pi=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(ye);return e.geometry=z.get(Sm),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;}};Pi.extension={type:[S.WebGLPipes,S.WebGPUPipes,S.CanvasPipes],name:"nineSliceSprite"};});var xh=p(()=>{R();wm();G.add(Pi);});var Mi,Pm=p(()=>{R();Mi=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;}};Mi.extension={type:[S.WebGLPipes,S.WebGPUPipes,S.CanvasPipes],name:"filter"};});function Mm(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 Cm=p(()=>{});var e_,Ci,Am=p(()=>{R();J();Vt();Jr();ri();xe();mt();$e();ii();zt();Cm();_t();e_=new Qt({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])}),Ci=class{constructor(t){this._filterStackIndex=0,this._filterStack=[],this._filterGlobalUniforms=new wt({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 Dt({}),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?Mm(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,u=false,c=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)){c=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."),c=false;break}c=m.enabled||c,u||(u=m.blendRequired);}if(!c){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=u,s.container=t.container,s.filterEffect=t.filterEffect,s.previousRenderSurface=e.renderTarget.renderSurface,s.inputTexture=yt.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=F.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),yt.returnTexture(r);else {let a=e.inputTexture,h=yt.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 c=a;a=h,h=c;}n[l].apply(this,a,e.previousRenderSurface,false),yt.returnTexture(a),yt.returnTexture(h);}e.blendRequired&&yt.returnTexture(o);}getBackTexture(t,e,r){let s=t.colorTexture.source._resolution,o=yt.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=W.shared,u=n.previousRenderSurface===r,c=this.renderer.renderTarget.rootRenderTarget.colorTexture.source._resolution,f=this._filterStackIndex-1;for(;f>0&&this._filterStack[f].skip;)--f;f>0&&(c=this._filterStack[f].inputTexture.source._resolution);let d=this._filterGlobalUniforms,m=d.uniforms,x=m.uOutputFrame,g=m.uInputSize,_=m.uInputPixel,y=m.uInputClamp,b=m.uGlobalFrame,v=m.uOutputTexture;if(u){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}}x[0]=a.minX-h.x,x[1]=a.minY-h.y;}else x[0]=0,x[1]=0;x[2]=e.frame.width,x[3]=e.frame.height,g[0]=e.source.width,g[1]=e.source.height,g[2]=1/g[0],g[3]=1/g[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*g[2]-.5*_[2],y[3]=e.frame.height*g[3]-.5*_[3];let P=this.renderer.renderTarget.rootRenderTarget.colorTexture;b[0]=h.x*c,b[1]=h.y*c,b[2]=P.source.width*c,b[3]=P.source.height*c;let T=this.renderer.renderTarget.getRenderTarget(r);if(o.renderTarget.bind(r,!!s),r instanceof F?(v[0]=r.frame.width,v[1]=r.frame.height):(v[0]=T.width,v[1]=T.height),v[2]=T.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:e_,shader:t,state:t._state,topology:"triangle-list"}),o.type===Jt.WEBGL&&o.renderTarget.finishRenderPass();}_getFilterData(){return {skip:false,inputTexture:null,bounds:new rt,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}};Ci.extension={type:[S.WebGLSystem,S.WebGPUSystem],name:"filter"};});var _h=p(()=>{R();Pm();Am();G.add(Ci);G.add(Mi);});var r_={};var Em=p(()=>{lu();gn();xu();yu();ps();bs();Pa();Ma();Ba();ih();uh();fh();gh();xh();_h();});var i_={};var Rm=p(()=>{gn();ps();bs();Pa();Ma();Ba();ih();uh();fh();gh();xh();_h();});var Xt={};$m(Xt,{DistortionFilter:()=>Oi,EqualizerFilter:()=>kt,Filter:()=>lt,MonoFilter:()=>Vi,ReverbFilter:()=>zi,StereoFilter:()=>Hi,StreamFilter:()=>Wi,TelephoneFilter:()=>Ni});var Ph;function Mh(i){return Ph=i,i}function $(){return Ph}var lt=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 Oi=class extends lt{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 nt=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 lt{constructor(i=0,t=0,e=0,r=0,s=0,o=0,n=0,a=0,h=0,l=0){let u=[],c=[{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||(u=c.map(f=>{let d=$().context.audioContext.createBiquadFilter();return d.type=f.type,nt.setParamValue(d.Q,1),d.frequency.value=f.f,nt.setParamValue(d.gain,f.gain),d})),super(u[0],u[u.length-1]),this.bands=u,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}`);nt.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=>{nt.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 Vi=class extends lt{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 zi=class extends lt{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 Hi=class extends lt{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?nt.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 Wi=class extends lt{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 Ni=class extends lt{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",nt.setParamValue(s.frequency,2e3),o.type="lowpass",nt.setParamValue(o.frequency,2e3),n.type="highpass",nt.setParamValue(n.frequency,500),a.type="highpass",nt.setParamValue(a.frequency,500),s.connect(o),o.connect(n),n.connect(a),t=s,e=a;}super(t,e);}};R();var Bm={extension:{type:S.Environment,name:"browser",priority:-1},test:()=>true,load:async()=>{await Promise.resolve().then(()=>(Em(),r_));}};R();var Fm={extension:{type:S.Environment,name:"webworker",priority:0},test:()=>typeof self<"u"&&self.WorkerGlobalScope!==void 0,load:async()=>{await Promise.resolve().then(()=>(Rm(),i_));}};R();R();bs();ps();Pn();Wt();Dn();zr();Ct();fs();Li(da());G.add(Bm,Fm);var Ai=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 o_=0,yh=class extends Y{constructor(i){super(),this.id=o_++,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-yh.PADDING),this._end=Math.min(this._end+yh.PADDING,this._duration),this._source.onloadedmetadata=()=>{this._source&&(this._source.currentTime=t,this._source.onloadedmetadata=null,this.emit("progress",t/this._duration,this._duration),ct.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(){ct.shared.remove(this._onUpdate,this),this._internalStop(),this.emit("progress",1,this._duration),this.emit("end",this);}destroy(){ct.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}]`}},Po=yh;Po.PADDING=.1;var Ei=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 Po(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 Bi=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 Ve=["ogg","oga","opus","m4a","mp3","mpeg","wav","aiff","wma","mid","caf"],bh=["audio/mpeg","audio/ogg"],ze={};function km(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$/;Ve.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(ze,r);}km();var a_=0,Ri=class extends Y{constructor(t){super(),this.id=a_++,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);nt.setParamValue(this._gain.gain,o*s*r),nt.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:u}=this._media.nodes.cloneBufferSource();this._source=l,this._gain=u,this._speed=s,this._volume=n,this._loop=!!o,this._muted=a,this._filters=h,this.refresh();let c=this._source.buffer.duration;this._duration=c,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){ct.shared.remove(this._updateListener,this),t&&ct.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 He=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 Gm=class extends He{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(Gm.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,nt.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}},Mo=Gm;Mo.BUFFER_SIZE=0;var We=class{init(t){this.parent=t,this._nodes=new Mo(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 Ri(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 it.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 Sr=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 Ei:new We;return new Sr(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:Mt.extname(e).slice(1)})).filter(({ext:e})=>ze[e]).sort((e,r)=>Ve.indexOf(e.ext)-Ve.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 Bi(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(Sr._pool.length>0){let i=Sr._pool.pop();return i.init(this.media),i}return this.media.create()}_poolInstance(i){i.destroy(),Sr._pool.indexOf(i)<0&&Sr._pool.push(i);}},ve=Sr;ve._pool=[];var Tr=class i extends He{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 Co=class{constructor(){this.init();}init(){return this.supported&&(this._webAudioContext=new Tr),this._htmlAudioContext=new Ai,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 Tr.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 ve)return this._sounds[t]=e,e;let r=this._getOptions(e),s=ve.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 Im=i=>{let t=i.src,e=i?.alias?.[0];return (!e||i.src===e)&&(e=Mt.basename(t,Mt.extname(t))),e},Dm={extension:S.Asset,detection:{test:async()=>true,add:async i=>[...i,...Ve.filter(t=>ze[t])],remove:async i=>i.filter(t=>i.includes(t))},loader:{name:"sound",extension:{type:[S.LoadParser],priority:qe.High},test(i){let t=Mt.extname(i).slice(1);return !!ze[t]||bh.some(e=>i.startsWith(`data:${e}`))},async load(i,t){let e=await new Promise((r,s)=>ve.from({...t.data,url:i,preload:true,loaded(o,n){o?s(o):r(n),t.data?.loaded?.(o,n);}}));return $().add(Im(t),e),e},async unload(i,t){$().remove(Im(t));}}};G.add(Dm);Mh(new Co);({DistortionFilter:Xt.DistortionFilter,EqualizerFilter:Xt.EqualizerFilter,MonoFilter:Xt.MonoFilter,ReverbFilter:Xt.ReverbFilter,StereoFilter:Xt.StereoFilter,StreamFilter:Xt.StreamFilter,TelephoneFilter:Xt.TelephoneFilter});var Ft={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___",FLAGS_CATEGORY_KEY:"___flags___",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___",TEMP_STORAGE_KEY:"___temp_storage___",TEMP_STORAGE_DEADLINES_KEY:"___temp_storage_deadlines___"};var ot;(s=>(s.log=(o,...n)=>console.log(`[Pixi\u2019VN] ${o}`,...n),s.warn=(o,...n)=>console.warn(`[Pixi\u2019VN] ${o}`,...n),s.error=(o,...n)=>console.error(`[Pixi\u2019VN] ${o}`,...n),s.info=(o,...n)=>console.info(`[Pixi\u2019VN] ${o}`,...n)))(ot||={});function ki(i){try{if(typeof i>"u")return i;let t=JSON.stringify(i);return JSON.parse(t)}catch(t){throw ot.error("Error creating exportable element",i,t),new Error("[Pixi\u2019VN] Error creating exportable element")}}var Q=class i{static storage=new Map;static startingStorage=[];constructor(){}static get keysSystem(){return Ft}static get tempStorage(){return i.storage.get(Ft.TEMP_STORAGE_KEY)||{}}static set tempStorage(t){i.storage.set(Ft.TEMP_STORAGE_KEY,t);}static get tempStorageDeadlines(){return i.storage.get(Ft.TEMP_STORAGE_DEADLINES_KEY)||{}}static set tempStorageDeadlines(t){i.storage.set(Ft.TEMP_STORAGE_DEADLINES_KEY,t);}static getTempVariable(t){if(i.tempStorage.hasOwnProperty(t))return ki(i.tempStorage[t])}static clearOldTempVariables(t){let e=i.tempStorage,r=i.tempStorageDeadlines;if(t===0)e={},r={};else for(let s in r)r[s]<t&&(delete e[s],delete r[s]);i.tempStorage=e,i.tempStorageDeadlines=r;}static setVariable(t,e){if(i.storage.has(t.toLowerCase())&&i.storage.delete(t.toLowerCase()),e==null){i.storage.delete(t);return}i.storage.set(t,e);}static getVariable(t){let e=i.getTempVariable(t);return e!==void 0?e:(!i.storage.has(t)&&i.storage.has(t.toLowerCase())&&(t=t.toLowerCase()),ki(i.storage.get(t)))}static removeVariable(t){!i.storage.has(t)&&i.storage.has(t.toLowerCase())&&(t=t.toLowerCase()),i.storage.delete(t);}static setFlag(t,e){let r=i.getVariable(Ft.FLAGS_CATEGORY_KEY)||[];if(e)r.includes(t)||r.push(t);else {let s=r.indexOf(t);s>-1&&r.splice(s,1);}i.setVariable(Ft.FLAGS_CATEGORY_KEY,r);}static getFlag(t){return (i.getVariable(Ft.FLAGS_CATEGORY_KEY)||[]).includes(t)}};var wr=class{constructor(t,e){this.categoryId=t,this._id=e;}_id;get id(){return this._id}categoryId;setStorageProperty(t,e){let r=Q.getVariable(this.categoryId);r||(r={}),r.hasOwnProperty(this.id)||(r[this.id]={}),e==null?r[this.id].hasOwnProperty(t)&&delete r[this.id][t]:r[this.id]={...r[this.id],[t]:e},Object.keys(r[this.id]).length===0&&delete r[this.id],Q.setVariable(this.categoryId,r);}getStorageProperty(t,e=this.id){let r=Q.getVariable(this.categoryId);if(r&&r.hasOwnProperty(e)&&r[e].hasOwnProperty(t))return r[e][t]}};var u_="@",Pr=class extends wr{sourceId;constructor(t,e=""){super(Ft.CHARACTER_CATEGORY_KEY,t+(e?u_+e:"")),this.sourceId=t;}getStorageProperty(t){let e=super.getStorageProperty(t);return e===void 0&&(e=super.getStorageProperty(t,this.sourceId)),e}};var Ao=class extends Pr{constructor(t,e){super(typeof t=="string"?t:t.id,typeof t=="string"?"":t.emotion),this.defaultName=e.name,this.defaultSurname=e.surname,this.defaultAge=e.age,this._icon=e.icon,this._color=e.color;}defaultName;get name(){return this.getStorageProperty("name")||this.defaultName||this.id}set name(t){this.setStorageProperty("name",t);}defaultSurname;get surname(){return this.getStorageProperty("surname")||this.defaultSurname}set surname(t){this.setStorageProperty("surname",t);}defaultAge;get age(){return this.getStorageProperty("age")||this.defaultAge}set age(t){this.setStorageProperty("age",t);}_icon;get icon(){return this._icon}_color;get color(){return this._color}};var Eo={};function Um(i){if(Array.isArray(i)){i.forEach(t=>Um(t));return}Eo[i.id]&&ot.info(`Character id ${i.id} already exists, it will be overwritten`),Eo[i.id]=i;}function c_(i){try{let t=Eo[i];if(!t){ot.error(`Character ${i} not found, did you forget to register it with the saveCharacter?`);return}return t}catch(t){ot.error(`Error while getting Character ${i}`,t);return}}function d_(){return Object.values(Eo)}export{Ao as CharacterBaseModel,Pr as CharacterStoredClass,d_ as getAllCharacters,c_ as getCharacterById,Um as saveCharacter};
|
|
569
|
+
`}};});var ph,mh,So,am=p(()=>{J();ks();im();Ls();si();xe();mt();nm();So=class extends te{constructor(){ph??(ph=or({name:"tiling-sprite-shader",bits:[Ti,sm,ar]})),mh??(mh=nr({name:"tiling-sprite-shader",bits:[rm,om,hr]}));let t=new wt({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:mh,gpuProgram:ph,resources:{localUniforms:new wt({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:F.EMPTY.source,uSampler:F.EMPTY.source.style}});}updateUniforms(t,e,r,s,o,n){let a=this.resources.tilingUniforms,h=n.width,l=n.height,u=n.textureMatrix,c=a.uniforms.uTextureTransform;c.set(r.a*h/t,r.b*h/e,r.c*l/t,r.d*l/e,r.tx/t,r.ty/e),c.invert(),a.uniforms.uMapCoord=u.mapCoord,a.uniforms.uClampFrame=u.uClampFrame,a.uniforms.uClampOffset=u.uClampOffset,a.uniforms.uTextureTransform=c,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 To,hm=p(()=>{vo();To=class extends vr{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 lm(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 um=p(()=>{});function cm(i,t,e,r){let s=0,o=i.length/(t),n=r.a,a=r.b,h=r.c,l=r.d,u=r.tx,c=r.ty;for(e*=t;s<o;){let f=i[e],d=i[e+1];i[e]=n*f+h*d+u,i[e+1]=a*f+l*d+c,e+=t,s++;}}var dm=p(()=>{});function fm(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),cm(t,2,0,a);}var pm=p(()=>{J();dm();});var wo,wi,mm=p(()=>{R();ti();js();ii();hi();Ks();vo();am();hm();um();pm();wo=new To,wi=class{constructor(t){this._state=Ue.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 ye);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 So),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,_e(t.groupColorAlpha,r.uColor,0),this._state.blendMode=ae(t.groupBlendMode,t.texture._source),this._renderer.encoder.draw({geometry:wo,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 vr({indices:wo.indices,positions:wo.positions.slice(),uvs:wo.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()),fm(t,r.uvs),lm(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===Jt.WEBGL&&(s=this._renderer.context.supports.nonPowOf2wrapping),e.canBatch=r.textureMatrix.isSimple&&(s||r.source.isPowerOfTwo),e.canBatch}};wi.extension={type:[S.WebGLPipes,S.WebGPUPipes,S.CanvasPipes],name:"tilingSprite"};});var gh=p(()=>{R();mm();G.add(wi);});var gm,_m,ym=p(()=>{ut();vo();gm=class xm extends vr{constructor(...t){super({});let e=t[0]??{};typeof e=="number"&&(I(V,"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={...xm.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 c=0;c<e;c++){let f=c%this.verticesX,d=c/this.verticesX|0;r.push(f*h,d*l),s.push(f/n,d/a);}let u=n*a;for(let c=0;c<u;c++){let f=c%n,d=c/n|0,m=d*this.verticesX+f,x=d*this.verticesX+f+1,g=(d+1)*this.verticesX+f,_=(d+1)*this.verticesX+f+1;o.push(m,x,g,x,_,g);}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();}};gm.defaultOptions={width:100,height:100,verticesX:10,verticesY:10};_m=gm;});var bm,Sm,Tm=p(()=>{ym();bm=class vm extends _m{constructor(t={}){t={...vm.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,u=s+o,c=e>u?1:e/u,f=n+a,d=r>f?1:r/f,m=Math.min(c,d),x=h*e,g=l*r;t[0]=t[8]=t[16]=t[24]=-x,t[2]=t[10]=t[18]=t[26]=s*m-x,t[4]=t[12]=t[20]=t[28]=e-o*m-x,t[6]=t[14]=t[22]=t[30]=e-x,t[1]=t[3]=t[5]=t[7]=-g,t[9]=t[11]=t[13]=t[15]=n*m-g,t[17]=t[19]=t[21]=t[23]=r-a*m-g,t[25]=t[27]=t[29]=t[31]=r-g,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();}};bm.defaultOptions={width:100,height:100,leftWidth:10,topHeight:10,rightWidth:10,bottomHeight:10,originalWidth:100,originalHeight:100};Sm=bm;});var Pi,wm=p(()=>{R();It();Ks();Tm();Pi=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(ye);return e.geometry=z.get(Sm),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;}};Pi.extension={type:[S.WebGLPipes,S.WebGPUPipes,S.CanvasPipes],name:"nineSliceSprite"};});var xh=p(()=>{R();wm();G.add(Pi);});var Mi,Pm=p(()=>{R();Mi=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;}};Mi.extension={type:[S.WebGLPipes,S.WebGPUPipes,S.CanvasPipes],name:"filter"};});function Mm(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 Cm=p(()=>{});var e_,Ci,Am=p(()=>{R();J();Vt();Jr();ri();xe();mt();$e();ii();zt();Cm();_t();e_=new Qt({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])}),Ci=class{constructor(t){this._filterStackIndex=0,this._filterStack=[],this._filterGlobalUniforms=new wt({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 Dt({}),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?Mm(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,u=false,c=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)){c=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."),c=false;break}c=m.enabled||c,u||(u=m.blendRequired);}if(!c){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=u,s.container=t.container,s.filterEffect=t.filterEffect,s.previousRenderSurface=e.renderTarget.renderSurface,s.inputTexture=yt.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=F.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),yt.returnTexture(r);else {let a=e.inputTexture,h=yt.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 c=a;a=h,h=c;}n[l].apply(this,a,e.previousRenderSurface,false),yt.returnTexture(a),yt.returnTexture(h);}e.blendRequired&&yt.returnTexture(o);}getBackTexture(t,e,r){let s=t.colorTexture.source._resolution,o=yt.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=W.shared,u=n.previousRenderSurface===r,c=this.renderer.renderTarget.rootRenderTarget.colorTexture.source._resolution,f=this._filterStackIndex-1;for(;f>0&&this._filterStack[f].skip;)--f;f>0&&(c=this._filterStack[f].inputTexture.source._resolution);let d=this._filterGlobalUniforms,m=d.uniforms,x=m.uOutputFrame,g=m.uInputSize,_=m.uInputPixel,y=m.uInputClamp,b=m.uGlobalFrame,v=m.uOutputTexture;if(u){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}}x[0]=a.minX-h.x,x[1]=a.minY-h.y;}else x[0]=0,x[1]=0;x[2]=e.frame.width,x[3]=e.frame.height,g[0]=e.source.width,g[1]=e.source.height,g[2]=1/g[0],g[3]=1/g[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*g[2]-.5*_[2],y[3]=e.frame.height*g[3]-.5*_[3];let P=this.renderer.renderTarget.rootRenderTarget.colorTexture;b[0]=h.x*c,b[1]=h.y*c,b[2]=P.source.width*c,b[3]=P.source.height*c;let T=this.renderer.renderTarget.getRenderTarget(r);if(o.renderTarget.bind(r,!!s),r instanceof F?(v[0]=r.frame.width,v[1]=r.frame.height):(v[0]=T.width,v[1]=T.height),v[2]=T.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:e_,shader:t,state:t._state,topology:"triangle-list"}),o.type===Jt.WEBGL&&o.renderTarget.finishRenderPass();}_getFilterData(){return {skip:false,inputTexture:null,bounds:new rt,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}};Ci.extension={type:[S.WebGLSystem,S.WebGPUSystem],name:"filter"};});var _h=p(()=>{R();Pm();Am();G.add(Ci);G.add(Mi);});var r_={};var Em=p(()=>{lu();gn();xu();yu();ps();bs();Pa();Ma();Ba();ih();uh();fh();gh();xh();_h();});var i_={};var Rm=p(()=>{gn();ps();bs();Pa();Ma();Ba();ih();uh();fh();gh();xh();_h();});var Xt={};$m(Xt,{DistortionFilter:()=>Oi,EqualizerFilter:()=>kt,Filter:()=>lt,MonoFilter:()=>Vi,ReverbFilter:()=>zi,StereoFilter:()=>Hi,StreamFilter:()=>Wi,TelephoneFilter:()=>Ni});var Ph;function Mh(i){return Ph=i,i}function $(){return Ph}var lt=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 Oi=class extends lt{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 nt=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 lt{constructor(i=0,t=0,e=0,r=0,s=0,o=0,n=0,a=0,h=0,l=0){let u=[],c=[{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||(u=c.map(f=>{let d=$().context.audioContext.createBiquadFilter();return d.type=f.type,nt.setParamValue(d.Q,1),d.frequency.value=f.f,nt.setParamValue(d.gain,f.gain),d})),super(u[0],u[u.length-1]),this.bands=u,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}`);nt.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=>{nt.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 Vi=class extends lt{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 zi=class extends lt{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 Hi=class extends lt{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?nt.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 Wi=class extends lt{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 Ni=class extends lt{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",nt.setParamValue(s.frequency,2e3),o.type="lowpass",nt.setParamValue(o.frequency,2e3),n.type="highpass",nt.setParamValue(n.frequency,500),a.type="highpass",nt.setParamValue(a.frequency,500),s.connect(o),o.connect(n),n.connect(a),t=s,e=a;}super(t,e);}};R();var Bm={extension:{type:S.Environment,name:"browser",priority:-1},test:()=>true,load:async()=>{await Promise.resolve().then(()=>(Em(),r_));}};R();var Fm={extension:{type:S.Environment,name:"webworker",priority:0},test:()=>typeof self<"u"&&self.WorkerGlobalScope!==void 0,load:async()=>{await Promise.resolve().then(()=>(Rm(),i_));}};R();R();bs();ps();Pn();Wt();Dn();zr();Ct();fs();Li(da());G.add(Bm,Fm);var Ai=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 o_=0,yh=class extends Y{constructor(i){super(),this.id=o_++,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-yh.PADDING),this._end=Math.min(this._end+yh.PADDING,this._duration),this._source.onloadedmetadata=()=>{this._source&&(this._source.currentTime=t,this._source.onloadedmetadata=null,this.emit("progress",t/this._duration,this._duration),ct.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(){ct.shared.remove(this._onUpdate,this),this._internalStop(),this.emit("progress",1,this._duration),this.emit("end",this);}destroy(){ct.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}]`}},Po=yh;Po.PADDING=.1;var Ei=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 Po(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 Bi=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 Ve=["ogg","oga","opus","m4a","mp3","mpeg","wav","aiff","wma","mid","caf"],bh=["audio/mpeg","audio/ogg"],ze={};function km(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$/;Ve.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(ze,r);}km();var a_=0,Ri=class extends Y{constructor(t){super(),this.id=a_++,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);nt.setParamValue(this._gain.gain,o*s*r),nt.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:u}=this._media.nodes.cloneBufferSource();this._source=l,this._gain=u,this._speed=s,this._volume=n,this._loop=!!o,this._muted=a,this._filters=h,this.refresh();let c=this._source.buffer.duration;this._duration=c,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){ct.shared.remove(this._updateListener,this),t&&ct.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 He=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 Gm=class extends He{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(Gm.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,nt.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}},Mo=Gm;Mo.BUFFER_SIZE=0;var We=class{init(t){this.parent=t,this._nodes=new Mo(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 Ri(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 it.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 Sr=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 Ei:new We;return new Sr(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:Mt.extname(e).slice(1)})).filter(({ext:e})=>ze[e]).sort((e,r)=>Ve.indexOf(e.ext)-Ve.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 Bi(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(Sr._pool.length>0){let i=Sr._pool.pop();return i.init(this.media),i}return this.media.create()}_poolInstance(i){i.destroy(),Sr._pool.indexOf(i)<0&&Sr._pool.push(i);}},ve=Sr;ve._pool=[];var Tr=class i extends He{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 Co=class{constructor(){this.init();}init(){return this.supported&&(this._webAudioContext=new Tr),this._htmlAudioContext=new Ai,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 Tr.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 ve)return this._sounds[t]=e,e;let r=this._getOptions(e),s=ve.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 Im=i=>{let t=i.src,e=i?.alias?.[0];return (!e||i.src===e)&&(e=Mt.basename(t,Mt.extname(t))),e},Dm={extension:S.Asset,detection:{test:async()=>true,add:async i=>[...i,...Ve.filter(t=>ze[t])],remove:async i=>i.filter(t=>i.includes(t))},loader:{name:"sound",extension:{type:[S.LoadParser],priority:qe.High},test(i){let t=Mt.extname(i).slice(1);return !!ze[t]||bh.some(e=>i.startsWith(`data:${e}`))},async load(i,t){let e=await new Promise((r,s)=>ve.from({...t.data,url:i,preload:true,loaded(o,n){o?s(o):r(n),t.data?.loaded?.(o,n);}}));return $().add(Im(t),e),e},async unload(i,t){$().remove(Im(t));}}};G.add(Dm);Mh(new Co);({DistortionFilter:Xt.DistortionFilter,EqualizerFilter:Xt.EqualizerFilter,MonoFilter:Xt.MonoFilter,ReverbFilter:Xt.ReverbFilter,StereoFilter:Xt.StereoFilter,StreamFilter:Xt.StreamFilter,TelephoneFilter:Xt.TelephoneFilter});var Ft={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___",FLAGS_CATEGORY_KEY:"___flags___",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___",TEMP_STORAGE_KEY:"___temp_storage___",TEMP_STORAGE_DEADLINES_KEY:"___temp_storage_deadlines___"};var ot;(s=>(s.log=(o,...n)=>console.log(`[Pixi\u2019VN] ${o}`,...n),s.warn=(o,...n)=>console.warn(`[Pixi\u2019VN] ${o}`,...n),s.error=(o,...n)=>console.error(`[Pixi\u2019VN] ${o}`,...n),s.info=(o,...n)=>console.info(`[Pixi\u2019VN] ${o}`,...n)))(ot||={});function ki(i){try{if(typeof i>"u")return i;let t=JSON.stringify(i);return JSON.parse(t)}catch(t){throw ot.error("Error creating exportable element",i,t),new Error("[Pixi\u2019VN] Error creating exportable element")}}var Q=class i{static storage=new Map;static startingStorage=[];constructor(){}static get keysSystem(){return Ft}static get tempStorage(){return i.storage.get(Ft.TEMP_STORAGE_KEY)||{}}static set tempStorage(t){i.storage.set(Ft.TEMP_STORAGE_KEY,t);}static get tempStorageDeadlines(){return i.storage.get(Ft.TEMP_STORAGE_DEADLINES_KEY)||{}}static set tempStorageDeadlines(t){i.storage.set(Ft.TEMP_STORAGE_DEADLINES_KEY,t);}static getTempVariable(t){if(i.tempStorage.hasOwnProperty(t))return ki(i.tempStorage[t])}static clearOldTempVariables(t){let e=i.tempStorage,r=i.tempStorageDeadlines;if(t===0)e={},r={};else for(let s in r)r[s]<t&&(delete e[s],delete r[s]);i.tempStorage=e,i.tempStorageDeadlines=r;}static setVariable(t,e){if(i.storage.has(t.toLowerCase())&&i.storage.delete(t.toLowerCase()),e==null){i.storage.delete(t);return}i.storage.set(t,e);}static getVariable(t){let e=i.getTempVariable(t);return e!==void 0?e:(!i.storage.has(t)&&i.storage.has(t.toLowerCase())&&(t=t.toLowerCase()),ki(i.storage.get(t)))}static removeVariable(t){!i.storage.has(t)&&i.storage.has(t.toLowerCase())&&(t=t.toLowerCase()),i.storage.delete(t);}static setFlag(t,e){let r=i.getVariable(Ft.FLAGS_CATEGORY_KEY)||[];if(e)r.includes(t)||r.push(t);else {let s=r.indexOf(t);s>-1&&r.splice(s,1);}i.setVariable(Ft.FLAGS_CATEGORY_KEY,r);}static getFlag(t){return (i.getVariable(Ft.FLAGS_CATEGORY_KEY)||[]).includes(t)}};var wr=class{constructor(t,e){this.categoryId=t,this._id=e;}_id;get id(){return this._id}categoryId;setStorageProperty(t,e){let r=Q.getVariable(this.categoryId);r||(r={}),r.hasOwnProperty(this.id)||(r[this.id]={}),e==null?r[this.id].hasOwnProperty(t)&&delete r[this.id][t]:r[this.id]={...r[this.id],[t]:e},Object.keys(r[this.id]).length===0&&delete r[this.id],Q.setVariable(this.categoryId,r);}getStorageProperty(t,e=this.id){let r=Q.getVariable(this.categoryId);if(r&&r.hasOwnProperty(e)&&r[e].hasOwnProperty(t))return r[e][t]}};var u_="@",Pr=class extends wr{sourceId;constructor(t,e=""){super(Ft.CHARACTER_CATEGORY_KEY,t+(e?u_+e:"")),this.sourceId=t;}getStorageProperty(t){let e=super.getStorageProperty(t);return e===void 0&&(e=super.getStorageProperty(t,this.sourceId)),e}};var Ao=class extends Pr{constructor(t,e){super(typeof t=="string"?t:t.id,typeof t=="string"?"":t.emotion),this.defaultName=e.name,this.defaultSurname=e.surname,this.defaultAge=e.age,this._icon=e.icon,this._color=e.color;}defaultName;get name(){return this.getStorageProperty("name")||this.defaultName||this.id}set name(t){this.setStorageProperty("name",t);}defaultSurname;get surname(){return this.getStorageProperty("surname")||this.defaultSurname}set surname(t){this.setStorageProperty("surname",t);}defaultAge;get age(){return this.getStorageProperty("age")||this.defaultAge}set age(t){this.setStorageProperty("age",t);}_icon;get icon(){return this._icon}_color;get color(){return this._color}};var Eo=new Map;function Um(i){if(Array.isArray(i)){i.forEach(t=>Um(t));return}Eo.get(i.id)&&ot.info(`Character id ${i.id} already exists, it will be overwritten`),Eo.set(i.id,i);}function c_(i){try{let t=Eo.get(i);if(!t){ot.error(`Character ${i} not found, did you forget to register it with the saveCharacter?`);return}return t}catch(t){ot.error(`Error while getting Character ${i}`,t);return}}function d_(){return Object.values(Eo)}export{Ao as CharacterBaseModel,Pr as CharacterStoredClass,d_ as getAllCharacters,c_ as getCharacterById,Um as saveCharacter};
|