diff --git a/aclonica.woff2 b/aclonica.woff2 deleted file mode 100644 index ac9c610..0000000 Binary files a/aclonica.woff2 and /dev/null differ diff --git a/assets/SharedSystems-DeezA36t.js b/assets/SharedSystems-Cfxyk_gB.js similarity index 99% rename from assets/SharedSystems-DeezA36t.js rename to assets/SharedSystems-Cfxyk_gB.js index b8f9add..d99dca3 100644 --- a/assets/SharedSystems-DeezA36t.js +++ b/assets/SharedSystems-Cfxyk_gB.js @@ -1,4 +1,4 @@ -import{u as We,G as te,v as re,x as Ve,l as se,M as g,E as u,e as D,y as ne,z as _,F as je,R as E,H as ae,I as ie,J as Ne,a as m,S as p,j as B,w as oe,K as $,L as $e,d as q,B as k,k as U,N as M,T as b,O as S,Q as qe,c as Ke,C as w,V as le,W as ue,X as de,Y as ce,Z as Ye,P as Je,h as Xe,b as K,D as he,_ as Y,$ as Qe,a0 as Ze,a1 as et}from"./index-2UyWUVAY.js";import{S as fe,T as J,B as tt,c as rt}from"./colorToUniform-Bdgu2gC3.js";const pe=class A extends We{constructor(e){e={...A.defaultOptions,...e},super(e),this.enabled=!0,this._state=fe.for2d(),this.blendMode=e.blendMode,this.padding=e.padding,typeof e.antialias=="boolean"?this.antialias=e.antialias?"on":"off":this.antialias=e.antialias,this.resolution=e.resolution,this.blendRequired=e.blendRequired,this.addResource("uTexture",0,1)}apply(e,t,r,n){e.applyFilter(this,t,r,n)}get blendMode(){return this._state.blendMode}set blendMode(e){this._state.blendMode=e}static from(e){const{gpu:t,gl:r,...n}=e;let a,i;return t&&(a=te.from(t)),r&&(i=re.from(r)),new A({gpuProgram:a,glProgram:i,...n})}};pe.defaultOptions={blendMode:"normal",resolution:1,padding:0,antialias:"off",blendRequired:!1};let st=pe;var nt=`in vec2 vMaskCoord; +import{u as We,G as te,v as re,x as Ve,l as se,M as g,E as u,e as D,y as ne,z as _,F as je,R as E,H as ae,I as ie,J as Ne,a as m,S as p,j as B,w as oe,K as $,L as $e,d as q,B as k,k as U,N as M,T as b,O as S,Q as qe,c as Ke,C as w,V as le,W as ue,X as de,Y as ce,Z as Ye,P as Je,h as Xe,b as K,D as he,_ as Y,$ as Qe,a0 as Ze,a1 as et}from"./index-WJSjzvvL.js";import{S as fe,T as J,B as tt,c as rt}from"./colorToUniform-Dzvfc6yy.js";const pe=class A extends We{constructor(e){e={...A.defaultOptions,...e},super(e),this.enabled=!0,this._state=fe.for2d(),this.blendMode=e.blendMode,this.padding=e.padding,typeof e.antialias=="boolean"?this.antialias=e.antialias?"on":"off":this.antialias=e.antialias,this.resolution=e.resolution,this.blendRequired=e.blendRequired,this.addResource("uTexture",0,1)}apply(e,t,r,n){e.applyFilter(this,t,r,n)}get blendMode(){return this._state.blendMode}set blendMode(e){this._state.blendMode=e}static from(e){const{gpu:t,gl:r,...n}=e;let a,i;return t&&(a=te.from(t)),r&&(i=re.from(r)),new A({gpuProgram:a,glProgram:i,...n})}};pe.defaultOptions={blendMode:"normal",resolution:1,padding:0,antialias:"off",blendRequired:!1};let st=pe;var nt=`in vec2 vMaskCoord; in vec2 vTextureCoord; uniform sampler2D uTexture; diff --git a/assets/WebGLRenderer-DaH2izjB.js b/assets/WebGLRenderer-O3oCvy8A.js similarity index 99% rename from assets/WebGLRenderer-DaH2izjB.js rename to assets/WebGLRenderer-O3oCvy8A.js index 4024bdc..5313eeb 100644 --- a/assets/WebGLRenderer-DaH2izjB.js +++ b/assets/WebGLRenderer-O3oCvy8A.js @@ -1,4 +1,4 @@ -import{E as l,B as A,w as m,D as S,K,a2 as Ae,v as Be,u as G,a as p,T as $,S as R,O as L,k as H,j as B,l as U,s as z,M as Y,a3 as q,a4 as Ne,a5 as Ie,a6 as Z,a7 as De,e as x,A as ye,R as Ce}from"./index-2UyWUVAY.js";import{S as O,b as Q}from"./colorToUniform-Bdgu2gC3.js";import{e as Ge,G as Ue,c as Oe,b as Pe,U as Fe,R as Me,B as J,d as N,f as Le,S as He,a as we}from"./SharedSystems-DeezA36t.js";class ee{constructor(){this._didUpload=!1,this._tempState=O.for2d()}init(e){e.renderer.runners.contextChange.add(this)}contextChange(){this._didUpload=!1}start(e,r,s){const n=e.renderer;n.shader.bind(s,this._didUpload),n.shader.updateUniformGroup(n.globalUniforms.uniformGroup),n.geometry.bind(r,s.glProgram)}execute(e,r){const s=e.renderer;this._didUpload=!0,this._tempState.blendMode=r.blendMode,s.state.set(this._tempState);const n=r.textures.textures;for(let i=0;i(t[t.ELEMENT_ARRAY_BUFFER=34963]="ELEMENT_ARRAY_BUFFER",t[t.ARRAY_BUFFER=34962]="ARRAY_BUFFER",t[t.UNIFORM_BUFFER=35345]="UNIFORM_BUFFER",t))(T||{});class Ve{constructor(e,r){this.buffer=e||null,this.updateID=-1,this.byteLength=-1,this.type=r}}class te{constructor(e){this._gpuBuffers=Object.create(null),this._boundBufferBases=Object.create(null),this._renderer=e}destroy(){this._renderer=null,this._gl=null,this._gpuBuffers=null,this._boundBufferBases=null}contextChange(){this._gpuBuffers=Object.create(null),this._gl=this._renderer.gl}getGlBuffer(e){return this._gpuBuffers[e.uid]||this.createGLBuffer(e)}bind(e){const{_gl:r}=this,s=this.getGlBuffer(e);r.bindBuffer(s.type,s.buffer)}bindBufferBase(e,r){const{_gl:s}=this;if(this._boundBufferBases[r]!==e){const n=this.getGlBuffer(e);this._boundBufferBases[r]=e,s.bindBufferBase(s.UNIFORM_BUFFER,r,n.buffer)}}bindBufferRange(e,r,s){const{_gl:n}=this;s=s||0;const i=this.getGlBuffer(e);n.bindBufferRange(n.UNIFORM_BUFFER,r||0,i.buffer,s*256,256)}updateBuffer(e){const{_gl:r}=this,s=this.getGlBuffer(e);if(e._updateID===s.updateID)return s;s.updateID=e._updateID,r.bindBuffer(s.type,s.buffer);const n=e.data;if(s.byteLength>=e.data.byteLength)r.bufferSubData(s.type,0,n,0,e._updateSize/n.BYTES_PER_ELEMENT);else{const i=e.descriptor.usage&A.STATIC?r.STATIC_DRAW:r.DYNAMIC_DRAW;s.byteLength=n.byteLength,r.bufferData(s.type,n,i)}return s}destroyAll(){const e=this._gl;for(const r in this._gpuBuffers)e.deleteBuffer(this._gpuBuffers[r].buffer);this._gpuBuffers=Object.create(null)}onBufferDestroy(e,r){const s=this._gpuBuffers[e.uid],n=this._gl;r||n.deleteBuffer(s.buffer),this._gpuBuffers[e.uid]=null}createGLBuffer(e){const{_gl:r}=this;let s=T.ARRAY_BUFFER;e.descriptor.usage&A.INDEX?s=T.ELEMENT_ARRAY_BUFFER:e.descriptor.usage&A.UNIFORM&&(s=T.UNIFORM_BUFFER);const n=new Ve(r.createBuffer(),s);return this._gpuBuffers[e.uid]=n,e.on("destroy",this.onBufferDestroy,this),n}}te.extension={type:[l.WebGLSystem],name:"buffer"};const P=class re{constructor(e){this.supports={uint32Indices:!0,uniformBufferObject:!0,vertexArrayObject:!0,srgbTextures:!0,nonPowOf2wrapping:!0,msaa:!0,nonPowOf2mipmaps:!0},this._renderer=e,this.extensions=Object.create(null),this.handleContextLost=this.handleContextLost.bind(this),this.handleContextRestored=this.handleContextRestored.bind(this)}get isLost(){return!this.gl||this.gl.isContextLost()}contextChange(e){this.gl=e,this._renderer.gl=e}init(e){e={...re.defaultOptions,...e};let r=this.multiView=e.multiView;if(e.context&&r&&(m("Renderer created with both a context and multiview enabled. Disabling multiView as both cannot work together."),r=!1),r?this.canvas=S.get().createCanvas(this._renderer.canvas.width,this._renderer.canvas.height):this.canvas=this._renderer.view.canvas,e.context)this.initFromContext(e.context);else{const s=this._renderer.background.alpha<1,n=e.premultipliedAlpha??!0,i=e.antialias&&!this._renderer.backBuffer.useBackBuffer;this.createContext(e.preferWebGLVersion,{alpha:s,premultipliedAlpha:n,antialias:i,stencil:!0,preserveDrawingBuffer:e.preserveDrawingBuffer,powerPreference:e.powerPreference??"default"})}}ensureCanvasSize(e){if(!this.multiView){e!==this.canvas&&m("multiView is disabled, but targetCanvas is not the main canvas");return}const{canvas:r}=this;(r.width{var r;this.gl.isContextLost()&&((r=this.extensions.loseContext)==null||r.restoreContext())},0))}handleContextRestored(){this._renderer.runners.contextChange.emit(this.gl)}destroy(){var r;const e=this._renderer.view.canvas;this._renderer=null,e.removeEventListener("webglcontextlost",this.handleContextLost),e.removeEventListener("webglcontextrestored",this.handleContextRestored),this.gl.useProgram(null),(r=this.extensions.loseContext)==null||r.loseContext()}forceContextLoss(){var e;(e=this.extensions.loseContext)==null||e.loseContext(),this._contextLossForced=!0}validateContext(e){const r=e.getContextAttributes();r&&!r.stencil&&m("Provided WebGL context does not have a stencil buffer, masks may not render correctly");const s=this.supports,n=this.webGLVersion===2,i=this.extensions;s.uint32Indices=n||!!i.uint32ElementIndex,s.uniformBufferObject=n,s.vertexArrayObject=n||!!i.vertexArrayObject,s.srgbTextures=n||!!i.srgb,s.nonPowOf2wrapping=n,s.nonPowOf2mipmaps=n,s.msaa=n,s.uint32Indices||m("Provided WebGL context does not support 32 index buffer, large scenes may not render correctly")}};P.extension={type:[l.WebGLSystem],name:"context"};P.defaultOptions={context:null,premultipliedAlpha:!0,preserveDrawingBuffer:!1,powerPreference:void 0,preferWebGLVersion:2,multiView:!1};let ke=P;var y=(t=>(t[t.RGBA=6408]="RGBA",t[t.RGB=6407]="RGB",t[t.RG=33319]="RG",t[t.RED=6403]="RED",t[t.RGBA_INTEGER=36249]="RGBA_INTEGER",t[t.RGB_INTEGER=36248]="RGB_INTEGER",t[t.RG_INTEGER=33320]="RG_INTEGER",t[t.RED_INTEGER=36244]="RED_INTEGER",t[t.ALPHA=6406]="ALPHA",t[t.LUMINANCE=6409]="LUMINANCE",t[t.LUMINANCE_ALPHA=6410]="LUMINANCE_ALPHA",t[t.DEPTH_COMPONENT=6402]="DEPTH_COMPONENT",t[t.DEPTH_STENCIL=34041]="DEPTH_STENCIL",t))(y||{}),se=(t=>(t[t.TEXTURE_2D=3553]="TEXTURE_2D",t[t.TEXTURE_CUBE_MAP=34067]="TEXTURE_CUBE_MAP",t[t.TEXTURE_2D_ARRAY=35866]="TEXTURE_2D_ARRAY",t[t.TEXTURE_CUBE_MAP_POSITIVE_X=34069]="TEXTURE_CUBE_MAP_POSITIVE_X",t[t.TEXTURE_CUBE_MAP_NEGATIVE_X=34070]="TEXTURE_CUBE_MAP_NEGATIVE_X",t[t.TEXTURE_CUBE_MAP_POSITIVE_Y=34071]="TEXTURE_CUBE_MAP_POSITIVE_Y",t[t.TEXTURE_CUBE_MAP_NEGATIVE_Y=34072]="TEXTURE_CUBE_MAP_NEGATIVE_Y",t[t.TEXTURE_CUBE_MAP_POSITIVE_Z=34073]="TEXTURE_CUBE_MAP_POSITIVE_Z",t[t.TEXTURE_CUBE_MAP_NEGATIVE_Z=34074]="TEXTURE_CUBE_MAP_NEGATIVE_Z",t))(se||{}),f=(t=>(t[t.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",t[t.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",t[t.UNSIGNED_SHORT_5_6_5=33635]="UNSIGNED_SHORT_5_6_5",t[t.UNSIGNED_SHORT_4_4_4_4=32819]="UNSIGNED_SHORT_4_4_4_4",t[t.UNSIGNED_SHORT_5_5_5_1=32820]="UNSIGNED_SHORT_5_5_5_1",t[t.UNSIGNED_INT=5125]="UNSIGNED_INT",t[t.UNSIGNED_INT_10F_11F_11F_REV=35899]="UNSIGNED_INT_10F_11F_11F_REV",t[t.UNSIGNED_INT_2_10_10_10_REV=33640]="UNSIGNED_INT_2_10_10_10_REV",t[t.UNSIGNED_INT_24_8=34042]="UNSIGNED_INT_24_8",t[t.UNSIGNED_INT_5_9_9_9_REV=35902]="UNSIGNED_INT_5_9_9_9_REV",t[t.BYTE=5120]="BYTE",t[t.SHORT=5122]="SHORT",t[t.INT=5124]="INT",t[t.FLOAT=5126]="FLOAT",t[t.FLOAT_32_UNSIGNED_INT_24_8_REV=36269]="FLOAT_32_UNSIGNED_INT_24_8_REV",t[t.HALF_FLOAT=36193]="HALF_FLOAT",t))(f||{});const w={uint8x2:f.UNSIGNED_BYTE,uint8x4:f.UNSIGNED_BYTE,sint8x2:f.BYTE,sint8x4:f.BYTE,unorm8x2:f.UNSIGNED_BYTE,unorm8x4:f.UNSIGNED_BYTE,snorm8x2:f.BYTE,snorm8x4:f.BYTE,uint16x2:f.UNSIGNED_SHORT,uint16x4:f.UNSIGNED_SHORT,sint16x2:f.SHORT,sint16x4:f.SHORT,unorm16x2:f.UNSIGNED_SHORT,unorm16x4:f.UNSIGNED_SHORT,snorm16x2:f.SHORT,snorm16x4:f.SHORT,float16x2:f.HALF_FLOAT,float16x4:f.HALF_FLOAT,float32:f.FLOAT,float32x2:f.FLOAT,float32x3:f.FLOAT,float32x4:f.FLOAT,uint32:f.UNSIGNED_INT,uint32x2:f.UNSIGNED_INT,uint32x3:f.UNSIGNED_INT,uint32x4:f.UNSIGNED_INT,sint32:f.INT,sint32x2:f.INT,sint32x3:f.INT,sint32x4:f.INT};function Xe(t){return w[t]??w.float32}const We={"point-list":0,"line-list":1,"line-strip":3,"triangle-list":4,"triangle-strip":5};class ne{constructor(e){this._geometryVaoHash=Object.create(null),this._renderer=e,this._activeGeometry=null,this._activeVao=null,this.hasVao=!0,this.hasInstance=!0}contextChange(){const e=this.gl=this._renderer.gl;if(!this._renderer.context.supports.vertexArrayObject)throw new Error("[PixiJS] Vertex Array Objects are not supported on this device");const r=this._renderer.context.extensions.vertexArrayObject;r&&(e.createVertexArray=()=>r.createVertexArrayOES(),e.bindVertexArray=n=>r.bindVertexArrayOES(n),e.deleteVertexArray=n=>r.deleteVertexArrayOES(n));const s=this._renderer.context.extensions.vertexAttribDivisorANGLE;s&&(e.drawArraysInstanced=(n,i,a,o)=>{s.drawArraysInstancedANGLE(n,i,a,o)},e.drawElementsInstanced=(n,i,a,o,c)=>{s.drawElementsInstancedANGLE(n,i,a,o,c)},e.vertexAttribDivisor=(n,i)=>s.vertexAttribDivisorANGLE(n,i)),this._activeGeometry=null,this._activeVao=null,this._geometryVaoHash=Object.create(null)}bind(e,r){const s=this.gl;this._activeGeometry=e;const n=this.getVao(e,r);this._activeVao!==n&&(this._activeVao=n,s.bindVertexArray(n)),this.updateBuffers()}reset(){this.unbind()}updateBuffers(){const e=this._activeGeometry,r=this._renderer.buffer;for(let s=0;s1?i.drawElementsInstanced(o,r||a.indexBuffer.data.length,u,(s||0)*c,n):i.drawElements(o,r||a.indexBuffer.data.length,u,(s||0)*c)}else n>1?i.drawArraysInstanced(o,s||0,r||a.getSize(),n):i.drawArrays(o,s||0,r||a.getSize());return this}unbind(){this.gl.bindVertexArray(null),this._activeVao=null,this._activeGeometry=null}destroy(){this._renderer=null,this.gl=null,this._activeVao=null,this._activeGeometry=null}}ne.extension={type:[l.WebGLSystem],name:"geometry"};const je=new Ae({attributes:{aPosition:[-1,-1,3,-1,-1,3]}}),F=class ie{constructor(e){this.useBackBuffer=!1,this._useBackBufferThisRender=!1,this._renderer=e}init(e={}){const{useBackBuffer:r,antialias:s}={...ie.defaultOptions,...e};this.useBackBuffer=r,this._antialias=s,this._renderer.context.supports.msaa||(m("antialiasing, is not supported on when using the back buffer"),this._antialias=!1),this._state=O.for2d();const n=new Be({vertex:` +import{E as l,B as A,w as m,D as S,K,a2 as Ae,v as Be,u as G,a as p,T as $,S as R,O as L,k as H,j as B,l as U,s as z,M as Y,a3 as q,a4 as Ne,a5 as Ie,a6 as Z,a7 as De,e as x,A as ye,R as Ce}from"./index-WJSjzvvL.js";import{S as O,b as Q}from"./colorToUniform-Dzvfc6yy.js";import{e as Ge,G as Ue,c as Oe,b as Pe,U as Fe,R as Me,B as J,d as N,f as Le,S as He,a as we}from"./SharedSystems-Cfxyk_gB.js";class ee{constructor(){this._didUpload=!1,this._tempState=O.for2d()}init(e){e.renderer.runners.contextChange.add(this)}contextChange(){this._didUpload=!1}start(e,r,s){const n=e.renderer;n.shader.bind(s,this._didUpload),n.shader.updateUniformGroup(n.globalUniforms.uniformGroup),n.geometry.bind(r,s.glProgram)}execute(e,r){const s=e.renderer;this._didUpload=!0,this._tempState.blendMode=r.blendMode,s.state.set(this._tempState);const n=r.textures.textures;for(let i=0;i(t[t.ELEMENT_ARRAY_BUFFER=34963]="ELEMENT_ARRAY_BUFFER",t[t.ARRAY_BUFFER=34962]="ARRAY_BUFFER",t[t.UNIFORM_BUFFER=35345]="UNIFORM_BUFFER",t))(T||{});class Ve{constructor(e,r){this.buffer=e||null,this.updateID=-1,this.byteLength=-1,this.type=r}}class te{constructor(e){this._gpuBuffers=Object.create(null),this._boundBufferBases=Object.create(null),this._renderer=e}destroy(){this._renderer=null,this._gl=null,this._gpuBuffers=null,this._boundBufferBases=null}contextChange(){this._gpuBuffers=Object.create(null),this._gl=this._renderer.gl}getGlBuffer(e){return this._gpuBuffers[e.uid]||this.createGLBuffer(e)}bind(e){const{_gl:r}=this,s=this.getGlBuffer(e);r.bindBuffer(s.type,s.buffer)}bindBufferBase(e,r){const{_gl:s}=this;if(this._boundBufferBases[r]!==e){const n=this.getGlBuffer(e);this._boundBufferBases[r]=e,s.bindBufferBase(s.UNIFORM_BUFFER,r,n.buffer)}}bindBufferRange(e,r,s){const{_gl:n}=this;s=s||0;const i=this.getGlBuffer(e);n.bindBufferRange(n.UNIFORM_BUFFER,r||0,i.buffer,s*256,256)}updateBuffer(e){const{_gl:r}=this,s=this.getGlBuffer(e);if(e._updateID===s.updateID)return s;s.updateID=e._updateID,r.bindBuffer(s.type,s.buffer);const n=e.data;if(s.byteLength>=e.data.byteLength)r.bufferSubData(s.type,0,n,0,e._updateSize/n.BYTES_PER_ELEMENT);else{const i=e.descriptor.usage&A.STATIC?r.STATIC_DRAW:r.DYNAMIC_DRAW;s.byteLength=n.byteLength,r.bufferData(s.type,n,i)}return s}destroyAll(){const e=this._gl;for(const r in this._gpuBuffers)e.deleteBuffer(this._gpuBuffers[r].buffer);this._gpuBuffers=Object.create(null)}onBufferDestroy(e,r){const s=this._gpuBuffers[e.uid],n=this._gl;r||n.deleteBuffer(s.buffer),this._gpuBuffers[e.uid]=null}createGLBuffer(e){const{_gl:r}=this;let s=T.ARRAY_BUFFER;e.descriptor.usage&A.INDEX?s=T.ELEMENT_ARRAY_BUFFER:e.descriptor.usage&A.UNIFORM&&(s=T.UNIFORM_BUFFER);const n=new Ve(r.createBuffer(),s);return this._gpuBuffers[e.uid]=n,e.on("destroy",this.onBufferDestroy,this),n}}te.extension={type:[l.WebGLSystem],name:"buffer"};const P=class re{constructor(e){this.supports={uint32Indices:!0,uniformBufferObject:!0,vertexArrayObject:!0,srgbTextures:!0,nonPowOf2wrapping:!0,msaa:!0,nonPowOf2mipmaps:!0},this._renderer=e,this.extensions=Object.create(null),this.handleContextLost=this.handleContextLost.bind(this),this.handleContextRestored=this.handleContextRestored.bind(this)}get isLost(){return!this.gl||this.gl.isContextLost()}contextChange(e){this.gl=e,this._renderer.gl=e}init(e){e={...re.defaultOptions,...e};let r=this.multiView=e.multiView;if(e.context&&r&&(m("Renderer created with both a context and multiview enabled. Disabling multiView as both cannot work together."),r=!1),r?this.canvas=S.get().createCanvas(this._renderer.canvas.width,this._renderer.canvas.height):this.canvas=this._renderer.view.canvas,e.context)this.initFromContext(e.context);else{const s=this._renderer.background.alpha<1,n=e.premultipliedAlpha??!0,i=e.antialias&&!this._renderer.backBuffer.useBackBuffer;this.createContext(e.preferWebGLVersion,{alpha:s,premultipliedAlpha:n,antialias:i,stencil:!0,preserveDrawingBuffer:e.preserveDrawingBuffer,powerPreference:e.powerPreference??"default"})}}ensureCanvasSize(e){if(!this.multiView){e!==this.canvas&&m("multiView is disabled, but targetCanvas is not the main canvas");return}const{canvas:r}=this;(r.width{var r;this.gl.isContextLost()&&((r=this.extensions.loseContext)==null||r.restoreContext())},0))}handleContextRestored(){this._renderer.runners.contextChange.emit(this.gl)}destroy(){var r;const e=this._renderer.view.canvas;this._renderer=null,e.removeEventListener("webglcontextlost",this.handleContextLost),e.removeEventListener("webglcontextrestored",this.handleContextRestored),this.gl.useProgram(null),(r=this.extensions.loseContext)==null||r.loseContext()}forceContextLoss(){var e;(e=this.extensions.loseContext)==null||e.loseContext(),this._contextLossForced=!0}validateContext(e){const r=e.getContextAttributes();r&&!r.stencil&&m("Provided WebGL context does not have a stencil buffer, masks may not render correctly");const s=this.supports,n=this.webGLVersion===2,i=this.extensions;s.uint32Indices=n||!!i.uint32ElementIndex,s.uniformBufferObject=n,s.vertexArrayObject=n||!!i.vertexArrayObject,s.srgbTextures=n||!!i.srgb,s.nonPowOf2wrapping=n,s.nonPowOf2mipmaps=n,s.msaa=n,s.uint32Indices||m("Provided WebGL context does not support 32 index buffer, large scenes may not render correctly")}};P.extension={type:[l.WebGLSystem],name:"context"};P.defaultOptions={context:null,premultipliedAlpha:!0,preserveDrawingBuffer:!1,powerPreference:void 0,preferWebGLVersion:2,multiView:!1};let ke=P;var y=(t=>(t[t.RGBA=6408]="RGBA",t[t.RGB=6407]="RGB",t[t.RG=33319]="RG",t[t.RED=6403]="RED",t[t.RGBA_INTEGER=36249]="RGBA_INTEGER",t[t.RGB_INTEGER=36248]="RGB_INTEGER",t[t.RG_INTEGER=33320]="RG_INTEGER",t[t.RED_INTEGER=36244]="RED_INTEGER",t[t.ALPHA=6406]="ALPHA",t[t.LUMINANCE=6409]="LUMINANCE",t[t.LUMINANCE_ALPHA=6410]="LUMINANCE_ALPHA",t[t.DEPTH_COMPONENT=6402]="DEPTH_COMPONENT",t[t.DEPTH_STENCIL=34041]="DEPTH_STENCIL",t))(y||{}),se=(t=>(t[t.TEXTURE_2D=3553]="TEXTURE_2D",t[t.TEXTURE_CUBE_MAP=34067]="TEXTURE_CUBE_MAP",t[t.TEXTURE_2D_ARRAY=35866]="TEXTURE_2D_ARRAY",t[t.TEXTURE_CUBE_MAP_POSITIVE_X=34069]="TEXTURE_CUBE_MAP_POSITIVE_X",t[t.TEXTURE_CUBE_MAP_NEGATIVE_X=34070]="TEXTURE_CUBE_MAP_NEGATIVE_X",t[t.TEXTURE_CUBE_MAP_POSITIVE_Y=34071]="TEXTURE_CUBE_MAP_POSITIVE_Y",t[t.TEXTURE_CUBE_MAP_NEGATIVE_Y=34072]="TEXTURE_CUBE_MAP_NEGATIVE_Y",t[t.TEXTURE_CUBE_MAP_POSITIVE_Z=34073]="TEXTURE_CUBE_MAP_POSITIVE_Z",t[t.TEXTURE_CUBE_MAP_NEGATIVE_Z=34074]="TEXTURE_CUBE_MAP_NEGATIVE_Z",t))(se||{}),f=(t=>(t[t.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",t[t.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",t[t.UNSIGNED_SHORT_5_6_5=33635]="UNSIGNED_SHORT_5_6_5",t[t.UNSIGNED_SHORT_4_4_4_4=32819]="UNSIGNED_SHORT_4_4_4_4",t[t.UNSIGNED_SHORT_5_5_5_1=32820]="UNSIGNED_SHORT_5_5_5_1",t[t.UNSIGNED_INT=5125]="UNSIGNED_INT",t[t.UNSIGNED_INT_10F_11F_11F_REV=35899]="UNSIGNED_INT_10F_11F_11F_REV",t[t.UNSIGNED_INT_2_10_10_10_REV=33640]="UNSIGNED_INT_2_10_10_10_REV",t[t.UNSIGNED_INT_24_8=34042]="UNSIGNED_INT_24_8",t[t.UNSIGNED_INT_5_9_9_9_REV=35902]="UNSIGNED_INT_5_9_9_9_REV",t[t.BYTE=5120]="BYTE",t[t.SHORT=5122]="SHORT",t[t.INT=5124]="INT",t[t.FLOAT=5126]="FLOAT",t[t.FLOAT_32_UNSIGNED_INT_24_8_REV=36269]="FLOAT_32_UNSIGNED_INT_24_8_REV",t[t.HALF_FLOAT=36193]="HALF_FLOAT",t))(f||{});const w={uint8x2:f.UNSIGNED_BYTE,uint8x4:f.UNSIGNED_BYTE,sint8x2:f.BYTE,sint8x4:f.BYTE,unorm8x2:f.UNSIGNED_BYTE,unorm8x4:f.UNSIGNED_BYTE,snorm8x2:f.BYTE,snorm8x4:f.BYTE,uint16x2:f.UNSIGNED_SHORT,uint16x4:f.UNSIGNED_SHORT,sint16x2:f.SHORT,sint16x4:f.SHORT,unorm16x2:f.UNSIGNED_SHORT,unorm16x4:f.UNSIGNED_SHORT,snorm16x2:f.SHORT,snorm16x4:f.SHORT,float16x2:f.HALF_FLOAT,float16x4:f.HALF_FLOAT,float32:f.FLOAT,float32x2:f.FLOAT,float32x3:f.FLOAT,float32x4:f.FLOAT,uint32:f.UNSIGNED_INT,uint32x2:f.UNSIGNED_INT,uint32x3:f.UNSIGNED_INT,uint32x4:f.UNSIGNED_INT,sint32:f.INT,sint32x2:f.INT,sint32x3:f.INT,sint32x4:f.INT};function Xe(t){return w[t]??w.float32}const We={"point-list":0,"line-list":1,"line-strip":3,"triangle-list":4,"triangle-strip":5};class ne{constructor(e){this._geometryVaoHash=Object.create(null),this._renderer=e,this._activeGeometry=null,this._activeVao=null,this.hasVao=!0,this.hasInstance=!0}contextChange(){const e=this.gl=this._renderer.gl;if(!this._renderer.context.supports.vertexArrayObject)throw new Error("[PixiJS] Vertex Array Objects are not supported on this device");const r=this._renderer.context.extensions.vertexArrayObject;r&&(e.createVertexArray=()=>r.createVertexArrayOES(),e.bindVertexArray=n=>r.bindVertexArrayOES(n),e.deleteVertexArray=n=>r.deleteVertexArrayOES(n));const s=this._renderer.context.extensions.vertexAttribDivisorANGLE;s&&(e.drawArraysInstanced=(n,i,a,o)=>{s.drawArraysInstancedANGLE(n,i,a,o)},e.drawElementsInstanced=(n,i,a,o,c)=>{s.drawElementsInstancedANGLE(n,i,a,o,c)},e.vertexAttribDivisor=(n,i)=>s.vertexAttribDivisorANGLE(n,i)),this._activeGeometry=null,this._activeVao=null,this._geometryVaoHash=Object.create(null)}bind(e,r){const s=this.gl;this._activeGeometry=e;const n=this.getVao(e,r);this._activeVao!==n&&(this._activeVao=n,s.bindVertexArray(n)),this.updateBuffers()}reset(){this.unbind()}updateBuffers(){const e=this._activeGeometry,r=this._renderer.buffer;for(let s=0;s1?i.drawElementsInstanced(o,r||a.indexBuffer.data.length,u,(s||0)*c,n):i.drawElements(o,r||a.indexBuffer.data.length,u,(s||0)*c)}else n>1?i.drawArraysInstanced(o,s||0,r||a.getSize(),n):i.drawArrays(o,s||0,r||a.getSize());return this}unbind(){this.gl.bindVertexArray(null),this._activeVao=null,this._activeGeometry=null}destroy(){this._renderer=null,this.gl=null,this._activeVao=null,this._activeGeometry=null}}ne.extension={type:[l.WebGLSystem],name:"geometry"};const je=new Ae({attributes:{aPosition:[-1,-1,3,-1,-1,3]}}),F=class ie{constructor(e){this.useBackBuffer=!1,this._useBackBufferThisRender=!1,this._renderer=e}init(e={}){const{useBackBuffer:r,antialias:s}={...ie.defaultOptions,...e};this.useBackBuffer=r,this._antialias=s,this._renderer.context.supports.msaa||(m("antialiasing, is not supported on when using the back buffer"),this._antialias=!1),this._state=O.for2d();const n=new Be({vertex:` attribute vec2 aPosition; out vec2 vUv; diff --git a/assets/WebGPURenderer-CUsLfpfB.js b/assets/WebGPURenderer-CNuCBG1t.js similarity index 99% rename from assets/WebGPURenderer-CUsLfpfB.js rename to assets/WebGPURenderer-CNuCBG1t.js index e282a8e..edec16c 100644 --- a/assets/WebGPURenderer-CUsLfpfB.js +++ b/assets/WebGPURenderer-CNuCBG1t.js @@ -1,4 +1,4 @@ -import{g as w,E as l,f as ne,D as P,S as T,B as S,d as oe,h as R,i as C,w as E,j as b,k as ae,T as ue,l as A,m as U,M as k,o as L,p as ce,q as de,s as he,t as D,u as z,a as M,e as G,A as pe,R as le}from"./index-2UyWUVAY.js";import{S as F,l as fe,a as ge}from"./colorToUniform-Bdgu2gC3.js";import{c as me,u as _e,U as be,B as ye,G as xe,e as Ge,R as Be,t as Se,S as Pe,a as Te}from"./SharedSystems-DeezA36t.js";const y=F.for2d();class O{start(e,t,r){const s=e.renderer,i=s.encoder,n=r.gpuProgram;this._shader=r,this._geometry=t,i.setGeometry(t,n),y.blendMode="normal",s.pipeline.getPipeline(t,n,y);const o=s.globalUniforms.bindGroup;i.resetBindGroup(1),i.setBindGroup(0,o,n)}execute(e,t){const r=this._shader.gpuProgram,s=e.renderer,i=s.encoder;if(!t.bindGroup){const u=t.textures;t.bindGroup=w(u.textures,u.count)}y.blendMode=t.blendMode;const n=s.bindGroup.getBindGroup(t.bindGroup,r,1),o=s.pipeline.getPipeline(this._geometry,r,y);t.bindGroup._touch(s.textureGC.count),i.setPipeline(o),i.renderPassEncoder.setBindGroup(1,n),i.renderPassEncoder.drawIndexed(t.size,1,t.start)}}O.extension={type:[l.WebGPUPipesAdaptor],name:"batch"};class H{constructor(e){this._hash=Object.create(null),this._renderer=e}contextChange(e){this._gpu=e}getBindGroup(e,t,r){return e._updateKey(),this._hash[e._key]||this._createBindGroup(e,t,r)}_createBindGroup(e,t,r){const s=this._gpu.device,i=t.layout[r],n=[],o=this._renderer;for(const f in i){const h=e.resources[f]??e.resources[i[f]];let p;if(h._resourceType==="uniformGroup"){const d=h;o.ubo.updateUniformGroup(d);const g=d.buffer;p={buffer:o.buffer.getGPUBuffer(g),offset:0,size:g.descriptor.size}}else if(h._resourceType==="buffer"){const d=h;p={buffer:o.buffer.getGPUBuffer(d),offset:0,size:d.descriptor.size}}else if(h._resourceType==="bufferResource"){const d=h;p={buffer:o.buffer.getGPUBuffer(d.buffer),offset:d.offset,size:d.size}}else if(h._resourceType==="textureSampler"){const d=h;p=o.texture.getGpuSampler(d)}else if(h._resourceType==="textureSource"){const d=h;p=o.texture.getGpuSource(d).createView({})}n.push({binding:i[f],resource:p})}const u=o.shader.getProgramData(t).bindGroups[r],c=s.createBindGroup({layout:u,entries:n});return this._hash[e._key]=c,c}destroy(){for(const e of Object.keys(this._hash))this._hash[e]=null;this._hash=null,this._renderer=null}}H.extension={type:[l.WebGPUSystem],name:"bindGroup"};class W{constructor(){this._gpuBuffers=Object.create(null),this._managedBuffers=[]}contextChange(e){this._gpu=e}getGPUBuffer(e){return this._gpuBuffers[e.uid]||this.createGPUBuffer(e)}updateBuffer(e){const t=this._gpuBuffers[e.uid]||this.createGPUBuffer(e),r=e.data;return e._updateID&&r&&(e._updateID=0,this._gpu.device.queue.writeBuffer(t,0,r.buffer,0,(e._updateSize||r.byteLength)+3&-4)),t}destroyAll(){for(const e in this._gpuBuffers)this._gpuBuffers[e].destroy();this._gpuBuffers={}}createGPUBuffer(e){this._gpuBuffers[e.uid]||(e.on("update",this.updateBuffer,this),e.on("change",this.onBufferChange,this),e.on("destroy",this.onBufferDestroy,this),this._managedBuffers.push(e));const t=this._gpu.device.createBuffer(e.descriptor);return e._updateID=0,e.data&&(ne(e.data.buffer,t.getMappedRange()),t.unmap()),this._gpuBuffers[e.uid]=t,t}onBufferChange(e){this._gpuBuffers[e.uid].destroy(),e._updateID=0,this._gpuBuffers[e.uid]=this.createGPUBuffer(e)}onBufferDestroy(e){this._managedBuffers.splice(this._managedBuffers.indexOf(e),1),this._destroyBuffer(e)}destroy(){this._managedBuffers.forEach(e=>this._destroyBuffer(e)),this._managedBuffers=null,this._gpuBuffers=null}_destroyBuffer(e){this._gpuBuffers[e.uid].destroy(),e.off("update",this.updateBuffer,this),e.off("change",this.onBufferChange,this),e.off("destroy",this.onBufferDestroy,this),this._gpuBuffers[e.uid]=null}}W.extension={type:[l.WebGPUSystem],name:"buffer"};class ve{constructor({minUniformOffsetAlignment:e}){this._minUniformOffsetAlignment=256,this.byteIndex=0,this._minUniformOffsetAlignment=e,this.data=new Float32Array(65535)}clear(){this.byteIndex=0}addEmptyGroup(e){if(e>this._minUniformOffsetAlignment/4)throw new Error(`UniformBufferBatch: array is too large: ${e*4}`);const t=this.byteIndex;let r=t+e*4;if(r=Math.ceil(r/this._minUniformOffsetAlignment)*this._minUniformOffsetAlignment,r>this.data.length*4)throw new Error("UniformBufferBatch: ubo batch got too big");return this.byteIndex=r,t}addGroup(e){const t=this.addEmptyGroup(e.length);for(let r=0;r{this.gpu=t,this._renderer.runners.contextChange.emit(this.gpu)}),this._initPromise)}contextChange(e){this._renderer.gpu=e}async _createDeviceAndAdaptor(e){const t=await P.get().getNavigator().gpu.requestAdapter({powerPreference:e.powerPreference,forceFallbackAdapter:e.forceFallbackAdapter}),r=["texture-compression-bc","texture-compression-astc","texture-compression-etc2"].filter(i=>t.features.has(i)),s=await t.requestDevice({requiredFeatures:r});return{adapter:t,device:s}}destroy(){this.gpu=null,this._renderer=null}}v.extension={type:[l.WebGPUSystem],name:"device"};v.defaultOptions={powerPreference:void 0,forceFallbackAdapter:!1};class V{constructor(e){this._boundBindGroup=Object.create(null),this._boundVertexBuffer=Object.create(null),this._renderer=e}renderStart(){this.commandFinished=new Promise(e=>{this._resolveCommandFinished=e}),this.commandEncoder=this._renderer.gpu.device.createCommandEncoder()}beginRenderPass(e){this.endRenderPass(),this._clearCache(),this.renderPassEncoder=this.commandEncoder.beginRenderPass(e.descriptor)}endRenderPass(){this.renderPassEncoder&&this.renderPassEncoder.end(),this.renderPassEncoder=null}setViewport(e){this.renderPassEncoder.setViewport(e.x,e.y,e.width,e.height,0,1)}setPipelineFromGeometryProgramAndState(e,t,r,s){const i=this._renderer.pipeline.getPipeline(e,t,r,s);this.setPipeline(i)}setPipeline(e){this._boundPipeline!==e&&(this._boundPipeline=e,this.renderPassEncoder.setPipeline(e))}_setVertexBuffer(e,t){this._boundVertexBuffer[e]!==t&&(this._boundVertexBuffer[e]=t,this.renderPassEncoder.setVertexBuffer(e,this._renderer.buffer.updateBuffer(t)))}_setIndexBuffer(e){if(this._boundIndexBuffer===e)return;this._boundIndexBuffer=e;const t=e.data.BYTES_PER_ELEMENT===2?"uint16":"uint32";this.renderPassEncoder.setIndexBuffer(this._renderer.buffer.updateBuffer(e),t)}resetBindGroup(e){this._boundBindGroup[e]=null}setBindGroup(e,t,r){if(this._boundBindGroup[e]===t)return;this._boundBindGroup[e]=t,t._touch(this._renderer.textureGC.count);const s=this._renderer.bindGroup.getBindGroup(t,r,e);this.renderPassEncoder.setBindGroup(e,s)}setGeometry(e,t){const r=this._renderer.pipeline.getBufferNamesToBind(e,t);for(const s in r)this._setVertexBuffer(s,e.attributes[r[s]].buffer);e.indexBuffer&&this._setIndexBuffer(e.indexBuffer)}_setShaderBindGroups(e,t){for(const r in e.groups){const s=e.groups[r];t||this._syncBindGroup(s),this.setBindGroup(r,s,e.gpuProgram)}}_syncBindGroup(e){for(const t in e.resources){const r=e.resources[t];r.isUniformGroup&&this._renderer.ubo.updateUniformGroup(r)}}draw(e){const{geometry:t,shader:r,state:s,topology:i,size:n,start:o,instanceCount:u,skipSync:c}=e;this.setPipelineFromGeometryProgramAndState(t,r.gpuProgram,s,i),this.setGeometry(t,r.gpuProgram),this._setShaderBindGroups(r,c),t.indexBuffer?this.renderPassEncoder.drawIndexed(n||t.indexBuffer.data.length,u||t.instanceCount,o||0):this.renderPassEncoder.draw(n||t.getSize(),u||t.instanceCount,o||0)}finishRenderPass(){this.renderPassEncoder&&(this.renderPassEncoder.end(),this.renderPassEncoder=null)}postrender(){this.finishRenderPass(),this._gpu.device.queue.submit([this.commandEncoder.finish()]),this._resolveCommandFinished(),this.commandEncoder=null}restoreRenderPass(){const e=this._renderer.renderTarget.adaptor.getDescriptor(this._renderer.renderTarget.renderTarget,!1,[0,0,0,1]);this.renderPassEncoder=this.commandEncoder.beginRenderPass(e);const t=this._boundPipeline,r={...this._boundVertexBuffer},s=this._boundIndexBuffer,i={...this._boundBindGroup};this._clearCache();const n=this._renderer.renderTarget.viewport;this.renderPassEncoder.setViewport(n.x,n.y,n.width,n.height,0,1),this.setPipeline(t);for(const o in r)this._setVertexBuffer(o,r[o]);for(const o in i)this.setBindGroup(o,i[o],null);this._setIndexBuffer(s)}_clearCache(){for(let e=0;e<16;e++)this._boundBindGroup[e]=null,this._boundVertexBuffer[e]=null;this._boundIndexBuffer=null,this._boundPipeline=null}destroy(){this._renderer=null,this._gpu=null,this._boundBindGroup=null,this._boundVertexBuffer=null,this._boundIndexBuffer=null,this._boundPipeline=null}contextChange(e){this._gpu=e}}V.extension={type:[l.WebGPUSystem],name:"encoder",priority:1};class N{constructor(e){this._renderTargetStencilState=Object.create(null),this._renderer=e,e.renderTarget.onRenderTargetChange.add(this)}onRenderTargetChange(e){let t=this._renderTargetStencilState[e.uid];t||(t=this._renderTargetStencilState[e.uid]={stencilMode:T.DISABLED,stencilReference:0}),this._activeRenderTarget=e,this.setStencilMode(t.stencilMode,t.stencilReference)}setStencilMode(e,t){const r=this._renderTargetStencilState[this._activeRenderTarget.uid];r.stencilMode=e,r.stencilReference=t;const s=this._renderer;s.pipeline.setStencilMode(e),s.encoder.renderPassEncoder.setStencilReference(t)}destroy(){this._renderer.renderTarget.onRenderTargetChange.remove(this),this._renderer=null,this._activeRenderTarget=null,this._renderTargetStencilState=null}}N.extension={type:[l.WebGPUSystem],name:"stencil"};const x={i32:{align:4,size:4},u32:{align:4,size:4},f32:{align:4,size:4},f16:{align:2,size:2},"vec2":{align:8,size:8},"vec2":{align:8,size:8},"vec2":{align:8,size:8},"vec2":{align:4,size:4},"vec3":{align:16,size:12},"vec3":{align:16,size:12},"vec3":{align:16,size:12},"vec3":{align:8,size:6},"vec4":{align:16,size:16},"vec4":{align:16,size:16},"vec4":{align:16,size:16},"vec4":{align:8,size:8},"mat2x2":{align:8,size:16},"mat2x2":{align:4,size:8},"mat3x2":{align:8,size:24},"mat3x2":{align:4,size:12},"mat4x2":{align:8,size:32},"mat4x2":{align:4,size:16},"mat2x3":{align:16,size:32},"mat2x3":{align:8,size:16},"mat3x3":{align:16,size:48},"mat3x3":{align:8,size:24},"mat4x3":{align:16,size:64},"mat4x3":{align:8,size:32},"mat2x4":{align:16,size:32},"mat2x4":{align:8,size:16},"mat3x4":{align:16,size:48},"mat3x4":{align:8,size:24},"mat4x4":{align:16,size:64},"mat4x4":{align:8,size:32}};function Ce(a){const e=a.map(r=>({data:r,offset:0,size:0}));let t=0;for(let r=0;r1&&(i=Math.max(i,n)*s.data.size),t=Math.ceil(t/n)*n,s.size=i,s.offset=t,t+=i}return t=Math.ceil(t/16)*16,{uboElements:e,size:t}}function Ue(a,e){const{size:t,align:r}=x[a.data.type],s=(r-t)/4;return` +import{g as w,E as l,f as ne,D as P,S as T,B as S,d as oe,h as R,i as C,w as E,j as b,k as ae,T as ue,l as A,m as U,M as k,o as L,p as ce,q as de,s as he,t as D,u as z,a as M,e as G,A as pe,R as le}from"./index-WJSjzvvL.js";import{S as F,l as fe,a as ge}from"./colorToUniform-Dzvfc6yy.js";import{c as me,u as _e,U as be,B as ye,G as xe,e as Ge,R as Be,t as Se,S as Pe,a as Te}from"./SharedSystems-Cfxyk_gB.js";const y=F.for2d();class O{start(e,t,r){const s=e.renderer,i=s.encoder,n=r.gpuProgram;this._shader=r,this._geometry=t,i.setGeometry(t,n),y.blendMode="normal",s.pipeline.getPipeline(t,n,y);const o=s.globalUniforms.bindGroup;i.resetBindGroup(1),i.setBindGroup(0,o,n)}execute(e,t){const r=this._shader.gpuProgram,s=e.renderer,i=s.encoder;if(!t.bindGroup){const u=t.textures;t.bindGroup=w(u.textures,u.count)}y.blendMode=t.blendMode;const n=s.bindGroup.getBindGroup(t.bindGroup,r,1),o=s.pipeline.getPipeline(this._geometry,r,y);t.bindGroup._touch(s.textureGC.count),i.setPipeline(o),i.renderPassEncoder.setBindGroup(1,n),i.renderPassEncoder.drawIndexed(t.size,1,t.start)}}O.extension={type:[l.WebGPUPipesAdaptor],name:"batch"};class H{constructor(e){this._hash=Object.create(null),this._renderer=e}contextChange(e){this._gpu=e}getBindGroup(e,t,r){return e._updateKey(),this._hash[e._key]||this._createBindGroup(e,t,r)}_createBindGroup(e,t,r){const s=this._gpu.device,i=t.layout[r],n=[],o=this._renderer;for(const f in i){const h=e.resources[f]??e.resources[i[f]];let p;if(h._resourceType==="uniformGroup"){const d=h;o.ubo.updateUniformGroup(d);const g=d.buffer;p={buffer:o.buffer.getGPUBuffer(g),offset:0,size:g.descriptor.size}}else if(h._resourceType==="buffer"){const d=h;p={buffer:o.buffer.getGPUBuffer(d),offset:0,size:d.descriptor.size}}else if(h._resourceType==="bufferResource"){const d=h;p={buffer:o.buffer.getGPUBuffer(d.buffer),offset:d.offset,size:d.size}}else if(h._resourceType==="textureSampler"){const d=h;p=o.texture.getGpuSampler(d)}else if(h._resourceType==="textureSource"){const d=h;p=o.texture.getGpuSource(d).createView({})}n.push({binding:i[f],resource:p})}const u=o.shader.getProgramData(t).bindGroups[r],c=s.createBindGroup({layout:u,entries:n});return this._hash[e._key]=c,c}destroy(){for(const e of Object.keys(this._hash))this._hash[e]=null;this._hash=null,this._renderer=null}}H.extension={type:[l.WebGPUSystem],name:"bindGroup"};class W{constructor(){this._gpuBuffers=Object.create(null),this._managedBuffers=[]}contextChange(e){this._gpu=e}getGPUBuffer(e){return this._gpuBuffers[e.uid]||this.createGPUBuffer(e)}updateBuffer(e){const t=this._gpuBuffers[e.uid]||this.createGPUBuffer(e),r=e.data;return e._updateID&&r&&(e._updateID=0,this._gpu.device.queue.writeBuffer(t,0,r.buffer,0,(e._updateSize||r.byteLength)+3&-4)),t}destroyAll(){for(const e in this._gpuBuffers)this._gpuBuffers[e].destroy();this._gpuBuffers={}}createGPUBuffer(e){this._gpuBuffers[e.uid]||(e.on("update",this.updateBuffer,this),e.on("change",this.onBufferChange,this),e.on("destroy",this.onBufferDestroy,this),this._managedBuffers.push(e));const t=this._gpu.device.createBuffer(e.descriptor);return e._updateID=0,e.data&&(ne(e.data.buffer,t.getMappedRange()),t.unmap()),this._gpuBuffers[e.uid]=t,t}onBufferChange(e){this._gpuBuffers[e.uid].destroy(),e._updateID=0,this._gpuBuffers[e.uid]=this.createGPUBuffer(e)}onBufferDestroy(e){this._managedBuffers.splice(this._managedBuffers.indexOf(e),1),this._destroyBuffer(e)}destroy(){this._managedBuffers.forEach(e=>this._destroyBuffer(e)),this._managedBuffers=null,this._gpuBuffers=null}_destroyBuffer(e){this._gpuBuffers[e.uid].destroy(),e.off("update",this.updateBuffer,this),e.off("change",this.onBufferChange,this),e.off("destroy",this.onBufferDestroy,this),this._gpuBuffers[e.uid]=null}}W.extension={type:[l.WebGPUSystem],name:"buffer"};class ve{constructor({minUniformOffsetAlignment:e}){this._minUniformOffsetAlignment=256,this.byteIndex=0,this._minUniformOffsetAlignment=e,this.data=new Float32Array(65535)}clear(){this.byteIndex=0}addEmptyGroup(e){if(e>this._minUniformOffsetAlignment/4)throw new Error(`UniformBufferBatch: array is too large: ${e*4}`);const t=this.byteIndex;let r=t+e*4;if(r=Math.ceil(r/this._minUniformOffsetAlignment)*this._minUniformOffsetAlignment,r>this.data.length*4)throw new Error("UniformBufferBatch: ubo batch got too big");return this.byteIndex=r,t}addGroup(e){const t=this.addEmptyGroup(e.length);for(let r=0;r{this.gpu=t,this._renderer.runners.contextChange.emit(this.gpu)}),this._initPromise)}contextChange(e){this._renderer.gpu=e}async _createDeviceAndAdaptor(e){const t=await P.get().getNavigator().gpu.requestAdapter({powerPreference:e.powerPreference,forceFallbackAdapter:e.forceFallbackAdapter}),r=["texture-compression-bc","texture-compression-astc","texture-compression-etc2"].filter(i=>t.features.has(i)),s=await t.requestDevice({requiredFeatures:r});return{adapter:t,device:s}}destroy(){this.gpu=null,this._renderer=null}}v.extension={type:[l.WebGPUSystem],name:"device"};v.defaultOptions={powerPreference:void 0,forceFallbackAdapter:!1};class V{constructor(e){this._boundBindGroup=Object.create(null),this._boundVertexBuffer=Object.create(null),this._renderer=e}renderStart(){this.commandFinished=new Promise(e=>{this._resolveCommandFinished=e}),this.commandEncoder=this._renderer.gpu.device.createCommandEncoder()}beginRenderPass(e){this.endRenderPass(),this._clearCache(),this.renderPassEncoder=this.commandEncoder.beginRenderPass(e.descriptor)}endRenderPass(){this.renderPassEncoder&&this.renderPassEncoder.end(),this.renderPassEncoder=null}setViewport(e){this.renderPassEncoder.setViewport(e.x,e.y,e.width,e.height,0,1)}setPipelineFromGeometryProgramAndState(e,t,r,s){const i=this._renderer.pipeline.getPipeline(e,t,r,s);this.setPipeline(i)}setPipeline(e){this._boundPipeline!==e&&(this._boundPipeline=e,this.renderPassEncoder.setPipeline(e))}_setVertexBuffer(e,t){this._boundVertexBuffer[e]!==t&&(this._boundVertexBuffer[e]=t,this.renderPassEncoder.setVertexBuffer(e,this._renderer.buffer.updateBuffer(t)))}_setIndexBuffer(e){if(this._boundIndexBuffer===e)return;this._boundIndexBuffer=e;const t=e.data.BYTES_PER_ELEMENT===2?"uint16":"uint32";this.renderPassEncoder.setIndexBuffer(this._renderer.buffer.updateBuffer(e),t)}resetBindGroup(e){this._boundBindGroup[e]=null}setBindGroup(e,t,r){if(this._boundBindGroup[e]===t)return;this._boundBindGroup[e]=t,t._touch(this._renderer.textureGC.count);const s=this._renderer.bindGroup.getBindGroup(t,r,e);this.renderPassEncoder.setBindGroup(e,s)}setGeometry(e,t){const r=this._renderer.pipeline.getBufferNamesToBind(e,t);for(const s in r)this._setVertexBuffer(s,e.attributes[r[s]].buffer);e.indexBuffer&&this._setIndexBuffer(e.indexBuffer)}_setShaderBindGroups(e,t){for(const r in e.groups){const s=e.groups[r];t||this._syncBindGroup(s),this.setBindGroup(r,s,e.gpuProgram)}}_syncBindGroup(e){for(const t in e.resources){const r=e.resources[t];r.isUniformGroup&&this._renderer.ubo.updateUniformGroup(r)}}draw(e){const{geometry:t,shader:r,state:s,topology:i,size:n,start:o,instanceCount:u,skipSync:c}=e;this.setPipelineFromGeometryProgramAndState(t,r.gpuProgram,s,i),this.setGeometry(t,r.gpuProgram),this._setShaderBindGroups(r,c),t.indexBuffer?this.renderPassEncoder.drawIndexed(n||t.indexBuffer.data.length,u||t.instanceCount,o||0):this.renderPassEncoder.draw(n||t.getSize(),u||t.instanceCount,o||0)}finishRenderPass(){this.renderPassEncoder&&(this.renderPassEncoder.end(),this.renderPassEncoder=null)}postrender(){this.finishRenderPass(),this._gpu.device.queue.submit([this.commandEncoder.finish()]),this._resolveCommandFinished(),this.commandEncoder=null}restoreRenderPass(){const e=this._renderer.renderTarget.adaptor.getDescriptor(this._renderer.renderTarget.renderTarget,!1,[0,0,0,1]);this.renderPassEncoder=this.commandEncoder.beginRenderPass(e);const t=this._boundPipeline,r={...this._boundVertexBuffer},s=this._boundIndexBuffer,i={...this._boundBindGroup};this._clearCache();const n=this._renderer.renderTarget.viewport;this.renderPassEncoder.setViewport(n.x,n.y,n.width,n.height,0,1),this.setPipeline(t);for(const o in r)this._setVertexBuffer(o,r[o]);for(const o in i)this.setBindGroup(o,i[o],null);this._setIndexBuffer(s)}_clearCache(){for(let e=0;e<16;e++)this._boundBindGroup[e]=null,this._boundVertexBuffer[e]=null;this._boundIndexBuffer=null,this._boundPipeline=null}destroy(){this._renderer=null,this._gpu=null,this._boundBindGroup=null,this._boundVertexBuffer=null,this._boundIndexBuffer=null,this._boundPipeline=null}contextChange(e){this._gpu=e}}V.extension={type:[l.WebGPUSystem],name:"encoder",priority:1};class N{constructor(e){this._renderTargetStencilState=Object.create(null),this._renderer=e,e.renderTarget.onRenderTargetChange.add(this)}onRenderTargetChange(e){let t=this._renderTargetStencilState[e.uid];t||(t=this._renderTargetStencilState[e.uid]={stencilMode:T.DISABLED,stencilReference:0}),this._activeRenderTarget=e,this.setStencilMode(t.stencilMode,t.stencilReference)}setStencilMode(e,t){const r=this._renderTargetStencilState[this._activeRenderTarget.uid];r.stencilMode=e,r.stencilReference=t;const s=this._renderer;s.pipeline.setStencilMode(e),s.encoder.renderPassEncoder.setStencilReference(t)}destroy(){this._renderer.renderTarget.onRenderTargetChange.remove(this),this._renderer=null,this._activeRenderTarget=null,this._renderTargetStencilState=null}}N.extension={type:[l.WebGPUSystem],name:"stencil"};const x={i32:{align:4,size:4},u32:{align:4,size:4},f32:{align:4,size:4},f16:{align:2,size:2},"vec2":{align:8,size:8},"vec2":{align:8,size:8},"vec2":{align:8,size:8},"vec2":{align:4,size:4},"vec3":{align:16,size:12},"vec3":{align:16,size:12},"vec3":{align:16,size:12},"vec3":{align:8,size:6},"vec4":{align:16,size:16},"vec4":{align:16,size:16},"vec4":{align:16,size:16},"vec4":{align:8,size:8},"mat2x2":{align:8,size:16},"mat2x2":{align:4,size:8},"mat3x2":{align:8,size:24},"mat3x2":{align:4,size:12},"mat4x2":{align:8,size:32},"mat4x2":{align:4,size:16},"mat2x3":{align:16,size:32},"mat2x3":{align:8,size:16},"mat3x3":{align:16,size:48},"mat3x3":{align:8,size:24},"mat4x3":{align:16,size:64},"mat4x3":{align:8,size:32},"mat2x4":{align:16,size:32},"mat2x4":{align:8,size:16},"mat3x4":{align:16,size:48},"mat3x4":{align:8,size:24},"mat4x4":{align:16,size:64},"mat4x4":{align:8,size:32}};function Ce(a){const e=a.map(r=>({data:r,offset:0,size:0}));let t=0;for(let r=0;r1&&(i=Math.max(i,n)*s.data.size),t=Math.ceil(t/n)*n,s.size=i,s.offset=t,t+=i}return t=Math.ceil(t/16)*16,{uboElements:e,size:t}}function Ue(a,e){const{size:t,align:r}=x[a.data.type],s=(r-t)/4;return` v = uv.${a.data.name}; ${e!==0?`offset += ${e};`:""} diff --git a/assets/browserAll-8U9aaa5a.js b/assets/browserAll-Bnl4Z-wu.js similarity index 99% rename from assets/browserAll-8U9aaa5a.js rename to assets/browserAll-Bnl4Z-wu.js index dda6a3e..e856ab8 100644 --- a/assets/browserAll-8U9aaa5a.js +++ b/assets/browserAll-Bnl4Z-wu.js @@ -1 +1 @@ -import{P as m,r as J,E as w,b as L,U as Q,c as ee,w as y,e as z,C as Z}from"./index-2UyWUVAY.js";import"./webworkerAll-Yj3NqXCQ.js";import"./colorToUniform-Bdgu2gC3.js";class M{constructor(e){this.bubbles=!0,this.cancelBubble=!0,this.cancelable=!1,this.composed=!1,this.defaultPrevented=!1,this.eventPhase=M.prototype.NONE,this.propagationStopped=!1,this.propagationImmediatelyStopped=!1,this.layer=new m,this.page=new m,this.NONE=0,this.CAPTURING_PHASE=1,this.AT_TARGET=2,this.BUBBLING_PHASE=3,this.manager=e}get layerX(){return this.layer.x}get layerY(){return this.layer.y}get pageX(){return this.page.x}get pageY(){return this.page.y}get data(){return this}composedPath(){return this.manager&&(!this.path||this.path[this.path.length-1]!==this.target)&&(this.path=this.target?this.manager.propagationPath(this.target):[]),this.path}initEvent(e,t,i){throw new Error("initEvent() is a legacy DOM API. It is not implemented in the Federated Events API.")}initUIEvent(e,t,i,n,s){throw new Error("initUIEvent() is a legacy DOM API. It is not implemented in the Federated Events API.")}preventDefault(){this.nativeEvent instanceof Event&&this.nativeEvent.cancelable&&this.nativeEvent.preventDefault(),this.defaultPrevented=!0}stopImmediatePropagation(){this.propagationImmediatelyStopped=!0}stopPropagation(){this.propagationStopped=!0}}var O=/iPhone/i,C=/iPod/i,S=/iPad/i,U=/\biOS-universal(?:.+)Mac\b/i,k=/\bAndroid(?:.+)Mobile\b/i,H=/Android/i,b=/(?:SD4930UR|\bSilk(?:.+)Mobile\b)/i,A=/Silk/i,g=/Windows Phone/i,X=/\bWindows(?:.+)ARM\b/i,R=/BlackBerry/i,F=/BB10/i,Y=/Opera Mini/i,K=/\b(CriOS|Chrome)(?:.+)Mobile/i,$=/Mobile(?:.+)Firefox\b/i,G=function(r){return typeof r<"u"&&r.platform==="MacIntel"&&typeof r.maxTouchPoints=="number"&&r.maxTouchPoints>1&&typeof MSStream>"u"};function te(r){return function(e){return e.test(r)}}function W(r){var e={userAgent:"",platform:"",maxTouchPoints:0};!r&&typeof navigator<"u"?e={userAgent:navigator.userAgent,platform:navigator.platform,maxTouchPoints:navigator.maxTouchPoints||0}:typeof r=="string"?e.userAgent=r:r&&r.userAgent&&(e={userAgent:r.userAgent,platform:r.platform,maxTouchPoints:r.maxTouchPoints||0});var t=e.userAgent,i=t.split("[FBAN");typeof i[1]<"u"&&(t=i[0]),i=t.split("Twitter"),typeof i[1]<"u"&&(t=i[0]);var n=te(t),s={apple:{phone:n(O)&&!n(g),ipod:n(C),tablet:!n(O)&&(n(S)||G(e))&&!n(g),universal:n(U),device:(n(O)||n(C)||n(S)||n(U)||G(e))&&!n(g)},amazon:{phone:n(b),tablet:!n(b)&&n(A),device:n(b)||n(A)},android:{phone:!n(g)&&n(b)||!n(g)&&n(k),tablet:!n(g)&&!n(b)&&!n(k)&&(n(A)||n(H)),device:!n(g)&&(n(b)||n(A)||n(k)||n(H))||n(/\bokhttp\b/i)},windows:{phone:n(g),tablet:n(X),device:n(g)||n(X)},other:{blackberry:n(R),blackberry10:n(F),opera:n(Y),firefox:n($),chrome:n(K),device:n(R)||n(F)||n(Y)||n($)||n(K)},any:!1,phone:!1,tablet:!1};return s.any=s.apple.device||s.android.device||s.windows.device||s.other.device,s.phone=s.apple.phone||s.android.phone||s.windows.phone,s.tablet=s.apple.tablet||s.android.tablet||s.windows.tablet,s}const ie=W.default??W,ne=ie(globalThis.navigator),se=9,I=100,oe=0,re=0,j=2,N=1,ae=-1e3,he=-1e3,le=2;class V{constructor(e,t=ne){this._mobileInfo=t,this.debug=!1,this._isActive=!1,this._isMobileAccessibility=!1,this._pool=[],this._renderId=0,this._children=[],this._androidUpdateCount=0,this._androidUpdateFrequency=500,this._hookDiv=null,(t.tablet||t.phone)&&this._createTouchHook();const i=document.createElement("div");i.style.width=`${I}px`,i.style.height=`${I}px`,i.style.position="absolute",i.style.top=`${oe}px`,i.style.left=`${re}px`,i.style.zIndex=j.toString(),this._div=i,this._renderer=e,this._onKeyDown=this._onKeyDown.bind(this),this._onMouseMove=this._onMouseMove.bind(this),globalThis.addEventListener("keydown",this._onKeyDown,!1)}get isActive(){return this._isActive}get isMobileAccessibility(){return this._isMobileAccessibility}get hookDiv(){return this._hookDiv}_createTouchHook(){const e=document.createElement("button");e.style.width=`${N}px`,e.style.height=`${N}px`,e.style.position="absolute",e.style.top=`${ae}px`,e.style.left=`${he}px`,e.style.zIndex=le.toString(),e.style.backgroundColor="#FF0000",e.title="select to enable accessibility for this content",e.addEventListener("focus",()=>{this._isMobileAccessibility=!0,this._activate(),this._destroyTouchHook()}),document.body.appendChild(e),this._hookDiv=e}_destroyTouchHook(){this._hookDiv&&(document.body.removeChild(this._hookDiv),this._hookDiv=null)}_activate(){var e;this._isActive||(this._isActive=!0,globalThis.document.addEventListener("mousemove",this._onMouseMove,!0),globalThis.removeEventListener("keydown",this._onKeyDown,!1),this._renderer.runners.postrender.add(this),(e=this._renderer.view.canvas.parentNode)==null||e.appendChild(this._div))}_deactivate(){var e;!this._isActive||this._isMobileAccessibility||(this._isActive=!1,globalThis.document.removeEventListener("mousemove",this._onMouseMove,!0),globalThis.addEventListener("keydown",this._onKeyDown,!1),this._renderer.runners.postrender.remove(this),(e=this._div.parentNode)==null||e.removeChild(this._div))}_updateAccessibleObjects(e){if(!e.visible||!e.accessibleChildren)return;e.accessible&&e.isInteractive()&&(e._accessibleActive||this._addChild(e),e._renderId=this._renderId);const t=e.children;if(t)for(let i=0;i title : ${e.title}
tabIndex: ${e.tabIndex}`}_capHitArea(e){e.x<0&&(e.width+=e.x,e.x=0),e.y<0&&(e.height+=e.y,e.y=0);const{width:t,height:i}=this._renderer;e.x+e.width>t&&(e.width=t-e.x),e.y+e.height>i&&(e.height=i-e.y)}_addChild(e){let t=this._pool.pop();t||(t=document.createElement("button"),t.style.width=`${I}px`,t.style.height=`${I}px`,t.style.backgroundColor=this.debug?"rgba(255,255,255,0.5)":"transparent",t.style.position="absolute",t.style.zIndex=j.toString(),t.style.borderStyle="none",navigator.userAgent.toLowerCase().includes("chrome")?t.setAttribute("aria-live","off"):t.setAttribute("aria-live","polite"),navigator.userAgent.match(/rv:.*Gecko\//)?t.setAttribute("aria-relevant","additions"):t.setAttribute("aria-relevant","text"),t.addEventListener("click",this._onClick.bind(this)),t.addEventListener("focus",this._onFocus.bind(this)),t.addEventListener("focusout",this._onFocusOut.bind(this))),t.style.pointerEvents=e.accessiblePointerEvents,t.type=e.accessibleType,e.accessibleTitle&&e.accessibleTitle!==null?t.title=e.accessibleTitle:(!e.accessibleHint||e.accessibleHint===null)&&(t.title=`container ${e.tabIndex}`),e.accessibleHint&&e.accessibleHint!==null&&t.setAttribute("aria-label",e.accessibleHint),this.debug&&this._updateDebugHTML(t),e._accessibleActive=!0,e._accessibleDiv=t,t.container=e,this._children.push(e),this._div.appendChild(e._accessibleDiv),e._accessibleDiv.tabIndex=e.tabIndex}_dispatchEvent(e,t){const{container:i}=e.target,n=this._renderer.events.rootBoundary,s=Object.assign(new M(n),{target:i});n.rootTarget=this._renderer.lastObjectRendered,t.forEach(o=>n.dispatchEvent(s,o))}_onClick(e){this._dispatchEvent(e,["click","pointertap","tap"])}_onFocus(e){e.target.getAttribute("aria-live")||e.target.setAttribute("aria-live","assertive"),this._dispatchEvent(e,["mouseover"])}_onFocusOut(e){e.target.getAttribute("aria-live")||e.target.setAttribute("aria-live","polite"),this._dispatchEvent(e,["mouseout"])}_onKeyDown(e){e.keyCode===se&&this._activate()}_onMouseMove(e){e.movementX===0&&e.movementY===0||this._deactivate()}destroy(){this._destroyTouchHook(),this._div=null,globalThis.document.removeEventListener("mousemove",this._onMouseMove,!0),globalThis.removeEventListener("keydown",this._onKeyDown),this._pool=null,this._children=null,this._renderer=null}}V.extension={type:[w.WebGLSystem,w.WebGPUSystem],name:"accessibility"};const ue={accessible:!1,accessibleTitle:null,accessibleHint:null,tabIndex:0,_accessibleActive:!1,_accessibleDiv:null,accessibleType:"button",accessiblePointerEvents:"auto",accessibleChildren:!0,_renderId:-1};class de{constructor(){this.interactionFrequency=10,this._deltaTime=0,this._didMove=!1,this._tickerAdded=!1,this._pauseUpdate=!0}init(e){this.removeTickerListener(),this.events=e,this.interactionFrequency=10,this._deltaTime=0,this._didMove=!1,this._tickerAdded=!1,this._pauseUpdate=!0}get pauseUpdate(){return this._pauseUpdate}set pauseUpdate(e){this._pauseUpdate=e}addTickerListener(){this._tickerAdded||!this.domElement||(L.system.add(this._tickerUpdate,this,Q.INTERACTION),this._tickerAdded=!0)}removeTickerListener(){this._tickerAdded&&(L.system.remove(this._tickerUpdate,this),this._tickerAdded=!1)}pointerMoved(){this._didMove=!0}_update(){if(!this.domElement||this._pauseUpdate)return;if(this._didMove){this._didMove=!1;return}const e=this.events._rootPointerEvent;this.events.supportsTouchEvents&&e.pointerType==="touch"||globalThis.document.dispatchEvent(new PointerEvent("pointermove",{clientX:e.clientX,clientY:e.clientY,pointerType:e.pointerType,pointerId:e.pointerId}))}_tickerUpdate(e){this._deltaTime+=e.deltaTime,!(this._deltaTimei.priority-n.priority)}dispatchEvent(e,t){e.propagationStopped=!1,e.propagationImmediatelyStopped=!1,this.propagate(e,t),this.dispatch.emit(t||e.type,e)}mapEvent(e){if(!this.rootTarget)return;const t=this.mappingTable[e.type];if(t)for(let i=0,n=t.length;i=0;n--)if(e.currentTarget=i[n],this.notifyTarget(e,t),e.propagationStopped||e.propagationImmediatelyStopped)return}}all(e,t,i=this._allInteractiveElements){if(i.length===0)return;e.eventPhase=e.BUBBLING_PHASE;const n=Array.isArray(t)?t:[t];for(let s=i.length-1;s>=0;s--)n.forEach(o=>{e.currentTarget=i[s],this.notifyTarget(e,o)})}propagationPath(e){const t=[e];for(let i=0;i=0;h--){const l=v[h],u=this.hitTestMoveRecursive(l,this._isInteractive(t)?t:l.eventMode,i,n,s,o||s(e,i));if(u){if(u.length>0&&!u[u.length-1].parent)continue;const d=e.isInteractive();(u.length>0||d)&&(d&&this._allInteractiveElements.push(e),u.push(e)),this._hitElements.length===0&&(this._hitElements=u),a=!0}}}const c=this._isInteractive(t),p=e.isInteractive();return p&&p&&this._allInteractiveElements.push(e),o||this._hitElements.length>0?null:a?this._hitElements:c&&!s(e,i)&&n(e,i)?p?[e]:[]:null}hitTestRecursive(e,t,i,n,s){if(this._interactivePrune(e)||s(e,i))return null;if((e.eventMode==="dynamic"||t==="dynamic")&&(E.pauseUpdate=!1),e.interactiveChildren&&e.children){const c=e.children,p=i;for(let v=c.length-1;v>=0;v--){const h=c[v],l=this.hitTestRecursive(h,this._isInteractive(t)?t:h.eventMode,p,n,s);if(l){if(l.length>0&&!l[l.length-1].parent)continue;const u=e.isInteractive();return(l.length>0||u)&&l.push(e),l}}}const o=this._isInteractive(t),a=e.isInteractive();return o&&n(e,i)?a?[e]:[]:null}_isInteractive(e){return e==="static"||e==="dynamic"}_interactivePrune(e){return!e||!e.visible||!e.renderable||!e.includeInBuild||!e.measurable||e.eventMode==="none"||e.eventMode==="passive"&&!e.interactiveChildren}hitPruneFn(e,t){if(e.hitArea&&(e.worldTransform.applyInverse(t,P),!e.hitArea.contains(P.x,P.y)))return!0;if(e.effects&&e.effects.length)for(let i=0;i0&&s!==t.target){const v=e.type==="mousemove"?"mouseout":"pointerout",h=this.createPointerEvent(e,v,s);if(this.dispatchEvent(h,"pointerout"),i&&this.dispatchEvent(h,"mouseout"),!t.composedPath().includes(s)){const l=this.createPointerEvent(e,"pointerleave",s);for(l.eventPhase=l.AT_TARGET;l.target&&!t.composedPath().includes(l.target);)l.currentTarget=l.target,this.notifyTarget(l),i&&this.notifyTarget(l,"mouseleave"),l.target=l.target.parent;this.freeEvent(l)}this.freeEvent(h)}if(s!==t.target){const v=e.type==="mousemove"?"mouseover":"pointerover",h=this.clonePointerEvent(t,v);this.dispatchEvent(h,"pointerover"),i&&this.dispatchEvent(h,"mouseover");let l=s==null?void 0:s.parent;for(;l&&l!==this.rootTarget.parent&&l!==t.target;)l=l.parent;if(!l||l===this.rootTarget.parent){const d=this.clonePointerEvent(t,"pointerenter");for(d.eventPhase=d.AT_TARGET;d.target&&d.target!==s&&d.target!==this.rootTarget.parent;)d.currentTarget=d.target,this.notifyTarget(d),i&&this.notifyTarget(d,"mouseenter"),d.target=d.target.parent;this.freeEvent(d)}this.freeEvent(h)}const o=[],a=this.enableGlobalMoveEvents??!0;this.moveOnAll?o.push("pointermove"):this.dispatchEvent(t,"pointermove"),a&&o.push("globalpointermove"),t.pointerType==="touch"&&(this.moveOnAll?o.splice(1,0,"touchmove"):this.dispatchEvent(t,"touchmove"),a&&o.push("globaltouchmove")),i&&(this.moveOnAll?o.splice(1,0,"mousemove"):this.dispatchEvent(t,"mousemove"),a&&o.push("globalmousemove"),this.cursor=(p=t.target)==null?void 0:p.cursor),o.length>0&&this.all(t,o),this._allInteractiveElements.length=0,this._hitElements.length=0,n.overTargets=t.composedPath(),this.freeEvent(t)}mapPointerOver(e){var o;if(!(e instanceof f)){y("EventBoundary cannot map a non-pointer event as a pointer event");return}const t=this.trackingData(e.pointerId),i=this.createPointerEvent(e),n=i.pointerType==="mouse"||i.pointerType==="pen";this.dispatchEvent(i,"pointerover"),n&&this.dispatchEvent(i,"mouseover"),i.pointerType==="mouse"&&(this.cursor=(o=i.target)==null?void 0:o.cursor);const s=this.clonePointerEvent(i,"pointerenter");for(s.eventPhase=s.AT_TARGET;s.target&&s.target!==this.rootTarget.parent;)s.currentTarget=s.target,this.notifyTarget(s),n&&this.notifyTarget(s,"mouseenter"),s.target=s.target.parent;t.overTargets=i.composedPath(),this.freeEvent(i),this.freeEvent(s)}mapPointerOut(e){if(!(e instanceof f)){y("EventBoundary cannot map a non-pointer event as a pointer event");return}const t=this.trackingData(e.pointerId);if(t.overTargets){const i=e.pointerType==="mouse"||e.pointerType==="pen",n=this.findMountedTarget(t.overTargets),s=this.createPointerEvent(e,"pointerout",n);this.dispatchEvent(s),i&&this.dispatchEvent(s,"mouseout");const o=this.createPointerEvent(e,"pointerleave",n);for(o.eventPhase=o.AT_TARGET;o.target&&o.target!==this.rootTarget.parent;)o.currentTarget=o.target,this.notifyTarget(o),i&&this.notifyTarget(o,"mouseleave"),o.target=o.target.parent;t.overTargets=null,this.freeEvent(s),this.freeEvent(o)}this.cursor=null}mapPointerUp(e){if(!(e instanceof f)){y("EventBoundary cannot map a non-pointer event as a pointer event");return}const t=performance.now(),i=this.createPointerEvent(e);if(this.dispatchEvent(i,"pointerup"),i.pointerType==="touch")this.dispatchEvent(i,"touchend");else if(i.pointerType==="mouse"||i.pointerType==="pen"){const a=i.button===2;this.dispatchEvent(i,a?"rightup":"mouseup")}const n=this.trackingData(e.pointerId),s=this.findMountedTarget(n.pressTargetsByButton[e.button]);let o=s;if(s&&!i.composedPath().includes(s)){let a=s;for(;a&&!i.composedPath().includes(a);){if(i.currentTarget=a,this.notifyTarget(i,"pointerupoutside"),i.pointerType==="touch")this.notifyTarget(i,"touchendoutside");else if(i.pointerType==="mouse"||i.pointerType==="pen"){const c=i.button===2;this.notifyTarget(i,c?"rightupoutside":"mouseupoutside")}a=a.parent}delete n.pressTargetsByButton[e.button],o=a}if(o){const a=this.clonePointerEvent(i,"click");a.target=o,a.path=null,n.clicksByButton[e.button]||(n.clicksByButton[e.button]={clickCount:0,target:a.target,timeStamp:t});const c=n.clicksByButton[e.button];if(c.target===a.target&&t-c.timeStamp<200?++c.clickCount:c.clickCount=1,c.target=a.target,c.timeStamp=t,a.detail=c.clickCount,a.pointerType==="mouse"){const p=a.button===2;this.dispatchEvent(a,p?"rightclick":"click")}else a.pointerType==="touch"&&this.dispatchEvent(a,"tap");this.dispatchEvent(a,"pointertap"),this.freeEvent(a)}this.freeEvent(i)}mapPointerUpOutside(e){if(!(e instanceof f)){y("EventBoundary cannot map a non-pointer event as a pointer event");return}const t=this.trackingData(e.pointerId),i=this.findMountedTarget(t.pressTargetsByButton[e.button]),n=this.createPointerEvent(e);if(i){let s=i;for(;s;)n.currentTarget=s,this.notifyTarget(n,"pointerupoutside"),n.pointerType==="touch"?this.notifyTarget(n,"touchendoutside"):(n.pointerType==="mouse"||n.pointerType==="pen")&&this.notifyTarget(n,n.button===2?"rightupoutside":"mouseupoutside"),s=s.parent;delete t.pressTargetsByButton[e.button]}this.freeEvent(n)}mapWheel(e){if(!(e instanceof T)){y("EventBoundary cannot map a non-wheel event as a wheel event");return}const t=this.createWheelEvent(e);this.dispatchEvent(t),this.freeEvent(t)}findMountedTarget(e){if(!e)return null;let t=e[0];for(let i=1;i(i==="globalMove"&&(this.rootBoundary.enableGlobalMoveEvents=n),t[i]=n,!0)}),this._onPointerDown=this._onPointerDown.bind(this),this._onPointerMove=this._onPointerMove.bind(this),this._onPointerUp=this._onPointerUp.bind(this),this._onPointerOverOut=this._onPointerOverOut.bind(this),this.onWheel=this.onWheel.bind(this)}static get defaultEventMode(){return this._defaultEventMode}init(e){const{canvas:t,resolution:i}=this.renderer;this.setTargetElement(t),this.resolution=i,x._defaultEventMode=e.eventMode??"passive",Object.assign(this.features,e.eventFeatures??{}),this.rootBoundary.enableGlobalMoveEvents=this.features.globalMove}resolutionChange(e){this.resolution=e}destroy(){this.setTargetElement(null),this.renderer=null,this._currentCursor=null}setCursor(e){e=e||"default";let t=!0;if(globalThis.OffscreenCanvas&&this.domElement instanceof OffscreenCanvas&&(t=!1),this._currentCursor===e)return;this._currentCursor=e;const i=this.cursorStyles[e];if(i)switch(typeof i){case"string":t&&(this.domElement.style.cursor=i);break;case"function":i(e);break;case"object":t&&Object.assign(this.domElement.style,i);break}else t&&typeof e=="string"&&!Object.prototype.hasOwnProperty.call(this.cursorStyles,e)&&(this.domElement.style.cursor=e)}get pointer(){return this._rootPointerEvent}_onPointerDown(e){if(!this.features.click)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered;const t=this._normalizeToPointerData(e);this.autoPreventDefault&&t[0].isNormalized&&(e.cancelable||!("cancelable"in e))&&e.preventDefault();for(let i=0,n=t.length;i0&&(t=e.composedPath()[0]);const i=t!==this.domElement?"outside":"",n=this._normalizeToPointerData(e);for(let s=0,o=n.length;s"u"&&(s.button=0),typeof s.buttons>"u"&&(s.buttons=1),typeof s.isPrimary>"u"&&(s.isPrimary=e.touches.length===1&&e.type==="touchstart"),typeof s.width>"u"&&(s.width=s.radiusX||1),typeof s.height>"u"&&(s.height=s.radiusY||1),typeof s.tiltX>"u"&&(s.tiltX=0),typeof s.tiltY>"u"&&(s.tiltY=0),typeof s.pointerType>"u"&&(s.pointerType="touch"),typeof s.pointerId>"u"&&(s.pointerId=s.identifier||0),typeof s.pressure>"u"&&(s.pressure=s.force||.5),typeof s.twist>"u"&&(s.twist=0),typeof s.tangentialPressure>"u"&&(s.tangentialPressure=0),typeof s.layerX>"u"&&(s.layerX=s.offsetX=s.clientX),typeof s.layerY>"u"&&(s.layerY=s.offsetY=s.clientY),s.isNormalized=!0,s.type=e.type,t.push(s)}else if(!globalThis.MouseEvent||e instanceof MouseEvent&&(!this.supportsPointerEvents||!(e instanceof globalThis.PointerEvent))){const i=e;typeof i.isPrimary>"u"&&(i.isPrimary=!0),typeof i.width>"u"&&(i.width=1),typeof i.height>"u"&&(i.height=1),typeof i.tiltX>"u"&&(i.tiltX=0),typeof i.tiltY>"u"&&(i.tiltY=0),typeof i.pointerType>"u"&&(i.pointerType="mouse"),typeof i.pointerId>"u"&&(i.pointerId=fe),typeof i.pressure>"u"&&(i.pressure=.5),typeof i.twist>"u"&&(i.twist=0),typeof i.tangentialPressure>"u"&&(i.tangentialPressure=0),i.isNormalized=!0,t.push(i)}else t.push(e);return t}normalizeWheelEvent(e){const t=this._rootWheelEvent;return this._transferMouseData(t,e),t.deltaX=e.deltaX,t.deltaY=e.deltaY,t.deltaZ=e.deltaZ,t.deltaMode=e.deltaMode,this.mapPositionToPoint(t.screen,e.clientX,e.clientY),t.global.copyFrom(t.screen),t.offset.copyFrom(t.screen),t.nativeEvent=e,t.type=e.type,t}_bootstrapEvent(e,t){return e.originalEvent=null,e.nativeEvent=t,e.pointerId=t.pointerId,e.width=t.width,e.height=t.height,e.isPrimary=t.isPrimary,e.pointerType=t.pointerType,e.pressure=t.pressure,e.tangentialPressure=t.tangentialPressure,e.tiltX=t.tiltX,e.tiltY=t.tiltY,e.twist=t.twist,this._transferMouseData(e,t),this.mapPositionToPoint(e.screen,t.clientX,t.clientY),e.global.copyFrom(e.screen),e.offset.copyFrom(e.screen),e.isTrusted=t.isTrusted,e.type==="pointerleave"&&(e.type="pointerout"),e.type.startsWith("mouse")&&(e.type=e.type.replace("mouse","pointer")),e.type.startsWith("touch")&&(e.type=ge[e.type]||e.type),e}_transferMouseData(e,t){e.isTrusted=t.isTrusted,e.srcElement=t.srcElement,e.timeStamp=performance.now(),e.type=t.type,e.altKey=t.altKey,e.button=t.button,e.buttons=t.buttons,e.client.x=t.clientX,e.client.y=t.clientY,e.ctrlKey=t.ctrlKey,e.metaKey=t.metaKey,e.movement.x=t.movementX,e.movement.y=t.movementY,e.page.x=t.pageX,e.page.y=t.pageY,e.relatedTarget=null,e.shiftKey=t.shiftKey}};B.extension={name:"events",type:[w.WebGLSystem,w.CanvasSystem,w.WebGPUSystem],priority:-1};B.defaultEventFeatures={move:!0,globalMove:!0,click:!0,wheel:!0};let q=B;const me={onclick:null,onmousedown:null,onmouseenter:null,onmouseleave:null,onmousemove:null,onglobalmousemove:null,onmouseout:null,onmouseover:null,onmouseup:null,onmouseupoutside:null,onpointercancel:null,onpointerdown:null,onpointerenter:null,onpointerleave:null,onpointermove:null,onglobalpointermove:null,onpointerout:null,onpointerover:null,onpointertap:null,onpointerup:null,onpointerupoutside:null,onrightclick:null,onrightdown:null,onrightup:null,onrightupoutside:null,ontap:null,ontouchcancel:null,ontouchend:null,ontouchendoutside:null,ontouchmove:null,onglobaltouchmove:null,ontouchstart:null,onwheel:null,get interactive(){return this.eventMode==="dynamic"||this.eventMode==="static"},set interactive(r){this.eventMode=r?"static":"passive"},_internalEventMode:void 0,get eventMode(){return this._internalEventMode??q.defaultEventMode},set eventMode(r){this._internalEventMode=r},isInteractive(){return this.eventMode==="static"||this.eventMode==="dynamic"},interactiveChildren:!0,hitArea:null,addEventListener(r,e,t){const i=typeof t=="boolean"&&t||typeof t=="object"&&t.capture,n=typeof t=="object"?t.signal:void 0,s=typeof t=="object"?t.once===!0:!1,o=typeof e=="function"?void 0:e;r=i?`${r}capture`:r;const a=typeof e=="function"?e:e.handleEvent,c=this;n&&n.addEventListener("abort",()=>{c.off(r,a,o)}),s?c.once(r,a,o):c.on(r,a,o)},removeEventListener(r,e,t){const i=typeof t=="boolean"&&t||typeof t=="object"&&t.capture,n=typeof e=="function"?void 0:e;r=i?`${r}capture`:r,e=typeof e=="function"?e:e.handleEvent,this.off(r,e,n)},dispatchEvent(r){if(!(r instanceof M))throw new Error("Container cannot propagate events outside of the Federated Events API");return r.defaultPrevented=!1,r.path=null,r.target=this,r.manager.dispatchEvent(r),!r.defaultPrevented}};z.add(V);Z.mixin(ue);z.add(q);Z.mixin(me); +import{P as m,r as J,E as w,b as L,U as Q,c as ee,w as y,e as z,C as Z}from"./index-WJSjzvvL.js";import"./webworkerAll-Cp5jyL-l.js";import"./colorToUniform-Dzvfc6yy.js";class M{constructor(e){this.bubbles=!0,this.cancelBubble=!0,this.cancelable=!1,this.composed=!1,this.defaultPrevented=!1,this.eventPhase=M.prototype.NONE,this.propagationStopped=!1,this.propagationImmediatelyStopped=!1,this.layer=new m,this.page=new m,this.NONE=0,this.CAPTURING_PHASE=1,this.AT_TARGET=2,this.BUBBLING_PHASE=3,this.manager=e}get layerX(){return this.layer.x}get layerY(){return this.layer.y}get pageX(){return this.page.x}get pageY(){return this.page.y}get data(){return this}composedPath(){return this.manager&&(!this.path||this.path[this.path.length-1]!==this.target)&&(this.path=this.target?this.manager.propagationPath(this.target):[]),this.path}initEvent(e,t,i){throw new Error("initEvent() is a legacy DOM API. It is not implemented in the Federated Events API.")}initUIEvent(e,t,i,n,s){throw new Error("initUIEvent() is a legacy DOM API. It is not implemented in the Federated Events API.")}preventDefault(){this.nativeEvent instanceof Event&&this.nativeEvent.cancelable&&this.nativeEvent.preventDefault(),this.defaultPrevented=!0}stopImmediatePropagation(){this.propagationImmediatelyStopped=!0}stopPropagation(){this.propagationStopped=!0}}var O=/iPhone/i,C=/iPod/i,S=/iPad/i,U=/\biOS-universal(?:.+)Mac\b/i,k=/\bAndroid(?:.+)Mobile\b/i,H=/Android/i,b=/(?:SD4930UR|\bSilk(?:.+)Mobile\b)/i,A=/Silk/i,g=/Windows Phone/i,X=/\bWindows(?:.+)ARM\b/i,R=/BlackBerry/i,F=/BB10/i,Y=/Opera Mini/i,K=/\b(CriOS|Chrome)(?:.+)Mobile/i,$=/Mobile(?:.+)Firefox\b/i,G=function(r){return typeof r<"u"&&r.platform==="MacIntel"&&typeof r.maxTouchPoints=="number"&&r.maxTouchPoints>1&&typeof MSStream>"u"};function te(r){return function(e){return e.test(r)}}function W(r){var e={userAgent:"",platform:"",maxTouchPoints:0};!r&&typeof navigator<"u"?e={userAgent:navigator.userAgent,platform:navigator.platform,maxTouchPoints:navigator.maxTouchPoints||0}:typeof r=="string"?e.userAgent=r:r&&r.userAgent&&(e={userAgent:r.userAgent,platform:r.platform,maxTouchPoints:r.maxTouchPoints||0});var t=e.userAgent,i=t.split("[FBAN");typeof i[1]<"u"&&(t=i[0]),i=t.split("Twitter"),typeof i[1]<"u"&&(t=i[0]);var n=te(t),s={apple:{phone:n(O)&&!n(g),ipod:n(C),tablet:!n(O)&&(n(S)||G(e))&&!n(g),universal:n(U),device:(n(O)||n(C)||n(S)||n(U)||G(e))&&!n(g)},amazon:{phone:n(b),tablet:!n(b)&&n(A),device:n(b)||n(A)},android:{phone:!n(g)&&n(b)||!n(g)&&n(k),tablet:!n(g)&&!n(b)&&!n(k)&&(n(A)||n(H)),device:!n(g)&&(n(b)||n(A)||n(k)||n(H))||n(/\bokhttp\b/i)},windows:{phone:n(g),tablet:n(X),device:n(g)||n(X)},other:{blackberry:n(R),blackberry10:n(F),opera:n(Y),firefox:n($),chrome:n(K),device:n(R)||n(F)||n(Y)||n($)||n(K)},any:!1,phone:!1,tablet:!1};return s.any=s.apple.device||s.android.device||s.windows.device||s.other.device,s.phone=s.apple.phone||s.android.phone||s.windows.phone,s.tablet=s.apple.tablet||s.android.tablet||s.windows.tablet,s}const ie=W.default??W,ne=ie(globalThis.navigator),se=9,I=100,oe=0,re=0,j=2,N=1,ae=-1e3,he=-1e3,le=2;class V{constructor(e,t=ne){this._mobileInfo=t,this.debug=!1,this._isActive=!1,this._isMobileAccessibility=!1,this._pool=[],this._renderId=0,this._children=[],this._androidUpdateCount=0,this._androidUpdateFrequency=500,this._hookDiv=null,(t.tablet||t.phone)&&this._createTouchHook();const i=document.createElement("div");i.style.width=`${I}px`,i.style.height=`${I}px`,i.style.position="absolute",i.style.top=`${oe}px`,i.style.left=`${re}px`,i.style.zIndex=j.toString(),this._div=i,this._renderer=e,this._onKeyDown=this._onKeyDown.bind(this),this._onMouseMove=this._onMouseMove.bind(this),globalThis.addEventListener("keydown",this._onKeyDown,!1)}get isActive(){return this._isActive}get isMobileAccessibility(){return this._isMobileAccessibility}get hookDiv(){return this._hookDiv}_createTouchHook(){const e=document.createElement("button");e.style.width=`${N}px`,e.style.height=`${N}px`,e.style.position="absolute",e.style.top=`${ae}px`,e.style.left=`${he}px`,e.style.zIndex=le.toString(),e.style.backgroundColor="#FF0000",e.title="select to enable accessibility for this content",e.addEventListener("focus",()=>{this._isMobileAccessibility=!0,this._activate(),this._destroyTouchHook()}),document.body.appendChild(e),this._hookDiv=e}_destroyTouchHook(){this._hookDiv&&(document.body.removeChild(this._hookDiv),this._hookDiv=null)}_activate(){var e;this._isActive||(this._isActive=!0,globalThis.document.addEventListener("mousemove",this._onMouseMove,!0),globalThis.removeEventListener("keydown",this._onKeyDown,!1),this._renderer.runners.postrender.add(this),(e=this._renderer.view.canvas.parentNode)==null||e.appendChild(this._div))}_deactivate(){var e;!this._isActive||this._isMobileAccessibility||(this._isActive=!1,globalThis.document.removeEventListener("mousemove",this._onMouseMove,!0),globalThis.addEventListener("keydown",this._onKeyDown,!1),this._renderer.runners.postrender.remove(this),(e=this._div.parentNode)==null||e.removeChild(this._div))}_updateAccessibleObjects(e){if(!e.visible||!e.accessibleChildren)return;e.accessible&&e.isInteractive()&&(e._accessibleActive||this._addChild(e),e._renderId=this._renderId);const t=e.children;if(t)for(let i=0;i title : ${e.title}
tabIndex: ${e.tabIndex}`}_capHitArea(e){e.x<0&&(e.width+=e.x,e.x=0),e.y<0&&(e.height+=e.y,e.y=0);const{width:t,height:i}=this._renderer;e.x+e.width>t&&(e.width=t-e.x),e.y+e.height>i&&(e.height=i-e.y)}_addChild(e){let t=this._pool.pop();t||(t=document.createElement("button"),t.style.width=`${I}px`,t.style.height=`${I}px`,t.style.backgroundColor=this.debug?"rgba(255,255,255,0.5)":"transparent",t.style.position="absolute",t.style.zIndex=j.toString(),t.style.borderStyle="none",navigator.userAgent.toLowerCase().includes("chrome")?t.setAttribute("aria-live","off"):t.setAttribute("aria-live","polite"),navigator.userAgent.match(/rv:.*Gecko\//)?t.setAttribute("aria-relevant","additions"):t.setAttribute("aria-relevant","text"),t.addEventListener("click",this._onClick.bind(this)),t.addEventListener("focus",this._onFocus.bind(this)),t.addEventListener("focusout",this._onFocusOut.bind(this))),t.style.pointerEvents=e.accessiblePointerEvents,t.type=e.accessibleType,e.accessibleTitle&&e.accessibleTitle!==null?t.title=e.accessibleTitle:(!e.accessibleHint||e.accessibleHint===null)&&(t.title=`container ${e.tabIndex}`),e.accessibleHint&&e.accessibleHint!==null&&t.setAttribute("aria-label",e.accessibleHint),this.debug&&this._updateDebugHTML(t),e._accessibleActive=!0,e._accessibleDiv=t,t.container=e,this._children.push(e),this._div.appendChild(e._accessibleDiv),e._accessibleDiv.tabIndex=e.tabIndex}_dispatchEvent(e,t){const{container:i}=e.target,n=this._renderer.events.rootBoundary,s=Object.assign(new M(n),{target:i});n.rootTarget=this._renderer.lastObjectRendered,t.forEach(o=>n.dispatchEvent(s,o))}_onClick(e){this._dispatchEvent(e,["click","pointertap","tap"])}_onFocus(e){e.target.getAttribute("aria-live")||e.target.setAttribute("aria-live","assertive"),this._dispatchEvent(e,["mouseover"])}_onFocusOut(e){e.target.getAttribute("aria-live")||e.target.setAttribute("aria-live","polite"),this._dispatchEvent(e,["mouseout"])}_onKeyDown(e){e.keyCode===se&&this._activate()}_onMouseMove(e){e.movementX===0&&e.movementY===0||this._deactivate()}destroy(){this._destroyTouchHook(),this._div=null,globalThis.document.removeEventListener("mousemove",this._onMouseMove,!0),globalThis.removeEventListener("keydown",this._onKeyDown),this._pool=null,this._children=null,this._renderer=null}}V.extension={type:[w.WebGLSystem,w.WebGPUSystem],name:"accessibility"};const ue={accessible:!1,accessibleTitle:null,accessibleHint:null,tabIndex:0,_accessibleActive:!1,_accessibleDiv:null,accessibleType:"button",accessiblePointerEvents:"auto",accessibleChildren:!0,_renderId:-1};class de{constructor(){this.interactionFrequency=10,this._deltaTime=0,this._didMove=!1,this._tickerAdded=!1,this._pauseUpdate=!0}init(e){this.removeTickerListener(),this.events=e,this.interactionFrequency=10,this._deltaTime=0,this._didMove=!1,this._tickerAdded=!1,this._pauseUpdate=!0}get pauseUpdate(){return this._pauseUpdate}set pauseUpdate(e){this._pauseUpdate=e}addTickerListener(){this._tickerAdded||!this.domElement||(L.system.add(this._tickerUpdate,this,Q.INTERACTION),this._tickerAdded=!0)}removeTickerListener(){this._tickerAdded&&(L.system.remove(this._tickerUpdate,this),this._tickerAdded=!1)}pointerMoved(){this._didMove=!0}_update(){if(!this.domElement||this._pauseUpdate)return;if(this._didMove){this._didMove=!1;return}const e=this.events._rootPointerEvent;this.events.supportsTouchEvents&&e.pointerType==="touch"||globalThis.document.dispatchEvent(new PointerEvent("pointermove",{clientX:e.clientX,clientY:e.clientY,pointerType:e.pointerType,pointerId:e.pointerId}))}_tickerUpdate(e){this._deltaTime+=e.deltaTime,!(this._deltaTimei.priority-n.priority)}dispatchEvent(e,t){e.propagationStopped=!1,e.propagationImmediatelyStopped=!1,this.propagate(e,t),this.dispatch.emit(t||e.type,e)}mapEvent(e){if(!this.rootTarget)return;const t=this.mappingTable[e.type];if(t)for(let i=0,n=t.length;i=0;n--)if(e.currentTarget=i[n],this.notifyTarget(e,t),e.propagationStopped||e.propagationImmediatelyStopped)return}}all(e,t,i=this._allInteractiveElements){if(i.length===0)return;e.eventPhase=e.BUBBLING_PHASE;const n=Array.isArray(t)?t:[t];for(let s=i.length-1;s>=0;s--)n.forEach(o=>{e.currentTarget=i[s],this.notifyTarget(e,o)})}propagationPath(e){const t=[e];for(let i=0;i=0;h--){const l=v[h],u=this.hitTestMoveRecursive(l,this._isInteractive(t)?t:l.eventMode,i,n,s,o||s(e,i));if(u){if(u.length>0&&!u[u.length-1].parent)continue;const d=e.isInteractive();(u.length>0||d)&&(d&&this._allInteractiveElements.push(e),u.push(e)),this._hitElements.length===0&&(this._hitElements=u),a=!0}}}const c=this._isInteractive(t),p=e.isInteractive();return p&&p&&this._allInteractiveElements.push(e),o||this._hitElements.length>0?null:a?this._hitElements:c&&!s(e,i)&&n(e,i)?p?[e]:[]:null}hitTestRecursive(e,t,i,n,s){if(this._interactivePrune(e)||s(e,i))return null;if((e.eventMode==="dynamic"||t==="dynamic")&&(E.pauseUpdate=!1),e.interactiveChildren&&e.children){const c=e.children,p=i;for(let v=c.length-1;v>=0;v--){const h=c[v],l=this.hitTestRecursive(h,this._isInteractive(t)?t:h.eventMode,p,n,s);if(l){if(l.length>0&&!l[l.length-1].parent)continue;const u=e.isInteractive();return(l.length>0||u)&&l.push(e),l}}}const o=this._isInteractive(t),a=e.isInteractive();return o&&n(e,i)?a?[e]:[]:null}_isInteractive(e){return e==="static"||e==="dynamic"}_interactivePrune(e){return!e||!e.visible||!e.renderable||!e.includeInBuild||!e.measurable||e.eventMode==="none"||e.eventMode==="passive"&&!e.interactiveChildren}hitPruneFn(e,t){if(e.hitArea&&(e.worldTransform.applyInverse(t,P),!e.hitArea.contains(P.x,P.y)))return!0;if(e.effects&&e.effects.length)for(let i=0;i0&&s!==t.target){const v=e.type==="mousemove"?"mouseout":"pointerout",h=this.createPointerEvent(e,v,s);if(this.dispatchEvent(h,"pointerout"),i&&this.dispatchEvent(h,"mouseout"),!t.composedPath().includes(s)){const l=this.createPointerEvent(e,"pointerleave",s);for(l.eventPhase=l.AT_TARGET;l.target&&!t.composedPath().includes(l.target);)l.currentTarget=l.target,this.notifyTarget(l),i&&this.notifyTarget(l,"mouseleave"),l.target=l.target.parent;this.freeEvent(l)}this.freeEvent(h)}if(s!==t.target){const v=e.type==="mousemove"?"mouseover":"pointerover",h=this.clonePointerEvent(t,v);this.dispatchEvent(h,"pointerover"),i&&this.dispatchEvent(h,"mouseover");let l=s==null?void 0:s.parent;for(;l&&l!==this.rootTarget.parent&&l!==t.target;)l=l.parent;if(!l||l===this.rootTarget.parent){const d=this.clonePointerEvent(t,"pointerenter");for(d.eventPhase=d.AT_TARGET;d.target&&d.target!==s&&d.target!==this.rootTarget.parent;)d.currentTarget=d.target,this.notifyTarget(d),i&&this.notifyTarget(d,"mouseenter"),d.target=d.target.parent;this.freeEvent(d)}this.freeEvent(h)}const o=[],a=this.enableGlobalMoveEvents??!0;this.moveOnAll?o.push("pointermove"):this.dispatchEvent(t,"pointermove"),a&&o.push("globalpointermove"),t.pointerType==="touch"&&(this.moveOnAll?o.splice(1,0,"touchmove"):this.dispatchEvent(t,"touchmove"),a&&o.push("globaltouchmove")),i&&(this.moveOnAll?o.splice(1,0,"mousemove"):this.dispatchEvent(t,"mousemove"),a&&o.push("globalmousemove"),this.cursor=(p=t.target)==null?void 0:p.cursor),o.length>0&&this.all(t,o),this._allInteractiveElements.length=0,this._hitElements.length=0,n.overTargets=t.composedPath(),this.freeEvent(t)}mapPointerOver(e){var o;if(!(e instanceof f)){y("EventBoundary cannot map a non-pointer event as a pointer event");return}const t=this.trackingData(e.pointerId),i=this.createPointerEvent(e),n=i.pointerType==="mouse"||i.pointerType==="pen";this.dispatchEvent(i,"pointerover"),n&&this.dispatchEvent(i,"mouseover"),i.pointerType==="mouse"&&(this.cursor=(o=i.target)==null?void 0:o.cursor);const s=this.clonePointerEvent(i,"pointerenter");for(s.eventPhase=s.AT_TARGET;s.target&&s.target!==this.rootTarget.parent;)s.currentTarget=s.target,this.notifyTarget(s),n&&this.notifyTarget(s,"mouseenter"),s.target=s.target.parent;t.overTargets=i.composedPath(),this.freeEvent(i),this.freeEvent(s)}mapPointerOut(e){if(!(e instanceof f)){y("EventBoundary cannot map a non-pointer event as a pointer event");return}const t=this.trackingData(e.pointerId);if(t.overTargets){const i=e.pointerType==="mouse"||e.pointerType==="pen",n=this.findMountedTarget(t.overTargets),s=this.createPointerEvent(e,"pointerout",n);this.dispatchEvent(s),i&&this.dispatchEvent(s,"mouseout");const o=this.createPointerEvent(e,"pointerleave",n);for(o.eventPhase=o.AT_TARGET;o.target&&o.target!==this.rootTarget.parent;)o.currentTarget=o.target,this.notifyTarget(o),i&&this.notifyTarget(o,"mouseleave"),o.target=o.target.parent;t.overTargets=null,this.freeEvent(s),this.freeEvent(o)}this.cursor=null}mapPointerUp(e){if(!(e instanceof f)){y("EventBoundary cannot map a non-pointer event as a pointer event");return}const t=performance.now(),i=this.createPointerEvent(e);if(this.dispatchEvent(i,"pointerup"),i.pointerType==="touch")this.dispatchEvent(i,"touchend");else if(i.pointerType==="mouse"||i.pointerType==="pen"){const a=i.button===2;this.dispatchEvent(i,a?"rightup":"mouseup")}const n=this.trackingData(e.pointerId),s=this.findMountedTarget(n.pressTargetsByButton[e.button]);let o=s;if(s&&!i.composedPath().includes(s)){let a=s;for(;a&&!i.composedPath().includes(a);){if(i.currentTarget=a,this.notifyTarget(i,"pointerupoutside"),i.pointerType==="touch")this.notifyTarget(i,"touchendoutside");else if(i.pointerType==="mouse"||i.pointerType==="pen"){const c=i.button===2;this.notifyTarget(i,c?"rightupoutside":"mouseupoutside")}a=a.parent}delete n.pressTargetsByButton[e.button],o=a}if(o){const a=this.clonePointerEvent(i,"click");a.target=o,a.path=null,n.clicksByButton[e.button]||(n.clicksByButton[e.button]={clickCount:0,target:a.target,timeStamp:t});const c=n.clicksByButton[e.button];if(c.target===a.target&&t-c.timeStamp<200?++c.clickCount:c.clickCount=1,c.target=a.target,c.timeStamp=t,a.detail=c.clickCount,a.pointerType==="mouse"){const p=a.button===2;this.dispatchEvent(a,p?"rightclick":"click")}else a.pointerType==="touch"&&this.dispatchEvent(a,"tap");this.dispatchEvent(a,"pointertap"),this.freeEvent(a)}this.freeEvent(i)}mapPointerUpOutside(e){if(!(e instanceof f)){y("EventBoundary cannot map a non-pointer event as a pointer event");return}const t=this.trackingData(e.pointerId),i=this.findMountedTarget(t.pressTargetsByButton[e.button]),n=this.createPointerEvent(e);if(i){let s=i;for(;s;)n.currentTarget=s,this.notifyTarget(n,"pointerupoutside"),n.pointerType==="touch"?this.notifyTarget(n,"touchendoutside"):(n.pointerType==="mouse"||n.pointerType==="pen")&&this.notifyTarget(n,n.button===2?"rightupoutside":"mouseupoutside"),s=s.parent;delete t.pressTargetsByButton[e.button]}this.freeEvent(n)}mapWheel(e){if(!(e instanceof T)){y("EventBoundary cannot map a non-wheel event as a wheel event");return}const t=this.createWheelEvent(e);this.dispatchEvent(t),this.freeEvent(t)}findMountedTarget(e){if(!e)return null;let t=e[0];for(let i=1;i(i==="globalMove"&&(this.rootBoundary.enableGlobalMoveEvents=n),t[i]=n,!0)}),this._onPointerDown=this._onPointerDown.bind(this),this._onPointerMove=this._onPointerMove.bind(this),this._onPointerUp=this._onPointerUp.bind(this),this._onPointerOverOut=this._onPointerOverOut.bind(this),this.onWheel=this.onWheel.bind(this)}static get defaultEventMode(){return this._defaultEventMode}init(e){const{canvas:t,resolution:i}=this.renderer;this.setTargetElement(t),this.resolution=i,x._defaultEventMode=e.eventMode??"passive",Object.assign(this.features,e.eventFeatures??{}),this.rootBoundary.enableGlobalMoveEvents=this.features.globalMove}resolutionChange(e){this.resolution=e}destroy(){this.setTargetElement(null),this.renderer=null,this._currentCursor=null}setCursor(e){e=e||"default";let t=!0;if(globalThis.OffscreenCanvas&&this.domElement instanceof OffscreenCanvas&&(t=!1),this._currentCursor===e)return;this._currentCursor=e;const i=this.cursorStyles[e];if(i)switch(typeof i){case"string":t&&(this.domElement.style.cursor=i);break;case"function":i(e);break;case"object":t&&Object.assign(this.domElement.style,i);break}else t&&typeof e=="string"&&!Object.prototype.hasOwnProperty.call(this.cursorStyles,e)&&(this.domElement.style.cursor=e)}get pointer(){return this._rootPointerEvent}_onPointerDown(e){if(!this.features.click)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered;const t=this._normalizeToPointerData(e);this.autoPreventDefault&&t[0].isNormalized&&(e.cancelable||!("cancelable"in e))&&e.preventDefault();for(let i=0,n=t.length;i0&&(t=e.composedPath()[0]);const i=t!==this.domElement?"outside":"",n=this._normalizeToPointerData(e);for(let s=0,o=n.length;s"u"&&(s.button=0),typeof s.buttons>"u"&&(s.buttons=1),typeof s.isPrimary>"u"&&(s.isPrimary=e.touches.length===1&&e.type==="touchstart"),typeof s.width>"u"&&(s.width=s.radiusX||1),typeof s.height>"u"&&(s.height=s.radiusY||1),typeof s.tiltX>"u"&&(s.tiltX=0),typeof s.tiltY>"u"&&(s.tiltY=0),typeof s.pointerType>"u"&&(s.pointerType="touch"),typeof s.pointerId>"u"&&(s.pointerId=s.identifier||0),typeof s.pressure>"u"&&(s.pressure=s.force||.5),typeof s.twist>"u"&&(s.twist=0),typeof s.tangentialPressure>"u"&&(s.tangentialPressure=0),typeof s.layerX>"u"&&(s.layerX=s.offsetX=s.clientX),typeof s.layerY>"u"&&(s.layerY=s.offsetY=s.clientY),s.isNormalized=!0,s.type=e.type,t.push(s)}else if(!globalThis.MouseEvent||e instanceof MouseEvent&&(!this.supportsPointerEvents||!(e instanceof globalThis.PointerEvent))){const i=e;typeof i.isPrimary>"u"&&(i.isPrimary=!0),typeof i.width>"u"&&(i.width=1),typeof i.height>"u"&&(i.height=1),typeof i.tiltX>"u"&&(i.tiltX=0),typeof i.tiltY>"u"&&(i.tiltY=0),typeof i.pointerType>"u"&&(i.pointerType="mouse"),typeof i.pointerId>"u"&&(i.pointerId=fe),typeof i.pressure>"u"&&(i.pressure=.5),typeof i.twist>"u"&&(i.twist=0),typeof i.tangentialPressure>"u"&&(i.tangentialPressure=0),i.isNormalized=!0,t.push(i)}else t.push(e);return t}normalizeWheelEvent(e){const t=this._rootWheelEvent;return this._transferMouseData(t,e),t.deltaX=e.deltaX,t.deltaY=e.deltaY,t.deltaZ=e.deltaZ,t.deltaMode=e.deltaMode,this.mapPositionToPoint(t.screen,e.clientX,e.clientY),t.global.copyFrom(t.screen),t.offset.copyFrom(t.screen),t.nativeEvent=e,t.type=e.type,t}_bootstrapEvent(e,t){return e.originalEvent=null,e.nativeEvent=t,e.pointerId=t.pointerId,e.width=t.width,e.height=t.height,e.isPrimary=t.isPrimary,e.pointerType=t.pointerType,e.pressure=t.pressure,e.tangentialPressure=t.tangentialPressure,e.tiltX=t.tiltX,e.tiltY=t.tiltY,e.twist=t.twist,this._transferMouseData(e,t),this.mapPositionToPoint(e.screen,t.clientX,t.clientY),e.global.copyFrom(e.screen),e.offset.copyFrom(e.screen),e.isTrusted=t.isTrusted,e.type==="pointerleave"&&(e.type="pointerout"),e.type.startsWith("mouse")&&(e.type=e.type.replace("mouse","pointer")),e.type.startsWith("touch")&&(e.type=ge[e.type]||e.type),e}_transferMouseData(e,t){e.isTrusted=t.isTrusted,e.srcElement=t.srcElement,e.timeStamp=performance.now(),e.type=t.type,e.altKey=t.altKey,e.button=t.button,e.buttons=t.buttons,e.client.x=t.clientX,e.client.y=t.clientY,e.ctrlKey=t.ctrlKey,e.metaKey=t.metaKey,e.movement.x=t.movementX,e.movement.y=t.movementY,e.page.x=t.pageX,e.page.y=t.pageY,e.relatedTarget=null,e.shiftKey=t.shiftKey}};B.extension={name:"events",type:[w.WebGLSystem,w.CanvasSystem,w.WebGPUSystem],priority:-1};B.defaultEventFeatures={move:!0,globalMove:!0,click:!0,wheel:!0};let q=B;const me={onclick:null,onmousedown:null,onmouseenter:null,onmouseleave:null,onmousemove:null,onglobalmousemove:null,onmouseout:null,onmouseover:null,onmouseup:null,onmouseupoutside:null,onpointercancel:null,onpointerdown:null,onpointerenter:null,onpointerleave:null,onpointermove:null,onglobalpointermove:null,onpointerout:null,onpointerover:null,onpointertap:null,onpointerup:null,onpointerupoutside:null,onrightclick:null,onrightdown:null,onrightup:null,onrightupoutside:null,ontap:null,ontouchcancel:null,ontouchend:null,ontouchendoutside:null,ontouchmove:null,onglobaltouchmove:null,ontouchstart:null,onwheel:null,get interactive(){return this.eventMode==="dynamic"||this.eventMode==="static"},set interactive(r){this.eventMode=r?"static":"passive"},_internalEventMode:void 0,get eventMode(){return this._internalEventMode??q.defaultEventMode},set eventMode(r){this._internalEventMode=r},isInteractive(){return this.eventMode==="static"||this.eventMode==="dynamic"},interactiveChildren:!0,hitArea:null,addEventListener(r,e,t){const i=typeof t=="boolean"&&t||typeof t=="object"&&t.capture,n=typeof t=="object"?t.signal:void 0,s=typeof t=="object"?t.once===!0:!1,o=typeof e=="function"?void 0:e;r=i?`${r}capture`:r;const a=typeof e=="function"?e:e.handleEvent,c=this;n&&n.addEventListener("abort",()=>{c.off(r,a,o)}),s?c.once(r,a,o):c.on(r,a,o)},removeEventListener(r,e,t){const i=typeof t=="boolean"&&t||typeof t=="object"&&t.capture,n=typeof e=="function"?void 0:e;r=i?`${r}capture`:r,e=typeof e=="function"?e:e.handleEvent,this.off(r,e,n)},dispatchEvent(r){if(!(r instanceof M))throw new Error("Container cannot propagate events outside of the Federated Events API");return r.defaultPrevented=!1,r.path=null,r.target=this,r.manager.dispatchEvent(r),!r.defaultPrevented}};z.add(V);Z.mixin(ue);z.add(q);Z.mixin(me); diff --git a/assets/colorToUniform-Bdgu2gC3.js b/assets/colorToUniform-Dzvfc6yy.js similarity index 98% rename from assets/colorToUniform-Bdgu2gC3.js rename to assets/colorToUniform-Dzvfc6yy.js index 5ffc3e0..8c02763 100644 --- a/assets/colorToUniform-Bdgu2gC3.js +++ b/assets/colorToUniform-Dzvfc6yy.js @@ -1,4 +1,4 @@ -import{T as _,a as M,n as g}from"./index-2UyWUVAY.js";const P={normal:0,add:1,multiply:2,screen:3,overlay:4,erase:5,"normal-npm":6,"add-npm":7,"screen-npm":8,min:9,max:10},u=0,h=1,c=2,d=3,f=4,p=5,x=class b{constructor(){this.data=0,this.blendMode="normal",this.polygonOffset=0,this.blend=!0,this.depthMask=!0}get blend(){return!!(this.data&1<, diff --git a/assets/creeps/basic/0.png b/assets/creeps/basic/0.png deleted file mode 100644 index 05b90b7..0000000 Binary files a/assets/creeps/basic/0.png and /dev/null differ diff --git a/assets/creeps/basic/1.png b/assets/creeps/basic/1.png deleted file mode 100644 index d978a9a..0000000 Binary files a/assets/creeps/basic/1.png and /dev/null differ diff --git a/assets/creeps/basic/10.png b/assets/creeps/basic/10.png deleted file mode 100644 index 48b4f7d..0000000 Binary files a/assets/creeps/basic/10.png and /dev/null differ diff --git a/assets/creeps/basic/11.png b/assets/creeps/basic/11.png deleted file mode 100644 index d978a9a..0000000 Binary files a/assets/creeps/basic/11.png and /dev/null differ diff --git a/assets/creeps/basic/2.png b/assets/creeps/basic/2.png deleted file mode 100644 index 48b4f7d..0000000 Binary files a/assets/creeps/basic/2.png and /dev/null differ diff --git a/assets/creeps/basic/3.png b/assets/creeps/basic/3.png deleted file mode 100644 index 06a46df..0000000 Binary files a/assets/creeps/basic/3.png and /dev/null differ diff --git a/assets/creeps/basic/4.png b/assets/creeps/basic/4.png deleted file mode 100644 index 139737c..0000000 Binary files a/assets/creeps/basic/4.png and /dev/null differ diff --git a/assets/creeps/basic/5.png b/assets/creeps/basic/5.png deleted file mode 100644 index fac6dd7..0000000 Binary files a/assets/creeps/basic/5.png and /dev/null differ diff --git a/assets/creeps/basic/6.png b/assets/creeps/basic/6.png deleted file mode 100644 index db9bc87..0000000 Binary files a/assets/creeps/basic/6.png and /dev/null differ diff --git a/assets/creeps/basic/7.png b/assets/creeps/basic/7.png deleted file mode 100644 index fac6dd7..0000000 Binary files a/assets/creeps/basic/7.png and /dev/null differ diff --git a/assets/creeps/basic/8.png b/assets/creeps/basic/8.png deleted file mode 100644 index 139737c..0000000 Binary files a/assets/creeps/basic/8.png and /dev/null differ diff --git a/assets/creeps/basic/9.png b/assets/creeps/basic/9.png deleted file mode 100644 index 06a46df..0000000 Binary files a/assets/creeps/basic/9.png and /dev/null differ diff --git a/assets/creeps/cloaker/0.png b/assets/creeps/cloaker/0.png deleted file mode 100644 index bcbc3af..0000000 Binary files a/assets/creeps/cloaker/0.png and /dev/null differ diff --git a/assets/creeps/cloaker/1.png b/assets/creeps/cloaker/1.png deleted file mode 100644 index 200bc9e..0000000 Binary files a/assets/creeps/cloaker/1.png and /dev/null differ diff --git a/assets/creeps/cloaker/10.png b/assets/creeps/cloaker/10.png deleted file mode 100644 index 3df93f8..0000000 Binary files a/assets/creeps/cloaker/10.png and /dev/null differ diff --git a/assets/creeps/cloaker/11.png b/assets/creeps/cloaker/11.png deleted file mode 100644 index 2512c1c..0000000 Binary files a/assets/creeps/cloaker/11.png and /dev/null differ diff --git a/assets/creeps/cloaker/2.png b/assets/creeps/cloaker/2.png deleted file mode 100644 index 5e0d41c..0000000 Binary files a/assets/creeps/cloaker/2.png and /dev/null differ diff --git a/assets/creeps/cloaker/3.png b/assets/creeps/cloaker/3.png deleted file mode 100644 index 779efea..0000000 Binary files a/assets/creeps/cloaker/3.png and /dev/null differ diff --git a/assets/creeps/cloaker/4.png b/assets/creeps/cloaker/4.png deleted file mode 100644 index 95924e0..0000000 Binary files a/assets/creeps/cloaker/4.png and /dev/null differ diff --git a/assets/creeps/cloaker/5.png b/assets/creeps/cloaker/5.png deleted file mode 100644 index 56ce34e..0000000 Binary files a/assets/creeps/cloaker/5.png and /dev/null differ diff --git a/assets/creeps/cloaker/6.png b/assets/creeps/cloaker/6.png deleted file mode 100644 index da52a20..0000000 Binary files a/assets/creeps/cloaker/6.png and /dev/null differ diff --git a/assets/creeps/cloaker/7.png b/assets/creeps/cloaker/7.png deleted file mode 100644 index 4baad15..0000000 Binary files a/assets/creeps/cloaker/7.png and /dev/null differ diff --git a/assets/creeps/cloaker/8.png b/assets/creeps/cloaker/8.png deleted file mode 100644 index 5030dca..0000000 Binary files a/assets/creeps/cloaker/8.png and /dev/null differ diff --git a/assets/creeps/cloaker/9.png b/assets/creeps/cloaker/9.png deleted file mode 100644 index 4ac8690..0000000 Binary files a/assets/creeps/cloaker/9.png and /dev/null differ diff --git a/assets/creeps/demon/0.png b/assets/creeps/demon/0.png deleted file mode 100644 index 4981186..0000000 Binary files a/assets/creeps/demon/0.png and /dev/null differ diff --git a/assets/creeps/demon/1.png b/assets/creeps/demon/1.png deleted file mode 100644 index c082f4d..0000000 Binary files a/assets/creeps/demon/1.png and /dev/null differ diff --git a/assets/creeps/demon/2.png b/assets/creeps/demon/2.png deleted file mode 100644 index 284d170..0000000 Binary files a/assets/creeps/demon/2.png and /dev/null differ diff --git a/assets/creeps/demon/3.png b/assets/creeps/demon/3.png deleted file mode 100644 index 22e9cc8..0000000 Binary files a/assets/creeps/demon/3.png and /dev/null differ diff --git a/assets/creeps/demon/4.png b/assets/creeps/demon/4.png deleted file mode 100644 index 14e592a..0000000 Binary files a/assets/creeps/demon/4.png and /dev/null differ diff --git a/assets/creeps/demon/5.png b/assets/creeps/demon/5.png deleted file mode 100644 index 0590e06..0000000 Binary files a/assets/creeps/demon/5.png and /dev/null differ diff --git a/assets/creeps/demon/6.png b/assets/creeps/demon/6.png deleted file mode 100644 index d59ee3e..0000000 Binary files a/assets/creeps/demon/6.png and /dev/null differ diff --git a/assets/creeps/demon/7.png b/assets/creeps/demon/7.png deleted file mode 100644 index f40d8ab..0000000 Binary files a/assets/creeps/demon/7.png and /dev/null differ diff --git a/assets/creeps/demon_spritesheet.png b/assets/creeps/demon_spritesheet.png new file mode 100644 index 0000000..7e85eeb Binary files /dev/null and b/assets/creeps/demon_spritesheet.png differ diff --git a/assets/creeps/hood_spritesheet.png b/assets/creeps/hood_spritesheet.png new file mode 100644 index 0000000..0ed174f Binary files /dev/null and b/assets/creeps/hood_spritesheet.png differ diff --git a/assets/creeps/maker/0.png b/assets/creeps/maker/0.png deleted file mode 100644 index 042a582..0000000 Binary files a/assets/creeps/maker/0.png and /dev/null differ diff --git a/assets/creeps/maker/1.png b/assets/creeps/maker/1.png deleted file mode 100644 index 042a582..0000000 Binary files a/assets/creeps/maker/1.png and /dev/null differ diff --git a/assets/creeps/maker/10.png b/assets/creeps/maker/10.png deleted file mode 100644 index 55fa573..0000000 Binary files a/assets/creeps/maker/10.png and /dev/null differ diff --git a/assets/creeps/maker/2.png b/assets/creeps/maker/2.png deleted file mode 100644 index 55fa573..0000000 Binary files a/assets/creeps/maker/2.png and /dev/null differ diff --git a/assets/creeps/maker/3.png b/assets/creeps/maker/3.png deleted file mode 100644 index 59275bc..0000000 Binary files a/assets/creeps/maker/3.png and /dev/null differ diff --git a/assets/creeps/maker/4.png b/assets/creeps/maker/4.png deleted file mode 100644 index e120c5c..0000000 Binary files a/assets/creeps/maker/4.png and /dev/null differ diff --git a/assets/creeps/maker/5.png b/assets/creeps/maker/5.png deleted file mode 100644 index 510cbc1..0000000 Binary files a/assets/creeps/maker/5.png and /dev/null differ diff --git a/assets/creeps/maker/6.png b/assets/creeps/maker/6.png deleted file mode 100644 index 3ded504..0000000 Binary files a/assets/creeps/maker/6.png and /dev/null differ diff --git a/assets/creeps/maker/7.png b/assets/creeps/maker/7.png deleted file mode 100644 index 510cbc1..0000000 Binary files a/assets/creeps/maker/7.png and /dev/null differ diff --git a/assets/creeps/maker/8.png b/assets/creeps/maker/8.png deleted file mode 100644 index e120c5c..0000000 Binary files a/assets/creeps/maker/8.png and /dev/null differ diff --git a/assets/creeps/maker/9.png b/assets/creeps/maker/9.png deleted file mode 100644 index 59275bc..0000000 Binary files a/assets/creeps/maker/9.png and /dev/null differ diff --git a/assets/creeps/optimize.cjs b/assets/creeps/optimize.cjs index 110dbf5..cea9e1c 100644 --- a/assets/creeps/optimize.cjs +++ b/assets/creeps/optimize.cjs @@ -1,18 +1,20 @@ + const fs = require('fs'); const { exec, execSync } = require('child_process'); let dir = fs.readdirSync('.'); -dir.forEach((item) => { - const itemPath = `./${item}`; - if (fs.lstatSync(itemPath).isDirectory()) { - let subDir = fs.readdirSync(itemPath); - subDir.forEach(async (subItem) => { - const subItemPath = `${itemPath}/${subItem}`; - if (fs.lstatSync(subItemPath).isFile() && subItem.endsWith('.png')) { - const outputFilePath = `${itemPath}/${subItem.replace('.png', 's.png')}`; - await execSync(`convert -resize 128x128 -quality 80 ${subItemPath} ${outputFilePath}`); - fs.unlinkSync(subItemPath); - fs.renameSync(outputFilePath, subItemPath); - } - }); - } -}); +// dir.forEach((item) => { +// const itemPath = `./${item}`; +// if (fs.lstatSync(itemPath).isDirectory()) { +// let subDir = fs.readdirSync(itemPath); +// subDir.forEach(async (subItem) => { +// const subItemPath = `${itemPath}/${subItem}`; +// if (fs.lstatSync(subItemPath).isFile() && subItem.endsWith('.png')) { +// const outputFilePath = `${itemPath}/${subItem.replace('.png', 's.png')}`; +// await execSync(`convert -resize 128x128 -quality 80 ${subItemPath} ${outputFilePath}`); +// fs.unlinkSync(subItemPath); +// fs.renameSync(outputFilePath, subItemPath); +// } +// }); +// } +// }); +// Disabled for now, dont need to optimize assets. diff --git a/assets/creeps/pumpkin_spritesheet.png b/assets/creeps/pumpkin_spritesheet.png new file mode 100644 index 0000000..1e0a57f Binary files /dev/null and b/assets/creeps/pumpkin_spritesheet.png differ diff --git a/assets/creeps/quick/0.png b/assets/creeps/quick/0.png deleted file mode 100644 index 516c3c1..0000000 Binary files a/assets/creeps/quick/0.png and /dev/null differ diff --git a/assets/creeps/quick/1.png b/assets/creeps/quick/1.png deleted file mode 100644 index 409cd58..0000000 Binary files a/assets/creeps/quick/1.png and /dev/null differ diff --git a/assets/creeps/quick/2.png b/assets/creeps/quick/2.png deleted file mode 100644 index 90d2e95..0000000 Binary files a/assets/creeps/quick/2.png and /dev/null differ diff --git a/assets/creeps/quick/3.png b/assets/creeps/quick/3.png deleted file mode 100644 index 83250d4..0000000 Binary files a/assets/creeps/quick/3.png and /dev/null differ diff --git a/assets/creeps/quick/4.png b/assets/creeps/quick/4.png deleted file mode 100644 index f3f6d65..0000000 Binary files a/assets/creeps/quick/4.png and /dev/null differ diff --git a/assets/creeps/quick/5.png b/assets/creeps/quick/5.png deleted file mode 100644 index 046d3a4..0000000 Binary files a/assets/creeps/quick/5.png and /dev/null differ diff --git a/assets/creeps/quick/6.png b/assets/creeps/quick/6.png deleted file mode 100644 index 8038456..0000000 Binary files a/assets/creeps/quick/6.png and /dev/null differ diff --git a/assets/creeps/quick/7.png b/assets/creeps/quick/7.png deleted file mode 100644 index 65f4bbe..0000000 Binary files a/assets/creeps/quick/7.png and /dev/null differ diff --git a/assets/creeps/skeleton_spritesheet.png b/assets/creeps/skeleton_spritesheet.png new file mode 100644 index 0000000..f011c85 Binary files /dev/null and b/assets/creeps/skeleton_spritesheet.png differ diff --git a/assets/creeps/tank/0.png b/assets/creeps/tank/0.png deleted file mode 100644 index f409430..0000000 Binary files a/assets/creeps/tank/0.png and /dev/null differ diff --git a/assets/creeps/tank/1.png b/assets/creeps/tank/1.png deleted file mode 100644 index 469e13d..0000000 Binary files a/assets/creeps/tank/1.png and /dev/null differ diff --git a/assets/creeps/tank/10.png b/assets/creeps/tank/10.png deleted file mode 100644 index c67f03f..0000000 Binary files a/assets/creeps/tank/10.png and /dev/null differ diff --git a/assets/creeps/tank/11.png b/assets/creeps/tank/11.png deleted file mode 100644 index 469e13d..0000000 Binary files a/assets/creeps/tank/11.png and /dev/null differ diff --git a/assets/creeps/tank/2.png b/assets/creeps/tank/2.png deleted file mode 100644 index c67f03f..0000000 Binary files a/assets/creeps/tank/2.png and /dev/null differ diff --git a/assets/creeps/tank/3.png b/assets/creeps/tank/3.png deleted file mode 100644 index ea50556..0000000 Binary files a/assets/creeps/tank/3.png and /dev/null differ diff --git a/assets/creeps/tank/4.png b/assets/creeps/tank/4.png deleted file mode 100644 index ee42532..0000000 Binary files a/assets/creeps/tank/4.png and /dev/null differ diff --git a/assets/creeps/tank/5.png b/assets/creeps/tank/5.png deleted file mode 100644 index 88404b0..0000000 Binary files a/assets/creeps/tank/5.png and /dev/null differ diff --git a/assets/creeps/tank/6.png b/assets/creeps/tank/6.png deleted file mode 100644 index 1e04a28..0000000 Binary files a/assets/creeps/tank/6.png and /dev/null differ diff --git a/assets/creeps/tank/7.png b/assets/creeps/tank/7.png deleted file mode 100644 index 88404b0..0000000 Binary files a/assets/creeps/tank/7.png and /dev/null differ diff --git a/assets/creeps/tank/8.png b/assets/creeps/tank/8.png deleted file mode 100644 index ee42532..0000000 Binary files a/assets/creeps/tank/8.png and /dev/null differ diff --git a/assets/creeps/tank/9.png b/assets/creeps/tank/9.png deleted file mode 100644 index 6531367..0000000 Binary files a/assets/creeps/tank/9.png and /dev/null differ diff --git a/assets/creeps/wood_spritesheet.png b/assets/creeps/wood_spritesheet.png new file mode 100644 index 0000000..d9e183a Binary files /dev/null and b/assets/creeps/wood_spritesheet.png differ diff --git a/assets/creeps/zombie_spritesheet.png b/assets/creeps/zombie_spritesheet.png new file mode 100644 index 0000000..35e6d09 Binary files /dev/null and b/assets/creeps/zombie_spritesheet.png differ diff --git a/assets/gems/Artifact_spritesheet.png b/assets/gems/Artifact_spritesheet.png new file mode 100644 index 0000000..bb0066e Binary files /dev/null and b/assets/gems/Artifact_spritesheet.png differ diff --git a/assets/gems/Fire/1.png b/assets/gems/Fire/1.png deleted file mode 100644 index 64c4c3e..0000000 Binary files a/assets/gems/Fire/1.png and /dev/null differ diff --git a/assets/gems/Fire/2.png b/assets/gems/Fire/2.png deleted file mode 100644 index a5d4666..0000000 Binary files a/assets/gems/Fire/2.png and /dev/null differ diff --git a/assets/gems/Fire/3.png b/assets/gems/Fire/3.png deleted file mode 100644 index 4736ff3..0000000 Binary files a/assets/gems/Fire/3.png and /dev/null differ diff --git a/assets/gems/Fire/4.png b/assets/gems/Fire/4.png deleted file mode 100644 index 25a9f06..0000000 Binary files a/assets/gems/Fire/4.png and /dev/null differ diff --git a/assets/gems/Fire/5.png b/assets/gems/Fire/5.png deleted file mode 100644 index f40d840..0000000 Binary files a/assets/gems/Fire/5.png and /dev/null differ diff --git a/assets/gems/Fire/6.png b/assets/gems/Fire/6.png deleted file mode 100644 index ad0e01b..0000000 Binary files a/assets/gems/Fire/6.png and /dev/null differ diff --git a/assets/gems/Fire/7.png b/assets/gems/Fire/7.png deleted file mode 100644 index 3879e55..0000000 Binary files a/assets/gems/Fire/7.png and /dev/null differ diff --git a/assets/gems/Fire/8.png b/assets/gems/Fire/8.png deleted file mode 100644 index 5c2f95c..0000000 Binary files a/assets/gems/Fire/8.png and /dev/null differ diff --git a/assets/gems/Fire/9.png b/assets/gems/Fire/9.png deleted file mode 100644 index e8f5448..0000000 Binary files a/assets/gems/Fire/9.png and /dev/null differ diff --git a/assets/gems/Fire_spritesheet.png b/assets/gems/Fire_spritesheet.png new file mode 100644 index 0000000..55783eb Binary files /dev/null and b/assets/gems/Fire_spritesheet.png differ diff --git a/assets/gems/Gold_spritesheet.png b/assets/gems/Gold_spritesheet.png new file mode 100644 index 0000000..670b9af Binary files /dev/null and b/assets/gems/Gold_spritesheet.png differ diff --git a/assets/gems/Soulforge/1.png b/assets/gems/Soulforge/1.png deleted file mode 100644 index add5555..0000000 Binary files a/assets/gems/Soulforge/1.png and /dev/null differ diff --git a/assets/gems/Soulforge/2.png b/assets/gems/Soulforge/2.png deleted file mode 100644 index 8da6be4..0000000 Binary files a/assets/gems/Soulforge/2.png and /dev/null differ diff --git a/assets/gems/Soulforge_spritesheet.png b/assets/gems/Soulforge_spritesheet.png new file mode 100644 index 0000000..d4eea29 Binary files /dev/null and b/assets/gems/Soulforge_spritesheet.png differ diff --git a/assets/gems/Titalium/1.png b/assets/gems/Titalium/1.png deleted file mode 100644 index d9a9b42..0000000 Binary files a/assets/gems/Titalium/1.png and /dev/null differ diff --git a/assets/gems/Titalium/2.png b/assets/gems/Titalium/2.png deleted file mode 100644 index e8df315..0000000 Binary files a/assets/gems/Titalium/2.png and /dev/null differ diff --git a/assets/gems/Titalium/3.png b/assets/gems/Titalium/3.png deleted file mode 100644 index c014b53..0000000 Binary files a/assets/gems/Titalium/3.png and /dev/null differ diff --git a/assets/gems/Titalium_spritesheet.png b/assets/gems/Titalium_spritesheet.png new file mode 100644 index 0000000..a09059d Binary files /dev/null and b/assets/gems/Titalium_spritesheet.png differ diff --git a/assets/gems/Yeti/1.png b/assets/gems/Yeti/1.png deleted file mode 100644 index 4dbf7c1..0000000 Binary files a/assets/gems/Yeti/1.png and /dev/null differ diff --git a/assets/gems/Yeti/2.png b/assets/gems/Yeti/2.png deleted file mode 100644 index e6b3b07..0000000 Binary files a/assets/gems/Yeti/2.png and /dev/null differ diff --git a/assets/gems/Yeti_spritesheet.png b/assets/gems/Yeti_spritesheet.png new file mode 100644 index 0000000..78c834d Binary files /dev/null and b/assets/gems/Yeti_spritesheet.png differ diff --git a/assets/gui/background_01.png b/assets/gui/background_01.png deleted file mode 100755 index 3fa5d9b..0000000 Binary files a/assets/gui/background_01.png and /dev/null differ diff --git a/assets/gui/banner_03.png b/assets/gui/banner_03.png deleted file mode 100755 index 63258b3..0000000 Binary files a/assets/gui/banner_03.png and /dev/null differ diff --git a/assets/gui/frame_c2_02.png b/assets/gui/frame_c2_02.png deleted file mode 100755 index 1adb74d..0000000 Binary files a/assets/gui/frame_c2_02.png and /dev/null differ diff --git a/assets/gui/gem_frame.png b/assets/gui/gem_frame.png deleted file mode 100755 index d3d7f42..0000000 Binary files a/assets/gui/gem_frame.png and /dev/null differ diff --git a/assets/gui/inventory.png b/assets/gui/inventory.png deleted file mode 100755 index ab93a6a..0000000 Binary files a/assets/gui/inventory.png and /dev/null differ diff --git a/assets/gui/plank_14.png b/assets/gui/plank_14.png deleted file mode 100755 index 3a1152d..0000000 Binary files a/assets/gui/plank_14.png and /dev/null differ diff --git a/assets/gui/shield_01.png b/assets/gui/shield_01.png deleted file mode 100755 index 57969ac..0000000 Binary files a/assets/gui/shield_01.png and /dev/null differ diff --git a/assets/gui/shield_02.png b/assets/gui/shield_02.png deleted file mode 100755 index 618adb8..0000000 Binary files a/assets/gui/shield_02.png and /dev/null differ diff --git a/assets/gui/skull_01.png b/assets/gui/skull_01.png deleted file mode 100755 index aeb97cd..0000000 Binary files a/assets/gui/skull_01.png and /dev/null differ diff --git a/assets/gui/star.png b/assets/gui/star.png deleted file mode 100755 index 20ce16c..0000000 Binary files a/assets/gui/star.png and /dev/null differ diff --git a/assets/gui/star_empty.png b/assets/gui/star_empty.png deleted file mode 100755 index 2682b22..0000000 Binary files a/assets/gui/star_empty.png and /dev/null differ diff --git a/assets/gui/title.png b/assets/gui/title.png deleted file mode 100755 index a34a831..0000000 Binary files a/assets/gui/title.png and /dev/null differ diff --git a/assets/index-2UyWUVAY.js b/assets/index-WJSjzvvL.js similarity index 68% rename from assets/index-2UyWUVAY.js rename to assets/index-WJSjzvvL.js index 76cb1f1..802333f 100644 --- a/assets/index-2UyWUVAY.js +++ b/assets/index-WJSjzvvL.js @@ -1,10 +1,10 @@ -const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/browserAll-8U9aaa5a.js","assets/webworkerAll-Yj3NqXCQ.js","assets/colorToUniform-Bdgu2gC3.js","assets/WebGPURenderer-CUsLfpfB.js","assets/SharedSystems-DeezA36t.js","assets/WebGLRenderer-DaH2izjB.js"])))=>i.map(i=>d[i]); -var Ua=Object.defineProperty;var Oa=(i,t,e)=>t in i?Ua(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e;var p=(i,t,e)=>Oa(i,typeof t!="symbol"?t+"":t,e);(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const n of document.querySelectorAll('link[rel="modulepreload"]'))s(n);new MutationObserver(n=>{for(const r of n)if(r.type==="childList")for(const a of r.addedNodes)a.tagName==="LINK"&&a.rel==="modulepreload"&&s(a)}).observe(document,{childList:!0,subtree:!0});function e(n){const r={};return n.integrity&&(r.integrity=n.integrity),n.referrerPolicy&&(r.referrerPolicy=n.referrerPolicy),n.crossOrigin==="use-credentials"?r.credentials="include":n.crossOrigin==="anonymous"?r.credentials="omit":r.credentials="same-origin",r}function s(n){if(n.ep)return;n.ep=!0;const r=e(n);fetch(n.href,r)}})();const Na="modulepreload",Wa=function(i){return"/"+i},tn={},mi=function(t,e,s){let n=Promise.resolve();if(e&&e.length>0){document.getElementsByTagName("link");const a=document.querySelector("meta[property=csp-nonce]"),o=(a==null?void 0:a.nonce)||(a==null?void 0:a.getAttribute("nonce"));n=Promise.allSettled(e.map(h=>{if(h=Wa(h),h in tn)return;tn[h]=!0;const l=h.endsWith(".css"),c=l?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${h}"]${c}`))return;const d=document.createElement("link");if(d.rel=l?"stylesheet":Na,l||(d.as="script"),d.crossOrigin="",d.href=h,o&&d.setAttribute("nonce",o),document.head.appendChild(d),l)return new Promise((f,g)=>{d.addEventListener("load",f),d.addEventListener("error",()=>g(new Error(`Unable to preload CSS for ${h}`)))})}))}function r(a){const o=new Event("vite:preloadError",{cancelable:!0});if(o.payload=a,window.dispatchEvent(o),!o.defaultPrevented)throw a}return n.then(a=>{for(const o of a||[])o.status==="rejected"&&r(o.reason);return t().catch(r)})};var G=(i=>(i.Application="application",i.WebGLPipes="webgl-pipes",i.WebGLPipesAdaptor="webgl-pipes-adaptor",i.WebGLSystem="webgl-system",i.WebGPUPipes="webgpu-pipes",i.WebGPUPipesAdaptor="webgpu-pipes-adaptor",i.WebGPUSystem="webgpu-system",i.CanvasSystem="canvas-system",i.CanvasPipesAdaptor="canvas-pipes-adaptor",i.CanvasPipes="canvas-pipes",i.Asset="asset",i.LoadParser="load-parser",i.ResolveParser="resolve-parser",i.CacheParser="cache-parser",i.DetectionParser="detection-parser",i.MaskEffect="mask-effect",i.BlendMode="blend-mode",i.TextureSource="texture-source",i.Environment="environment",i.ShapeBuilder="shape-builder",i.Batcher="batcher",i))(G||{});const rs=i=>{if(typeof i=="function"||typeof i=="object"&&i.extension){if(!i.extension)throw new Error("Extension class must have an extension object");i={...typeof i.extension!="object"?{type:i.extension}:i.extension,ref:i}}if(typeof i=="object")i={...i};else throw new Error("Invalid extension type");return typeof i.type=="string"&&(i.type=[i.type]),i},ei=(i,t)=>rs(i).priority??t,dt={_addHandlers:{},_removeHandlers:{},_queue:{},remove(...i){return i.map(rs).forEach(t=>{t.type.forEach(e=>{var s,n;return(n=(s=this._removeHandlers)[e])==null?void 0:n.call(s,t)})}),this},add(...i){return i.map(rs).forEach(t=>{t.type.forEach(e=>{var r,a;const s=this._addHandlers,n=this._queue;s[e]?(a=s[e])==null||a.call(s,t):(n[e]=n[e]||[],(r=n[e])==null||r.push(t))})}),this},handle(i,t,e){var a;const s=this._addHandlers,n=this._removeHandlers;if(s[i]||n[i])throw new Error(`Extension type ${i} already has a handler`);s[i]=t,n[i]=e;const r=this._queue;return r[i]&&((a=r[i])==null||a.forEach(o=>t(o)),delete r[i]),this},handleByMap(i,t){return this.handle(i,e=>{e.name&&(t[e.name]=e.ref)},e=>{e.name&&delete t[e.name]})},handleByNamedList(i,t,e=-1){return this.handle(i,s=>{t.findIndex(r=>r.name===s.name)>=0||(t.push({name:s.name,value:s.ref}),t.sort((r,a)=>ei(a.value,e)-ei(r.value,e)))},s=>{const n=t.findIndex(r=>r.name===s.name);n!==-1&&t.splice(n,1)})},handleByList(i,t,e=-1){return this.handle(i,s=>{t.includes(s.ref)||(t.push(s.ref),t.sort((n,r)=>ei(r,e)-ei(n,e)))},s=>{const n=t.indexOf(s.ref);n!==-1&&t.splice(n,1)})}},Ha={extension:{type:G.Environment,name:"browser",priority:-1},test:()=>!0,load:async()=>{await mi(()=>import("./browserAll-8U9aaa5a.js"),__vite__mapDeps([0,1,2]))}},$a={extension:{type:G.Environment,name:"webworker",priority:0},test:()=>typeof self<"u"&&self.WorkerGlobalScope!==void 0,load:async()=>{await mi(()=>import("./webworkerAll-Yj3NqXCQ.js"),__vite__mapDeps([1,2]))}};class pt{constructor(t,e,s){this._x=e||0,this._y=s||0,this._observer=t}clone(t){return new pt(t??this._observer,this._x,this._y)}set(t=0,e=t){return(this._x!==t||this._y!==e)&&(this._x=t,this._y=e,this._observer._onUpdate(this)),this}copyFrom(t){return(this._x!==t.x||this._y!==t.y)&&(this._x=t.x,this._y=t.y,this._observer._onUpdate(this)),this}copyTo(t){return t.set(this._x,this._y),t}equals(t){return t.x===this._x&&t.y===this._y}toString(){return`[pixi.js/math:ObservablePoint x=0 y=0 scope=${this._observer}]`}get x(){return this._x}set x(t){this._x!==t&&(this._x=t,this._observer._onUpdate(this))}get y(){return this._y}set y(t){this._y!==t&&(this._y=t,this._observer._onUpdate(this))}}function Ps(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}var nr={exports:{}};(function(i){var t=Object.prototype.hasOwnProperty,e="~";function s(){}Object.create&&(s.prototype=Object.create(null),new s().__proto__||(e=!1));function n(h,l,c){this.fn=h,this.context=l,this.once=c||!1}function r(h,l,c,d,f){if(typeof c!="function")throw new TypeError("The listener must be a function");var g=new n(c,d||h,f),m=e?e+l:l;return h._events[m]?h._events[m].fn?h._events[m]=[h._events[m],g]:h._events[m].push(g):(h._events[m]=g,h._eventsCount++),h}function a(h,l){--h._eventsCount===0?h._events=new s:delete h._events[l]}function o(){this._events=new s,this._eventsCount=0}o.prototype.eventNames=function(){var l=[],c,d;if(this._eventsCount===0)return l;for(d in c=this._events)t.call(c,d)&&l.push(e?d.slice(1):d);return Object.getOwnPropertySymbols?l.concat(Object.getOwnPropertySymbols(c)):l},o.prototype.listeners=function(l){var c=e?e+l:l,d=this._events[c];if(!d)return[];if(d.fn)return[d.fn];for(var f=0,g=d.length,m=new Array(g);fJt[i],uY:i=>te[i],vX:i=>ee[i],vY:i=>ie[i],inv:i=>i&8?i&15:-i&7,add:(i,t)=>as[i][t],sub:(i,t)=>as[i][j.inv(t)],rotate180:i=>i^4,isVertical:i=>(i&3)===2,byDirection:(i,t)=>Math.abs(i)*2<=Math.abs(t)?t>=0?j.S:j.N:Math.abs(t)*2<=Math.abs(i)?i>0?j.E:j.W:t>0?i>0?j.SE:j.SW:i>0?j.NE:j.NW,matrixAppendRotationInv:(i,t,e=0,s=0)=>{const n=rr[j.inv(t)];n.tx=e,n.ty=s,i.append(n)}},si=[new lt,new lt,new lt,new lt];class E{constructor(t=0,e=0,s=0,n=0){this.type="rectangle",this.x=Number(t),this.y=Number(e),this.width=Number(s),this.height=Number(n)}get left(){return this.x}get right(){return this.x+this.width}get top(){return this.y}get bottom(){return this.y+this.height}isEmpty(){return this.left===this.right||this.top===this.bottom}static get EMPTY(){return new E(0,0,0,0)}clone(){return new E(this.x,this.y,this.width,this.height)}copyFromBounds(t){return this.x=t.minX,this.y=t.minY,this.width=t.maxX-t.minX,this.height=t.maxY-t.minY,this}copyFrom(t){return this.x=t.x,this.y=t.y,this.width=t.width,this.height=t.height,this}copyTo(t){return t.copyFrom(this),t}contains(t,e){return this.width<=0||this.height<=0?!1:t>=this.x&&t=this.y&&e=h&&t<=l&&e>=c&&e<=d&&!(t>f&&tm&&et.right?t.right:this.right)<=k)return!1;const T=this.yt.bottom?t.bottom:this.bottom)>T}const s=this.left,n=this.right,r=this.top,a=this.bottom;if(n<=s||a<=r)return!1;const o=si[0].set(t.left,t.top),h=si[1].set(t.left,t.bottom),l=si[2].set(t.right,t.top),c=si[3].set(t.right,t.bottom);if(l.x<=o.x||h.y<=o.y)return!1;const d=Math.sign(e.a*e.d-e.b*e.c);if(d===0||(e.apply(o,o),e.apply(h,h),e.apply(l,l),e.apply(c,c),Math.max(o.x,h.x,l.x,c.x)<=s||Math.min(o.x,h.x,l.x,c.x)>=n||Math.max(o.y,h.y,l.y,c.y)<=r||Math.min(o.y,h.y,l.y,c.y)>=a))return!1;const f=d*(h.y-o.y),g=d*(o.x-h.x),m=f*s+g*r,y=f*n+g*r,x=f*s+g*a,w=f*n+g*a;if(Math.max(m,y,x,w)<=f*o.x+g*o.y||Math.min(m,y,x,w)>=f*c.x+g*c.y)return!1;const _=d*(o.y-l.y),b=d*(l.x-o.x),S=_*s+b*r,A=_*n+b*r,F=_*s+b*a,P=_*n+b*a;return!(Math.max(S,A,F,P)<=_*o.x+b*o.y||Math.min(S,A,F,P)>=_*c.x+b*c.y)}pad(t=0,e=t){return this.x-=t,this.y-=e,this.width+=t*2,this.height+=e*2,this}fit(t){const e=Math.max(this.x,t.x),s=Math.min(this.x+this.width,t.x+t.width),n=Math.max(this.y,t.y),r=Math.min(this.y+this.height,t.y+t.height);return this.x=e,this.width=Math.max(s-e,0),this.y=n,this.height=Math.max(r-n,0),this}ceil(t=1,e=.001){const s=Math.ceil((this.x+this.width-e)*t)/t,n=Math.ceil((this.y+this.height-e)*t)/t;return this.x=Math.floor((this.x+e)*t)/t,this.y=Math.floor((this.y+e)*t)/t,this.width=s-this.x,this.height=n-this.y,this}enlarge(t){const e=Math.min(this.x,t.x),s=Math.max(this.x+this.width,t.x+t.width),n=Math.min(this.y,t.y),r=Math.max(this.y+this.height,t.y+t.height);return this.x=e,this.width=s-e,this.y=n,this.height=r-n,this}getBounds(t){return t=t||new E,t.copyFrom(this),t}toString(){return`[pixi.js/math:Rectangle x=${this.x} y=${this.y} width=${this.width} height=${this.height}]`}}const Ei={default:-1};function nt(i="default"){return Ei[i]===void 0&&(Ei[i]=-1),++Ei[i]}const en={},N="8.0.0",Qa="8.3.4";function U(i,t,e=3){if(en[t])return;let s=new Error().stack;typeof s>"u"?console.warn("PixiJS Deprecation Warning: ",`${t} +const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/browserAll-Bnl4Z-wu.js","assets/webworkerAll-Cp5jyL-l.js","assets/colorToUniform-Dzvfc6yy.js","assets/WebGPURenderer-CNuCBG1t.js","assets/SharedSystems-Cfxyk_gB.js","assets/WebGLRenderer-O3oCvy8A.js"])))=>i.map(i=>d[i]); +var Ua=Object.defineProperty;var Na=(i,t,e)=>t in i?Ua(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e;var p=(i,t,e)=>Na(i,typeof t!="symbol"?t+"":t,e);(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const n of document.querySelectorAll('link[rel="modulepreload"]'))s(n);new MutationObserver(n=>{for(const r of n)if(r.type==="childList")for(const a of r.addedNodes)a.tagName==="LINK"&&a.rel==="modulepreload"&&s(a)}).observe(document,{childList:!0,subtree:!0});function e(n){const r={};return n.integrity&&(r.integrity=n.integrity),n.referrerPolicy&&(r.referrerPolicy=n.referrerPolicy),n.crossOrigin==="use-credentials"?r.credentials="include":n.crossOrigin==="anonymous"?r.credentials="omit":r.credentials="same-origin",r}function s(n){if(n.ep)return;n.ep=!0;const r=e(n);fetch(n.href,r)}})();const Oa="modulepreload",Wa=function(i){return"/"+i},en={},mi=function(t,e,s){let n=Promise.resolve();if(e&&e.length>0){document.getElementsByTagName("link");const a=document.querySelector("meta[property=csp-nonce]"),o=(a==null?void 0:a.nonce)||(a==null?void 0:a.getAttribute("nonce"));n=Promise.allSettled(e.map(h=>{if(h=Wa(h),h in en)return;en[h]=!0;const l=h.endsWith(".css"),c=l?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${h}"]${c}`))return;const d=document.createElement("link");if(d.rel=l?"stylesheet":Oa,l||(d.as="script"),d.crossOrigin="",d.href=h,o&&d.setAttribute("nonce",o),document.head.appendChild(d),l)return new Promise((f,g)=>{d.addEventListener("load",f),d.addEventListener("error",()=>g(new Error(`Unable to preload CSS for ${h}`)))})}))}function r(a){const o=new Event("vite:preloadError",{cancelable:!0});if(o.payload=a,window.dispatchEvent(o),!o.defaultPrevented)throw a}return n.then(a=>{for(const o of a||[])o.status==="rejected"&&r(o.reason);return t().catch(r)})};var G=(i=>(i.Application="application",i.WebGLPipes="webgl-pipes",i.WebGLPipesAdaptor="webgl-pipes-adaptor",i.WebGLSystem="webgl-system",i.WebGPUPipes="webgpu-pipes",i.WebGPUPipesAdaptor="webgpu-pipes-adaptor",i.WebGPUSystem="webgpu-system",i.CanvasSystem="canvas-system",i.CanvasPipesAdaptor="canvas-pipes-adaptor",i.CanvasPipes="canvas-pipes",i.Asset="asset",i.LoadParser="load-parser",i.ResolveParser="resolve-parser",i.CacheParser="cache-parser",i.DetectionParser="detection-parser",i.MaskEffect="mask-effect",i.BlendMode="blend-mode",i.TextureSource="texture-source",i.Environment="environment",i.ShapeBuilder="shape-builder",i.Batcher="batcher",i))(G||{});const as=i=>{if(typeof i=="function"||typeof i=="object"&&i.extension){if(!i.extension)throw new Error("Extension class must have an extension object");i={...typeof i.extension!="object"?{type:i.extension}:i.extension,ref:i}}if(typeof i=="object")i={...i};else throw new Error("Invalid extension type");return typeof i.type=="string"&&(i.type=[i.type]),i},ei=(i,t)=>as(i).priority??t,dt={_addHandlers:{},_removeHandlers:{},_queue:{},remove(...i){return i.map(as).forEach(t=>{t.type.forEach(e=>{var s,n;return(n=(s=this._removeHandlers)[e])==null?void 0:n.call(s,t)})}),this},add(...i){return i.map(as).forEach(t=>{t.type.forEach(e=>{var r,a;const s=this._addHandlers,n=this._queue;s[e]?(a=s[e])==null||a.call(s,t):(n[e]=n[e]||[],(r=n[e])==null||r.push(t))})}),this},handle(i,t,e){var a;const s=this._addHandlers,n=this._removeHandlers;if(s[i]||n[i])throw new Error(`Extension type ${i} already has a handler`);s[i]=t,n[i]=e;const r=this._queue;return r[i]&&((a=r[i])==null||a.forEach(o=>t(o)),delete r[i]),this},handleByMap(i,t){return this.handle(i,e=>{e.name&&(t[e.name]=e.ref)},e=>{e.name&&delete t[e.name]})},handleByNamedList(i,t,e=-1){return this.handle(i,s=>{t.findIndex(r=>r.name===s.name)>=0||(t.push({name:s.name,value:s.ref}),t.sort((r,a)=>ei(a.value,e)-ei(r.value,e)))},s=>{const n=t.findIndex(r=>r.name===s.name);n!==-1&&t.splice(n,1)})},handleByList(i,t,e=-1){return this.handle(i,s=>{t.includes(s.ref)||(t.push(s.ref),t.sort((n,r)=>ei(r,e)-ei(n,e)))},s=>{const n=t.indexOf(s.ref);n!==-1&&t.splice(n,1)})}},Ha={extension:{type:G.Environment,name:"browser",priority:-1},test:()=>!0,load:async()=>{await mi(()=>import("./browserAll-Bnl4Z-wu.js"),__vite__mapDeps([0,1,2]))}},$a={extension:{type:G.Environment,name:"webworker",priority:0},test:()=>typeof self<"u"&&self.WorkerGlobalScope!==void 0,load:async()=>{await mi(()=>import("./webworkerAll-Cp5jyL-l.js"),__vite__mapDeps([1,2]))}};class pt{constructor(t,e,s){this._x=e||0,this._y=s||0,this._observer=t}clone(t){return new pt(t??this._observer,this._x,this._y)}set(t=0,e=t){return(this._x!==t||this._y!==e)&&(this._x=t,this._y=e,this._observer._onUpdate(this)),this}copyFrom(t){return(this._x!==t.x||this._y!==t.y)&&(this._x=t.x,this._y=t.y,this._observer._onUpdate(this)),this}copyTo(t){return t.set(this._x,this._y),t}equals(t){return t.x===this._x&&t.y===this._y}toString(){return`[pixi.js/math:ObservablePoint x=0 y=0 scope=${this._observer}]`}get x(){return this._x}set x(t){this._x!==t&&(this._x=t,this._observer._onUpdate(this))}get y(){return this._y}set y(t){this._y!==t&&(this._y=t,this._observer._onUpdate(this))}}function Gs(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}var nr={exports:{}};(function(i){var t=Object.prototype.hasOwnProperty,e="~";function s(){}Object.create&&(s.prototype=Object.create(null),new s().__proto__||(e=!1));function n(h,l,c){this.fn=h,this.context=l,this.once=c||!1}function r(h,l,c,d,f){if(typeof c!="function")throw new TypeError("The listener must be a function");var g=new n(c,d||h,f),m=e?e+l:l;return h._events[m]?h._events[m].fn?h._events[m]=[h._events[m],g]:h._events[m].push(g):(h._events[m]=g,h._eventsCount++),h}function a(h,l){--h._eventsCount===0?h._events=new s:delete h._events[l]}function o(){this._events=new s,this._eventsCount=0}o.prototype.eventNames=function(){var l=[],c,d;if(this._eventsCount===0)return l;for(d in c=this._events)t.call(c,d)&&l.push(e?d.slice(1):d);return Object.getOwnPropertySymbols?l.concat(Object.getOwnPropertySymbols(c)):l},o.prototype.listeners=function(l){var c=e?e+l:l,d=this._events[c];if(!d)return[];if(d.fn)return[d.fn];for(var f=0,g=d.length,m=new Array(g);fJt[i],uY:i=>te[i],vX:i=>ee[i],vY:i=>ie[i],inv:i=>i&8?i&15:-i&7,add:(i,t)=>os[i][t],sub:(i,t)=>os[i][j.inv(t)],rotate180:i=>i^4,isVertical:i=>(i&3)===2,byDirection:(i,t)=>Math.abs(i)*2<=Math.abs(t)?t>=0?j.S:j.N:Math.abs(t)*2<=Math.abs(i)?i>0?j.E:j.W:t>0?i>0?j.SE:j.SW:i>0?j.NE:j.NW,matrixAppendRotationInv:(i,t,e=0,s=0)=>{const n=rr[j.inv(t)];n.tx=e,n.ty=s,i.append(n)}},si=[new lt,new lt,new lt,new lt];class I{constructor(t=0,e=0,s=0,n=0){this.type="rectangle",this.x=Number(t),this.y=Number(e),this.width=Number(s),this.height=Number(n)}get left(){return this.x}get right(){return this.x+this.width}get top(){return this.y}get bottom(){return this.y+this.height}isEmpty(){return this.left===this.right||this.top===this.bottom}static get EMPTY(){return new I(0,0,0,0)}clone(){return new I(this.x,this.y,this.width,this.height)}copyFromBounds(t){return this.x=t.minX,this.y=t.minY,this.width=t.maxX-t.minX,this.height=t.maxY-t.minY,this}copyFrom(t){return this.x=t.x,this.y=t.y,this.width=t.width,this.height=t.height,this}copyTo(t){return t.copyFrom(this),t}contains(t,e){return this.width<=0||this.height<=0?!1:t>=this.x&&t=this.y&&e=h&&t<=l&&e>=c&&e<=d&&!(t>f&&tm&&et.right?t.right:this.right)<=k)return!1;const T=this.yt.bottom?t.bottom:this.bottom)>T}const s=this.left,n=this.right,r=this.top,a=this.bottom;if(n<=s||a<=r)return!1;const o=si[0].set(t.left,t.top),h=si[1].set(t.left,t.bottom),l=si[2].set(t.right,t.top),c=si[3].set(t.right,t.bottom);if(l.x<=o.x||h.y<=o.y)return!1;const d=Math.sign(e.a*e.d-e.b*e.c);if(d===0||(e.apply(o,o),e.apply(h,h),e.apply(l,l),e.apply(c,c),Math.max(o.x,h.x,l.x,c.x)<=s||Math.min(o.x,h.x,l.x,c.x)>=n||Math.max(o.y,h.y,l.y,c.y)<=r||Math.min(o.y,h.y,l.y,c.y)>=a))return!1;const f=d*(h.y-o.y),g=d*(o.x-h.x),m=f*s+g*r,y=f*n+g*r,x=f*s+g*a,w=f*n+g*a;if(Math.max(m,y,x,w)<=f*o.x+g*o.y||Math.min(m,y,x,w)>=f*c.x+g*c.y)return!1;const _=d*(o.y-l.y),b=d*(l.x-o.x),S=_*s+b*r,A=_*n+b*r,F=_*s+b*a,P=_*n+b*a;return!(Math.max(S,A,F,P)<=_*o.x+b*o.y||Math.min(S,A,F,P)>=_*c.x+b*c.y)}pad(t=0,e=t){return this.x-=t,this.y-=e,this.width+=t*2,this.height+=e*2,this}fit(t){const e=Math.max(this.x,t.x),s=Math.min(this.x+this.width,t.x+t.width),n=Math.max(this.y,t.y),r=Math.min(this.y+this.height,t.y+t.height);return this.x=e,this.width=Math.max(s-e,0),this.y=n,this.height=Math.max(r-n,0),this}ceil(t=1,e=.001){const s=Math.ceil((this.x+this.width-e)*t)/t,n=Math.ceil((this.y+this.height-e)*t)/t;return this.x=Math.floor((this.x+e)*t)/t,this.y=Math.floor((this.y+e)*t)/t,this.width=s-this.x,this.height=n-this.y,this}enlarge(t){const e=Math.min(this.x,t.x),s=Math.max(this.x+this.width,t.x+t.width),n=Math.min(this.y,t.y),r=Math.max(this.y+this.height,t.y+t.height);return this.x=e,this.width=s-e,this.y=n,this.height=r-n,this}getBounds(t){return t=t||new I,t.copyFrom(this),t}toString(){return`[pixi.js/math:Rectangle x=${this.x} y=${this.y} width=${this.width} height=${this.height}]`}}const Ri={default:-1};function nt(i="default"){return Ri[i]===void 0&&(Ri[i]=-1),++Ri[i]}const sn={},O="8.0.0",Qa="8.3.4";function U(i,t,e=3){if(sn[t])return;let s=new Error().stack;typeof s>"u"?console.warn("PixiJS Deprecation Warning: ",`${t} Deprecated since v${i}`):(s=s.split(` `).splice(e).join(` `),console.groupCollapsed?(console.groupCollapsed("%cPixiJS Deprecation Warning: %c%s","color:#614108;background:#fffbe6","font-weight:normal;color:#614108;background:#fffbe6",`${t} Deprecated since v${i}`),console.warn(s),console.groupEnd()):(console.warn("PixiJS Deprecation Warning: ",`${t} -Deprecated since v${i}`),console.warn(s))),en[t]=!0}const ar=()=>{};function sn(i){return i+=i===0?1:0,--i,i|=i>>>1,i|=i>>>2,i|=i>>>4,i|=i>>>8,i|=i>>>16,i+1}function nn(i){return!(i&i-1)&&!!i}function Ja(i){const t={};for(const e in i)i[e]!==void 0&&(t[e]=i[e]);return t}const rn=Object.create(null);function to(i){const t=rn[i];return t===void 0&&(rn[i]=nt("resource")),t}const or=class hr extends gt{constructor(t={}){super(),this._resourceType="textureSampler",this._touched=0,this._maxAnisotropy=1,this.destroyed=!1,t={...hr.defaultOptions,...t},this.addressMode=t.addressMode,this.addressModeU=t.addressModeU??this.addressModeU,this.addressModeV=t.addressModeV??this.addressModeV,this.addressModeW=t.addressModeW??this.addressModeW,this.scaleMode=t.scaleMode,this.magFilter=t.magFilter??this.magFilter,this.minFilter=t.minFilter??this.minFilter,this.mipmapFilter=t.mipmapFilter??this.mipmapFilter,this.lodMinClamp=t.lodMinClamp,this.lodMaxClamp=t.lodMaxClamp,this.compare=t.compare,this.maxAnisotropy=t.maxAnisotropy??1}set addressMode(t){this.addressModeU=t,this.addressModeV=t,this.addressModeW=t}get addressMode(){return this.addressModeU}set wrapMode(t){U(N,"TextureStyle.wrapMode is now TextureStyle.addressMode"),this.addressMode=t}get wrapMode(){return this.addressMode}set scaleMode(t){this.magFilter=t,this.minFilter=t,this.mipmapFilter=t}get scaleMode(){return this.magFilter}set maxAnisotropy(t){this._maxAnisotropy=Math.min(t,16),this._maxAnisotropy>1&&(this.scaleMode="linear")}get maxAnisotropy(){return this._maxAnisotropy}get _resourceId(){return this._sharedResourceId||this._generateResourceId()}update(){this.emit("change",this),this._sharedResourceId=null}_generateResourceId(){const t=`${this.addressModeU}-${this.addressModeV}-${this.addressModeW}-${this.magFilter}-${this.minFilter}-${this.mipmapFilter}-${this.lodMinClamp}-${this.lodMaxClamp}-${this.compare}-${this._maxAnisotropy}`;return this._sharedResourceId=to(t),this._resourceId}destroy(){this.destroyed=!0,this.emit("destroy",this),this.emit("change",this),this.removeAllListeners()}};or.defaultOptions={addressMode:"clamp-to-edge",scaleMode:"linear"};let eo=or;const lr=class cr extends gt{constructor(t={}){super(),this.options=t,this.uid=nt("textureSource"),this._resourceType="textureSource",this._resourceId=nt("resource"),this.uploadMethodId="unknown",this._resolution=1,this.pixelWidth=1,this.pixelHeight=1,this.width=1,this.height=1,this.sampleCount=1,this.mipLevelCount=1,this.autoGenerateMipmaps=!1,this.format="rgba8unorm",this.dimension="2d",this.antialias=!1,this._touched=0,this._batchTick=-1,this._textureBindLocation=-1,t={...cr.defaultOptions,...t},this.label=t.label??"",this.resource=t.resource,this.autoGarbageCollect=t.autoGarbageCollect,this._resolution=t.resolution,t.width?this.pixelWidth=t.width*this._resolution:this.pixelWidth=this.resource?this.resourceWidth??1:1,t.height?this.pixelHeight=t.height*this._resolution:this.pixelHeight=this.resource?this.resourceHeight??1:1,this.width=this.pixelWidth/this._resolution,this.height=this.pixelHeight/this._resolution,this.format=t.format,this.dimension=t.dimensions,this.mipLevelCount=t.mipLevelCount,this.autoGenerateMipmaps=t.autoGenerateMipmaps,this.sampleCount=t.sampleCount,this.antialias=t.antialias,this.alphaMode=t.alphaMode,this.style=new eo(Ja(t)),this.destroyed=!1,this._refreshPOT()}get source(){return this}get style(){return this._style}set style(t){var e,s;this.style!==t&&((e=this._style)==null||e.off("change",this._onStyleChange,this),this._style=t,(s=this._style)==null||s.on("change",this._onStyleChange,this),this._onStyleChange())}get addressMode(){return this._style.addressMode}set addressMode(t){this._style.addressMode=t}get repeatMode(){return this._style.addressMode}set repeatMode(t){this._style.addressMode=t}get magFilter(){return this._style.magFilter}set magFilter(t){this._style.magFilter=t}get minFilter(){return this._style.minFilter}set minFilter(t){this._style.minFilter=t}get mipmapFilter(){return this._style.mipmapFilter}set mipmapFilter(t){this._style.mipmapFilter=t}get lodMinClamp(){return this._style.lodMinClamp}set lodMinClamp(t){this._style.lodMinClamp=t}get lodMaxClamp(){return this._style.lodMaxClamp}set lodMaxClamp(t){this._style.lodMaxClamp=t}_onStyleChange(){this.emit("styleChange",this)}update(){if(this.resource){const t=this._resolution;if(this.resize(this.resourceWidth/t,this.resourceHeight/t))return}this.emit("update",this)}destroy(){this.destroyed=!0,this.emit("destroy",this),this.emit("change",this),this._style&&(this._style.destroy(),this._style=null),this.uploadMethodId=null,this.resource=null,this.removeAllListeners()}unload(){this._resourceId=nt("resource"),this.emit("change",this),this.emit("unload",this)}get resourceWidth(){const{resource:t}=this;return t.naturalWidth||t.videoWidth||t.displayWidth||t.width}get resourceHeight(){const{resource:t}=this;return t.naturalHeight||t.videoHeight||t.displayHeight||t.height}get resolution(){return this._resolution}set resolution(t){this._resolution!==t&&(this._resolution=t,this.width=this.pixelWidth/t,this.height=this.pixelHeight/t)}resize(t,e,s){s=s||this._resolution,t=t||this.width,e=e||this.height;const n=Math.round(t*s),r=Math.round(e*s);return this.width=n/s,this.height=r/s,this._resolution=s,this.pixelWidth===n&&this.pixelHeight===r?!1:(this._refreshPOT(),this.pixelWidth=n,this.pixelHeight=r,this.emit("resize",this),this._resourceId=nt("resource"),this.emit("change",this),!0)}updateMipmaps(){this.autoGenerateMipmaps&&this.mipLevelCount>1&&this.emit("updateMipmaps",this)}set wrapMode(t){this._style.wrapMode=t}get wrapMode(){return this._style.wrapMode}set scaleMode(t){this._style.scaleMode=t}get scaleMode(){return this._style.scaleMode}_refreshPOT(){this.isPowerOfTwo=nn(this.pixelWidth)&&nn(this.pixelHeight)}static test(t){throw new Error("Unimplemented")}};lr.defaultOptions={resolution:1,format:"bgra8unorm",alphaMode:"premultiply-alpha-on-upload",dimensions:"2d",mipLevelCount:1,autoGenerateMipmaps:!1,sampleCount:1,antialias:!1,autoGarbageCollect:!1};let Ot=lr;class Gs extends Ot{constructor(t){const e=t.resource||new Float32Array(t.width*t.height*4);let s=t.format;s||(e instanceof Float32Array?s="rgba32float":e instanceof Int32Array||e instanceof Uint32Array?s="rgba32uint":e instanceof Int16Array||e instanceof Uint16Array?s="rgba16uint":(e instanceof Int8Array,s="bgra8unorm")),super({...t,resource:e,format:s}),this.uploadMethodId="buffer"}static test(t){return t instanceof Int8Array||t instanceof Uint8Array||t instanceof Uint8ClampedArray||t instanceof Int16Array||t instanceof Uint16Array||t instanceof Int32Array||t instanceof Uint32Array||t instanceof Float32Array}}Gs.extension=G.TextureSource;const an=new H;class io{constructor(t,e){this.mapCoord=new H,this.uClampFrame=new Float32Array(4),this.uClampOffset=new Float32Array(2),this._textureID=-1,this._updateID=0,this.clampOffset=0,typeof e>"u"?this.clampMargin=t.width<10?0:.5:this.clampMargin=e,this.isSimple=!1,this.texture=t}get texture(){return this._texture}set texture(t){var e;this.texture!==t&&((e=this._texture)==null||e.removeListener("update",this.update,this),this._texture=t,this._texture.addListener("update",this.update,this),this.update())}multiplyUvs(t,e){e===void 0&&(e=t);const s=this.mapCoord;for(let n=0;nthis.maxX||this.minY>this.maxY}get rectangle(){this._rectangle||(this._rectangle=new E);const t=this._rectangle;return this.minX>this.maxX||this.minY>this.maxY?(t.x=0,t.y=0,t.width=0,t.height=0):t.copyFromBounds(this),t}clear(){return this.minX=1/0,this.minY=1/0,this.maxX=-1/0,this.maxY=-1/0,this.matrix=on,this}set(t,e,s,n){this.minX=t,this.minY=e,this.maxX=s,this.maxY=n}addFrame(t,e,s,n,r){r||(r=this.matrix);const a=r.a,o=r.b,h=r.c,l=r.d,c=r.tx,d=r.ty;let f=this.minX,g=this.minY,m=this.maxX,y=this.maxY,x=a*t+h*e+c,w=o*t+l*e+d;xm&&(m=x),w>y&&(y=w),x=a*s+h*e+c,w=o*s+l*e+d,xm&&(m=x),w>y&&(y=w),x=a*t+h*n+c,w=o*t+l*n+d,xm&&(m=x),w>y&&(y=w),x=a*s+h*n+c,w=o*s+l*n+d,xm&&(m=x),w>y&&(y=w),this.minX=f,this.minY=g,this.maxX=m,this.maxY=y}addRect(t,e){this.addFrame(t.x,t.y,t.x+t.width,t.y+t.height,e)}addBounds(t,e){this.addFrame(t.minX,t.minY,t.maxX,t.maxY,e)}addBoundsMask(t){this.minX=this.minX>t.minX?this.minX:t.minX,this.minY=this.minY>t.minY?this.minY:t.minY,this.maxX=this.maxXthis.maxX?f:this.maxX,this.maxY=g>this.maxY?g:this.maxY,f=a*e+h*r+c,g=o*e+l*r+d,this.minX=fthis.maxX?f:this.maxX,this.maxY=g>this.maxY?g:this.maxY,f=a*n+h*r+c,g=o*n+l*r+d,this.minX=fthis.maxX?f:this.maxX,this.maxY=g>this.maxY?g:this.maxY}fit(t){return this.minXt.right&&(this.maxX=t.right),this.minYt.bottom&&(this.maxY=t.bottom),this}fitBounds(t,e,s,n){return this.minXe&&(this.maxX=e),this.minYn&&(this.maxY=n),this}pad(t,e=t){return this.minX-=t,this.maxX+=t,this.minY-=e,this.maxY+=e,this}ceil(){return this.minX=Math.floor(this.minX),this.minY=Math.floor(this.minY),this.maxX=Math.ceil(this.maxX),this.maxY=Math.ceil(this.maxY),this}clone(){return new Et(this.minX,this.minY,this.maxX,this.maxY)}scale(t,e=t){return this.minX*=t,this.minY*=e,this.maxX*=t,this.maxY*=e,this}get x(){return this.minX}set x(t){const e=this.maxX-this.minX;this.minX=t,this.maxX=t+e}get y(){return this.minY}set y(t){const e=this.maxY-this.minY;this.minY=t,this.maxY=t+e}get width(){return this.maxX-this.minX}set width(t){this.maxX=this.minX+t}get height(){return this.maxY-this.minY}set height(t){this.maxY=this.minY+t}get left(){return this.minX}get right(){return this.maxX}get top(){return this.minY}get bottom(){return this.maxY}get isPositive(){return this.maxX-this.minX>0&&this.maxY-this.minY>0}get isValid(){return this.minX+this.minY!==1/0}addVertexData(t,e,s,n){let r=this.minX,a=this.minY,o=this.maxX,h=this.maxY;n||(n=this.matrix);const l=n.a,c=n.b,d=n.c,f=n.d,g=n.tx,m=n.ty;for(let y=e;yo?_:o,h=b>h?b:h}this.minX=r,this.minY=a,this.maxX=o,this.maxY=h}containsPoint(t,e){return this.minX<=t&&this.minY<=e&&this.maxX>=t&&this.maxY>=e}toString(){return`[pixi.js:Bounds minX=${this.minX} minY=${this.minY} maxX=${this.maxX} maxY=${this.maxY} width=${this.width} height=${this.height}]`}}var no={grad:.9,turn:360,rad:360/(2*Math.PI)},Ft=function(i){return typeof i=="string"?i.length>0:typeof i=="number"},at=function(i,t,e){return t===void 0&&(t=0),e===void 0&&(e=Math.pow(10,t)),Math.round(e*i)/e+0},wt=function(i,t,e){return t===void 0&&(t=0),e===void 0&&(e=1),i>e?e:i>t?i:t},dr=function(i){return(i=isFinite(i)?i%360:0)>0?i:i+360},hn=function(i){return{r:wt(i.r,0,255),g:wt(i.g,0,255),b:wt(i.b,0,255),a:wt(i.a)}},Ri=function(i){return{r:at(i.r),g:at(i.g),b:at(i.b),a:at(i.a,3)}},ro=/^#([0-9a-f]{3,8})$/i,ni=function(i){var t=i.toString(16);return t.length<2?"0"+t:t},ur=function(i){var t=i.r,e=i.g,s=i.b,n=i.a,r=Math.max(t,e,s),a=r-Math.min(t,e,s),o=a?r===t?(e-s)/a:r===e?2+(s-t)/a:4+(t-e)/a:0;return{h:60*(o<0?o+6:o),s:r?a/r*100:0,v:r/255*100,a:n}},fr=function(i){var t=i.h,e=i.s,s=i.v,n=i.a;t=t/360*6,e/=100,s/=100;var r=Math.floor(t),a=s*(1-e),o=s*(1-(t-r)*e),h=s*(1-(1-t+r)*e),l=r%6;return{r:255*[s,o,a,a,h,s][l],g:255*[h,s,s,o,a,a][l],b:255*[a,a,h,s,s,o][l],a:n}},ln=function(i){return{h:dr(i.h),s:wt(i.s,0,100),l:wt(i.l,0,100),a:wt(i.a)}},cn=function(i){return{h:at(i.h),s:at(i.s),l:at(i.l),a:at(i.a,3)}},dn=function(i){return fr((e=(t=i).s,{h:t.h,s:(e*=((s=t.l)<50?s:100-s)/100)>0?2*e/(s+e)*100:0,v:s+e,a:t.a}));var t,e,s},Ne=function(i){return{h:(t=ur(i)).h,s:(n=(200-(e=t.s))*(s=t.v)/100)>0&&n<200?e*s/100/(n<=100?n:200-n)*100:0,l:n/2,a:t.a};var t,e,s,n},ao=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,oo=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,ho=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,lo=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,os={string:[[function(i){var t=ro.exec(i);return t?(i=t[1]).length<=4?{r:parseInt(i[0]+i[0],16),g:parseInt(i[1]+i[1],16),b:parseInt(i[2]+i[2],16),a:i.length===4?at(parseInt(i[3]+i[3],16)/255,2):1}:i.length===6||i.length===8?{r:parseInt(i.substr(0,2),16),g:parseInt(i.substr(2,2),16),b:parseInt(i.substr(4,2),16),a:i.length===8?at(parseInt(i.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(i){var t=ho.exec(i)||lo.exec(i);return t?t[2]!==t[4]||t[4]!==t[6]?null:hn({r:Number(t[1])/(t[2]?100/255:1),g:Number(t[3])/(t[4]?100/255:1),b:Number(t[5])/(t[6]?100/255:1),a:t[7]===void 0?1:Number(t[7])/(t[8]?100:1)}):null},"rgb"],[function(i){var t=ao.exec(i)||oo.exec(i);if(!t)return null;var e,s,n=ln({h:(e=t[1],s=t[2],s===void 0&&(s="deg"),Number(e)*(no[s]||1)),s:Number(t[3]),l:Number(t[4]),a:t[5]===void 0?1:Number(t[5])/(t[6]?100:1)});return dn(n)},"hsl"]],object:[[function(i){var t=i.r,e=i.g,s=i.b,n=i.a,r=n===void 0?1:n;return Ft(t)&&Ft(e)&&Ft(s)?hn({r:Number(t),g:Number(e),b:Number(s),a:Number(r)}):null},"rgb"],[function(i){var t=i.h,e=i.s,s=i.l,n=i.a,r=n===void 0?1:n;if(!Ft(t)||!Ft(e)||!Ft(s))return null;var a=ln({h:Number(t),s:Number(e),l:Number(s),a:Number(r)});return dn(a)},"hsl"],[function(i){var t=i.h,e=i.s,s=i.v,n=i.a,r=n===void 0?1:n;if(!Ft(t)||!Ft(e)||!Ft(s))return null;var a=function(o){return{h:dr(o.h),s:wt(o.s,0,100),v:wt(o.v,0,100),a:wt(o.a)}}({h:Number(t),s:Number(e),v:Number(s),a:Number(r)});return fr(a)},"hsv"]]},un=function(i,t){for(var e=0;e=.5},i.prototype.toHex=function(){return t=Ri(this.rgba),e=t.r,s=t.g,n=t.b,a=(r=t.a)<1?ni(at(255*r)):"","#"+ni(e)+ni(s)+ni(n)+a;var t,e,s,n,r,a},i.prototype.toRgb=function(){return Ri(this.rgba)},i.prototype.toRgbString=function(){return t=Ri(this.rgba),e=t.r,s=t.g,n=t.b,(r=t.a)<1?"rgba("+e+", "+s+", "+n+", "+r+")":"rgb("+e+", "+s+", "+n+")";var t,e,s,n,r},i.prototype.toHsl=function(){return cn(Ne(this.rgba))},i.prototype.toHslString=function(){return t=cn(Ne(this.rgba)),e=t.h,s=t.s,n=t.l,(r=t.a)<1?"hsla("+e+", "+s+"%, "+n+"%, "+r+")":"hsl("+e+", "+s+"%, "+n+"%)";var t,e,s,n,r},i.prototype.toHsv=function(){return t=ur(this.rgba),{h:at(t.h),s:at(t.s),v:at(t.v),a:at(t.a,3)};var t},i.prototype.invert=function(){return Pt({r:255-(t=this.rgba).r,g:255-t.g,b:255-t.b,a:t.a});var t},i.prototype.saturate=function(t){return t===void 0&&(t=.1),Pt(Fi(this.rgba,t))},i.prototype.desaturate=function(t){return t===void 0&&(t=.1),Pt(Fi(this.rgba,-t))},i.prototype.grayscale=function(){return Pt(Fi(this.rgba,-1))},i.prototype.lighten=function(t){return t===void 0&&(t=.1),Pt(fn(this.rgba,t))},i.prototype.darken=function(t){return t===void 0&&(t=.1),Pt(fn(this.rgba,-t))},i.prototype.rotate=function(t){return t===void 0&&(t=15),this.hue(this.hue()+t)},i.prototype.alpha=function(t){return typeof t=="number"?Pt({r:(e=this.rgba).r,g:e.g,b:e.b,a:t}):at(this.rgba.a,3);var e},i.prototype.hue=function(t){var e=Ne(this.rgba);return typeof t=="number"?Pt({h:t,s:e.s,l:e.l,a:e.a}):at(e.h)},i.prototype.isEqual=function(t){return this.toHex()===Pt(t).toHex()},i}(),Pt=function(i){return i instanceof hs?i:new hs(i)},pn=[],uo=function(i){i.forEach(function(t){pn.indexOf(t)<0&&(t(hs,os),pn.push(t))})};function fo(i,t){var e={white:"#ffffff",bisque:"#ffe4c4",blue:"#0000ff",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",antiquewhite:"#faebd7",aqua:"#00ffff",azure:"#f0ffff",whitesmoke:"#f5f5f5",papayawhip:"#ffefd5",plum:"#dda0dd",blanchedalmond:"#ffebcd",black:"#000000",gold:"#ffd700",goldenrod:"#daa520",gainsboro:"#dcdcdc",cornsilk:"#fff8dc",cornflowerblue:"#6495ed",burlywood:"#deb887",aquamarine:"#7fffd4",beige:"#f5f5dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkkhaki:"#bdb76b",darkgray:"#a9a9a9",darkgreen:"#006400",darkgrey:"#a9a9a9",peachpuff:"#ffdab9",darkmagenta:"#8b008b",darkred:"#8b0000",darkorchid:"#9932cc",darkorange:"#ff8c00",darkslateblue:"#483d8b",gray:"#808080",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",deeppink:"#ff1493",deepskyblue:"#00bfff",wheat:"#f5deb3",firebrick:"#b22222",floralwhite:"#fffaf0",ghostwhite:"#f8f8ff",darkviolet:"#9400d3",magenta:"#ff00ff",green:"#008000",dodgerblue:"#1e90ff",grey:"#808080",honeydew:"#f0fff0",hotpink:"#ff69b4",blueviolet:"#8a2be2",forestgreen:"#228b22",lawngreen:"#7cfc00",indianred:"#cd5c5c",indigo:"#4b0082",fuchsia:"#ff00ff",brown:"#a52a2a",maroon:"#800000",mediumblue:"#0000cd",lightcoral:"#f08080",darkturquoise:"#00ced1",lightcyan:"#e0ffff",ivory:"#fffff0",lightyellow:"#ffffe0",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",linen:"#faf0e6",mediumaquamarine:"#66cdaa",lemonchiffon:"#fffacd",lime:"#00ff00",khaki:"#f0e68c",mediumseagreen:"#3cb371",limegreen:"#32cd32",mediumspringgreen:"#00fa9a",lightskyblue:"#87cefa",lightblue:"#add8e6",midnightblue:"#191970",lightpink:"#ffb6c1",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",mintcream:"#f5fffa",lightslategray:"#778899",lightslategrey:"#778899",navajowhite:"#ffdead",navy:"#000080",mediumvioletred:"#c71585",powderblue:"#b0e0e6",palegoldenrod:"#eee8aa",oldlace:"#fdf5e6",paleturquoise:"#afeeee",mediumturquoise:"#48d1cc",mediumorchid:"#ba55d3",rebeccapurple:"#663399",lightsteelblue:"#b0c4de",mediumslateblue:"#7b68ee",thistle:"#d8bfd8",tan:"#d2b48c",orchid:"#da70d6",mediumpurple:"#9370db",purple:"#800080",pink:"#ffc0cb",skyblue:"#87ceeb",springgreen:"#00ff7f",palegreen:"#98fb98",red:"#ff0000",yellow:"#ffff00",slateblue:"#6a5acd",lavenderblush:"#fff0f5",peru:"#cd853f",palevioletred:"#db7093",violet:"#ee82ee",teal:"#008080",slategray:"#708090",slategrey:"#708090",aliceblue:"#f0f8ff",darkseagreen:"#8fbc8f",darkolivegreen:"#556b2f",greenyellow:"#adff2f",seagreen:"#2e8b57",seashell:"#fff5ee",tomato:"#ff6347",silver:"#c0c0c0",sienna:"#a0522d",lavender:"#e6e6fa",lightgreen:"#90ee90",orange:"#ffa500",orangered:"#ff4500",steelblue:"#4682b4",royalblue:"#4169e1",turquoise:"#40e0d0",yellowgreen:"#9acd32",salmon:"#fa8072",saddlebrown:"#8b4513",sandybrown:"#f4a460",rosybrown:"#bc8f8f",darksalmon:"#e9967a",lightgoldenrodyellow:"#fafad2",snow:"#fffafa",lightgrey:"#d3d3d3",lightgray:"#d3d3d3",dimgray:"#696969",dimgrey:"#696969",olivedrab:"#6b8e23",olive:"#808000"},s={};for(var n in e)s[e[n]]=n;var r={};i.prototype.toName=function(a){if(!(this.rgba.a||this.rgba.r||this.rgba.g||this.rgba.b))return"transparent";var o,h,l=s[this.toHex()];if(l)return l;if(a!=null&&a.closest){var c=this.toRgb(),d=1/0,f="black";if(!r.length)for(var g in e)r[g]=new i(e[g]).toRgb();for(var m in e){var y=(o=c,h=r[m],Math.pow(o.r-h.r,2)+Math.pow(o.g-h.g,2)+Math.pow(o.b-h.b,2));yr===e[a]);if(t!==null&&e!==null){const r=Object.keys(t),a=Object.keys(e);return r.length!==a.length?!1:r.every(o=>t[o]===e[o])}return t===e}toRgba(){const[t,e,s,n]=this._components;return{r:t,g:e,b:s,a:n}}toRgb(){const[t,e,s]=this._components;return{r:t,g:e,b:s}}toRgbaString(){const[t,e,s]=this.toUint8RgbArray();return`rgba(${t},${e},${s},${this.alpha})`}toUint8RgbArray(t){const[e,s,n]=this._components;return this._arrayRgb||(this._arrayRgb=[]),t=t||this._arrayRgb,t[0]=Math.round(e*255),t[1]=Math.round(s*255),t[2]=Math.round(n*255),t}toArray(t){this._arrayRgba||(this._arrayRgba=[]),t=t||this._arrayRgba;const[e,s,n,r]=this._components;return t[0]=e,t[1]=s,t[2]=n,t[3]=r,t}toRgbArray(t){this._arrayRgb||(this._arrayRgb=[]),t=t||this._arrayRgb;const[e,s,n]=this._components;return t[0]=e,t[1]=s,t[2]=n,t}toNumber(){return this._int}toBgrNumber(){const[t,e,s]=this.toUint8RgbArray();return(s<<16)+(e<<8)+t}toLittleEndianNumber(){const t=this._int;return(t>>16)+(t&65280)+((t&255)<<16)}multiply(t){const[e,s,n,r]=De._temp.setValue(t)._components;return this._components[0]*=e,this._components[1]*=s,this._components[2]*=n,this._components[3]*=r,this._refreshInt(),this._value=null,this}premultiply(t,e=!0){return e&&(this._components[0]*=t,this._components[1]*=t,this._components[2]*=t),this._components[3]=t,this._refreshInt(),this._value=null,this}toPremultiplied(t,e=!0){if(t===1)return(255<<24)+this._int;if(t===0)return e?0:this._int;let s=this._int>>16&255,n=this._int>>8&255,r=this._int&255;return e&&(s=s*t+.5|0,n=n*t+.5|0,r=r*t+.5|0),(t*255<<24)+(s<<16)+(n<<8)+r}toHex(){const t=this._int.toString(16);return`#${"000000".substring(0,6-t.length)+t}`}toHexa(){const e=Math.round(this._components[3]*255).toString(16);return this.toHex()+"00".substring(0,2-e.length)+e}setAlpha(t){return this._components[3]=this._clamp(t),this}_normalize(t){let e,s,n,r;if((typeof t=="number"||t instanceof Number)&&t>=0&&t<=16777215){const a=t;e=(a>>16&255)/255,s=(a>>8&255)/255,n=(a&255)/255,r=1}else if((Array.isArray(t)||t instanceof Float32Array)&&t.length>=3&&t.length<=4)t=this._clamp(t),[e,s,n,r=1]=t;else if((t instanceof Uint8Array||t instanceof Uint8ClampedArray)&&t.length>=3&&t.length<=4)t=this._clamp(t,0,255),[e,s,n,r=255]=t,e/=255,s/=255,n/=255,r/=255;else if(typeof t=="string"||typeof t=="object"){if(typeof t=="string"){const o=De.HEX_PATTERN.exec(t);o&&(t=`#${o[2]}`)}const a=Pt(t);a.isValid()&&({r:e,g:s,b:n,a:r}=a.rgba,e/=255,s/=255,n/=255)}if(e!==void 0)this._components[0]=e,this._components[1]=s,this._components[2]=n,this._components[3]=r,this._refreshInt();else throw new Error(`Unable to convert color ${t}`)}_refreshInt(){this._clamp(this._components);const[t,e,s]=this._components;this._int=(t*255<<16)+(e*255<<8)+(s*255|0)}_clamp(t,e=0,s=1){return typeof t=="number"?Math.min(Math.max(t,e),s):(t.forEach((n,r)=>{t[r]=Math.min(Math.max(n,e),s)}),t)}static isColorLike(t){return typeof t=="number"||typeof t=="string"||t instanceof Number||t instanceof De||Array.isArray(t)||t instanceof Uint8Array||t instanceof Uint8ClampedArray||t instanceof Float32Array||t.r!==void 0&&t.g!==void 0&&t.b!==void 0||t.r!==void 0&&t.g!==void 0&&t.b!==void 0&&t.a!==void 0||t.h!==void 0&&t.s!==void 0&&t.l!==void 0||t.h!==void 0&&t.s!==void 0&&t.l!==void 0&&t.a!==void 0||t.h!==void 0&&t.s!==void 0&&t.v!==void 0||t.h!==void 0&&t.s!==void 0&&t.v!==void 0&&t.a!==void 0}};me.shared=new me;me._temp=new me;me.HEX_PATTERN=/^(#|0x)?(([a-f0-9]{3}){1,2}([a-f0-9]{2})?)$/i;let Y=me;const po={cullArea:null,cullable:!1,cullableChildren:!0};class ks{constructor(t,e){this._pool=[],this._count=0,this._index=0,this._classType=t,e&&this.prepopulate(e)}prepopulate(t){for(let e=0;e0?e=this._pool[--this._index]:e=new this._classType,(s=e.init)==null||s.call(e,t),e}return(t){var e;(e=t.reset)==null||e.call(t),this._pool[this._index++]=t}get totalSize(){return this._count}get totalFree(){return this._index}get totalUsed(){return this._count-this._index}clear(){this._pool.length=0,this._index=0}}class go{constructor(){this._poolsByClass=new Map}prepopulate(t,e){this.getPool(t).prepopulate(e)}get(t,e){return this.getPool(t).get(e)}return(t){this.getPool(t.constructor).return(t)}getPool(t){return this._poolsByClass.has(t)||this._poolsByClass.set(t,new ks(t)),this._poolsByClass.get(t)}stats(){const t={};return this._poolsByClass.forEach(e=>{const s=t[e._classType.name]?e._classType.name+e._classType.ID:e._classType.name;t[s]={free:e.totalFree,used:e.totalUsed,size:e.totalSize}}),t}}const zt=new go;function mo(i,t,e){const s=i.length;let n;if(t>=s||e===0)return;e=t+e>s?s-t:e;const r=s-e;for(n=t;n0&&s<=e){for(let a=e-1;a>=i;a--){const o=this.children[a];o&&(n.push(o),o.parent=null)}mo(this.children,i,e);const r=this.renderGroup||this.parentRenderGroup;r&&r.removeChildren(n);for(let a=0;a=this.children.length)throw new Error(`getChildAt: Index (${i}) does not exist.`);return this.children[i]},setChildIndex(i,t){if(t<0||t>=this.children.length)throw new Error(`The index ${t} supplied is out of bounds ${this.children.length}`);this.getChildIndex(i),this.addChildAt(i,t)},getChildIndex(i){const t=this.children.indexOf(i);if(t===-1)throw new Error("The supplied Container must be a child of the caller");return t},addChildAt(i,t){this.allowChildren||U(N,"addChildAt: Only Containers will be allowed to add children in v8.0.0");const{children:e}=this;if(t<0||t>e.length)throw new Error(`${i}addChildAt: The index ${t} supplied is out of bounds ${e.length}`);if(i.parent){const n=i.parent.children.indexOf(i);if(i.parent===this&&n===t)return i;n!==-1&&i.parent.children.splice(n,1)}t===e.length?e.push(i):e.splice(t,0,i),i.parent=this,i.didChange=!0,i.didViewUpdate=!1,i._updateFlags=15;const s=this.renderGroup||this.parentRenderGroup;return s&&s.addChild(i),this.sortableChildren&&(this.sortDirty=!0),this.emit("childAdded",i,this,t),i.emit("added",this),i},swapChildren(i,t){if(i===t)return;const e=this.getChildIndex(i),s=this.getChildIndex(t);this.children[e]=t,this.children[s]=i;const n=this.renderGroup||this.parentRenderGroup;n&&(n.structureDidChange=!0),this._didContainerChangeTick++},removeFromParent(){var i;(i=this.parent)==null||i.removeChild(this)},reparentChild(...i){return i.length===1?this.reparentChildAt(i[0],this.children.length):(i.forEach(t=>this.reparentChildAt(t,this.children.length)),i[0])},reparentChildAt(i,t){if(i.parent===this)return this.setChildIndex(i,t),i;const e=i.worldTransform.clone();i.removeFromParent(),this.addChildAt(i,t);const s=this.worldTransform.clone();return s.invert(),e.prepend(s),i.setFromMatrix(e),i}};class gn{constructor(){this.pipe="filter",this.priority=1}destroy(){for(let t=0;t{this.add({test:t.test,maskClass:t})}))}add(t){this._tests.push(t)}getMaskEffect(t){this._initialized||this.init();for(let e=0;es.priority-n.priority);const e=this.renderGroup||this.parentRenderGroup;e&&(e.structureDidChange=!0),this._updateIsSimple()},removeEffect(i){const t=this.effects.indexOf(i);t!==-1&&(this.effects.splice(t,1),this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._updateIsSimple())},set mask(i){const t=this._maskEffect;(t==null?void 0:t.mask)!==i&&(t&&(this.removeEffect(t),ls.returnMaskEffect(t),this._maskEffect=null),i!=null&&(this._maskEffect=ls.getMaskEffect(i),this.addEffect(this._maskEffect)))},get mask(){var i;return(i=this._maskEffect)==null?void 0:i.mask},set filters(i){var r;!Array.isArray(i)&&i&&(i=[i]);const t=this._filterEffect||(this._filterEffect=new gn);i=i;const e=(i==null?void 0:i.length)>0,s=((r=t.filters)==null?void 0:r.length)>0,n=e!==s;i=Array.isArray(i)?i.slice(0):i,t.filters=Object.freeze(i),n&&(e?this.addEffect(t):(this.removeEffect(t),t.filters=i??null))},get filters(){var i;return(i=this._filterEffect)==null?void 0:i.filters},set filterArea(i){this._filterEffect||(this._filterEffect=new gn),this._filterEffect.filterArea=i},get filterArea(){var i;return(i=this._filterEffect)==null?void 0:i.filterArea}},_o={label:null,get name(){return U(N,"Container.name property has been removed, use Container.label instead"),this.label},set name(i){U(N,"Container.name property has been removed, use Container.label instead"),this.label=i},getChildByName(i,t=!1){return this.getChildByLabel(i,t)},getChildByLabel(i,t=!1){const e=this.children;for(let s=0;s-1&&this.renderGroupChildren.splice(e,1),t.renderGroupParent=null}addChild(t){if(this.structureDidChange=!0,t.parentRenderGroup=this,t.updateTick=-1,t.parent===this.root?t.relativeRenderGroupDepth=1:t.relativeRenderGroupDepth=t.parent.relativeRenderGroupDepth+1,t.didChange=!0,this.onChildUpdate(t),t.renderGroup){this.addRenderGroupChild(t.renderGroup);return}t._onRender&&this.addOnRender(t);const e=t.children;for(let s=0;s0}addOnRender(t){this._onRenderContainers.push(t)}removeOnRender(t){this._onRenderContainers.splice(this._onRenderContainers.indexOf(t),1)}runOnRender(){for(let t=0;tthis.addChild(n)),(s=t.parent)==null||s.addChild(this)}static mixin(t){Object.defineProperties(tt.prototype,Object.getOwnPropertyDescriptors(t))}set _didChangeId(t){this._didViewChangeTick=t>>12&4095,this._didContainerChangeTick=t&4095}get _didChangeId(){return this._didContainerChangeTick&4095|(this._didViewChangeTick&4095)<<12}addChild(...t){if(this.allowChildren||U(N,"addChild: Only Containers will be allowed to add children in v8.0.0"),t.length>1){for(let n=0;n1){for(let n=0;n-1&&(this._didViewChangeTick++,this.children.splice(s,1),this.renderGroup?this.renderGroup.removeChild(e):this.parentRenderGroup&&this.parentRenderGroup.removeChild(e),e.parent=null,this.emit("childRemoved",e,this,s),e.emit("removed",this)),e}_onUpdate(t){t&&t===this._skew&&this._updateSkew(),this._didContainerChangeTick++,!this.didChange&&(this.didChange=!0,this.parentRenderGroup&&this.parentRenderGroup.onChildUpdate(this))}set isRenderGroup(t){!!this.renderGroup!==t&&(t?this.enableRenderGroup():this.disableRenderGroup())}get isRenderGroup(){return!!this.renderGroup}enableRenderGroup(){if(this.renderGroup)return;const t=this.parentRenderGroup;t==null||t.removeChild(this),this.renderGroup=zt.get(Po,this),this.groupTransform=H.IDENTITY,t==null||t.addChild(this),this._updateIsSimple()}disableRenderGroup(){if(!this.renderGroup)return;const t=this.parentRenderGroup;t==null||t.removeChild(this),zt.return(this.renderGroup),this.renderGroup=null,this.groupTransform=this.relativeGroupTransform,t==null||t.addChild(this),this._updateIsSimple()}_updateIsSimple(){this.isSimple=!this.renderGroup&&this.effects.length===0}get worldTransform(){return this._worldTransform||(this._worldTransform=new H),this.renderGroup?this._worldTransform.copyFrom(this.renderGroup.worldTransform):this.parentRenderGroup&&this._worldTransform.appendFrom(this.relativeGroupTransform,this.parentRenderGroup.worldTransform),this._worldTransform}get x(){return this._position.x}set x(t){this._position.x=t}get y(){return this._position.y}set y(t){this._position.y=t}get position(){return this._position}set position(t){this._position.copyFrom(t)}get rotation(){return this._rotation}set rotation(t){this._rotation!==t&&(this._rotation=t,this._onUpdate(this._skew))}get angle(){return this.rotation*Xa}set angle(t){this.rotation=t*ja}get pivot(){return this._pivot===Ui&&(this._pivot=new pt(this,0,0)),this._pivot}set pivot(t){this._pivot===Ui&&(this._pivot=new pt(this,0,0)),typeof t=="number"?this._pivot.set(t):this._pivot.copyFrom(t)}get skew(){return this._skew===zi&&(this._skew=new pt(this,0,0)),this._skew}set skew(t){this._skew===zi&&(this._skew=new pt(this,0,0)),this._skew.copyFrom(t)}get scale(){return this._scale===Oi&&(this._scale=new pt(this,1,1)),this._scale}set scale(t){this._scale===Oi&&(this._scale=new pt(this,0,0)),typeof t=="number"?this._scale.set(t):this._scale.copyFrom(t)}get width(){return Math.abs(this.scale.x*this.getLocalBounds().width)}set width(t){const e=this.getLocalBounds().width;this._setWidth(t,e)}get height(){return Math.abs(this.scale.y*this.getLocalBounds().height)}set height(t){const e=this.getLocalBounds().height;this._setHeight(t,e)}getSize(t){t||(t={});const e=this.getLocalBounds();return t.width=Math.abs(this.scale.x*e.width),t.height=Math.abs(this.scale.y*e.height),t}setSize(t,e){const s=this.getLocalBounds();typeof t=="object"?(e=t.height??t.width,t=t.width):e??(e=t),t!==void 0&&this._setWidth(t,s.width),e!==void 0&&this._setHeight(e,s.height)}_updateSkew(){const t=this._rotation,e=this._skew;this._cx=Math.cos(t+e._y),this._sx=Math.sin(t+e._y),this._cy=-Math.sin(t-e._x),this._sy=Math.cos(t-e._x)}updateTransform(t){return this.position.set(typeof t.x=="number"?t.x:this.position.x,typeof t.y=="number"?t.y:this.position.y),this.scale.set(typeof t.scaleX=="number"?t.scaleX||1:this.scale.x,typeof t.scaleY=="number"?t.scaleY||1:this.scale.y),this.rotation=typeof t.rotation=="number"?t.rotation:this.rotation,this.skew.set(typeof t.skewX=="number"?t.skewX:this.skew.x,typeof t.skewY=="number"?t.skewY:this.skew.y),this.pivot.set(typeof t.pivotX=="number"?t.pivotX:this.pivot.x,typeof t.pivotY=="number"?t.pivotY:this.pivot.y),this}setFromMatrix(t){t.decompose(this)}updateLocalTransform(){const t=this._didContainerChangeTick;if(this._didLocalTransformChangeId===t)return;this._didLocalTransformChangeId=t;const e=this.localTransform,s=this._scale,n=this._pivot,r=this._position,a=s._x,o=s._y,h=n._x,l=n._y;e.a=this._cx*a,e.b=this._sx*a,e.c=this._cy*o,e.d=this._sy*o,e.tx=r._x-(h*e.a+l*e.c),e.ty=r._y-(h*e.b+l*e.d)}set alpha(t){t!==this.localAlpha&&(this.localAlpha=t,this._updateFlags|=xn,this._onUpdate())}get alpha(){return this.localAlpha}set tint(t){const s=Y.shared.setValue(t??16777215).toBgrNumber();s!==this.localColor&&(this.localColor=s,this._updateFlags|=xn,this._onUpdate())}get tint(){const t=this.localColor;return((t&255)<<16)+(t&65280)+(t>>16&255)}set blendMode(t){this.localBlendMode!==t&&(this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._updateFlags|=ko,this.localBlendMode=t,this._onUpdate())}get blendMode(){return this.localBlendMode}get visible(){return!!(this.localDisplayStatus&2)}set visible(t){const e=t?2:0;(this.localDisplayStatus&2)!==e&&(this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._updateFlags|=Ni,this.localDisplayStatus^=2,this._onUpdate())}get culled(){return!(this.localDisplayStatus&4)}set culled(t){const e=t?0:4;(this.localDisplayStatus&4)!==e&&(this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._updateFlags|=Ni,this.localDisplayStatus^=4,this._onUpdate())}get renderable(){return!!(this.localDisplayStatus&1)}set renderable(t){const e=t?1:0;(this.localDisplayStatus&1)!==e&&(this._updateFlags|=Ni,this.localDisplayStatus^=1,this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._onUpdate())}get isRenderable(){return this.localDisplayStatus===7&&this.groupAlpha>0}destroy(t=!1){var n;if(this.destroyed)return;this.destroyed=!0;const e=this.removeChildren(0,this.children.length);if(this.removeFromParent(),this.parent=null,this._maskEffect=null,this._filterEffect=null,this.effects=null,this._position=null,this._scale=null,this._pivot=null,this._skew=null,this.emit("destroyed",this),this.removeAllListeners(),typeof t=="boolean"?t:t==null?void 0:t.children)for(let r=0;r=e.minX&&s<=e.maxX&&n>=e.minY&&n<=e.maxY}destroy(t){super.destroy(t),this._bounds=null}}class $ extends Si{constructor(t=z.EMPTY){t instanceof z&&(t={texture:t});const{texture:e=z.EMPTY,anchor:s,roundPixels:n,width:r,height:a,...o}=t;super({label:"Sprite",...o}),this.renderPipeId="sprite",this.batched=!0,this._didSpriteUpdate=!1,this._sourceBounds={minX:0,maxX:1,minY:0,maxY:0},this._sourceBoundsDirty=!0,this._anchor=new pt({_onUpdate:()=>{this.onViewUpdate()}}),s?this.anchor=s:e.defaultAnchor&&(this.anchor=e.defaultAnchor),this.texture=e,this.allowChildren=!1,this.roundPixels=n??!1,r!==void 0&&(this.width=r),a!==void 0&&(this.height=a)}static from(t,e=!1){return t instanceof z?new $(t):new $(z.from(t,e))}set texture(t){t||(t=z.EMPTY);const e=this._texture;e!==t&&(e&&e.dynamic&&e.off("update",this.onViewUpdate,this),t.dynamic&&t.on("update",this.onViewUpdate,this),this._texture=t,this._width&&this._setWidth(this._width,this._texture.orig.width),this._height&&this._setHeight(this._height,this._texture.orig.height),this.onViewUpdate())}get texture(){return this._texture}get bounds(){return this._boundsDirty&&(this._updateBounds(),this._boundsDirty=!1),this._bounds}get sourceBounds(){return this._sourceBoundsDirty&&(this._updateSourceBounds(),this._sourceBoundsDirty=!1),this._sourceBounds}containsPoint(t){const e=this.sourceBounds;return t.x>=e.maxX&&t.x<=e.minX&&t.y>=e.maxY&&t.y<=e.minY}addBounds(t){const e=this._texture.trim?this.sourceBounds:this.bounds;t.addFrame(e.minX,e.minY,e.maxX,e.maxY)}onViewUpdate(){if(this._didViewChangeTick++,this._didSpriteUpdate=!0,this._sourceBoundsDirty=this._boundsDirty=!0,this.didViewUpdate)return;this.didViewUpdate=!0;const t=this.renderGroup||this.parentRenderGroup;t&&t.onChildViewUpdate(this)}_updateBounds(){so(this._bounds,this._anchor,this._texture,0)}_updateSourceBounds(){const t=this._anchor,e=this._texture,s=this._sourceBounds,{width:n,height:r}=e.orig;s.maxX=-t._x*n,s.minX=s.maxX+n,s.maxY=-t._y*r,s.minY=s.maxY+r}destroy(t=!1){if(super.destroy(t),typeof t=="boolean"?t:t==null?void 0:t.texture){const s=typeof t=="boolean"?t:t==null?void 0:t.textureSource;this._texture.destroy(s)}this._texture=null,this._bounds=null,this._sourceBounds=null,this._anchor=null}get anchor(){return this._anchor}set anchor(t){typeof t=="number"?this._anchor.set(t):this._anchor.copyFrom(t)}get width(){return Math.abs(this.scale.x)*this._texture.orig.width}set width(t){this._setWidth(t,this._texture.orig.width),this._width=t}get height(){return Math.abs(this.scale.y)*this._texture.orig.height}set height(t){this._setHeight(t,this._texture.orig.height),this._height=t}getSize(t){return t||(t={}),t.width=Math.abs(this.scale.x)*this._texture.orig.width,t.height=Math.abs(this.scale.y)*this._texture.orig.height,t}setSize(t,e){typeof t=="object"?(e=t.height??t.width,t=t.width):e??(e=t),t!==void 0&&this._setWidth(t,this._texture.orig.width),e!==void 0&&this._setHeight(e,this._texture.orig.height)}}const Bo=new Et;function _r(i,t,e){const s=Bo;i.measurable=!0,pr(i,e,s),t.addBoundsMask(s),i.measurable=!1}function br(i,t,e){const s=xe.get();i.measurable=!0;const n=Ut.get().identity(),r=Sr(i,e,n);mr(i,s,r),i.measurable=!1,t.addBoundsMask(s),Ut.return(n),xe.return(s)}function Sr(i,t,e){return i?(i!==t&&(Sr(i.parent,t,e),i.updateLocalTransform(),e.append(i.localTransform)),e):(st("Mask bounds, renderable is not inside the root container"),e)}class vr{constructor(t){this.priority=0,this.pipe="alphaMask",t!=null&&t.mask&&this.init(t.mask)}init(t){this.mask=t,this.renderMaskToTexture=!(t instanceof $),this.mask.renderable=this.renderMaskToTexture,this.mask.includeInBuild=!this.renderMaskToTexture,this.mask.measurable=!1}reset(){this.mask.measurable=!0,this.mask=null}addBounds(t,e){_r(this.mask,t,e)}addLocalBounds(t,e){br(this.mask,t,e)}containsPoint(t,e){const s=this.mask;return e(s,t)}destroy(){this.reset()}static test(t){return t instanceof $}}vr.extension=G.MaskEffect;class Cr{constructor(t){this.priority=0,this.pipe="colorMask",t!=null&&t.mask&&this.init(t.mask)}init(t){this.mask=t}destroy(){}static test(t){return typeof t=="number"}}Cr.extension=G.MaskEffect;class Tr{constructor(t){this.priority=0,this.pipe="stencilMask",t!=null&&t.mask&&this.init(t.mask)}init(t){this.mask=t,this.mask.includeInBuild=!1,this.mask.measurable=!1}reset(){this.mask.measurable=!0,this.mask.includeInBuild=!0,this.mask=null}addBounds(t,e){_r(this.mask,t,e)}addLocalBounds(t,e){br(this.mask,t,e)}containsPoint(t,e){const s=this.mask;return e(s,t)}destroy(){this.reset()}static test(t){return t instanceof tt}}Tr.extension=G.MaskEffect;const Io={createCanvas:(i,t)=>{const e=document.createElement("canvas");return e.width=i,e.height=t,e},getCanvasRenderingContext2D:()=>CanvasRenderingContext2D,getWebGLRenderingContext:()=>WebGLRenderingContext,getNavigator:()=>navigator,getBaseUrl:()=>document.baseURI??window.location.href,getFontFaceSet:()=>document.fonts,fetch:(i,t)=>fetch(i,t),parseXML:i=>new DOMParser().parseFromString(i,"text/xml")};let yn=Io;const Q={get(){return yn},set(i){yn=i}};class Ar extends Ot{constructor(t){t.resource||(t.resource=Q.get().createCanvas()),t.width||(t.width=t.resource.width,t.autoDensity||(t.width/=t.resolution)),t.height||(t.height=t.resource.height,t.autoDensity||(t.height/=t.resolution)),super(t),this.uploadMethodId="image",this.autoDensity=t.autoDensity;const e=t.resource;(this.pixelWidth!==e.width||this.pixelWidth!==e.height)&&this.resizeCanvas(),this.transparent=!!t.transparent}resizeCanvas(){this.autoDensity&&(this.resource.style.width=`${this.width}px`,this.resource.style.height=`${this.height}px`),(this.resource.width!==this.pixelWidth||this.resource.height!==this.pixelHeight)&&(this.resource.width=this.pixelWidth,this.resource.height=this.pixelHeight)}resize(t=this.width,e=this.height,s=this._resolution){const n=super.resize(t,e,s);return n&&this.resizeCanvas(),n}static test(t){return globalThis.HTMLCanvasElement&&t instanceof HTMLCanvasElement||globalThis.OffscreenCanvas&&t instanceof OffscreenCanvas}get context2D(){return this._context2D||(this._context2D=this.resource.getContext("2d"))}}Ar.extension=G.TextureSource;class Ce extends Ot{constructor(t){if(t.resource&&globalThis.HTMLImageElement&&t.resource instanceof HTMLImageElement){const e=Q.get().createCanvas(t.resource.width,t.resource.height);e.getContext("2d").drawImage(t.resource,0,0,t.resource.width,t.resource.height),t.resource=e,st("ImageSource: Image element passed, converting to canvas. Use CanvasSource instead.")}super(t),this.uploadMethodId="image",this.autoGarbageCollect=!0}static test(t){return globalThis.HTMLImageElement&&t instanceof HTMLImageElement||typeof ImageBitmap<"u"&&t instanceof ImageBitmap||globalThis.VideoFrame&&t instanceof VideoFrame}}Ce.extension=G.TextureSource;var yi=(i=>(i[i.INTERACTION=50]="INTERACTION",i[i.HIGH=25]="HIGH",i[i.NORMAL=0]="NORMAL",i[i.LOW=-25]="LOW",i[i.UTILITY=-50]="UTILITY",i))(yi||{});class Wi{constructor(t,e=null,s=0,n=!1){this.next=null,this.previous=null,this._destroyed=!1,this._fn=t,this._context=e,this.priority=s,this._once=n}match(t,e=null){return this._fn===t&&this._context===e}emit(t){this._fn&&(this._context?this._fn.call(this._context,t):this._fn(t));const e=this.next;return this._once&&this.destroy(!0),this._destroyed&&(this.next=null),e}connect(t){this.previous=t,t.next&&(t.next.previous=this),this.next=t.next,t.next=this}destroy(t=!1){this._destroyed=!0,this._fn=null,this._context=null,this.previous&&(this.previous.next=this.next),this.next&&(this.next.previous=this.previous);const e=this.next;return this.next=t?null:e,this.previous=null,e}}const Mr=class mt{constructor(){this.autoStart=!1,this.deltaTime=1,this.lastTime=-1,this.speed=1,this.started=!1,this._requestId=null,this._maxElapsedMS=100,this._minElapsedMS=0,this._protected=!1,this._lastFrame=-1,this._head=new Wi(null,null,1/0),this.deltaMS=1/mt.targetFPMS,this.elapsedMS=1/mt.targetFPMS,this._tick=t=>{this._requestId=null,this.started&&(this.update(t),this.started&&this._requestId===null&&this._head.next&&(this._requestId=requestAnimationFrame(this._tick)))}}_requestIfNeeded(){this._requestId===null&&this._head.next&&(this.lastTime=performance.now(),this._lastFrame=this.lastTime,this._requestId=requestAnimationFrame(this._tick))}_cancelIfNeeded(){this._requestId!==null&&(cancelAnimationFrame(this._requestId),this._requestId=null)}_startIfPossible(){this.started?this._requestIfNeeded():this.autoStart&&this.start()}add(t,e,s=yi.NORMAL){return this._addListener(new Wi(t,e,s))}addOnce(t,e,s=yi.NORMAL){return this._addListener(new Wi(t,e,s,!0))}_addListener(t){let e=this._head.next,s=this._head;if(!e)t.connect(s);else{for(;e;){if(t.priority>e.priority){t.connect(s);break}s=e,e=e.next}t.previous||t.connect(s)}return this._startIfPossible(),this}remove(t,e){let s=this._head.next;for(;s;)s.match(t,e)?s=s.destroy():s=s.next;return this._head.next||this._cancelIfNeeded(),this}get count(){if(!this._head)return 0;let t=0,e=this._head;for(;e=e.next;)t++;return t}start(){this.started||(this.started=!0,this._requestIfNeeded())}stop(){this.started&&(this.started=!1,this._cancelIfNeeded())}destroy(){if(!this._protected){this.stop();let t=this._head.next;for(;t;)t=t.destroy(!0);this._head.destroy(),this._head=null}}update(t=performance.now()){let e;if(t>this.lastTime){if(e=this.elapsedMS=t-this.lastTime,e>this._maxElapsedMS&&(e=this._maxElapsedMS),e*=this.speed,this._minElapsedMS){const r=t-this._lastFrame|0;if(r{var a;const t=document.createElement("canvas").getContext("webgl");if(!t)return"premultiply-alpha-on-upload";const e=await new Promise(o=>{const h=document.createElement("video");h.onloadeddata=()=>o(h),h.onerror=()=>o(null),h.autoplay=!1,h.crossOrigin="anonymous",h.preload="auto",h.src="data:video/webm;base64,GkXfo59ChoEBQveBAULygQRC84EIQoKEd2VibUKHgQJChYECGFOAZwEAAAAAAAHTEU2bdLpNu4tTq4QVSalmU6yBoU27i1OrhBZUrmtTrIHGTbuMU6uEElTDZ1OsggEXTbuMU6uEHFO7a1OsggG97AEAAAAAAABZAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAVSalmoCrXsYMPQkBNgIRMYXZmV0GETGF2ZkSJiEBEAAAAAAAAFlSua8yuAQAAAAAAAEPXgQFzxYgAAAAAAAAAAZyBACK1nIN1bmSIgQCGhVZfVlA5g4EBI+ODhAJiWgDglLCBArqBApqBAlPAgQFVsIRVuYEBElTDZ9Vzc9JjwItjxYgAAAAAAAAAAWfInEWjh0VOQ09ERVJEh49MYXZjIGxpYnZweC12cDlnyKJFo4hEVVJBVElPTkSHlDAwOjAwOjAwLjA0MDAwMDAwMAAAH0O2dcfngQCgwqGggQAAAIJJg0IAABAAFgA4JBwYSgAAICAAEb///4r+AAB1oZ2mm+6BAaWWgkmDQgAAEAAWADgkHBhKAAAgIABIQBxTu2uRu4+zgQC3iveBAfGCAXHwgQM=",h.load()});if(!e)return"premultiply-alpha-on-upload";const s=t.createTexture();t.bindTexture(t.TEXTURE_2D,s);const n=t.createFramebuffer();t.bindFramebuffer(t.FRAMEBUFFER,n),t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,s,0),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,t.NONE),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,e);const r=new Uint8Array(4);return t.readPixels(0,0,1,1,t.RGBA,t.UNSIGNED_BYTE,r),t.deleteFramebuffer(n),t.deleteTexture(s),(a=t.getExtension("WEBGL_lose_context"))==null||a.loseContext(),r[0]<=r[3]?"premultiplied-alpha":"premultiply-alpha-on-upload"})()),Hi}const vi=class Gr extends Ot{constructor(t){super(t),this.isReady=!1,this.uploadMethodId="video",t={...Gr.defaultOptions,...t},this._autoUpdate=!0,this._isConnectedToTicker=!1,this._updateFPS=t.updateFPS||0,this._msToNextUpdate=0,this.autoPlay=t.autoPlay!==!1,this.alphaMode=t.alphaMode??"premultiply-alpha-on-upload",this._videoFrameRequestCallback=this._videoFrameRequestCallback.bind(this),this._videoFrameRequestCallbackHandle=null,this._load=null,this._resolve=null,this._reject=null,this._onCanPlay=this._onCanPlay.bind(this),this._onCanPlayThrough=this._onCanPlayThrough.bind(this),this._onError=this._onError.bind(this),this._onPlayStart=this._onPlayStart.bind(this),this._onPlayStop=this._onPlayStop.bind(this),this._onSeeked=this._onSeeked.bind(this),t.autoLoad!==!1&&this.load()}updateFrame(){if(!this.destroyed){if(this._updateFPS){const t=It.shared.elapsedMS*this.resource.playbackRate;this._msToNextUpdate=Math.floor(this._msToNextUpdate-t)}(!this._updateFPS||this._msToNextUpdate<=0)&&(this._msToNextUpdate=this._updateFPS?Math.floor(1e3/this._updateFPS):0),this.isValid&&this.update()}}_videoFrameRequestCallback(){this.updateFrame(),this.destroyed?this._videoFrameRequestCallbackHandle=null:this._videoFrameRequestCallbackHandle=this.resource.requestVideoFrameCallback(this._videoFrameRequestCallback)}get isValid(){return!!this.resource.videoWidth&&!!this.resource.videoHeight}async load(){if(this._load)return this._load;const t=this.resource,e=this.options;return(t.readyState===t.HAVE_ENOUGH_DATA||t.readyState===t.HAVE_FUTURE_DATA)&&t.width&&t.height&&(t.complete=!0),t.addEventListener("play",this._onPlayStart),t.addEventListener("pause",this._onPlayStop),t.addEventListener("seeked",this._onSeeked),this._isSourceReady()?this._mediaReady():(e.preload||t.addEventListener("canplay",this._onCanPlay),t.addEventListener("canplaythrough",this._onCanPlayThrough),t.addEventListener("error",this._onError,!0)),this.alphaMode=await Pr(),this._load=new Promise((s,n)=>{this.isValid?s(this):(this._resolve=s,this._reject=n,e.preloadTimeoutMs!==void 0&&(this._preloadTimeout=setTimeout(()=>{this._onError(new ErrorEvent(`Preload exceeded timeout of ${e.preloadTimeoutMs}ms`))})),t.load())}),this._load}_onError(t){this.resource.removeEventListener("error",this._onError,!0),this.emit("error",t),this._reject&&(this._reject(t),this._reject=null,this._resolve=null)}_isSourcePlaying(){const t=this.resource;return!t.paused&&!t.ended}_isSourceReady(){return this.resource.readyState>2}_onPlayStart(){this.isValid||this._mediaReady(),this._configureAutoUpdate()}_onPlayStop(){this._configureAutoUpdate()}_onSeeked(){this._autoUpdate&&!this._isSourcePlaying()&&(this._msToNextUpdate=0,this.updateFrame(),this._msToNextUpdate=0)}_onCanPlay(){this.resource.removeEventListener("canplay",this._onCanPlay),this._mediaReady()}_onCanPlayThrough(){this.resource.removeEventListener("canplaythrough",this._onCanPlay),this._preloadTimeout&&(clearTimeout(this._preloadTimeout),this._preloadTimeout=void 0),this._mediaReady()}_mediaReady(){const t=this.resource;this.isValid&&(this.isReady=!0,this.resize(t.videoWidth,t.videoHeight)),this._msToNextUpdate=0,this.updateFrame(),this._msToNextUpdate=0,this._resolve&&(this._resolve(this),this._resolve=null,this._reject=null),this._isSourcePlaying()?this._onPlayStart():this.autoPlay&&this.resource.play()}destroy(){this._configureAutoUpdate();const t=this.resource;t&&(t.removeEventListener("play",this._onPlayStart),t.removeEventListener("pause",this._onPlayStop),t.removeEventListener("seeked",this._onSeeked),t.removeEventListener("canplay",this._onCanPlay),t.removeEventListener("canplaythrough",this._onCanPlayThrough),t.removeEventListener("error",this._onError,!0),t.pause(),t.src="",t.load()),super.destroy()}get autoUpdate(){return this._autoUpdate}set autoUpdate(t){t!==this._autoUpdate&&(this._autoUpdate=t,this._configureAutoUpdate())}get updateFPS(){return this._updateFPS}set updateFPS(t){t!==this._updateFPS&&(this._updateFPS=t,this._configureAutoUpdate())}_configureAutoUpdate(){this._autoUpdate&&this._isSourcePlaying()?!this._updateFPS&&this.resource.requestVideoFrameCallback?(this._isConnectedToTicker&&(It.shared.remove(this.updateFrame,this),this._isConnectedToTicker=!1,this._msToNextUpdate=0),this._videoFrameRequestCallbackHandle===null&&(this._videoFrameRequestCallbackHandle=this.resource.requestVideoFrameCallback(this._videoFrameRequestCallback))):(this._videoFrameRequestCallbackHandle!==null&&(this.resource.cancelVideoFrameCallback(this._videoFrameRequestCallbackHandle),this._videoFrameRequestCallbackHandle=null),this._isConnectedToTicker||(It.shared.add(this.updateFrame,this),this._isConnectedToTicker=!0,this._msToNextUpdate=0)):(this._videoFrameRequestCallbackHandle!==null&&(this.resource.cancelVideoFrameCallback(this._videoFrameRequestCallbackHandle),this._videoFrameRequestCallbackHandle=null),this._isConnectedToTicker&&(It.shared.remove(this.updateFrame,this),this._isConnectedToTicker=!1,this._msToNextUpdate=0))}static test(t){return globalThis.HTMLVideoElement&&t instanceof HTMLVideoElement}};vi.extension=G.TextureSource;vi.defaultOptions={...Ot.defaultOptions,autoLoad:!0,autoPlay:!0,updateFPS:0,crossorigin:!0,loop:!1,muted:!0,playsinline:!0,preload:!1};vi.MIME_TYPES={ogv:"video/ogg",mov:"video/quicktime",m4v:"video/mp4"};let fi=vi;const vt=(i,t,e=!1)=>(Array.isArray(i)||(i=[i]),t?i.map(s=>typeof s=="string"||e?t(s):s):i);class Eo{constructor(){this._parsers=[],this._cache=new Map,this._cacheMap=new Map}reset(){this._cacheMap.clear(),this._cache.clear()}has(t){return this._cache.has(t)}get(t){const e=this._cache.get(t);return e||st(`[Assets] Asset id ${t} was not found in the Cache`),e}set(t,e){const s=vt(t);let n;for(let h=0;h{r.set(h,e)});const a=[...r.keys()],o={cacheKeys:a,keys:s};s.forEach(h=>{this._cacheMap.set(h,o)}),a.forEach(h=>{const l=n?n[h]:e;this._cache.has(h)&&this._cache.get(h)!==l&&st("[Cache] already has key:",h),this._cache.set(h,r.get(h))})}remove(t){if(!this._cacheMap.has(t)){st(`[Assets] Asset id ${t} was not found in the Cache`);return}const e=this._cacheMap.get(t);e.cacheKeys.forEach(n=>{this._cache.delete(n)}),e.keys.forEach(n=>{this._cacheMap.delete(n)})}get parsers(){return this._parsers}}const q=new Eo,cs=[];dt.handleByList(G.TextureSource,cs);function kr(i={}){const t=i&&i.resource,e=t?i.resource:i,s=t?i:{resource:i};for(let n=0;n{q.has(s)&&q.remove(s)}),t||q.set(s,r),r}function Fo(i,t=!1){return typeof i=="string"?q.get(i):i instanceof Ot?new z({source:i}):Ro(i,t)}z.from=Fo;Ot.from=kr;dt.add(vr,Cr,Tr,fi,Ce,Ar,Gs);var Xt=(i=>(i[i.Low=0]="Low",i[i.Normal=1]="Normal",i[i.High=2]="High",i))(Xt||{});function St(i){if(typeof i!="string")throw new TypeError(`Path must be a string. Received ${JSON.stringify(i)}`)}function Ie(i){return i.split("?")[0].split("#")[0]}function Lo(i){return i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Do(i,t,e){return i.replace(new RegExp(Lo(t),"g"),e)}function zo(i,t){let e="",s=0,n=-1,r=0,a=-1;for(let o=0;o<=i.length;++o){if(o2){const h=e.lastIndexOf("/");if(h!==e.length-1){h===-1?(e="",s=0):(e=e.slice(0,h),s=e.length-1-e.lastIndexOf("/")),n=o,r=0;continue}}else if(e.length===2||e.length===1){e="",s=0,n=o,r=0;continue}}}else e.length>0?e+=`/${i.slice(n+1,o)}`:e=i.slice(n+1,o),s=o-n-1;n=o,r=0}else a===46&&r!==-1?++r:r=-1}return e}const xt={toPosix(i){return Do(i,"\\","/")},isUrl(i){return/^https?:/.test(this.toPosix(i))},isDataUrl(i){return/^data:([a-z]+\/[a-z0-9-+.]+(;[a-z0-9-.!#$%*+.{}|~`]+=[a-z0-9-.!#$%*+.{}()_|~`]+)*)?(;base64)?,([a-z0-9!$&',()*+;=\-._~:@\/?%\s<>]*?)$/i.test(i)},isBlobUrl(i){return i.startsWith("blob:")},hasProtocol(i){return/^[^/:]+:/.test(this.toPosix(i))},getProtocol(i){St(i),i=this.toPosix(i);const t=/^file:\/\/\//.exec(i);if(t)return t[0];const e=/^[^/:]+:\/{0,2}/.exec(i);return e?e[0]:""},toAbsolute(i,t,e){if(St(i),this.isDataUrl(i)||this.isBlobUrl(i))return i;const s=Ie(this.toPosix(t??Q.get().getBaseUrl())),n=Ie(this.toPosix(e??this.rootname(s)));return i=this.toPosix(i),i.startsWith("/")?xt.join(n,i.slice(1)):this.isAbsolute(i)?i:this.join(s,i)},normalize(i){if(St(i),i.length===0)return".";if(this.isDataUrl(i)||this.isBlobUrl(i))return i;i=this.toPosix(i);let t="";const e=i.startsWith("/");this.hasProtocol(i)&&(t=this.rootname(i),i=i.slice(t.length));const s=i.endsWith("/");return i=zo(i),i.length>0&&s&&(i+="/"),e?`/${i}`:t+i},isAbsolute(i){return St(i),i=this.toPosix(i),this.hasProtocol(i)?!0:i.startsWith("/")},join(...i){if(i.length===0)return".";let t;for(let e=0;e0)if(t===void 0)t=s;else{const n=i[e-1]??"";this.joinExtensions.includes(this.extname(n).toLowerCase())?t+=`/../${s}`:t+=`/${s}`}}return t===void 0?".":this.normalize(t)},dirname(i){if(St(i),i.length===0)return".";i=this.toPosix(i);let t=i.charCodeAt(0);const e=t===47;let s=-1,n=!0;const r=this.getProtocol(i),a=i;i=i.slice(r.length);for(let o=i.length-1;o>=1;--o)if(t=i.charCodeAt(o),t===47){if(!n){s=o;break}}else n=!1;return s===-1?e?"/":this.isUrl(a)?r+i:r:e&&s===1?"//":r+i.slice(0,s)},rootname(i){St(i),i=this.toPosix(i);let t="";if(i.startsWith("/")?t="/":t=this.getProtocol(i),this.isUrl(i)){const e=i.indexOf("/",t.length);e!==-1?t=i.slice(0,e):t=i,t.endsWith("/")||(t+="/")}return t},basename(i,t){St(i),t&&St(t),i=Ie(this.toPosix(i));let e=0,s=-1,n=!0,r;if(t!==void 0&&t.length>0&&t.length<=i.length){if(t.length===i.length&&t===i)return"";let a=t.length-1,o=-1;for(r=i.length-1;r>=0;--r){const h=i.charCodeAt(r);if(h===47){if(!n){e=r+1;break}}else o===-1&&(n=!1,o=r+1),a>=0&&(h===t.charCodeAt(a)?--a===-1&&(s=r):(a=-1,s=o))}return e===s?s=o:s===-1&&(s=i.length),i.slice(e,s)}for(r=i.length-1;r>=0;--r)if(i.charCodeAt(r)===47){if(!n){e=r+1;break}}else s===-1&&(n=!1,s=r+1);return s===-1?"":i.slice(e,s)},extname(i){St(i),i=Ie(this.toPosix(i));let t=-1,e=0,s=-1,n=!0,r=0;for(let a=i.length-1;a>=0;--a){const o=i.charCodeAt(a);if(o===47){if(!n){e=a+1;break}continue}s===-1&&(n=!1,s=a+1),o===46?t===-1?t=a:r!==1&&(r=1):t!==-1&&(r=-1)}return t===-1||s===-1||r===0||r===1&&t===s-1&&t===e+1?"":i.slice(t,s)},parse(i){St(i);const t={root:"",dir:"",base:"",ext:"",name:""};if(i.length===0)return t;i=Ie(this.toPosix(i));let e=i.charCodeAt(0);const s=this.isAbsolute(i);let n;t.root=this.rootname(i),s||this.hasProtocol(i)?n=1:n=0;let r=-1,a=0,o=-1,h=!0,l=i.length-1,c=0;for(;l>=n;--l){if(e=i.charCodeAt(l),e===47){if(!h){a=l+1;break}continue}o===-1&&(h=!1,o=l+1),e===46?r===-1?r=l:c!==1&&(c=1):r!==-1&&(c=-1)}return r===-1||o===-1||c===0||c===1&&r===o-1&&r===a+1?o!==-1&&(a===0&&s?t.base=t.name=i.slice(1,o):t.base=t.name=i.slice(a,o)):(a===0&&s?(t.name=i.slice(1,r),t.base=i.slice(1,o)):(t.name=i.slice(a,r),t.base=i.slice(a,o)),t.ext=i.slice(r,o)),t.dir=this.dirname(i),t},sep:"/",delimiter:":",joinExtensions:[".html"]};function Br(i,t,e,s,n){const r=t[e];for(let a=0;a{const a=r.substring(1,r.length-1).split(",");n.push(a)}),Br(i,n,0,e,s)}else s.push(i);return s}const wi=i=>!Array.isArray(i);class Te{constructor(){this._defaultBundleIdentifierOptions={connector:"-",createBundleAssetId:(t,e)=>`${t}${this._bundleIdConnector}${e}`,extractAssetIdFromBundle:(t,e)=>e.replace(`${t}${this._bundleIdConnector}`,"")},this._bundleIdConnector=this._defaultBundleIdentifierOptions.connector,this._createBundleAssetId=this._defaultBundleIdentifierOptions.createBundleAssetId,this._extractAssetIdFromBundle=this._defaultBundleIdentifierOptions.extractAssetIdFromBundle,this._assetMap={},this._preferredOrder=[],this._parsers=[],this._resolverHash={},this._bundles={}}setBundleIdentifier(t){if(this._bundleIdConnector=t.connector??this._bundleIdConnector,this._createBundleAssetId=t.createBundleAssetId??this._createBundleAssetId,this._extractAssetIdFromBundle=t.extractAssetIdFromBundle??this._extractAssetIdFromBundle,this._extractAssetIdFromBundle("foo",this._createBundleAssetId("foo","bar"))!=="bar")throw new Error("[Resolver] GenerateBundleAssetId are not working correctly")}prefer(...t){t.forEach(e=>{this._preferredOrder.push(e),e.priority||(e.priority=Object.keys(e.params))}),this._resolverHash={}}set basePath(t){this._basePath=t}get basePath(){return this._basePath}set rootPath(t){this._rootPath=t}get rootPath(){return this._rootPath}get parsers(){return this._parsers}reset(){this.setBundleIdentifier(this._defaultBundleIdentifierOptions),this._assetMap={},this._preferredOrder=[],this._resolverHash={},this._rootPath=null,this._basePath=null,this._manifest=null,this._bundles={},this._defaultSearchParams=null}setDefaultSearchParams(t){if(typeof t=="string")this._defaultSearchParams=t;else{const e=t;this._defaultSearchParams=Object.keys(e).map(s=>`${encodeURIComponent(s)}=${encodeURIComponent(e[s])}`).join("&")}}getAlias(t){const{alias:e,src:s}=t;return vt(e||s,r=>typeof r=="string"?r:Array.isArray(r)?r.map(a=>(a==null?void 0:a.src)??a):r!=null&&r.src?r.src:r,!0)}addManifest(t){this._manifest&&st("[Resolver] Manifest already exists, this will be overwritten"),this._manifest=t,t.bundles.forEach(e=>{this.addBundle(e.name,e.assets)})}addBundle(t,e){const s=[];let n=e;Array.isArray(e)||(n=Object.entries(e).map(([r,a])=>typeof a=="string"||Array.isArray(a)?{alias:r,src:a}:{alias:r,...a})),n.forEach(r=>{const a=r.src,o=r.alias;let h;if(typeof o=="string"){const l=this._createBundleAssetId(t,o);s.push(l),h=[o,l]}else{const l=o.map(c=>this._createBundleAssetId(t,c));s.push(...l),h=[...o,...l]}this.add({...r,alias:h,src:a})}),this._bundles[t]=s}add(t){const e=[];Array.isArray(t)?e.push(...t):e.push(t);let s;s=r=>{this.hasKey(r)&&st(`[Resolver] already has key: ${r} overwriting`)},vt(e).forEach(r=>{const{src:a}=r;let{data:o,format:h,loadParser:l}=r;const c=vt(a).map(g=>typeof g=="string"?Uo(g):Array.isArray(g)?g:[g]),d=this.getAlias(r);Array.isArray(d)?d.forEach(s):s(d);const f=[];c.forEach(g=>{g.forEach(m=>{let y={};if(typeof m!="object"){y.src=m;for(let x=0;x{this._assetMap[g]=f})})}resolveBundle(t){const e=wi(t);t=vt(t);const s={};return t.forEach(n=>{const r=this._bundles[n];if(r){const a=this.resolve(r),o={};for(const h in a){const l=a[h];o[this._extractAssetIdFromBundle(n,h)]=l}s[n]=o}}),e?s[t[0]]:s}resolveUrl(t){const e=this.resolve(t);if(typeof t!="string"){const s={};for(const n in e)s[n]=e[n].src;return s}return e.src}resolve(t){const e=wi(t);t=vt(t);const s={};return t.forEach(n=>{if(!this._resolverHash[n])if(this._assetMap[n]){let r=this._assetMap[n];const a=this._getPreferredOrder(r);a==null||a.priority.forEach(o=>{a.params[o].forEach(h=>{const l=r.filter(c=>c[o]?c[o]===h:!1);l.length&&(r=l)})}),this._resolverHash[n]=r[0]}else this._resolverHash[n]=this._buildResolvedAsset({alias:[n],src:n},{});s[n]=this._resolverHash[n]}),e?s[t[0]]:s}hasKey(t){return!!this._assetMap[t]}hasBundle(t){return!!this._bundles[t]}_getPreferredOrder(t){for(let e=0;er.params.format.includes(s.format));if(n)return n}return this._preferredOrder[0]}_appendDefaultSearchParams(t){if(!this._defaultSearchParams)return t;const e=/\?/.test(t)?"&":"?";return`${t}${e}${this._defaultSearchParams}`}_buildResolvedAsset(t,e){const{aliases:s,data:n,loadParser:r,format:a}=e;return(this._basePath||this._rootPath)&&(t.src=xt.toAbsolute(t.src,this._basePath,this._rootPath)),t.alias=s??t.alias??[t.src],t.src=this._appendDefaultSearchParams(t.src),t.data={...n||{},...t.data},t.loadParser=r??t.loadParser,t.format=a??t.format??Oo(t.src),t}}Te.RETINA_PREFIX=/@([0-9\.]+)x/;function Oo(i){return i.split(".").pop().split("?").shift().split("#").shift()}const ds=(i,t)=>{const e=t.split("?")[1];return e&&(i+=`?${e}`),i},Ir=class ze{constructor(t,e){this.linkedSheets=[],this._texture=t instanceof z?t:null,this.textureSource=t.source,this.textures={},this.animations={},this.data=e;const s=parseFloat(e.meta.scale);s?(this.resolution=s,t.source.resolution=this.resolution):this.resolution=t.source._resolution,this._frames=this.data.frames,this._frameKeys=Object.keys(this._frames),this._batchIndex=0,this._callback=null}parse(){return new Promise(t=>{this._callback=t,this._batchIndex=0,this._frameKeys.length<=ze.BATCH_SIZE?(this._processFrames(0),this._processAnimations(),this._parseComplete()):this._nextBatch()})}_processFrames(t){let e=t;const s=ze.BATCH_SIZE;for(;e-t{this._batchIndex*ze.BATCH_SIZE{s[n]=t}),Object.keys(t.textures).forEach(n=>{s[n]=t.textures[n]}),!e){const n=xt.dirname(i[0]);t.linkedSheets.forEach((r,a)=>{const o=Er([`${n}/${t.data.meta.related_multi_packs[a]}`],r,!0);Object.assign(s,o)})}return s}const Wo={extension:G.Asset,cache:{test:i=>i instanceof wn,getCacheableAssets:(i,t)=>Er(i,t,!1)},resolver:{extension:{type:G.ResolveParser,name:"resolveSpritesheet"},test:i=>{const e=i.split("?")[0].split("."),s=e.pop(),n=e.pop();return s==="json"&&No.includes(n)},parse:i=>{var e;const t=i.split(".");return{resolution:parseFloat(((e=Te.RETINA_PREFIX.exec(i))==null?void 0:e[1])??"1"),format:t[t.length-2],src:i}}},loader:{name:"spritesheetLoader",extension:{type:G.LoadParser,priority:Xt.Normal,name:"spritesheetLoader"},async testParse(i,t){return xt.extname(t.src).toLowerCase()===".json"&&!!i.frames},async parse(i,t,e){var l,c;const{texture:s,imageFilename:n}=(t==null?void 0:t.data)??{};let r=xt.dirname(t.src);r&&r.lastIndexOf("/")!==r.length-1&&(r+="/");let a;if(s instanceof z)a=s;else{const d=ds(r+(n??i.meta.image),t.src);a=(await e.load([d]))[d]}const o=new wn(a.source,i);await o.parse();const h=(l=i==null?void 0:i.meta)==null?void 0:l.related_multi_packs;if(Array.isArray(h)){const d=[];for(const g of h){if(typeof g!="string")continue;let m=r+g;(c=t.data)!=null&&c.ignoreMultiPack||(m=ds(m,t.src),d.push(e.load({src:m,data:{ignoreMultiPack:!0}})))}const f=await Promise.all(d);o.linkedSheets=f,f.forEach(g=>{g.linkedSheets=[o].concat(o.linkedSheets.filter(m=>m!==g))})}return o},async unload(i,t,e){await e.unload(i.textureSource._sourceOrigin),i.destroy(!1)}}};dt.add(Wo);const $i=Object.create(null),_n=Object.create(null);function Bs(i,t){let e=_n[i];return e===void 0&&($i[t]===void 0&&($i[t]=1),_n[i]=e=$i[t]++),e}let he;function Rr(){return(!he||he!=null&&he.isContextLost())&&(he=Q.get().createCanvas().getContext("webgl",{})),he}let ri;function Ho(){if(!ri){ri="mediump";const i=Rr();i&&i.getShaderPrecisionFormat&&(ri=i.getShaderPrecisionFormat(i.FRAGMENT_SHADER,i.HIGH_FLOAT).precision?"highp":"mediump")}return ri}function $o(i,t,e){return t?i:e?(i=i.replace("out vec4 finalColor;",""),` +Deprecated since v${i}`),console.warn(s))),sn[t]=!0}const ar=()=>{};function nn(i){return i+=i===0?1:0,--i,i|=i>>>1,i|=i>>>2,i|=i>>>4,i|=i>>>8,i|=i>>>16,i+1}function rn(i){return!(i&i-1)&&!!i}function Ja(i){const t={};for(const e in i)i[e]!==void 0&&(t[e]=i[e]);return t}const an=Object.create(null);function to(i){const t=an[i];return t===void 0&&(an[i]=nt("resource")),t}const or=class hr extends gt{constructor(t={}){super(),this._resourceType="textureSampler",this._touched=0,this._maxAnisotropy=1,this.destroyed=!1,t={...hr.defaultOptions,...t},this.addressMode=t.addressMode,this.addressModeU=t.addressModeU??this.addressModeU,this.addressModeV=t.addressModeV??this.addressModeV,this.addressModeW=t.addressModeW??this.addressModeW,this.scaleMode=t.scaleMode,this.magFilter=t.magFilter??this.magFilter,this.minFilter=t.minFilter??this.minFilter,this.mipmapFilter=t.mipmapFilter??this.mipmapFilter,this.lodMinClamp=t.lodMinClamp,this.lodMaxClamp=t.lodMaxClamp,this.compare=t.compare,this.maxAnisotropy=t.maxAnisotropy??1}set addressMode(t){this.addressModeU=t,this.addressModeV=t,this.addressModeW=t}get addressMode(){return this.addressModeU}set wrapMode(t){U(O,"TextureStyle.wrapMode is now TextureStyle.addressMode"),this.addressMode=t}get wrapMode(){return this.addressMode}set scaleMode(t){this.magFilter=t,this.minFilter=t,this.mipmapFilter=t}get scaleMode(){return this.magFilter}set maxAnisotropy(t){this._maxAnisotropy=Math.min(t,16),this._maxAnisotropy>1&&(this.scaleMode="linear")}get maxAnisotropy(){return this._maxAnisotropy}get _resourceId(){return this._sharedResourceId||this._generateResourceId()}update(){this.emit("change",this),this._sharedResourceId=null}_generateResourceId(){const t=`${this.addressModeU}-${this.addressModeV}-${this.addressModeW}-${this.magFilter}-${this.minFilter}-${this.mipmapFilter}-${this.lodMinClamp}-${this.lodMaxClamp}-${this.compare}-${this._maxAnisotropy}`;return this._sharedResourceId=to(t),this._resourceId}destroy(){this.destroyed=!0,this.emit("destroy",this),this.emit("change",this),this.removeAllListeners()}};or.defaultOptions={addressMode:"clamp-to-edge",scaleMode:"linear"};let eo=or;const lr=class cr extends gt{constructor(t={}){super(),this.options=t,this.uid=nt("textureSource"),this._resourceType="textureSource",this._resourceId=nt("resource"),this.uploadMethodId="unknown",this._resolution=1,this.pixelWidth=1,this.pixelHeight=1,this.width=1,this.height=1,this.sampleCount=1,this.mipLevelCount=1,this.autoGenerateMipmaps=!1,this.format="rgba8unorm",this.dimension="2d",this.antialias=!1,this._touched=0,this._batchTick=-1,this._textureBindLocation=-1,t={...cr.defaultOptions,...t},this.label=t.label??"",this.resource=t.resource,this.autoGarbageCollect=t.autoGarbageCollect,this._resolution=t.resolution,t.width?this.pixelWidth=t.width*this._resolution:this.pixelWidth=this.resource?this.resourceWidth??1:1,t.height?this.pixelHeight=t.height*this._resolution:this.pixelHeight=this.resource?this.resourceHeight??1:1,this.width=this.pixelWidth/this._resolution,this.height=this.pixelHeight/this._resolution,this.format=t.format,this.dimension=t.dimensions,this.mipLevelCount=t.mipLevelCount,this.autoGenerateMipmaps=t.autoGenerateMipmaps,this.sampleCount=t.sampleCount,this.antialias=t.antialias,this.alphaMode=t.alphaMode,this.style=new eo(Ja(t)),this.destroyed=!1,this._refreshPOT()}get source(){return this}get style(){return this._style}set style(t){var e,s;this.style!==t&&((e=this._style)==null||e.off("change",this._onStyleChange,this),this._style=t,(s=this._style)==null||s.on("change",this._onStyleChange,this),this._onStyleChange())}get addressMode(){return this._style.addressMode}set addressMode(t){this._style.addressMode=t}get repeatMode(){return this._style.addressMode}set repeatMode(t){this._style.addressMode=t}get magFilter(){return this._style.magFilter}set magFilter(t){this._style.magFilter=t}get minFilter(){return this._style.minFilter}set minFilter(t){this._style.minFilter=t}get mipmapFilter(){return this._style.mipmapFilter}set mipmapFilter(t){this._style.mipmapFilter=t}get lodMinClamp(){return this._style.lodMinClamp}set lodMinClamp(t){this._style.lodMinClamp=t}get lodMaxClamp(){return this._style.lodMaxClamp}set lodMaxClamp(t){this._style.lodMaxClamp=t}_onStyleChange(){this.emit("styleChange",this)}update(){if(this.resource){const t=this._resolution;if(this.resize(this.resourceWidth/t,this.resourceHeight/t))return}this.emit("update",this)}destroy(){this.destroyed=!0,this.emit("destroy",this),this.emit("change",this),this._style&&(this._style.destroy(),this._style=null),this.uploadMethodId=null,this.resource=null,this.removeAllListeners()}unload(){this._resourceId=nt("resource"),this.emit("change",this),this.emit("unload",this)}get resourceWidth(){const{resource:t}=this;return t.naturalWidth||t.videoWidth||t.displayWidth||t.width}get resourceHeight(){const{resource:t}=this;return t.naturalHeight||t.videoHeight||t.displayHeight||t.height}get resolution(){return this._resolution}set resolution(t){this._resolution!==t&&(this._resolution=t,this.width=this.pixelWidth/t,this.height=this.pixelHeight/t)}resize(t,e,s){s=s||this._resolution,t=t||this.width,e=e||this.height;const n=Math.round(t*s),r=Math.round(e*s);return this.width=n/s,this.height=r/s,this._resolution=s,this.pixelWidth===n&&this.pixelHeight===r?!1:(this._refreshPOT(),this.pixelWidth=n,this.pixelHeight=r,this.emit("resize",this),this._resourceId=nt("resource"),this.emit("change",this),!0)}updateMipmaps(){this.autoGenerateMipmaps&&this.mipLevelCount>1&&this.emit("updateMipmaps",this)}set wrapMode(t){this._style.wrapMode=t}get wrapMode(){return this._style.wrapMode}set scaleMode(t){this._style.scaleMode=t}get scaleMode(){return this._style.scaleMode}_refreshPOT(){this.isPowerOfTwo=rn(this.pixelWidth)&&rn(this.pixelHeight)}static test(t){throw new Error("Unimplemented")}};lr.defaultOptions={resolution:1,format:"bgra8unorm",alphaMode:"premultiply-alpha-on-upload",dimensions:"2d",mipLevelCount:1,autoGenerateMipmaps:!1,sampleCount:1,antialias:!1,autoGarbageCollect:!1};let Nt=lr;class ks extends Nt{constructor(t){const e=t.resource||new Float32Array(t.width*t.height*4);let s=t.format;s||(e instanceof Float32Array?s="rgba32float":e instanceof Int32Array||e instanceof Uint32Array?s="rgba32uint":e instanceof Int16Array||e instanceof Uint16Array?s="rgba16uint":(e instanceof Int8Array,s="bgra8unorm")),super({...t,resource:e,format:s}),this.uploadMethodId="buffer"}static test(t){return t instanceof Int8Array||t instanceof Uint8Array||t instanceof Uint8ClampedArray||t instanceof Int16Array||t instanceof Uint16Array||t instanceof Int32Array||t instanceof Uint32Array||t instanceof Float32Array}}ks.extension=G.TextureSource;const on=new H;class io{constructor(t,e){this.mapCoord=new H,this.uClampFrame=new Float32Array(4),this.uClampOffset=new Float32Array(2),this._textureID=-1,this._updateID=0,this.clampOffset=0,typeof e>"u"?this.clampMargin=t.width<10?0:.5:this.clampMargin=e,this.isSimple=!1,this.texture=t}get texture(){return this._texture}set texture(t){var e;this.texture!==t&&((e=this._texture)==null||e.removeListener("update",this.update,this),this._texture=t,this._texture.addListener("update",this.update,this),this.update())}multiplyUvs(t,e){e===void 0&&(e=t);const s=this.mapCoord;for(let n=0;nthis.maxX||this.minY>this.maxY}get rectangle(){this._rectangle||(this._rectangle=new I);const t=this._rectangle;return this.minX>this.maxX||this.minY>this.maxY?(t.x=0,t.y=0,t.width=0,t.height=0):t.copyFromBounds(this),t}clear(){return this.minX=1/0,this.minY=1/0,this.maxX=-1/0,this.maxY=-1/0,this.matrix=hn,this}set(t,e,s,n){this.minX=t,this.minY=e,this.maxX=s,this.maxY=n}addFrame(t,e,s,n,r){r||(r=this.matrix);const a=r.a,o=r.b,h=r.c,l=r.d,c=r.tx,d=r.ty;let f=this.minX,g=this.minY,m=this.maxX,y=this.maxY,x=a*t+h*e+c,w=o*t+l*e+d;xm&&(m=x),w>y&&(y=w),x=a*s+h*e+c,w=o*s+l*e+d,xm&&(m=x),w>y&&(y=w),x=a*t+h*n+c,w=o*t+l*n+d,xm&&(m=x),w>y&&(y=w),x=a*s+h*n+c,w=o*s+l*n+d,xm&&(m=x),w>y&&(y=w),this.minX=f,this.minY=g,this.maxX=m,this.maxY=y}addRect(t,e){this.addFrame(t.x,t.y,t.x+t.width,t.y+t.height,e)}addBounds(t,e){this.addFrame(t.minX,t.minY,t.maxX,t.maxY,e)}addBoundsMask(t){this.minX=this.minX>t.minX?this.minX:t.minX,this.minY=this.minY>t.minY?this.minY:t.minY,this.maxX=this.maxXthis.maxX?f:this.maxX,this.maxY=g>this.maxY?g:this.maxY,f=a*e+h*r+c,g=o*e+l*r+d,this.minX=fthis.maxX?f:this.maxX,this.maxY=g>this.maxY?g:this.maxY,f=a*n+h*r+c,g=o*n+l*r+d,this.minX=fthis.maxX?f:this.maxX,this.maxY=g>this.maxY?g:this.maxY}fit(t){return this.minXt.right&&(this.maxX=t.right),this.minYt.bottom&&(this.maxY=t.bottom),this}fitBounds(t,e,s,n){return this.minXe&&(this.maxX=e),this.minYn&&(this.maxY=n),this}pad(t,e=t){return this.minX-=t,this.maxX+=t,this.minY-=e,this.maxY+=e,this}ceil(){return this.minX=Math.floor(this.minX),this.minY=Math.floor(this.minY),this.maxX=Math.ceil(this.maxX),this.maxY=Math.ceil(this.maxY),this}clone(){return new Et(this.minX,this.minY,this.maxX,this.maxY)}scale(t,e=t){return this.minX*=t,this.minY*=e,this.maxX*=t,this.maxY*=e,this}get x(){return this.minX}set x(t){const e=this.maxX-this.minX;this.minX=t,this.maxX=t+e}get y(){return this.minY}set y(t){const e=this.maxY-this.minY;this.minY=t,this.maxY=t+e}get width(){return this.maxX-this.minX}set width(t){this.maxX=this.minX+t}get height(){return this.maxY-this.minY}set height(t){this.maxY=this.minY+t}get left(){return this.minX}get right(){return this.maxX}get top(){return this.minY}get bottom(){return this.maxY}get isPositive(){return this.maxX-this.minX>0&&this.maxY-this.minY>0}get isValid(){return this.minX+this.minY!==1/0}addVertexData(t,e,s,n){let r=this.minX,a=this.minY,o=this.maxX,h=this.maxY;n||(n=this.matrix);const l=n.a,c=n.b,d=n.c,f=n.d,g=n.tx,m=n.ty;for(let y=e;yo?_:o,h=b>h?b:h}this.minX=r,this.minY=a,this.maxX=o,this.maxY=h}containsPoint(t,e){return this.minX<=t&&this.minY<=e&&this.maxX>=t&&this.maxY>=e}toString(){return`[pixi.js:Bounds minX=${this.minX} minY=${this.minY} maxX=${this.maxX} maxY=${this.maxY} width=${this.width} height=${this.height}]`}}var no={grad:.9,turn:360,rad:360/(2*Math.PI)},Ft=function(i){return typeof i=="string"?i.length>0:typeof i=="number"},at=function(i,t,e){return t===void 0&&(t=0),e===void 0&&(e=Math.pow(10,t)),Math.round(e*i)/e+0},wt=function(i,t,e){return t===void 0&&(t=0),e===void 0&&(e=1),i>e?e:i>t?i:t},dr=function(i){return(i=isFinite(i)?i%360:0)>0?i:i+360},ln=function(i){return{r:wt(i.r,0,255),g:wt(i.g,0,255),b:wt(i.b,0,255),a:wt(i.a)}},Fi=function(i){return{r:at(i.r),g:at(i.g),b:at(i.b),a:at(i.a,3)}},ro=/^#([0-9a-f]{3,8})$/i,ni=function(i){var t=i.toString(16);return t.length<2?"0"+t:t},ur=function(i){var t=i.r,e=i.g,s=i.b,n=i.a,r=Math.max(t,e,s),a=r-Math.min(t,e,s),o=a?r===t?(e-s)/a:r===e?2+(s-t)/a:4+(t-e)/a:0;return{h:60*(o<0?o+6:o),s:r?a/r*100:0,v:r/255*100,a:n}},fr=function(i){var t=i.h,e=i.s,s=i.v,n=i.a;t=t/360*6,e/=100,s/=100;var r=Math.floor(t),a=s*(1-e),o=s*(1-(t-r)*e),h=s*(1-(1-t+r)*e),l=r%6;return{r:255*[s,o,a,a,h,s][l],g:255*[h,s,s,o,a,a][l],b:255*[a,a,h,s,s,o][l],a:n}},cn=function(i){return{h:dr(i.h),s:wt(i.s,0,100),l:wt(i.l,0,100),a:wt(i.a)}},dn=function(i){return{h:at(i.h),s:at(i.s),l:at(i.l),a:at(i.a,3)}},un=function(i){return fr((e=(t=i).s,{h:t.h,s:(e*=((s=t.l)<50?s:100-s)/100)>0?2*e/(s+e)*100:0,v:s+e,a:t.a}));var t,e,s},Oe=function(i){return{h:(t=ur(i)).h,s:(n=(200-(e=t.s))*(s=t.v)/100)>0&&n<200?e*s/100/(n<=100?n:200-n)*100:0,l:n/2,a:t.a};var t,e,s,n},ao=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,oo=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,ho=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,lo=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,hs={string:[[function(i){var t=ro.exec(i);return t?(i=t[1]).length<=4?{r:parseInt(i[0]+i[0],16),g:parseInt(i[1]+i[1],16),b:parseInt(i[2]+i[2],16),a:i.length===4?at(parseInt(i[3]+i[3],16)/255,2):1}:i.length===6||i.length===8?{r:parseInt(i.substr(0,2),16),g:parseInt(i.substr(2,2),16),b:parseInt(i.substr(4,2),16),a:i.length===8?at(parseInt(i.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(i){var t=ho.exec(i)||lo.exec(i);return t?t[2]!==t[4]||t[4]!==t[6]?null:ln({r:Number(t[1])/(t[2]?100/255:1),g:Number(t[3])/(t[4]?100/255:1),b:Number(t[5])/(t[6]?100/255:1),a:t[7]===void 0?1:Number(t[7])/(t[8]?100:1)}):null},"rgb"],[function(i){var t=ao.exec(i)||oo.exec(i);if(!t)return null;var e,s,n=cn({h:(e=t[1],s=t[2],s===void 0&&(s="deg"),Number(e)*(no[s]||1)),s:Number(t[3]),l:Number(t[4]),a:t[5]===void 0?1:Number(t[5])/(t[6]?100:1)});return un(n)},"hsl"]],object:[[function(i){var t=i.r,e=i.g,s=i.b,n=i.a,r=n===void 0?1:n;return Ft(t)&&Ft(e)&&Ft(s)?ln({r:Number(t),g:Number(e),b:Number(s),a:Number(r)}):null},"rgb"],[function(i){var t=i.h,e=i.s,s=i.l,n=i.a,r=n===void 0?1:n;if(!Ft(t)||!Ft(e)||!Ft(s))return null;var a=cn({h:Number(t),s:Number(e),l:Number(s),a:Number(r)});return un(a)},"hsl"],[function(i){var t=i.h,e=i.s,s=i.v,n=i.a,r=n===void 0?1:n;if(!Ft(t)||!Ft(e)||!Ft(s))return null;var a=function(o){return{h:dr(o.h),s:wt(o.s,0,100),v:wt(o.v,0,100),a:wt(o.a)}}({h:Number(t),s:Number(e),v:Number(s),a:Number(r)});return fr(a)},"hsv"]]},fn=function(i,t){for(var e=0;e=.5},i.prototype.toHex=function(){return t=Fi(this.rgba),e=t.r,s=t.g,n=t.b,a=(r=t.a)<1?ni(at(255*r)):"","#"+ni(e)+ni(s)+ni(n)+a;var t,e,s,n,r,a},i.prototype.toRgb=function(){return Fi(this.rgba)},i.prototype.toRgbString=function(){return t=Fi(this.rgba),e=t.r,s=t.g,n=t.b,(r=t.a)<1?"rgba("+e+", "+s+", "+n+", "+r+")":"rgb("+e+", "+s+", "+n+")";var t,e,s,n,r},i.prototype.toHsl=function(){return dn(Oe(this.rgba))},i.prototype.toHslString=function(){return t=dn(Oe(this.rgba)),e=t.h,s=t.s,n=t.l,(r=t.a)<1?"hsla("+e+", "+s+"%, "+n+"%, "+r+")":"hsl("+e+", "+s+"%, "+n+"%)";var t,e,s,n,r},i.prototype.toHsv=function(){return t=ur(this.rgba),{h:at(t.h),s:at(t.s),v:at(t.v),a:at(t.a,3)};var t},i.prototype.invert=function(){return Pt({r:255-(t=this.rgba).r,g:255-t.g,b:255-t.b,a:t.a});var t},i.prototype.saturate=function(t){return t===void 0&&(t=.1),Pt(Li(this.rgba,t))},i.prototype.desaturate=function(t){return t===void 0&&(t=.1),Pt(Li(this.rgba,-t))},i.prototype.grayscale=function(){return Pt(Li(this.rgba,-1))},i.prototype.lighten=function(t){return t===void 0&&(t=.1),Pt(pn(this.rgba,t))},i.prototype.darken=function(t){return t===void 0&&(t=.1),Pt(pn(this.rgba,-t))},i.prototype.rotate=function(t){return t===void 0&&(t=15),this.hue(this.hue()+t)},i.prototype.alpha=function(t){return typeof t=="number"?Pt({r:(e=this.rgba).r,g:e.g,b:e.b,a:t}):at(this.rgba.a,3);var e},i.prototype.hue=function(t){var e=Oe(this.rgba);return typeof t=="number"?Pt({h:t,s:e.s,l:e.l,a:e.a}):at(e.h)},i.prototype.isEqual=function(t){return this.toHex()===Pt(t).toHex()},i}(),Pt=function(i){return i instanceof ls?i:new ls(i)},gn=[],uo=function(i){i.forEach(function(t){gn.indexOf(t)<0&&(t(ls,hs),gn.push(t))})};function fo(i,t){var e={white:"#ffffff",bisque:"#ffe4c4",blue:"#0000ff",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",antiquewhite:"#faebd7",aqua:"#00ffff",azure:"#f0ffff",whitesmoke:"#f5f5f5",papayawhip:"#ffefd5",plum:"#dda0dd",blanchedalmond:"#ffebcd",black:"#000000",gold:"#ffd700",goldenrod:"#daa520",gainsboro:"#dcdcdc",cornsilk:"#fff8dc",cornflowerblue:"#6495ed",burlywood:"#deb887",aquamarine:"#7fffd4",beige:"#f5f5dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkkhaki:"#bdb76b",darkgray:"#a9a9a9",darkgreen:"#006400",darkgrey:"#a9a9a9",peachpuff:"#ffdab9",darkmagenta:"#8b008b",darkred:"#8b0000",darkorchid:"#9932cc",darkorange:"#ff8c00",darkslateblue:"#483d8b",gray:"#808080",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",deeppink:"#ff1493",deepskyblue:"#00bfff",wheat:"#f5deb3",firebrick:"#b22222",floralwhite:"#fffaf0",ghostwhite:"#f8f8ff",darkviolet:"#9400d3",magenta:"#ff00ff",green:"#008000",dodgerblue:"#1e90ff",grey:"#808080",honeydew:"#f0fff0",hotpink:"#ff69b4",blueviolet:"#8a2be2",forestgreen:"#228b22",lawngreen:"#7cfc00",indianred:"#cd5c5c",indigo:"#4b0082",fuchsia:"#ff00ff",brown:"#a52a2a",maroon:"#800000",mediumblue:"#0000cd",lightcoral:"#f08080",darkturquoise:"#00ced1",lightcyan:"#e0ffff",ivory:"#fffff0",lightyellow:"#ffffe0",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",linen:"#faf0e6",mediumaquamarine:"#66cdaa",lemonchiffon:"#fffacd",lime:"#00ff00",khaki:"#f0e68c",mediumseagreen:"#3cb371",limegreen:"#32cd32",mediumspringgreen:"#00fa9a",lightskyblue:"#87cefa",lightblue:"#add8e6",midnightblue:"#191970",lightpink:"#ffb6c1",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",mintcream:"#f5fffa",lightslategray:"#778899",lightslategrey:"#778899",navajowhite:"#ffdead",navy:"#000080",mediumvioletred:"#c71585",powderblue:"#b0e0e6",palegoldenrod:"#eee8aa",oldlace:"#fdf5e6",paleturquoise:"#afeeee",mediumturquoise:"#48d1cc",mediumorchid:"#ba55d3",rebeccapurple:"#663399",lightsteelblue:"#b0c4de",mediumslateblue:"#7b68ee",thistle:"#d8bfd8",tan:"#d2b48c",orchid:"#da70d6",mediumpurple:"#9370db",purple:"#800080",pink:"#ffc0cb",skyblue:"#87ceeb",springgreen:"#00ff7f",palegreen:"#98fb98",red:"#ff0000",yellow:"#ffff00",slateblue:"#6a5acd",lavenderblush:"#fff0f5",peru:"#cd853f",palevioletred:"#db7093",violet:"#ee82ee",teal:"#008080",slategray:"#708090",slategrey:"#708090",aliceblue:"#f0f8ff",darkseagreen:"#8fbc8f",darkolivegreen:"#556b2f",greenyellow:"#adff2f",seagreen:"#2e8b57",seashell:"#fff5ee",tomato:"#ff6347",silver:"#c0c0c0",sienna:"#a0522d",lavender:"#e6e6fa",lightgreen:"#90ee90",orange:"#ffa500",orangered:"#ff4500",steelblue:"#4682b4",royalblue:"#4169e1",turquoise:"#40e0d0",yellowgreen:"#9acd32",salmon:"#fa8072",saddlebrown:"#8b4513",sandybrown:"#f4a460",rosybrown:"#bc8f8f",darksalmon:"#e9967a",lightgoldenrodyellow:"#fafad2",snow:"#fffafa",lightgrey:"#d3d3d3",lightgray:"#d3d3d3",dimgray:"#696969",dimgrey:"#696969",olivedrab:"#6b8e23",olive:"#808000"},s={};for(var n in e)s[e[n]]=n;var r={};i.prototype.toName=function(a){if(!(this.rgba.a||this.rgba.r||this.rgba.g||this.rgba.b))return"transparent";var o,h,l=s[this.toHex()];if(l)return l;if(a!=null&&a.closest){var c=this.toRgb(),d=1/0,f="black";if(!r.length)for(var g in e)r[g]=new i(e[g]).toRgb();for(var m in e){var y=(o=c,h=r[m],Math.pow(o.r-h.r,2)+Math.pow(o.g-h.g,2)+Math.pow(o.b-h.b,2));yr===e[a]);if(t!==null&&e!==null){const r=Object.keys(t),a=Object.keys(e);return r.length!==a.length?!1:r.every(o=>t[o]===e[o])}return t===e}toRgba(){const[t,e,s,n]=this._components;return{r:t,g:e,b:s,a:n}}toRgb(){const[t,e,s]=this._components;return{r:t,g:e,b:s}}toRgbaString(){const[t,e,s]=this.toUint8RgbArray();return`rgba(${t},${e},${s},${this.alpha})`}toUint8RgbArray(t){const[e,s,n]=this._components;return this._arrayRgb||(this._arrayRgb=[]),t=t||this._arrayRgb,t[0]=Math.round(e*255),t[1]=Math.round(s*255),t[2]=Math.round(n*255),t}toArray(t){this._arrayRgba||(this._arrayRgba=[]),t=t||this._arrayRgba;const[e,s,n,r]=this._components;return t[0]=e,t[1]=s,t[2]=n,t[3]=r,t}toRgbArray(t){this._arrayRgb||(this._arrayRgb=[]),t=t||this._arrayRgb;const[e,s,n]=this._components;return t[0]=e,t[1]=s,t[2]=n,t}toNumber(){return this._int}toBgrNumber(){const[t,e,s]=this.toUint8RgbArray();return(s<<16)+(e<<8)+t}toLittleEndianNumber(){const t=this._int;return(t>>16)+(t&65280)+((t&255)<<16)}multiply(t){const[e,s,n,r]=De._temp.setValue(t)._components;return this._components[0]*=e,this._components[1]*=s,this._components[2]*=n,this._components[3]*=r,this._refreshInt(),this._value=null,this}premultiply(t,e=!0){return e&&(this._components[0]*=t,this._components[1]*=t,this._components[2]*=t),this._components[3]=t,this._refreshInt(),this._value=null,this}toPremultiplied(t,e=!0){if(t===1)return(255<<24)+this._int;if(t===0)return e?0:this._int;let s=this._int>>16&255,n=this._int>>8&255,r=this._int&255;return e&&(s=s*t+.5|0,n=n*t+.5|0,r=r*t+.5|0),(t*255<<24)+(s<<16)+(n<<8)+r}toHex(){const t=this._int.toString(16);return`#${"000000".substring(0,6-t.length)+t}`}toHexa(){const e=Math.round(this._components[3]*255).toString(16);return this.toHex()+"00".substring(0,2-e.length)+e}setAlpha(t){return this._components[3]=this._clamp(t),this}_normalize(t){let e,s,n,r;if((typeof t=="number"||t instanceof Number)&&t>=0&&t<=16777215){const a=t;e=(a>>16&255)/255,s=(a>>8&255)/255,n=(a&255)/255,r=1}else if((Array.isArray(t)||t instanceof Float32Array)&&t.length>=3&&t.length<=4)t=this._clamp(t),[e,s,n,r=1]=t;else if((t instanceof Uint8Array||t instanceof Uint8ClampedArray)&&t.length>=3&&t.length<=4)t=this._clamp(t,0,255),[e,s,n,r=255]=t,e/=255,s/=255,n/=255,r/=255;else if(typeof t=="string"||typeof t=="object"){if(typeof t=="string"){const o=De.HEX_PATTERN.exec(t);o&&(t=`#${o[2]}`)}const a=Pt(t);a.isValid()&&({r:e,g:s,b:n,a:r}=a.rgba,e/=255,s/=255,n/=255)}if(e!==void 0)this._components[0]=e,this._components[1]=s,this._components[2]=n,this._components[3]=r,this._refreshInt();else throw new Error(`Unable to convert color ${t}`)}_refreshInt(){this._clamp(this._components);const[t,e,s]=this._components;this._int=(t*255<<16)+(e*255<<8)+(s*255|0)}_clamp(t,e=0,s=1){return typeof t=="number"?Math.min(Math.max(t,e),s):(t.forEach((n,r)=>{t[r]=Math.min(Math.max(n,e),s)}),t)}static isColorLike(t){return typeof t=="number"||typeof t=="string"||t instanceof Number||t instanceof De||Array.isArray(t)||t instanceof Uint8Array||t instanceof Uint8ClampedArray||t instanceof Float32Array||t.r!==void 0&&t.g!==void 0&&t.b!==void 0||t.r!==void 0&&t.g!==void 0&&t.b!==void 0&&t.a!==void 0||t.h!==void 0&&t.s!==void 0&&t.l!==void 0||t.h!==void 0&&t.s!==void 0&&t.l!==void 0&&t.a!==void 0||t.h!==void 0&&t.s!==void 0&&t.v!==void 0||t.h!==void 0&&t.s!==void 0&&t.v!==void 0&&t.a!==void 0}};me.shared=new me;me._temp=new me;me.HEX_PATTERN=/^(#|0x)?(([a-f0-9]{3}){1,2}([a-f0-9]{2})?)$/i;let Y=me;const po={cullArea:null,cullable:!1,cullableChildren:!0};class Bs{constructor(t,e){this._pool=[],this._count=0,this._index=0,this._classType=t,e&&this.prepopulate(e)}prepopulate(t){for(let e=0;e0?e=this._pool[--this._index]:e=new this._classType,(s=e.init)==null||s.call(e,t),e}return(t){var e;(e=t.reset)==null||e.call(t),this._pool[this._index++]=t}get totalSize(){return this._count}get totalFree(){return this._index}get totalUsed(){return this._count-this._index}clear(){this._pool.length=0,this._index=0}}class go{constructor(){this._poolsByClass=new Map}prepopulate(t,e){this.getPool(t).prepopulate(e)}get(t,e){return this.getPool(t).get(e)}return(t){this.getPool(t.constructor).return(t)}getPool(t){return this._poolsByClass.has(t)||this._poolsByClass.set(t,new Bs(t)),this._poolsByClass.get(t)}stats(){const t={};return this._poolsByClass.forEach(e=>{const s=t[e._classType.name]?e._classType.name+e._classType.ID:e._classType.name;t[s]={free:e.totalFree,used:e.totalUsed,size:e.totalSize}}),t}}const zt=new go;function mo(i,t,e){const s=i.length;let n;if(t>=s||e===0)return;e=t+e>s?s-t:e;const r=s-e;for(n=t;n0&&s<=e){for(let a=e-1;a>=i;a--){const o=this.children[a];o&&(n.push(o),o.parent=null)}mo(this.children,i,e);const r=this.renderGroup||this.parentRenderGroup;r&&r.removeChildren(n);for(let a=0;a=this.children.length)throw new Error(`getChildAt: Index (${i}) does not exist.`);return this.children[i]},setChildIndex(i,t){if(t<0||t>=this.children.length)throw new Error(`The index ${t} supplied is out of bounds ${this.children.length}`);this.getChildIndex(i),this.addChildAt(i,t)},getChildIndex(i){const t=this.children.indexOf(i);if(t===-1)throw new Error("The supplied Container must be a child of the caller");return t},addChildAt(i,t){this.allowChildren||U(O,"addChildAt: Only Containers will be allowed to add children in v8.0.0");const{children:e}=this;if(t<0||t>e.length)throw new Error(`${i}addChildAt: The index ${t} supplied is out of bounds ${e.length}`);if(i.parent){const n=i.parent.children.indexOf(i);if(i.parent===this&&n===t)return i;n!==-1&&i.parent.children.splice(n,1)}t===e.length?e.push(i):e.splice(t,0,i),i.parent=this,i.didChange=!0,i.didViewUpdate=!1,i._updateFlags=15;const s=this.renderGroup||this.parentRenderGroup;return s&&s.addChild(i),this.sortableChildren&&(this.sortDirty=!0),this.emit("childAdded",i,this,t),i.emit("added",this),i},swapChildren(i,t){if(i===t)return;const e=this.getChildIndex(i),s=this.getChildIndex(t);this.children[e]=t,this.children[s]=i;const n=this.renderGroup||this.parentRenderGroup;n&&(n.structureDidChange=!0),this._didContainerChangeTick++},removeFromParent(){var i;(i=this.parent)==null||i.removeChild(this)},reparentChild(...i){return i.length===1?this.reparentChildAt(i[0],this.children.length):(i.forEach(t=>this.reparentChildAt(t,this.children.length)),i[0])},reparentChildAt(i,t){if(i.parent===this)return this.setChildIndex(i,t),i;const e=i.worldTransform.clone();i.removeFromParent(),this.addChildAt(i,t);const s=this.worldTransform.clone();return s.invert(),e.prepend(s),i.setFromMatrix(e),i}};class mn{constructor(){this.pipe="filter",this.priority=1}destroy(){for(let t=0;t{this.add({test:t.test,maskClass:t})}))}add(t){this._tests.push(t)}getMaskEffect(t){this._initialized||this.init();for(let e=0;es.priority-n.priority);const e=this.renderGroup||this.parentRenderGroup;e&&(e.structureDidChange=!0),this._updateIsSimple()},removeEffect(i){const t=this.effects.indexOf(i);t!==-1&&(this.effects.splice(t,1),this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._updateIsSimple())},set mask(i){const t=this._maskEffect;(t==null?void 0:t.mask)!==i&&(t&&(this.removeEffect(t),cs.returnMaskEffect(t),this._maskEffect=null),i!=null&&(this._maskEffect=cs.getMaskEffect(i),this.addEffect(this._maskEffect)))},get mask(){var i;return(i=this._maskEffect)==null?void 0:i.mask},set filters(i){var r;!Array.isArray(i)&&i&&(i=[i]);const t=this._filterEffect||(this._filterEffect=new mn);i=i;const e=(i==null?void 0:i.length)>0,s=((r=t.filters)==null?void 0:r.length)>0,n=e!==s;i=Array.isArray(i)?i.slice(0):i,t.filters=Object.freeze(i),n&&(e?this.addEffect(t):(this.removeEffect(t),t.filters=i??null))},get filters(){var i;return(i=this._filterEffect)==null?void 0:i.filters},set filterArea(i){this._filterEffect||(this._filterEffect=new mn),this._filterEffect.filterArea=i},get filterArea(){var i;return(i=this._filterEffect)==null?void 0:i.filterArea}},_o={label:null,get name(){return U(O,"Container.name property has been removed, use Container.label instead"),this.label},set name(i){U(O,"Container.name property has been removed, use Container.label instead"),this.label=i},getChildByName(i,t=!1){return this.getChildByLabel(i,t)},getChildByLabel(i,t=!1){const e=this.children;for(let s=0;s-1&&this.renderGroupChildren.splice(e,1),t.renderGroupParent=null}addChild(t){if(this.structureDidChange=!0,t.parentRenderGroup=this,t.updateTick=-1,t.parent===this.root?t.relativeRenderGroupDepth=1:t.relativeRenderGroupDepth=t.parent.relativeRenderGroupDepth+1,t.didChange=!0,this.onChildUpdate(t),t.renderGroup){this.addRenderGroupChild(t.renderGroup);return}t._onRender&&this.addOnRender(t);const e=t.children;for(let s=0;s0}addOnRender(t){this._onRenderContainers.push(t)}removeOnRender(t){this._onRenderContainers.splice(this._onRenderContainers.indexOf(t),1)}runOnRender(){for(let t=0;tthis.addChild(n)),(s=t.parent)==null||s.addChild(this)}static mixin(t){Object.defineProperties(tt.prototype,Object.getOwnPropertyDescriptors(t))}set _didChangeId(t){this._didViewChangeTick=t>>12&4095,this._didContainerChangeTick=t&4095}get _didChangeId(){return this._didContainerChangeTick&4095|(this._didViewChangeTick&4095)<<12}addChild(...t){if(this.allowChildren||U(O,"addChild: Only Containers will be allowed to add children in v8.0.0"),t.length>1){for(let n=0;n1){for(let n=0;n-1&&(this._didViewChangeTick++,this.children.splice(s,1),this.renderGroup?this.renderGroup.removeChild(e):this.parentRenderGroup&&this.parentRenderGroup.removeChild(e),e.parent=null,this.emit("childRemoved",e,this,s),e.emit("removed",this)),e}_onUpdate(t){t&&t===this._skew&&this._updateSkew(),this._didContainerChangeTick++,!this.didChange&&(this.didChange=!0,this.parentRenderGroup&&this.parentRenderGroup.onChildUpdate(this))}set isRenderGroup(t){!!this.renderGroup!==t&&(t?this.enableRenderGroup():this.disableRenderGroup())}get isRenderGroup(){return!!this.renderGroup}enableRenderGroup(){if(this.renderGroup)return;const t=this.parentRenderGroup;t==null||t.removeChild(this),this.renderGroup=zt.get(Po,this),this.groupTransform=H.IDENTITY,t==null||t.addChild(this),this._updateIsSimple()}disableRenderGroup(){if(!this.renderGroup)return;const t=this.parentRenderGroup;t==null||t.removeChild(this),zt.return(this.renderGroup),this.renderGroup=null,this.groupTransform=this.relativeGroupTransform,t==null||t.addChild(this),this._updateIsSimple()}_updateIsSimple(){this.isSimple=!this.renderGroup&&this.effects.length===0}get worldTransform(){return this._worldTransform||(this._worldTransform=new H),this.renderGroup?this._worldTransform.copyFrom(this.renderGroup.worldTransform):this.parentRenderGroup&&this._worldTransform.appendFrom(this.relativeGroupTransform,this.parentRenderGroup.worldTransform),this._worldTransform}get x(){return this._position.x}set x(t){this._position.x=t}get y(){return this._position.y}set y(t){this._position.y=t}get position(){return this._position}set position(t){this._position.copyFrom(t)}get rotation(){return this._rotation}set rotation(t){this._rotation!==t&&(this._rotation=t,this._onUpdate(this._skew))}get angle(){return this.rotation*Xa}set angle(t){this.rotation=t*ja}get pivot(){return this._pivot===Ni&&(this._pivot=new pt(this,0,0)),this._pivot}set pivot(t){this._pivot===Ni&&(this._pivot=new pt(this,0,0)),typeof t=="number"?this._pivot.set(t):this._pivot.copyFrom(t)}get skew(){return this._skew===Ui&&(this._skew=new pt(this,0,0)),this._skew}set skew(t){this._skew===Ui&&(this._skew=new pt(this,0,0)),this._skew.copyFrom(t)}get scale(){return this._scale===Oi&&(this._scale=new pt(this,1,1)),this._scale}set scale(t){this._scale===Oi&&(this._scale=new pt(this,0,0)),typeof t=="number"?this._scale.set(t):this._scale.copyFrom(t)}get width(){return Math.abs(this.scale.x*this.getLocalBounds().width)}set width(t){const e=this.getLocalBounds().width;this._setWidth(t,e)}get height(){return Math.abs(this.scale.y*this.getLocalBounds().height)}set height(t){const e=this.getLocalBounds().height;this._setHeight(t,e)}getSize(t){t||(t={});const e=this.getLocalBounds();return t.width=Math.abs(this.scale.x*e.width),t.height=Math.abs(this.scale.y*e.height),t}setSize(t,e){const s=this.getLocalBounds();typeof t=="object"?(e=t.height??t.width,t=t.width):e??(e=t),t!==void 0&&this._setWidth(t,s.width),e!==void 0&&this._setHeight(e,s.height)}_updateSkew(){const t=this._rotation,e=this._skew;this._cx=Math.cos(t+e._y),this._sx=Math.sin(t+e._y),this._cy=-Math.sin(t-e._x),this._sy=Math.cos(t-e._x)}updateTransform(t){return this.position.set(typeof t.x=="number"?t.x:this.position.x,typeof t.y=="number"?t.y:this.position.y),this.scale.set(typeof t.scaleX=="number"?t.scaleX||1:this.scale.x,typeof t.scaleY=="number"?t.scaleY||1:this.scale.y),this.rotation=typeof t.rotation=="number"?t.rotation:this.rotation,this.skew.set(typeof t.skewX=="number"?t.skewX:this.skew.x,typeof t.skewY=="number"?t.skewY:this.skew.y),this.pivot.set(typeof t.pivotX=="number"?t.pivotX:this.pivot.x,typeof t.pivotY=="number"?t.pivotY:this.pivot.y),this}setFromMatrix(t){t.decompose(this)}updateLocalTransform(){const t=this._didContainerChangeTick;if(this._didLocalTransformChangeId===t)return;this._didLocalTransformChangeId=t;const e=this.localTransform,s=this._scale,n=this._pivot,r=this._position,a=s._x,o=s._y,h=n._x,l=n._y;e.a=this._cx*a,e.b=this._sx*a,e.c=this._cy*o,e.d=this._sy*o,e.tx=r._x-(h*e.a+l*e.c),e.ty=r._y-(h*e.b+l*e.d)}set alpha(t){t!==this.localAlpha&&(this.localAlpha=t,this._updateFlags|=yn,this._onUpdate())}get alpha(){return this.localAlpha}set tint(t){const s=Y.shared.setValue(t??16777215).toBgrNumber();s!==this.localColor&&(this.localColor=s,this._updateFlags|=yn,this._onUpdate())}get tint(){const t=this.localColor;return((t&255)<<16)+(t&65280)+(t>>16&255)}set blendMode(t){this.localBlendMode!==t&&(this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._updateFlags|=ko,this.localBlendMode=t,this._onUpdate())}get blendMode(){return this.localBlendMode}get visible(){return!!(this.localDisplayStatus&2)}set visible(t){const e=t?2:0;(this.localDisplayStatus&2)!==e&&(this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._updateFlags|=Wi,this.localDisplayStatus^=2,this._onUpdate())}get culled(){return!(this.localDisplayStatus&4)}set culled(t){const e=t?0:4;(this.localDisplayStatus&4)!==e&&(this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._updateFlags|=Wi,this.localDisplayStatus^=4,this._onUpdate())}get renderable(){return!!(this.localDisplayStatus&1)}set renderable(t){const e=t?1:0;(this.localDisplayStatus&1)!==e&&(this._updateFlags|=Wi,this.localDisplayStatus^=1,this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._onUpdate())}get isRenderable(){return this.localDisplayStatus===7&&this.groupAlpha>0}destroy(t=!1){var n;if(this.destroyed)return;this.destroyed=!0;const e=this.removeChildren(0,this.children.length);if(this.removeFromParent(),this.parent=null,this._maskEffect=null,this._filterEffect=null,this.effects=null,this._position=null,this._scale=null,this._pivot=null,this._skew=null,this.emit("destroyed",this),this.removeAllListeners(),typeof t=="boolean"?t:t==null?void 0:t.children)for(let r=0;r=e.minX&&s<=e.maxX&&n>=e.minY&&n<=e.maxY}destroy(t){super.destroy(t),this._bounds=null}}class $ extends vi{constructor(t=z.EMPTY){t instanceof z&&(t={texture:t});const{texture:e=z.EMPTY,anchor:s,roundPixels:n,width:r,height:a,...o}=t;super({label:"Sprite",...o}),this.renderPipeId="sprite",this.batched=!0,this._didSpriteUpdate=!1,this._sourceBounds={minX:0,maxX:1,minY:0,maxY:0},this._sourceBoundsDirty=!0,this._anchor=new pt({_onUpdate:()=>{this.onViewUpdate()}}),s?this.anchor=s:e.defaultAnchor&&(this.anchor=e.defaultAnchor),this.texture=e,this.allowChildren=!1,this.roundPixels=n??!1,r!==void 0&&(this.width=r),a!==void 0&&(this.height=a)}static from(t,e=!1){return t instanceof z?new $(t):new $(z.from(t,e))}set texture(t){t||(t=z.EMPTY);const e=this._texture;e!==t&&(e&&e.dynamic&&e.off("update",this.onViewUpdate,this),t.dynamic&&t.on("update",this.onViewUpdate,this),this._texture=t,this._width&&this._setWidth(this._width,this._texture.orig.width),this._height&&this._setHeight(this._height,this._texture.orig.height),this.onViewUpdate())}get texture(){return this._texture}get bounds(){return this._boundsDirty&&(this._updateBounds(),this._boundsDirty=!1),this._bounds}get sourceBounds(){return this._sourceBoundsDirty&&(this._updateSourceBounds(),this._sourceBoundsDirty=!1),this._sourceBounds}containsPoint(t){const e=this.sourceBounds;return t.x>=e.maxX&&t.x<=e.minX&&t.y>=e.maxY&&t.y<=e.minY}addBounds(t){const e=this._texture.trim?this.sourceBounds:this.bounds;t.addFrame(e.minX,e.minY,e.maxX,e.maxY)}onViewUpdate(){if(this._didViewChangeTick++,this._didSpriteUpdate=!0,this._sourceBoundsDirty=this._boundsDirty=!0,this.didViewUpdate)return;this.didViewUpdate=!0;const t=this.renderGroup||this.parentRenderGroup;t&&t.onChildViewUpdate(this)}_updateBounds(){so(this._bounds,this._anchor,this._texture,0)}_updateSourceBounds(){const t=this._anchor,e=this._texture,s=this._sourceBounds,{width:n,height:r}=e.orig;s.maxX=-t._x*n,s.minX=s.maxX+n,s.maxY=-t._y*r,s.minY=s.maxY+r}destroy(t=!1){if(super.destroy(t),typeof t=="boolean"?t:t==null?void 0:t.texture){const s=typeof t=="boolean"?t:t==null?void 0:t.textureSource;this._texture.destroy(s)}this._texture=null,this._bounds=null,this._sourceBounds=null,this._anchor=null}get anchor(){return this._anchor}set anchor(t){typeof t=="number"?this._anchor.set(t):this._anchor.copyFrom(t)}get width(){return Math.abs(this.scale.x)*this._texture.orig.width}set width(t){this._setWidth(t,this._texture.orig.width),this._width=t}get height(){return Math.abs(this.scale.y)*this._texture.orig.height}set height(t){this._setHeight(t,this._texture.orig.height),this._height=t}getSize(t){return t||(t={}),t.width=Math.abs(this.scale.x)*this._texture.orig.width,t.height=Math.abs(this.scale.y)*this._texture.orig.height,t}setSize(t,e){typeof t=="object"?(e=t.height??t.width,t=t.width):e??(e=t),t!==void 0&&this._setWidth(t,this._texture.orig.width),e!==void 0&&this._setHeight(e,this._texture.orig.height)}}const Bo=new Et;function _r(i,t,e){const s=Bo;i.measurable=!0,pr(i,e,s),t.addBoundsMask(s),i.measurable=!1}function br(i,t,e){const s=xe.get();i.measurable=!0;const n=Ut.get().identity(),r=Sr(i,e,n);mr(i,s,r),i.measurable=!1,t.addBoundsMask(s),Ut.return(n),xe.return(s)}function Sr(i,t,e){return i?(i!==t&&(Sr(i.parent,t,e),i.updateLocalTransform(),e.append(i.localTransform)),e):(st("Mask bounds, renderable is not inside the root container"),e)}class vr{constructor(t){this.priority=0,this.pipe="alphaMask",t!=null&&t.mask&&this.init(t.mask)}init(t){this.mask=t,this.renderMaskToTexture=!(t instanceof $),this.mask.renderable=this.renderMaskToTexture,this.mask.includeInBuild=!this.renderMaskToTexture,this.mask.measurable=!1}reset(){this.mask.measurable=!0,this.mask=null}addBounds(t,e){_r(this.mask,t,e)}addLocalBounds(t,e){br(this.mask,t,e)}containsPoint(t,e){const s=this.mask;return e(s,t)}destroy(){this.reset()}static test(t){return t instanceof $}}vr.extension=G.MaskEffect;class Cr{constructor(t){this.priority=0,this.pipe="colorMask",t!=null&&t.mask&&this.init(t.mask)}init(t){this.mask=t}destroy(){}static test(t){return typeof t=="number"}}Cr.extension=G.MaskEffect;class Tr{constructor(t){this.priority=0,this.pipe="stencilMask",t!=null&&t.mask&&this.init(t.mask)}init(t){this.mask=t,this.mask.includeInBuild=!1,this.mask.measurable=!1}reset(){this.mask.measurable=!0,this.mask.includeInBuild=!0,this.mask=null}addBounds(t,e){_r(this.mask,t,e)}addLocalBounds(t,e){br(this.mask,t,e)}containsPoint(t,e){const s=this.mask;return e(s,t)}destroy(){this.reset()}static test(t){return t instanceof tt}}Tr.extension=G.MaskEffect;const Io={createCanvas:(i,t)=>{const e=document.createElement("canvas");return e.width=i,e.height=t,e},getCanvasRenderingContext2D:()=>CanvasRenderingContext2D,getWebGLRenderingContext:()=>WebGLRenderingContext,getNavigator:()=>navigator,getBaseUrl:()=>document.baseURI??window.location.href,getFontFaceSet:()=>document.fonts,fetch:(i,t)=>fetch(i,t),parseXML:i=>new DOMParser().parseFromString(i,"text/xml")};let wn=Io;const Q={get(){return wn},set(i){wn=i}};class Ar extends Nt{constructor(t){t.resource||(t.resource=Q.get().createCanvas()),t.width||(t.width=t.resource.width,t.autoDensity||(t.width/=t.resolution)),t.height||(t.height=t.resource.height,t.autoDensity||(t.height/=t.resolution)),super(t),this.uploadMethodId="image",this.autoDensity=t.autoDensity;const e=t.resource;(this.pixelWidth!==e.width||this.pixelWidth!==e.height)&&this.resizeCanvas(),this.transparent=!!t.transparent}resizeCanvas(){this.autoDensity&&(this.resource.style.width=`${this.width}px`,this.resource.style.height=`${this.height}px`),(this.resource.width!==this.pixelWidth||this.resource.height!==this.pixelHeight)&&(this.resource.width=this.pixelWidth,this.resource.height=this.pixelHeight)}resize(t=this.width,e=this.height,s=this._resolution){const n=super.resize(t,e,s);return n&&this.resizeCanvas(),n}static test(t){return globalThis.HTMLCanvasElement&&t instanceof HTMLCanvasElement||globalThis.OffscreenCanvas&&t instanceof OffscreenCanvas}get context2D(){return this._context2D||(this._context2D=this.resource.getContext("2d"))}}Ar.extension=G.TextureSource;class Ce extends Nt{constructor(t){if(t.resource&&globalThis.HTMLImageElement&&t.resource instanceof HTMLImageElement){const e=Q.get().createCanvas(t.resource.width,t.resource.height);e.getContext("2d").drawImage(t.resource,0,0,t.resource.width,t.resource.height),t.resource=e,st("ImageSource: Image element passed, converting to canvas. Use CanvasSource instead.")}super(t),this.uploadMethodId="image",this.autoGarbageCollect=!0}static test(t){return globalThis.HTMLImageElement&&t instanceof HTMLImageElement||typeof ImageBitmap<"u"&&t instanceof ImageBitmap||globalThis.VideoFrame&&t instanceof VideoFrame}}Ce.extension=G.TextureSource;var yi=(i=>(i[i.INTERACTION=50]="INTERACTION",i[i.HIGH=25]="HIGH",i[i.NORMAL=0]="NORMAL",i[i.LOW=-25]="LOW",i[i.UTILITY=-50]="UTILITY",i))(yi||{});class Hi{constructor(t,e=null,s=0,n=!1){this.next=null,this.previous=null,this._destroyed=!1,this._fn=t,this._context=e,this.priority=s,this._once=n}match(t,e=null){return this._fn===t&&this._context===e}emit(t){this._fn&&(this._context?this._fn.call(this._context,t):this._fn(t));const e=this.next;return this._once&&this.destroy(!0),this._destroyed&&(this.next=null),e}connect(t){this.previous=t,t.next&&(t.next.previous=this),this.next=t.next,t.next=this}destroy(t=!1){this._destroyed=!0,this._fn=null,this._context=null,this.previous&&(this.previous.next=this.next),this.next&&(this.next.previous=this.previous);const e=this.next;return this.next=t?null:e,this.previous=null,e}}const Mr=class mt{constructor(){this.autoStart=!1,this.deltaTime=1,this.lastTime=-1,this.speed=1,this.started=!1,this._requestId=null,this._maxElapsedMS=100,this._minElapsedMS=0,this._protected=!1,this._lastFrame=-1,this._head=new Hi(null,null,1/0),this.deltaMS=1/mt.targetFPMS,this.elapsedMS=1/mt.targetFPMS,this._tick=t=>{this._requestId=null,this.started&&(this.update(t),this.started&&this._requestId===null&&this._head.next&&(this._requestId=requestAnimationFrame(this._tick)))}}_requestIfNeeded(){this._requestId===null&&this._head.next&&(this.lastTime=performance.now(),this._lastFrame=this.lastTime,this._requestId=requestAnimationFrame(this._tick))}_cancelIfNeeded(){this._requestId!==null&&(cancelAnimationFrame(this._requestId),this._requestId=null)}_startIfPossible(){this.started?this._requestIfNeeded():this.autoStart&&this.start()}add(t,e,s=yi.NORMAL){return this._addListener(new Hi(t,e,s))}addOnce(t,e,s=yi.NORMAL){return this._addListener(new Hi(t,e,s,!0))}_addListener(t){let e=this._head.next,s=this._head;if(!e)t.connect(s);else{for(;e;){if(t.priority>e.priority){t.connect(s);break}s=e,e=e.next}t.previous||t.connect(s)}return this._startIfPossible(),this}remove(t,e){let s=this._head.next;for(;s;)s.match(t,e)?s=s.destroy():s=s.next;return this._head.next||this._cancelIfNeeded(),this}get count(){if(!this._head)return 0;let t=0,e=this._head;for(;e=e.next;)t++;return t}start(){this.started||(this.started=!0,this._requestIfNeeded())}stop(){this.started&&(this.started=!1,this._cancelIfNeeded())}destroy(){if(!this._protected){this.stop();let t=this._head.next;for(;t;)t=t.destroy(!0);this._head.destroy(),this._head=null}}update(t=performance.now()){let e;if(t>this.lastTime){if(e=this.elapsedMS=t-this.lastTime,e>this._maxElapsedMS&&(e=this._maxElapsedMS),e*=this.speed,this._minElapsedMS){const r=t-this._lastFrame|0;if(r{var a;const t=document.createElement("canvas").getContext("webgl");if(!t)return"premultiply-alpha-on-upload";const e=await new Promise(o=>{const h=document.createElement("video");h.onloadeddata=()=>o(h),h.onerror=()=>o(null),h.autoplay=!1,h.crossOrigin="anonymous",h.preload="auto",h.src="data:video/webm;base64,GkXfo59ChoEBQveBAULygQRC84EIQoKEd2VibUKHgQJChYECGFOAZwEAAAAAAAHTEU2bdLpNu4tTq4QVSalmU6yBoU27i1OrhBZUrmtTrIHGTbuMU6uEElTDZ1OsggEXTbuMU6uEHFO7a1OsggG97AEAAAAAAABZAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAVSalmoCrXsYMPQkBNgIRMYXZmV0GETGF2ZkSJiEBEAAAAAAAAFlSua8yuAQAAAAAAAEPXgQFzxYgAAAAAAAAAAZyBACK1nIN1bmSIgQCGhVZfVlA5g4EBI+ODhAJiWgDglLCBArqBApqBAlPAgQFVsIRVuYEBElTDZ9Vzc9JjwItjxYgAAAAAAAAAAWfInEWjh0VOQ09ERVJEh49MYXZjIGxpYnZweC12cDlnyKJFo4hEVVJBVElPTkSHlDAwOjAwOjAwLjA0MDAwMDAwMAAAH0O2dcfngQCgwqGggQAAAIJJg0IAABAAFgA4JBwYSgAAICAAEb///4r+AAB1oZ2mm+6BAaWWgkmDQgAAEAAWADgkHBhKAAAgIABIQBxTu2uRu4+zgQC3iveBAfGCAXHwgQM=",h.load()});if(!e)return"premultiply-alpha-on-upload";const s=t.createTexture();t.bindTexture(t.TEXTURE_2D,s);const n=t.createFramebuffer();t.bindFramebuffer(t.FRAMEBUFFER,n),t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,s,0),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,t.NONE),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,e);const r=new Uint8Array(4);return t.readPixels(0,0,1,1,t.RGBA,t.UNSIGNED_BYTE,r),t.deleteFramebuffer(n),t.deleteTexture(s),(a=t.getExtension("WEBGL_lose_context"))==null||a.loseContext(),r[0]<=r[3]?"premultiplied-alpha":"premultiply-alpha-on-upload"})()),$i}const Ci=class Gr extends Nt{constructor(t){super(t),this.isReady=!1,this.uploadMethodId="video",t={...Gr.defaultOptions,...t},this._autoUpdate=!0,this._isConnectedToTicker=!1,this._updateFPS=t.updateFPS||0,this._msToNextUpdate=0,this.autoPlay=t.autoPlay!==!1,this.alphaMode=t.alphaMode??"premultiply-alpha-on-upload",this._videoFrameRequestCallback=this._videoFrameRequestCallback.bind(this),this._videoFrameRequestCallbackHandle=null,this._load=null,this._resolve=null,this._reject=null,this._onCanPlay=this._onCanPlay.bind(this),this._onCanPlayThrough=this._onCanPlayThrough.bind(this),this._onError=this._onError.bind(this),this._onPlayStart=this._onPlayStart.bind(this),this._onPlayStop=this._onPlayStop.bind(this),this._onSeeked=this._onSeeked.bind(this),t.autoLoad!==!1&&this.load()}updateFrame(){if(!this.destroyed){if(this._updateFPS){const t=It.shared.elapsedMS*this.resource.playbackRate;this._msToNextUpdate=Math.floor(this._msToNextUpdate-t)}(!this._updateFPS||this._msToNextUpdate<=0)&&(this._msToNextUpdate=this._updateFPS?Math.floor(1e3/this._updateFPS):0),this.isValid&&this.update()}}_videoFrameRequestCallback(){this.updateFrame(),this.destroyed?this._videoFrameRequestCallbackHandle=null:this._videoFrameRequestCallbackHandle=this.resource.requestVideoFrameCallback(this._videoFrameRequestCallback)}get isValid(){return!!this.resource.videoWidth&&!!this.resource.videoHeight}async load(){if(this._load)return this._load;const t=this.resource,e=this.options;return(t.readyState===t.HAVE_ENOUGH_DATA||t.readyState===t.HAVE_FUTURE_DATA)&&t.width&&t.height&&(t.complete=!0),t.addEventListener("play",this._onPlayStart),t.addEventListener("pause",this._onPlayStop),t.addEventListener("seeked",this._onSeeked),this._isSourceReady()?this._mediaReady():(e.preload||t.addEventListener("canplay",this._onCanPlay),t.addEventListener("canplaythrough",this._onCanPlayThrough),t.addEventListener("error",this._onError,!0)),this.alphaMode=await Pr(),this._load=new Promise((s,n)=>{this.isValid?s(this):(this._resolve=s,this._reject=n,e.preloadTimeoutMs!==void 0&&(this._preloadTimeout=setTimeout(()=>{this._onError(new ErrorEvent(`Preload exceeded timeout of ${e.preloadTimeoutMs}ms`))})),t.load())}),this._load}_onError(t){this.resource.removeEventListener("error",this._onError,!0),this.emit("error",t),this._reject&&(this._reject(t),this._reject=null,this._resolve=null)}_isSourcePlaying(){const t=this.resource;return!t.paused&&!t.ended}_isSourceReady(){return this.resource.readyState>2}_onPlayStart(){this.isValid||this._mediaReady(),this._configureAutoUpdate()}_onPlayStop(){this._configureAutoUpdate()}_onSeeked(){this._autoUpdate&&!this._isSourcePlaying()&&(this._msToNextUpdate=0,this.updateFrame(),this._msToNextUpdate=0)}_onCanPlay(){this.resource.removeEventListener("canplay",this._onCanPlay),this._mediaReady()}_onCanPlayThrough(){this.resource.removeEventListener("canplaythrough",this._onCanPlay),this._preloadTimeout&&(clearTimeout(this._preloadTimeout),this._preloadTimeout=void 0),this._mediaReady()}_mediaReady(){const t=this.resource;this.isValid&&(this.isReady=!0,this.resize(t.videoWidth,t.videoHeight)),this._msToNextUpdate=0,this.updateFrame(),this._msToNextUpdate=0,this._resolve&&(this._resolve(this),this._resolve=null,this._reject=null),this._isSourcePlaying()?this._onPlayStart():this.autoPlay&&this.resource.play()}destroy(){this._configureAutoUpdate();const t=this.resource;t&&(t.removeEventListener("play",this._onPlayStart),t.removeEventListener("pause",this._onPlayStop),t.removeEventListener("seeked",this._onSeeked),t.removeEventListener("canplay",this._onCanPlay),t.removeEventListener("canplaythrough",this._onCanPlayThrough),t.removeEventListener("error",this._onError,!0),t.pause(),t.src="",t.load()),super.destroy()}get autoUpdate(){return this._autoUpdate}set autoUpdate(t){t!==this._autoUpdate&&(this._autoUpdate=t,this._configureAutoUpdate())}get updateFPS(){return this._updateFPS}set updateFPS(t){t!==this._updateFPS&&(this._updateFPS=t,this._configureAutoUpdate())}_configureAutoUpdate(){this._autoUpdate&&this._isSourcePlaying()?!this._updateFPS&&this.resource.requestVideoFrameCallback?(this._isConnectedToTicker&&(It.shared.remove(this.updateFrame,this),this._isConnectedToTicker=!1,this._msToNextUpdate=0),this._videoFrameRequestCallbackHandle===null&&(this._videoFrameRequestCallbackHandle=this.resource.requestVideoFrameCallback(this._videoFrameRequestCallback))):(this._videoFrameRequestCallbackHandle!==null&&(this.resource.cancelVideoFrameCallback(this._videoFrameRequestCallbackHandle),this._videoFrameRequestCallbackHandle=null),this._isConnectedToTicker||(It.shared.add(this.updateFrame,this),this._isConnectedToTicker=!0,this._msToNextUpdate=0)):(this._videoFrameRequestCallbackHandle!==null&&(this.resource.cancelVideoFrameCallback(this._videoFrameRequestCallbackHandle),this._videoFrameRequestCallbackHandle=null),this._isConnectedToTicker&&(It.shared.remove(this.updateFrame,this),this._isConnectedToTicker=!1,this._msToNextUpdate=0))}static test(t){return globalThis.HTMLVideoElement&&t instanceof HTMLVideoElement}};Ci.extension=G.TextureSource;Ci.defaultOptions={...Nt.defaultOptions,autoLoad:!0,autoPlay:!0,updateFPS:0,crossorigin:!0,loop:!1,muted:!0,playsinline:!0,preload:!1};Ci.MIME_TYPES={ogv:"video/ogg",mov:"video/quicktime",m4v:"video/mp4"};let fi=Ci;const vt=(i,t,e=!1)=>(Array.isArray(i)||(i=[i]),t?i.map(s=>typeof s=="string"||e?t(s):s):i);class Eo{constructor(){this._parsers=[],this._cache=new Map,this._cacheMap=new Map}reset(){this._cacheMap.clear(),this._cache.clear()}has(t){return this._cache.has(t)}get(t){const e=this._cache.get(t);return e||st(`[Assets] Asset id ${t} was not found in the Cache`),e}set(t,e){const s=vt(t);let n;for(let h=0;h{r.set(h,e)});const a=[...r.keys()],o={cacheKeys:a,keys:s};s.forEach(h=>{this._cacheMap.set(h,o)}),a.forEach(h=>{const l=n?n[h]:e;this._cache.has(h)&&this._cache.get(h)!==l&&st("[Cache] already has key:",h),this._cache.set(h,r.get(h))})}remove(t){if(!this._cacheMap.has(t)){st(`[Assets] Asset id ${t} was not found in the Cache`);return}const e=this._cacheMap.get(t);e.cacheKeys.forEach(n=>{this._cache.delete(n)}),e.keys.forEach(n=>{this._cacheMap.delete(n)})}get parsers(){return this._parsers}}const q=new Eo,ds=[];dt.handleByList(G.TextureSource,ds);function kr(i={}){const t=i&&i.resource,e=t?i.resource:i,s=t?i:{resource:i};for(let n=0;n{q.has(s)&&q.remove(s)}),t||q.set(s,r),r}function Fo(i,t=!1){return typeof i=="string"?q.get(i):i instanceof Nt?new z({source:i}):Ro(i,t)}z.from=Fo;Nt.from=kr;dt.add(vr,Cr,Tr,fi,Ce,Ar,ks);var Xt=(i=>(i[i.Low=0]="Low",i[i.Normal=1]="Normal",i[i.High=2]="High",i))(Xt||{});function St(i){if(typeof i!="string")throw new TypeError(`Path must be a string. Received ${JSON.stringify(i)}`)}function Ie(i){return i.split("?")[0].split("#")[0]}function Lo(i){return i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Do(i,t,e){return i.replace(new RegExp(Lo(t),"g"),e)}function zo(i,t){let e="",s=0,n=-1,r=0,a=-1;for(let o=0;o<=i.length;++o){if(o2){const h=e.lastIndexOf("/");if(h!==e.length-1){h===-1?(e="",s=0):(e=e.slice(0,h),s=e.length-1-e.lastIndexOf("/")),n=o,r=0;continue}}else if(e.length===2||e.length===1){e="",s=0,n=o,r=0;continue}}}else e.length>0?e+=`/${i.slice(n+1,o)}`:e=i.slice(n+1,o),s=o-n-1;n=o,r=0}else a===46&&r!==-1?++r:r=-1}return e}const xt={toPosix(i){return Do(i,"\\","/")},isUrl(i){return/^https?:/.test(this.toPosix(i))},isDataUrl(i){return/^data:([a-z]+\/[a-z0-9-+.]+(;[a-z0-9-.!#$%*+.{}|~`]+=[a-z0-9-.!#$%*+.{}()_|~`]+)*)?(;base64)?,([a-z0-9!$&',()*+;=\-._~:@\/?%\s<>]*?)$/i.test(i)},isBlobUrl(i){return i.startsWith("blob:")},hasProtocol(i){return/^[^/:]+:/.test(this.toPosix(i))},getProtocol(i){St(i),i=this.toPosix(i);const t=/^file:\/\/\//.exec(i);if(t)return t[0];const e=/^[^/:]+:\/{0,2}/.exec(i);return e?e[0]:""},toAbsolute(i,t,e){if(St(i),this.isDataUrl(i)||this.isBlobUrl(i))return i;const s=Ie(this.toPosix(t??Q.get().getBaseUrl())),n=Ie(this.toPosix(e??this.rootname(s)));return i=this.toPosix(i),i.startsWith("/")?xt.join(n,i.slice(1)):this.isAbsolute(i)?i:this.join(s,i)},normalize(i){if(St(i),i.length===0)return".";if(this.isDataUrl(i)||this.isBlobUrl(i))return i;i=this.toPosix(i);let t="";const e=i.startsWith("/");this.hasProtocol(i)&&(t=this.rootname(i),i=i.slice(t.length));const s=i.endsWith("/");return i=zo(i),i.length>0&&s&&(i+="/"),e?`/${i}`:t+i},isAbsolute(i){return St(i),i=this.toPosix(i),this.hasProtocol(i)?!0:i.startsWith("/")},join(...i){if(i.length===0)return".";let t;for(let e=0;e0)if(t===void 0)t=s;else{const n=i[e-1]??"";this.joinExtensions.includes(this.extname(n).toLowerCase())?t+=`/../${s}`:t+=`/${s}`}}return t===void 0?".":this.normalize(t)},dirname(i){if(St(i),i.length===0)return".";i=this.toPosix(i);let t=i.charCodeAt(0);const e=t===47;let s=-1,n=!0;const r=this.getProtocol(i),a=i;i=i.slice(r.length);for(let o=i.length-1;o>=1;--o)if(t=i.charCodeAt(o),t===47){if(!n){s=o;break}}else n=!1;return s===-1?e?"/":this.isUrl(a)?r+i:r:e&&s===1?"//":r+i.slice(0,s)},rootname(i){St(i),i=this.toPosix(i);let t="";if(i.startsWith("/")?t="/":t=this.getProtocol(i),this.isUrl(i)){const e=i.indexOf("/",t.length);e!==-1?t=i.slice(0,e):t=i,t.endsWith("/")||(t+="/")}return t},basename(i,t){St(i),t&&St(t),i=Ie(this.toPosix(i));let e=0,s=-1,n=!0,r;if(t!==void 0&&t.length>0&&t.length<=i.length){if(t.length===i.length&&t===i)return"";let a=t.length-1,o=-1;for(r=i.length-1;r>=0;--r){const h=i.charCodeAt(r);if(h===47){if(!n){e=r+1;break}}else o===-1&&(n=!1,o=r+1),a>=0&&(h===t.charCodeAt(a)?--a===-1&&(s=r):(a=-1,s=o))}return e===s?s=o:s===-1&&(s=i.length),i.slice(e,s)}for(r=i.length-1;r>=0;--r)if(i.charCodeAt(r)===47){if(!n){e=r+1;break}}else s===-1&&(n=!1,s=r+1);return s===-1?"":i.slice(e,s)},extname(i){St(i),i=Ie(this.toPosix(i));let t=-1,e=0,s=-1,n=!0,r=0;for(let a=i.length-1;a>=0;--a){const o=i.charCodeAt(a);if(o===47){if(!n){e=a+1;break}continue}s===-1&&(n=!1,s=a+1),o===46?t===-1?t=a:r!==1&&(r=1):t!==-1&&(r=-1)}return t===-1||s===-1||r===0||r===1&&t===s-1&&t===e+1?"":i.slice(t,s)},parse(i){St(i);const t={root:"",dir:"",base:"",ext:"",name:""};if(i.length===0)return t;i=Ie(this.toPosix(i));let e=i.charCodeAt(0);const s=this.isAbsolute(i);let n;t.root=this.rootname(i),s||this.hasProtocol(i)?n=1:n=0;let r=-1,a=0,o=-1,h=!0,l=i.length-1,c=0;for(;l>=n;--l){if(e=i.charCodeAt(l),e===47){if(!h){a=l+1;break}continue}o===-1&&(h=!1,o=l+1),e===46?r===-1?r=l:c!==1&&(c=1):r!==-1&&(c=-1)}return r===-1||o===-1||c===0||c===1&&r===o-1&&r===a+1?o!==-1&&(a===0&&s?t.base=t.name=i.slice(1,o):t.base=t.name=i.slice(a,o)):(a===0&&s?(t.name=i.slice(1,r),t.base=i.slice(1,o)):(t.name=i.slice(a,r),t.base=i.slice(a,o)),t.ext=i.slice(r,o)),t.dir=this.dirname(i),t},sep:"/",delimiter:":",joinExtensions:[".html"]};function Br(i,t,e,s,n){const r=t[e];for(let a=0;a{const a=r.substring(1,r.length-1).split(",");n.push(a)}),Br(i,n,0,e,s)}else s.push(i);return s}const wi=i=>!Array.isArray(i);class Te{constructor(){this._defaultBundleIdentifierOptions={connector:"-",createBundleAssetId:(t,e)=>`${t}${this._bundleIdConnector}${e}`,extractAssetIdFromBundle:(t,e)=>e.replace(`${t}${this._bundleIdConnector}`,"")},this._bundleIdConnector=this._defaultBundleIdentifierOptions.connector,this._createBundleAssetId=this._defaultBundleIdentifierOptions.createBundleAssetId,this._extractAssetIdFromBundle=this._defaultBundleIdentifierOptions.extractAssetIdFromBundle,this._assetMap={},this._preferredOrder=[],this._parsers=[],this._resolverHash={},this._bundles={}}setBundleIdentifier(t){if(this._bundleIdConnector=t.connector??this._bundleIdConnector,this._createBundleAssetId=t.createBundleAssetId??this._createBundleAssetId,this._extractAssetIdFromBundle=t.extractAssetIdFromBundle??this._extractAssetIdFromBundle,this._extractAssetIdFromBundle("foo",this._createBundleAssetId("foo","bar"))!=="bar")throw new Error("[Resolver] GenerateBundleAssetId are not working correctly")}prefer(...t){t.forEach(e=>{this._preferredOrder.push(e),e.priority||(e.priority=Object.keys(e.params))}),this._resolverHash={}}set basePath(t){this._basePath=t}get basePath(){return this._basePath}set rootPath(t){this._rootPath=t}get rootPath(){return this._rootPath}get parsers(){return this._parsers}reset(){this.setBundleIdentifier(this._defaultBundleIdentifierOptions),this._assetMap={},this._preferredOrder=[],this._resolverHash={},this._rootPath=null,this._basePath=null,this._manifest=null,this._bundles={},this._defaultSearchParams=null}setDefaultSearchParams(t){if(typeof t=="string")this._defaultSearchParams=t;else{const e=t;this._defaultSearchParams=Object.keys(e).map(s=>`${encodeURIComponent(s)}=${encodeURIComponent(e[s])}`).join("&")}}getAlias(t){const{alias:e,src:s}=t;return vt(e||s,r=>typeof r=="string"?r:Array.isArray(r)?r.map(a=>(a==null?void 0:a.src)??a):r!=null&&r.src?r.src:r,!0)}addManifest(t){this._manifest&&st("[Resolver] Manifest already exists, this will be overwritten"),this._manifest=t,t.bundles.forEach(e=>{this.addBundle(e.name,e.assets)})}addBundle(t,e){const s=[];let n=e;Array.isArray(e)||(n=Object.entries(e).map(([r,a])=>typeof a=="string"||Array.isArray(a)?{alias:r,src:a}:{alias:r,...a})),n.forEach(r=>{const a=r.src,o=r.alias;let h;if(typeof o=="string"){const l=this._createBundleAssetId(t,o);s.push(l),h=[o,l]}else{const l=o.map(c=>this._createBundleAssetId(t,c));s.push(...l),h=[...o,...l]}this.add({...r,alias:h,src:a})}),this._bundles[t]=s}add(t){const e=[];Array.isArray(t)?e.push(...t):e.push(t);let s;s=r=>{this.hasKey(r)&&st(`[Resolver] already has key: ${r} overwriting`)},vt(e).forEach(r=>{const{src:a}=r;let{data:o,format:h,loadParser:l}=r;const c=vt(a).map(g=>typeof g=="string"?Uo(g):Array.isArray(g)?g:[g]),d=this.getAlias(r);Array.isArray(d)?d.forEach(s):s(d);const f=[];c.forEach(g=>{g.forEach(m=>{let y={};if(typeof m!="object"){y.src=m;for(let x=0;x{this._assetMap[g]=f})})}resolveBundle(t){const e=wi(t);t=vt(t);const s={};return t.forEach(n=>{const r=this._bundles[n];if(r){const a=this.resolve(r),o={};for(const h in a){const l=a[h];o[this._extractAssetIdFromBundle(n,h)]=l}s[n]=o}}),e?s[t[0]]:s}resolveUrl(t){const e=this.resolve(t);if(typeof t!="string"){const s={};for(const n in e)s[n]=e[n].src;return s}return e.src}resolve(t){const e=wi(t);t=vt(t);const s={};return t.forEach(n=>{if(!this._resolverHash[n])if(this._assetMap[n]){let r=this._assetMap[n];const a=this._getPreferredOrder(r);a==null||a.priority.forEach(o=>{a.params[o].forEach(h=>{const l=r.filter(c=>c[o]?c[o]===h:!1);l.length&&(r=l)})}),this._resolverHash[n]=r[0]}else this._resolverHash[n]=this._buildResolvedAsset({alias:[n],src:n},{});s[n]=this._resolverHash[n]}),e?s[t[0]]:s}hasKey(t){return!!this._assetMap[t]}hasBundle(t){return!!this._bundles[t]}_getPreferredOrder(t){for(let e=0;er.params.format.includes(s.format));if(n)return n}return this._preferredOrder[0]}_appendDefaultSearchParams(t){if(!this._defaultSearchParams)return t;const e=/\?/.test(t)?"&":"?";return`${t}${e}${this._defaultSearchParams}`}_buildResolvedAsset(t,e){const{aliases:s,data:n,loadParser:r,format:a}=e;return(this._basePath||this._rootPath)&&(t.src=xt.toAbsolute(t.src,this._basePath,this._rootPath)),t.alias=s??t.alias??[t.src],t.src=this._appendDefaultSearchParams(t.src),t.data={...n||{},...t.data},t.loadParser=r??t.loadParser,t.format=a??t.format??No(t.src),t}}Te.RETINA_PREFIX=/@([0-9\.]+)x/;function No(i){return i.split(".").pop().split("?").shift().split("#").shift()}const us=(i,t)=>{const e=t.split("?")[1];return e&&(i+=`?${e}`),i},Ir=class ze{constructor(t,e){this.linkedSheets=[],this._texture=t instanceof z?t:null,this.textureSource=t.source,this.textures={},this.animations={},this.data=e;const s=parseFloat(e.meta.scale);s?(this.resolution=s,t.source.resolution=this.resolution):this.resolution=t.source._resolution,this._frames=this.data.frames,this._frameKeys=Object.keys(this._frames),this._batchIndex=0,this._callback=null}parse(){return new Promise(t=>{this._callback=t,this._batchIndex=0,this._frameKeys.length<=ze.BATCH_SIZE?(this._processFrames(0),this._processAnimations(),this._parseComplete()):this._nextBatch()})}_processFrames(t){let e=t;const s=ze.BATCH_SIZE;for(;e-t{this._batchIndex*ze.BATCH_SIZE{s[n]=t}),Object.keys(t.textures).forEach(n=>{s[n]=t.textures[n]}),!e){const n=xt.dirname(i[0]);t.linkedSheets.forEach((r,a)=>{const o=Er([`${n}/${t.data.meta.related_multi_packs[a]}`],r,!0);Object.assign(s,o)})}return s}const Wo={extension:G.Asset,cache:{test:i=>i instanceof _i,getCacheableAssets:(i,t)=>Er(i,t,!1)},resolver:{extension:{type:G.ResolveParser,name:"resolveSpritesheet"},test:i=>{const e=i.split("?")[0].split("."),s=e.pop(),n=e.pop();return s==="json"&&Oo.includes(n)},parse:i=>{var e;const t=i.split(".");return{resolution:parseFloat(((e=Te.RETINA_PREFIX.exec(i))==null?void 0:e[1])??"1"),format:t[t.length-2],src:i}}},loader:{name:"spritesheetLoader",extension:{type:G.LoadParser,priority:Xt.Normal,name:"spritesheetLoader"},async testParse(i,t){return xt.extname(t.src).toLowerCase()===".json"&&!!i.frames},async parse(i,t,e){var l,c;const{texture:s,imageFilename:n}=(t==null?void 0:t.data)??{};let r=xt.dirname(t.src);r&&r.lastIndexOf("/")!==r.length-1&&(r+="/");let a;if(s instanceof z)a=s;else{const d=us(r+(n??i.meta.image),t.src);a=(await e.load([d]))[d]}const o=new _i(a.source,i);await o.parse();const h=(l=i==null?void 0:i.meta)==null?void 0:l.related_multi_packs;if(Array.isArray(h)){const d=[];for(const g of h){if(typeof g!="string")continue;let m=r+g;(c=t.data)!=null&&c.ignoreMultiPack||(m=us(m,t.src),d.push(e.load({src:m,data:{ignoreMultiPack:!0}})))}const f=await Promise.all(d);o.linkedSheets=f,f.forEach(g=>{g.linkedSheets=[o].concat(o.linkedSheets.filter(m=>m!==g))})}return o},async unload(i,t,e){await e.unload(i.textureSource._sourceOrigin),i.destroy(!1)}}};dt.add(Wo);const Vi=Object.create(null),_n=Object.create(null);function Is(i,t){let e=_n[i];return e===void 0&&(Vi[t]===void 0&&(Vi[t]=1),_n[i]=e=Vi[t]++),e}let he;function Rr(){return(!he||he!=null&&he.isContextLost())&&(he=Q.get().createCanvas().getContext("webgl",{})),he}let ri;function Ho(){if(!ri){ri="mediump";const i=Rr();i&&i.getShaderPrecisionFormat&&(ri=i.getShaderPrecisionFormat(i.FRAGMENT_SHADER,i.HIGH_FLOAT).precision?"highp":"mediump")}return ri}function $o(i,t,e){return t?i:e?(i=i.replace("out vec4 finalColor;",""),` #ifdef GL_ES // This checks if it is WebGL1 #define in varying @@ -22,9 +22,9 @@ Deprecated since v${i}`),console.warn(s))),en[t]=!0}const ar=()=>{};function sn( `}function Vo(i,t,e){const s=e?t.maxSupportedFragmentPrecision:t.maxSupportedVertexPrecision;if(i.substring(0,9)!=="precision"){let n=e?t.requestedFragmentPrecision:t.requestedVertexPrecision;return n==="highp"&&s!=="highp"&&(n="mediump"),`precision ${n} float; ${i}`}else if(s!=="highp"&&i.substring(0,15)==="precision highp")return i.replace("precision highp","precision mediump");return i}function Yo(i,t){return t?`#version 300 es ${i}`:i}const Xo={},jo={};function qo(i,{name:t="pixi-program"},e=!0){t=t.replace(/\s+/g,"-"),t+=e?"-fragment":"-vertex";const s=e?Xo:jo;return s[t]?(s[t]++,t+=`-${s[t]}`):s[t]=1,i.indexOf("#define SHADER_NAME")!==-1?i:`${`#define SHADER_NAME ${t}`} -${i}`}function Ko(i,t){return t?i.replace("#version 300 es",""):i}const Vi={stripVersion:Ko,ensurePrecision:Vo,addProgramDefines:$o,setProgramName:qo,insertVersion:Yo},Yi=Object.create(null),Fr=class us{constructor(t){t={...us.defaultOptions,...t};const e=t.fragment.indexOf("#version 300 es")!==-1,s={stripVersion:e,ensurePrecision:{requestedFragmentPrecision:t.preferredFragmentPrecision,requestedVertexPrecision:t.preferredVertexPrecision,maxSupportedVertexPrecision:"highp",maxSupportedFragmentPrecision:Ho()},setProgramName:{name:t.name},addProgramDefines:e,insertVersion:e};let n=t.fragment,r=t.vertex;Object.keys(Vi).forEach(a=>{const o=s[a];n=Vi[a](n,o,!0),r=Vi[a](r,o,!1)}),this.fragment=n,this.vertex=r,this._key=Bs(`${this.vertex}:${this.fragment}`,"gl-program")}destroy(){this.fragment=null,this.vertex=null,this._attributeData=null,this._uniformData=null,this._uniformBlockData=null,this.transformFeedbackVaryings=null}static from(t){const e=`${t.vertex}:${t.fragment}`;return Yi[e]||(Yi[e]=new us(t)),Yi[e]}};Fr.defaultOptions={preferredVertexPrecision:"highp",preferredFragmentPrecision:"mediump"};let Lr=Fr;const bn={uint8x2:{size:2,stride:2,normalised:!1},uint8x4:{size:4,stride:4,normalised:!1},sint8x2:{size:2,stride:2,normalised:!1},sint8x4:{size:4,stride:4,normalised:!1},unorm8x2:{size:2,stride:2,normalised:!0},unorm8x4:{size:4,stride:4,normalised:!0},snorm8x2:{size:2,stride:2,normalised:!0},snorm8x4:{size:4,stride:4,normalised:!0},uint16x2:{size:2,stride:4,normalised:!1},uint16x4:{size:4,stride:8,normalised:!1},sint16x2:{size:2,stride:4,normalised:!1},sint16x4:{size:4,stride:8,normalised:!1},unorm16x2:{size:2,stride:4,normalised:!0},unorm16x4:{size:4,stride:8,normalised:!0},snorm16x2:{size:2,stride:4,normalised:!0},snorm16x4:{size:4,stride:8,normalised:!0},float16x2:{size:2,stride:4,normalised:!1},float16x4:{size:4,stride:8,normalised:!1},float32:{size:1,stride:4,normalised:!1},float32x2:{size:2,stride:8,normalised:!1},float32x3:{size:3,stride:12,normalised:!1},float32x4:{size:4,stride:16,normalised:!1},uint32:{size:1,stride:4,normalised:!1},uint32x2:{size:2,stride:8,normalised:!1},uint32x3:{size:3,stride:12,normalised:!1},uint32x4:{size:4,stride:16,normalised:!1},sint32:{size:1,stride:4,normalised:!1},sint32x2:{size:2,stride:8,normalised:!1},sint32x3:{size:3,stride:12,normalised:!1},sint32x4:{size:4,stride:16,normalised:!1}};function Zo(i){return bn[i]??bn.float32}const Qo={f32:"float32","vec2":"float32x2","vec3":"float32x3","vec4":"float32x4",vec2f:"float32x2",vec3f:"float32x3",vec4f:"float32x4",i32:"sint32","vec2":"sint32x2","vec3":"sint32x3","vec4":"sint32x4",u32:"uint32","vec2":"uint32x2","vec3":"uint32x3","vec4":"uint32x4",bool:"uint32","vec2":"uint32x2","vec3":"uint32x3","vec4":"uint32x4"};function Jo({source:i,entryPoint:t}){const e={},s=i.indexOf(`fn ${t}`);if(s!==-1){const n=i.indexOf("->",s);if(n!==-1){const r=i.substring(s,n),a=/@location\((\d+)\)\s+([a-zA-Z0-9_]+)\s*:\s*([a-zA-Z0-9_<>]+)(?:,|\s|$)/g;let o;for(;(o=a.exec(r))!==null;){const h=Qo[o[3]]??"float32";e[o[2]]={location:parseInt(o[1],10),format:h,stride:Zo(h).stride,offset:0,instance:!1,start:0}}}}return e}function Xi(i){var d,f;const t=/(^|[^/])@(group|binding)\(\d+\)[^;]+;/g,e=/@group\((\d+)\)/,s=/@binding\((\d+)\)/,n=/var(<[^>]+>)? (\w+)/,r=/:\s*(\w+)/,a=/struct\s+(\w+)\s*{([^}]+)}/g,o=/(\w+)\s*:\s*([\w\<\>]+)/g,h=/struct\s+(\w+)/,l=(d=i.match(t))==null?void 0:d.map(g=>({group:parseInt(g.match(e)[1],10),binding:parseInt(g.match(s)[1],10),name:g.match(n)[2],isUniform:g.match(n)[1]==="",type:g.match(r)[1]}));if(!l)return{groups:[],structs:[]};const c=((f=i.match(a))==null?void 0:f.map(g=>{const m=g.match(h)[1],y=g.match(o).reduce((x,w)=>{const[_,b]=w.split(":");return x[_.trim()]=b.trim(),x},{});return y?{name:m,members:y}:null}).filter(({name:g})=>l.some(m=>m.type===g)))??[];return{groups:l,structs:c}}var Ue=(i=>(i[i.VERTEX=1]="VERTEX",i[i.FRAGMENT=2]="FRAGMENT",i[i.COMPUTE=4]="COMPUTE",i))(Ue||{});function th({groups:i}){const t=[];for(let e=0;ee.has(a.name)?!1:(e.add(a.name),!0)),r=[...i.groups,...t.groups].filter(a=>{const o=`${a.name}-${a.binding}`;return s.has(o)?!1:(s.add(o),!0)});return{structs:n,groups:r}}const ji=Object.create(null);class Ci{constructor(t){var o,h;this._layoutKey=0,this._attributeLocationsKey=0;const{fragment:e,vertex:s,layout:n,gpuLayout:r,name:a}=t;if(this.name=a,this.fragment=e,this.vertex=s,e.source===s.source){const l=Xi(e.source);this.structsAndGroups=l}else{const l=Xi(s.source),c=Xi(e.source);this.structsAndGroups=ih(l,c)}this.layout=n??eh(this.structsAndGroups),this.gpuLayout=r??th(this.structsAndGroups),this.autoAssignGlobalUniforms=((o=this.layout[0])==null?void 0:o.globalUniforms)!==void 0,this.autoAssignLocalUniforms=((h=this.layout[1])==null?void 0:h.localUniforms)!==void 0,this._generateProgramKey()}_generateProgramKey(){const{vertex:t,fragment:e}=this,s=t.source+e.source+t.entryPoint+e.entryPoint;this._layoutKey=Bs(s,"program")}get attributeData(){return this._attributeData??(this._attributeData=Jo(this.vertex)),this._attributeData}destroy(){this.gpuLayout=null,this.layout=null,this.structsAndGroups=null,this.fragment=null,this.vertex=null}static from(t){const e=`${t.vertex.source}:${t.fragment.source}:${t.fragment.entryPoint}:${t.vertex.entryPoint}`;return ji[e]||(ji[e]=new Ci(t)),ji[e]}}const Dr=["f32","i32","vec2","vec3","vec4","mat2x2","mat3x3","mat4x4","mat3x2","mat4x2","mat2x3","mat4x3","mat2x4","mat3x4"],sh=Dr.reduce((i,t)=>(i[t]=!0,i),{});function nh(i,t){switch(i){case"f32":return 0;case"vec2":return new Float32Array(2*t);case"vec3":return new Float32Array(3*t);case"vec4":return new Float32Array(4*t);case"mat2x2":return new Float32Array([1,0,0,1]);case"mat3x3":return new Float32Array([1,0,0,0,1,0,0,0,1]);case"mat4x4":return new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])}return null}const zr=class Ur{constructor(t,e){this._touched=0,this.uid=nt("uniform"),this._resourceType="uniformGroup",this._resourceId=nt("resource"),this.isUniformGroup=!0,this._dirtyId=0,this.destroyed=!1,e={...Ur.defaultOptions,...e},this.uniformStructures=t;const s={};for(const n in t){const r=t[n];if(r.name=n,r.size=r.size??1,!sh[r.type])throw new Error(`Uniform type ${r.type} is not supported. Supported uniform types are: ${Dr.join(", ")}`);r.value??(r.value=nh(r.type,r.size)),s[n]=r.value}this.uniforms=s,this._dirtyId=1,this.ubo=e.ubo,this.isStatic=e.isStatic,this._signature=Bs(Object.keys(s).map(n=>`${n}-${t[n].type}`).join("-"),"uniform-group")}update(){this._dirtyId++}};zr.defaultOptions={ubo:!1,isStatic:!1};let Or=zr;class pi{constructor(t){this.resources=Object.create(null),this._dirty=!0;let e=0;for(const s in t){const n=t[s];this.setResource(n,e++)}this._updateKey()}_updateKey(){if(!this._dirty)return;this._dirty=!1;const t=[];let e=0;for(const s in this.resources)t[e++]=this.resources[s]._resourceId;this._key=t.join("|")}setResource(t,e){var n,r;const s=this.resources[e];t!==s&&(s&&((n=t.off)==null||n.call(t,"change",this.onResourceChange,this)),(r=t.on)==null||r.call(t,"change",this.onResourceChange,this),this.resources[e]=t,this._dirty=!0)}getResource(t){return this.resources[t]}_touch(t){const e=this.resources;for(const s in e)e[s]._touched=t}destroy(){var e;const t=this.resources;for(const s in t){const n=t[s];(e=n.off)==null||e.call(n,"change",this.onResourceChange,this)}this.resources=null}onResourceChange(t){if(this._dirty=!0,t.destroyed){const e=this.resources;for(const s in e)e[s]===t&&(e[s]=null)}else this._updateKey()}}var fs=(i=>(i[i.WEBGL=1]="WEBGL",i[i.WEBGPU=2]="WEBGPU",i[i.BOTH=3]="BOTH",i))(fs||{});class Is extends gt{constructor(t){super(),this._uniformBindMap=Object.create(null),this._ownedBindGroups=[];let{gpuProgram:e,glProgram:s,groups:n,resources:r,compatibleRenderers:a,groupMap:o}=t;this.gpuProgram=e,this.glProgram=s,a===void 0&&(a=0,e&&(a|=fs.WEBGPU),s&&(a|=fs.WEBGL)),this.compatibleRenderers=a;const h={};if(!r&&!n&&(r={}),r&&n)throw new Error("[Shader] Cannot have both resources and groups");if(!e&&n&&!o)throw new Error("[Shader] No group map or WebGPU shader provided - consider using resources instead.");if(!e&&n&&o)for(const l in o)for(const c in o[l]){const d=o[l][c];h[d]={group:l,binding:c,name:d}}else if(e&&n&&!o){const l=e.structsAndGroups.groups;o={},l.forEach(c=>{o[c.group]=o[c.group]||{},o[c.group][c.binding]=c.name,h[c.name]=c})}else if(r){n={},o={},e&&e.structsAndGroups.groups.forEach(d=>{o[d.group]=o[d.group]||{},o[d.group][d.binding]=d.name,h[d.name]=d});let l=0;for(const c in r)h[c]||(n[99]||(n[99]=new pi,this._ownedBindGroups.push(n[99])),h[c]={group:99,binding:l,name:c},o[99]=o[99]||{},o[99][l]=c,l++);for(const c in r){const d=c;let f=r[c];!f.source&&!f._resourceType&&(f=new Or(f));const g=h[d];g&&(n[g.group]||(n[g.group]=new pi,this._ownedBindGroups.push(n[g.group])),n[g.group].setResource(f,g.binding))}}this.groups=n,this._uniformBindMap=o,this.resources=this._buildResourceAccessor(n,h)}addResource(t,e,s){var n,r;(n=this._uniformBindMap)[e]||(n[e]={}),(r=this._uniformBindMap[e])[s]||(r[s]=t),this.groups[e]||(this.groups[e]=new pi,this._ownedBindGroups.push(this.groups[e]))}_buildResourceAccessor(t,e){const s={};for(const n in e){const r=e[n];Object.defineProperty(s,r.name,{get(){return t[r.group].getResource(r.binding)},set(a){t[r.group].setResource(a,r.binding)}})}return s}destroy(t=!1){var e,s;this.emit("destroy",this),t&&((e=this.gpuProgram)==null||e.destroy(),(s=this.glProgram)==null||s.destroy()),this.gpuProgram=null,this.glProgram=null,this.removeAllListeners(),this._uniformBindMap=null,this._ownedBindGroups.forEach(n=>{n.destroy()}),this._ownedBindGroups=null,this.resources=null,this.groups=null}static from(t){const{gpu:e,gl:s,...n}=t;let r,a;return e&&(r=Ci.from(e)),s&&(a=Lr.from(s)),new Is({gpuProgram:r,glProgram:a,...n})}}const ps=[];dt.handleByNamedList(G.Environment,ps);async function rh(i){if(!i)for(let t=0;t80*e){o=l=i[0],h=c=i[1];for(var m=e;ml&&(l=d),f>c&&(c=f);g=Math.max(l-o,c-h),g=g!==0?32767/g:0}return $e(r,a,e,o,h,g,0),a}function Nr(i,t,e,s,n){var r,a;if(n===xs(i,t,e,s)>0)for(r=t;r=t;r-=s)a=Sn(r,i[r],i[r+1],a);return a&&Ai(a,a.next)&&(Ye(a),a=a.next),a}function ae(i,t){if(!i)return i;t||(t=i);var e=i,s;do if(s=!1,!e.steiner&&(Ai(e,e.next)||K(e.prev,e,e.next)===0)){if(Ye(e),e=t=e.prev,e===e.next)break;s=!0}else e=e.next;while(s||e!==t);return t}function $e(i,t,e,s,n,r,a){if(i){!a&&r&&mh(i,s,n,r);for(var o=i,h,l;i.prev!==i.next;){if(h=i.prev,l=i.next,r?hh(i,s,n,r):oh(i)){t.push(h.i/e|0),t.push(i.i/e|0),t.push(l.i/e|0),Ye(i),i=l.next,o=l.next;continue}if(i=l,i===o){a?a===1?(i=lh(ae(i),t,e),$e(i,t,e,s,n,r,2)):a===2&&ch(i,t,e,s,n,r):$e(ae(i),t,e,s,n,r,1);break}}}}function oh(i){var t=i.prev,e=i,s=i.next;if(K(t,e,s)>=0)return!1;for(var n=t.x,r=e.x,a=s.x,o=t.y,h=e.y,l=s.y,c=nr?n>a?n:a:r>a?r:a,g=o>h?o>l?o:l:h>l?h:l,m=s.next;m!==t;){if(m.x>=c&&m.x<=f&&m.y>=d&&m.y<=g&&ue(n,o,r,h,a,l,m.x,m.y)&&K(m.prev,m,m.next)>=0)return!1;m=m.next}return!0}function hh(i,t,e,s){var n=i.prev,r=i,a=i.next;if(K(n,r,a)>=0)return!1;for(var o=n.x,h=r.x,l=a.x,c=n.y,d=r.y,f=a.y,g=oh?o>l?o:l:h>l?h:l,x=c>d?c>f?c:f:d>f?d:f,w=gs(g,m,t,e,s),_=gs(y,x,t,e,s),b=i.prevZ,S=i.nextZ;b&&b.z>=w&&S&&S.z<=_;){if(b.x>=g&&b.x<=y&&b.y>=m&&b.y<=x&&b!==n&&b!==a&&ue(o,c,h,d,l,f,b.x,b.y)&&K(b.prev,b,b.next)>=0||(b=b.prevZ,S.x>=g&&S.x<=y&&S.y>=m&&S.y<=x&&S!==n&&S!==a&&ue(o,c,h,d,l,f,S.x,S.y)&&K(S.prev,S,S.next)>=0))return!1;S=S.nextZ}for(;b&&b.z>=w;){if(b.x>=g&&b.x<=y&&b.y>=m&&b.y<=x&&b!==n&&b!==a&&ue(o,c,h,d,l,f,b.x,b.y)&&K(b.prev,b,b.next)>=0)return!1;b=b.prevZ}for(;S&&S.z<=_;){if(S.x>=g&&S.x<=y&&S.y>=m&&S.y<=x&&S!==n&&S!==a&&ue(o,c,h,d,l,f,S.x,S.y)&&K(S.prev,S,S.next)>=0)return!1;S=S.nextZ}return!0}function lh(i,t,e){var s=i;do{var n=s.prev,r=s.next.next;!Ai(n,r)&&Wr(n,s,s.next,r)&&Ve(n,r)&&Ve(r,n)&&(t.push(n.i/e|0),t.push(s.i/e|0),t.push(r.i/e|0),Ye(s),Ye(s.next),s=i=r),s=s.next}while(s!==i);return ae(s)}function ch(i,t,e,s,n,r){var a=i;do{for(var o=a.next.next;o!==a.prev;){if(a.i!==o.i&&wh(a,o)){var h=Hr(a,o);a=ae(a,a.next),h=ae(h,h.next),$e(a,t,e,s,n,r,0),$e(h,t,e,s,n,r,0);return}o=o.next}a=a.next}while(a!==i)}function dh(i,t,e,s){var n=[],r,a,o,h,l;for(r=0,a=t.length;r=e.next.y&&e.next.y!==e.y){var o=e.x+(n-e.y)*(e.next.x-e.x)/(e.next.y-e.y);if(o<=s&&o>r&&(r=o,a=e.x=e.x&&e.x>=l&&s!==e.x&&ue(na.x||e.x===a.x&&gh(a,e)))&&(a=e,d=f)),e=e.next;while(e!==h);return a}function gh(i,t){return K(i.prev,i,t.prev)<0&&K(t.next,i,i.next)<0}function mh(i,t,e,s){var n=i;do n.z===0&&(n.z=gs(n.x,n.y,t,e,s)),n.prevZ=n.prev,n.nextZ=n.next,n=n.next;while(n!==i);n.prevZ.nextZ=null,n.prevZ=null,xh(n)}function xh(i){var t,e,s,n,r,a,o,h,l=1;do{for(e=i,i=null,r=null,a=0;e;){for(a++,s=e,o=0,t=0;t0||h>0&&s;)o!==0&&(h===0||!s||e.z<=s.z)?(n=e,e=e.nextZ,o--):(n=s,s=s.nextZ,h--),r?r.nextZ=n:i=n,n.prevZ=r,r=n;e=s}r.nextZ=null,l*=2}while(a>1);return i}function gs(i,t,e,s,n){return i=(i-e)*n|0,t=(t-s)*n|0,i=(i|i<<8)&16711935,i=(i|i<<4)&252645135,i=(i|i<<2)&858993459,i=(i|i<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,i|t<<1}function yh(i){var t=i,e=i;do(t.x=(i-a)*(r-o)&&(i-a)*(s-o)>=(e-a)*(t-o)&&(e-a)*(r-o)>=(n-a)*(s-o)}function wh(i,t){return i.next.i!==t.i&&i.prev.i!==t.i&&!_h(i,t)&&(Ve(i,t)&&Ve(t,i)&&bh(i,t)&&(K(i.prev,i,t.prev)||K(i,t.prev,t))||Ai(i,t)&&K(i.prev,i,i.next)>0&&K(t.prev,t,t.next)>0)}function K(i,t,e){return(t.y-i.y)*(e.x-t.x)-(t.x-i.x)*(e.y-t.y)}function Ai(i,t){return i.x===t.x&&i.y===t.y}function Wr(i,t,e,s){var n=oi(K(i,t,e)),r=oi(K(i,t,s)),a=oi(K(e,s,i)),o=oi(K(e,s,t));return!!(n!==r&&a!==o||n===0&&ai(i,e,t)||r===0&&ai(i,s,t)||a===0&&ai(e,i,s)||o===0&&ai(e,t,s))}function ai(i,t,e){return t.x<=Math.max(i.x,e.x)&&t.x>=Math.min(i.x,e.x)&&t.y<=Math.max(i.y,e.y)&&t.y>=Math.min(i.y,e.y)}function oi(i){return i>0?1:i<0?-1:0}function _h(i,t){var e=i;do{if(e.i!==i.i&&e.next.i!==i.i&&e.i!==t.i&&e.next.i!==t.i&&Wr(e,e.next,i,t))return!0;e=e.next}while(e!==i);return!1}function Ve(i,t){return K(i.prev,i,i.next)<0?K(i,t,i.next)>=0&&K(i,i.prev,t)>=0:K(i,t,i.prev)<0||K(i,i.next,t)<0}function bh(i,t){var e=i,s=!1,n=(i.x+t.x)/2,r=(i.y+t.y)/2;do e.y>r!=e.next.y>r&&e.next.y!==e.y&&n<(e.next.x-e.x)*(r-e.y)/(e.next.y-e.y)+e.x&&(s=!s),e=e.next;while(e!==i);return s}function Hr(i,t){var e=new ms(i.i,i.x,i.y),s=new ms(t.i,t.x,t.y),n=i.next,r=t.prev;return i.next=t,t.prev=i,e.next=n,n.prev=e,s.next=e,e.prev=s,r.next=s,s.prev=r,s}function Sn(i,t,e,s){var n=new ms(i,t,e);return s?(n.next=s.next,n.prev=s,s.next.prev=n,s.next=n):(n.prev=n,n.next=n),n}function Ye(i){i.next.prev=i.prev,i.prev.next=i.next,i.prevZ&&(i.prevZ.nextZ=i.nextZ),i.nextZ&&(i.nextZ.prevZ=i.prevZ)}function ms(i,t,e){this.i=i,this.x=t,this.y=e,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}Ti.deviation=function(i,t,e,s){var n=t&&t.length,r=n?t[0]*e:i.length,a=Math.abs(xs(i,0,r,e));if(n)for(var o=0,h=t.length;o0&&(s+=i[n-1].length,e.holes.push(s))}return e};var Sh=Es.exports;const vh=Ps(Sh);var $r=(i=>(i[i.NONE=0]="NONE",i[i.COLOR=16384]="COLOR",i[i.STENCIL=1024]="STENCIL",i[i.DEPTH=256]="DEPTH",i[i.COLOR_DEPTH=16640]="COLOR_DEPTH",i[i.COLOR_STENCIL=17408]="COLOR_STENCIL",i[i.DEPTH_STENCIL=1280]="DEPTH_STENCIL",i[i.ALL=17664]="ALL",i))($r||{});class Ch{constructor(t){this.items=[],this._name=t}emit(t,e,s,n,r,a,o,h){const{name:l,items:c}=this;for(let d=0,f=c.length;d{this.runners[e]=new Ch(e)})}_addSystems(t){let e;for(e in t){const s=t[e];this._addSystem(s.value,s.name)}}_addSystem(t,e){const s=new t(this);if(this[e])throw new Error(`Whoops! The name "${e}" is already in use`);this[e]=s,this._systemsHash[e]=s;for(const n in this.runners)this.runners[n].add(s);return this}_addPipes(t,e){const s=e.reduce((n,r)=>(n[r.name]=r.value,n),{});t.forEach(n=>{const r=n.value,a=n.name,o=s[a];this.renderPipes[a]=new r(this,o?new o:null)})}destroy(t=!1){this.runners.destroy.items.reverse(),this.runners.destroy.emit(t),Object.values(this.runners).forEach(e=>{e.destroy()}),this._systemsHash=null,this.renderPipes=null}generateTexture(t){return this.textureGenerator.generateTexture(t)}get roundPixels(){return!!this._roundPixels}_unsafeEvalCheck(){if(!ah())throw new Error("Current environment does not allow unsafe-eval, please use pixi.js/unsafe-eval module to enable support.")}};Vr.defaultOptions={resolution:1,failIfMajorPerformanceCaveat:!1,roundPixels:!1};let Xr=Vr,hi;function Ah(i){return hi!==void 0||(hi=(()=>{var e;const t={stencil:!0,failIfMajorPerformanceCaveat:i??Xr.defaultOptions.failIfMajorPerformanceCaveat};try{if(!Q.get().getWebGLRenderingContext())return!1;let n=Q.get().createCanvas().getContext("webgl",t);const r=!!((e=n==null?void 0:n.getContextAttributes())!=null&&e.stencil);if(n){const a=n.getExtension("WEBGL_lose_context");a&&a.loseContext()}return n=null,r}catch{return!1}})()),hi}let li;async function Mh(i={}){return li!==void 0||(li=await(async()=>{const t=Q.get().getNavigator().gpu;if(!t)return!1;try{return await(await t.requestAdapter(i)).requestDevice(),!0}catch{return!1}})()),li}const vn=["webgl","webgpu","canvas"];async function Ph(i){let t=[];i.preference?(t.push(i.preference),vn.forEach(r=>{r!==i.preference&&t.push(r)})):t=vn.slice();let e,s={};for(let r=0;r{const{WebGPURenderer:h}=await import("./WebGPURenderer-CUsLfpfB.js");return{WebGPURenderer:h}},__vite__mapDeps([3,2,4]));e=o,s={...i,...i.webgpu};break}else if(a==="webgl"&&Ah(i.failIfMajorPerformanceCaveat??Xr.defaultOptions.failIfMajorPerformanceCaveat)){const{WebGLRenderer:o}=await mi(async()=>{const{WebGLRenderer:h}=await import("./WebGLRenderer-DaH2izjB.js");return{WebGLRenderer:h}},__vite__mapDeps([5,2,4]));e=o,s={...i,...i.webgl};break}else if(a==="canvas")throw s={...i},new Error("CanvasRenderer is not yet implemented")}if(delete s.webgpu,delete s.webgl,!e)throw new Error("No available renderer for the current environment");const n=new e;return await n.init(s),n}const jr="8.4.0";class qr{static init(){var t;(t=globalThis.__PIXI_APP_INIT__)==null||t.call(globalThis,this,jr)}static destroy(){}}qr.extension=G.Application;class Gh{constructor(t){this._renderer=t}init(){var t;(t=globalThis.__PIXI_RENDERER_INIT__)==null||t.call(globalThis,this._renderer,jr)}destroy(){this._renderer=null}}Gh.extension={type:[G.WebGLSystem,G.WebGPUSystem],name:"initHook",priority:-10};const Kr=class ys{constructor(...t){this.stage=new tt,t[0]!==void 0&&U(N,"Application constructor options are deprecated, please use Application.init() instead.")}async init(t){t={...t},this.renderer=await Ph(t),ys._plugins.forEach(e=>{e.init.call(this,t)})}render(){this.renderer.render({container:this.stage})}get canvas(){return this.renderer.canvas}get view(){return U(N,"Application.view is deprecated, please use Application.canvas instead."),this.renderer.canvas}get screen(){return this.renderer.screen}destroy(t=!1,e=!1){const s=ys._plugins.slice(0);s.reverse(),s.forEach(n=>{n.destroy.call(this)}),this.stage.destroy(e),this.stage=null,this.renderer.destroy(t),this.renderer=null}};Kr._plugins=[];let Zr=Kr;dt.handleByList(G.Application,Zr._plugins);dt.add(qr);class Qr extends gt{constructor(){super(...arguments),this.chars=Object.create(null),this.lineHeight=0,this.fontFamily="",this.fontMetrics={fontSize:0,ascent:0,descent:0},this.baseLineOffset=0,this.distanceField={type:"none",range:0},this.pages=[],this.applyFillAsTint=!0,this.baseMeasurementFontSize=100,this.baseRenderedFontSize=100}get font(){return U(N,"BitmapFont.font is deprecated, please use BitmapFont.fontFamily instead."),this.fontFamily}get pageTextures(){return U(N,"BitmapFont.pageTextures is deprecated, please use BitmapFont.pages instead."),this.pages}get size(){return U(N,"BitmapFont.size is deprecated, please use BitmapFont.fontMetrics.fontSize instead."),this.fontMetrics.fontSize}get distanceFieldRange(){return U(N,"BitmapFont.distanceFieldRange is deprecated, please use BitmapFont.distanceField.range instead."),this.distanceField.range}get distanceFieldType(){return U(N,"BitmapFont.distanceFieldType is deprecated, please use BitmapFont.distanceField.type instead."),this.distanceField.type}destroy(t=!1){var e;this.emit("destroy",this),this.removeAllListeners();for(const s in this.chars)(e=this.chars[s].texture)==null||e.destroy();this.chars=null,t&&(this.pages.forEach(s=>s.texture.destroy(!0)),this.pages=null)}}const Jr=class ws{constructor(t,e,s,n){this.uid=nt("fillGradient"),this.type="linear",this.gradientStops=[],this._styleKey=null,this.x0=t,this.y0=e,this.x1=s,this.y1=n}addColorStop(t,e){return this.gradientStops.push({offset:t,color:Y.shared.setValue(e).toHexa()}),this._styleKey=null,this}buildLinearGradient(){const t=ws.defaultTextureSize,{gradientStops:e}=this,s=Q.get().createCanvas();s.width=t,s.height=t;const n=s.getContext("2d"),r=n.createLinearGradient(0,0,ws.defaultTextureSize,1);for(let y=0;y`${n.offset}-${n.color}`).join("-"),e=this.texture.uid,s=this.transform.toArray().join("-");return`fill-gradient-${this.uid}-${t}-${e}-${s}-${this.x0}-${this.y0}-${this.x1}-${this.y1}`}};Jr.defaultTextureSize=256;let Xe=Jr;const Cn={repeat:{addressModeU:"repeat",addressModeV:"repeat"},"repeat-x":{addressModeU:"repeat",addressModeV:"clamp-to-edge"},"repeat-y":{addressModeU:"clamp-to-edge",addressModeV:"repeat"},"no-repeat":{addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge"}};class Mi{constructor(t,e){this.uid=nt("fillPattern"),this.transform=new H,this._styleKey=null,this.texture=t,this.transform.scale(1/t.frame.width,1/t.frame.height),e&&(t.source.style.addressModeU=Cn[e].addressModeU,t.source.style.addressModeV=Cn[e].addressModeV)}setTransform(t){const e=this.texture;this.transform.copyFrom(t),this.transform.invert(),this.transform.scale(1/e.frame.width,1/e.frame.height),this._styleKey=null}get styleKey(){return this._styleKey?this._styleKey:(this._styleKey=`fill-pattern-${this.uid}-${this.texture.uid}-${this.transform.toArray().join("-")}`,this._styleKey)}}var kh=Ih,qi={a:7,c:6,h:1,l:2,m:2,q:4,s:4,t:2,v:1,z:0},Bh=/([astvzqmhlc])([^astvzqmhlc]*)/ig;function Ih(i){var t=[];return i.replace(Bh,function(e,s,n){var r=s.toLowerCase();for(n=Rh(n),r=="m"&&n.length>2&&(t.push([s].concat(n.splice(0,2))),r="l",s=s=="m"?"l":"L");;){if(n.length==qi[r])return n.unshift(s),t.push(n);if(n.length0&&(n=s.pop(),n?(r=n.startX,a=n.startY):(r=0,a=0)),n=null;break;default:st(`Unknown SVG path command: ${l}`)}l!=="Z"&&l!=="z"&&n===null&&(n={startX:r,startY:a},s.push(n))}return t}class Rs{constructor(t=0,e=0,s=0){this.type="circle",this.x=t,this.y=e,this.radius=s}clone(){return new Rs(this.x,this.y,this.radius)}contains(t,e){if(this.radius<=0)return!1;const s=this.radius*this.radius;let n=this.x-t,r=this.y-e;return n*=n,r*=r,n+r<=s}strokeContains(t,e,s){if(this.radius===0)return!1;const n=this.x-t,r=this.y-e,a=this.radius,o=s/2,h=Math.sqrt(n*n+r*r);return ha-o}getBounds(t){return t=t||new E,t.x=this.x-this.radius,t.y=this.y-this.radius,t.width=this.radius*2,t.height=this.radius*2,t}copyFrom(t){return this.x=t.x,this.y=t.y,this.radius=t.radius,this}copyTo(t){return t.copyFrom(this),t}toString(){return`[pixi.js/math:Circle x=${this.x} y=${this.y} radius=${this.radius}]`}}class Fs{constructor(t=0,e=0,s=0,n=0){this.type="ellipse",this.x=t,this.y=e,this.halfWidth=s,this.halfHeight=n}clone(){return new Fs(this.x,this.y,this.halfWidth,this.halfHeight)}contains(t,e){if(this.halfWidth<=0||this.halfHeight<=0)return!1;let s=(t-this.x)/this.halfWidth,n=(e-this.y)/this.halfHeight;return s*=s,n*=n,s+n<=1}strokeContains(t,e,s){const{halfWidth:n,halfHeight:r}=this;if(n<=0||r<=0)return!1;const a=s/2,o=n-a,h=r-a,l=n+a,c=r+a,d=t-this.x,f=e-this.y,g=d*d/(o*o)+f*f/(h*h),m=d*d/(l*l)+f*f/(c*c);return g>1&&m<=1}getBounds(t){return t=t||new E,t.x=this.x-this.halfWidth,t.y=this.y-this.halfHeight,t.width=this.halfWidth*2,t.height=this.halfHeight*2,t}copyFrom(t){return this.x=t.x,this.y=t.y,this.halfWidth=t.halfWidth,this.halfHeight=t.halfHeight,this}copyTo(t){return t.copyFrom(this),t}toString(){return`[pixi.js/math:Ellipse x=${this.x} y=${this.y} halfWidth=${this.halfWidth} halfHeight=${this.halfHeight}]`}}function Dh(i,t,e,s,n,r){const a=i-e,o=t-s,h=n-e,l=r-s,c=a*h+o*l,d=h*h+l*l;let f=-1;d!==0&&(f=c/d);let g,m;f<0?(g=e,m=s):f>1?(g=n,m=r):(g=e+f*h,m=s+f*l);const y=i-g,x=t-m;return y*y+x*x}class We{constructor(...t){this.type="polygon";let e=Array.isArray(t[0])?t[0]:t;if(typeof e[0]!="number"){const s=[];for(let n=0,r=e.length;ne!=c>e&&t<(l-o)*((e-h)/(c-h))+o&&(s=!s)}return s}strokeContains(t,e,s){const n=s/2,r=n*n,{points:a}=this,o=a.length-(this.closePath?0:2);for(let h=0;hn?l:n,r=ca?c:a}return t.x=s,t.width=n-s,t.y=r,t.height=a-r,t}copyFrom(t){return this.points=t.points.slice(),this.closePath=t.closePath,this}copyTo(t){return t.copyFrom(this),t}toString(){return`[pixi.js/math:PolygoncloseStroke=${this.closePath}points=${this.points.reduce((t,e)=>`${t}, ${e}`,"")}]`}get lastX(){return this.points[this.points.length-2]}get lastY(){return this.points[this.points.length-1]}get x(){return this.points[this.points.length-2]}get y(){return this.points[this.points.length-1]}}const ci=(i,t,e,s,n,r)=>{const a=i-e,o=t-s,h=Math.sqrt(a*a+o*o);return h>=n-r&&h<=n+r};class Ls{constructor(t=0,e=0,s=0,n=0,r=20){this.type="roundedRectangle",this.x=t,this.y=e,this.width=s,this.height=n,this.radius=r}getBounds(t){return t=t||new E,t.x=this.x,t.y=this.y,t.width=this.width,t.height=this.height,t}clone(){return new Ls(this.x,this.y,this.width,this.height,this.radius)}copyFrom(t){return this.x=t.x,this.y=t.y,this.width=t.width,this.height=t.height,this}copyTo(t){return t.copyFrom(this),t}contains(t,e){if(this.width<=0||this.height<=0)return!1;if(t>=this.x&&t<=this.x+this.width&&e>=this.y&&e<=this.y+this.height){const s=Math.max(0,Math.min(this.radius,Math.min(this.width,this.height)/2));if(e>=this.y+s&&e<=this.y+this.height-s||t>=this.x+s&&t<=this.x+this.width-s)return!0;let n=t-(this.x+s),r=e-(this.y+s);const a=s*s;if(n*n+r*r<=a||(n=t-(this.x+this.width-s),n*n+r*r<=a)||(r=e-(this.y+this.height-s),n*n+r*r<=a)||(n=t-(this.x+s),n*n+r*r<=a))return!0}return!1}strokeContains(t,e,s){const{x:n,y:r,width:a,height:o,radius:h}=this,l=s/2,c=n+h,d=r+h,f=a-h*2,g=o-h*2,m=n+a,y=r+o;return(t>=n-l&&t<=n+l||t>=m-l&&t<=m+l)&&e>=d&&e<=d+g||(e>=r-l&&e<=r+l||e>=y-l&&e<=y+l)&&t>=c&&t<=c+f?!0:tm-h&&em-h&&e>y-h&&ci(t,e,m-h,y-h,h,l)||ty-h&&ci(t,e,c,y-h,h,l)}toString(){return`[pixi.js/math:RoundedRectangle x=${this.x} y=${this.y}width=${this.width} height=${this.height} radius=${this.radius}]`}}const zh=["precision mediump float;","void main(void){","float test = 0.1;","%forloop%","gl_FragColor = vec4(0.0);","}"].join(` +${i}`}function Ko(i,t){return t?i.replace("#version 300 es",""):i}const Yi={stripVersion:Ko,ensurePrecision:Vo,addProgramDefines:$o,setProgramName:qo,insertVersion:Yo},Xi=Object.create(null),Fr=class fs{constructor(t){t={...fs.defaultOptions,...t};const e=t.fragment.indexOf("#version 300 es")!==-1,s={stripVersion:e,ensurePrecision:{requestedFragmentPrecision:t.preferredFragmentPrecision,requestedVertexPrecision:t.preferredVertexPrecision,maxSupportedVertexPrecision:"highp",maxSupportedFragmentPrecision:Ho()},setProgramName:{name:t.name},addProgramDefines:e,insertVersion:e};let n=t.fragment,r=t.vertex;Object.keys(Yi).forEach(a=>{const o=s[a];n=Yi[a](n,o,!0),r=Yi[a](r,o,!1)}),this.fragment=n,this.vertex=r,this._key=Is(`${this.vertex}:${this.fragment}`,"gl-program")}destroy(){this.fragment=null,this.vertex=null,this._attributeData=null,this._uniformData=null,this._uniformBlockData=null,this.transformFeedbackVaryings=null}static from(t){const e=`${t.vertex}:${t.fragment}`;return Xi[e]||(Xi[e]=new fs(t)),Xi[e]}};Fr.defaultOptions={preferredVertexPrecision:"highp",preferredFragmentPrecision:"mediump"};let Lr=Fr;const bn={uint8x2:{size:2,stride:2,normalised:!1},uint8x4:{size:4,stride:4,normalised:!1},sint8x2:{size:2,stride:2,normalised:!1},sint8x4:{size:4,stride:4,normalised:!1},unorm8x2:{size:2,stride:2,normalised:!0},unorm8x4:{size:4,stride:4,normalised:!0},snorm8x2:{size:2,stride:2,normalised:!0},snorm8x4:{size:4,stride:4,normalised:!0},uint16x2:{size:2,stride:4,normalised:!1},uint16x4:{size:4,stride:8,normalised:!1},sint16x2:{size:2,stride:4,normalised:!1},sint16x4:{size:4,stride:8,normalised:!1},unorm16x2:{size:2,stride:4,normalised:!0},unorm16x4:{size:4,stride:8,normalised:!0},snorm16x2:{size:2,stride:4,normalised:!0},snorm16x4:{size:4,stride:8,normalised:!0},float16x2:{size:2,stride:4,normalised:!1},float16x4:{size:4,stride:8,normalised:!1},float32:{size:1,stride:4,normalised:!1},float32x2:{size:2,stride:8,normalised:!1},float32x3:{size:3,stride:12,normalised:!1},float32x4:{size:4,stride:16,normalised:!1},uint32:{size:1,stride:4,normalised:!1},uint32x2:{size:2,stride:8,normalised:!1},uint32x3:{size:3,stride:12,normalised:!1},uint32x4:{size:4,stride:16,normalised:!1},sint32:{size:1,stride:4,normalised:!1},sint32x2:{size:2,stride:8,normalised:!1},sint32x3:{size:3,stride:12,normalised:!1},sint32x4:{size:4,stride:16,normalised:!1}};function Zo(i){return bn[i]??bn.float32}const Qo={f32:"float32","vec2":"float32x2","vec3":"float32x3","vec4":"float32x4",vec2f:"float32x2",vec3f:"float32x3",vec4f:"float32x4",i32:"sint32","vec2":"sint32x2","vec3":"sint32x3","vec4":"sint32x4",u32:"uint32","vec2":"uint32x2","vec3":"uint32x3","vec4":"uint32x4",bool:"uint32","vec2":"uint32x2","vec3":"uint32x3","vec4":"uint32x4"};function Jo({source:i,entryPoint:t}){const e={},s=i.indexOf(`fn ${t}`);if(s!==-1){const n=i.indexOf("->",s);if(n!==-1){const r=i.substring(s,n),a=/@location\((\d+)\)\s+([a-zA-Z0-9_]+)\s*:\s*([a-zA-Z0-9_<>]+)(?:,|\s|$)/g;let o;for(;(o=a.exec(r))!==null;){const h=Qo[o[3]]??"float32";e[o[2]]={location:parseInt(o[1],10),format:h,stride:Zo(h).stride,offset:0,instance:!1,start:0}}}}return e}function ji(i){var d,f;const t=/(^|[^/])@(group|binding)\(\d+\)[^;]+;/g,e=/@group\((\d+)\)/,s=/@binding\((\d+)\)/,n=/var(<[^>]+>)? (\w+)/,r=/:\s*(\w+)/,a=/struct\s+(\w+)\s*{([^}]+)}/g,o=/(\w+)\s*:\s*([\w\<\>]+)/g,h=/struct\s+(\w+)/,l=(d=i.match(t))==null?void 0:d.map(g=>({group:parseInt(g.match(e)[1],10),binding:parseInt(g.match(s)[1],10),name:g.match(n)[2],isUniform:g.match(n)[1]==="",type:g.match(r)[1]}));if(!l)return{groups:[],structs:[]};const c=((f=i.match(a))==null?void 0:f.map(g=>{const m=g.match(h)[1],y=g.match(o).reduce((x,w)=>{const[_,b]=w.split(":");return x[_.trim()]=b.trim(),x},{});return y?{name:m,members:y}:null}).filter(({name:g})=>l.some(m=>m.type===g)))??[];return{groups:l,structs:c}}var Ue=(i=>(i[i.VERTEX=1]="VERTEX",i[i.FRAGMENT=2]="FRAGMENT",i[i.COMPUTE=4]="COMPUTE",i))(Ue||{});function th({groups:i}){const t=[];for(let e=0;ee.has(a.name)?!1:(e.add(a.name),!0)),r=[...i.groups,...t.groups].filter(a=>{const o=`${a.name}-${a.binding}`;return s.has(o)?!1:(s.add(o),!0)});return{structs:n,groups:r}}const qi=Object.create(null);class Ti{constructor(t){var o,h;this._layoutKey=0,this._attributeLocationsKey=0;const{fragment:e,vertex:s,layout:n,gpuLayout:r,name:a}=t;if(this.name=a,this.fragment=e,this.vertex=s,e.source===s.source){const l=ji(e.source);this.structsAndGroups=l}else{const l=ji(s.source),c=ji(e.source);this.structsAndGroups=ih(l,c)}this.layout=n??eh(this.structsAndGroups),this.gpuLayout=r??th(this.structsAndGroups),this.autoAssignGlobalUniforms=((o=this.layout[0])==null?void 0:o.globalUniforms)!==void 0,this.autoAssignLocalUniforms=((h=this.layout[1])==null?void 0:h.localUniforms)!==void 0,this._generateProgramKey()}_generateProgramKey(){const{vertex:t,fragment:e}=this,s=t.source+e.source+t.entryPoint+e.entryPoint;this._layoutKey=Is(s,"program")}get attributeData(){return this._attributeData??(this._attributeData=Jo(this.vertex)),this._attributeData}destroy(){this.gpuLayout=null,this.layout=null,this.structsAndGroups=null,this.fragment=null,this.vertex=null}static from(t){const e=`${t.vertex.source}:${t.fragment.source}:${t.fragment.entryPoint}:${t.vertex.entryPoint}`;return qi[e]||(qi[e]=new Ti(t)),qi[e]}}const Dr=["f32","i32","vec2","vec3","vec4","mat2x2","mat3x3","mat4x4","mat3x2","mat4x2","mat2x3","mat4x3","mat2x4","mat3x4"],sh=Dr.reduce((i,t)=>(i[t]=!0,i),{});function nh(i,t){switch(i){case"f32":return 0;case"vec2":return new Float32Array(2*t);case"vec3":return new Float32Array(3*t);case"vec4":return new Float32Array(4*t);case"mat2x2":return new Float32Array([1,0,0,1]);case"mat3x3":return new Float32Array([1,0,0,0,1,0,0,0,1]);case"mat4x4":return new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])}return null}const zr=class Ur{constructor(t,e){this._touched=0,this.uid=nt("uniform"),this._resourceType="uniformGroup",this._resourceId=nt("resource"),this.isUniformGroup=!0,this._dirtyId=0,this.destroyed=!1,e={...Ur.defaultOptions,...e},this.uniformStructures=t;const s={};for(const n in t){const r=t[n];if(r.name=n,r.size=r.size??1,!sh[r.type])throw new Error(`Uniform type ${r.type} is not supported. Supported uniform types are: ${Dr.join(", ")}`);r.value??(r.value=nh(r.type,r.size)),s[n]=r.value}this.uniforms=s,this._dirtyId=1,this.ubo=e.ubo,this.isStatic=e.isStatic,this._signature=Is(Object.keys(s).map(n=>`${n}-${t[n].type}`).join("-"),"uniform-group")}update(){this._dirtyId++}};zr.defaultOptions={ubo:!1,isStatic:!1};let Nr=zr;class pi{constructor(t){this.resources=Object.create(null),this._dirty=!0;let e=0;for(const s in t){const n=t[s];this.setResource(n,e++)}this._updateKey()}_updateKey(){if(!this._dirty)return;this._dirty=!1;const t=[];let e=0;for(const s in this.resources)t[e++]=this.resources[s]._resourceId;this._key=t.join("|")}setResource(t,e){var n,r;const s=this.resources[e];t!==s&&(s&&((n=t.off)==null||n.call(t,"change",this.onResourceChange,this)),(r=t.on)==null||r.call(t,"change",this.onResourceChange,this),this.resources[e]=t,this._dirty=!0)}getResource(t){return this.resources[t]}_touch(t){const e=this.resources;for(const s in e)e[s]._touched=t}destroy(){var e;const t=this.resources;for(const s in t){const n=t[s];(e=n.off)==null||e.call(n,"change",this.onResourceChange,this)}this.resources=null}onResourceChange(t){if(this._dirty=!0,t.destroyed){const e=this.resources;for(const s in e)e[s]===t&&(e[s]=null)}else this._updateKey()}}var ps=(i=>(i[i.WEBGL=1]="WEBGL",i[i.WEBGPU=2]="WEBGPU",i[i.BOTH=3]="BOTH",i))(ps||{});class Es extends gt{constructor(t){super(),this._uniformBindMap=Object.create(null),this._ownedBindGroups=[];let{gpuProgram:e,glProgram:s,groups:n,resources:r,compatibleRenderers:a,groupMap:o}=t;this.gpuProgram=e,this.glProgram=s,a===void 0&&(a=0,e&&(a|=ps.WEBGPU),s&&(a|=ps.WEBGL)),this.compatibleRenderers=a;const h={};if(!r&&!n&&(r={}),r&&n)throw new Error("[Shader] Cannot have both resources and groups");if(!e&&n&&!o)throw new Error("[Shader] No group map or WebGPU shader provided - consider using resources instead.");if(!e&&n&&o)for(const l in o)for(const c in o[l]){const d=o[l][c];h[d]={group:l,binding:c,name:d}}else if(e&&n&&!o){const l=e.structsAndGroups.groups;o={},l.forEach(c=>{o[c.group]=o[c.group]||{},o[c.group][c.binding]=c.name,h[c.name]=c})}else if(r){n={},o={},e&&e.structsAndGroups.groups.forEach(d=>{o[d.group]=o[d.group]||{},o[d.group][d.binding]=d.name,h[d.name]=d});let l=0;for(const c in r)h[c]||(n[99]||(n[99]=new pi,this._ownedBindGroups.push(n[99])),h[c]={group:99,binding:l,name:c},o[99]=o[99]||{},o[99][l]=c,l++);for(const c in r){const d=c;let f=r[c];!f.source&&!f._resourceType&&(f=new Nr(f));const g=h[d];g&&(n[g.group]||(n[g.group]=new pi,this._ownedBindGroups.push(n[g.group])),n[g.group].setResource(f,g.binding))}}this.groups=n,this._uniformBindMap=o,this.resources=this._buildResourceAccessor(n,h)}addResource(t,e,s){var n,r;(n=this._uniformBindMap)[e]||(n[e]={}),(r=this._uniformBindMap[e])[s]||(r[s]=t),this.groups[e]||(this.groups[e]=new pi,this._ownedBindGroups.push(this.groups[e]))}_buildResourceAccessor(t,e){const s={};for(const n in e){const r=e[n];Object.defineProperty(s,r.name,{get(){return t[r.group].getResource(r.binding)},set(a){t[r.group].setResource(a,r.binding)}})}return s}destroy(t=!1){var e,s;this.emit("destroy",this),t&&((e=this.gpuProgram)==null||e.destroy(),(s=this.glProgram)==null||s.destroy()),this.gpuProgram=null,this.glProgram=null,this.removeAllListeners(),this._uniformBindMap=null,this._ownedBindGroups.forEach(n=>{n.destroy()}),this._ownedBindGroups=null,this.resources=null,this.groups=null}static from(t){const{gpu:e,gl:s,...n}=t;let r,a;return e&&(r=Ti.from(e)),s&&(a=Lr.from(s)),new Es({gpuProgram:r,glProgram:a,...n})}}const gs=[];dt.handleByNamedList(G.Environment,gs);async function rh(i){if(!i)for(let t=0;t80*e){o=l=i[0],h=c=i[1];for(var m=e;ml&&(l=d),f>c&&(c=f);g=Math.max(l-o,c-h),g=g!==0?32767/g:0}return $e(r,a,e,o,h,g,0),a}function Or(i,t,e,s,n){var r,a;if(n===ys(i,t,e,s)>0)for(r=t;r=t;r-=s)a=Sn(r,i[r],i[r+1],a);return a&&Mi(a,a.next)&&(Ye(a),a=a.next),a}function ae(i,t){if(!i)return i;t||(t=i);var e=i,s;do if(s=!1,!e.steiner&&(Mi(e,e.next)||K(e.prev,e,e.next)===0)){if(Ye(e),e=t=e.prev,e===e.next)break;s=!0}else e=e.next;while(s||e!==t);return t}function $e(i,t,e,s,n,r,a){if(i){!a&&r&&mh(i,s,n,r);for(var o=i,h,l;i.prev!==i.next;){if(h=i.prev,l=i.next,r?hh(i,s,n,r):oh(i)){t.push(h.i/e|0),t.push(i.i/e|0),t.push(l.i/e|0),Ye(i),i=l.next,o=l.next;continue}if(i=l,i===o){a?a===1?(i=lh(ae(i),t,e),$e(i,t,e,s,n,r,2)):a===2&&ch(i,t,e,s,n,r):$e(ae(i),t,e,s,n,r,1);break}}}}function oh(i){var t=i.prev,e=i,s=i.next;if(K(t,e,s)>=0)return!1;for(var n=t.x,r=e.x,a=s.x,o=t.y,h=e.y,l=s.y,c=nr?n>a?n:a:r>a?r:a,g=o>h?o>l?o:l:h>l?h:l,m=s.next;m!==t;){if(m.x>=c&&m.x<=f&&m.y>=d&&m.y<=g&&ue(n,o,r,h,a,l,m.x,m.y)&&K(m.prev,m,m.next)>=0)return!1;m=m.next}return!0}function hh(i,t,e,s){var n=i.prev,r=i,a=i.next;if(K(n,r,a)>=0)return!1;for(var o=n.x,h=r.x,l=a.x,c=n.y,d=r.y,f=a.y,g=oh?o>l?o:l:h>l?h:l,x=c>d?c>f?c:f:d>f?d:f,w=ms(g,m,t,e,s),_=ms(y,x,t,e,s),b=i.prevZ,S=i.nextZ;b&&b.z>=w&&S&&S.z<=_;){if(b.x>=g&&b.x<=y&&b.y>=m&&b.y<=x&&b!==n&&b!==a&&ue(o,c,h,d,l,f,b.x,b.y)&&K(b.prev,b,b.next)>=0||(b=b.prevZ,S.x>=g&&S.x<=y&&S.y>=m&&S.y<=x&&S!==n&&S!==a&&ue(o,c,h,d,l,f,S.x,S.y)&&K(S.prev,S,S.next)>=0))return!1;S=S.nextZ}for(;b&&b.z>=w;){if(b.x>=g&&b.x<=y&&b.y>=m&&b.y<=x&&b!==n&&b!==a&&ue(o,c,h,d,l,f,b.x,b.y)&&K(b.prev,b,b.next)>=0)return!1;b=b.prevZ}for(;S&&S.z<=_;){if(S.x>=g&&S.x<=y&&S.y>=m&&S.y<=x&&S!==n&&S!==a&&ue(o,c,h,d,l,f,S.x,S.y)&&K(S.prev,S,S.next)>=0)return!1;S=S.nextZ}return!0}function lh(i,t,e){var s=i;do{var n=s.prev,r=s.next.next;!Mi(n,r)&&Wr(n,s,s.next,r)&&Ve(n,r)&&Ve(r,n)&&(t.push(n.i/e|0),t.push(s.i/e|0),t.push(r.i/e|0),Ye(s),Ye(s.next),s=i=r),s=s.next}while(s!==i);return ae(s)}function ch(i,t,e,s,n,r){var a=i;do{for(var o=a.next.next;o!==a.prev;){if(a.i!==o.i&&wh(a,o)){var h=Hr(a,o);a=ae(a,a.next),h=ae(h,h.next),$e(a,t,e,s,n,r,0),$e(h,t,e,s,n,r,0);return}o=o.next}a=a.next}while(a!==i)}function dh(i,t,e,s){var n=[],r,a,o,h,l;for(r=0,a=t.length;r=e.next.y&&e.next.y!==e.y){var o=e.x+(n-e.y)*(e.next.x-e.x)/(e.next.y-e.y);if(o<=s&&o>r&&(r=o,a=e.x=e.x&&e.x>=l&&s!==e.x&&ue(na.x||e.x===a.x&&gh(a,e)))&&(a=e,d=f)),e=e.next;while(e!==h);return a}function gh(i,t){return K(i.prev,i,t.prev)<0&&K(t.next,i,i.next)<0}function mh(i,t,e,s){var n=i;do n.z===0&&(n.z=ms(n.x,n.y,t,e,s)),n.prevZ=n.prev,n.nextZ=n.next,n=n.next;while(n!==i);n.prevZ.nextZ=null,n.prevZ=null,xh(n)}function xh(i){var t,e,s,n,r,a,o,h,l=1;do{for(e=i,i=null,r=null,a=0;e;){for(a++,s=e,o=0,t=0;t0||h>0&&s;)o!==0&&(h===0||!s||e.z<=s.z)?(n=e,e=e.nextZ,o--):(n=s,s=s.nextZ,h--),r?r.nextZ=n:i=n,n.prevZ=r,r=n;e=s}r.nextZ=null,l*=2}while(a>1);return i}function ms(i,t,e,s,n){return i=(i-e)*n|0,t=(t-s)*n|0,i=(i|i<<8)&16711935,i=(i|i<<4)&252645135,i=(i|i<<2)&858993459,i=(i|i<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,i|t<<1}function yh(i){var t=i,e=i;do(t.x=(i-a)*(r-o)&&(i-a)*(s-o)>=(e-a)*(t-o)&&(e-a)*(r-o)>=(n-a)*(s-o)}function wh(i,t){return i.next.i!==t.i&&i.prev.i!==t.i&&!_h(i,t)&&(Ve(i,t)&&Ve(t,i)&&bh(i,t)&&(K(i.prev,i,t.prev)||K(i,t.prev,t))||Mi(i,t)&&K(i.prev,i,i.next)>0&&K(t.prev,t,t.next)>0)}function K(i,t,e){return(t.y-i.y)*(e.x-t.x)-(t.x-i.x)*(e.y-t.y)}function Mi(i,t){return i.x===t.x&&i.y===t.y}function Wr(i,t,e,s){var n=oi(K(i,t,e)),r=oi(K(i,t,s)),a=oi(K(e,s,i)),o=oi(K(e,s,t));return!!(n!==r&&a!==o||n===0&&ai(i,e,t)||r===0&&ai(i,s,t)||a===0&&ai(e,i,s)||o===0&&ai(e,t,s))}function ai(i,t,e){return t.x<=Math.max(i.x,e.x)&&t.x>=Math.min(i.x,e.x)&&t.y<=Math.max(i.y,e.y)&&t.y>=Math.min(i.y,e.y)}function oi(i){return i>0?1:i<0?-1:0}function _h(i,t){var e=i;do{if(e.i!==i.i&&e.next.i!==i.i&&e.i!==t.i&&e.next.i!==t.i&&Wr(e,e.next,i,t))return!0;e=e.next}while(e!==i);return!1}function Ve(i,t){return K(i.prev,i,i.next)<0?K(i,t,i.next)>=0&&K(i,i.prev,t)>=0:K(i,t,i.prev)<0||K(i,i.next,t)<0}function bh(i,t){var e=i,s=!1,n=(i.x+t.x)/2,r=(i.y+t.y)/2;do e.y>r!=e.next.y>r&&e.next.y!==e.y&&n<(e.next.x-e.x)*(r-e.y)/(e.next.y-e.y)+e.x&&(s=!s),e=e.next;while(e!==i);return s}function Hr(i,t){var e=new xs(i.i,i.x,i.y),s=new xs(t.i,t.x,t.y),n=i.next,r=t.prev;return i.next=t,t.prev=i,e.next=n,n.prev=e,s.next=e,e.prev=s,r.next=s,s.prev=r,s}function Sn(i,t,e,s){var n=new xs(i,t,e);return s?(n.next=s.next,n.prev=s,s.next.prev=n,s.next=n):(n.prev=n,n.next=n),n}function Ye(i){i.next.prev=i.prev,i.prev.next=i.next,i.prevZ&&(i.prevZ.nextZ=i.nextZ),i.nextZ&&(i.nextZ.prevZ=i.prevZ)}function xs(i,t,e){this.i=i,this.x=t,this.y=e,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}Ai.deviation=function(i,t,e,s){var n=t&&t.length,r=n?t[0]*e:i.length,a=Math.abs(ys(i,0,r,e));if(n)for(var o=0,h=t.length;o0&&(s+=i[n-1].length,e.holes.push(s))}return e};var Sh=Rs.exports;const vh=Gs(Sh);var $r=(i=>(i[i.NONE=0]="NONE",i[i.COLOR=16384]="COLOR",i[i.STENCIL=1024]="STENCIL",i[i.DEPTH=256]="DEPTH",i[i.COLOR_DEPTH=16640]="COLOR_DEPTH",i[i.COLOR_STENCIL=17408]="COLOR_STENCIL",i[i.DEPTH_STENCIL=1280]="DEPTH_STENCIL",i[i.ALL=17664]="ALL",i))($r||{});class Ch{constructor(t){this.items=[],this._name=t}emit(t,e,s,n,r,a,o,h){const{name:l,items:c}=this;for(let d=0,f=c.length;d{this.runners[e]=new Ch(e)})}_addSystems(t){let e;for(e in t){const s=t[e];this._addSystem(s.value,s.name)}}_addSystem(t,e){const s=new t(this);if(this[e])throw new Error(`Whoops! The name "${e}" is already in use`);this[e]=s,this._systemsHash[e]=s;for(const n in this.runners)this.runners[n].add(s);return this}_addPipes(t,e){const s=e.reduce((n,r)=>(n[r.name]=r.value,n),{});t.forEach(n=>{const r=n.value,a=n.name,o=s[a];this.renderPipes[a]=new r(this,o?new o:null)})}destroy(t=!1){this.runners.destroy.items.reverse(),this.runners.destroy.emit(t),Object.values(this.runners).forEach(e=>{e.destroy()}),this._systemsHash=null,this.renderPipes=null}generateTexture(t){return this.textureGenerator.generateTexture(t)}get roundPixels(){return!!this._roundPixels}_unsafeEvalCheck(){if(!ah())throw new Error("Current environment does not allow unsafe-eval, please use pixi.js/unsafe-eval module to enable support.")}};Vr.defaultOptions={resolution:1,failIfMajorPerformanceCaveat:!1,roundPixels:!1};let Xr=Vr,hi;function Ah(i){return hi!==void 0||(hi=(()=>{var e;const t={stencil:!0,failIfMajorPerformanceCaveat:i??Xr.defaultOptions.failIfMajorPerformanceCaveat};try{if(!Q.get().getWebGLRenderingContext())return!1;let n=Q.get().createCanvas().getContext("webgl",t);const r=!!((e=n==null?void 0:n.getContextAttributes())!=null&&e.stencil);if(n){const a=n.getExtension("WEBGL_lose_context");a&&a.loseContext()}return n=null,r}catch{return!1}})()),hi}let li;async function Mh(i={}){return li!==void 0||(li=await(async()=>{const t=Q.get().getNavigator().gpu;if(!t)return!1;try{return await(await t.requestAdapter(i)).requestDevice(),!0}catch{return!1}})()),li}const vn=["webgl","webgpu","canvas"];async function Ph(i){let t=[];i.preference?(t.push(i.preference),vn.forEach(r=>{r!==i.preference&&t.push(r)})):t=vn.slice();let e,s={};for(let r=0;r{const{WebGPURenderer:h}=await import("./WebGPURenderer-CNuCBG1t.js");return{WebGPURenderer:h}},__vite__mapDeps([3,2,4]));e=o,s={...i,...i.webgpu};break}else if(a==="webgl"&&Ah(i.failIfMajorPerformanceCaveat??Xr.defaultOptions.failIfMajorPerformanceCaveat)){const{WebGLRenderer:o}=await mi(async()=>{const{WebGLRenderer:h}=await import("./WebGLRenderer-O3oCvy8A.js");return{WebGLRenderer:h}},__vite__mapDeps([5,2,4]));e=o,s={...i,...i.webgl};break}else if(a==="canvas")throw s={...i},new Error("CanvasRenderer is not yet implemented")}if(delete s.webgpu,delete s.webgl,!e)throw new Error("No available renderer for the current environment");const n=new e;return await n.init(s),n}const jr="8.4.0";class qr{static init(){var t;(t=globalThis.__PIXI_APP_INIT__)==null||t.call(globalThis,this,jr)}static destroy(){}}qr.extension=G.Application;class Gh{constructor(t){this._renderer=t}init(){var t;(t=globalThis.__PIXI_RENDERER_INIT__)==null||t.call(globalThis,this._renderer,jr)}destroy(){this._renderer=null}}Gh.extension={type:[G.WebGLSystem,G.WebGPUSystem],name:"initHook",priority:-10};const Kr=class ws{constructor(...t){this.stage=new tt,t[0]!==void 0&&U(O,"Application constructor options are deprecated, please use Application.init() instead.")}async init(t){t={...t},this.renderer=await Ph(t),ws._plugins.forEach(e=>{e.init.call(this,t)})}render(){this.renderer.render({container:this.stage})}get canvas(){return this.renderer.canvas}get view(){return U(O,"Application.view is deprecated, please use Application.canvas instead."),this.renderer.canvas}get screen(){return this.renderer.screen}destroy(t=!1,e=!1){const s=ws._plugins.slice(0);s.reverse(),s.forEach(n=>{n.destroy.call(this)}),this.stage.destroy(e),this.stage=null,this.renderer.destroy(t),this.renderer=null}};Kr._plugins=[];let Zr=Kr;dt.handleByList(G.Application,Zr._plugins);dt.add(qr);class Qr extends gt{constructor(){super(...arguments),this.chars=Object.create(null),this.lineHeight=0,this.fontFamily="",this.fontMetrics={fontSize:0,ascent:0,descent:0},this.baseLineOffset=0,this.distanceField={type:"none",range:0},this.pages=[],this.applyFillAsTint=!0,this.baseMeasurementFontSize=100,this.baseRenderedFontSize=100}get font(){return U(O,"BitmapFont.font is deprecated, please use BitmapFont.fontFamily instead."),this.fontFamily}get pageTextures(){return U(O,"BitmapFont.pageTextures is deprecated, please use BitmapFont.pages instead."),this.pages}get size(){return U(O,"BitmapFont.size is deprecated, please use BitmapFont.fontMetrics.fontSize instead."),this.fontMetrics.fontSize}get distanceFieldRange(){return U(O,"BitmapFont.distanceFieldRange is deprecated, please use BitmapFont.distanceField.range instead."),this.distanceField.range}get distanceFieldType(){return U(O,"BitmapFont.distanceFieldType is deprecated, please use BitmapFont.distanceField.type instead."),this.distanceField.type}destroy(t=!1){var e;this.emit("destroy",this),this.removeAllListeners();for(const s in this.chars)(e=this.chars[s].texture)==null||e.destroy();this.chars=null,t&&(this.pages.forEach(s=>s.texture.destroy(!0)),this.pages=null)}}const Jr=class _s{constructor(t,e,s,n){this.uid=nt("fillGradient"),this.type="linear",this.gradientStops=[],this._styleKey=null,this.x0=t,this.y0=e,this.x1=s,this.y1=n}addColorStop(t,e){return this.gradientStops.push({offset:t,color:Y.shared.setValue(e).toHexa()}),this._styleKey=null,this}buildLinearGradient(){const t=_s.defaultTextureSize,{gradientStops:e}=this,s=Q.get().createCanvas();s.width=t,s.height=t;const n=s.getContext("2d"),r=n.createLinearGradient(0,0,_s.defaultTextureSize,1);for(let y=0;y`${n.offset}-${n.color}`).join("-"),e=this.texture.uid,s=this.transform.toArray().join("-");return`fill-gradient-${this.uid}-${t}-${e}-${s}-${this.x0}-${this.y0}-${this.x1}-${this.y1}`}};Jr.defaultTextureSize=256;let Xe=Jr;const Cn={repeat:{addressModeU:"repeat",addressModeV:"repeat"},"repeat-x":{addressModeU:"repeat",addressModeV:"clamp-to-edge"},"repeat-y":{addressModeU:"clamp-to-edge",addressModeV:"repeat"},"no-repeat":{addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge"}};class Pi{constructor(t,e){this.uid=nt("fillPattern"),this.transform=new H,this._styleKey=null,this.texture=t,this.transform.scale(1/t.frame.width,1/t.frame.height),e&&(t.source.style.addressModeU=Cn[e].addressModeU,t.source.style.addressModeV=Cn[e].addressModeV)}setTransform(t){const e=this.texture;this.transform.copyFrom(t),this.transform.invert(),this.transform.scale(1/e.frame.width,1/e.frame.height),this._styleKey=null}get styleKey(){return this._styleKey?this._styleKey:(this._styleKey=`fill-pattern-${this.uid}-${this.texture.uid}-${this.transform.toArray().join("-")}`,this._styleKey)}}var kh=Ih,Ki={a:7,c:6,h:1,l:2,m:2,q:4,s:4,t:2,v:1,z:0},Bh=/([astvzqmhlc])([^astvzqmhlc]*)/ig;function Ih(i){var t=[];return i.replace(Bh,function(e,s,n){var r=s.toLowerCase();for(n=Rh(n),r=="m"&&n.length>2&&(t.push([s].concat(n.splice(0,2))),r="l",s=s=="m"?"l":"L");;){if(n.length==Ki[r])return n.unshift(s),t.push(n);if(n.length0&&(n=s.pop(),n?(r=n.startX,a=n.startY):(r=0,a=0)),n=null;break;default:st(`Unknown SVG path command: ${l}`)}l!=="Z"&&l!=="z"&&n===null&&(n={startX:r,startY:a},s.push(n))}return t}class Fs{constructor(t=0,e=0,s=0){this.type="circle",this.x=t,this.y=e,this.radius=s}clone(){return new Fs(this.x,this.y,this.radius)}contains(t,e){if(this.radius<=0)return!1;const s=this.radius*this.radius;let n=this.x-t,r=this.y-e;return n*=n,r*=r,n+r<=s}strokeContains(t,e,s){if(this.radius===0)return!1;const n=this.x-t,r=this.y-e,a=this.radius,o=s/2,h=Math.sqrt(n*n+r*r);return ha-o}getBounds(t){return t=t||new I,t.x=this.x-this.radius,t.y=this.y-this.radius,t.width=this.radius*2,t.height=this.radius*2,t}copyFrom(t){return this.x=t.x,this.y=t.y,this.radius=t.radius,this}copyTo(t){return t.copyFrom(this),t}toString(){return`[pixi.js/math:Circle x=${this.x} y=${this.y} radius=${this.radius}]`}}class Ls{constructor(t=0,e=0,s=0,n=0){this.type="ellipse",this.x=t,this.y=e,this.halfWidth=s,this.halfHeight=n}clone(){return new Ls(this.x,this.y,this.halfWidth,this.halfHeight)}contains(t,e){if(this.halfWidth<=0||this.halfHeight<=0)return!1;let s=(t-this.x)/this.halfWidth,n=(e-this.y)/this.halfHeight;return s*=s,n*=n,s+n<=1}strokeContains(t,e,s){const{halfWidth:n,halfHeight:r}=this;if(n<=0||r<=0)return!1;const a=s/2,o=n-a,h=r-a,l=n+a,c=r+a,d=t-this.x,f=e-this.y,g=d*d/(o*o)+f*f/(h*h),m=d*d/(l*l)+f*f/(c*c);return g>1&&m<=1}getBounds(t){return t=t||new I,t.x=this.x-this.halfWidth,t.y=this.y-this.halfHeight,t.width=this.halfWidth*2,t.height=this.halfHeight*2,t}copyFrom(t){return this.x=t.x,this.y=t.y,this.halfWidth=t.halfWidth,this.halfHeight=t.halfHeight,this}copyTo(t){return t.copyFrom(this),t}toString(){return`[pixi.js/math:Ellipse x=${this.x} y=${this.y} halfWidth=${this.halfWidth} halfHeight=${this.halfHeight}]`}}function Dh(i,t,e,s,n,r){const a=i-e,o=t-s,h=n-e,l=r-s,c=a*h+o*l,d=h*h+l*l;let f=-1;d!==0&&(f=c/d);let g,m;f<0?(g=e,m=s):f>1?(g=n,m=r):(g=e+f*h,m=s+f*l);const y=i-g,x=t-m;return y*y+x*x}class We{constructor(...t){this.type="polygon";let e=Array.isArray(t[0])?t[0]:t;if(typeof e[0]!="number"){const s=[];for(let n=0,r=e.length;ne!=c>e&&t<(l-o)*((e-h)/(c-h))+o&&(s=!s)}return s}strokeContains(t,e,s){const n=s/2,r=n*n,{points:a}=this,o=a.length-(this.closePath?0:2);for(let h=0;hn?l:n,r=ca?c:a}return t.x=s,t.width=n-s,t.y=r,t.height=a-r,t}copyFrom(t){return this.points=t.points.slice(),this.closePath=t.closePath,this}copyTo(t){return t.copyFrom(this),t}toString(){return`[pixi.js/math:PolygoncloseStroke=${this.closePath}points=${this.points.reduce((t,e)=>`${t}, ${e}`,"")}]`}get lastX(){return this.points[this.points.length-2]}get lastY(){return this.points[this.points.length-1]}get x(){return this.points[this.points.length-2]}get y(){return this.points[this.points.length-1]}}const ci=(i,t,e,s,n,r)=>{const a=i-e,o=t-s,h=Math.sqrt(a*a+o*o);return h>=n-r&&h<=n+r};class Ds{constructor(t=0,e=0,s=0,n=0,r=20){this.type="roundedRectangle",this.x=t,this.y=e,this.width=s,this.height=n,this.radius=r}getBounds(t){return t=t||new I,t.x=this.x,t.y=this.y,t.width=this.width,t.height=this.height,t}clone(){return new Ds(this.x,this.y,this.width,this.height,this.radius)}copyFrom(t){return this.x=t.x,this.y=t.y,this.width=t.width,this.height=t.height,this}copyTo(t){return t.copyFrom(this),t}contains(t,e){if(this.width<=0||this.height<=0)return!1;if(t>=this.x&&t<=this.x+this.width&&e>=this.y&&e<=this.y+this.height){const s=Math.max(0,Math.min(this.radius,Math.min(this.width,this.height)/2));if(e>=this.y+s&&e<=this.y+this.height-s||t>=this.x+s&&t<=this.x+this.width-s)return!0;let n=t-(this.x+s),r=e-(this.y+s);const a=s*s;if(n*n+r*r<=a||(n=t-(this.x+this.width-s),n*n+r*r<=a)||(r=e-(this.y+this.height-s),n*n+r*r<=a)||(n=t-(this.x+s),n*n+r*r<=a))return!0}return!1}strokeContains(t,e,s){const{x:n,y:r,width:a,height:o,radius:h}=this,l=s/2,c=n+h,d=r+h,f=a-h*2,g=o-h*2,m=n+a,y=r+o;return(t>=n-l&&t<=n+l||t>=m-l&&t<=m+l)&&e>=d&&e<=d+g||(e>=r-l&&e<=r+l||e>=y-l&&e<=y+l)&&t>=c&&t<=c+f?!0:tm-h&&em-h&&e>y-h&&ci(t,e,m-h,y-h,h,l)||ty-h&&ci(t,e,c,y-h,h,l)}toString(){return`[pixi.js/math:RoundedRectangle x=${this.x} y=${this.y}width=${this.width} height=${this.height} radius=${this.radius}]`}}const zh=["precision mediump float;","void main(void){","float test = 0.1;","%forloop%","gl_FragColor = vec4(0.0);","}"].join(` `);function Uh(i){let t="";for(let e=0;e0&&(t+=` -else `),e>>=0;return ea[e]||Wh(i,t,e)}let Ki=0;function Wh(i,t,e){const s={};let n=0;Ki||(Ki=ta());for(let a=0;a0){const a=new Uint8Array(i,e*8,r);new Uint8Array(t,e*8,r).set(a)}}const Hh={normal:"normal-npm",add:"add-npm",screen:"screen-npm"};var $h=(i=>(i[i.DISABLED=0]="DISABLED",i[i.RENDERING_MASK_ADD=1]="RENDERING_MASK_ADD",i[i.MASK_ACTIVE=2]="MASK_ACTIVE",i[i.RENDERING_MASK_REMOVE=3]="RENDERING_MASK_REMOVE",i[i.NONE=4]="NONE",i))($h||{});function Mn(i,t){return t.alphaMode==="no-premultiply-alpha"&&Hh[i]||i}class Vh{constructor(){this.ids=Object.create(null),this.textures=[],this.count=0}clear(){for(let t=0;t0?ia[--_s]:new Yh}function Gn(i){ia[_s++]=i}let Re=0;const sa=class gi{constructor(t={}){this.uid=nt("batcher"),this.dirty=!0,this.batchIndex=0,this.batches=[],this._elements=[],gi.defaultOptions.maxTextures=gi.defaultOptions.maxTextures??ta(),t={...gi.defaultOptions,...t};const{maxTextures:e,attributesInitialSize:s,indicesInitialSize:n}=t;this.attributeBuffer=new Tn(s*4),this.indexBuffer=new Uint16Array(n),this.maxTextures=e}begin(){this.elementSize=0,this.elementStart=0,this.indexSize=0,this.attributeSize=0;for(let t=0;tthis.attributeBuffer.size&&this._resizeAttributeBuffer(this.attributeSize*4),this.indexSize>this.indexBuffer.length&&this._resizeIndexBuffer(this.indexSize);const o=this.attributeBuffer.float32View,h=this.attributeBuffer.uint32View,l=this.indexBuffer;let c=this._batchIndexSize,d=this._batchIndexStart,f="startBatch";const g=this.maxTextures;for(let m=this.elementStart;m=g||b)&&(this._finishBatch(s,d,c-d,n,a,t,f),f="renderBatch",d=c,a=_,s=Pn(),n=s.textures,n.clear(),++Re),y._textureId=w._textureBindLocation=n.count,n.ids[w.uid]=n.count,n.textures[n.count++]=w,y._batch=s,c+=y.indexSize,y.packAsQuad?(this.packQuadAttributes(y,o,h,y._attributeStart,y._textureId),this.packQuadIndex(l,y._indexStart,y._attributeStart/this.vertexSize)):(this.packAttributes(y,o,h,y._attributeStart,y._textureId),this.packIndex(y,l,y._indexStart,y._attributeStart/this.vertexSize))}n.count>0&&(this._finishBatch(s,d,c-d,n,a,t,f),d=c,++Re),this.elementStart=this.elementSize,this._batchIndexStart=d,this._batchIndexSize=c}_finishBatch(t,e,s,n,r,a,o){t.gpuBindGroup=null,t.bindGroup=null,t.action=o,t.batcher=this,t.textures=n,t.blendMode=r,t.start=e,t.size=s,++Re,this.batches[this.batchIndex++]=t,a.add(t)}finish(t){this.break(t)}ensureAttributeBuffer(t){t*4<=this.attributeBuffer.size||this._resizeAttributeBuffer(t*4)}ensureIndexBuffer(t){t<=this.indexBuffer.length||this._resizeIndexBuffer(t)}_resizeAttributeBuffer(t){const e=Math.max(t,this.attributeBuffer.size*2),s=new Tn(e);An(this.attributeBuffer.rawBinaryData,s.rawBinaryData),this.attributeBuffer=s}_resizeIndexBuffer(t){const e=this.indexBuffer;let s=Math.max(t,e.length*1.5);s+=s%2;const n=s>65535?new Uint32Array(s):new Uint16Array(s);if(n.BYTES_PER_ELEMENT!==e.BYTES_PER_ELEMENT)for(let r=0;r(i[i.MAP_READ=1]="MAP_READ",i[i.MAP_WRITE=2]="MAP_WRITE",i[i.COPY_SRC=4]="COPY_SRC",i[i.COPY_DST=8]="COPY_DST",i[i.INDEX=16]="INDEX",i[i.VERTEX=32]="VERTEX",i[i.UNIFORM=64]="UNIFORM",i[i.STORAGE=128]="STORAGE",i[i.INDIRECT=256]="INDIRECT",i[i.QUERY_RESOLVE=512]="QUERY_RESOLVE",i[i.STATIC=1024]="STATIC",i))(it||{});class Vt extends gt{constructor(t){let{data:e,size:s}=t;const{usage:n,label:r,shrinkToFit:a}=t;super(),this.uid=nt("buffer"),this._resourceType="buffer",this._resourceId=nt("resource"),this._touched=0,this._updateID=1,this.shrinkToFit=!0,this.destroyed=!1,e instanceof Array&&(e=new Float32Array(e)),this._data=e,s=s??(e==null?void 0:e.byteLength);const o=!!e;this.descriptor={size:s,usage:n,mappedAtCreation:o,label:r},this.shrinkToFit=a??!0}get data(){return this._data}set data(t){this.setDataWithSize(t,t.length,!0)}get static(){return!!(this.descriptor.usage&it.STATIC)}set static(t){t?this.descriptor.usage|=it.STATIC:this.descriptor.usage&=~it.STATIC}setDataWithSize(t,e,s){if(this._updateID++,this._updateSize=e*t.BYTES_PER_ELEMENT,this._data===t){s&&this.emit("update",this);return}const n=this._data;if(this._data=t,n.length!==t.length){!this.shrinkToFit&&t.byteLengtho&&(o=g),m>h&&(h=m),ge.destroy()),this.attributes=null,this.buffers=null,this.indexBuffer=null,this._bounds=null}}const Kh=new Float32Array(1),Zh=new Uint32Array(1);class Qh extends ra{constructor(){const e=new Vt({data:Kh,label:"attribute-batch-buffer",usage:it.VERTEX|it.COPY_DST,shrinkToFit:!1}),s=new Vt({data:Zh,label:"index-batch-buffer",usage:it.INDEX|it.COPY_DST,shrinkToFit:!1}),n=6*4;super({attributes:{aPosition:{buffer:e,format:"float32x2",stride:n,offset:0},aUV:{buffer:e,format:"float32x2",stride:n,offset:2*4},aColor:{buffer:e,format:"unorm8x4",stride:n,offset:4*4},aTextureIdAndRound:{buffer:e,format:"uint16x2",stride:n,offset:5*4}},indexBuffer:s})}}function kn(i,t,e){if(i)for(const s in i){const n=s.toLocaleLowerCase(),r=t[n];if(r){let a=i[s];s==="header"&&(a=a.replace(/@in\s+[^;]+;\s*/g,"").replace(/@out\s+[^;]+;\s*/g,"")),e&&r.push(`//----${e}----//`),r.push(a)}else st(`${s} placement hook does not exist in shader`)}}const Jh=/\{\{(.*?)\}\}/g;function Bn(i){var s;const t={};return(((s=i.match(Jh))==null?void 0:s.map(n=>n.replace(/[{()}]/g,"")))??[]).forEach(n=>{t[n]=[]}),t}function In(i,t){let e;const s=/@in\s+([^;]+);/g;for(;(e=s.exec(i))!==null;)t.push(e[1])}function En(i,t,e=!1){const s=[];In(t,s),i.forEach(o=>{o.header&&In(o.header,s)});const n=s;e&&n.sort();const r=n.map((o,h)=>` @location(${h}) ${o},`).join(` +else `),e>>=0;return ea[e]||Wh(i,t,e)}let Zi=0;function Wh(i,t,e){const s={};let n=0;Zi||(Zi=ta());for(let a=0;a0){const a=new Uint8Array(i,e*8,r);new Uint8Array(t,e*8,r).set(a)}}const Hh={normal:"normal-npm",add:"add-npm",screen:"screen-npm"};var $h=(i=>(i[i.DISABLED=0]="DISABLED",i[i.RENDERING_MASK_ADD=1]="RENDERING_MASK_ADD",i[i.MASK_ACTIVE=2]="MASK_ACTIVE",i[i.RENDERING_MASK_REMOVE=3]="RENDERING_MASK_REMOVE",i[i.NONE=4]="NONE",i))($h||{});function Mn(i,t){return t.alphaMode==="no-premultiply-alpha"&&Hh[i]||i}class Vh{constructor(){this.ids=Object.create(null),this.textures=[],this.count=0}clear(){for(let t=0;t0?ia[--bs]:new Yh}function Gn(i){ia[bs++]=i}let Re=0;const sa=class gi{constructor(t={}){this.uid=nt("batcher"),this.dirty=!0,this.batchIndex=0,this.batches=[],this._elements=[],gi.defaultOptions.maxTextures=gi.defaultOptions.maxTextures??ta(),t={...gi.defaultOptions,...t};const{maxTextures:e,attributesInitialSize:s,indicesInitialSize:n}=t;this.attributeBuffer=new Tn(s*4),this.indexBuffer=new Uint16Array(n),this.maxTextures=e}begin(){this.elementSize=0,this.elementStart=0,this.indexSize=0,this.attributeSize=0;for(let t=0;tthis.attributeBuffer.size&&this._resizeAttributeBuffer(this.attributeSize*4),this.indexSize>this.indexBuffer.length&&this._resizeIndexBuffer(this.indexSize);const o=this.attributeBuffer.float32View,h=this.attributeBuffer.uint32View,l=this.indexBuffer;let c=this._batchIndexSize,d=this._batchIndexStart,f="startBatch";const g=this.maxTextures;for(let m=this.elementStart;m=g||b)&&(this._finishBatch(s,d,c-d,n,a,t,f),f="renderBatch",d=c,a=_,s=Pn(),n=s.textures,n.clear(),++Re),y._textureId=w._textureBindLocation=n.count,n.ids[w.uid]=n.count,n.textures[n.count++]=w,y._batch=s,c+=y.indexSize,y.packAsQuad?(this.packQuadAttributes(y,o,h,y._attributeStart,y._textureId),this.packQuadIndex(l,y._indexStart,y._attributeStart/this.vertexSize)):(this.packAttributes(y,o,h,y._attributeStart,y._textureId),this.packIndex(y,l,y._indexStart,y._attributeStart/this.vertexSize))}n.count>0&&(this._finishBatch(s,d,c-d,n,a,t,f),d=c,++Re),this.elementStart=this.elementSize,this._batchIndexStart=d,this._batchIndexSize=c}_finishBatch(t,e,s,n,r,a,o){t.gpuBindGroup=null,t.bindGroup=null,t.action=o,t.batcher=this,t.textures=n,t.blendMode=r,t.start=e,t.size=s,++Re,this.batches[this.batchIndex++]=t,a.add(t)}finish(t){this.break(t)}ensureAttributeBuffer(t){t*4<=this.attributeBuffer.size||this._resizeAttributeBuffer(t*4)}ensureIndexBuffer(t){t<=this.indexBuffer.length||this._resizeIndexBuffer(t)}_resizeAttributeBuffer(t){const e=Math.max(t,this.attributeBuffer.size*2),s=new Tn(e);An(this.attributeBuffer.rawBinaryData,s.rawBinaryData),this.attributeBuffer=s}_resizeIndexBuffer(t){const e=this.indexBuffer;let s=Math.max(t,e.length*1.5);s+=s%2;const n=s>65535?new Uint32Array(s):new Uint16Array(s);if(n.BYTES_PER_ELEMENT!==e.BYTES_PER_ELEMENT)for(let r=0;r(i[i.MAP_READ=1]="MAP_READ",i[i.MAP_WRITE=2]="MAP_WRITE",i[i.COPY_SRC=4]="COPY_SRC",i[i.COPY_DST=8]="COPY_DST",i[i.INDEX=16]="INDEX",i[i.VERTEX=32]="VERTEX",i[i.UNIFORM=64]="UNIFORM",i[i.STORAGE=128]="STORAGE",i[i.INDIRECT=256]="INDIRECT",i[i.QUERY_RESOLVE=512]="QUERY_RESOLVE",i[i.STATIC=1024]="STATIC",i))(it||{});class Vt extends gt{constructor(t){let{data:e,size:s}=t;const{usage:n,label:r,shrinkToFit:a}=t;super(),this.uid=nt("buffer"),this._resourceType="buffer",this._resourceId=nt("resource"),this._touched=0,this._updateID=1,this.shrinkToFit=!0,this.destroyed=!1,e instanceof Array&&(e=new Float32Array(e)),this._data=e,s=s??(e==null?void 0:e.byteLength);const o=!!e;this.descriptor={size:s,usage:n,mappedAtCreation:o,label:r},this.shrinkToFit=a??!0}get data(){return this._data}set data(t){this.setDataWithSize(t,t.length,!0)}get static(){return!!(this.descriptor.usage&it.STATIC)}set static(t){t?this.descriptor.usage|=it.STATIC:this.descriptor.usage&=~it.STATIC}setDataWithSize(t,e,s){if(this._updateID++,this._updateSize=e*t.BYTES_PER_ELEMENT,this._data===t){s&&this.emit("update",this);return}const n=this._data;if(this._data=t,n.length!==t.length){!this.shrinkToFit&&t.byteLengtho&&(o=g),m>h&&(h=m),ge.destroy()),this.attributes=null,this.buffers=null,this.indexBuffer=null,this._bounds=null}}const Kh=new Float32Array(1),Zh=new Uint32Array(1);class Qh extends ra{constructor(){const e=new Vt({data:Kh,label:"attribute-batch-buffer",usage:it.VERTEX|it.COPY_DST,shrinkToFit:!1}),s=new Vt({data:Zh,label:"index-batch-buffer",usage:it.INDEX|it.COPY_DST,shrinkToFit:!1}),n=6*4;super({attributes:{aPosition:{buffer:e,format:"float32x2",stride:n,offset:0},aUV:{buffer:e,format:"float32x2",stride:n,offset:2*4},aColor:{buffer:e,format:"unorm8x4",stride:n,offset:4*4},aTextureIdAndRound:{buffer:e,format:"uint16x2",stride:n,offset:5*4}},indexBuffer:s})}}function kn(i,t,e){if(i)for(const s in i){const n=s.toLocaleLowerCase(),r=t[n];if(r){let a=i[s];s==="header"&&(a=a.replace(/@in\s+[^;]+;\s*/g,"").replace(/@out\s+[^;]+;\s*/g,"")),e&&r.push(`//----${e}----//`),r.push(a)}else st(`${s} placement hook does not exist in shader`)}}const Jh=/\{\{(.*?)\}\}/g;function Bn(i){var s;const t={};return(((s=i.match(Jh))==null?void 0:s.map(n=>n.replace(/[{()}]/g,"")))??[]).forEach(n=>{t[n]=[]}),t}function In(i,t){let e;const s=/@in\s+([^;]+);/g;for(;(e=s.exec(i))!==null;)t.push(e[1])}function En(i,t,e=!1){const s=[];In(t,s),i.forEach(o=>{o.header&&In(o.header,s)});const n=s;e&&n.sort();const r=n.map((o,h)=>` @location(${h}) ${o},`).join(` `);let a=t.replace(/@in\s+[^;]+;\s*/g,"");return a=a.replace("{{in}}",` ${r} `),a}function Rn(i,t){let e;const s=/@out\s+([^;]+);/g;for(;(e=s.exec(i))!==null;)t.push(e[1])}function tl(i){const e=/\b(\w+)\s*:/g.exec(i);return e?e[1]:""}function el(i){const t=/@.*?\s+/g;return i.replace(t,"")}function il(i,t){const e=[];Rn(t,e),i.forEach(h=>{h.header&&Rn(h.header,e)});let s=0;const n=e.sort().map(h=>h.indexOf("builtin")>-1?h:`@location(${s++}) ${h}`).join(`, @@ -41,7 +41,7 @@ ${a} `).length?e=e.replace(`{{${s}}}`,`//-----${s} START-----// ${n.join(` `)} -//----${s} FINISH----//`):e=e.replace(`{{${s}}}`,"")}return e}const $t=Object.create(null),Zi=new Map;let sl=0;function nl({template:i,bits:t}){const e=aa(i,t);if($t[e])return $t[e];const{vertex:s,fragment:n}=al(i,t);return $t[e]=oa(s,n,t),$t[e]}function rl({template:i,bits:t}){const e=aa(i,t);return $t[e]||($t[e]=oa(i.vertex,i.fragment,t)),$t[e]}function al(i,t){const e=t.map(a=>a.vertex).filter(a=>!!a),s=t.map(a=>a.fragment).filter(a=>!!a);let n=En(e,i.vertex,!0);n=il(e,n);const r=En(s,i.fragment,!0);return{vertex:n,fragment:r}}function aa(i,t){return t.map(e=>(Zi.has(e)||Zi.set(e,sl++),Zi.get(e))).sort((e,s)=>e-s).join("-")+i.vertex+i.fragment}function oa(i,t,e){const s=Bn(i),n=Bn(t);return e.forEach(r=>{kn(r.vertex,s,r.name),kn(r.fragment,n,r.name)}),{vertex:Fn(i,s),fragment:Fn(t,n)}}const ol=` +//----${s} FINISH----//`):e=e.replace(`{{${s}}}`,"")}return e}const $t=Object.create(null),Qi=new Map;let sl=0;function nl({template:i,bits:t}){const e=aa(i,t);if($t[e])return $t[e];const{vertex:s,fragment:n}=al(i,t);return $t[e]=oa(s,n,t),$t[e]}function rl({template:i,bits:t}){const e=aa(i,t);return $t[e]||($t[e]=oa(i.vertex,i.fragment,t)),$t[e]}function al(i,t){const e=t.map(a=>a.vertex).filter(a=>!!a),s=t.map(a=>a.fragment).filter(a=>!!a);let n=En(e,i.vertex,!0);n=il(e,n);const r=En(s,i.fragment,!0);return{vertex:n,fragment:r}}function aa(i,t){return t.map(e=>(Qi.has(e)||Qi.set(e,sl++),Qi.get(e))).sort((e,s)=>e-s).join("-")+i.vertex+i.fragment}function oa(i,t,e){const s=Bn(i),n=Bn(t);return e.forEach(r=>{kn(r.vertex,s,r.name),kn(r.fragment,n,r.name)}),{vertex:Fn(i,s),fragment:Fn(t,n)}}const ol=` @in aPosition: vec2; @in aUV: vec2; @@ -179,7 +179,7 @@ ${n.join(` uniform mat3 uWorldTransformMatrix; uniform vec4 uWorldColorAlpha; uniform vec2 uResolution; - `}};function fl({bits:i,name:t}){const e=nl({template:{fragment:hl,vertex:ol},bits:[dl,...i]});return Ci.from({name:t,vertex:{source:e.vertex,entryPoint:"main"},fragment:{source:e.fragment,entryPoint:"main"}})}function pl({bits:i,name:t}){return new Lr({name:t,...rl({template:{vertex:ll,fragment:cl},bits:[ul,...i]})})}const gl={name:"color-bit",vertex:{header:` + `}};function fl({bits:i,name:t}){const e=nl({template:{fragment:hl,vertex:ol},bits:[dl,...i]});return Ti.from({name:t,vertex:{source:e.vertex,entryPoint:"main"},fragment:{source:e.fragment,entryPoint:"main"}})}function pl({bits:i,name:t}){return new Lr({name:t,...rl({template:{vertex:ll,fragment:cl},bits:[ul,...i]})})}const gl={name:"color-bit",vertex:{header:` @in aColor: vec4; `,main:` vColor *= vec4(aColor.rgb * aColor.a, aColor.a); @@ -187,9 +187,9 @@ ${n.join(` in vec4 aColor; `,main:` vColor *= vec4(aColor.rgb * aColor.a, aColor.a); - `}},Qi={};function xl(i){const t=[];if(i===1)t.push("@group(1) @binding(0) var textureSource1: texture_2d;"),t.push("@group(1) @binding(1) var textureSampler1: sampler;");else{let e=0;for(let s=0;s;`),t.push(`@group(1) @binding(${e++}) var textureSampler${s+1}: sampler;`)}return t.join(` + `}},Ji={};function xl(i){const t=[];if(i===1)t.push("@group(1) @binding(0) var textureSource1: texture_2d;"),t.push("@group(1) @binding(1) var textureSampler1: sampler;");else{let e=0;for(let s=0;s;`),t.push(`@group(1) @binding(${e++}) var textureSampler${s+1}: sampler;`)}return t.join(` `)}function yl(i){const t=[];if(i===1)t.push("outColor = textureSampleGrad(textureSource1, textureSampler1, vUV, uvDx, uvDy);");else{t.push("switch vTextureId {");for(let e=0;e; @out @interpolate(flat) vTextureId : u32; `,main:` @@ -208,8 +208,8 @@ ${n.join(` var uvDy = dpdy(vUV); ${yl(i)} - `}}),Qi[i]}const Ji={};function _l(i){const t=[];for(let e=0;e0&&t.push("else"),e0&&t.push("else"),e, targetSize: vec2) -> vec2 { return (floor(((position * 0.5 + 0.5) * targetSize) + 0.5) / targetSize) * 2.0 - 1.0; @@ -238,12 +238,12 @@ ${n.join(` { return (floor(((position * 0.5 + 0.5) * targetSize) + 0.5) / targetSize) * 2.0 - 1.0; } - `}},Ln={};function Cl(i){let t=Ln[i];if(t)return t;const e=new Int32Array(i);for(let s=0;s>16&255,s=i>>8&255,n=i&255,r=t>>16&255,a=t>>8&255,o=t&255,h=e*r/255,l=s*a/255,c=n*o/255;return(h<<16)+(l<<8)+c}const kl=new H;class da{constructor(){this.packAsQuad=!1,this.batcherName="default",this.applyTransform=!0,this.roundPixels=0,this._batcher=null,this._batch=null}get uvs(){return this.geometryData.uvs}get positions(){return this.geometryData.vertices}get indices(){return this.geometryData.indices}get blendMode(){return this.applyTransform?this.renderable.groupBlendMode:"normal"}get color(){const t=this.baseColor,e=t>>16|t&65280|(t&255)<<16,s=this.renderable;return s?Gl(e,s.groupColor)+(this.alpha*s.groupAlpha*255<<24):e+(this.alpha*255<<24)}get transform(){var t;return((t=this.renderable)==null?void 0:t.groupTransform)||kl}copyTo(t){t.indexOffset=this.indexOffset,t.indexSize=this.indexSize,t.attributeOffset=this.attributeOffset,t.attributeSize=this.attributeSize,t.baseColor=this.baseColor,t.alpha=this.alpha,t.texture=this.texture,t.geometryData=this.geometryData}reset(){this.applyTransform=!0}}const je={extension:{type:G.ShapeBuilder,name:"circle"},build(i,t){let e,s,n,r,a,o;if(i.type==="circle"){const S=i;e=S.x,s=S.y,a=o=S.radius,n=r=0}else if(i.type==="ellipse"){const S=i;e=S.x,s=S.y,a=S.halfWidth,o=S.halfHeight,n=r=0}else{const S=i,A=S.width/2,F=S.height/2;e=S.x+A,s=S.y+F,a=o=Math.max(0,Math.min(S.radius,Math.min(A,F))),n=A-a,r=F-o}if(!(a>=0&&o>=0&&n>=0&&r>=0))return t;const h=Math.ceil(2.3*Math.sqrt(a+o)),l=h*8+(n?4:0)+(r?4:0);if(l===0)return t;if(h===0)return t[0]=t[6]=e+n,t[1]=t[3]=s+r,t[2]=t[4]=e-n,t[5]=t[7]=s-r,t;let c=0,d=h*4+(n?2:0)+2,f=d,g=l,m=n+a,y=r,x=e+m,w=e-m,_=s+y;if(t[c++]=x,t[c++]=_,t[--d]=_,t[--d]=w,r){const S=s-y;t[f++]=w,t[f++]=S,t[--g]=S,t[--g]=x}for(let S=1;S0&&(n[r++]=h,n[r++]=l,n[r++]=h-1),h++;n[r++]=l+1,n[r++]=l,n[r++]=h-1}},Bl={...je,extension:{...je.extension,name:"ellipse"}},Il={...je,extension:{...je.extension,name:"roundedRectangle"}},El=1e-4,zn=1e-4;function Rl(i){const t=i.length;if(t<6)return 1;let e=0;for(let s=0,n=i[t-2],r=i[t-1];sd&&(d+=Math.PI*2);let f=c;const g=d-c,m=Math.abs(g),y=Math.sqrt(h*h+l*l),x=(15*m*Math.sqrt(y)/Math.PI>>0)+1,w=g/x;if(f+=w,o){a.push(i,t),a.push(e,s);for(let _=1,b=f;_=0&&(c.join==="round"?_+=Qt(v,T,v-L*I,T-R*I,v-X*I,T-et*I,x,!1)+4:_+=2,x.push(v-X*D,T-et*D),x.push(v+X*I,T+et*I));continue}const Zs=(-L+P)*(-R+T)-(-L+v)*(-R+k),Qs=(-X+Z)*(-et+T)-(-X+v)*(-et+Rt),Je=(Wt*Qs-Ge*Zs)/Qe,ti=(ke*Zs-Pe*Qs)/Qe,Bi=(Je-v)*(Je-v)+(ti-T)*(ti-T),jt=v+(Je-v)*I,qt=T+(ti-T)*I,Kt=v-(Je-v)*D,Zt=T-(ti-T)*D,Da=Math.min(Wt*Wt+Pe*Pe,Ge*Ge+ke*ke),Js=Be?I:D,za=Da+Js*Js*A;Bi<=za?c.join==="bevel"||Bi/A>F?(Be?(x.push(jt,qt),x.push(v+L*D,T+R*D),x.push(jt,qt),x.push(v+X*D,T+et*D)):(x.push(v-L*I,T-R*I),x.push(Kt,Zt),x.push(v-X*I,T-et*I),x.push(Kt,Zt)),_+=2):c.join==="round"?Be?(x.push(jt,qt),x.push(v+L*D,T+R*D),_+=Qt(v,T,v+L*D,T+R*D,v+X*D,T+et*D,x,!0)+4,x.push(jt,qt),x.push(v+X*D,T+et*D)):(x.push(v-L*I,T-R*I),x.push(Kt,Zt),_+=Qt(v,T,v-L*I,T-R*I,v-X*I,T-et*I,x,!1)+4,x.push(v-X*I,T-et*I),x.push(Kt,Zt)):(x.push(jt,qt),x.push(Kt,Zt)):(x.push(v-L*I,T-R*I),x.push(v+L*D,T+R*D),c.join==="round"?Be?_+=Qt(v,T,v+L*D,T+R*D,v+X*D,T+et*D,x,!0)+2:_+=Qt(v,T,v-L*I,T-R*I,v-X*I,T-et*I,x,!1)+2:c.join==="miter"&&Bi/A<=F&&(Be?(x.push(Kt,Zt),x.push(Kt,Zt)):(x.push(jt,qt),x.push(jt,qt)),_+=2),x.push(v-X*I,T-et*I),x.push(v+X*D,T+et*D),_+=2)}P=i[(w-2)*2],k=i[(w-2)*2+1],v=i[(w-1)*2],T=i[(w-1)*2+1],L=-(k-T),R=P-v,bt=Math.sqrt(L*L+R*R),L/=bt,R/=bt,L*=S,R*=S,x.push(v-L*I,T-R*I),x.push(v+L*D,T+R*D),m||(c.cap==="round"?_+=Qt(v-L*(I-D)*.5,T-R*(I-D)*.5,v-L*I,T-R*I,v+L*D,T+R*D,x,!1)+2:c.cap==="square"&&(_+=Un(v,T,L,R,I,D,!1,x)));const La=zn*zn;for(let V=b;V<_+b-2;++V)P=x[V*2],k=x[V*2+1],v=x[(V+1)*2],T=x[(V+1)*2+1],Z=x[(V+2)*2],Rt=x[(V+2)*2+1],!(Math.abs(P*(T-Rt)+v*(Rt-k)+Z*(k-T))=0&&a>=0&&(t[0]=s,t[1]=n,t[2]=s+r,t[3]=n,t[4]=s+r,t[5]=n+a,t[6]=s,t[7]=n+a),t},triangulate(i,t,e,s,n,r){let a=0;s*=e,t[s+a]=i[0],t[s+a+1]=i[1],a+=e,t[s+a]=i[2],t[s+a+1]=i[3],a+=e,t[s+a]=i[6],t[s+a+1]=i[7],a+=e,t[s+a]=i[4],t[s+a+1]=i[5],a+=e;const o=s/e;n[r++]=o,n[r++]=o+1,n[r++]=o+2,n[r++]=o+1,n[r++]=o+3,n[r++]=o+2}},Ul={extension:{type:G.ShapeBuilder,name:"triangle"},build(i,t){return t[0]=i.x,t[1]=i.y,t[2]=i.x2,t[3]=i.y2,t[4]=i.x3,t[5]=i.y3,t},triangulate(i,t,e,s,n,r){let a=0;s*=e,t[s+a]=i[0],t[s+a+1]=i[1],a+=e,t[s+a]=i[2],t[s+a+1]=i[3],a+=e,t[s+a]=i[4],t[s+a+1]=i[5];const o=s/e;n[r++]=o,n[r++]=o+1,n[r++]=o+2}},Pi={};dt.handleByMap(G.ShapeBuilder,Pi);dt.add(zl,Dl,Ul,je,Bl,Il);const Ol=new E;function Nl(i,t){const{geometryData:e,batches:s}=t;s.length=0,e.indices.length=0,e.vertices.length=0,e.uvs.length=0;for(let n=0;n{const g=h.length,m=a.length/2,y=[],x=Pi[c.type];if(x.build(c,y),d&&ca(y,d),s){const S=c.closePath??!0;Fl(y,t,!1,S,a,2,m,h)}else if(e&&l===f){l!==0&&console.warn("[Pixi Graphics] only the last shape have be cut out");const S=[],A=y.slice();Hl(e.shapePath).forEach(P=>{S.push(A.length/2),A.push(...P)}),ua(A,S,a,2,m,h,g)}else x.triangulate(y,a,2,m,h,g);const w=o.length/2,_=t.texture;if(_!==z.WHITE){const S=t.matrix;S&&(d&&S.append(d.clone().invert()),Ml(a,2,m,o,w,2,a.length/2-m,S))}else Pl(o,w,2,a.length/2-m);const b=zt.get(da);b.indexOffset=g,b.indexSize=h.length-g,b.attributeOffset=m,b.attributeSize=a.length/2-m,b.baseColor=t.color,b.alpha=t.alpha,b.texture=_,b.geometryData=r,n.push(b)})}function Hl(i){if(!i)return[];const t=i.shapePrimitives,e=[];for(let s=0;s{zt.return(s)})}destroy(){for(const t in this._gpuContextHash)this._gpuContextHash[t]&&this.onGraphicsContextDestroy(this._gpuContextHash[t].context)}};Ds.extension={type:[G.WebGLSystem,G.WebGPUSystem,G.CanvasSystem],name:"graphicsContext"};Ds.defaultOptions={bezierSmoothness:.5};let fa=Ds;const Yl=8,di=11920929e-14,Xl=1;function pa(i,t,e,s,n,r,a,o,h,l){const d=Math.min(.99,Math.max(0,l??fa.defaultOptions.bezierSmoothness));let f=(Xl-d)/1;return f*=f,jl(t,e,s,n,r,a,o,h,i,f),i}function jl(i,t,e,s,n,r,a,o,h,l){Ss(i,t,e,s,n,r,a,o,h,l,0),h.push(a,o)}function Ss(i,t,e,s,n,r,a,o,h,l,c){if(c>Yl)return;const d=(i+e)/2,f=(t+s)/2,g=(e+n)/2,m=(s+r)/2,y=(n+a)/2,x=(r+o)/2,w=(d+g)/2,_=(f+m)/2,b=(g+y)/2,S=(m+x)/2,A=(w+b)/2,F=(_+S)/2;if(c>0){let P=a-i,k=o-t;const v=Math.abs((e-a)*k-(s-o)*P),T=Math.abs((n-a)*k-(r-o)*P);if(v>di&&T>di){if((v+T)*(v+T)<=l*(P*P+k*k)){h.push(A,F);return}}else if(v>di){if(v*v<=l*(P*P+k*k)){h.push(A,F);return}}else if(T>di){if(T*T<=l*(P*P+k*k)){h.push(A,F);return}}else if(P=A-(i+a)/2,k=F-(t+o)/2,P*P+k*k<=l){h.push(A,F);return}}Ss(i,t,d,f,w,_,A,F,h,l,c+1),Ss(A,F,b,S,y,x,a,o,h,l,c+1)}const ql=8,Kl=11920929e-14,Zl=1;function Ql(i,t,e,s,n,r,a,o){const l=Math.min(.99,Math.max(0,o??fa.defaultOptions.bezierSmoothness));let c=(Zl-l)/1;return c*=c,Jl(t,e,s,n,r,a,i,c),i}function Jl(i,t,e,s,n,r,a,o){vs(a,i,t,e,s,n,r,o,0),a.push(n,r)}function vs(i,t,e,s,n,r,a,o,h){if(h>ql)return;const l=(t+s)/2,c=(e+n)/2,d=(s+r)/2,f=(n+a)/2,g=(l+d)/2,m=(c+f)/2;let y=r-t,x=a-e;const w=Math.abs((s-r)*x-(n-a)*y);if(w>Kl){if(w*w<=o*(y*y+x*x)){i.push(g,m);return}}else if(y=g-(t+r)/2,x=m-(e+a)/2,y*y+x*x<=o){i.push(g,m);return}vs(i,t,e,l,c,g,m,o,h+1),vs(i,g,m,d,f,r,a,o,h+1)}function ga(i,t,e,s,n,r,a,o){let h=Math.abs(n-r);(!a&&n>r||a&&r>n)&&(h=2*Math.PI-h),o=o||Math.max(6,Math.floor(6*Math.pow(s,1/3)*(h/Math.PI))),o=Math.max(o,3);let l=h/o,c=n;l*=a?-1:1;for(let d=0;dd*h)}const He=Math.PI*2,ts={centerX:0,centerY:0,ang1:0,ang2:0},es=({x:i,y:t},e,s,n,r,a,o,h)=>{i*=e,t*=s;const l=n*i-r*t,c=r*i+n*t;return h.x=l+a,h.y=c+o,h};function ec(i,t){const e=t===-1.5707963267948966?-.551915024494:1.3333333333333333*Math.tan(t/4),s=t===1.5707963267948966?.551915024494:e,n=Math.cos(i),r=Math.sin(i),a=Math.cos(i+t),o=Math.sin(i+t);return[{x:n-r*s,y:r+n*s},{x:a+o*s,y:o-a*s},{x:a,y:o}]}const Nn=(i,t,e,s)=>{const n=i*s-t*e<0?-1:1;let r=i*e+t*s;return r>1&&(r=1),r<-1&&(r=-1),n*Math.acos(r)},ic=(i,t,e,s,n,r,a,o,h,l,c,d,f)=>{const g=Math.pow(n,2),m=Math.pow(r,2),y=Math.pow(c,2),x=Math.pow(d,2);let w=g*m-g*x-m*y;w<0&&(w=0),w/=g*x+m*y,w=Math.sqrt(w)*(a===o?-1:1);const _=w*n/r*d,b=w*-r/n*c,S=l*_-h*b+(i+e)/2,A=h*_+l*b+(t+s)/2,F=(c-_)/n,P=(d-b)/r,k=(-c-_)/n,v=(-d-b)/r,T=Nn(1,0,F,P);let Z=Nn(F,P,k,v);o===0&&Z>0&&(Z-=He),o===1&&Z<0&&(Z+=He),f.centerX=S,f.centerY=A,f.ang1=T,f.ang2=Z};function sc(i,t,e,s,n,r,a,o=0,h=0,l=0){if(r===0||a===0)return;const c=Math.sin(o*He/360),d=Math.cos(o*He/360),f=d*(t-s)/2+c*(e-n)/2,g=-c*(t-s)/2+d*(e-n)/2;if(f===0&&g===0)return;r=Math.abs(r),a=Math.abs(a);const m=Math.pow(f,2)/Math.pow(r,2)+Math.pow(g,2)/Math.pow(a,2);m>1&&(r*=Math.sqrt(m),a*=Math.sqrt(m)),ic(t,e,s,n,r,a,h,l,c,d,f,g,ts);let{ang1:y,ang2:x}=ts;const{centerX:w,centerY:_}=ts;let b=Math.abs(x)/(He/4);Math.abs(1-b)<1e-7&&(b=1);const S=Math.max(Math.ceil(b),1);x/=S;let A=i[i.length-2],F=i[i.length-1];const P={x:0,y:0};for(let k=0;k{const h=o.x-a.x,l=o.y-a.y,c=Math.sqrt(h*h+l*l),d=h/c,f=l/c;return{len:c,nx:d,ny:f}},n=(a,o)=>{a===0?i.moveTo(o.x,o.y):i.lineTo(o.x,o.y)};let r=t[t.length-1];for(let a=0;a0&&(g=-1,m=!0);const y=f/2;let x,w=Math.abs(Math.cos(y)*h/Math.sin(y));w>Math.min(c.len/2,d.len/2)?(w=Math.min(c.len/2,d.len/2),x=Math.abs(w*Math.sin(y)/Math.cos(y))):x=h;const _=o.x+d.nx*w+-d.ny*x*g,b=o.y+d.ny*w+d.nx*x*g,S=Math.atan2(c.ny,c.nx)+Math.PI/2*g,A=Math.atan2(d.ny,d.nx)-Math.PI/2*g;a===0&&i.moveTo(_+Math.cos(S)*x,b+Math.sin(S)*x),i.arc(_,b,x,S,A,m),r=o}}function rc(i,t,e,s){const n=(o,h)=>Math.sqrt((o.x-h.x)**2+(o.y-h.y)**2),r=(o,h,l)=>({x:o.x+(h.x-o.x)*l,y:o.y+(h.y-o.y)*l}),a=t.length;for(let o=0;o=2;d-=2)c[d]===c[d-2]&&c[d-1]===c[d-3]&&c.splice(d-1,2);return this.poly(c,!0,a)}ellipse(t,e,s,n,r){return this.drawShape(new Fs(t,e,s,n),r),this}roundRect(t,e,s,n,r,a){return this.drawShape(new Ls(t,e,s,n,r),a),this}drawShape(t,e){return this.endPoly(),this.shapePrimitives.push({shape:t,transform:e}),this}startPoly(t,e){let s=this._currentPoly;return s&&this.endPoly(),s=new We,s.points.push(t,e),this._currentPoly=s,this}endPoly(t=!1){const e=this._currentPoly;return e&&e.points.length>2&&(e.closePath=t,this.shapePrimitives.push({shape:e})),this._currentPoly=null,this}_ensurePoly(t=!0){if(!this._currentPoly&&(this._currentPoly=new We,t)){const e=this.shapePrimitives[this.shapePrimitives.length-1];if(e){let s=e.shape.x,n=e.shape.y;if(e.transform&&!e.transform.isIdentity()){const r=e.transform,a=s;s=r.a*s+r.c*n+r.tx,n=r.b*a+r.d*n+r.ty}this._currentPoly.points.push(s,n)}else this._currentPoly.points.push(0,0)}}buildPath(){const t=this._graphicsPath2D;this.shapePrimitives.length=0,this._currentPoly=null;for(let e=0;eparseInt(k,10)),t.context.poly(_,!0),e&&t.context.fill(),s&&t.context.stroke();break;case"polyline":b=i.getAttribute("points"),_=b.match(/\d+/g).map(k=>parseInt(k,10)),t.context.poly(_,!1),s&&t.context.stroke();break;case"g":case"svg":break;default:{console.info(`[SVG parser] <${i.nodeName}> elements unsupported`);break}}for(let k=0;k{this._fill=ne({...this._originalFill},yt.defaultFillStyle)})),this._fill=ne(t===0?"black":t,yt.defaultFillStyle),this.update())}get stroke(){return this._originalStroke}set stroke(t){t!==this._originalStroke&&(this._originalStroke=t,this._isFillStyle(t)&&(this._originalStroke=this._createProxy({...yt.defaultStrokeStyle,...t},()=>{this._stroke=_i({...this._originalStroke},yt.defaultStrokeStyle)})),this._stroke=_i(t,yt.defaultStrokeStyle),this.update())}_generateKey(){return this._styleKey=pc(this),this._styleKey}update(){this._styleKey=null,this.emit("update",this)}reset(){const t=de.defaultTextStyle;for(const e in t)this[e]=t[e]}get styleKey(){return this._styleKey||this._generateKey()}clone(){return new de({align:this.align,breakWords:this.breakWords,dropShadow:this._dropShadow?{...this._dropShadow}:null,fill:this._fill,fontFamily:this.fontFamily,fontSize:this.fontSize,fontStyle:this.fontStyle,fontVariant:this.fontVariant,fontWeight:this.fontWeight,leading:this.leading,letterSpacing:this.letterSpacing,lineHeight:this.lineHeight,padding:this.padding,stroke:this._stroke,textBaseline:this.textBaseline,whiteSpace:this.whiteSpace,wordWrap:this.wordWrap,wordWrapWidth:this.wordWrapWidth})}destroy(t=!1){var s,n,r,a;if(this.removeAllListeners(),typeof t=="boolean"?t:t==null?void 0:t.texture){const o=typeof t=="boolean"?t:t==null?void 0:t.textureSource;(s=this._fill)!=null&&s.texture&&this._fill.texture.destroy(o),(n=this._originalFill)!=null&&n.texture&&this._originalFill.texture.destroy(o),(r=this._stroke)!=null&&r.texture&&this._stroke.texture.destroy(o),(a=this._originalStroke)!=null&&a.texture&&this._originalStroke.texture.destroy(o)}this._fill=null,this._stroke=null,this.dropShadow=null,this._originalStroke=null,this._originalFill=null}_createProxy(t,e){return new Proxy(t,{set:(s,n,r)=>(s[n]=r,e==null||e(n,r),this.update(),!0)})}_isFillStyle(t){return(t??null)!==null&&!(Y.isColorLike(t)||t instanceof Xe||t instanceof Mi)}};Us.defaultDropShadow={alpha:1,angle:Math.PI/6,blur:0,color:"black",distance:5};Us.defaultTextStyle={align:"left",breakWords:!1,dropShadow:null,fill:"black",fontFamily:"Arial",fontSize:26,fontStyle:"normal",fontVariant:"normal",fontWeight:"normal",leading:0,letterSpacing:0,lineHeight:0,padding:0,stroke:null,textBaseline:"alphabetic",trim:!1,whiteSpace:"pre",wordWrap:!1,wordWrapWidth:100};let W=Us;function xc(i){const t=i;if(typeof t.dropShadow=="boolean"&&t.dropShadow){const e=W.defaultDropShadow;i.dropShadow={alpha:t.dropShadowAlpha??e.alpha,angle:t.dropShadowAngle??e.angle,blur:t.dropShadowBlur??e.blur,color:t.dropShadowColor??e.color,distance:t.dropShadowDistance??e.distance}}if(t.strokeThickness!==void 0){U(N,"strokeThickness is now a part of stroke");const e=t.stroke;let s={};if(Y.isColorLike(e))s.color=e;else if(e instanceof Xe||e instanceof Mi)s.fill=e;else if(Object.hasOwnProperty.call(e,"color")||Object.hasOwnProperty.call(e,"fill"))s=e;else throw new Error("Invalid stroke value.");i.stroke={...s,width:t.strokeThickness}}if(Array.isArray(t.fillGradientStops)){U(N,"gradient fill is now a fill pattern: `new FillGradient(...)`");let e;i.fontSize==null?i.fontSize=W.defaultTextStyle.fontSize:typeof i.fontSize=="string"?e=parseInt(i.fontSize,10):e=i.fontSize;const s=new Xe(0,0,0,e*1.7),n=t.fillGradientStops.map(r=>Y.shared.setValue(r).toNumber());n.forEach((r,a)=>{const o=a/(n.length-1);s.addColorStop(o,r)}),i.fill={fill:s}}}class yc{constructor(t){this._canvasPool=Object.create(null),this.canvasOptions=t||{},this.enableFullScreen=!1}_createCanvasAndContext(t,e){const s=Q.get().createCanvas();s.width=t,s.height=e;const n=s.getContext("2d");return{canvas:s,context:n}}getOptimalCanvasAndContext(t,e,s=1){t=Math.ceil(t*s-1e-6),e=Math.ceil(e*s-1e-6),t=sn(t),e=sn(e);const n=(t<<17)+(e<<1);this._canvasPool[n]||(this._canvasPool[n]=[]);let r=this._canvasPool[n].pop();return r||(r=this._createCanvasAndContext(t,e)),r}returnCanvasAndContext(t){const e=t.canvas,{width:s,height:n}=e,r=(s<<17)+(n<<1);this._canvasPool[r].push(t)}clear(){this._canvasPool={}}}const jn=new yc,wc=["serif","sans-serif","monospace","cursive","fantasy","system-ui"];function Cs(i){const t=typeof i.fontSize=="number"?`${i.fontSize}px`:i.fontSize;let e=i.fontFamily;Array.isArray(i.fontFamily)||(e=i.fontFamily.split(","));for(let s=e.length-1;s>=0;s--){let n=e[s].trim();!/([\"\'])[^\'\"]+\1/.test(n)&&!wc.includes(n)&&(n=`"${n}"`),e[s]=n}return`${i.fontStyle} ${i.fontVariant} ${i.fontWeight} ${t} ${e.join(",")}`}const is={willReadFrequently:!0},Tt=class M{static get experimentalLetterSpacingSupported(){let t=M._experimentalLetterSpacingSupported;if(t!==void 0){const e=Q.get().getCanvasRenderingContext2D().prototype;t=M._experimentalLetterSpacingSupported="letterSpacing"in e||"textLetterSpacing"in e}return t}constructor(t,e,s,n,r,a,o,h,l){this.text=t,this.style=e,this.width=s,this.height=n,this.lines=r,this.lineWidths=a,this.lineHeight=o,this.maxLineWidth=h,this.fontProperties=l}static measureText(t=" ",e,s=M._canvas,n=e.wordWrap){var _;const r=`${t}:${e.styleKey}`;if(M._measurementCache[r])return M._measurementCache[r];const a=Cs(e),o=M.measureFont(a);o.fontSize===0&&(o.fontSize=e.fontSize,o.ascent=e.fontSize);const h=M.__context;h.font=a;const c=(n?M._wordWrap(t,e,s):t).split(/(?:\r\n|\r|\n)/),d=new Array(c.length);let f=0;for(let b=0;b0&&(n?r-=e:r+=(M.graphemeSegmenter(t).length-1)*e),r}static _wordWrap(t,e,s=M._canvas){const n=s.getContext("2d",is);let r=0,a="",o="";const h=Object.create(null),{letterSpacing:l,whiteSpace:c}=e,d=M._collapseSpaces(c),f=M._collapseNewlines(c);let g=!d;const m=e.wordWrapWidth+l,y=M._tokenize(t);for(let x=0;xm)if(a!==""&&(o+=M._addLine(a),a="",r=0),M.canBreakWords(w,e.breakWords)){const b=M.wordWrapSplit(w);for(let S=0;Sm&&(o+=M._addLine(a),g=!1,a="",r=0),a+=A,r+=k}}else{a.length>0&&(o+=M._addLine(a),a="",r=0);const b=x===y.length-1;o+=M._addLine(w,!b),g=!1,a="",r=0}else _+r>m&&(g=!1,o+=M._addLine(a),a="",r=0),(a.length>0||!M.isBreakingSpace(w)||g)&&(a+=w,r+=_)}return o+=M._addLine(a,!1),o}static _addLine(t,e=!0){return t=M._trimRight(t),t=e?`${t} -`:t,t}static _getFromCache(t,e,s,n){let r=s[t];return typeof r!="number"&&(r=M._measureText(t,e,n)+e,s[t]=r),r}static _collapseSpaces(t){return t==="normal"||t==="pre-line"}static _collapseNewlines(t){return t==="normal"}static _trimRight(t){if(typeof t!="string")return"";for(let e=t.length-1;e>=0;e--){const s=t[e];if(!M.isBreakingSpace(s))break;t=t.slice(0,-1)}return t}static _isNewline(t){return typeof t!="string"?!1:M._newlines.includes(t.charCodeAt(0))}static isBreakingSpace(t,e){return typeof t!="string"?!1:M._breakingSpaces.includes(t.charCodeAt(0))}static _tokenize(t){const e=[];let s="";if(typeof t!="string")return e;for(let n=0;n{if(typeof(Intl==null?void 0:Intl.Segmenter)=="function"){const i=new Intl.Segmenter;return t=>[...i.segment(t)].map(e=>e.segment)}return i=>[...i]})();Tt.experimentalLetterSpacing=!1;Tt._fonts={};Tt._newlines=[10,13];Tt._breakingSpaces=[9,32,8192,8193,8194,8195,8196,8197,8198,8200,8201,8202,8287,12288];Tt._measurementCache={};let Ts=Tt;function qn(i,t){if(i.texture===z.WHITE&&!i.fill)return Y.shared.setValue(i.color).setAlpha(i.alpha??1).toHexa();if(i.fill){if(i.fill instanceof Mi){const e=i.fill,s=t.createPattern(e.texture.source.resource,"repeat"),n=e.transform.copyTo(H.shared);return n.scale(e.texture.frame.width,e.texture.frame.height),s.setTransform(n),s}else if(i.fill instanceof Xe){const e=i.fill;if(e.type==="linear"){const s=t.createLinearGradient(e.x0,e.y0,e.x1,e.y1);return e.gradientStops.forEach(n=>{s.addColorStop(n.offset,Y.shared.setValue(n.color).toHex())}),s}}}else{const e=t.createPattern(i.texture.source.resource,"repeat"),s=i.matrix.copyTo(H.shared);return s.scale(i.texture.frame.width,i.texture.frame.height),e.setTransform(s),e}return st("FillStyle not recognised",i),"red"}function ya(i){if(i==="")return[];typeof i=="string"&&(i=[i]);const t=[];for(let e=0,s=i.length;e!this._currentChars.includes(w)).filter((w,_,b)=>b.indexOf(w)===_);if(!e.length)return;this._currentChars=[...this._currentChars,...e];let s;this._currentPageIndex===-1?s=this._nextPage():s=this.pages[this._currentPageIndex];let{canvas:n,context:r}=s.canvasAndContext,a=s.texture.source;const o=this._style;let h=this._currentX,l=this._currentY;const c=this.baseRenderedFontSize/this.baseMeasurementFontSize,d=this._padding*c,f=o.fontStyle==="italic"?2:1;let g=0,m=!1;for(let w=0;wthis._textureSize&&(l+=g,g=P,h=0,l+g>this._textureSize)){a.update();const v=this._nextPage();n=v.canvasAndContext.canvas,r=v.canvasAndContext.context,a=v.texture.source,l=0}const k=S/c-(((y=o.dropShadow)==null?void 0:y.distance)??0)-(((x=o._stroke)==null?void 0:x.width)??0);if(this.chars[_]={id:_.codePointAt(0),xOffset:-this._padding,yOffset:-this._padding,xAdvance:k,kerning:{}},m){this._drawGlyph(r,b,h+d,l+d,c,o);const v=a.width*c,T=a.height*c,Z=new E(h/v*a.width,l/T*a.height,F/v*a.width,P/T*a.height);this.chars[_].texture=new z({source:a,frame:Z}),h+=Math.ceil(F)}}a.update(),this._currentX=h,this._currentY=l,this._skipKerning&&this._applyKerning(e,r)}get pageTextures(){return U(N,"BitmapFont.pageTextures is deprecated, please use BitmapFont.pages instead."),this.pages}_applyKerning(t,e){const s=this._measureCache;for(let n=0;n{const y=r.width;for(let x=0;x{let m=r.chars.length-1;if(s){let y=r.chars[m];for(;y===" ";)r.width-=e.chars[y].xAdvance,y=r.chars[--m]}n.width=Math.max(n.width,r.width),r={width:0,charPositions:[],chars:[],spaceWidth:0,spacesIndex:[]},o=!0,n.lines.push(r),n.height+=e.lineHeight},d=e.baseMeasurementFontSize/t.fontSize,f=t.letterSpacing*d,g=t.wordWrapWidth*d;for(let m=0;m>16&255,s=i>>8&255,n=i&255,r=t>>16&255,a=t>>8&255,o=t&255,h=e*r/255,l=s*a/255,c=n*o/255;return(h<<16)+(l<<8)+c}const kl=new H;class da{constructor(){this.packAsQuad=!1,this.batcherName="default",this.applyTransform=!0,this.roundPixels=0,this._batcher=null,this._batch=null}get uvs(){return this.geometryData.uvs}get positions(){return this.geometryData.vertices}get indices(){return this.geometryData.indices}get blendMode(){return this.applyTransform?this.renderable.groupBlendMode:"normal"}get color(){const t=this.baseColor,e=t>>16|t&65280|(t&255)<<16,s=this.renderable;return s?Gl(e,s.groupColor)+(this.alpha*s.groupAlpha*255<<24):e+(this.alpha*255<<24)}get transform(){var t;return((t=this.renderable)==null?void 0:t.groupTransform)||kl}copyTo(t){t.indexOffset=this.indexOffset,t.indexSize=this.indexSize,t.attributeOffset=this.attributeOffset,t.attributeSize=this.attributeSize,t.baseColor=this.baseColor,t.alpha=this.alpha,t.texture=this.texture,t.geometryData=this.geometryData}reset(){this.applyTransform=!0}}const je={extension:{type:G.ShapeBuilder,name:"circle"},build(i,t){let e,s,n,r,a,o;if(i.type==="circle"){const S=i;e=S.x,s=S.y,a=o=S.radius,n=r=0}else if(i.type==="ellipse"){const S=i;e=S.x,s=S.y,a=S.halfWidth,o=S.halfHeight,n=r=0}else{const S=i,A=S.width/2,F=S.height/2;e=S.x+A,s=S.y+F,a=o=Math.max(0,Math.min(S.radius,Math.min(A,F))),n=A-a,r=F-o}if(!(a>=0&&o>=0&&n>=0&&r>=0))return t;const h=Math.ceil(2.3*Math.sqrt(a+o)),l=h*8+(n?4:0)+(r?4:0);if(l===0)return t;if(h===0)return t[0]=t[6]=e+n,t[1]=t[3]=s+r,t[2]=t[4]=e-n,t[5]=t[7]=s-r,t;let c=0,d=h*4+(n?2:0)+2,f=d,g=l,m=n+a,y=r,x=e+m,w=e-m,_=s+y;if(t[c++]=x,t[c++]=_,t[--d]=_,t[--d]=w,r){const S=s-y;t[f++]=w,t[f++]=S,t[--g]=S,t[--g]=x}for(let S=1;S0&&(n[r++]=h,n[r++]=l,n[r++]=h-1),h++;n[r++]=l+1,n[r++]=l,n[r++]=h-1}},Bl={...je,extension:{...je.extension,name:"ellipse"}},Il={...je,extension:{...je.extension,name:"roundedRectangle"}},El=1e-4,zn=1e-4;function Rl(i){const t=i.length;if(t<6)return 1;let e=0;for(let s=0,n=i[t-2],r=i[t-1];sd&&(d+=Math.PI*2);let f=c;const g=d-c,m=Math.abs(g),y=Math.sqrt(h*h+l*l),x=(15*m*Math.sqrt(y)/Math.PI>>0)+1,w=g/x;if(f+=w,o){a.push(i,t),a.push(e,s);for(let _=1,b=f;_=0&&(c.join==="round"?_+=Qt(v,T,v-L*B,T-E*B,v-X*B,T-et*B,x,!1)+4:_+=2,x.push(v-X*D,T-et*D),x.push(v+X*B,T+et*B));continue}const Qs=(-L+P)*(-E+T)-(-L+v)*(-E+k),Js=(-X+Z)*(-et+T)-(-X+v)*(-et+Rt),Je=(Wt*Js-Ge*Qs)/Qe,ti=(ke*Qs-Pe*Js)/Qe,Ii=(Je-v)*(Je-v)+(ti-T)*(ti-T),jt=v+(Je-v)*B,qt=T+(ti-T)*B,Kt=v-(Je-v)*D,Zt=T-(ti-T)*D,Da=Math.min(Wt*Wt+Pe*Pe,Ge*Ge+ke*ke),tn=Be?B:D,za=Da+tn*tn*A;Ii<=za?c.join==="bevel"||Ii/A>F?(Be?(x.push(jt,qt),x.push(v+L*D,T+E*D),x.push(jt,qt),x.push(v+X*D,T+et*D)):(x.push(v-L*B,T-E*B),x.push(Kt,Zt),x.push(v-X*B,T-et*B),x.push(Kt,Zt)),_+=2):c.join==="round"?Be?(x.push(jt,qt),x.push(v+L*D,T+E*D),_+=Qt(v,T,v+L*D,T+E*D,v+X*D,T+et*D,x,!0)+4,x.push(jt,qt),x.push(v+X*D,T+et*D)):(x.push(v-L*B,T-E*B),x.push(Kt,Zt),_+=Qt(v,T,v-L*B,T-E*B,v-X*B,T-et*B,x,!1)+4,x.push(v-X*B,T-et*B),x.push(Kt,Zt)):(x.push(jt,qt),x.push(Kt,Zt)):(x.push(v-L*B,T-E*B),x.push(v+L*D,T+E*D),c.join==="round"?Be?_+=Qt(v,T,v+L*D,T+E*D,v+X*D,T+et*D,x,!0)+2:_+=Qt(v,T,v-L*B,T-E*B,v-X*B,T-et*B,x,!1)+2:c.join==="miter"&&Ii/A<=F&&(Be?(x.push(Kt,Zt),x.push(Kt,Zt)):(x.push(jt,qt),x.push(jt,qt)),_+=2),x.push(v-X*B,T-et*B),x.push(v+X*D,T+et*D),_+=2)}P=i[(w-2)*2],k=i[(w-2)*2+1],v=i[(w-1)*2],T=i[(w-1)*2+1],L=-(k-T),E=P-v,bt=Math.sqrt(L*L+E*E),L/=bt,E/=bt,L*=S,E*=S,x.push(v-L*B,T-E*B),x.push(v+L*D,T+E*D),m||(c.cap==="round"?_+=Qt(v-L*(B-D)*.5,T-E*(B-D)*.5,v-L*B,T-E*B,v+L*D,T+E*D,x,!1)+2:c.cap==="square"&&(_+=Un(v,T,L,E,B,D,!1,x)));const La=zn*zn;for(let V=b;V<_+b-2;++V)P=x[V*2],k=x[V*2+1],v=x[(V+1)*2],T=x[(V+1)*2+1],Z=x[(V+2)*2],Rt=x[(V+2)*2+1],!(Math.abs(P*(T-Rt)+v*(Rt-k)+Z*(k-T))=0&&a>=0&&(t[0]=s,t[1]=n,t[2]=s+r,t[3]=n,t[4]=s+r,t[5]=n+a,t[6]=s,t[7]=n+a),t},triangulate(i,t,e,s,n,r){let a=0;s*=e,t[s+a]=i[0],t[s+a+1]=i[1],a+=e,t[s+a]=i[2],t[s+a+1]=i[3],a+=e,t[s+a]=i[6],t[s+a+1]=i[7],a+=e,t[s+a]=i[4],t[s+a+1]=i[5],a+=e;const o=s/e;n[r++]=o,n[r++]=o+1,n[r++]=o+2,n[r++]=o+1,n[r++]=o+3,n[r++]=o+2}},Ul={extension:{type:G.ShapeBuilder,name:"triangle"},build(i,t){return t[0]=i.x,t[1]=i.y,t[2]=i.x2,t[3]=i.y2,t[4]=i.x3,t[5]=i.y3,t},triangulate(i,t,e,s,n,r){let a=0;s*=e,t[s+a]=i[0],t[s+a+1]=i[1],a+=e,t[s+a]=i[2],t[s+a+1]=i[3],a+=e,t[s+a]=i[4],t[s+a+1]=i[5];const o=s/e;n[r++]=o,n[r++]=o+1,n[r++]=o+2}},Gi={};dt.handleByMap(G.ShapeBuilder,Gi);dt.add(zl,Dl,Ul,je,Bl,Il);const Nl=new I;function Ol(i,t){const{geometryData:e,batches:s}=t;s.length=0,e.indices.length=0,e.vertices.length=0,e.uvs.length=0;for(let n=0;n{const g=h.length,m=a.length/2,y=[],x=Gi[c.type];if(x.build(c,y),d&&ca(y,d),s){const S=c.closePath??!0;Fl(y,t,!1,S,a,2,m,h)}else if(e&&l===f){l!==0&&console.warn("[Pixi Graphics] only the last shape have be cut out");const S=[],A=y.slice();Hl(e.shapePath).forEach(P=>{S.push(A.length/2),A.push(...P)}),ua(A,S,a,2,m,h,g)}else x.triangulate(y,a,2,m,h,g);const w=o.length/2,_=t.texture;if(_!==z.WHITE){const S=t.matrix;S&&(d&&S.append(d.clone().invert()),Ml(a,2,m,o,w,2,a.length/2-m,S))}else Pl(o,w,2,a.length/2-m);const b=zt.get(da);b.indexOffset=g,b.indexSize=h.length-g,b.attributeOffset=m,b.attributeSize=a.length/2-m,b.baseColor=t.color,b.alpha=t.alpha,b.texture=_,b.geometryData=r,n.push(b)})}function Hl(i){if(!i)return[];const t=i.shapePrimitives,e=[];for(let s=0;s{zt.return(s)})}destroy(){for(const t in this._gpuContextHash)this._gpuContextHash[t]&&this.onGraphicsContextDestroy(this._gpuContextHash[t].context)}};zs.extension={type:[G.WebGLSystem,G.WebGPUSystem,G.CanvasSystem],name:"graphicsContext"};zs.defaultOptions={bezierSmoothness:.5};let fa=zs;const Yl=8,di=11920929e-14,Xl=1;function pa(i,t,e,s,n,r,a,o,h,l){const d=Math.min(.99,Math.max(0,l??fa.defaultOptions.bezierSmoothness));let f=(Xl-d)/1;return f*=f,jl(t,e,s,n,r,a,o,h,i,f),i}function jl(i,t,e,s,n,r,a,o,h,l){vs(i,t,e,s,n,r,a,o,h,l,0),h.push(a,o)}function vs(i,t,e,s,n,r,a,o,h,l,c){if(c>Yl)return;const d=(i+e)/2,f=(t+s)/2,g=(e+n)/2,m=(s+r)/2,y=(n+a)/2,x=(r+o)/2,w=(d+g)/2,_=(f+m)/2,b=(g+y)/2,S=(m+x)/2,A=(w+b)/2,F=(_+S)/2;if(c>0){let P=a-i,k=o-t;const v=Math.abs((e-a)*k-(s-o)*P),T=Math.abs((n-a)*k-(r-o)*P);if(v>di&&T>di){if((v+T)*(v+T)<=l*(P*P+k*k)){h.push(A,F);return}}else if(v>di){if(v*v<=l*(P*P+k*k)){h.push(A,F);return}}else if(T>di){if(T*T<=l*(P*P+k*k)){h.push(A,F);return}}else if(P=A-(i+a)/2,k=F-(t+o)/2,P*P+k*k<=l){h.push(A,F);return}}vs(i,t,d,f,w,_,A,F,h,l,c+1),vs(A,F,b,S,y,x,a,o,h,l,c+1)}const ql=8,Kl=11920929e-14,Zl=1;function Ql(i,t,e,s,n,r,a,o){const l=Math.min(.99,Math.max(0,o??fa.defaultOptions.bezierSmoothness));let c=(Zl-l)/1;return c*=c,Jl(t,e,s,n,r,a,i,c),i}function Jl(i,t,e,s,n,r,a,o){Cs(a,i,t,e,s,n,r,o,0),a.push(n,r)}function Cs(i,t,e,s,n,r,a,o,h){if(h>ql)return;const l=(t+s)/2,c=(e+n)/2,d=(s+r)/2,f=(n+a)/2,g=(l+d)/2,m=(c+f)/2;let y=r-t,x=a-e;const w=Math.abs((s-r)*x-(n-a)*y);if(w>Kl){if(w*w<=o*(y*y+x*x)){i.push(g,m);return}}else if(y=g-(t+r)/2,x=m-(e+a)/2,y*y+x*x<=o){i.push(g,m);return}Cs(i,t,e,l,c,g,m,o,h+1),Cs(i,g,m,d,f,r,a,o,h+1)}function ga(i,t,e,s,n,r,a,o){let h=Math.abs(n-r);(!a&&n>r||a&&r>n)&&(h=2*Math.PI-h),o=o||Math.max(6,Math.floor(6*Math.pow(s,1/3)*(h/Math.PI))),o=Math.max(o,3);let l=h/o,c=n;l*=a?-1:1;for(let d=0;dd*h)}const He=Math.PI*2,es={centerX:0,centerY:0,ang1:0,ang2:0},is=({x:i,y:t},e,s,n,r,a,o,h)=>{i*=e,t*=s;const l=n*i-r*t,c=r*i+n*t;return h.x=l+a,h.y=c+o,h};function ec(i,t){const e=t===-1.5707963267948966?-.551915024494:1.3333333333333333*Math.tan(t/4),s=t===1.5707963267948966?.551915024494:e,n=Math.cos(i),r=Math.sin(i),a=Math.cos(i+t),o=Math.sin(i+t);return[{x:n-r*s,y:r+n*s},{x:a+o*s,y:o-a*s},{x:a,y:o}]}const On=(i,t,e,s)=>{const n=i*s-t*e<0?-1:1;let r=i*e+t*s;return r>1&&(r=1),r<-1&&(r=-1),n*Math.acos(r)},ic=(i,t,e,s,n,r,a,o,h,l,c,d,f)=>{const g=Math.pow(n,2),m=Math.pow(r,2),y=Math.pow(c,2),x=Math.pow(d,2);let w=g*m-g*x-m*y;w<0&&(w=0),w/=g*x+m*y,w=Math.sqrt(w)*(a===o?-1:1);const _=w*n/r*d,b=w*-r/n*c,S=l*_-h*b+(i+e)/2,A=h*_+l*b+(t+s)/2,F=(c-_)/n,P=(d-b)/r,k=(-c-_)/n,v=(-d-b)/r,T=On(1,0,F,P);let Z=On(F,P,k,v);o===0&&Z>0&&(Z-=He),o===1&&Z<0&&(Z+=He),f.centerX=S,f.centerY=A,f.ang1=T,f.ang2=Z};function sc(i,t,e,s,n,r,a,o=0,h=0,l=0){if(r===0||a===0)return;const c=Math.sin(o*He/360),d=Math.cos(o*He/360),f=d*(t-s)/2+c*(e-n)/2,g=-c*(t-s)/2+d*(e-n)/2;if(f===0&&g===0)return;r=Math.abs(r),a=Math.abs(a);const m=Math.pow(f,2)/Math.pow(r,2)+Math.pow(g,2)/Math.pow(a,2);m>1&&(r*=Math.sqrt(m),a*=Math.sqrt(m)),ic(t,e,s,n,r,a,h,l,c,d,f,g,es);let{ang1:y,ang2:x}=es;const{centerX:w,centerY:_}=es;let b=Math.abs(x)/(He/4);Math.abs(1-b)<1e-7&&(b=1);const S=Math.max(Math.ceil(b),1);x/=S;let A=i[i.length-2],F=i[i.length-1];const P={x:0,y:0};for(let k=0;k{const h=o.x-a.x,l=o.y-a.y,c=Math.sqrt(h*h+l*l),d=h/c,f=l/c;return{len:c,nx:d,ny:f}},n=(a,o)=>{a===0?i.moveTo(o.x,o.y):i.lineTo(o.x,o.y)};let r=t[t.length-1];for(let a=0;a0&&(g=-1,m=!0);const y=f/2;let x,w=Math.abs(Math.cos(y)*h/Math.sin(y));w>Math.min(c.len/2,d.len/2)?(w=Math.min(c.len/2,d.len/2),x=Math.abs(w*Math.sin(y)/Math.cos(y))):x=h;const _=o.x+d.nx*w+-d.ny*x*g,b=o.y+d.ny*w+d.nx*x*g,S=Math.atan2(c.ny,c.nx)+Math.PI/2*g,A=Math.atan2(d.ny,d.nx)-Math.PI/2*g;a===0&&i.moveTo(_+Math.cos(S)*x,b+Math.sin(S)*x),i.arc(_,b,x,S,A,m),r=o}}function rc(i,t,e,s){const n=(o,h)=>Math.sqrt((o.x-h.x)**2+(o.y-h.y)**2),r=(o,h,l)=>({x:o.x+(h.x-o.x)*l,y:o.y+(h.y-o.y)*l}),a=t.length;for(let o=0;o=2;d-=2)c[d]===c[d-2]&&c[d-1]===c[d-3]&&c.splice(d-1,2);return this.poly(c,!0,a)}ellipse(t,e,s,n,r){return this.drawShape(new Ls(t,e,s,n),r),this}roundRect(t,e,s,n,r,a){return this.drawShape(new Ds(t,e,s,n,r),a),this}drawShape(t,e){return this.endPoly(),this.shapePrimitives.push({shape:t,transform:e}),this}startPoly(t,e){let s=this._currentPoly;return s&&this.endPoly(),s=new We,s.points.push(t,e),this._currentPoly=s,this}endPoly(t=!1){const e=this._currentPoly;return e&&e.points.length>2&&(e.closePath=t,this.shapePrimitives.push({shape:e})),this._currentPoly=null,this}_ensurePoly(t=!0){if(!this._currentPoly&&(this._currentPoly=new We,t)){const e=this.shapePrimitives[this.shapePrimitives.length-1];if(e){let s=e.shape.x,n=e.shape.y;if(e.transform&&!e.transform.isIdentity()){const r=e.transform,a=s;s=r.a*s+r.c*n+r.tx,n=r.b*a+r.d*n+r.ty}this._currentPoly.points.push(s,n)}else this._currentPoly.points.push(0,0)}}buildPath(){const t=this._graphicsPath2D;this.shapePrimitives.length=0,this._currentPoly=null;for(let e=0;eparseInt(k,10)),t.context.poly(_,!0),e&&t.context.fill(),s&&t.context.stroke();break;case"polyline":b=i.getAttribute("points"),_=b.match(/\d+/g).map(k=>parseInt(k,10)),t.context.poly(_,!1),s&&t.context.stroke();break;case"g":case"svg":break;default:{console.info(`[SVG parser] <${i.nodeName}> elements unsupported`);break}}for(let k=0;k{this._fill=ne({...this._originalFill},yt.defaultFillStyle)})),this._fill=ne(t===0?"black":t,yt.defaultFillStyle),this.update())}get stroke(){return this._originalStroke}set stroke(t){t!==this._originalStroke&&(this._originalStroke=t,this._isFillStyle(t)&&(this._originalStroke=this._createProxy({...yt.defaultStrokeStyle,...t},()=>{this._stroke=bi({...this._originalStroke},yt.defaultStrokeStyle)})),this._stroke=bi(t,yt.defaultStrokeStyle),this.update())}_generateKey(){return this._styleKey=pc(this),this._styleKey}update(){this._styleKey=null,this.emit("update",this)}reset(){const t=de.defaultTextStyle;for(const e in t)this[e]=t[e]}get styleKey(){return this._styleKey||this._generateKey()}clone(){return new de({align:this.align,breakWords:this.breakWords,dropShadow:this._dropShadow?{...this._dropShadow}:null,fill:this._fill,fontFamily:this.fontFamily,fontSize:this.fontSize,fontStyle:this.fontStyle,fontVariant:this.fontVariant,fontWeight:this.fontWeight,leading:this.leading,letterSpacing:this.letterSpacing,lineHeight:this.lineHeight,padding:this.padding,stroke:this._stroke,textBaseline:this.textBaseline,whiteSpace:this.whiteSpace,wordWrap:this.wordWrap,wordWrapWidth:this.wordWrapWidth})}destroy(t=!1){var s,n,r,a;if(this.removeAllListeners(),typeof t=="boolean"?t:t==null?void 0:t.texture){const o=typeof t=="boolean"?t:t==null?void 0:t.textureSource;(s=this._fill)!=null&&s.texture&&this._fill.texture.destroy(o),(n=this._originalFill)!=null&&n.texture&&this._originalFill.texture.destroy(o),(r=this._stroke)!=null&&r.texture&&this._stroke.texture.destroy(o),(a=this._originalStroke)!=null&&a.texture&&this._originalStroke.texture.destroy(o)}this._fill=null,this._stroke=null,this.dropShadow=null,this._originalStroke=null,this._originalFill=null}_createProxy(t,e){return new Proxy(t,{set:(s,n,r)=>(s[n]=r,e==null||e(n,r),this.update(),!0)})}_isFillStyle(t){return(t??null)!==null&&!(Y.isColorLike(t)||t instanceof Xe||t instanceof Pi)}};Ns.defaultDropShadow={alpha:1,angle:Math.PI/6,blur:0,color:"black",distance:5};Ns.defaultTextStyle={align:"left",breakWords:!1,dropShadow:null,fill:"black",fontFamily:"Arial",fontSize:26,fontStyle:"normal",fontVariant:"normal",fontWeight:"normal",leading:0,letterSpacing:0,lineHeight:0,padding:0,stroke:null,textBaseline:"alphabetic",trim:!1,whiteSpace:"pre",wordWrap:!1,wordWrapWidth:100};let W=Ns;function xc(i){const t=i;if(typeof t.dropShadow=="boolean"&&t.dropShadow){const e=W.defaultDropShadow;i.dropShadow={alpha:t.dropShadowAlpha??e.alpha,angle:t.dropShadowAngle??e.angle,blur:t.dropShadowBlur??e.blur,color:t.dropShadowColor??e.color,distance:t.dropShadowDistance??e.distance}}if(t.strokeThickness!==void 0){U(O,"strokeThickness is now a part of stroke");const e=t.stroke;let s={};if(Y.isColorLike(e))s.color=e;else if(e instanceof Xe||e instanceof Pi)s.fill=e;else if(Object.hasOwnProperty.call(e,"color")||Object.hasOwnProperty.call(e,"fill"))s=e;else throw new Error("Invalid stroke value.");i.stroke={...s,width:t.strokeThickness}}if(Array.isArray(t.fillGradientStops)){U(O,"gradient fill is now a fill pattern: `new FillGradient(...)`");let e;i.fontSize==null?i.fontSize=W.defaultTextStyle.fontSize:typeof i.fontSize=="string"?e=parseInt(i.fontSize,10):e=i.fontSize;const s=new Xe(0,0,0,e*1.7),n=t.fillGradientStops.map(r=>Y.shared.setValue(r).toNumber());n.forEach((r,a)=>{const o=a/(n.length-1);s.addColorStop(o,r)}),i.fill={fill:s}}}class yc{constructor(t){this._canvasPool=Object.create(null),this.canvasOptions=t||{},this.enableFullScreen=!1}_createCanvasAndContext(t,e){const s=Q.get().createCanvas();s.width=t,s.height=e;const n=s.getContext("2d");return{canvas:s,context:n}}getOptimalCanvasAndContext(t,e,s=1){t=Math.ceil(t*s-1e-6),e=Math.ceil(e*s-1e-6),t=nn(t),e=nn(e);const n=(t<<17)+(e<<1);this._canvasPool[n]||(this._canvasPool[n]=[]);let r=this._canvasPool[n].pop();return r||(r=this._createCanvasAndContext(t,e)),r}returnCanvasAndContext(t){const e=t.canvas,{width:s,height:n}=e,r=(s<<17)+(n<<1);this._canvasPool[r].push(t)}clear(){this._canvasPool={}}}const jn=new yc,wc=["serif","sans-serif","monospace","cursive","fantasy","system-ui"];function Ts(i){const t=typeof i.fontSize=="number"?`${i.fontSize}px`:i.fontSize;let e=i.fontFamily;Array.isArray(i.fontFamily)||(e=i.fontFamily.split(","));for(let s=e.length-1;s>=0;s--){let n=e[s].trim();!/([\"\'])[^\'\"]+\1/.test(n)&&!wc.includes(n)&&(n=`"${n}"`),e[s]=n}return`${i.fontStyle} ${i.fontVariant} ${i.fontWeight} ${t} ${e.join(",")}`}const ss={willReadFrequently:!0},Tt=class M{static get experimentalLetterSpacingSupported(){let t=M._experimentalLetterSpacingSupported;if(t!==void 0){const e=Q.get().getCanvasRenderingContext2D().prototype;t=M._experimentalLetterSpacingSupported="letterSpacing"in e||"textLetterSpacing"in e}return t}constructor(t,e,s,n,r,a,o,h,l){this.text=t,this.style=e,this.width=s,this.height=n,this.lines=r,this.lineWidths=a,this.lineHeight=o,this.maxLineWidth=h,this.fontProperties=l}static measureText(t=" ",e,s=M._canvas,n=e.wordWrap){var _;const r=`${t}:${e.styleKey}`;if(M._measurementCache[r])return M._measurementCache[r];const a=Ts(e),o=M.measureFont(a);o.fontSize===0&&(o.fontSize=e.fontSize,o.ascent=e.fontSize);const h=M.__context;h.font=a;const c=(n?M._wordWrap(t,e,s):t).split(/(?:\r\n|\r|\n)/),d=new Array(c.length);let f=0;for(let b=0;b0&&(n?r-=e:r+=(M.graphemeSegmenter(t).length-1)*e),r}static _wordWrap(t,e,s=M._canvas){const n=s.getContext("2d",ss);let r=0,a="",o="";const h=Object.create(null),{letterSpacing:l,whiteSpace:c}=e,d=M._collapseSpaces(c),f=M._collapseNewlines(c);let g=!d;const m=e.wordWrapWidth+l,y=M._tokenize(t);for(let x=0;xm)if(a!==""&&(o+=M._addLine(a),a="",r=0),M.canBreakWords(w,e.breakWords)){const b=M.wordWrapSplit(w);for(let S=0;Sm&&(o+=M._addLine(a),g=!1,a="",r=0),a+=A,r+=k}}else{a.length>0&&(o+=M._addLine(a),a="",r=0);const b=x===y.length-1;o+=M._addLine(w,!b),g=!1,a="",r=0}else _+r>m&&(g=!1,o+=M._addLine(a),a="",r=0),(a.length>0||!M.isBreakingSpace(w)||g)&&(a+=w,r+=_)}return o+=M._addLine(a,!1),o}static _addLine(t,e=!0){return t=M._trimRight(t),t=e?`${t} +`:t,t}static _getFromCache(t,e,s,n){let r=s[t];return typeof r!="number"&&(r=M._measureText(t,e,n)+e,s[t]=r),r}static _collapseSpaces(t){return t==="normal"||t==="pre-line"}static _collapseNewlines(t){return t==="normal"}static _trimRight(t){if(typeof t!="string")return"";for(let e=t.length-1;e>=0;e--){const s=t[e];if(!M.isBreakingSpace(s))break;t=t.slice(0,-1)}return t}static _isNewline(t){return typeof t!="string"?!1:M._newlines.includes(t.charCodeAt(0))}static isBreakingSpace(t,e){return typeof t!="string"?!1:M._breakingSpaces.includes(t.charCodeAt(0))}static _tokenize(t){const e=[];let s="";if(typeof t!="string")return e;for(let n=0;n{if(typeof(Intl==null?void 0:Intl.Segmenter)=="function"){const i=new Intl.Segmenter;return t=>[...i.segment(t)].map(e=>e.segment)}return i=>[...i]})();Tt.experimentalLetterSpacing=!1;Tt._fonts={};Tt._newlines=[10,13];Tt._breakingSpaces=[9,32,8192,8193,8194,8195,8196,8197,8198,8200,8201,8202,8287,12288];Tt._measurementCache={};let As=Tt;function qn(i,t){if(i.texture===z.WHITE&&!i.fill)return Y.shared.setValue(i.color).setAlpha(i.alpha??1).toHexa();if(i.fill){if(i.fill instanceof Pi){const e=i.fill,s=t.createPattern(e.texture.source.resource,"repeat"),n=e.transform.copyTo(H.shared);return n.scale(e.texture.frame.width,e.texture.frame.height),s.setTransform(n),s}else if(i.fill instanceof Xe){const e=i.fill;if(e.type==="linear"){const s=t.createLinearGradient(e.x0,e.y0,e.x1,e.y1);return e.gradientStops.forEach(n=>{s.addColorStop(n.offset,Y.shared.setValue(n.color).toHex())}),s}}}else{const e=t.createPattern(i.texture.source.resource,"repeat"),s=i.matrix.copyTo(H.shared);return s.scale(i.texture.frame.width,i.texture.frame.height),e.setTransform(s),e}return st("FillStyle not recognised",i),"red"}function ya(i){if(i==="")return[];typeof i=="string"&&(i=[i]);const t=[];for(let e=0,s=i.length;e!this._currentChars.includes(w)).filter((w,_,b)=>b.indexOf(w)===_);if(!e.length)return;this._currentChars=[...this._currentChars,...e];let s;this._currentPageIndex===-1?s=this._nextPage():s=this.pages[this._currentPageIndex];let{canvas:n,context:r}=s.canvasAndContext,a=s.texture.source;const o=this._style;let h=this._currentX,l=this._currentY;const c=this.baseRenderedFontSize/this.baseMeasurementFontSize,d=this._padding*c,f=o.fontStyle==="italic"?2:1;let g=0,m=!1;for(let w=0;wthis._textureSize&&(l+=g,g=P,h=0,l+g>this._textureSize)){a.update();const v=this._nextPage();n=v.canvasAndContext.canvas,r=v.canvasAndContext.context,a=v.texture.source,l=0}const k=S/c-(((y=o.dropShadow)==null?void 0:y.distance)??0)-(((x=o._stroke)==null?void 0:x.width)??0);if(this.chars[_]={id:_.codePointAt(0),xOffset:-this._padding,yOffset:-this._padding,xAdvance:k,kerning:{}},m){this._drawGlyph(r,b,h+d,l+d,c,o);const v=a.width*c,T=a.height*c,Z=new I(h/v*a.width,l/T*a.height,F/v*a.width,P/T*a.height);this.chars[_].texture=new z({source:a,frame:Z}),h+=Math.ceil(F)}}a.update(),this._currentX=h,this._currentY=l,this._skipKerning&&this._applyKerning(e,r)}get pageTextures(){return U(O,"BitmapFont.pageTextures is deprecated, please use BitmapFont.pages instead."),this.pages}_applyKerning(t,e){const s=this._measureCache;for(let n=0;n{const y=r.width;for(let x=0;x{let m=r.chars.length-1;if(s){let y=r.chars[m];for(;y===" ";)r.width-=e.chars[y].xAdvance,y=r.chars[--m]}n.width=Math.max(n.width,r.width),r={width:0,charPositions:[],chars:[],spaceWidth:0,spacesIndex:[]},o=!0,n.lines.push(r),n.height+=e.lineHeight},d=e.baseMeasurementFontSize/t.fontSize,f=t.letterSpacing*d,g=t.wordWrapWidth*d;for(let m=0;mg?(c(),l(h),x||r.charPositions.push(0)):(h.start=r.width,l(h),x||r.charPositions.push(0)),y==="\r"||y===` -`)r.width!==0&&c();else if(!x){const A=w.xAdvance+(w.kerning[a]||0)+f;r.width+=A,r.spaceWidth=A,r.spacesIndex.push(r.charPositions.length),r.chars.push(y)}}else{const S=w.kerning[a]||0,A=w.xAdvance+S+f;h.positions[h.index++]=h.width+S,h.chars.push(y),h.width+=A}a=y}return c(),t.align==="center"?bc(n):t.align==="right"?Sc(n):t.align==="justify"&&vc(n),n}function bc(i){for(let t=0;t50&&st("BitmapText",`You have dynamically created ${ui} bitmap fonts, this can be inefficient. Try pre installing your font styles using \`BitmapFont.install({name:"style1", style})\``),o.once("destroy",()=>{ui--,q.remove(s)}),q.set(s,o)}const r=q.get(s);return(a=r.ensureCharacters)==null||a.call(r,t),r}getLayout(t,e,s=!0){const n=this.getFont(t,e);return _c([...t],e,n,s)}measureText(t,e,s=!0){return this.getLayout(t,e,s)}install(...t){var l,c,d,f;let e=t[0];typeof e=="string"&&(e={name:e,style:t[1],chars:(l=t[2])==null?void 0:l.chars,resolution:(c=t[2])==null?void 0:c.resolution,padding:(d=t[2])==null?void 0:d.padding,skipKerning:(f=t[2])==null?void 0:f.skipKerning},U(N,"BitmapFontManager.install(name, style, options) is deprecated, use BitmapFontManager.install({name, style, ...options})"));const s=e==null?void 0:e.name;if(!s)throw new Error("[BitmapFontManager] Property `name` is required.");e={...this.defaultOptions,...e};const n=e.style,r=n instanceof W?n:new W(n),a=r._fill.fill!==null&&r._fill.fill!==void 0,o=new Kn({style:r,overrideFill:a,skipKerning:e.skipKerning,padding:e.padding,resolution:e.resolution,overrideSize:!1}),h=ya(e.chars);return o.ensureCharacters(h.join("")),q.set(`${s}-bitmap`,o),o.once("destroy",()=>q.remove(`${s}-bitmap`)),o}uninstall(t){const e=`${t}-bitmap`,s=q.get(e);s&&(q.remove(e),s.destroy())}}const Zn=new Cc;class ba extends Qr{constructor(t,e){super();const{textures:s,data:n}=t;Object.keys(n.pages).forEach(r=>{const a=n.pages[parseInt(r,10)],o=s[a.id];this.pages.push({texture:o})}),Object.keys(n.chars).forEach(r=>{const a=n.chars[r],{frame:o,source:h}=s[a.page],l=new E(a.x+o.x,a.y+o.y,a.width,a.height),c=new z({source:h,frame:l});this.chars[r]={id:r.codePointAt(0),xOffset:a.xOffset,yOffset:a.yOffset,xAdvance:a.xAdvance,kerning:a.kerning??{},texture:c}}),this.baseRenderedFontSize=n.fontSize,this.baseMeasurementFontSize=n.fontSize,this.fontMetrics={ascent:0,descent:0,fontSize:n.fontSize},this.baseLineOffset=n.baseLineOffset,this.lineHeight=n.lineHeight,this.fontFamily=n.fontFamily,this.distanceField=n.distanceField??{type:"none",range:0},this.url=e}destroy(){super.destroy();for(let t=0;t")?Qn.test(Q.get().parseXML(i)):!1},parse(i){return Qn.parse(Q.get().parseXML(i))}},Tc=[".xml",".fnt"],Ac={extension:{type:G.CacheParser,name:"cacheBitmapFont"},test:i=>i instanceof ba,getCacheableAssets(i,t){const e={};return i.forEach(s=>{e[s]=t,e[`${s}-bitmap`]=t}),e[`${t.fontFamily}-bitmap`]=t,e}},Mc={extension:{type:G.LoadParser,priority:Xt.Normal},name:"loadBitmapFont",test(i){return Tc.includes(xt.extname(i).toLowerCase())},async testParse(i){return ss.test(i)||Jn.test(i)},async parse(i,t,e){const s=ss.test(i)?ss.parse(i):Jn.parse(i),{src:n}=t,{pages:r}=s,a=[],o=s.distanceField?{scaleMode:"linear",alphaMode:"premultiply-alpha-on-upload",autoGenerateMipmaps:!1,resolution:1}:{};for(let d=0;dh[d.src]);return new ba({data:s,textures:l},n)},async load(i,t){return await(await Q.get().fetch(i)).text()},async unload(i,t,e){await Promise.all(i.pages.map(s=>e.unload(s.texture.source._sourceOrigin))),i.destroy()}};class Pc{constructor(t,e=!1){this._loader=t,this._assetList=[],this._isLoading=!1,this._maxConcurrent=1,this.verbose=e}add(t){t.forEach(e=>{this._assetList.push(e)}),this.verbose&&console.log("[BackgroundLoader] assets: ",this._assetList),this._isActive&&!this._isLoading&&this._next()}async _next(){if(this._assetList.length&&this._isActive){this._isLoading=!0;const t=[],e=Math.min(this._assetList.length,this._maxConcurrent);for(let s=0;sArray.isArray(i)&&i.every(t=>t instanceof z),getCacheableAssets:(i,t)=>{const e={};return i.forEach(s=>{t.forEach((n,r)=>{e[s+(r===0?"":r+1)]=n})}),e}};async function Sa(i){if("Image"in globalThis)return new Promise(t=>{const e=new Image;e.onload=()=>{t(!0)},e.onerror=()=>{t(!1)},e.src=i});if("createImageBitmap"in globalThis&&"fetch"in globalThis){try{const t=await(await fetch(i)).blob();await createImageBitmap(t)}catch{return!1}return!0}return!1}const kc={extension:{type:G.DetectionParser,priority:1},test:async()=>Sa("data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAAB0AAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAIAAAACAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQ0MAAAAABNjb2xybmNseAACAAIAAYAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAACVtZGF0EgAKCBgANogQEAwgMg8f8D///8WfhwB8+ErK42A="),add:async i=>[...i,"avif"],remove:async i=>i.filter(t=>t!=="avif")},tr=["png","jpg","jpeg"],Bc={extension:{type:G.DetectionParser,priority:-1},test:()=>Promise.resolve(!0),add:async i=>[...i,...tr],remove:async i=>i.filter(t=>!tr.includes(t))},Ic="WorkerGlobalScope"in globalThis&&globalThis instanceof globalThis.WorkerGlobalScope;function Os(i){return Ic?!1:document.createElement("video").canPlayType(i)!==""}const Ec={extension:{type:G.DetectionParser,priority:0},test:async()=>Os("video/mp4"),add:async i=>[...i,"mp4","m4v"],remove:async i=>i.filter(t=>t!=="mp4"&&t!=="m4v")},Rc={extension:{type:G.DetectionParser,priority:0},test:async()=>Os("video/ogg"),add:async i=>[...i,"ogv"],remove:async i=>i.filter(t=>t!=="ogv")},Fc={extension:{type:G.DetectionParser,priority:0},test:async()=>Os("video/webm"),add:async i=>[...i,"webm"],remove:async i=>i.filter(t=>t!=="webm")},Lc={extension:{type:G.DetectionParser,priority:0},test:async()=>Sa("data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAAAAAAfQ//73v/+BiOh/AAA="),add:async i=>[...i,"webp"],remove:async i=>i.filter(t=>t!=="webp")};class Dc{constructor(){this._parsers=[],this._parsersValidated=!1,this.parsers=new Proxy(this._parsers,{set:(t,e,s)=>(this._parsersValidated=!1,t[e]=s,!0)}),this.promiseCache={}}reset(){this._parsersValidated=!1,this.promiseCache={}}_getLoadPromiseAndParser(t,e){const s={promise:null,parser:null};return s.promise=(async()=>{var a,o;let n=null,r=null;if(e.loadParser&&(r=this._parserHash[e.loadParser],r||st(`[Assets] specified load parser "${e.loadParser}" not found while loading ${t}`)),!r){for(let h=0;h({alias:[l],src:l,data:{}})),o=a.length,h=a.map(async l=>{const c=xt.toAbsolute(l.src);if(!n[l.src])try{this.promiseCache[c]||(this.promiseCache[c]=this._getLoadPromiseAndParser(c,l)),n[l.src]=await this.promiseCache[c].promise,e&&e(++s/o)}catch(d){throw delete this.promiseCache[c],delete n[l.src],new Error(`[Loader.load] Failed to load ${c}. -${d}`)}});return await Promise.all(h),r?n[a[0].src]:n}async unload(t){const s=vt(t,n=>({alias:[n],src:n})).map(async n=>{var o,h;const r=xt.toAbsolute(n.src),a=this.promiseCache[r];if(a){const l=await a.promise;delete this.promiseCache[r],await((h=(o=a.parser)==null?void 0:o.unload)==null?void 0:h.call(o,l,n,this))}});await Promise.all(s)}_validateParsers(){this._parsersValidated=!0,this._parserHash=this._parsers.filter(t=>t.name).reduce((t,e)=>(e.name?t[e.name]&&st(`[Assets] loadParser name conflict "${e.name}"`):st("[Assets] loadParser should have a name"),{...t,[e.name]:e}),{})}}function Ae(i,t){if(Array.isArray(t)){for(const e of t)if(i.startsWith(`data:${e}`))return!0;return!1}return i.startsWith(`data:${t}`)}function Me(i,t){const e=i.split("?")[0],s=xt.extname(e).toLowerCase();return Array.isArray(t)?t.includes(s):s===t}const zc=".json",Uc="application/json",Oc={extension:{type:G.LoadParser,priority:Xt.Low},name:"loadJson",test(i){return Ae(i,Uc)||Me(i,zc)},async load(i){return await(await Q.get().fetch(i)).json()}},Nc=".txt",Wc="text/plain",Hc={name:"loadTxt",extension:{type:G.LoadParser,priority:Xt.Low,name:"loadTxt"},test(i){return Ae(i,Wc)||Me(i,Nc)},async load(i){return await(await Q.get().fetch(i)).text()}},$c=["normal","bold","100","200","300","400","500","600","700","800","900"],Vc=[".ttf",".otf",".woff",".woff2"],Yc=["font/ttf","font/otf","font/woff","font/woff2"],Xc=/^(--|-?[A-Z_])[0-9A-Z_-]*$/i;function jc(i){const t=xt.extname(i),n=xt.basename(i,t).replace(/(-|_)/g," ").toLowerCase().split(" ").map(o=>o.charAt(0).toUpperCase()+o.slice(1));let r=n.length>0;for(const o of n)if(!o.match(Xc)){r=!1;break}let a=n.join(" ");return r||(a=`"${a.replace(/[\\"]/g,"\\$&")}"`),a}const qc=/^[0-9A-Za-z%:/?#\[\]@!\$&'()\*\+,;=\-._~]*$/;function Kc(i){return qc.test(i)?i:encodeURI(i)}const Zc={extension:{type:G.LoadParser,priority:Xt.Low},name:"loadWebFont",test(i){return Ae(i,Yc)||Me(i,Vc)},async load(i,t){var s,n,r;const e=Q.get().getFontFaceSet();if(e){const a=[],o=((s=t.data)==null?void 0:s.family)??jc(i),h=((r=(n=t.data)==null?void 0:n.weights)==null?void 0:r.filter(c=>$c.includes(c)))??["normal"],l=t.data??{};for(let c=0;c{q.remove(t.family),Q.get().getFontFaceSet().delete(t)})}};function Ns(i,t=1){var s;const e=(s=Te.RETINA_PREFIX)==null?void 0:s.exec(i);return e?parseFloat(e[1]):t}function Ws(i,t,e){i.label=e,i._sourceOrigin=e;const s=new z({source:i,label:e}),n=()=>{delete t.promiseCache[e],q.has(e)&&q.remove(e)};return s.source.once("destroy",()=>{t.promiseCache[e]&&(st("[Assets] A TextureSource managed by Assets was destroyed instead of unloaded! Use Assets.unload() instead of destroying the TextureSource."),n())}),s.once("destroy",()=>{i.destroyed||(st("[Assets] A Texture managed by Assets was destroyed instead of unloaded! Use Assets.unload() instead of destroying the Texture."),n())}),s}const Qc=".svg",Jc="image/svg+xml",td={extension:{type:G.LoadParser,priority:Xt.Low,name:"loadSVG"},name:"loadSVG",config:{crossOrigin:"anonymous",parseAsGraphicsContext:!1},test(i){return Ae(i,Jc)||Me(i,Qc)},async load(i,t,e){return t.data.parseAsGraphicsContext??this.config.parseAsGraphicsContext?id(i):ed(i,t,e,this.config.crossOrigin)},unload(i){i.destroy(!0)}};async function ed(i,t,e,s){var x,w,_;const r=await(await Q.get().fetch(i)).blob(),a=URL.createObjectURL(r),o=new Image;o.src=a,o.crossOrigin=s,await o.decode(),URL.revokeObjectURL(a);const h=document.createElement("canvas"),l=h.getContext("2d"),c=((x=t.data)==null?void 0:x.resolution)||Ns(i),d=((w=t.data)==null?void 0:w.width)??o.width,f=((_=t.data)==null?void 0:_.height)??o.height;h.width=d*c,h.height=f*c,l.drawImage(o,0,0,d*c,f*c);const{parseAsGraphicsContext:g,...m}=t.data,y=new Ce({resource:h,alphaMode:"premultiply-alpha-on-upload",resolution:c,...m});return Ws(y,e,i)}async function id(i){const e=await(await Q.get().fetch(i)).text(),s=new yt;return s.svg(e),s}const sd=`(function () { +`)r.width!==0&&c();else if(!x){const A=w.xAdvance+(w.kerning[a]||0)+f;r.width+=A,r.spaceWidth=A,r.spacesIndex.push(r.charPositions.length),r.chars.push(y)}}else{const S=w.kerning[a]||0,A=w.xAdvance+S+f;h.positions[h.index++]=h.width+S,h.chars.push(y),h.width+=A}a=y}return c(),t.align==="center"?bc(n):t.align==="right"?Sc(n):t.align==="justify"&&vc(n),n}function bc(i){for(let t=0;t50&&st("BitmapText",`You have dynamically created ${ui} bitmap fonts, this can be inefficient. Try pre installing your font styles using \`BitmapFont.install({name:"style1", style})\``),o.once("destroy",()=>{ui--,q.remove(s)}),q.set(s,o)}const r=q.get(s);return(a=r.ensureCharacters)==null||a.call(r,t),r}getLayout(t,e,s=!0){const n=this.getFont(t,e);return _c([...t],e,n,s)}measureText(t,e,s=!0){return this.getLayout(t,e,s)}install(...t){var l,c,d,f;let e=t[0];typeof e=="string"&&(e={name:e,style:t[1],chars:(l=t[2])==null?void 0:l.chars,resolution:(c=t[2])==null?void 0:c.resolution,padding:(d=t[2])==null?void 0:d.padding,skipKerning:(f=t[2])==null?void 0:f.skipKerning},U(O,"BitmapFontManager.install(name, style, options) is deprecated, use BitmapFontManager.install({name, style, ...options})"));const s=e==null?void 0:e.name;if(!s)throw new Error("[BitmapFontManager] Property `name` is required.");e={...this.defaultOptions,...e};const n=e.style,r=n instanceof W?n:new W(n),a=r._fill.fill!==null&&r._fill.fill!==void 0,o=new Kn({style:r,overrideFill:a,skipKerning:e.skipKerning,padding:e.padding,resolution:e.resolution,overrideSize:!1}),h=ya(e.chars);return o.ensureCharacters(h.join("")),q.set(`${s}-bitmap`,o),o.once("destroy",()=>q.remove(`${s}-bitmap`)),o}uninstall(t){const e=`${t}-bitmap`,s=q.get(e);s&&(q.remove(e),s.destroy())}}const Zn=new Cc;class ba extends Qr{constructor(t,e){super();const{textures:s,data:n}=t;Object.keys(n.pages).forEach(r=>{const a=n.pages[parseInt(r,10)],o=s[a.id];this.pages.push({texture:o})}),Object.keys(n.chars).forEach(r=>{const a=n.chars[r],{frame:o,source:h}=s[a.page],l=new I(a.x+o.x,a.y+o.y,a.width,a.height),c=new z({source:h,frame:l});this.chars[r]={id:r.codePointAt(0),xOffset:a.xOffset,yOffset:a.yOffset,xAdvance:a.xAdvance,kerning:a.kerning??{},texture:c}}),this.baseRenderedFontSize=n.fontSize,this.baseMeasurementFontSize=n.fontSize,this.fontMetrics={ascent:0,descent:0,fontSize:n.fontSize},this.baseLineOffset=n.baseLineOffset,this.lineHeight=n.lineHeight,this.fontFamily=n.fontFamily,this.distanceField=n.distanceField??{type:"none",range:0},this.url=e}destroy(){super.destroy();for(let t=0;t")?Qn.test(Q.get().parseXML(i)):!1},parse(i){return Qn.parse(Q.get().parseXML(i))}},Tc=[".xml",".fnt"],Ac={extension:{type:G.CacheParser,name:"cacheBitmapFont"},test:i=>i instanceof ba,getCacheableAssets(i,t){const e={};return i.forEach(s=>{e[s]=t,e[`${s}-bitmap`]=t}),e[`${t.fontFamily}-bitmap`]=t,e}},Mc={extension:{type:G.LoadParser,priority:Xt.Normal},name:"loadBitmapFont",test(i){return Tc.includes(xt.extname(i).toLowerCase())},async testParse(i){return ns.test(i)||Jn.test(i)},async parse(i,t,e){const s=ns.test(i)?ns.parse(i):Jn.parse(i),{src:n}=t,{pages:r}=s,a=[],o=s.distanceField?{scaleMode:"linear",alphaMode:"premultiply-alpha-on-upload",autoGenerateMipmaps:!1,resolution:1}:{};for(let d=0;dh[d.src]);return new ba({data:s,textures:l},n)},async load(i,t){return await(await Q.get().fetch(i)).text()},async unload(i,t,e){await Promise.all(i.pages.map(s=>e.unload(s.texture.source._sourceOrigin))),i.destroy()}};class Pc{constructor(t,e=!1){this._loader=t,this._assetList=[],this._isLoading=!1,this._maxConcurrent=1,this.verbose=e}add(t){t.forEach(e=>{this._assetList.push(e)}),this.verbose&&console.log("[BackgroundLoader] assets: ",this._assetList),this._isActive&&!this._isLoading&&this._next()}async _next(){if(this._assetList.length&&this._isActive){this._isLoading=!0;const t=[],e=Math.min(this._assetList.length,this._maxConcurrent);for(let s=0;sArray.isArray(i)&&i.every(t=>t instanceof z),getCacheableAssets:(i,t)=>{const e={};return i.forEach(s=>{t.forEach((n,r)=>{e[s+(r===0?"":r+1)]=n})}),e}};async function Sa(i){if("Image"in globalThis)return new Promise(t=>{const e=new Image;e.onload=()=>{t(!0)},e.onerror=()=>{t(!1)},e.src=i});if("createImageBitmap"in globalThis&&"fetch"in globalThis){try{const t=await(await fetch(i)).blob();await createImageBitmap(t)}catch{return!1}return!0}return!1}const kc={extension:{type:G.DetectionParser,priority:1},test:async()=>Sa("data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAAB0AAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAIAAAACAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQ0MAAAAABNjb2xybmNseAACAAIAAYAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAACVtZGF0EgAKCBgANogQEAwgMg8f8D///8WfhwB8+ErK42A="),add:async i=>[...i,"avif"],remove:async i=>i.filter(t=>t!=="avif")},tr=["png","jpg","jpeg"],Bc={extension:{type:G.DetectionParser,priority:-1},test:()=>Promise.resolve(!0),add:async i=>[...i,...tr],remove:async i=>i.filter(t=>!tr.includes(t))},Ic="WorkerGlobalScope"in globalThis&&globalThis instanceof globalThis.WorkerGlobalScope;function Os(i){return Ic?!1:document.createElement("video").canPlayType(i)!==""}const Ec={extension:{type:G.DetectionParser,priority:0},test:async()=>Os("video/mp4"),add:async i=>[...i,"mp4","m4v"],remove:async i=>i.filter(t=>t!=="mp4"&&t!=="m4v")},Rc={extension:{type:G.DetectionParser,priority:0},test:async()=>Os("video/ogg"),add:async i=>[...i,"ogv"],remove:async i=>i.filter(t=>t!=="ogv")},Fc={extension:{type:G.DetectionParser,priority:0},test:async()=>Os("video/webm"),add:async i=>[...i,"webm"],remove:async i=>i.filter(t=>t!=="webm")},Lc={extension:{type:G.DetectionParser,priority:0},test:async()=>Sa("data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAAAAAAfQ//73v/+BiOh/AAA="),add:async i=>[...i,"webp"],remove:async i=>i.filter(t=>t!=="webp")};class Dc{constructor(){this._parsers=[],this._parsersValidated=!1,this.parsers=new Proxy(this._parsers,{set:(t,e,s)=>(this._parsersValidated=!1,t[e]=s,!0)}),this.promiseCache={}}reset(){this._parsersValidated=!1,this.promiseCache={}}_getLoadPromiseAndParser(t,e){const s={promise:null,parser:null};return s.promise=(async()=>{var a,o;let n=null,r=null;if(e.loadParser&&(r=this._parserHash[e.loadParser],r||st(`[Assets] specified load parser "${e.loadParser}" not found while loading ${t}`)),!r){for(let h=0;h({alias:[l],src:l,data:{}})),o=a.length,h=a.map(async l=>{const c=xt.toAbsolute(l.src);if(!n[l.src])try{this.promiseCache[c]||(this.promiseCache[c]=this._getLoadPromiseAndParser(c,l)),n[l.src]=await this.promiseCache[c].promise,e&&e(++s/o)}catch(d){throw delete this.promiseCache[c],delete n[l.src],new Error(`[Loader.load] Failed to load ${c}. +${d}`)}});return await Promise.all(h),r?n[a[0].src]:n}async unload(t){const s=vt(t,n=>({alias:[n],src:n})).map(async n=>{var o,h;const r=xt.toAbsolute(n.src),a=this.promiseCache[r];if(a){const l=await a.promise;delete this.promiseCache[r],await((h=(o=a.parser)==null?void 0:o.unload)==null?void 0:h.call(o,l,n,this))}});await Promise.all(s)}_validateParsers(){this._parsersValidated=!0,this._parserHash=this._parsers.filter(t=>t.name).reduce((t,e)=>(e.name?t[e.name]&&st(`[Assets] loadParser name conflict "${e.name}"`):st("[Assets] loadParser should have a name"),{...t,[e.name]:e}),{})}}function Ae(i,t){if(Array.isArray(t)){for(const e of t)if(i.startsWith(`data:${e}`))return!0;return!1}return i.startsWith(`data:${t}`)}function Me(i,t){const e=i.split("?")[0],s=xt.extname(e).toLowerCase();return Array.isArray(t)?t.includes(s):s===t}const zc=".json",Uc="application/json",Nc={extension:{type:G.LoadParser,priority:Xt.Low},name:"loadJson",test(i){return Ae(i,Uc)||Me(i,zc)},async load(i){return await(await Q.get().fetch(i)).json()}},Oc=".txt",Wc="text/plain",Hc={name:"loadTxt",extension:{type:G.LoadParser,priority:Xt.Low,name:"loadTxt"},test(i){return Ae(i,Wc)||Me(i,Oc)},async load(i){return await(await Q.get().fetch(i)).text()}},$c=["normal","bold","100","200","300","400","500","600","700","800","900"],Vc=[".ttf",".otf",".woff",".woff2"],Yc=["font/ttf","font/otf","font/woff","font/woff2"],Xc=/^(--|-?[A-Z_])[0-9A-Z_-]*$/i;function jc(i){const t=xt.extname(i),n=xt.basename(i,t).replace(/(-|_)/g," ").toLowerCase().split(" ").map(o=>o.charAt(0).toUpperCase()+o.slice(1));let r=n.length>0;for(const o of n)if(!o.match(Xc)){r=!1;break}let a=n.join(" ");return r||(a=`"${a.replace(/[\\"]/g,"\\$&")}"`),a}const qc=/^[0-9A-Za-z%:/?#\[\]@!\$&'()\*\+,;=\-._~]*$/;function Kc(i){return qc.test(i)?i:encodeURI(i)}const Zc={extension:{type:G.LoadParser,priority:Xt.Low},name:"loadWebFont",test(i){return Ae(i,Yc)||Me(i,Vc)},async load(i,t){var s,n,r;const e=Q.get().getFontFaceSet();if(e){const a=[],o=((s=t.data)==null?void 0:s.family)??jc(i),h=((r=(n=t.data)==null?void 0:n.weights)==null?void 0:r.filter(c=>$c.includes(c)))??["normal"],l=t.data??{};for(let c=0;c{q.remove(t.family),Q.get().getFontFaceSet().delete(t)})}};function Ws(i,t=1){var s;const e=(s=Te.RETINA_PREFIX)==null?void 0:s.exec(i);return e?parseFloat(e[1]):t}function Hs(i,t,e){i.label=e,i._sourceOrigin=e;const s=new z({source:i,label:e}),n=()=>{delete t.promiseCache[e],q.has(e)&&q.remove(e)};return s.source.once("destroy",()=>{t.promiseCache[e]&&(st("[Assets] A TextureSource managed by Assets was destroyed instead of unloaded! Use Assets.unload() instead of destroying the TextureSource."),n())}),s.once("destroy",()=>{i.destroyed||(st("[Assets] A Texture managed by Assets was destroyed instead of unloaded! Use Assets.unload() instead of destroying the Texture."),n())}),s}const Qc=".svg",Jc="image/svg+xml",td={extension:{type:G.LoadParser,priority:Xt.Low,name:"loadSVG"},name:"loadSVG",config:{crossOrigin:"anonymous",parseAsGraphicsContext:!1},test(i){return Ae(i,Jc)||Me(i,Qc)},async load(i,t,e){return t.data.parseAsGraphicsContext??this.config.parseAsGraphicsContext?id(i):ed(i,t,e,this.config.crossOrigin)},unload(i){i.destroy(!0)}};async function ed(i,t,e,s){var x,w,_;const r=await(await Q.get().fetch(i)).blob(),a=URL.createObjectURL(r),o=new Image;o.src=a,o.crossOrigin=s,await o.decode(),URL.revokeObjectURL(a);const h=document.createElement("canvas"),l=h.getContext("2d"),c=((x=t.data)==null?void 0:x.resolution)||Ws(i),d=((w=t.data)==null?void 0:w.width)??o.width,f=((_=t.data)==null?void 0:_.height)??o.height;h.width=d*c,h.height=f*c,l.drawImage(o,0,0,d*c,f*c);const{parseAsGraphicsContext:g,...m}=t.data,y=new Ce({resource:h,alphaMode:"premultiply-alpha-on-upload",resolution:c,...m});return Hs(y,e,i)}async function id(i){const e=await(await Q.get().fetch(i)).text(),s=new yt;return s.svg(e),s}const sd=`(function () { 'use strict'; const WHITE_PNG = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8/x8AAwMCAO+ip1sAAAAASUVORK5CYII="; @@ -264,7 +264,7 @@ ${d}`)}});return await Promise.all(h),r?n[a[0].src]:n}async unload(t){const s=vt }); })(); -`;let fe=null,As=class{constructor(){fe||(fe=URL.createObjectURL(new Blob([sd],{type:"application/javascript"}))),this.worker=new Worker(fe)}};As.revokeObjectURL=function(){fe&&(URL.revokeObjectURL(fe),fe=null)};const nd=`(function () { +`;let fe=null,Ms=class{constructor(){fe||(fe=URL.createObjectURL(new Blob([sd],{type:"application/javascript"}))),this.worker=new Worker(fe)}};Ms.revokeObjectURL=function(){fe&&(URL.revokeObjectURL(fe),fe=null)};const nd=`(function () { 'use strict'; async function loadImageBitmap(url, alphaMode) { @@ -293,4 +293,5 @@ ${d}`)}});return await Promise.all(h),r?n[a[0].src]:n}async unload(t){const s=vt }; })(); -`;let pe=null;class va{constructor(){pe||(pe=URL.createObjectURL(new Blob([nd],{type:"application/javascript"}))),this.worker=new Worker(pe)}}va.revokeObjectURL=function(){pe&&(URL.revokeObjectURL(pe),pe=null)};let er=0,ns;class rd{constructor(){this._initialized=!1,this._createdWorkers=0,this._workerPool=[],this._queue=[],this._resolveHash={}}isImageBitmapSupported(){return this._isImageBitmapSupported!==void 0?this._isImageBitmapSupported:(this._isImageBitmapSupported=new Promise(t=>{const{worker:e}=new As;e.addEventListener("message",s=>{e.terminate(),As.revokeObjectURL(),t(s.data)})}),this._isImageBitmapSupported)}loadImageBitmap(t,e){var s;return this._run("loadImageBitmap",[t,(s=e==null?void 0:e.data)==null?void 0:s.alphaMode])}async _initWorkers(){this._initialized||(this._initialized=!0)}_getWorker(){ns===void 0&&(ns=navigator.hardwareConcurrency||4);let t=this._workerPool.pop();return!t&&this._createdWorkers{this._complete(e.data),this._returnWorker(e.target),this._next()})),t}_returnWorker(t){this._workerPool.push(t)}_complete(t){t.error!==void 0?this._resolveHash[t.uuid].reject(t.error):this._resolveHash[t.uuid].resolve(t.data),this._resolveHash[t.uuid]=null}async _run(t,e){await this._initWorkers();const s=new Promise((n,r)=>{this._queue.push({id:t,arguments:e,resolve:n,reject:r})});return this._next(),s}_next(){if(!this._queue.length)return;const t=this._getWorker();if(!t)return;const e=this._queue.pop(),s=e.id;this._resolveHash[er]={resolve:e.resolve,reject:e.reject},t.postMessage({data:e.arguments,uuid:er++,id:s})}}const ir=new rd,ad=[".jpeg",".jpg",".png",".webp",".avif"],od=["image/jpeg","image/png","image/webp","image/avif"];async function hd(i,t){var n;const e=await Q.get().fetch(i);if(!e.ok)throw new Error(`[loadImageBitmap] Failed to fetch ${i}: ${e.status} ${e.statusText}`);const s=await e.blob();return((n=t==null?void 0:t.data)==null?void 0:n.alphaMode)==="premultiplied-alpha"?createImageBitmap(s,{premultiplyAlpha:"none"}):createImageBitmap(s)}const Ca={name:"loadTextures",extension:{type:G.LoadParser,priority:Xt.High,name:"loadTextures"},config:{preferWorkers:!0,preferCreateImageBitmap:!0,crossOrigin:"anonymous"},test(i){return Ae(i,od)||Me(i,ad)},async load(i,t,e){var r;let s=null;globalThis.createImageBitmap&&this.config.preferCreateImageBitmap?this.config.preferWorkers&&await ir.isImageBitmapSupported()?s=await ir.loadImageBitmap(i,t):s=await hd(i,t):s=await new Promise(a=>{s=new Image,s.crossOrigin=this.config.crossOrigin,s.src=i,s.complete?a(s):s.onload=()=>{a(s)}});const n=new Ce({resource:s,alphaMode:"premultiply-alpha-on-upload",resolution:((r=t.data)==null?void 0:r.resolution)||Ns(i),...t.data});return Ws(n,e,i)},unload(i){i.destroy(!0)}},Ta=[".mp4",".m4v",".webm",".ogg",".ogv",".h264",".avi",".mov"],ld=Ta.map(i=>`video/${i.substring(1)}`);function cd(i,t,e){e===void 0&&!t.startsWith("data:")?i.crossOrigin=ud(t):e!==!1&&(i.crossOrigin=typeof e=="string"?e:"anonymous")}function dd(i){return new Promise((t,e)=>{i.addEventListener("canplaythrough",s),i.addEventListener("error",n),i.load();function s(){r(),t()}function n(a){r(),e(a)}function r(){i.removeEventListener("canplaythrough",s),i.removeEventListener("error",n)}})}function ud(i,t=globalThis.location){if(i.startsWith("data:"))return"";t=t||globalThis.location;const e=new URL(i,document.baseURI);return e.hostname!==t.hostname||e.port!==t.port||e.protocol!==t.protocol?"anonymous":""}const fd={name:"loadVideo",extension:{type:G.LoadParser,name:"loadVideo"},test(i){const t=Ae(i,ld),e=Me(i,Ta);return t||e},async load(i,t,e){var h,l;const s={...fi.defaultOptions,resolution:((h=t.data)==null?void 0:h.resolution)||Ns(i),alphaMode:((l=t.data)==null?void 0:l.alphaMode)||await Pr(),...t.data},n=document.createElement("video"),r={preload:s.autoLoad!==!1?"auto":void 0,"webkit-playsinline":s.playsinline!==!1?"":void 0,playsinline:s.playsinline!==!1?"":void 0,muted:s.muted===!0?"":void 0,loop:s.loop===!0?"":void 0,autoplay:s.autoPlay!==!1?"":void 0};Object.keys(r).forEach(c=>{const d=r[c];d!==void 0&&n.setAttribute(c,d)}),s.muted===!0&&(n.muted=!0),cd(n,i,s.crossorigin);const a=document.createElement("source");let o;if(i.startsWith("data:"))o=i.slice(5,i.indexOf(";"));else if(!i.startsWith("blob:")){const c=i.split("?")[0].slice(i.lastIndexOf(".")+1).toLowerCase();o=fi.MIME_TYPES[c]||`video/${c}`}return a.src=i,o&&(a.type=o),new Promise(c=>{const d=async()=>{const f=new fi({...s,resource:n});n.removeEventListener("canplay",d),t.data.preload&&await dd(n),c(Ws(f,e,i))};n.addEventListener("canplay",d),n.appendChild(a)})},unload(i){i.destroy(!0)}},Aa={extension:{type:G.ResolveParser,name:"resolveTexture"},test:Ca.test,parse:i=>{var t;return{resolution:parseFloat(((t=Te.RETINA_PREFIX.exec(i))==null?void 0:t[1])??"1"),format:i.split(".").pop(),src:i}}},pd={extension:{type:G.ResolveParser,priority:-2,name:"resolveJson"},test:i=>Te.RETINA_PREFIX.test(i)&&i.endsWith(".json"),parse:Aa.parse};class gd{constructor(){this._detections=[],this._initialized=!1,this.resolver=new Te,this.loader=new Dc,this.cache=q,this._backgroundLoader=new Pc(this.loader),this._backgroundLoader.active=!0,this.reset()}async init(t={}){var r,a;if(this._initialized){st("[Assets]AssetManager already initialized, did you load before calling this Assets.init()?");return}if(this._initialized=!0,t.defaultSearchParams&&this.resolver.setDefaultSearchParams(t.defaultSearchParams),t.basePath&&(this.resolver.basePath=t.basePath),t.bundleIdentifier&&this.resolver.setBundleIdentifier(t.bundleIdentifier),t.manifest){let o=t.manifest;typeof o=="string"&&(o=await this.load(o)),this.resolver.addManifest(o)}const e=((r=t.texturePreference)==null?void 0:r.resolution)??1,s=typeof e=="number"?[e]:e,n=await this._detectFormats({preferredFormats:(a=t.texturePreference)==null?void 0:a.format,skipDetections:t.skipDetections,detections:this._detections});this.resolver.prefer({params:{format:n,resolution:s}}),t.preferences&&this.setPreferences(t.preferences)}add(t){this.resolver.add(t)}async load(t,e){this._initialized||await this.init();const s=wi(t),n=vt(t).map(o=>{if(typeof o!="string"){const h=this.resolver.getAlias(o);return h.some(l=>!this.resolver.hasKey(l))&&this.add(o),Array.isArray(h)?h[0]:h}return this.resolver.hasKey(o)||this.add({alias:o,src:o}),o}),r=this.resolver.resolve(n),a=await this._mapLoadToResolve(r,e);return s?a[n[0]]:a}addBundle(t,e){this.resolver.addBundle(t,e)}async loadBundle(t,e){this._initialized||await this.init();let s=!1;typeof t=="string"&&(s=!0,t=[t]);const n=this.resolver.resolveBundle(t),r={},a=Object.keys(n);let o=0,h=0;const l=()=>{e==null||e(++o/h)},c=a.map(d=>{const f=n[d];return h+=Object.keys(f).length,this._mapLoadToResolve(f,l).then(g=>{r[d]=g})});return await Promise.all(c),s?r[t[0]]:r}async backgroundLoad(t){this._initialized||await this.init(),typeof t=="string"&&(t=[t]);const e=this.resolver.resolve(t);this._backgroundLoader.add(Object.values(e))}async backgroundLoadBundle(t){this._initialized||await this.init(),typeof t=="string"&&(t=[t]);const e=this.resolver.resolveBundle(t);Object.values(e).forEach(s=>{this._backgroundLoader.add(Object.values(s))})}reset(){this.resolver.reset(),this.loader.reset(),this.cache.reset(),this._initialized=!1}get(t){if(typeof t=="string")return q.get(t);const e={};for(let s=0;s{const o=n[a.src],h=[a.src];a.alias&&h.push(...a.alias),h.forEach(l=>{r[l]=o}),q.set(h,o)}),r}async unload(t){this._initialized||await this.init();const e=vt(t).map(n=>typeof n!="string"?n.src:n),s=this.resolver.resolve(e);await this._unloadFromResolved(s)}async unloadBundle(t){this._initialized||await this.init(),t=vt(t);const e=this.resolver.resolveBundle(t),s=Object.keys(e).map(n=>this._unloadFromResolved(e[n]));await Promise.all(s)}async _unloadFromResolved(t){const e=Object.values(t);e.forEach(s=>{q.remove(s.src)}),await this.loader.unload(e)}async _detectFormats(t){let e=[];t.preferredFormats&&(e=Array.isArray(t.preferredFormats)?t.preferredFormats:[t.preferredFormats]);for(const s of t.detections)t.skipDetections||await s.test()?e=await s.add(e):t.skipDetections||(e=await s.remove(e));return e=e.filter((s,n)=>e.indexOf(s)===n),e}get detections(){return this._detections}setPreferences(t){this.loader.parsers.forEach(e=>{e.config&&Object.keys(e.config).filter(s=>s in t).forEach(s=>{e.config[s]=t[s]})})}}const Oe=new gd;dt.handleByList(G.LoadParser,Oe.loader.parsers).handleByList(G.ResolveParser,Oe.resolver.parsers).handleByList(G.CacheParser,Oe.cache.parsers).handleByList(G.DetectionParser,Oe.detections);dt.add(Gc,Bc,kc,Lc,Ec,Rc,Fc,Oc,Hc,Zc,td,Ca,fd,Mc,Ac,Aa,pd);const sr={loader:G.LoadParser,resolver:G.ResolveParser,cache:G.CacheParser,detection:G.DetectionParser};dt.handle(G.Asset,i=>{const t=i.ref;Object.entries(sr).filter(([e])=>!!t[e]).forEach(([e,s])=>dt.add(Object.assign(t[e],{extension:t[e].extension??s})))},i=>{const t=i.ref;Object.keys(sr).filter(e=>!!t[e]).forEach(e=>dt.remove(t[e]))});class Ct extends Si{constructor(t){t instanceof yt&&(t={context:t});const{context:e,roundPixels:s,...n}=t||{};super({label:"Graphics",...n}),this.renderPipeId="graphics",e?this._context=e:this._context=this._ownedContext=new yt,this._context.on("update",this.onViewUpdate,this),this.allowChildren=!1,this.roundPixels=s??!1}set context(t){t!==this._context&&(this._context.off("update",this.onViewUpdate,this),this._context=t,this._context.on("update",this.onViewUpdate,this),this.onViewUpdate())}get context(){return this._context}get bounds(){return this._context.bounds}addBounds(t){t.addBounds(this._context.bounds)}containsPoint(t){return this._context.containsPoint(t)}onViewUpdate(){if(this._didViewChangeTick++,this._didGraphicsUpdate=!0,this.didViewUpdate)return;this.didViewUpdate=!0;const t=this.renderGroup||this.parentRenderGroup;t&&t.onChildViewUpdate(this)}destroy(t){this._ownedContext&&!t?this._ownedContext.destroy(t):(t===!0||(t==null?void 0:t.context)===!0)&&this._context.destroy(t),this._ownedContext=null,this._context=null,super.destroy(t)}_callContextMethod(t,e){return this.context[t](...e),this}setFillStyle(...t){return this._callContextMethod("setFillStyle",t)}setStrokeStyle(...t){return this._callContextMethod("setStrokeStyle",t)}fill(...t){return this._callContextMethod("fill",t)}stroke(...t){return this._callContextMethod("stroke",t)}texture(...t){return this._callContextMethod("texture",t)}beginPath(){return this._callContextMethod("beginPath",[])}cut(){return this._callContextMethod("cut",[])}arc(...t){return this._callContextMethod("arc",t)}arcTo(...t){return this._callContextMethod("arcTo",t)}arcToSvg(...t){return this._callContextMethod("arcToSvg",t)}bezierCurveTo(...t){return this._callContextMethod("bezierCurveTo",t)}closePath(){return this._callContextMethod("closePath",[])}ellipse(...t){return this._callContextMethod("ellipse",t)}circle(...t){return this._callContextMethod("circle",t)}path(...t){return this._callContextMethod("path",t)}lineTo(...t){return this._callContextMethod("lineTo",t)}moveTo(...t){return this._callContextMethod("moveTo",t)}quadraticCurveTo(...t){return this._callContextMethod("quadraticCurveTo",t)}rect(...t){return this._callContextMethod("rect",t)}roundRect(...t){return this._callContextMethod("roundRect",t)}poly(...t){return this._callContextMethod("poly",t)}regularPoly(...t){return this._callContextMethod("regularPoly",t)}roundPoly(...t){return this._callContextMethod("roundPoly",t)}roundShape(...t){return this._callContextMethod("roundShape",t)}filletRect(...t){return this._callContextMethod("filletRect",t)}chamferRect(...t){return this._callContextMethod("chamferRect",t)}star(...t){return this._callContextMethod("star",t)}svg(...t){return this._callContextMethod("svg",t)}restore(...t){return this._callContextMethod("restore",t)}save(){return this._callContextMethod("save",[])}getTransform(){return this.context.getTransform()}resetTransform(){return this._callContextMethod("resetTransform",[])}rotateTransform(...t){return this._callContextMethod("rotate",t)}scaleTransform(...t){return this._callContextMethod("scale",t)}setTransform(...t){return this._callContextMethod("setTransform",t)}transform(...t){return this._callContextMethod("transform",t)}translateTransform(...t){return this._callContextMethod("translate",t)}clear(){return this._callContextMethod("clear",[])}get fillStyle(){return this._context.fillStyle}set fillStyle(t){this._context.fillStyle=t}get strokeStyle(){return this._context.strokeStyle}set strokeStyle(t){this._context.strokeStyle=t}clone(t=!1){return t?new Ct(this._context.clone()):(this._ownedContext=null,new Ct(this._context))}lineStyle(t,e,s){U(N,"Graphics#lineStyle is no longer needed. Use Graphics#setStrokeStyle to set the stroke style.");const n={};return t&&(n.width=t),e&&(n.color=e),s&&(n.alpha=s),this.context.strokeStyle=n,this}beginFill(t,e){U(N,"Graphics#beginFill is no longer needed. Use Graphics#fill to fill the shape with the desired style.");const s={};return t&&(s.color=t),e&&(s.alpha=e),this.context.fillStyle=s,this}endFill(){U(N,"Graphics#endFill is no longer needed. Use Graphics#fill to fill the shape with the desired style."),this.context.fill();const t=this.context.strokeStyle;return(t.width!==yt.defaultStrokeStyle.width||t.color!==yt.defaultStrokeStyle.color||t.alpha!==yt.defaultStrokeStyle.alpha)&&this.context.stroke(),this}drawCircle(...t){return U(N,"Graphics#drawCircle has been renamed to Graphics#circle"),this._callContextMethod("circle",t)}drawEllipse(...t){return U(N,"Graphics#drawEllipse has been renamed to Graphics#ellipse"),this._callContextMethod("ellipse",t)}drawPolygon(...t){return U(N,"Graphics#drawPolygon has been renamed to Graphics#poly"),this._callContextMethod("poly",t)}drawRect(...t){return U(N,"Graphics#drawRect has been renamed to Graphics#rect"),this._callContextMethod("rect",t)}drawRoundedRect(...t){return U(N,"Graphics#drawRoundedRect has been renamed to Graphics#roundRect"),this._callContextMethod("roundRect",t)}drawStar(...t){return U(N,"Graphics#drawStar has been renamed to Graphics#star"),this._callContextMethod("star",t)}}const Ma=class Pa extends ra{constructor(...t){let e=t[0]??{};e instanceof Float32Array&&(U(N,"use new MeshGeometry({ positions, uvs, indices }) instead"),e={positions:e,uvs:t[1],indices:t[2]}),e={...Pa.defaultOptions,...e};const s=e.positions||new Float32Array([0,0,1,0,1,1,0,1]),n=e.uvs||new Float32Array([0,0,1,0,1,1,0,1]),r=e.indices||new Uint32Array([0,1,2,0,2,3]),a=e.shrinkBuffersToFit,o=new Vt({data:s,label:"attribute-mesh-positions",shrinkToFit:a,usage:it.VERTEX|it.COPY_DST}),h=new Vt({data:n,label:"attribute-mesh-uvs",shrinkToFit:a,usage:it.VERTEX|it.COPY_DST}),l=new Vt({data:r,label:"index-mesh-buffer",shrinkToFit:a,usage:it.INDEX|it.COPY_DST});super({attributes:{aPosition:{buffer:o,format:"float32x2",stride:2*4,offset:0},aUV:{buffer:h,format:"float32x2",stride:2*4,offset:0}},indexBuffer:l,topology:e.topology}),this.batchMode="auto"}get positions(){return this.attributes.aPosition.buffer.data}set positions(t){this.attributes.aPosition.buffer.data=t}get uvs(){return this.attributes.aUV.buffer.data}set uvs(t){this.attributes.aUV.buffer.data=t}get indices(){return this.indexBuffer.data}set indices(t){this.indexBuffer.data=t}};Ma.defaultOptions={topology:"triangle-list",shrinkBuffersToFit:!1};let md=Ma;class we extends ${constructor(...t){let e=t[0];Array.isArray(t[0])&&(e={textures:t[0],autoUpdate:t[1]});const{textures:s,autoUpdate:n,...r}=e,[a]=s;super({...r,texture:a instanceof z?a:a.texture}),this._textures=null,this._durations=null,this._autoUpdate=n??!0,this._isConnectedToTicker=!1,this.animationSpeed=1,this.loop=!0,this.updateAnchor=!1,this.onComplete=null,this.onFrameChange=null,this.onLoop=null,this._currentTime=0,this._playing=!1,this._previousFrame=null,this.textures=s}stop(){this._playing&&(this._playing=!1,this._autoUpdate&&this._isConnectedToTicker&&(It.shared.remove(this.update,this),this._isConnectedToTicker=!1))}play(){this._playing||(this._playing=!0,this._autoUpdate&&!this._isConnectedToTicker&&(It.shared.add(this.update,this,yi.HIGH),this._isConnectedToTicker=!0))}gotoAndStop(t){this.stop(),this.currentFrame=t}gotoAndPlay(t){this.currentFrame=t,this.play()}update(t){if(!this._playing)return;const e=t.deltaTime,s=this.animationSpeed*e,n=this.currentFrame;if(this._durations!==null){let r=this._currentTime%1*this._durations[this.currentFrame];for(r+=s/60*1e3;r<0;)this._currentTime--,r+=this._durations[this.currentFrame];const a=Math.sign(this.animationSpeed*e);for(this._currentTime=Math.floor(this._currentTime);r>=this._durations[this.currentFrame];)r-=this._durations[this.currentFrame]*a,this._currentTime+=a;this._currentTime+=r/this._durations[this.currentFrame]}else this._currentTime+=s;this._currentTime<0&&!this.loop?(this.gotoAndStop(0),this.onComplete&&this.onComplete()):this._currentTime>=this._textures.length&&!this.loop?(this.gotoAndStop(this._textures.length-1),this.onComplete&&this.onComplete()):n!==this.currentFrame&&(this.loop&&this.onLoop&&(this.animationSpeed>0&&this.currentFramen)&&this.onLoop(),this._updateTexture())}_updateTexture(){const t=this.currentFrame;this._previousFrame!==t&&(this._previousFrame=t,this.texture=this._textures[t],this.updateAnchor&&this.anchor.copyFrom(this.texture.defaultAnchor),this.onFrameChange&&this.onFrameChange(this.currentFrame))}destroy(){this.stop(),super.destroy(),this.onComplete=null,this.onFrameChange=null,this.onLoop=null}static fromFrames(t){const e=[];for(let s=0;sthis.totalFrames-1)throw new Error(`[AnimatedSprite]: Invalid frame index value ${t}, expected to be between 0 and totalFrames ${this.totalFrames}.`);const e=this.currentFrame;this._currentTime=t,e!==this.currentFrame&&this._updateTexture()}get playing(){return this._playing}get autoUpdate(){return this._autoUpdate}set autoUpdate(t){t!==this._autoUpdate&&(this._autoUpdate=t,!this._autoUpdate&&this._isConnectedToTicker?(It.shared.remove(this.update,this),this._isConnectedToTicker=!1):this._autoUpdate&&!this._isConnectedToTicker&&this._playing&&(It.shared.add(this.update,this),this._isConnectedToTicker=!0))}}class xd extends Si{constructor(t,e){const{text:s,resolution:n,style:r,anchor:a,width:o,height:h,roundPixels:l,...c}=t;super({...c}),this.batched=!0,this._resolution=null,this._autoResolution=!0,this._didTextUpdate=!0,this._styleClass=e,this.text=s??"",this.style=r,this.resolution=n??null,this.allowChildren=!1,this._anchor=new pt({_onUpdate:()=>{this.onViewUpdate()}}),a&&(this.anchor=a),this.roundPixels=l??!1,o!==void 0&&(this.width=o),h!==void 0&&(this.height=h)}get anchor(){return this._anchor}set anchor(t){typeof t=="number"?this._anchor.set(t):this._anchor.copyFrom(t)}set text(t){t=t.toString(),this._text!==t&&(this._text=t,this.onViewUpdate())}get text(){return this._text}set resolution(t){this._autoResolution=t===null,this._resolution=t,this.onViewUpdate()}get resolution(){return this._resolution}get style(){return this._style}set style(t){var e;t=t||{},(e=this._style)==null||e.off("update",this.onViewUpdate,this),t instanceof this._styleClass?this._style=t:this._style=new this._styleClass(t),this._style.on("update",this.onViewUpdate,this),this.onViewUpdate()}get bounds(){return this._boundsDirty&&(this._updateBounds(),this._boundsDirty=!1),this._bounds}get width(){return Math.abs(this.scale.x)*this.bounds.width}set width(t){this._setWidth(t,this.bounds.width)}get height(){return Math.abs(this.scale.y)*this.bounds.height}set height(t){this._setHeight(t,this.bounds.height)}getSize(t){return t||(t={}),t.width=Math.abs(this.scale.x)*this.bounds.width,t.height=Math.abs(this.scale.y)*this.bounds.height,t}setSize(t,e){typeof t=="object"?(e=t.height??t.width,t=t.width):e??(e=t),t!==void 0&&this._setWidth(t,this.bounds.width),e!==void 0&&this._setHeight(e,this.bounds.height)}addBounds(t){const e=this.bounds;t.addFrame(e.minX,e.minY,e.maxX,e.maxY)}containsPoint(t){const e=this.bounds.width,s=this.bounds.height,n=-e*this.anchor.x;let r=0;return t.x>=n&&t.x<=n+e&&(r=-s*this.anchor.y,t.y>=r&&t.y<=r+s)}onViewUpdate(){if(this._didViewChangeTick++,this._boundsDirty=!0,this.didViewUpdate)return;this.didViewUpdate=!0,this._didTextUpdate=!0;const t=this.renderGroup||this.parentRenderGroup;t&&t.onChildViewUpdate(this)}_getKey(){return`${this.text}:${this._style.styleKey}:${this._resolution}`}destroy(t=!1){super.destroy(t),this.owner=null,this._bounds=null,this._anchor=null,(typeof t=="boolean"?t:t!=null&&t.style)&&this._style.destroy(t),this._style=null,this._text=null}}function yd(i,t){let e=i[0]??{};return(typeof e=="string"||i[1])&&(U(N,`use new ${t}({ text: "hi!", style }) instead`),e={text:e,style:i[1]}),e}class O extends xd{constructor(...t){const e=yd(t,"Text");super(e,W),this.renderPipeId="text"}_updateBounds(){const t=this._bounds,e=this._anchor,s=Ts.measureText(this._text,this._style),{width:n,height:r}=s;t.minX=-e._x*n,t.maxX=t.minX+n,t.minY=-e._y*r,t.maxY=t.minY+r}}const Ga=class ka extends md{constructor(...t){super({});let e=t[0]??{};typeof e=="number"&&(U(N,"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={...ka.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;const e=this.verticesX*this.verticesY,s=[],n=[],r=[],a=this.verticesX-1,o=this.verticesY-1,h=this.width/a,l=this.height/o;for(let d=0;de?1:this.width/e,n=this._topHeight+this._bottomHeight,r=this.height>n?1:this.height/n,a=Math.min(s,r);t[9]=t[11]=t[13]=t[15]=this._topHeight*a,t[17]=t[19]=t[21]=t[23]=this.height-this._bottomHeight*a,t[25]=t[27]=t[29]=t[31]=this.height,t[2]=t[10]=t[18]=t[26]=this._leftWidth*a,t[4]=t[12]=t[20]=t[28]=this.width-this._rightWidth*a,t[6]=t[14]=t[22]=t[30]=this.width,this.getBuffer("aPosition").update()}updateUvs(){const 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;const e=1/this._originalWidth,s=1/this._originalHeight;t[2]=t[10]=t[18]=t[26]=e*this._leftWidth,t[9]=t[11]=t[13]=t[15]=s*this._topHeight,t[4]=t[12]=t[20]=t[28]=1-e*this._rightWidth,t[17]=t[19]=t[21]=t[23]=1-s*this._bottomHeight,this.getBuffer("aUV").update()}};Ba.defaultOptions={width:100,height:100,leftWidth:10,topHeight:10,rightWidth:10,bottomHeight:10,originalWidth:100,originalHeight:100};let ce=Ba;const Ea=class Ra extends Si{constructor(t){var d,f,g,m;t instanceof z&&(t={texture:t});const{width:e,height:s,leftWidth:n,rightWidth:r,topHeight:a,bottomHeight:o,texture:h,roundPixels:l,...c}=t;super({label:"NineSliceSprite",...c}),this.renderPipeId="nineSliceSprite",this.batched=!0,this._didSpriteUpdate=!0,this._leftWidth=n??((d=h==null?void 0:h.defaultBorders)==null?void 0:d.left)??ce.defaultOptions.leftWidth,this._topHeight=a??((f=h==null?void 0:h.defaultBorders)==null?void 0:f.top)??ce.defaultOptions.topHeight,this._rightWidth=r??((g=h==null?void 0:h.defaultBorders)==null?void 0:g.right)??ce.defaultOptions.rightWidth,this._bottomHeight=o??((m=h==null?void 0:h.defaultBorders)==null?void 0:m.bottom)??ce.defaultOptions.bottomHeight,this.bounds.maxX=this._width=e??h.width??ce.defaultOptions.width,this.bounds.maxY=this._height=s??h.height??ce.defaultOptions.height,this.allowChildren=!1,this.texture=h??Ra.defaultOptions.texture,this.roundPixels=l??!1}get bounds(){return this._bounds}get width(){return this._width}set width(t){this.bounds.maxX=this._width=t,this.onViewUpdate()}get height(){return this._height}set height(t){this.bounds.maxY=this._height=t,this.onViewUpdate()}setSize(t,e){typeof t=="object"&&(e=t.height??t.width,t=t.width),this.bounds.maxX=this._width=t,this.bounds.maxY=this._height=e??t,this.onViewUpdate()}getSize(t){return t||(t={}),t.width=this._width,t.height=this._height,t}get leftWidth(){return this._leftWidth}set leftWidth(t){this._leftWidth=t,this.onViewUpdate()}get topHeight(){return this._topHeight}set topHeight(t){this._topHeight=t,this.onViewUpdate()}get rightWidth(){return this._rightWidth}set rightWidth(t){this._rightWidth=t,this.onViewUpdate()}get bottomHeight(){return this._bottomHeight}set bottomHeight(t){this._bottomHeight=t,this.onViewUpdate()}get texture(){return this._texture}set texture(t){t||(t=z.EMPTY);const e=this._texture;e!==t&&(e&&e.dynamic&&e.off("update",this.onViewUpdate,this),t.dynamic&&t.on("update",this.onViewUpdate,this),this._texture=t,this.onViewUpdate())}get originalWidth(){return this._texture.width}get originalHeight(){return this._texture.height}onViewUpdate(){if(this._didViewChangeTick++,this._didSpriteUpdate=!0,this.didViewUpdate)return;this.didViewUpdate=!0;const t=this.renderGroup||this.parentRenderGroup;t&&t.onChildViewUpdate(this)}addBounds(t){const e=this.bounds;t.addFrame(e.minX,e.minY,e.maxX,e.maxY)}destroy(t){if(super.destroy(t),typeof t=="boolean"?t:t==null?void 0:t.texture){const s=typeof t=="boolean"?t:t==null?void 0:t.textureSource;this._texture.destroy(s)}this._texture=null}};Ea.defaultOptions={texture:z.EMPTY};let _t=Ea;dt.add(Ha,$a);const B=class B{static async Load(t){return this.text.text="Loading asset: "+t,await Oe.load({src:t})}static async LoadAssets(){if(this.text){console.warn("Do not call GameAssets.LoadAssets() more than once.");return}console.log("Loading Texture Assets");const t=new O({text:"Loading textures. This might take a while.",style:new W({fill:3355443,fontSize:50})});t.x=u.app.canvas.width/2,t.y=u.app.canvas.height/2,t.anchor.set(.5,.5),u.app.stage.addChild(t),this.text=new O({text:"",style:new W({fill:3355443,fontSize:50})}),this.text.x=u.app.canvas.width/2,this.text.y=u.app.canvas.height/2+50,this.text.anchor.set(.5,.5),u.app.stage.addChild(this.text),await Promise.all([this.Load("./aclonica.woff2"),this.Load("./assets/gui/button_01.png").then(e=>this.Button01Texture=e),this.Load("./assets/gui/button_02.png").then(e=>this.Button02Texture=e),this.Load("./assets/gui/button_small.png").then(e=>this.ButtonSmallTexture=e),this.Load("./assets/gui/frame_01.png").then(e=>this.Frame01Texture=e),this.Load("./assets/gui/frame_02.png").then(e=>this.Frame02Texture=e),this.Load("./assets/gui/frame_03.png").then(e=>this.Frame03Texture=e),this.Load("./assets/gui/frame_04.png").then(e=>this.Frame04Texture=e),this.Load("./assets/gui/frame_05.png").then(e=>this.Frame05Texture=e),this.Load("./assets/gui/frame_inv.png").then(e=>this.FrameInventory=e),this.Load("./assets/gui/background_01.png").then(e=>this.FrameBackground=e),this.Load("./assets/gui/background_02.png").then(e=>this.FrameTowerTab=e),this.Load("./assets/gui/frame_violet.png").then(e=>this.VioletBackground=e),this.Load("./assets/gui/frame_red.png").then(e=>this.RedBackground=e),this.Load("./assets/gui/frame_green.png").then(e=>this.GreenBackground=e),this.Load("./assets/gui/frame_blue.png").then(e=>this.BlueBackground=e),this.Load("./assets/gui/frame_yellow.png").then(e=>this.YellowBackground=e),this.Load("./assets/gui/banner_01.png").then(e=>this.BannerGemsmith=e),this.Load("./assets/gui/note.png").then(e=>this.EndScreenDialog=e),this.Load("./assets/gui/main_background.jpg").then(e=>this.MainBackground=e),this.Load("./assets/tutorial/tutorial01.jpg").then(e=>this.Tutorial01=e),this.Load("./assets/tutorial/tutorial02.jpg").then(e=>this.Tutorial02=e),this.Load("./assets/tutorial/tutorial03.jpg").then(e=>this.Tutorial03=e),this.Load("./assets/tutorial/tutorial04.jpg").then(e=>this.Tutorial04=e),this.Load("./assets/tutorial/tutorial05.jpg").then(e=>this.Tutorial05=e),this.Load("./assets/gui/heart.png").then(e=>this.HealthTexture=e),this.Load("./assets/gui/money.png").then(e=>this.GoldTexture=e),this.Load("./assets/gui/wave.png").then(e=>this.WaveTexture=e),this.Load("./assets/gui/sword_02.png").then(e=>this.SwordsTexture=e),this.Load("./assets/gui/title01.png").then(e=>this.TitleTexture=e),this.Load("./assets/gui/icons/play.png").then(e=>this.PlayIconTexture=e),this.Load("./assets/gui/icons/pause.png").then(e=>this.PauseIconTexture=e),this.Load("./assets/gui/icons/pause.png").then(e=>this.PauseIconTexture=e),this.Load("./assets/gui/icons/fastforward.png").then(e=>this.FastForwardIconTexture=e),this.Load("./assets/gui/icons/home.png").then(e=>this.HomeIconTexture=e),this.Load("./assets/gui/icons/hammer.png").then(e=>this.HammerIconTexture=e),this.Load("./assets/gui/icons/cross.png").then(e=>this.XIconTexture=e),this.Load("./assets/gui/icons/plus.png").then(e=>this.PlusIconTexture=e),this.LoadMissions(),this.LoadTowers(),this.LoadCreeps(),this.LoadGems()]),t.destroy(),this.text.destroy(),this.text=!0}static async LoadGems(){const e=await(await fetch("./assets/json/Gems.json")).json();this.Gems=e;for(let s=0;s(i[i.Restricted=0]="Restricted",i[i.Buildable=1]="Buildable",i[i.Path=9]="Path",i))(Dt||{}),qe=(i=>(i[i.Basic=0]="Basic",i[i.Circle=1]="Circle",i[i.Electric=2]="Electric",i[i.Buff=3]="Buff",i[i.Strong=4]="Strong",i[i.Rail=5]="Rail",i[i.Trapper=6]="Trapper",i[i.Debuff=7]="Debuff",i))(qe||{});const J=class J{static TestSuite(){if(new URLSearchParams(location.href).entries().next().value[1]!="game")return;J.NotificationManager.Notify("Loaded testing suite.","danger");let e=C.Towers[qe.Electric];J.TowerManager.ToggleChoosingTowerLocation("RESET"),J.TowerManager.PlaceTower(e,6,10,e.behaviour,!0);for(let s=0;s<29;s++)this.GameScene.MissionStats.giveGem(new Ms(s%4),!0)}};p(J,"app"),p(J,"GameMaster"),p(J,"Grid"),p(J,"WaveManager"),p(J,"TowerManager"),p(J,"AnimationManager"),p(J,"NotificationManager"),p(J,"DebrisManager"),p(J,"GameScene"),p(J,"latestCommit"),p(J,"latestGemId",0),p(J,"GridCellSize",64),p(J,"GridColumns",25),p(J,"GridRows",17),p(J,"MouseX",0),p(J,"MouseY",0);let u=J;class _d{constructor(){p(this,"currentScene");u.GameMaster=this}_CreateGuiObject(t){this.currentScene.gui.push(t),u.GameMaster.currentScene.stage.addChild(t.container)}_RemoveGuiObject(t){this.currentScene.gui.splice(this.currentScene.gui.indexOf(t),1),u.GameMaster.currentScene.stage.removeChild(t.container)}changeScene(t){this.currentScene&&this.currentScene.destroy(),this.currentScene=t,this.currentScene.init()}}class At{constructor(t){p(this,"name",this.constructor.name);p(this,"_container",new tt);p(this,"_events",new gt);p(this,"enabled",!0);p(this,"bb",new E);u.GameMaster._CreateGuiObject(this),t&&(this._container.interactive=!0,this._container.onwheel=e=>{this.enabled&&this.onWheel(e)},this._container.onpointerdown=e=>{this.enabled&&this.onClick(e)})}destroy(){this._events.removeAllListeners(),this._container.parent&&this._container.parent.removeChild(this._container),this._container.destroy()}get container(){return this._container}get events(){return this._events}onClick(t){console.warn(`[${this.name} does not implement GuiObject.onClick()]`)}onWheel(t){console.warn(`[${this.name} does not implement GuiObject.onWheel()]`)}setEnabled(t){this.enabled=t}copyContainerToBB(){return this.bb.x=this.container.x,this.bb.y=this.container.y,this.bb.width=this.container.width,this.bb.height=this.container.height,this.bb}copyBBToContainer(){return this.container.x=this.bb.x,this.container.y=this.bb.y,this.container.width=this.bb.width,this.container.height=this.bb.height,this.container}copyPropertiesToObj(t){return t.x=this.bb.x,t.y=this.bb.y,t.width=this.bb.width,t.height=this.bb.height,t}}var ht=(i=>(i[i.Button01=0]="Button01",i[i.Button02=1]="Button02",i))(ht||{});class ut extends At{constructor(e,s,n,r=!0){super(!0);p(this,"caption");p(this,"bounds");p(this,"buttonTexture");p(this,"buttonSprite");p(this,"buttonText");p(this,"buttonIcon");n==0&&(this.buttonTexture=C.Button01Texture),n==1&&(this.buttonTexture=C.Button02Texture),this.caption=s,this.enabled=r,this.bounds=e,this.container.x=this.bounds.x,this.container.y=this.bounds.y,this.container.width=this.bounds.width,this.container.height=this.bounds.height,this.buttonSprite=new _t({texture:this.buttonTexture,leftWidth:100,topHeight:100,rightWidth:100,bottomHeight:100}),this.buttonSprite.x=0,this.buttonSprite.y=0,this.buttonSprite.width=this.bounds.width,this.buttonSprite.height=this.bounds.height,this.container.addChild(this.buttonSprite),this.buttonText=new O({text:this.caption,style:new W({fill:16777215,fontSize:24})}),this.container.addChild(this.buttonText),this.buttonText.anchor.set(.5,.5),this.buttonText.x=this.bounds.width/2,this.buttonText.y=this.bounds.height/2,this.container.x=this.bounds.x,this.container.y=this.bounds.y}setCaption(e){this.caption=e,this.buttonText.text=e}getCaption(){return this.caption}CustomButtonLogic(){console.warn(this.name+" - Button.CustomButtonLogic() is not implemented.")}}class Gi{constructor(){p(this,"stage",new tt);p(this,"gui",[]);p(this,"_events",new gt);u.app.stage.addChild(this.stage)}destroy(){this.stage.destroy(),this._events.removeAllListeners(),this.gui.forEach(t=>{t.destroy()})}addMainBackground(){const t=new $(C.MainBackground);t.width=u.app.canvas.width,t.height=u.app.canvas.height,this.stage.addChild(t)}get events(){return this._events}init(){}}class bd extends Gi{constructor(){super(...arguments);p(this,"currentImg",1);p(this,"sprite")}init(){let e=[null,C.Tutorial01,C.Tutorial02,C.Tutorial03,C.Tutorial04,C.Tutorial05];this.sprite=new $({texture:C.Tutorial01,scale:.6,x:250,y:150}),this.stage.addChild(this.sprite);let s=new ut(new E(250,this.sprite.height+160,120,60),"Back",ht.Button01);s.container.alpha=0,s.onClick=()=>{s.container.alpha==0||this.currentImg==1||(this.currentImg--,this.currentImg==3?this.sprite.scale=1.1:this.sprite.scale=.6,this.sprite.texture=e[this.currentImg],this.currentImg==1&&(s.container.alpha=0))};let n=new ut(new E(this.sprite.width+130,this.sprite.height+160,120,60),"Next",ht.Button01);n.onClick=()=>{n.container.alpha!=0&&(this.currentImg++,this.currentImg==3?this.sprite.scale=1.1:this.sprite.scale=.6,this.currentImg!=1&&(s.container.alpha=1),this.sprite.texture=e[this.currentImg],this.currentImg==5&&(n.container.alpha=0))};const r=new ut(new E(this.sprite.width-540,this.sprite.height+160,200,60),"Main menu",ht.Button01);r.onClick=a=>{u.GameMaster.changeScene(new js)}}}class Mt{constructor(){p(this,"name",this.constructor.name);p(this,"_container",new tt);p(this,"bb",new E);p(this,"_events",new gt)}destroy(){this._events.removeAllListeners(),this._container.parent&&this._container.parent.removeChild(this._container),this._container.destroy()}get container(){return this._container}get events(){return this._events}copyContainerToBB(){return this.container==null?null:(this.bb.x=this.container.x,this.bb.y=this.container.y,this.bb.width=this.container.width,this.bb.height=this.container.height,this.bb)}copyBBToContainer(){return this.container.x=this.bb.x,this.container.y=this.bb.y,this.container.width=this.bb.width,this.container.height=this.bb.height,this.container}copyPropertiesToObj(t){return t.x=this.bb.x,t.y=this.bb.y,t.width=this.bb.width,t.height=this.bb.height,t}}var re=(i=>(i.CreepSpawned="creepSpawned",i.Finished="finished",i.NewWave="newwave",i))(re||{}),ot=(i=>(i.Died="died",i.TakenDamage="takenDamage",i.GiveEffect="giveEffect",i.Escaped="escaped",i.Moved="moved",i))(ot||{}),Ke=(i=>(i.CellMouseOver="cellmouseover",i.CellMouseLeave="cellmouseleave",i))(Ke||{}),_e=(i=>(i.TowerPlacedEvent="towerPlacedEvent",i.TowerSoldEvent="towerSoldEvent",i))(_e||{}),Hs=(i=>(i.GemGivenEvent="gemGivenEvent",i))(Hs||{}),$s=(i=>(i.TowerPanelSelectGem="towerTabSelectGem",i))($s||{}),kt=(i=>(i.BasicTowerBehaviour="BasicTowerBehaviour",i.CircleTowerBehaviour="CircleTowerBehaviour",i.ElectricTowerBehaviour="ElectricTowerBehaviour",i.BuffTowerBehaviour="BuffTowerBehaviour",i.StrongTowerBehaviour="StrongTowerBehaviour",i.RailTowerBehaviour="RailTowerBehaviour",i.TrapperTowerBehaviour="TrapperTowerBehaviour",i.DebuffTowerBehaviour="DebuffTowerBehaviour",i))(kt||{});class Sd{constructor(){p(this,"isPlacingTower",!1);p(this,"canPlaceTowers",!0);p(this,"selectedTower",null);p(this,"previewSprite",new $({parent:u.GameMaster.currentScene.stage,zIndex:10,width:64,height:64,alpha:.8}));p(this,"towers",[]);u.TowerManager=this,u.GameScene.events.on(Ke.CellMouseOver,t=>{this.isPlacingTower&&(t.checkIfCantPlace()?(t.showRangePreview(!0,this.selectedTower.stats.range),this.previewSprite.tint=16711680):(t.showRangePreview(!1,this.selectedTower.stats.range),this.previewSprite.tint=16777215),this.previewSprite.x=t.column*u.GridCellSize,this.previewSprite.y=t.row*u.GridCellSize,this.previewSprite.texture=this.selectedTower.texture)}),u.GameScene.events.on(Ke.CellMouseLeave,t=>{this.previewSprite.texture=null,u.Grid.rangePreview.clear()})}ResetChooseTower(){this.selectedTower=null,this.isPlacingTower=!1,u.Grid.toggleGrid("hide")}ToggleChoosingTowerLocation(t){this.canPlaceTowers&&(u.Grid.toggleGrid(),this.isPlacingTower?(this.previewSprite.texture=null,this.selectedTower=null):C.Towers.forEach(e=>{e.name==t&&(this.selectedTower=e,console.log(this.selectedTower))}),this.isPlacingTower=!this.isPlacingTower)}PlayerClickOnGrid(t,e){if(this.canPlaceTowers&&this.isPlacingTower){if(!this.selectedTower)return u.NotificationManager.Notify("TowerManager.selectedTower is null when trying to place tower.","danger"),console.warn("TowerManager.selectedTower is null when trying to place tower.");this.PlaceTower(this.selectedTower,t,e,this.selectedTower.behaviour)}}GetTowerByRowAndCol(t,e){let s=null;return this.towers.forEach(n=>{n.row==t&&n.column==e&&(s=n)}),s}PlaceTower(t,e,s,n,r){const a=t.texture;if(!u.GameScene.MissionStats.hasEnoughGold(t.stats.cost)&&!r)return u.NotificationManager.Notify("Not enough gold.","warn");if(!this.GetTowerByRowAndCol(e,s)&&u.Grid.getCellByRowAndCol(e,s).type!=Dt.Path&&u.Grid.getCellByRowAndCol(e,s).type!=Dt.Restricted){r||u.GameScene.MissionStats.spendGold(t.stats.cost);let o=new Ld(e,s,a,t,n);this.towers.push(o),this.ToggleChoosingTowerLocation("RESET"),this.selectedTower=null,this.previewSprite.x=-100,u.GameScene.events.emit(_e.TowerPlacedEvent,t.name,e,s)}else u.NotificationManager.Notify("Can not place tower on path or other tower, choose another spot.","warn")}update(t){this.towers.forEach((e,s)=>{if(e.sold){for(e.slottedGems=e.slottedGems.filter(n=>n!=null);e.slottedGems.length>0;)e.UnslotGem(0);u.GameScene.events.emit(_e.TowerSoldEvent,e.definition.name,e.row,e.column),u.GameScene.MissionStats.earnGold(e.definition.stats.cost),e.destroy(),this.towers.splice(s,1)}else e.update(t)})}}function ct(i,t,e,s){const n=e-i,r=s-t;return Math.atan2(r,n)}class Vs extends Mt{constructor(e,s,n,r,a,o,h,l,c){super();p(this,"deleteMe",!1);p(this,"sprite");p(this,"x");p(this,"y");p(this,"angle");p(this,"speed");p(this,"damage");p(this,"pierce",1);p(this,"timeToLive");p(this,"parent");p(this,"gemResistanceModifications");p(this,"collidedCreepIDs",[]);this.x=e,this.y=s,this.timeToLive=h,this.pierce=l,this.damage=a,this.gemResistanceModifications=c,this.sprite=new we({textures:n,scale:.25,rotation:r}),this.sprite.anchor.set(.5,.5),this.sprite.play(),this.container.x=this.x,this.container.y=this.y,this.container.addChild(this.sprite),u.GameMaster.currentScene.stage.addChild(this.container),this.angle=r,this.speed=.9}destroy(){super.destroy(),this.deleteMe=!0}update(e){if(!this.deleteMe){if(this.x>1720||this.x<0||this.y>2e3||this.y<0||this.pierce<=0||this.timeToLive<=0)return this.destroy();this.timeToLive-=u.GameScene.gameSpeedMultiplier,u.Grid.creeps.forEach(s=>{if(!(this.pierce<=0)&&s&&s.container&&this.checkCollision(s)&&!this.collidedCreepIDs.find(r=>s.id==r.id)){this.collidedCreepIDs.push(s),this.pierce--,this.onCollide(s,this);return}}),this.x+=Math.cos(this.angle)*this.speed*e*u.GameScene.gameSpeedMultiplier,this.y+=Math.sin(this.angle)*this.speed*e*u.GameScene.gameSpeedMultiplier,this.container.x=this.x,this.container.y=this.y}}onCollide(e,s){u.GameScene.events.emit(ot.TakenDamage,e.id,s.damage,s.gemResistanceModifications)}checkCollision(e){if(e==null||e.container==null||e.container._position==null)return;let s=this.copyContainerToBB(),n=e.copyContainerToBB();return s.getBounds().intersects(n.getBounds())}}class vd extends Vs{constructor(e,s,n,r,a,o,h,l,c){super(e,s,n,r,a,o,h,l,c);p(this,"visuals",[]);p(this,"counter",0);this.pierce=1e3,this.timeToLive=2e3}destroy(){super.destroy(),this.visuals.forEach(e=>e.destroy()),this.visuals=[]}update(e){if(super.update(e),this.counter==2){this.counter=0;let s=new $({x:this.x,y:this.y,rotation:this.angle,texture:this.sprite.texture,scale:.25});s.anchor.set(.5,.5),this.visuals.push(s),this.visuals.forEach(n=>{if(n.scale==null)return n.destroy();n.width&&n.height&&n.alpha&&(n.width-=4,n.height-=4,n.alpha-=.1,(n.width<=0||n.height<=0||n.alpha<=0)&&n.destroy())}),u.GameScene.stage.addChild(s)}else this.counter++}}class Cd extends Vs{constructor(e,s,n,r,a,o,h,l,c,d,f){super(e,s,n,r,h,l,c,d,f);p(this,"visuals",[]);p(this,"counter",0);p(this,"goalX");p(this,"goalY");this.sprite.scale=.5,this.goalX=a,this.goalY=o}destroy(){super.destroy(),this.visuals.forEach(e=>e.destroy()),this.visuals=[]}update(e){if(!this.deleteMe){if(this.x>1720||this.x<0||this.y>2e3||this.y<0||this.pierce<=0||this.timeToLive<=0)return this.destroy();be(this.x,this.y,this.goalX,this.goalY)<25?(this.timeToLive-=u.GameScene.gameSpeedMultiplier,u.Grid.creeps.forEach(s=>{if(!(this.pierce<=0)&&s&&s.container&&this.checkCollision(s)){this.collidedCreepIDs.push(s),this.pierce--,this.onCollide(s,this);return}})):(this.x+=Math.cos(this.angle)*this.speed*e*u.GameScene.gameSpeedMultiplier,this.y+=Math.sin(this.angle)*this.speed*e*u.GameScene.gameSpeedMultiplier,this.container.x=this.x,this.container.y=this.y)}}}class Td extends Mt{constructor(e,s){super();p(this,"deleteMe",!1);p(this,"c");p(this,"oc");p(this,"Lightning");this.c=e,this.oc=s;let n=ct(e.x,e.y,s.x,s.y);this.Lightning=new we({textures:C.SpecialLightning,x:e.x,y:e.y,width:be(this.c.x,this.c.y,this.oc.x,this.oc.y),height:64,scale:1.2,rotation:n}),this.Lightning.anchor.set(0,.5),this.Lightning.play(),u.GameMaster.currentScene.stage.addChild(this.Lightning),u.DebrisManager.CreateDebris(this,30)}destroy(){this.deleteMe=!0,this.container.destroy(),this.Lightning.destroy()}update(){this.deleteMe||(this.Lightning.x=this.c.x,this.Lightning.y=this.c.y,this.Lightning.width=be(this.c.x,this.c.y,this.oc.x,this.oc.y))}}var Ys=(i=>(i.MovingBackwards="MovingBackwards",i.DebuffTowerDebuff="DebuffTowerDebuff",i))(Ys||{});class Ad{constructor(t,e){p(this,"effectEnum");p(this,"durationInMS");p(this,"ticks",0);this.effectEnum=t,this.durationInMS=e}}class Md extends Mt{constructor(e,s,n){super();p(this,"id");p(this,"creepType");p(this,"sprite");p(this,"path");p(this,"stats");p(this,"pathIndex",0);p(this,"speed");p(this,"direction",1);p(this,"healthBarGraphics",new Ct);p(this,"healthBarWidth",50);p(this,"effects",[]);p(this,"health");p(this,"maxHealth");p(this,"escaped",!1);p(this,"died",!1);p(this,"x");p(this,"y");p(this,"dead",!1);this.creepType=e,this.stats=structuredClone(C.Creeps[this.creepType].stats),this.sprite=new we(C.Creeps[this.creepType].textures),this.sprite.scale.x*=-1,this.sprite.anchor.set(.5,.5),this.sprite.animationSpeed=.3,this.sprite.play(),this.id=n,this.container.x=-70,this.container.y=-50,this.sprite.width=u.GridCellSize,this.sprite.height=u.GridCellSize,this.bb.width=this.sprite.width,this.speed=this.stats.speed/60,this.health=this.stats.health,this.maxHealth=this.stats.health,this.path=s,this.x=s[0][0]*u.GridCellSize+u.GridCellSize/2,this.y=s[0][1]*u.GridCellSize+u.GridCellSize/2,u.GameScene.events.on(ot.TakenDamage,(r,a,o)=>{r==this.id&&(this.effects.find(h=>h.effectEnum=="DebuffTowerDebuff")&&(a=a*1.5,console.log("multiplying damage, "+a)),this.health-=a+a*(o.physical-this.stats.resistance.physical),o.fire!=0&&(this.health-=Math.max(a*(o.fire-this.stats.resistance.fire),0)),o.ice!=0&&(this.health-=Math.max(a*(o.ice-this.stats.resistance.ice),0)),o.frostfire!=0&&(this.health-=Math.max(a*(o.frostfire-this.stats.resistance.frostfire),0)),o.divine!=0&&(this.health-=Math.max(a*(o.divine-this.stats.resistance.divine),0)),this.UpdateHealthbar())}),u.GameScene.events.on(ot.GiveEffect,(r,a,o)=>{r==this.id&&(console.log(" I CAUGHT THE EVENT!"),this.effects.find(h=>h.effectEnum==a)==null&&this.effects.push(new Ad(a,o)))}),u.Grid.container.addChild(this.container),this.container.addChild(this.healthBarGraphics),this.container.addChild(this.sprite),this.UpdateHealthbar()}UpdateHealthbar(){this.healthBarGraphics.clear();const e=this.health,s=this.maxHealth,n=Math.max(0,e/s),r=this.healthBarWidth,a=10,o=2,h=-r/2,l=-32;this.healthBarGraphics.rect(h-o,l-o,r+o*2,a+o*2),this.healthBarGraphics.fill({color:0});const c=r*n;this.healthBarGraphics.rect(h,l,c,a),this.healthBarGraphics.fill({color:16711680})}update(e){if(this.dead)return;if(this.health<=0){u.GameScene.events.emit(ot.Died,this.maxHealth,this),this.destroy(),this.dead=!0;return}if(this.pathIndex+1==this.path.length){if(this.escaped)return;this.events.emit(ot.Escaped,this),this.escaped=!0;return}const s=this.path[this.pathIndex],n=this.path[this.pathIndex+1],r=this.pathIndex-1!=0?this.path[this.pathIndex-1]:this.path[0];let a=!1;for(let m=this.effects.length-1;m>=0;m--){let y=this.effects[m];if(y.ticks+=e*u.GameScene.gameSpeedMultiplier,y.ticks>=y.durationInMS)this.effects.splice(m,1);else if(y.effectEnum=="MovingBackwards")return a=!0}let o,h,l,c;a?(o=r[0]*u.GridCellSize+u.GridCellSize/2,h=r[1]*u.GridCellSize+u.GridCellSize/2,l=s[0]-r[0],c=r[1]-s[1]):(o=n[0]*u.GridCellSize+u.GridCellSize/2,h=n[1]*u.GridCellSize+u.GridCellSize/2,l=n[0]-s[0],c=n[1]-s[1]),l>0?this.direction!=1&&(this.direction=1,this.sprite.scale.x*=-1):l<0&&this.direction!=-1&&(this.direction=-1,this.sprite.scale.x*=-1);let d=this.speed*e*l*u.GameScene.gameSpeedMultiplier,f=this.speed*e*c*u.GameScene.gameSpeedMultiplier,g=!1;d>0&&this.x+d>o&&(d=o-this.x,g=!0),d<0&&this.x+d0&&this.y+f>h&&(f=h-this.y,g=!0),f<0&&this.y+f=0;e--){let s=i.projectiles[e];s.deleteMe||i.sold?(s.collidedCreepIDs.forEach(()=>{i.damageDealt+=i.computedDamageToDeal}),s.collidedCreepIDs=[],s.destroy(),i.projectiles.splice(e,1)):s.update(t)}}function Nt(i){let t=0,e=0,s=0,n=0,r=0;if(i.totalGemResistanceModifications={fire:0,frostfire:0,divine:0,ice:0,physical:0},i.slottedGems.forEach(a=>{let o=a.currentGemImprovement();t+=o.damageUp,e+=o.attackSpeedUp,s+=o.rangeUp,n+=o.timeToLiveUp,r+=o.pierceUp;let h=a.currentGemResistanceModifications();i.totalGemResistanceModifications.physical+=h.physical,i.totalGemResistanceModifications.ice+=h.ice,i.totalGemResistanceModifications.fire+=h.fire,i.totalGemResistanceModifications.divine+=h.divine,i.totalGemResistanceModifications.frostfire+=h.frostfire}),i.computedDamageToDeal=i.definition.stats.damage+t,i.computedCooldown=i.definition.stats.cooldown-e,i.computedRange=i.definition.stats.range+s,i.computedTimeToLive=i.definition.stats.timeToLive+n,i.computedPierce=i.definition.stats.pierce+r,i.parent.isBuffedBy.length>0&&i.definition.name!=C.Towers[qe.Buff].name){let a=i.parent.isBuffedBy[0];i.computedDamageToDeal+=Number((a.computedDamageToDeal/2).toFixed(1)),i.computedCooldown-=Number((a.computedCooldown/5).toFixed(1)),i.computedRange+=Number((a.computedRange/10).toFixed(1)),i.computedTimeToLive+=Number((a.computedTimeToLive/5).toFixed(1)),i.computedPierce+=Number((a.computedPierce/4).toFixed(1)),i.totalGemResistanceModifications.physical+=a.totalGemResistanceModifications.physical*100/2/100,i.totalGemResistanceModifications.ice+=a.totalGemResistanceModifications.ice*100/2/100,i.totalGemResistanceModifications.fire+=a.totalGemResistanceModifications.fire*100/2/100,i.totalGemResistanceModifications.divine+=a.totalGemResistanceModifications.divine*100/2/100,i.totalGemResistanceModifications.frostfire+=a.totalGemResistanceModifications.frostfire*100/2/100}}function Pd(i,t){if(Nt(i),oe(i,t),i.millisecondsUntilNextShot>0)i.millisecondsUntilNextShot-=t*u.GameScene.gameSpeedMultiplier;else{let e=i.GetCreepsInRange();if(e.length>0){let s=e[0],n=i.column*u.GridCellSize+u.GridCellSize/2,r=i.row*u.GridCellSize+u.GridCellSize/2;i.millisecondsUntilNextShot=i.computedCooldown,i.Shoot(ct(n,r,s.x,s.y))}}}function Gd(i,t){if(Nt(i),oe(i,t),i.millisecondsUntilNextShot>0)i.millisecondsUntilNextShot-=t*u.GameScene.gameSpeedMultiplier;else if(i.GetCreepsInRange().length>0){i.millisecondsUntilNextShot=i.computedCooldown;let s=i.column*u.GridCellSize+u.GridCellSize/2,n=i.row*u.GridCellSize+u.GridCellSize/2;i.Shoot(ct(s,n,s,n+10)),i.Shoot(ct(s,n,s+10,n)),i.Shoot(ct(s,n,s-10,n)),i.Shoot(ct(s,n,s,n-10)),i.Shoot(ct(s,n,s+10,n+10)),i.Shoot(ct(s,n,s-10,n+10)),i.Shoot(ct(s,n,s-10,n-10)),i.Shoot(ct(s,n,s+10,n-10))}}function kd(i,t){if(Nt(i),oe(i,t),i.millisecondsUntilNextShot>0)i.millisecondsUntilNextShot-=t*u.GameScene.gameSpeedMultiplier;else{let e=i.GetCreepsInRange();if(e.length>0){let s=e[0],n=i.column*u.GridCellSize+u.GridCellSize/2,r=i.row*u.GridCellSize+u.GridCellSize/2;i.millisecondsUntilNextShot=i.computedCooldown;let a=i.Shoot(ct(n,r,s.x,s.y));a.onCollide=(o,h)=>{let l=[];h.pierce=0;let c=0;function d(f){if(c>=50){u.GameScene.PauseGame(),u.NotificationManager.Notify("Electric Tower max recursion exceeded! Please tell koneko! (game paused)","danger");return}c++,u.Grid.creeps.forEach(g=>{if(g.id!=o.id){const m=g.x,y=g.y,x=1.5*u.GridCellSize;if(be(f.x,f.y,m,y)_==g.id)!=null)return;l.push(g.id),new Td(f,g),u.GameScene.events.emit(ot.TakenDamage,g.id,Math.round(h.damage/2),h.gemResistanceModifications),d(g)}}})}u.GameScene.events.emit(ot.TakenDamage,o.id,h.damage,h.gemResistanceModifications),l.push(o.id),d(o)}}}}function Bd(i,t){Nt(i)}function Id(i,t){if(Nt(i),oe(i,t),i.millisecondsUntilNextShot>0)i.millisecondsUntilNextShot-=t*u.GameScene.gameSpeedMultiplier;else{let e=i.GetCreepsInRange();if(e.length>0){let s=e[0],n=i.column*u.GridCellSize+u.GridCellSize/2,r=i.row*u.GridCellSize+u.GridCellSize/2;i.millisecondsUntilNextShot=i.computedCooldown;let a=i.Shoot(ct(n,r,s.x,s.y));a.onCollide=(o,h)=>{u.GameScene.events.emit(ot.GiveEffect,o.id,Ys.MovingBackwards,750),u.GameScene.events.emit(ot.TakenDamage,o.id,h.damage/2,h.gemResistanceModifications)}}}}function Ed(i,t){if(Nt(i),oe(i,t),i.millisecondsUntilNextShot>0)i.millisecondsUntilNextShot-=t*u.GameScene.gameSpeedMultiplier;else{let e=i.GetCreepsInRange();if(e.length>0){let s=e[0],n=i.column*u.GridCellSize+u.GridCellSize/2,r=i.row*u.GridCellSize+u.GridCellSize/2;i.millisecondsUntilNextShot=i.computedCooldown,i.Shoot(ct(n,r,s.x,s.y))}}}function Rd(i,t){if(Nt(i),oe(i,t),i.millisecondsUntilNextShot>0)i.millisecondsUntilNextShot-=t*u.GameScene.gameSpeedMultiplier;else{if(u.GameScene.roundMode!=Fa.Combat)return;let e=i.column*u.GridCellSize+u.GridCellSize/2,s=i.row*u.GridCellSize+u.GridCellSize/2,n=u.Grid.GetPathCellsInRange(i.row,i.column,i.computedRange);if(n.length>0){let r=Math.floor(Math.random()*n.length),a=n[r],o=a.column*u.GridCellSize+u.GridCellSize/2,h=a.row*u.GridCellSize+u.GridCellSize/2,l=new Y("white");if(i.slottedGems.length>0){let d=new Y(i.slottedGems[0].definition.color);for(let f=1;f0&&(i.millisecondsUntilNextShot-=t*u.GameScene.gameSpeedMultiplier);let e=i.GetCreepsInRange();if(e.length>0){let s=e[0];if(i.millisecondsUntilNextShot<=0){let n=i.column*u.GridCellSize+u.GridCellSize/2,r=i.row*u.GridCellSize+u.GridCellSize/2;i.millisecondsUntilNextShot=i.computedCooldown;let a=i.Shoot(ct(n,r,s.x,s.y));a.onCollide=(o,h)=>{u.GameScene.events.emit(ot.GiveEffect,o.id,Ys.DebuffTowerDebuff,5e3),u.GameScene.events.emit(ot.TakenDamage,o.id,h.damage/1.5,h.gemResistanceModifications)}}}}function be(i,t,e,s){return Math.sqrt((e-i)*(e-i)+(s-t)*(s-t))}class Ld extends Mt{constructor(e,s,n,r,a){super();p(this,"row");p(this,"column");p(this,"setAsSold",!1);p(this,"sold",!1);p(this,"definition");p(this,"slottedGems",[]);p(this,"damageDealt",0);p(this,"projectiles",[]);p(this,"behaviour");p(this,"sprite");p(this,"millisecondsUntilNextShot");p(this,"graphics",new Ct);p(this,"computedDamageToDeal",0);p(this,"computedCooldown",0);p(this,"computedRange",0);p(this,"computedTimeToLive",0);p(this,"computedPierce",0);p(this,"totalGemResistanceModifications",{fire:0,frostfire:0,divine:0,ice:0,physical:0});p(this,"parent");p(this,"onParentCellEnter",e=>{!u.TowerManager.isPlacingTower&&u.Grid.gridInteractionEnabled&&!u.GameScene.towerPanel.isShown&&this.parent.showRangePreview(!1,this.computedRange)});p(this,"onParentCellLeave",e=>{this.graphics.clear()});this.row=e,this.column=s,this.behaviour=a,this.definition=r,this.millisecondsUntilNextShot=0,this.parent=u.Grid.getCellByRowAndCol(e,s),this.sprite=new $({texture:n,height:u.GridCellSize,width:u.GridCellSize,zIndex:130}),this.container.addChild(this.sprite),this.computedDamageToDeal=this.definition.stats.damage,this.computedRange=this.definition.stats.range,this.parent.container.addChild(this.container),this.container.interactiveChildren=!0,this.parent.clickDetector.on("pointerenter",this.onParentCellEnter),this.parent.clickDetector.on("pointerleave",this.onParentCellLeave),u.GameMaster.currentScene.stage.addChild(this.graphics)}SlotGem(e,s){this.slottedGems[s]=e,u.GameScene.towerPanel.Hide(),u.GameScene.towerPanel.Show(this)}UnslotGem(e){const s=this.slottedGems.splice(e,1)[0];if(s==null||!s)return console.warn("UnslotGem: Gem is null.");u.GameScene.MissionStats.giveGem(s,!0);for(let n=e;nn!=null),u.NotificationManager.Notify(`Lv. ${s.level} ${s.definition.name} unslotted and placed back in your inventory.`,"info")}GetCreepsInRange(){return u.Grid.creeps.filter(s=>{const n=s.x,r=s.y,a=this.column*u.GridCellSize+u.GridCellSize/2,o=this.row*u.GridCellSize+u.GridCellSize/2,h=this.computedRange*u.GridCellSize;return be(a,o,n,r)0){let o=new Y(this.slottedGems[0].definition.color);for(let h=1;h{u.Grid.gridInteractionEnabled&&(u.TowerManager.isPlacingTower?u.Grid.onGridCellClicked(s,n):this.OpenSelectedTowerPanel())}),this.clickDetector.on("pointerenter",a=>{!u.Grid.gridInteractionEnabled||u.GameScene.towerPanel.isShown||u.GameScene.events.emit(Ke.CellMouseOver,this)}),this.clickDetector.on("pointerleave",a=>{!u.Grid.gridInteractionEnabled||u.GameScene.towerPanel.isShown||u.GameScene.events.emit(Ke.CellMouseLeave,this)}),u.GameScene.events.on(_e.TowerPlacedEvent,(a,o,h)=>{if(o==this.row&&h==this.column)this.hasTowerPlaced=!0,u.Grid.rangePreview.clear();else if(a==C.Towers[qe.Buff].name){let l=u.TowerManager.GetTowerByRowAndCol(o,h);u.Grid.IsCellInRangeOfOtherCell(o,h,l.computedRange,this)&&this.isBuffedBy.push(l)}}),u.GameScene.events.on(_e.TowerSoldEvent,(a,o,h)=>{if(console.log(a,o,h),o==this.row&&h==this.column)this.hasTowerPlaced=!1,u.Grid.rangePreview.clear();else if(a==C.Towers[qe.Buff].name){let l=u.TowerManager.GetTowerByRowAndCol(o,h);u.Grid.IsCellInRangeOfOtherCell(o,h,l.computedRange,this)&&(console.log("REMOVED!"),this.isBuffedBy.splice(this.isBuffedBy.indexOf(l),1),console.log(this.isBuffedBy))}})}showRangePreview(e,s){let n=16777215;e&&(n=16711680),u.Grid.rangePreview.clear(),u.Grid.rangePreview.circle(this.column*u.GridCellSize+u.GridCellSize/2,this.row*u.GridCellSize+u.GridCellSize/2,s*u.GridCellSize),u.Grid.rangePreview.fill({color:n,alpha:.3})}OpenSelectedTowerPanel(){if(this.hasTowerPlaced){const e=u.TowerManager.GetTowerByRowAndCol(this.row,this.column);u.GameScene.towerPanel.Show(e)}}checkIfCantPlace(){return this.hasTowerPlaced||this.isPath||this.type==Dt.Path||this.type==Dt.Restricted}gDraw(){this.g.rect(0,0,this.bb.width,this.bb.height),this.type==Dt.Restricted?this.g.fill({color:2236962,alpha:.5}):this.hasTowerPlaced?this.g.fill({color:16711680,alpha:.5}):this.type==Dt.Path?this.g.fill({color:2236962,alpha:.5}):this.type==Dt.Buildable&&this.g.stroke({color:65280,alpha:.9})}gClear(){this.g.clear()}update(){}}class zd extends Mt{constructor(e,s){super();p(this,"gameMap");p(this,"cells",[]);p(this,"rangePreview");p(this,"creeps",[]);p(this,"gridShown",!1);p(this,"gridInteractionEnabled",!0);this.gameMap=e,u.Grid=this,this.bb.x=0,this.bb.y=0,this.bb.width=u.GridCellSize*u.GridColumns,this.bb.height=u.GridCellSize*u.GridRows,u.GameMaster.currentScene.stage.addChild(this.container);let n=new $(C.MissionBackgrounds[s]);this.container.addChild(n);for(let r=0;rc.some(d=>d[1]===a&&d[0]===r));h&&(o=Dt.Path);let l=new Dd(o,a,r,h);this.cells.push(l)}this.rangePreview=new Ct({zIndex:10,x:0,y:0,width:u.app.canvas.width,height:u.app.canvas.height}),this.container.addChild(this.rangePreview)}generateCells(){const e=Array.from({length:this.gameMap.rows},()=>Array(this.gameMap.columns).fill(1));this.cells.forEach(s=>{if(s.isPath){e[s.row][s.column]=9;for(let n=-1;n<=1;n++)for(let r=-1;r<=1;r++){const a=s.row+n,o=s.column+r;a>=0&&a=0&&o{a.isPath&&this.IsCellInRangeOfOtherCell(e,s,n,a)&&r.push(a)}),r}toggleGrid(e){this.cells.forEach(s=>{if(e){e=="hide"?s.gClear():s.gDraw();return}this.gridShown?s.gClear():s.gDraw()}),e=="hide"?this.gridShown=!1:e=="show"?this.gridShown=!0:this.gridShown=!this.gridShown}addCreep(e){this.creeps.push(e),e.events.on(ot.Died,s=>{this.onCreepDiedOrEscaped(s)}),e.events.on(ot.Escaped,s=>{this.onCreepDiedOrEscaped(s)})}onCreepDiedOrEscaped(e){this.creeps.splice(this.creeps.indexOf(e),1),e.destroy()}update(e){this.creeps.forEach(s=>{s.dead?(this.creeps.splice(this.creeps.indexOf(s),1),s=null):s.update(e)})}getCellByRowAndCol(e,s){return this.cells.filter(n=>n.row==e&&n.column==s)[0]}onGridCellClicked(e,s){}}class Ud extends Mt{constructor(e,s){super();p(this,"creeps",[]);p(this,"rounds");p(this,"paths");p(this,"ticks",0);p(this,"started",!1);p(this,"internalCreepId",0);p(this,"pathsIndex");p(this,"finished",!1);u.WaveManager=this,this.rounds=e,this.paths=s,this.pathsIndex=0}start(e){this.started=!0,this.ticks=0,this.creeps=[],this.finished=!1,this.pathsIndex+1==this.paths.length?this.pathsIndex=0:this.pathsIndex++;let s=0;this.rounds[e].waves.forEach(n=>{s+=n.firstCreepSpawnTick,n.creeps.forEach(r=>{const a=new Md(r,this.paths[this.pathsIndex],this.internalCreepId);this.internalCreepId++;const o={creep:a,tickToSpawnAt:s,spawned:!1};s+=n.spawnIntervalTicks,this.creeps.push(o)})}),console.log(this.creeps)}end(){this.started=!1}update(e){this.started!=!1&&(this.ticks+=e*u.GameScene.gameSpeedMultiplier,this.creeps.forEach(s=>{!s.spawned&&s.tickToSpawnAt<=this.ticks?(s.spawned=!0,this.events.emit(re.CreepSpawned,s.creep),!this.finished&&this.creeps.every(n=>n.spawned)&&(this.finished=!0,this.events.emit(re.Finished))):s.spawned&&s.creep.update(e)}))}}class Ht extends At{constructor(e,s,n,r,a,o,h,l){if(e>3||s>2||e<0||s<0)throw"Index/row out of bounds for TowerButton.";super(!0);p(this,"frameSprite");p(this,"background");p(this,"towerName");p(this,"iconSprite");p(this,"i",0);this.towerName=h,this.container.x=e*n+5,this.container.y=s*r+5,this.background=new $({texture:o}),this.iconSprite=new $({texture:l}),this.background.width=n,this.background.height=r,this.iconSprite.x=n/2,this.iconSprite.y=r/2,this.iconSprite.width=n/2,this.iconSprite.height=r/2,this.iconSprite.anchor.set(.5,.5),this.container.addChild(this.background),this.container.addChild(this.iconSprite),this.frameSprite=new _t({texture:C.Frame02Texture,leftWidth:100,topHeight:100,rightWidth:100,bottomHeight:100,roundPixels:!0,height:r,width:n}),this.container.addChild(this.frameSprite),a.addChild(this.container),u.GameScene.events.on(_e.TowerPlacedEvent,c=>{this.resetTint()}),this.container.onpointermove=c=>{u.Grid.gridInteractionEnabled!=!1&&(u.TowerManager.isPlacingTower||this.ShowTooltip())},this.container.onpointerleave=c=>{u.GameScene.tooltip.Hide()}}ShowTooltip(){let e;C.Towers.forEach(s=>{s.name==this.towerName&&(e=s)}),u.GameScene.tooltip.SetContentTower(this.towerName,e.stats.damage,e.stats.cost,e.stats.gemSlotsAmount),u.GameScene.tooltip.Show(u.MouseX,u.MouseY)}onClick(e){u.Grid.gridInteractionEnabled!=!1&&(u.TowerManager.isPlacingTower&&u.TowerManager.selectedTower.name!=this.towerName&&(u.GameScene.sidebar.towerTab.resetTint(),u.TowerManager.ResetChooseTower()),u.GameScene.towerPanel.Hide(),u.GameScene.tooltip.Hide(),this.frameSprite.tint==65280?(this.frameSprite.tint=16777215,this.ShowTooltip()):this.frameSprite.tint=65280,u.TowerManager.ToggleChoosingTowerLocation(this.towerName))}resetTint(){this.frameSprite.tint=16777215}}class Od extends At{constructor(e){super(!1);p(this,"bounds");p(this,"towerTabSprite");p(this,"towerButtons",[]);this.bounds=e,this.container.x=this.bounds.x,this.container.y=this.bounds.y,this.towerTabSprite=new _t({texture:C.FrameTowerTab,leftWidth:500,topHeight:500,rightWidth:500,bottomHeight:500,roundPixels:!0}),this.towerTabSprite.width=this.bounds.width,this.towerTabSprite.height=this.bounds.height,this.container.addChild(this.towerTabSprite),this.towerButtons.push(new Ht(0,0,70,70,this.container,C.RedBackground,C.Towers[0].name,C.Towers[0].texture)),this.towerButtons.push(new Ht(1,0,70,70,this.container,C.RedBackground,C.Towers[1].name,C.Towers[1].texture)),this.towerButtons.push(new Ht(2,0,70,70,this.container,C.BlueBackground,C.Towers[2].name,C.Towers[2].texture)),this.towerButtons.push(new Ht(3,0,70,70,this.container,C.BlueBackground,C.Towers[3].name,C.Towers[3].texture)),this.towerButtons.push(new Ht(0,1,70,70,this.container,C.GreenBackground,C.Towers[4].name,C.Towers[4].texture)),this.towerButtons.push(new Ht(1,1,70,70,this.container,C.GreenBackground,C.Towers[5].name,C.Towers[5].texture)),this.towerButtons.push(new Ht(2,1,70,70,this.container,C.YellowBackground,C.Towers[6].name,C.Towers[6].texture)),this.towerButtons.push(new Ht(3,1,70,70,this.container,C.YellowBackground,C.Towers[7].name,C.Towers[7].texture))}resetTint(){this.towerButtons.forEach(e=>e.resetTint())}}const se=class se{static init(){se.SidebarRect=new E(u.app.canvas.width-360,0,360,u.app.canvas.height),se.ChangeRoundButtonRect=new E(50,u.app.canvas.height-100,310,100)}};p(se,"SidebarRect"),p(se,"ChangeRoundButtonRect"),p(se,"MaximumPlayerNameLength",20);let Yt=se;class Ze extends At{constructor(e,s,n,r){super(!0);p(this,"iconSprite");p(this,"background");p(this,"frame");p(this,"i",0);p(this,"gem",null);let a;this.i=e,this.container.x=10,this.container.y=e*(u.GridCellSize+6)+300,this.background=new $({texture:C.Frame01Texture}),n==null&&!r?a=C.PlusIconTexture:r=="SELL"?a=C.GoldTexture:r=="UPGRADE"?a=C.PlusIconTexture:(a=n.texture,this.gem=n),this.iconSprite=new $({texture:a,zIndex:10}),this.background.width=u.GridCellSize,this.background.height=u.GridCellSize,n==null&&!r?(this.iconSprite.x=u.GridCellSize/2,this.iconSprite.y=u.GridCellSize/2,this.iconSprite.width=u.GridCellSize/2,this.iconSprite.height=u.GridCellSize/2,this.iconSprite.anchor.set(.5,.5)):r=="SELL"?(this.iconSprite.x=4,this.iconSprite.y=4,this.iconSprite.width=u.GridCellSize-8,this.iconSprite.height=u.GridCellSize-8):r=="UPGRADE"?(this.iconSprite.x=u.GridCellSize/2,this.iconSprite.y=u.GridCellSize/2,this.iconSprite.width=u.GridCellSize/2,this.iconSprite.height=u.GridCellSize/2,this.iconSprite.tint=3012919,this.iconSprite.anchor.set(.5,.5)):(this.iconSprite.x=4,this.iconSprite.y=4,this.iconSprite.width=u.GridCellSize-8,this.iconSprite.height=u.GridCellSize-8),this.frame=new $({texture:C.Frame05Texture,width:64,height:64}),this.container.addChild(this.background),this.container.addChild(this.iconSprite),this.container.addChild(this.frame);let o=n?n.level:"",h=new O({text:o,zIndex:11,style:{fill:"white",stroke:{color:0,width:5}}});this.container.addChild(h),s.addChild(this.container)}setTint(e){this.frame.tint=e}resetTint(){this.frame.tint=16777215}}class Nd extends At{constructor(e){super(!1);p(this,"bounds");p(this,"towerPanel");p(this,"closeBtn");p(this,"vGems",[]);p(this,"showingTower",null);p(this,"isShown",!1);p(this,"titleText");p(this,"damageText");p(this,"totalDamage");p(this,"attackSpeedText");p(this,"fireResDamage");p(this,"iceResDamage");p(this,"frostFireResDamage");p(this,"divineResDamage");p(this,"physicalResDamage");p(this,"sellButton");this.bounds=e,this.towerPanel=new _t({texture:C.Frame03Texture,leftWidth:100,topHeight:100,rightWidth:100,bottomHeight:100}),this.towerPanel.width=this.bounds.width,this.towerPanel.height=this.bounds.height-this.bounds.height/3.5,this.closeBtn=new ut(new E(-20,-20,60,60),"",ht.Button01,!0),this.closeBtn.container.removeFromParent(),this.closeBtn.CustomButtonLogic=()=>{this.closeBtn.buttonIcon=new $({texture:C.XIconTexture,x:this.closeBtn.container.width/2,y:this.closeBtn.container.height/2,scale:.2}),this.closeBtn.buttonIcon.anchor.set(.5,.5),this.closeBtn.container.addChild(this.closeBtn.buttonIcon)},this.closeBtn.onClick=()=>{this.Hide()},this.Hide(),this.closeBtn.CustomButtonLogic(),this.container.y=u.app.canvas.height/2-u.app.canvas.height/2.7,this.container.addChild(this.towerPanel),this.container.addChild(this.closeBtn.container),u.GameMaster.currentScene.stage.addChild(this.container),this.titleText=new O({x:this.bounds.width/3,y:50,zIndex:5,style:new W({fill:16777215,fontSize:25,stroke:{color:0,width:2}})}),this.titleText.anchor.set(.5,0),this.container.addChild(this.titleText),this.damageText=new O({x:10,y:100,zIndex:5,style:new W({fill:16753920,fontSize:18,stroke:{color:0,width:2}})}),this.container.addChild(this.damageText),this.attackSpeedText=new O({x:100,y:100,zIndex:5,style:new W({fill:16777215,fontSize:18,stroke:{color:0,width:2}})}),this.container.addChild(this.attackSpeedText),this.totalDamage=new O({x:10,y:130,zIndex:5,style:new W({fill:16711680,fontSize:18,stroke:{color:0,width:2}})}),this.container.addChild(this.totalDamage),this.fireResDamage=new O({x:10,y:170,zIndex:5,style:new W({fill:16536403,fontSize:18,stroke:{color:0,width:2}})}),this.container.addChild(this.fireResDamage),this.iceResDamage=new O({x:10,y:190,zIndex:5,style:new W({fill:3335420,fontSize:18,stroke:{color:0,width:2}})}),this.container.addChild(this.iceResDamage),this.frostFireResDamage=new O({x:10,y:210,zIndex:5,style:new W({fill:14111740,fontSize:18,stroke:{color:0,width:2}})}),this.container.addChild(this.frostFireResDamage),this.divineResDamage=new O({x:10,y:230,zIndex:5,style:new W({fill:16576083,fontSize:18,stroke:{color:0,width:2}})}),this.container.addChild(this.divineResDamage),this.physicalResDamage=new O({x:10,y:250,zIndex:5,style:new W({fill:16777215,fontSize:18,stroke:{color:0,width:2}})}),this.container.addChild(this.physicalResDamage),this.sellButton=new ut(new E(5,this.towerPanel.height-70,this.towerPanel.width-115,60),"Sell",ht.Button02,!0),this.sellButton.container.removeFromParent(),this.container.addChild(this.sellButton.container)}MakeSlots(e){this.vGems.forEach(n=>{n.destroy()}),this.vGems=[];let s=e.definition.stats.gemSlotsAmount;for(let n=0;n{r&&(u.GameScene.tooltip.SetContentGem(r),u.GameScene.tooltip.Show(u.MouseX,u.MouseY))},a.container.onpointerleave=()=>{u.GameScene.tooltip.Hide()},a.onClick=()=>{u.GameScene.tooltip.Hide(),console.warn("EMITTING TOWER PANEL SELECT GEM",r,a.i,n,e),u.GameScene.events.emit($s.TowerPanelSelectGem,r,a.i,e),!r&&u.GameScene.sidebar.gemTab.isSelectingGem?a.setTint(65535):a.resetTint()}}}Show(e){this.isShown=!0,Nt(e),this.SetContent(e),this.MakeSlots(e),this.showingTower=e,u.GameScene.sidebar.gemTab.selectingGemTowerObject=e,e.container.parent.x<1270?this.ShowRight():this.ShowLeft(),e.parent.showRangePreview(!1,e.computedRange)}SetContent(e){this.titleText.text=e.definition.name,this.damageText.text="Deals "+e.computedDamageToDeal+" damage",this.totalDamage.text="Damage dealt: "+e.damageDealt+" damage",this.attackSpeedText.x=this.damageText.width+10,this.attackSpeedText.text=` every ${Math.floor(e.computedCooldown/1e3*100)/100}s`,this.fireResDamage.text=`+${e.totalGemResistanceModifications.fire*100}% Fire damage`,this.iceResDamage.text=`+${e.totalGemResistanceModifications.ice*100}% Ice damage`,this.frostFireResDamage.text=`+${e.totalGemResistanceModifications.frostfire*100}% FrostFire damage`,this.divineResDamage.text=`+${e.totalGemResistanceModifications.divine*100}% Divine damage`,this.physicalResDamage.text=`+${e.totalGemResistanceModifications.physical*100}% Physical damage`,this.sellButton.setCaption("Sell for "+e.definition.stats.cost+" gold"),this.sellButton.onClick=()=>{e.Sell(),this.Hide()}}ShowLeft(){this.towerPanel.x=-100,this.container.x=0,this.container.alpha=1,this.closeBtn.container.x=this.bounds.width-150}ShowRight(){this.towerPanel.x=-10,this.container.x=Yt.SidebarRect.x-210,this.closeBtn.container.x=-20,this.container.alpha=1}Hide(){this.isShown=!1,this.container.alpha=0,this.container.x=-1e3,u.Grid.rangePreview.clear()}}class Wd extends At{constructor(e){super(!1);p(this,"bounds");p(this,"gemTabSprite");p(this,"vGems",[]);p(this,"isSelectingGem",!1);p(this,"selectingGemSlotIndex",-1);p(this,"selectingGemTowerObject",null);p(this,"isDragAndDroppingGem",!1);p(this,"dragAndDroppingGem",null);this.bounds=e,this.container.x=this.bounds.x,this.container.y=this.bounds.y,this.gemTabSprite=new _t({texture:C.FrameTowerTab,leftWidth:1e3,topHeight:1e3,rightWidth:1e3,bottomHeight:1e3}),this.gemTabSprite.x=0,this.gemTabSprite.y=0,this.gemTabSprite.width=this.bounds.width,this.gemTabSprite.height=this.bounds.height,this.container.addChild(this.gemTabSprite),u.app.canvas.addEventListener("pointermove",()=>{this.pointerMoveEvent()}),u.GameScene.events.on(Hs.GemGivenEvent,()=>{this.RebuildInventoryVisual()})}TowerPanelSelectingGem(e,s,n){console.log("TOWER PANEL SELECTING GEM "+s),s<0&&console.error("TOWER PANEL SELECTING GEM INDEX IS LESS THAN 0, ",s),this.isSelectingGem?e==null&&(this.isSelectingGem=!1,this.selectingGemSlotIndex=-1,this.selectingGemTowerObject=null):(this.isSelectingGem=!0,e==null?(u.NotificationManager.Notify("Click on any Gem in your inventory to slot it into this Gem slot.","info"),this.selectingGemSlotIndex=s,this.selectingGemTowerObject=n):(n.UnslotGem(s),this.RebuildInventoryVisual(),u.GameScene.towerPanel.Hide(),u.GameScene.towerPanel.Show(n),this.isSelectingGem=!1,this.selectingGemSlotIndex=-1,this.selectingGemTowerObject=null))}pointerMoveEvent(){!this.isDragAndDroppingGem||!this.dragAndDroppingGem||(this.dragAndDroppingGem.container.x=u.MouseX-32,this.dragAndDroppingGem.container.y=u.MouseY-32)}isOverlappingGemsmith(e,s,n){let r=e.copyContainerToBB(),a=s.copyContainerToBB(),o=n.x+a.x+u.GameScene.sidebar.container.x,h=n.y+a.y+u.GameScene.sidebar.container.y,l=new E(o,h,a.width,a.height);if(r.getBounds().intersects(l)&&s&&s.gem==null)return!0}RebuildInventoryVisual(){this.vGems.forEach(e=>e.destroy()),this.vGems=[],u.GameScene.MissionStats.getInventory().forEach((e,s)=>{let n=new Ze(0,this.container,e),r=10,a=s%4*70+10,o=s;for(;!(o<=3);)r+=66,o-=4;n.container.x=a,n.container.y=r,n.container.onpointermove=()=>{e==null||this.isDragAndDroppingGem||(u.GameScene.tooltip.SetContentGem(e),u.GameScene.tooltip.Show(u.MouseX,u.MouseY))},n.container.onpointerleave=()=>{u.GameScene.tooltip.Hide()},n.container.onpointerdown=()=>{if(u.GameScene.tooltip.Hide(),this.isSelectingGem){this.isSelectingGem=!1;let h=u.GameScene.MissionStats.takeGem(e);this.selectingGemTowerObject.SlotGem(h,this.selectingGemSlotIndex),this.RebuildInventoryVisual()}else this.isDragAndDroppingGem=!0,this.dragAndDroppingGem=n,n.container.removeFromParent(),u.GameScene.stage.addChild(n.container),this.pointerMoveEvent()},n.container.onpointerup=()=>{if(this.isSelectingGem)return;let h=null;if(this.isOverlappingGemsmith(this.dragAndDroppingGem,u.GameScene.sidebar.gemsmith.sellVGem,u.GameScene.sidebar.gemsmith.container)){let d=this.dragAndDroppingGem.gem.definition.initialGemValue+this.dragAndDroppingGem.gem.currentGemImprovement().gemValueUp;u.GameScene.MissionStats.earnGold(Math.ceil(d*.8)),u.NotificationManager.Notify(`Sold Lv. ${this.dragAndDroppingGem.gem.level} ${this.dragAndDroppingGem.gem.definition.name} for ${Math.ceil(d*.8)} gold.`,"info"),u.GameScene.MissionStats.takeGem(this.dragAndDroppingGem.gem),this.isDragAndDroppingGem=!1,this.dragAndDroppingGem=null,this.RebuildInventoryVisual();return}if(this.isOverlappingGemsmith(this.dragAndDroppingGem,u.GameScene.sidebar.gemsmith.upgradeVGem,u.GameScene.sidebar.gemsmith.container)){if(this.dragAndDroppingGem.gem.isMaxLevel())u.NotificationManager.Notify("Gem is max level.","warn");else{let d=this.dragAndDroppingGem.gem.definition.genericImprovements[this.dragAndDroppingGem.gem.level].gemValueUp;u.GameScene.MissionStats.hasEnoughGold(d)?(u.GameScene.MissionStats.spendGold(d),this.dragAndDroppingGem.gem.levelUp(1),u.NotificationManager.Notify(`Spent ${d} gold to upgrade ${this.dragAndDroppingGem.gem.definition.name} Lv. ${this.dragAndDroppingGem.gem.level-1} -> Lv. ${this.dragAndDroppingGem.gem.level}!`,"warn")):u.NotificationManager.Notify("You don't have enough, you need "+d+" gold to upgrade this gem.","warn")}this.isDragAndDroppingGem=!1,this.dragAndDroppingGem=null,this.RebuildInventoryVisual();return}if(u.GameScene.towerPanel.vGems.forEach(d=>{if(h||!this.dragAndDroppingGem)return;let f=this.dragAndDroppingGem.copyContainerToBB(),g=d.copyContainerToBB(),m=u.GameScene.towerPanel.container.x+g.x,y=u.GameScene.towerPanel.container.y+g.y,x=new E(m,y,g.width,g.height);f.getBounds().intersects(x)&&d&&d.gem==null&&(h=d)}),h){let d=u.GameScene.MissionStats.takeGem(e);u.GameScene.towerPanel.showingTower.SlotGem(d,h.i)}this.isDragAndDroppingGem=!1,this.dragAndDroppingGem=null,this.RebuildInventoryVisual()},this.vGems.push(n)})}}class Hd extends At{constructor(e){super(!1);p(this,"bounds");p(this,"sellVGem");p(this,"upgradeVGem");this.bounds=e,this.container.x=this.bounds.x,this.container.y=this.bounds.y;let s=new $({x:0,y:0,width:this.bounds.width,height:this.bounds.height,texture:C.BannerGemsmith});this.container.addChild(s);let n=new O({x:40,y:this.bounds.height/6.5,text:"Sell gem",style:new W({fill:16767744,fontSize:18,stroke:{color:0,width:2}})});this.container.addChild(n);let r=new O({x:155,y:this.bounds.height/6.5,text:"Upgrade gem",style:new W({fill:3012919,fontSize:18,stroke:{color:0,width:2}})});this.container.addChild(r),this.sellVGem=new Ze(0,this.container,null,"SELL"),this.sellVGem.container.x=45,this.sellVGem.container.y=this.bounds.height/4,this.upgradeVGem=new Ze(0,this.container,null,"UPGRADE"),this.upgradeVGem.container.x=180,this.upgradeVGem.container.y=this.bounds.height/4}}class $d extends At{constructor(e){super(!1);p(this,"towerTab");p(this,"gemTab");p(this,"gemsmith");p(this,"bounds");p(this,"sidebarSprite");this.bounds=e,this.container.x=this.bounds.x,this.container.y=this.bounds.y,this.sidebarSprite=new _t({texture:C.Frame01Texture,leftWidth:100,topHeight:100,rightWidth:100,bottomHeight:100}),this.sidebarSprite.x=40,this.sidebarSprite.y=-40,this.sidebarSprite.width=this.bounds.width+40,this.sidebarSprite.height=this.bounds.height+80,this.container.addChild(this.sidebarSprite);const s=new E(60,20,this.bounds.width-65,150);this.towerTab=new Od(s),this.container.addChild(this.towerTab.container);const n=new E(60,180,this.bounds.width-65,this.bounds.height-280-255);this.gemTab=new Wd(n),this.container.addChild(this.gemTab.container);const r=new E(60,185+n.height,this.bounds.width-65,this.bounds.height-840);this.gemsmith=new Hd(r),this.container.addChild(this.gemsmith.container)}}class Vd extends Mt{constructor(e,s){super();p(this,"hp",100);p(this,"gold",0);p(this,"goldEarned",0);p(this,"goldSpent",0);p(this,"wavesSurvived",0);p(this,"damageDealt",0);p(this,"creepsKilled",0);p(this,"goldText");p(this,"healthText");p(this,"waveText");p(this,"inventory",[]);this.hp=e,this.gold=s,this.container.x=0,this.container.y=20,u.GameMaster.currentScene.stage.addChild(this.container),this.healthText=new O({text:`${this.hp}`,style:new W({fill:"red",fontSize:36,fontWeight:"bold",dropShadow:!0})}),this.goldText=new O({text:`${this.gold}`,style:new W({fill:"gold",fontSize:36,fontWeight:"bold",dropShadow:!0})}),this.waveText=new O({text:`0/${u.GameScene.mission.rounds.length}`,style:new W({fill:"dodgerblue",fontSize:36,fontWeight:"bold",dropShadow:!0})});const n=new $(C.HealthTexture),r=new $(C.GoldTexture),a=new $(C.WaveTexture);this.healthText.x=200,this.healthText.y=-15,n.x=160,n.width=36,n.height=32,n.y=-10,this.goldText.x=200,this.goldText.y=20,r.x=150,r.width=56,r.height=56,r.y=15,this.waveText.x=200,this.waveText.y=55,a.x=155,a.width=46,a.height=32,a.y=65,this.container.addChild(this.healthText),this.container.addChild(this.goldText),this.container.addChild(this.waveText),this.container.addChild(n),this.container.addChild(r),this.container.addChild(a),u.GameScene.events.on(re.NewWave,o=>{this.waveText.text=`${o}/${u.GameScene.mission.rounds.length}`})}getHP(){return this.hp}hasEnoughGold(e){return e<=this.gold}setHP(e){this.hp=e,this.healthText.text=this.hp}takeDamage(e){this.hp-=e,this.healthText.text=this.hp}setGold(e){this.gold=e,this.goldText.text=this.gold}earnGold(e){this.gold+=e,this.goldText.text=this.gold}spendGold(e){this.gold-=e,this.goldText.text=this.gold}giveGem(e,s){if(this.inventory.length>=32)return u.NotificationManager.Notify("Can't hold more than 32 Gems. Extra Gem was thrown away.","danger");this.inventory.push(e),s||u.NotificationManager.Notify(`Lv. ${e.level} ${e.definition.name} added to your inventory.`,"gemaward"),u.GameScene.events.emit(Hs.GemGivenEvent,e)}takeGem(e){return this.inventory.splice(this.inventory.indexOf(e),1)[0]}getInventory(){return this.inventory}checkIfPlayerHasAnyGems(){return this.inventory.length>0}getStats(){return{hp:this.hp,gold:this.gold,wavesSurvived:this.wavesSurvived,goldEarned:this.goldEarned,goldSpent:this.goldSpent,score:this.calculateScore()}}calculateScore(){const e=[];for(const s of this.inventory)e.includes(s.definition.name)||e.push(s.definition.name);return this.damageDealt*2+this.hp*10+(this.goldEarned-this.goldSpent)*3+this.wavesSurvived*100+e.length*100}update(){}}class Yd extends At{constructor(e){super(!1);p(this,"bounds");p(this,"tooltipSprite");p(this,"titleText");p(this,"costText");p(this,"damageText");p(this,"gemAmount");p(this,"gemAmountSprite");p(this,"title");p(this,"costSprite");p(this,"damageSprite");p(this,"gemDescriptionText");this.bounds=e,this.container.x=-500,this.container.y=-500,this.container.zIndex=150,this.tooltipSprite=new _t({texture:C.Frame04Texture,leftWidth:200,topHeight:200,rightWidth:200,bottomHeight:200}),this.tooltipSprite.width=this.bounds.width,this.tooltipSprite.height=this.bounds.height,this.titleText=new O({x:this.tooltipSprite.width/2,y:-20,zIndex:5,style:new W({fill:16777215,stroke:{color:0,width:2}})}),this.titleText.anchor.set(.5,0),this.title=new $({x:this.tooltipSprite.width/2,y:-20,width:250,height:40,texture:C.TitleTexture}),this.title.anchor.set(.5,0),this.costSprite=new $({texture:C.GoldTexture,x:10,y:20,width:56,height:50}),this.costText=new O({x:54,y:26,zIndex:5,text:"Something went wrong if you see this.",style:{fill:"gold",fontWeight:"bold",stroke:{color:0,width:5}}}),this.damageText=new O({x:54,y:65,zIndex:5,text:"Something went wrong if you see this.",style:{fill:"red",fontWeight:"bold",stroke:{color:0,width:5}}}),this.damageSprite=new $({texture:C.SwordsTexture,x:22,y:70,width:32,height:32}),this.gemAmountSprite=new $({texture:C.GemAmountIcons[0],x:22,y:110,width:32,height:32}),this.gemAmount=new O({x:54,y:105,zIndex:5,text:"Something went wrong if you see this.",style:{fill:"white",fontWeight:"bold",stroke:{color:0,width:5}}}),this.gemDescriptionText=new O({x:10,y:20,text:"",style:{fontSize:18,wordWrap:!0,wordWrapWidth:this.tooltipSprite.width-30,fill:"white",fontWeight:"bold",fontStyle:"italic",stroke:{color:0,width:5}}}),this.container.addChild(this.tooltipSprite),this.container.addChild(this.title),this.container.addChild(this.costSprite),this.container.addChild(this.damageSprite),this.container.addChild(this.gemAmountSprite),this.container.addChild(this.costText),this.container.addChild(this.titleText),this.container.addChild(this.damageText),this.container.addChild(this.gemAmount),this.container.addChild(this.gemDescriptionText),u.app.stage.addChildAt(this.container,0)}SetContentTower(e,s,n,r){this.costSprite.alpha=1,this.damageSprite.alpha=1,this.gemAmountSprite.alpha=1,this.costText.alpha=1,this.damageText.alpha=1,this.gemAmount.alpha=1,this.gemDescriptionText.alpha=0,this.titleText.text=e,this.gemAmount.text=`Has ${r} Gem slots.`,this.gemAmountSprite.texture=C.GemAmountIcons[r],this.costText.text=`Costs ${n} gold.`,this.damageText.text=`Deals ${s} base damage.`}SetContentGem(e){this.costSprite.alpha=0,this.damageSprite.alpha=0,this.gemAmountSprite.alpha=0,this.costText.alpha=0,this.damageText.alpha=0,this.gemAmount.alpha=0,this.gemDescriptionText.alpha=1,this.titleText.text=`Lv. ${e.level} `+e.definition.name;let s;e.isMaxLevel()?s="Max level.":s=`Costs ${e.definition.genericImprovements[e.level].gemValueUp} gold to level up.`,this.gemDescriptionText.text=`${s} Valued at ${e.definition.initialGemValue+e.currentGemImprovement().gemValueUp} gold. `+e.definition.description}Show(e,s){this.container.alpha=1,e+this.container.width>u.app.canvas.width?this.container.x=e-this.container.width:this.container.x=e,this.container.y=s}Hide(){this.container.alpha=0,this.container.x=-500,this.container.y=-500}}const ft=class ft{static init(){window.addEventListener("keydown",ft.handleKeyDown)}static onKeyPressed(t){return ft.listeners=[...ft.listeners,t],()=>ft.offKey(t)}static offKey(t){const e=ft.listeners.indexOf(t);e>=0&&(ft.listeners=[...ft.listeners.slice(0,e),...ft.listeners.slice(e+1)])}static handleKeyDown(t){if(ft.listeners.length>0)for(let e=ft.listeners.length-1;e>=0&&(ft.listeners[e](t),!t.defaultPrevented);e--);}};p(ft,"listeners",[]);let Se=ft;class ki extends At{constructor(e,s,n){super();p(this,"overlay");p(this,"buttonHeight",65);p(this,"buttonCaptions");p(this,"buttons",[]);p(this,"dialogContent");p(this,"dialogContainer");p(this,"background");p(this,"generated",!1);p(this,"escapeKeyButton");p(this,"enterKeyButton");p(this,"keyboardManagerUnsubscribe");p(this,"onClosed");if(this.buttonCaptions=e,n&&!e.includes(n))throw new Error(`Escape key button "${n}" not found in buttons: ${e}`);if(this.escapeKeyButton=n,s&&!e.includes(s))throw new Error(`Enter key button "${s}" not found in buttons: ${e}`);this.enterKeyButton=s,this.keyboardManagerUnsubscribe=Se.onKeyPressed(this.onKeyPress.bind(this))}show(){return this.generate(),`${Math.round(this.dialogContainer.x)}${Math.round(this.dialogContainer.y)}${Math.round(this.dialogContainer.width)}${Math.round(this.dialogContainer.height)}`,`${Math.round(this.dialogContent.x)}${Math.round(this.dialogContent.y)}${Math.round(this.dialogContent.width)}${Math.round(this.dialogContent.height)}`,new Promise((e,s)=>{u.app.stage.addChild(this.container),this.onClosed=n=>{this.destroy(),e(n)}})}createDialogBackground(){return new _t({texture:C.Frame04Texture,leftWidth:60,topHeight:60,rightWidth:60,bottomHeight:60})}getWidth(){}getHeight(){}generate(){if(this.generated)return;this.generated=!0,this.overlay=new Ct,this.overlay.rect(0,0,u.app.canvas.width,u.app.canvas.height),this.overlay.fill({color:0,alpha:.5}),this.overlay.interactive=!0,this.container.addChild(this.overlay);const e=this.buttonCaptions.map(l=>({caption:l,width:l.length*14+60,height:this.buttonHeight,click:()=>this.close(l)}));this.background=this.createDialogBackground(),this.dialogContent=this.createContent();let s=0;for(const l of e)s>0&&(s+=10),s+=l.width;const n=this.buttonCaptions.length>0?this.buttonHeight+10:0;let r=this.getWidth()||Math.max(s,this.dialogContent.width)+this.background.leftWidth+this.background.rightWidth,a=this.getHeight()||this.dialogContent.height+n+this.background.topHeight+this.background.bottomHeight;const o=new E(u.app.canvas.width/2-r/2,u.app.canvas.height/2-a/2,r,a);this.dialogContainer=new tt,this.dialogContainer.x=o.x,this.dialogContainer.y=o.y,this.background.width=r,this.background.height=a,this.dialogContainer.addChild(this.background),this.dialogContent.width0&&(r=s[0]),!n&&s.length>0&&(n=s[s.length-1]);super(s,n,r);p(this,"caption");this.caption=e}createContent(){return new O({text:this.caption,style:new W({fill:16777215,fontSize:24})})}static show(e,s,n=0){return new Xs(e,s).show()}}const Lt=class Lt{constructor(t){p(this,"missionName");p(this,"scores");this.missionName=t,this.scores=this.loadScores(),this.scores.sort((e,s)=>s.score-e.score||e.timestamp-s.timestamp)}loadScores(){const t=localStorage.getItem(Lt.STORAGE_KEY_PREFIX+this.missionName);return Lt.parseStoredScores(t)}saveScores(){localStorage.setItem(Lt.STORAGE_KEY_PREFIX+this.missionName,JSON.stringify(this.scores))}addScore(t){this.scores.push(t),this.scores.sort((e,s)=>s.score-e.score),this.scores.length>Lt.MAX_SCORES&&(this.scores.length=Lt.MAX_SCORES),this.saveScores()}getScores(){return this.scores}static parseStoredScores(t){if(!t)return[];try{const e=JSON.parse(t);if(Array.isArray(e)&&e.every(s=>typeof s.playerName=="string"&&typeof s.score=="number"&&typeof s.timestamp=="number"))return e.map(s=>({playerName:s.playerName,score:s.score,timestamp:s.timestamp}))}catch(e){console.error("Failed to parse stored scores:",e)}return[]}};p(Lt,"STORAGE_KEY_PREFIX","highscore_"),p(Lt,"MAX_SCORES",10);let bi=Lt;const Le={Confirm:"OK",Skip:"Skip"};class jd extends ki{constructor(e,s,n){super([Le.Confirm,Le.Skip],Le.Confirm,Le.Skip);p(this,"dialogCaption");p(this,"playerNameTextInput");p(this,"lost");p(this,"highScore");p(this,"missionStats");this.lost=n,this.highScore=new bi(e),this.missionStats=s}generate(){super.generate(),this.dialogCaption=new O({text:this.lost?"You lost!":"You won!",style:new W({fill:16777215,fontSize:36,stroke:{color:0,width:2},dropShadow:{color:0,blur:8,distance:0}})}),this.dialogCaption.anchor.set(.5,.5),this.dialogCaption.x=this.dialogContainer.width/2,this.dialogCaption.y=50,this.dialogContainer.addChild(this.dialogCaption)}createDialogBackground(){return new _t({texture:C.EndScreenDialog,leftWidth:50,topHeight:100,rightWidth:50,bottomHeight:50})}createContent(){const e=new tt,s=35,n=this.createText("Mission details:","#fee",!0);e.addChild(n);const r=this.missionStats.getStats(),a=this.getWidth()-this.background.leftWidth-this.background.rightWidth-20,o=[this.createText("HP:"),this.createText("Gold:"),this.createText("Waves Survived:"),this.createText("Gold Earned:"),this.createText("Gold Spent:"),this.createText("----"),this.createText("Score:")],h=[this.createText(r.hp.toString(),"yellow"),this.createText(r.gold.toString(),"yellow"),this.createText(r.wavesSurvived.toString(),"yellow"),this.createText(r.goldEarned.toString(),"yellow"),this.createText(r.goldSpent.toString(),"yellow"),this.createText("----","yellow"),this.createText(r.score.toString(),"yellow")],l=300;for(let f=0;fthis.createText((f+1).toString()))],o=[this.createText("Player","#fee",!0),...r.map(d=>this.createText(d.playerName))],h=[this.createText("Score","#fee",!0),...r.map(d=>this.createText(d.score.toString()))],l=a.reduce((d,f)=>Math.max(d,f.width),0)+20,c=l+o.reduce((d,f)=>Math.max(d,f.width),0)+20;for(let d=0;d(i[i.Purchase=0]="Purchase",i[i.Combat=1]="Combat",i[i.Misc=2]="Misc",i))(Fa||{});class ve extends Gi{constructor(e){super();p(this,"isGameOver",!1);p(this,"mission");p(this,"missionIndex");p(this,"MissionStats");p(this,"roundMode");p(this,"ticker");p(this,"changeRoundButton");p(this,"sidebar");p(this,"tooltip");p(this,"towerPanel");p(this,"isPaused",!1);p(this,"gameSpeedMultiplier",1);p(this,"pauseButton");p(this,"visualGems",[]);p(this,"currentRound",0);p(this,"isWaveManagerFinished",!1);p(this,"playerWon",!1);p(this,"destroyTicker",!1);p(this,"offerGemsSprite");p(this,"dimGraphics",new Ct({x:0,y:0,zIndex:120}));p(this,"windowTitle");u.GameScene=this,this.windowTitle=document.title,C.Missions.forEach((s,n)=>{s.name==e&&(this.mission=s,this.missionIndex=n)})}init(){u.latestGemId=0,new zd(this.mission.gameMap,this.missionIndex),new Sd,new Ud(this.mission.rounds,this.mission.gameMap.paths),u.Grid.onGridCellClicked=(e,s)=>{u.TowerManager.isPlacingTower&&u.TowerManager.PlayerClickOnGrid(e,s)},u.WaveManager.events.on(re.CreepSpawned,e=>{u.Grid.addCreep(e),e.events.on(ot.Escaped,()=>{this.onCreepEscaped(e)})}),u.WaveManager.events.on(re.Finished,()=>{this.isWaveManagerFinished=!0}),this.events.on(ot.Died,(e,s)=>{this.MissionStats.earnGold(e)}),this.towerPanel=new Nd(Yt.SidebarRect),this.sidebar=new $d(Yt.SidebarRect),this.changeRoundButton=new ut(Yt.ChangeRoundButtonRect,"",ht.Button01,!0),this.changeRoundButton.container.removeFromParent(),this.sidebar.container.addChild(this.changeRoundButton.container),u.GameMaster.currentScene.stage.addChildAt(this.dimGraphics,0),this.tooltip=new Yd(new E(0,0,350,160)),this.changeRoundButton.CustomButtonLogic=()=>{this.changeRoundButton.buttonIcon=new $({texture:C.PlayIconTexture,x:this.changeRoundButton.container.width/2,y:this.changeRoundButton.container.height/2,scale:.2}),this.changeRoundButton.buttonIcon.anchor.set(.5,.5),this.changeRoundButton.container.addChild(this.changeRoundButton.buttonIcon)},this.changeRoundButton.CustomButtonLogic(),this.changeRoundButton.onClick=()=>{if(this.playerWon)return this.ReturnToMain();if(this.roundMode==1){this.gameSpeedMultiplier!==1?this.UpdateGameSpeedMultiplier(1):this.UpdateGameSpeedMultiplier(2);return}if(this.isGameOver)return u.NotificationManager.Notify("No more waves.","danger");this.roundMode!=2&&(this.setRoundMode(1),this.changeRoundButton.buttonIcon.texture=C.FastForwardIconTexture,this.events.emit(re.NewWave,`${this.currentRound+1}`))},this.MissionStats=new Vd(125,450),this.events.on($s.TowerPanelSelectGem,(e,s,n)=>{if(e==null&&!this.MissionStats.checkIfPlayerHasAnyGems())return u.NotificationManager.Notify("You require atleast 1 Gem in your inventory to slot it in a Gem slot.","warn");this.sidebar.gemTab.TowerPanelSelectingGem(e,s,n)}),this.pauseButton=new ut(new E(5,5,120,80),"",ht.Button01,!0),this.pauseButton.container.removeFromParent(),this.stage.addChild(this.pauseButton.container),this.pauseButton.CustomButtonLogic=()=>{this.pauseButton.buttonIcon=new $({texture:C.PauseIconTexture,x:this.pauseButton.container.width/2,y:this.pauseButton.container.height/2,scale:.2}),this.pauseButton.buttonIcon.anchor.set(.5,.5),this.pauseButton.container.addChild(this.pauseButton.buttonIcon)},this.pauseButton.CustomButtonLogic(),this.pauseButton.onClick=()=>{this.isPaused?this.UnpauseGame():(this.ShowPauseDialog(),this.PauseGame())},this.ticker=new It,this.ticker.maxFPS=60,this.ticker.minFPS=30,this.tooltip.SetContentTower(0,0,0,0),this.tooltip.Show(u.MouseX,u.MouseY),this.tooltip.Hide(),this.ticker.add(()=>{this.update&&this.update(this.ticker.elapsedMS)}),this.ticker.start()}update(e){if(this.isGameOver){this.destroyTicker&&(this.destroyTicker=!1,this.ticker.destroy());return}u.WaveManager.update(e),u.Grid.update(e),u.TowerManager.update(e),this.isWaveManagerFinished&&u.Grid.creeps.length==0&&(this.isWaveManagerFinished=!1,this.setRoundMode(0),this.changeRoundButton.buttonIcon.texture=C.PlayIconTexture,u.NotificationManager.Notify(`Round ${this.currentRound+1}/${this.mission.rounds.length} completed.`,"info"),this.currentRound+1==this.mission.rounds.length?(u.NotificationManager.Notify("Mission victory!!","reward"),this.changeRoundButton.buttonIcon.texture=C.HomeIconTexture,this.playerWon=!0):(this.OfferPlayerGems(),this.currentRound++)),this.MissionStats.getHP()<=0?(this.isGameOver=!0,this.ShowEndgameDialog(!0)):this.playerWon&&(this.isGameOver=!0,this.ShowEndgameDialog(!1))}DarkenScreen(){this.dimGraphics.rect(0,0,u.app.canvas.width,u.app.canvas.height),this.dimGraphics.fill({color:0,alpha:.5})}UndarkenScreen(){this.dimGraphics.clear()}OfferPlayerGems(){u.Grid.gridInteractionEnabled=!1,u.GameScene.sidebar.towerTab.resetTint(),u.TowerManager.ResetChooseTower(),this.setRoundMode(2);let e=this.mission.rounds[this.currentRound].offeredGems;this.DarkenScreen(),this.offerGemsSprite=new _t({width:380,height:150,texture:C.Frame01Texture,leftWidth:100,topHeight:100,rightWidth:100,bottomHeight:100,zIndex:this.dimGraphics.zIndex+1,x:u.app.canvas.width/2-190,y:u.app.canvas.height/2-75}),u.GameMaster.currentScene.stage.addChildAt(this.offerGemsSprite,0);let s=new O({x:u.app.canvas.width/4,y:u.app.canvas.height/4,zIndex:this.dimGraphics.zIndex+1,text:"Choose a Gem as your reward for beating this round!",style:{fontSize:40,fill:"orange",fontWeight:"bold",stroke:{color:0,width:5}}});u.GameMaster.currentScene.stage.addChildAt(s,0),e.forEach((n,r)=>{let a=new Ms(n,!0),o=new Ze(0,u.app.stage,a);this.visualGems.push(o),o.container.x=this.offerGemsSprite.x-15+69*(r+1),o.container.y=this.offerGemsSprite.y+40,o.container.onpointermove=()=>{u.GameScene.tooltip.SetContentGem(a),u.GameScene.tooltip.Show(u.MouseX,u.MouseY)},o.container.onpointerleave=()=>{u.GameScene.tooltip.Hide()},o.onClick=()=>{u.GameScene.tooltip.Hide(),s.destroy(),this.PlayerPickedGem(new Ms(n))}})}PlayerPickedGem(e){this.offerGemsSprite.destroy(),this.UndarkenScreen(),this.visualGems.forEach(s=>s.destroy()),u.Grid.gridInteractionEnabled=!0,this.MissionStats.giveGem(e),this.setRoundMode(0)}PauseGame(){this.isPaused=!0,this.ticker.stop(),document.title="[PAUSED] "+this.windowTitle}UnpauseGame(){this.isPaused=!1,this.ticker.start(),document.title=this.windowTitle}ShowPauseDialog(){new Kd().show()}async ShowEndgameDialog(e){await new jd(this.mission.name,this.MissionStats,e).show();const r=await new qd(this.mission.name,e,!e&&this.missionIndex+1{u.GameMaster.changeScene(new js)},C.Missions.forEach((e,s)=>{const n=new ut(new E(u.app.canvas.width/2-150,400+s*70,300,60),e.name,ht.Button01);n.onClick=r=>{u.GameMaster.changeScene(new ve(e.name))}})}}class js extends Gi{init(){this.addMainBackground();const t={caption:"New Game",rect:new E(u.app.canvas.width/2-300/2,400+0*70,300,60),texture:ht.Button01},e={caption:"How to play",rect:new E(u.app.canvas.width/2-300/2,400+1*70,300,60),texture:ht.Button01};new E(u.app.canvas.width/2-300/2,400+2*70,300,60),ht.Button01;let s=new O({x:0,y:0,text:"Latest commit: "+u.latestCommit,style:{fill:16777215,fontSize:10,fontWeight:"bold"}});this.stage.addChild(s);const n=new ut(t.rect,t.caption,t.texture,!0);n.onClick=a=>{u.GameMaster.changeScene(new ge)};let r=new ut(e.rect,e.caption,e.texture,!0);r.onClick=a=>{u.GameMaster.changeScene(new bd)}}}class Zd{constructor(){p(this,"finished",!1);p(this,"calledBack",!1);p(this,"callbackFn")}Finish(){this.finished=!0}update(t){this.finished}}class Qd extends Zd{constructor(e,s,n,r){super();p(this,"fadeType");p(this,"fadeTime");p(this,"pixiObject");p(this,"ticks",0);this.fadeType=e,this.fadeTime=s,this.pixiObject=n,this.callbackFn=r,e=="in"?this.pixiObject.alpha=0:this.pixiObject.alpha=1}update(e){if(super.update(e),this.pixiObject==null)return this.Finish();this.ticks++,this.fadeType=="in"?this.pixiObject.alpha=this.ticks/this.fadeTime:this.pixiObject.alpha-=1/this.fadeTime,this.ticks>=this.fadeTime&&this.Finish()}}class Jd{constructor(){p(this,"AnimationQueue",[])}Animate(t){this.AnimationQueue.push(t)}update(t){for(let e=this.AnimationQueue.length-1;e>=0;e--){const s=this.AnimationQueue[e];s.finished?(s.callbackFn(),this.AnimationQueue.splice(e,1)):s.update(t)}}}class tu{constructor(t,e,s,n,r){p(this,"textObj");p(this,"ticksToFadeAway");p(this,"animating",!1);p(this,"destroyed",!1);let a=16777215;e=="info"?a=2143228:e=="warn"?a=16570144:e=="danger"?a=16517642:e=="reward"?a=14047996:e=="gemaward"?a=16777215:e=="green"&&(a=65280),this.ticksToFadeAway=r,this.textObj=new O({text:t,style:new W({fill:a,fontSize:36,fontWeight:"bold",dropShadow:!0,align:"center"}),x:s,y:n,zIndex:100}),this.textObj.anchor.set(.5,.5),u.NotificationManager.container.addChild(this.textObj)}destroy(){this.textObj.destroy(),this.destroyed=!0}}class eu extends Mt{constructor(){super();p(this,"notifications",[]);p(this,"ticks",0);this.bb.x=u.app.canvas.width/2,this.bb.y=40,this.copyBBToContainer(),this.container.zIndex=200,u.app.stage.addChild(this.container)}Notify(e,s){let n=0,r=this.notifications.length*32;this.notifications.push(new tu(e,s,n,r,this.ticks+180))}update(e){this.ticks++;for(let s=this.notifications.length-1;s>=0;s--){const n=this.notifications[s];if(n.destroyed){this.notifications.splice(s,1);continue}this.ticks>=n.ticksToFadeAway&&!n.animating&&(n.animating=!0,u.AnimationManager.Animate(new Qd("out",300,n.textObj,()=>{n.destroy()})))}}}class iu{constructor(t,e){p(this,"ticksToDestroyAt");p(this,"debris");this.debris=t,this.ticksToDestroyAt=e}destroy(){this.debris.destroy()}update(t){this.debris instanceof Mt&&this.debris.update(t)}}class su extends Mt{constructor(){super(...arguments);p(this,"ticks",0);p(this,"debris",[])}update(e){this.ticks++;for(let s=this.debris.length-1;s>=0;s--){const n=this.debris[s];this.ticks>=n.ticksToDestroyAt?(n.destroy(),this.debris.splice(s,1)):n.update(e)}}CreateDebris(e,s){s||(s=120),this.debris.push(new iu(e,this.ticks+s))}}(async()=>{const i=new Zr;u.app=i,await i.init({width:1920,height:1080,resolution:1,autoDensity:!0,backgroundColor:16777215,sharedTicker:!0}),document.body.appendChild(i.canvas);function t(){const n=window.innerWidth,r=window.innerHeight,a=n/i.screen.width,o=r/i.screen.height,h=Math.min(a,o),l=Math.round(i.screen.width*h),c=Math.round(i.screen.height*h),d=(n-l)/2,f=(r-c)/2;i.canvas.style.width=`${l}px`,i.canvas.style.height=`${c}px`,i.canvas.style.marginLeft=`${d}px`,i.canvas.style.marginTop=`${f}px`,i.canvas.style.marginRight="0",i.canvas.style.marginBottom="0",i.canvas.style.display="block"}u.latestCommit=await fetch("./latest_commit").then(n=>n.text()),window.addEventListener("resize",t),t(),await C.LoadAssets(),Yt.init(),Se.init(),new _d,u.AnimationManager=new Jd,u.NotificationManager=new eu,u.DebrisManager=new su,globalThis.Engine=u,It.shared.add(n=>{u.NotificationManager.update(n.elapsedMS),u.AnimationManager.update(n.elapsedMS),u.DebrisManager.update(n.elapsedMS)}),i.canvas.addEventListener("pointermove",function(n){u.MouseX=(n.clientX-i.canvas.offsetLeft)/i.canvas.offsetWidth*1920,u.MouseY=(n.clientY-i.canvas.offsetTop)/i.canvas.offsetHeight*1080}),u.GameMaster.changeScene(new js),new URLSearchParams(location.href).entries().next().value[1]=="game"&&u.GameMaster.changeScene(new ve("The Turn")),u.latestCommit!="DEVELOPMENT"?window.onbeforeunload=()=>"You are about to leave.":u.TestSuite();let s=!1;window.addEventListener("blur",()=>{u.GameScene&&!u.GameScene.isPaused&&(u.GameScene.PauseGame(),s=!0)}),window.addEventListener("focus",()=>{u.GameScene&&s&&u.GameScene.isPaused&&(s=!1,u.GameScene.UnpauseGame())})})();export{U as $,Xr as A,it as B,tt as C,Q as D,G as E,pr as F,Ci as G,Et as H,gn as I,$ as J,Zo as K,ah as L,H as M,nt as N,E as O,lt as P,Ch as Q,fs as R,$h as S,Ot as T,yi as U,xn as V,ko as W,Ni as X,Y,mr as Z,jr as _,z as a,N as a0,Gh as a1,ra as a2,pl as a3,ml as a4,bl as a5,vl as a6,Cl as a7,xe as a8,W as a9,pc as aa,Ts as ab,da as ac,Mn as ad,ce as ae,md as af,Zn as ag,_c as ah,Ct as ai,q as aj,so as ak,Cs as al,qn as am,fa as an,It as b,gt as c,Vt as d,dt as e,An as f,Nh as g,pi as h,Bs as i,$r as j,Ar as k,Or as l,jn as m,sn as n,fl as o,gl as p,wl as q,mo as r,ta as s,Sl as t,Is as u,Lr as v,st as w,io as x,Al as y,zt as z}; +`;let pe=null;class va{constructor(){pe||(pe=URL.createObjectURL(new Blob([nd],{type:"application/javascript"}))),this.worker=new Worker(pe)}}va.revokeObjectURL=function(){pe&&(URL.revokeObjectURL(pe),pe=null)};let er=0,rs;class rd{constructor(){this._initialized=!1,this._createdWorkers=0,this._workerPool=[],this._queue=[],this._resolveHash={}}isImageBitmapSupported(){return this._isImageBitmapSupported!==void 0?this._isImageBitmapSupported:(this._isImageBitmapSupported=new Promise(t=>{const{worker:e}=new Ms;e.addEventListener("message",s=>{e.terminate(),Ms.revokeObjectURL(),t(s.data)})}),this._isImageBitmapSupported)}loadImageBitmap(t,e){var s;return this._run("loadImageBitmap",[t,(s=e==null?void 0:e.data)==null?void 0:s.alphaMode])}async _initWorkers(){this._initialized||(this._initialized=!0)}_getWorker(){rs===void 0&&(rs=navigator.hardwareConcurrency||4);let t=this._workerPool.pop();return!t&&this._createdWorkers{this._complete(e.data),this._returnWorker(e.target),this._next()})),t}_returnWorker(t){this._workerPool.push(t)}_complete(t){t.error!==void 0?this._resolveHash[t.uuid].reject(t.error):this._resolveHash[t.uuid].resolve(t.data),this._resolveHash[t.uuid]=null}async _run(t,e){await this._initWorkers();const s=new Promise((n,r)=>{this._queue.push({id:t,arguments:e,resolve:n,reject:r})});return this._next(),s}_next(){if(!this._queue.length)return;const t=this._getWorker();if(!t)return;const e=this._queue.pop(),s=e.id;this._resolveHash[er]={resolve:e.resolve,reject:e.reject},t.postMessage({data:e.arguments,uuid:er++,id:s})}}const ir=new rd,ad=[".jpeg",".jpg",".png",".webp",".avif"],od=["image/jpeg","image/png","image/webp","image/avif"];async function hd(i,t){var n;const e=await Q.get().fetch(i);if(!e.ok)throw new Error(`[loadImageBitmap] Failed to fetch ${i}: ${e.status} ${e.statusText}`);const s=await e.blob();return((n=t==null?void 0:t.data)==null?void 0:n.alphaMode)==="premultiplied-alpha"?createImageBitmap(s,{premultiplyAlpha:"none"}):createImageBitmap(s)}const Ca={name:"loadTextures",extension:{type:G.LoadParser,priority:Xt.High,name:"loadTextures"},config:{preferWorkers:!0,preferCreateImageBitmap:!0,crossOrigin:"anonymous"},test(i){return Ae(i,od)||Me(i,ad)},async load(i,t,e){var r;let s=null;globalThis.createImageBitmap&&this.config.preferCreateImageBitmap?this.config.preferWorkers&&await ir.isImageBitmapSupported()?s=await ir.loadImageBitmap(i,t):s=await hd(i,t):s=await new Promise(a=>{s=new Image,s.crossOrigin=this.config.crossOrigin,s.src=i,s.complete?a(s):s.onload=()=>{a(s)}});const n=new Ce({resource:s,alphaMode:"premultiply-alpha-on-upload",resolution:((r=t.data)==null?void 0:r.resolution)||Ws(i),...t.data});return Hs(n,e,i)},unload(i){i.destroy(!0)}},Ta=[".mp4",".m4v",".webm",".ogg",".ogv",".h264",".avi",".mov"],ld=Ta.map(i=>`video/${i.substring(1)}`);function cd(i,t,e){e===void 0&&!t.startsWith("data:")?i.crossOrigin=ud(t):e!==!1&&(i.crossOrigin=typeof e=="string"?e:"anonymous")}function dd(i){return new Promise((t,e)=>{i.addEventListener("canplaythrough",s),i.addEventListener("error",n),i.load();function s(){r(),t()}function n(a){r(),e(a)}function r(){i.removeEventListener("canplaythrough",s),i.removeEventListener("error",n)}})}function ud(i,t=globalThis.location){if(i.startsWith("data:"))return"";t=t||globalThis.location;const e=new URL(i,document.baseURI);return e.hostname!==t.hostname||e.port!==t.port||e.protocol!==t.protocol?"anonymous":""}const fd={name:"loadVideo",extension:{type:G.LoadParser,name:"loadVideo"},test(i){const t=Ae(i,ld),e=Me(i,Ta);return t||e},async load(i,t,e){var h,l;const s={...fi.defaultOptions,resolution:((h=t.data)==null?void 0:h.resolution)||Ws(i),alphaMode:((l=t.data)==null?void 0:l.alphaMode)||await Pr(),...t.data},n=document.createElement("video"),r={preload:s.autoLoad!==!1?"auto":void 0,"webkit-playsinline":s.playsinline!==!1?"":void 0,playsinline:s.playsinline!==!1?"":void 0,muted:s.muted===!0?"":void 0,loop:s.loop===!0?"":void 0,autoplay:s.autoPlay!==!1?"":void 0};Object.keys(r).forEach(c=>{const d=r[c];d!==void 0&&n.setAttribute(c,d)}),s.muted===!0&&(n.muted=!0),cd(n,i,s.crossorigin);const a=document.createElement("source");let o;if(i.startsWith("data:"))o=i.slice(5,i.indexOf(";"));else if(!i.startsWith("blob:")){const c=i.split("?")[0].slice(i.lastIndexOf(".")+1).toLowerCase();o=fi.MIME_TYPES[c]||`video/${c}`}return a.src=i,o&&(a.type=o),new Promise(c=>{const d=async()=>{const f=new fi({...s,resource:n});n.removeEventListener("canplay",d),t.data.preload&&await dd(n),c(Hs(f,e,i))};n.addEventListener("canplay",d),n.appendChild(a)})},unload(i){i.destroy(!0)}},Aa={extension:{type:G.ResolveParser,name:"resolveTexture"},test:Ca.test,parse:i=>{var t;return{resolution:parseFloat(((t=Te.RETINA_PREFIX.exec(i))==null?void 0:t[1])??"1"),format:i.split(".").pop(),src:i}}},pd={extension:{type:G.ResolveParser,priority:-2,name:"resolveJson"},test:i=>Te.RETINA_PREFIX.test(i)&&i.endsWith(".json"),parse:Aa.parse};class gd{constructor(){this._detections=[],this._initialized=!1,this.resolver=new Te,this.loader=new Dc,this.cache=q,this._backgroundLoader=new Pc(this.loader),this._backgroundLoader.active=!0,this.reset()}async init(t={}){var r,a;if(this._initialized){st("[Assets]AssetManager already initialized, did you load before calling this Assets.init()?");return}if(this._initialized=!0,t.defaultSearchParams&&this.resolver.setDefaultSearchParams(t.defaultSearchParams),t.basePath&&(this.resolver.basePath=t.basePath),t.bundleIdentifier&&this.resolver.setBundleIdentifier(t.bundleIdentifier),t.manifest){let o=t.manifest;typeof o=="string"&&(o=await this.load(o)),this.resolver.addManifest(o)}const e=((r=t.texturePreference)==null?void 0:r.resolution)??1,s=typeof e=="number"?[e]:e,n=await this._detectFormats({preferredFormats:(a=t.texturePreference)==null?void 0:a.format,skipDetections:t.skipDetections,detections:this._detections});this.resolver.prefer({params:{format:n,resolution:s}}),t.preferences&&this.setPreferences(t.preferences)}add(t){this.resolver.add(t)}async load(t,e){this._initialized||await this.init();const s=wi(t),n=vt(t).map(o=>{if(typeof o!="string"){const h=this.resolver.getAlias(o);return h.some(l=>!this.resolver.hasKey(l))&&this.add(o),Array.isArray(h)?h[0]:h}return this.resolver.hasKey(o)||this.add({alias:o,src:o}),o}),r=this.resolver.resolve(n),a=await this._mapLoadToResolve(r,e);return s?a[n[0]]:a}addBundle(t,e){this.resolver.addBundle(t,e)}async loadBundle(t,e){this._initialized||await this.init();let s=!1;typeof t=="string"&&(s=!0,t=[t]);const n=this.resolver.resolveBundle(t),r={},a=Object.keys(n);let o=0,h=0;const l=()=>{e==null||e(++o/h)},c=a.map(d=>{const f=n[d];return h+=Object.keys(f).length,this._mapLoadToResolve(f,l).then(g=>{r[d]=g})});return await Promise.all(c),s?r[t[0]]:r}async backgroundLoad(t){this._initialized||await this.init(),typeof t=="string"&&(t=[t]);const e=this.resolver.resolve(t);this._backgroundLoader.add(Object.values(e))}async backgroundLoadBundle(t){this._initialized||await this.init(),typeof t=="string"&&(t=[t]);const e=this.resolver.resolveBundle(t);Object.values(e).forEach(s=>{this._backgroundLoader.add(Object.values(s))})}reset(){this.resolver.reset(),this.loader.reset(),this.cache.reset(),this._initialized=!1}get(t){if(typeof t=="string")return q.get(t);const e={};for(let s=0;s{const o=n[a.src],h=[a.src];a.alias&&h.push(...a.alias),h.forEach(l=>{r[l]=o}),q.set(h,o)}),r}async unload(t){this._initialized||await this.init();const e=vt(t).map(n=>typeof n!="string"?n.src:n),s=this.resolver.resolve(e);await this._unloadFromResolved(s)}async unloadBundle(t){this._initialized||await this.init(),t=vt(t);const e=this.resolver.resolveBundle(t),s=Object.keys(e).map(n=>this._unloadFromResolved(e[n]));await Promise.all(s)}async _unloadFromResolved(t){const e=Object.values(t);e.forEach(s=>{q.remove(s.src)}),await this.loader.unload(e)}async _detectFormats(t){let e=[];t.preferredFormats&&(e=Array.isArray(t.preferredFormats)?t.preferredFormats:[t.preferredFormats]);for(const s of t.detections)t.skipDetections||await s.test()?e=await s.add(e):t.skipDetections||(e=await s.remove(e));return e=e.filter((s,n)=>e.indexOf(s)===n),e}get detections(){return this._detections}setPreferences(t){this.loader.parsers.forEach(e=>{e.config&&Object.keys(e.config).filter(s=>s in t).forEach(s=>{e.config[s]=t[s]})})}}const Ne=new gd;dt.handleByList(G.LoadParser,Ne.loader.parsers).handleByList(G.ResolveParser,Ne.resolver.parsers).handleByList(G.CacheParser,Ne.cache.parsers).handleByList(G.DetectionParser,Ne.detections);dt.add(Gc,Bc,kc,Lc,Ec,Rc,Fc,Nc,Hc,Zc,td,Ca,fd,Mc,Ac,Aa,pd);const sr={loader:G.LoadParser,resolver:G.ResolveParser,cache:G.CacheParser,detection:G.DetectionParser};dt.handle(G.Asset,i=>{const t=i.ref;Object.entries(sr).filter(([e])=>!!t[e]).forEach(([e,s])=>dt.add(Object.assign(t[e],{extension:t[e].extension??s})))},i=>{const t=i.ref;Object.keys(sr).filter(e=>!!t[e]).forEach(e=>dt.remove(t[e]))});class Ct extends vi{constructor(t){t instanceof yt&&(t={context:t});const{context:e,roundPixels:s,...n}=t||{};super({label:"Graphics",...n}),this.renderPipeId="graphics",e?this._context=e:this._context=this._ownedContext=new yt,this._context.on("update",this.onViewUpdate,this),this.allowChildren=!1,this.roundPixels=s??!1}set context(t){t!==this._context&&(this._context.off("update",this.onViewUpdate,this),this._context=t,this._context.on("update",this.onViewUpdate,this),this.onViewUpdate())}get context(){return this._context}get bounds(){return this._context.bounds}addBounds(t){t.addBounds(this._context.bounds)}containsPoint(t){return this._context.containsPoint(t)}onViewUpdate(){if(this._didViewChangeTick++,this._didGraphicsUpdate=!0,this.didViewUpdate)return;this.didViewUpdate=!0;const t=this.renderGroup||this.parentRenderGroup;t&&t.onChildViewUpdate(this)}destroy(t){this._ownedContext&&!t?this._ownedContext.destroy(t):(t===!0||(t==null?void 0:t.context)===!0)&&this._context.destroy(t),this._ownedContext=null,this._context=null,super.destroy(t)}_callContextMethod(t,e){return this.context[t](...e),this}setFillStyle(...t){return this._callContextMethod("setFillStyle",t)}setStrokeStyle(...t){return this._callContextMethod("setStrokeStyle",t)}fill(...t){return this._callContextMethod("fill",t)}stroke(...t){return this._callContextMethod("stroke",t)}texture(...t){return this._callContextMethod("texture",t)}beginPath(){return this._callContextMethod("beginPath",[])}cut(){return this._callContextMethod("cut",[])}arc(...t){return this._callContextMethod("arc",t)}arcTo(...t){return this._callContextMethod("arcTo",t)}arcToSvg(...t){return this._callContextMethod("arcToSvg",t)}bezierCurveTo(...t){return this._callContextMethod("bezierCurveTo",t)}closePath(){return this._callContextMethod("closePath",[])}ellipse(...t){return this._callContextMethod("ellipse",t)}circle(...t){return this._callContextMethod("circle",t)}path(...t){return this._callContextMethod("path",t)}lineTo(...t){return this._callContextMethod("lineTo",t)}moveTo(...t){return this._callContextMethod("moveTo",t)}quadraticCurveTo(...t){return this._callContextMethod("quadraticCurveTo",t)}rect(...t){return this._callContextMethod("rect",t)}roundRect(...t){return this._callContextMethod("roundRect",t)}poly(...t){return this._callContextMethod("poly",t)}regularPoly(...t){return this._callContextMethod("regularPoly",t)}roundPoly(...t){return this._callContextMethod("roundPoly",t)}roundShape(...t){return this._callContextMethod("roundShape",t)}filletRect(...t){return this._callContextMethod("filletRect",t)}chamferRect(...t){return this._callContextMethod("chamferRect",t)}star(...t){return this._callContextMethod("star",t)}svg(...t){return this._callContextMethod("svg",t)}restore(...t){return this._callContextMethod("restore",t)}save(){return this._callContextMethod("save",[])}getTransform(){return this.context.getTransform()}resetTransform(){return this._callContextMethod("resetTransform",[])}rotateTransform(...t){return this._callContextMethod("rotate",t)}scaleTransform(...t){return this._callContextMethod("scale",t)}setTransform(...t){return this._callContextMethod("setTransform",t)}transform(...t){return this._callContextMethod("transform",t)}translateTransform(...t){return this._callContextMethod("translate",t)}clear(){return this._callContextMethod("clear",[])}get fillStyle(){return this._context.fillStyle}set fillStyle(t){this._context.fillStyle=t}get strokeStyle(){return this._context.strokeStyle}set strokeStyle(t){this._context.strokeStyle=t}clone(t=!1){return t?new Ct(this._context.clone()):(this._ownedContext=null,new Ct(this._context))}lineStyle(t,e,s){U(O,"Graphics#lineStyle is no longer needed. Use Graphics#setStrokeStyle to set the stroke style.");const n={};return t&&(n.width=t),e&&(n.color=e),s&&(n.alpha=s),this.context.strokeStyle=n,this}beginFill(t,e){U(O,"Graphics#beginFill is no longer needed. Use Graphics#fill to fill the shape with the desired style.");const s={};return t&&(s.color=t),e&&(s.alpha=e),this.context.fillStyle=s,this}endFill(){U(O,"Graphics#endFill is no longer needed. Use Graphics#fill to fill the shape with the desired style."),this.context.fill();const t=this.context.strokeStyle;return(t.width!==yt.defaultStrokeStyle.width||t.color!==yt.defaultStrokeStyle.color||t.alpha!==yt.defaultStrokeStyle.alpha)&&this.context.stroke(),this}drawCircle(...t){return U(O,"Graphics#drawCircle has been renamed to Graphics#circle"),this._callContextMethod("circle",t)}drawEllipse(...t){return U(O,"Graphics#drawEllipse has been renamed to Graphics#ellipse"),this._callContextMethod("ellipse",t)}drawPolygon(...t){return U(O,"Graphics#drawPolygon has been renamed to Graphics#poly"),this._callContextMethod("poly",t)}drawRect(...t){return U(O,"Graphics#drawRect has been renamed to Graphics#rect"),this._callContextMethod("rect",t)}drawRoundedRect(...t){return U(O,"Graphics#drawRoundedRect has been renamed to Graphics#roundRect"),this._callContextMethod("roundRect",t)}drawStar(...t){return U(O,"Graphics#drawStar has been renamed to Graphics#star"),this._callContextMethod("star",t)}}const Ma=class Pa extends ra{constructor(...t){let e=t[0]??{};e instanceof Float32Array&&(U(O,"use new MeshGeometry({ positions, uvs, indices }) instead"),e={positions:e,uvs:t[1],indices:t[2]}),e={...Pa.defaultOptions,...e};const s=e.positions||new Float32Array([0,0,1,0,1,1,0,1]),n=e.uvs||new Float32Array([0,0,1,0,1,1,0,1]),r=e.indices||new Uint32Array([0,1,2,0,2,3]),a=e.shrinkBuffersToFit,o=new Vt({data:s,label:"attribute-mesh-positions",shrinkToFit:a,usage:it.VERTEX|it.COPY_DST}),h=new Vt({data:n,label:"attribute-mesh-uvs",shrinkToFit:a,usage:it.VERTEX|it.COPY_DST}),l=new Vt({data:r,label:"index-mesh-buffer",shrinkToFit:a,usage:it.INDEX|it.COPY_DST});super({attributes:{aPosition:{buffer:o,format:"float32x2",stride:2*4,offset:0},aUV:{buffer:h,format:"float32x2",stride:2*4,offset:0}},indexBuffer:l,topology:e.topology}),this.batchMode="auto"}get positions(){return this.attributes.aPosition.buffer.data}set positions(t){this.attributes.aPosition.buffer.data=t}get uvs(){return this.attributes.aUV.buffer.data}set uvs(t){this.attributes.aUV.buffer.data=t}get indices(){return this.indexBuffer.data}set indices(t){this.indexBuffer.data=t}};Ma.defaultOptions={topology:"triangle-list",shrinkBuffersToFit:!1};let md=Ma;class we extends ${constructor(...t){let e=t[0];Array.isArray(t[0])&&(e={textures:t[0],autoUpdate:t[1]});const{textures:s,autoUpdate:n,...r}=e,[a]=s;super({...r,texture:a instanceof z?a:a.texture}),this._textures=null,this._durations=null,this._autoUpdate=n??!0,this._isConnectedToTicker=!1,this.animationSpeed=1,this.loop=!0,this.updateAnchor=!1,this.onComplete=null,this.onFrameChange=null,this.onLoop=null,this._currentTime=0,this._playing=!1,this._previousFrame=null,this.textures=s}stop(){this._playing&&(this._playing=!1,this._autoUpdate&&this._isConnectedToTicker&&(It.shared.remove(this.update,this),this._isConnectedToTicker=!1))}play(){this._playing||(this._playing=!0,this._autoUpdate&&!this._isConnectedToTicker&&(It.shared.add(this.update,this,yi.HIGH),this._isConnectedToTicker=!0))}gotoAndStop(t){this.stop(),this.currentFrame=t}gotoAndPlay(t){this.currentFrame=t,this.play()}update(t){if(!this._playing)return;const e=t.deltaTime,s=this.animationSpeed*e,n=this.currentFrame;if(this._durations!==null){let r=this._currentTime%1*this._durations[this.currentFrame];for(r+=s/60*1e3;r<0;)this._currentTime--,r+=this._durations[this.currentFrame];const a=Math.sign(this.animationSpeed*e);for(this._currentTime=Math.floor(this._currentTime);r>=this._durations[this.currentFrame];)r-=this._durations[this.currentFrame]*a,this._currentTime+=a;this._currentTime+=r/this._durations[this.currentFrame]}else this._currentTime+=s;this._currentTime<0&&!this.loop?(this.gotoAndStop(0),this.onComplete&&this.onComplete()):this._currentTime>=this._textures.length&&!this.loop?(this.gotoAndStop(this._textures.length-1),this.onComplete&&this.onComplete()):n!==this.currentFrame&&(this.loop&&this.onLoop&&(this.animationSpeed>0&&this.currentFramen)&&this.onLoop(),this._updateTexture())}_updateTexture(){const t=this.currentFrame;this._previousFrame!==t&&(this._previousFrame=t,this.texture=this._textures[t],this.updateAnchor&&this.anchor.copyFrom(this.texture.defaultAnchor),this.onFrameChange&&this.onFrameChange(this.currentFrame))}destroy(){this.stop(),super.destroy(),this.onComplete=null,this.onFrameChange=null,this.onLoop=null}static fromFrames(t){const e=[];for(let s=0;sthis.totalFrames-1)throw new Error(`[AnimatedSprite]: Invalid frame index value ${t}, expected to be between 0 and totalFrames ${this.totalFrames}.`);const e=this.currentFrame;this._currentTime=t,e!==this.currentFrame&&this._updateTexture()}get playing(){return this._playing}get autoUpdate(){return this._autoUpdate}set autoUpdate(t){t!==this._autoUpdate&&(this._autoUpdate=t,!this._autoUpdate&&this._isConnectedToTicker?(It.shared.remove(this.update,this),this._isConnectedToTicker=!1):this._autoUpdate&&!this._isConnectedToTicker&&this._playing&&(It.shared.add(this.update,this),this._isConnectedToTicker=!0))}}class xd extends vi{constructor(t,e){const{text:s,resolution:n,style:r,anchor:a,width:o,height:h,roundPixels:l,...c}=t;super({...c}),this.batched=!0,this._resolution=null,this._autoResolution=!0,this._didTextUpdate=!0,this._styleClass=e,this.text=s??"",this.style=r,this.resolution=n??null,this.allowChildren=!1,this._anchor=new pt({_onUpdate:()=>{this.onViewUpdate()}}),a&&(this.anchor=a),this.roundPixels=l??!1,o!==void 0&&(this.width=o),h!==void 0&&(this.height=h)}get anchor(){return this._anchor}set anchor(t){typeof t=="number"?this._anchor.set(t):this._anchor.copyFrom(t)}set text(t){t=t.toString(),this._text!==t&&(this._text=t,this.onViewUpdate())}get text(){return this._text}set resolution(t){this._autoResolution=t===null,this._resolution=t,this.onViewUpdate()}get resolution(){return this._resolution}get style(){return this._style}set style(t){var e;t=t||{},(e=this._style)==null||e.off("update",this.onViewUpdate,this),t instanceof this._styleClass?this._style=t:this._style=new this._styleClass(t),this._style.on("update",this.onViewUpdate,this),this.onViewUpdate()}get bounds(){return this._boundsDirty&&(this._updateBounds(),this._boundsDirty=!1),this._bounds}get width(){return Math.abs(this.scale.x)*this.bounds.width}set width(t){this._setWidth(t,this.bounds.width)}get height(){return Math.abs(this.scale.y)*this.bounds.height}set height(t){this._setHeight(t,this.bounds.height)}getSize(t){return t||(t={}),t.width=Math.abs(this.scale.x)*this.bounds.width,t.height=Math.abs(this.scale.y)*this.bounds.height,t}setSize(t,e){typeof t=="object"?(e=t.height??t.width,t=t.width):e??(e=t),t!==void 0&&this._setWidth(t,this.bounds.width),e!==void 0&&this._setHeight(e,this.bounds.height)}addBounds(t){const e=this.bounds;t.addFrame(e.minX,e.minY,e.maxX,e.maxY)}containsPoint(t){const e=this.bounds.width,s=this.bounds.height,n=-e*this.anchor.x;let r=0;return t.x>=n&&t.x<=n+e&&(r=-s*this.anchor.y,t.y>=r&&t.y<=r+s)}onViewUpdate(){if(this._didViewChangeTick++,this._boundsDirty=!0,this.didViewUpdate)return;this.didViewUpdate=!0,this._didTextUpdate=!0;const t=this.renderGroup||this.parentRenderGroup;t&&t.onChildViewUpdate(this)}_getKey(){return`${this.text}:${this._style.styleKey}:${this._resolution}`}destroy(t=!1){super.destroy(t),this.owner=null,this._bounds=null,this._anchor=null,(typeof t=="boolean"?t:t!=null&&t.style)&&this._style.destroy(t),this._style=null,this._text=null}}function yd(i,t){let e=i[0]??{};return(typeof e=="string"||i[1])&&(U(O,`use new ${t}({ text: "hi!", style }) instead`),e={text:e,style:i[1]}),e}class N extends xd{constructor(...t){const e=yd(t,"Text");super(e,W),this.renderPipeId="text"}_updateBounds(){const t=this._bounds,e=this._anchor,s=As.measureText(this._text,this._style),{width:n,height:r}=s;t.minX=-e._x*n,t.maxX=t.minX+n,t.minY=-e._y*r,t.maxY=t.minY+r}}const Ga=class ka extends md{constructor(...t){super({});let e=t[0]??{};typeof e=="number"&&(U(O,"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={...ka.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;const e=this.verticesX*this.verticesY,s=[],n=[],r=[],a=this.verticesX-1,o=this.verticesY-1,h=this.width/a,l=this.height/o;for(let d=0;de?1:this.width/e,n=this._topHeight+this._bottomHeight,r=this.height>n?1:this.height/n,a=Math.min(s,r);t[9]=t[11]=t[13]=t[15]=this._topHeight*a,t[17]=t[19]=t[21]=t[23]=this.height-this._bottomHeight*a,t[25]=t[27]=t[29]=t[31]=this.height,t[2]=t[10]=t[18]=t[26]=this._leftWidth*a,t[4]=t[12]=t[20]=t[28]=this.width-this._rightWidth*a,t[6]=t[14]=t[22]=t[30]=this.width,this.getBuffer("aPosition").update()}updateUvs(){const 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;const e=1/this._originalWidth,s=1/this._originalHeight;t[2]=t[10]=t[18]=t[26]=e*this._leftWidth,t[9]=t[11]=t[13]=t[15]=s*this._topHeight,t[4]=t[12]=t[20]=t[28]=1-e*this._rightWidth,t[17]=t[19]=t[21]=t[23]=1-s*this._bottomHeight,this.getBuffer("aUV").update()}};Ba.defaultOptions={width:100,height:100,leftWidth:10,topHeight:10,rightWidth:10,bottomHeight:10,originalWidth:100,originalHeight:100};let ce=Ba;const Ea=class Ra extends vi{constructor(t){var d,f,g,m;t instanceof z&&(t={texture:t});const{width:e,height:s,leftWidth:n,rightWidth:r,topHeight:a,bottomHeight:o,texture:h,roundPixels:l,...c}=t;super({label:"NineSliceSprite",...c}),this.renderPipeId="nineSliceSprite",this.batched=!0,this._didSpriteUpdate=!0,this._leftWidth=n??((d=h==null?void 0:h.defaultBorders)==null?void 0:d.left)??ce.defaultOptions.leftWidth,this._topHeight=a??((f=h==null?void 0:h.defaultBorders)==null?void 0:f.top)??ce.defaultOptions.topHeight,this._rightWidth=r??((g=h==null?void 0:h.defaultBorders)==null?void 0:g.right)??ce.defaultOptions.rightWidth,this._bottomHeight=o??((m=h==null?void 0:h.defaultBorders)==null?void 0:m.bottom)??ce.defaultOptions.bottomHeight,this.bounds.maxX=this._width=e??h.width??ce.defaultOptions.width,this.bounds.maxY=this._height=s??h.height??ce.defaultOptions.height,this.allowChildren=!1,this.texture=h??Ra.defaultOptions.texture,this.roundPixels=l??!1}get bounds(){return this._bounds}get width(){return this._width}set width(t){this.bounds.maxX=this._width=t,this.onViewUpdate()}get height(){return this._height}set height(t){this.bounds.maxY=this._height=t,this.onViewUpdate()}setSize(t,e){typeof t=="object"&&(e=t.height??t.width,t=t.width),this.bounds.maxX=this._width=t,this.bounds.maxY=this._height=e??t,this.onViewUpdate()}getSize(t){return t||(t={}),t.width=this._width,t.height=this._height,t}get leftWidth(){return this._leftWidth}set leftWidth(t){this._leftWidth=t,this.onViewUpdate()}get topHeight(){return this._topHeight}set topHeight(t){this._topHeight=t,this.onViewUpdate()}get rightWidth(){return this._rightWidth}set rightWidth(t){this._rightWidth=t,this.onViewUpdate()}get bottomHeight(){return this._bottomHeight}set bottomHeight(t){this._bottomHeight=t,this.onViewUpdate()}get texture(){return this._texture}set texture(t){t||(t=z.EMPTY);const e=this._texture;e!==t&&(e&&e.dynamic&&e.off("update",this.onViewUpdate,this),t.dynamic&&t.on("update",this.onViewUpdate,this),this._texture=t,this.onViewUpdate())}get originalWidth(){return this._texture.width}get originalHeight(){return this._texture.height}onViewUpdate(){if(this._didViewChangeTick++,this._didSpriteUpdate=!0,this.didViewUpdate)return;this.didViewUpdate=!0;const t=this.renderGroup||this.parentRenderGroup;t&&t.onChildViewUpdate(this)}addBounds(t){const e=this.bounds;t.addFrame(e.minX,e.minY,e.maxX,e.maxY)}destroy(t){if(super.destroy(t),typeof t=="boolean"?t:t==null?void 0:t.texture){const s=typeof t=="boolean"?t:t==null?void 0:t.textureSource;this._texture.destroy(s)}this._texture=null}};Ea.defaultOptions={texture:z.EMPTY};let _t=Ea;dt.add(Ha,$a);const R=class R{static async Load(t){return this.text.text=`Loading asset: ${t} (${this.counter}/99)`,this.counter++,await Ne.load({src:t})}static async LoadAssets(){if(this.text){console.warn("Do not call GameAssets.LoadAssets() more than once.");return}console.log("Loading Texture Assets");const t=new N({text:"Loading textures. This might take a while.",style:new W({fill:3355443,fontSize:50})});t.x=u.app.canvas.width/2,t.y=u.app.canvas.height/2,t.anchor.set(.5,.5),u.app.stage.addChild(t),this.text=new N({text:"",style:new W({fill:3355443,fontSize:50})}),this.text.x=u.app.canvas.width/2,this.text.y=u.app.canvas.height/2+50,this.text.anchor.set(.5,.5),u.app.stage.addChild(this.text),await Promise.all([this.Load("./assets/gui/button_01.png").then(e=>this.Button01Texture=e),this.Load("./assets/gui/button_02.png").then(e=>this.Button02Texture=e),this.Load("./assets/gui/frame_01.png").then(e=>this.Frame01Texture=e),this.Load("./assets/gui/frame_02.png").then(e=>this.Frame02Texture=e),this.Load("./assets/gui/frame_03.png").then(e=>this.Frame03Texture=e),this.Load("./assets/gui/frame_04.png").then(e=>this.Frame04Texture=e),this.Load("./assets/gui/frame_05.png").then(e=>this.Frame05Texture=e),this.Load("./assets/gui/background_02.png").then(e=>this.FrameTowerTab=e),this.Load("./assets/gui/frame_red.png").then(e=>this.RedBackground=e),this.Load("./assets/gui/frame_green.png").then(e=>this.GreenBackground=e),this.Load("./assets/gui/frame_blue.png").then(e=>this.BlueBackground=e),this.Load("./assets/gui/frame_yellow.png").then(e=>this.YellowBackground=e),this.Load("./assets/gui/banner_01.png").then(e=>this.BannerGemsmith=e),this.Load("./assets/gui/note.png").then(e=>this.EndScreenDialog=e),this.Load("./assets/gui/main_background.jpg").then(e=>this.MainBackground=e),this.Load("./assets/tutorial/tutorial01.jpg").then(e=>this.Tutorial01=e),this.Load("./assets/tutorial/tutorial02.jpg").then(e=>this.Tutorial02=e),this.Load("./assets/tutorial/tutorial03.jpg").then(e=>this.Tutorial03=e),this.Load("./assets/tutorial/tutorial04.jpg").then(e=>this.Tutorial04=e),this.Load("./assets/tutorial/tutorial05.jpg").then(e=>this.Tutorial05=e),this.Load("./assets/gui/heart.png").then(e=>this.HealthTexture=e),this.Load("./assets/gui/money.png").then(e=>this.GoldTexture=e),this.Load("./assets/gui/wave.png").then(e=>this.WaveTexture=e),this.Load("./assets/gui/sword_02.png").then(e=>this.SwordsTexture=e),this.Load("./assets/gui/title01.png").then(e=>this.TitleTexture=e),this.Load("./assets/gui/icons/play.png").then(e=>this.PlayIconTexture=e),this.Load("./assets/gui/icons/pause.png").then(e=>this.PauseIconTexture=e),this.Load("./assets/gui/icons/fastforward.png").then(e=>this.FastForwardIconTexture=e),this.Load("./assets/gui/icons/cross.png").then(e=>this.XIconTexture=e),this.Load("./assets/gui/icons/plus.png").then(e=>this.PlusIconTexture=e),this.LoadMissions(),this.LoadTowers(),this.LoadCreeps(),this.LoadGems()]),t.destroy(),this.text.destroy(),this.text=!0}static async LoadGems(){const e=await(await fetch("./assets/json/Gems.json")).json();this.Gems=e;for(let s=0;s(i[i.Restricted=0]="Restricted",i[i.Buildable=1]="Buildable",i[i.Path=9]="Path",i))(Dt||{}),qe=(i=>(i[i.Basic=0]="Basic",i[i.Circle=1]="Circle",i[i.Electric=2]="Electric",i[i.Buff=3]="Buff",i[i.Strong=4]="Strong",i[i.Rail=5]="Rail",i[i.Trapper=6]="Trapper",i[i.Debuff=7]="Debuff",i))(qe||{});const J=class J{static TestSuite(){if(new URLSearchParams(location.href).entries().next().value[1]!="game")return;J.NotificationManager.Notify("Loaded testing suite.","danger");let e=C.Towers[qe.Electric];J.TowerManager.ToggleChoosingTowerLocation("RESET"),J.TowerManager.PlaceTower(e,6,10,e.behaviour,!0);for(let s=0;s<29;s++)this.GameScene.MissionStats.giveGem(new Ps(s%6),!0)}};p(J,"app"),p(J,"GameMaster"),p(J,"Grid"),p(J,"WaveManager"),p(J,"TowerManager"),p(J,"AnimationManager"),p(J,"NotificationManager"),p(J,"DebrisManager"),p(J,"GameScene"),p(J,"latestCommit"),p(J,"latestGemId",0),p(J,"GridCellSize",64),p(J,"GridColumns",25),p(J,"GridRows",17),p(J,"MouseX",0),p(J,"MouseY",0);let u=J;class _d{constructor(){p(this,"currentScene");u.GameMaster=this}_CreateGuiObject(t){this.currentScene.gui.push(t),u.GameMaster.currentScene.stage.addChild(t.container)}_RemoveGuiObject(t){this.currentScene.gui.splice(this.currentScene.gui.indexOf(t),1),u.GameMaster.currentScene.stage.removeChild(t.container)}changeScene(t){this.currentScene&&this.currentScene.destroy(),this.currentScene=t,this.currentScene.init()}}class At{constructor(t){p(this,"name",this.constructor.name);p(this,"_container",new tt);p(this,"_events",new gt);p(this,"enabled",!0);p(this,"bb",new I);u.GameMaster._CreateGuiObject(this),t&&(this._container.interactive=!0,this._container.onwheel=e=>{this.enabled&&this.onWheel(e)},this._container.onpointerdown=e=>{this.enabled&&this.onClick(e)})}destroy(){this._events.removeAllListeners(),this._container.parent&&this._container.parent.removeChild(this._container),this._container.destroy()}get container(){return this._container}get events(){return this._events}onClick(t){console.warn(`[${this.name} does not implement GuiObject.onClick()]`)}onWheel(t){console.warn(`[${this.name} does not implement GuiObject.onWheel()]`)}setEnabled(t){this.enabled=t}copyContainerToBB(){return this.bb.x=this.container.x,this.bb.y=this.container.y,this.bb.width=this.container.width,this.bb.height=this.container.height,this.bb}copyBBToContainer(){return this.container.x=this.bb.x,this.container.y=this.bb.y,this.container.width=this.bb.width,this.container.height=this.bb.height,this.container}copyPropertiesToObj(t){return t.x=this.bb.x,t.y=this.bb.y,t.width=this.bb.width,t.height=this.bb.height,t}}var ht=(i=>(i[i.Button01=0]="Button01",i[i.Button02=1]="Button02",i))(ht||{});class ut extends At{constructor(e,s,n,r=!0){super(!0);p(this,"caption");p(this,"bounds");p(this,"buttonTexture");p(this,"buttonSprite");p(this,"buttonText");p(this,"buttonIcon");n==0&&(this.buttonTexture=C.Button01Texture),n==1&&(this.buttonTexture=C.Button02Texture),this.caption=s,this.enabled=r,this.bounds=e,this.container.x=this.bounds.x,this.container.y=this.bounds.y,this.container.width=this.bounds.width,this.container.height=this.bounds.height,this.buttonSprite=new _t({texture:this.buttonTexture,leftWidth:100,topHeight:100,rightWidth:100,bottomHeight:100}),this.buttonSprite.x=0,this.buttonSprite.y=0,this.buttonSprite.width=this.bounds.width,this.buttonSprite.height=this.bounds.height,this.container.addChild(this.buttonSprite),this.buttonText=new N({text:this.caption,style:new W({fill:16777215,fontSize:24})}),this.container.addChild(this.buttonText),this.buttonText.anchor.set(.5,.5),this.buttonText.x=this.bounds.width/2,this.buttonText.y=this.bounds.height/2,this.container.x=this.bounds.x,this.container.y=this.bounds.y}setCaption(e){this.caption=e,this.buttonText.text=e}getCaption(){return this.caption}CustomButtonLogic(){console.warn(this.name+" - Button.CustomButtonLogic() is not implemented.")}}class ki{constructor(){p(this,"stage",new tt);p(this,"gui",[]);p(this,"_events",new gt);u.app.stage.addChild(this.stage)}destroy(){this.stage.destroy(),this._events.removeAllListeners(),this.gui.forEach(t=>{t.destroy()})}addMainBackground(){const t=new $(C.MainBackground);t.width=u.app.canvas.width,t.height=u.app.canvas.height,this.stage.addChild(t)}get events(){return this._events}init(){}}class bd extends ki{constructor(){super(...arguments);p(this,"currentImg",1);p(this,"sprite")}init(){let e=[null,C.Tutorial01,C.Tutorial02,C.Tutorial03,C.Tutorial04,C.Tutorial05];this.sprite=new $({texture:C.Tutorial01,scale:.6,x:250,y:150}),this.stage.addChild(this.sprite);let s=new ut(new I(250,this.sprite.height+160,120,60),"Back",ht.Button01);s.container.alpha=0,s.onClick=()=>{s.container.alpha==0||this.currentImg==1||(this.currentImg--,this.currentImg==3?this.sprite.scale=1.1:this.sprite.scale=.6,this.sprite.texture=e[this.currentImg],this.currentImg==1&&(s.container.alpha=0))};let n=new ut(new I(this.sprite.width+130,this.sprite.height+160,120,60),"Next",ht.Button01);n.onClick=()=>{n.container.alpha!=0&&(this.currentImg++,this.currentImg==3?this.sprite.scale=1.1:this.sprite.scale=.6,this.currentImg!=1&&(s.container.alpha=1),this.sprite.texture=e[this.currentImg],this.currentImg==5&&(n.container.alpha=0))};const r=new ut(new I(this.sprite.width-540,this.sprite.height+160,200,60),"Main menu",ht.Button01);r.onClick=a=>{u.GameMaster.changeScene(new qs)}}}class Mt{constructor(){p(this,"name",this.constructor.name);p(this,"_container",new tt);p(this,"bb",new I);p(this,"_events",new gt)}destroy(){this._events.removeAllListeners(),this._container.parent&&this._container.parent.removeChild(this._container),this._container.destroy()}get container(){return this._container}get events(){return this._events}copyContainerToBB(){return this.container==null?null:(this.bb.x=this.container.x,this.bb.y=this.container.y,this.bb.width=this.container.width,this.bb.height=this.container.height,this.bb)}copyBBToContainer(){return this.container.x=this.bb.x,this.container.y=this.bb.y,this.container.width=this.bb.width,this.container.height=this.bb.height,this.container}copyPropertiesToObj(t){return t.x=this.bb.x,t.y=this.bb.y,t.width=this.bb.width,t.height=this.bb.height,t}}var re=(i=>(i.CreepSpawned="creepSpawned",i.Finished="finished",i.NewWave="newwave",i))(re||{}),ot=(i=>(i.Died="died",i.TakenDamage="takenDamage",i.GiveEffect="giveEffect",i.Escaped="escaped",i.Moved="moved",i))(ot||{}),Ke=(i=>(i.CellMouseOver="cellmouseover",i.CellMouseLeave="cellmouseleave",i))(Ke||{}),_e=(i=>(i.TowerPlacedEvent="towerPlacedEvent",i.TowerSoldEvent="towerSoldEvent",i))(_e||{}),$s=(i=>(i.GemGivenEvent="gemGivenEvent",i))($s||{}),Vs=(i=>(i.TowerPanelSelectGem="towerTabSelectGem",i))(Vs||{}),kt=(i=>(i.BasicTowerBehaviour="BasicTowerBehaviour",i.CircleTowerBehaviour="CircleTowerBehaviour",i.ElectricTowerBehaviour="ElectricTowerBehaviour",i.BuffTowerBehaviour="BuffTowerBehaviour",i.StrongTowerBehaviour="StrongTowerBehaviour",i.RailTowerBehaviour="RailTowerBehaviour",i.TrapperTowerBehaviour="TrapperTowerBehaviour",i.DebuffTowerBehaviour="DebuffTowerBehaviour",i))(kt||{});class Sd{constructor(){p(this,"isPlacingTower",!1);p(this,"canPlaceTowers",!0);p(this,"selectedTower",null);p(this,"previewSprite",new $({parent:u.GameMaster.currentScene.stage,zIndex:10,width:64,height:64,alpha:.8}));p(this,"towers",[]);u.TowerManager=this,u.GameScene.events.on(Ke.CellMouseOver,t=>{this.isPlacingTower&&(t.checkIfCantPlace()?(t.showRangePreview(!0,this.selectedTower.stats.range),this.previewSprite.tint=16711680):(t.showRangePreview(!1,this.selectedTower.stats.range),this.previewSprite.tint=16777215),this.previewSprite.x=t.column*u.GridCellSize,this.previewSprite.y=t.row*u.GridCellSize,this.previewSprite.texture=this.selectedTower.texture)}),u.GameScene.events.on(Ke.CellMouseLeave,t=>{this.previewSprite.texture=null,u.Grid.rangePreview.clear()})}ResetChooseTower(){this.selectedTower=null,this.isPlacingTower=!1,u.Grid.toggleGrid("hide")}ToggleChoosingTowerLocation(t){this.canPlaceTowers&&(u.Grid.toggleGrid(),this.isPlacingTower?(this.previewSprite.texture=null,this.selectedTower=null):C.Towers.forEach(e=>{e.name==t&&(this.selectedTower=e,console.log(this.selectedTower))}),this.isPlacingTower=!this.isPlacingTower)}PlayerClickOnGrid(t,e){if(this.canPlaceTowers&&this.isPlacingTower){if(!this.selectedTower)return u.NotificationManager.Notify("TowerManager.selectedTower is null when trying to place tower.","danger"),console.warn("TowerManager.selectedTower is null when trying to place tower.");this.PlaceTower(this.selectedTower,t,e,this.selectedTower.behaviour)}}GetTowerByRowAndCol(t,e){let s=null;return this.towers.forEach(n=>{n.row==t&&n.column==e&&(s=n)}),s}PlaceTower(t,e,s,n,r){const a=t.texture;if(!u.GameScene.MissionStats.hasEnoughGold(t.stats.cost)&&!r)return u.NotificationManager.Notify("Not enough gold.","warn");if(!this.GetTowerByRowAndCol(e,s)&&u.Grid.getCellByRowAndCol(e,s).type!=Dt.Path&&u.Grid.getCellByRowAndCol(e,s).type!=Dt.Restricted){r||u.GameScene.MissionStats.spendGold(t.stats.cost);let o=new Ld(e,s,a,t,n);this.towers.push(o),this.ToggleChoosingTowerLocation("RESET"),this.selectedTower=null,this.previewSprite.x=-100,u.GameScene.events.emit(_e.TowerPlacedEvent,t.name,e,s)}else u.NotificationManager.Notify("Can not place tower on path or other tower, choose another spot.","warn")}update(t){this.towers.forEach((e,s)=>{if(e.sold){for(e.slottedGems=e.slottedGems.filter(n=>n!=null);e.slottedGems.length>0;)e.UnslotGem(0);u.GameScene.events.emit(_e.TowerSoldEvent,e.definition.name,e.row,e.column),u.GameScene.MissionStats.earnGold(e.definition.stats.cost),e.destroy(),this.towers.splice(s,1)}else e.update(t)})}}function ct(i,t,e,s){const n=e-i,r=s-t;return Math.atan2(r,n)}class Ys extends Mt{constructor(e,s,n,r,a,o,h,l,c){super();p(this,"deleteMe",!1);p(this,"sprite");p(this,"x");p(this,"y");p(this,"angle");p(this,"speed");p(this,"damage");p(this,"pierce",1);p(this,"timeToLive");p(this,"parent");p(this,"gemResistanceModifications");p(this,"collidedCreepIDs",[]);this.x=e,this.y=s,this.timeToLive=h,this.pierce=l,this.damage=a,this.gemResistanceModifications=c,this.sprite=new we({textures:n,scale:.25,rotation:r}),this.sprite.anchor.set(.5,.5),this.sprite.play(),this.container.x=this.x,this.container.y=this.y,this.container.addChild(this.sprite),u.GameMaster.currentScene.stage.addChild(this.container),this.angle=r,this.speed=.9}destroy(){super.destroy(),this.deleteMe=!0}update(e){if(!this.deleteMe){if(this.x>1720||this.x<0||this.y>2e3||this.y<0||this.pierce<=0||this.timeToLive<=0)return this.destroy();this.timeToLive-=u.GameScene.gameSpeedMultiplier,u.Grid.creeps.forEach(s=>{if(!(this.pierce<=0)&&s&&s.container&&this.checkCollision(s)&&!this.collidedCreepIDs.find(r=>s.id==r.id)){this.collidedCreepIDs.push(s),this.pierce--,this.onCollide(s,this);return}}),this.x+=Math.cos(this.angle)*this.speed*e*u.GameScene.gameSpeedMultiplier,this.y+=Math.sin(this.angle)*this.speed*e*u.GameScene.gameSpeedMultiplier,this.container.x=this.x,this.container.y=this.y}}onCollide(e,s){u.GameScene.events.emit(ot.TakenDamage,e.id,s.damage,s.gemResistanceModifications)}checkCollision(e){if(e==null||e.container==null||e.container._position==null)return;let s=this.copyContainerToBB(),n=e.copyContainerToBB();return s.getBounds().intersects(n.getBounds())}}class vd extends Ys{constructor(e,s,n,r,a,o,h,l,c){super(e,s,n,r,a,o,h,l,c);p(this,"visuals",[]);p(this,"counter",0);this.pierce=1e3,this.timeToLive=2e3}destroy(){super.destroy(),this.visuals.forEach(e=>e.destroy()),this.visuals=[]}update(e){if(super.update(e),this.counter==2){this.counter=0;let s=new $({x:this.x,y:this.y,rotation:this.angle,texture:this.sprite.texture,scale:.25});s.anchor.set(.5,.5),this.visuals.push(s),this.visuals.forEach(n=>{if(n.scale==null)return n.destroy();n.width&&n.height&&n.alpha&&(n.width-=4,n.height-=4,n.alpha-=.1,(n.width<=0||n.height<=0||n.alpha<=0)&&n.destroy())}),u.GameScene.stage.addChild(s)}else this.counter++}}class Cd extends Ys{constructor(e,s,n,r,a,o,h,l,c,d,f){super(e,s,n,r,h,l,c,d,f);p(this,"visuals",[]);p(this,"counter",0);p(this,"goalX");p(this,"goalY");this.sprite.scale=.5,this.sprite.rotation=Math.random()*Math.PI*2,this.goalX=a,this.goalY=o}destroy(){super.destroy(),this.visuals.forEach(e=>e.destroy()),this.visuals=[]}update(e){if(!this.deleteMe){if(this.x>1720||this.x<0||this.y>2e3||this.y<0||this.pierce<=0||this.timeToLive<=0)return this.destroy();be(this.x,this.y,this.goalX,this.goalY)<25?(this.timeToLive-=u.GameScene.gameSpeedMultiplier,u.Grid.creeps.forEach(s=>{if(!(this.pierce<=0)&&s&&s.container&&this.checkCollision(s)){this.collidedCreepIDs.push(s),this.pierce--,this.onCollide(s,this);return}})):(this.x+=Math.cos(this.angle)*this.speed*e*u.GameScene.gameSpeedMultiplier,this.y+=Math.sin(this.angle)*this.speed*e*u.GameScene.gameSpeedMultiplier,this.container.x=this.x,this.container.y=this.y)}}}class Td extends Mt{constructor(e,s){super();p(this,"deleteMe",!1);p(this,"c");p(this,"oc");p(this,"Lightning");this.c=e,this.oc=s;let n=ct(e.x,e.y,s.x,s.y);this.Lightning=new we({textures:C.SpecialLightning,x:e.x,y:e.y,width:be(this.c.x,this.c.y,this.oc.x,this.oc.y),height:64,scale:1.2,rotation:n}),this.Lightning.anchor.set(0,.5),this.Lightning.play(),u.GameMaster.currentScene.stage.addChild(this.Lightning),u.DebrisManager.CreateDebris(this,30)}destroy(){this.deleteMe=!0,this.container.destroy(),this.Lightning.destroy()}update(){this.deleteMe||(this.Lightning.x=this.c.x,this.Lightning.y=this.c.y,this.Lightning.width=be(this.c.x,this.c.y,this.oc.x,this.oc.y))}}var Xs=(i=>(i.MovingBackwards="MovingBackwards",i.DebuffTowerDebuff="DebuffTowerDebuff",i))(Xs||{});class Ad{constructor(t,e){p(this,"effectEnum");p(this,"durationInMS");p(this,"ticks",0);this.effectEnum=t,this.durationInMS=e}}class Md extends Mt{constructor(e,s,n){super();p(this,"id");p(this,"creepType");p(this,"sprite");p(this,"path");p(this,"stats");p(this,"pathIndex",0);p(this,"speed");p(this,"direction",1);p(this,"healthBarGraphics",new Ct);p(this,"healthBarWidth",50);p(this,"effects",[]);p(this,"health");p(this,"maxHealth");p(this,"escaped",!1);p(this,"died",!1);p(this,"x");p(this,"y");p(this,"dead",!1);this.creepType=e,this.stats=structuredClone(C.Creeps[this.creepType].stats),this.sprite=new we(C.Creeps[this.creepType].textures),this.sprite.scale.x*=-1,this.sprite.anchor.set(.5,.5),this.sprite.animationSpeed=.3,this.sprite.play(),this.id=n,this.container.x=-70,this.container.y=-50,this.sprite.width=u.GridCellSize,this.sprite.height=u.GridCellSize,this.bb.width=this.sprite.width,this.speed=this.stats.speed/60,this.health=this.stats.health,this.maxHealth=this.stats.health,this.path=s,this.x=s[0][0]*u.GridCellSize+u.GridCellSize/2,this.y=s[0][1]*u.GridCellSize+u.GridCellSize/2,u.GameScene.events.on(ot.TakenDamage,(r,a,o)=>{r==this.id&&(this.effects.find(h=>h.effectEnum=="DebuffTowerDebuff")&&(a=a*1.5,console.log("multiplying damage, "+a)),this.health-=a+a*(o.physical-this.stats.resistance.physical),o.fire!=0&&(this.health-=Math.max(a*(o.fire-this.stats.resistance.fire),0)),o.ice!=0&&(this.health-=Math.max(a*(o.ice-this.stats.resistance.ice),0)),o.frostfire!=0&&(this.health-=Math.max(a*(o.frostfire-this.stats.resistance.frostfire),0)),o.divine!=0&&(this.health-=Math.max(a*(o.divine-this.stats.resistance.divine),0)),this.UpdateHealthbar())}),u.GameScene.events.on(ot.GiveEffect,(r,a,o)=>{r==this.id&&(console.log(" I CAUGHT THE EVENT!"),this.effects.find(h=>h.effectEnum==a)==null&&this.effects.push(new Ad(a,o)))}),u.Grid.container.addChild(this.container),this.container.addChild(this.healthBarGraphics),this.container.addChild(this.sprite),this.UpdateHealthbar()}UpdateHealthbar(){this.healthBarGraphics.clear();const e=this.health,s=this.maxHealth,n=Math.max(0,e/s),r=this.healthBarWidth,a=10,o=2,h=-r/2,l=-32;this.healthBarGraphics.rect(h-o,l-o,r+o*2,a+o*2),this.healthBarGraphics.fill({color:0});const c=r*n;this.healthBarGraphics.rect(h,l,c,a),this.healthBarGraphics.fill({color:16711680})}update(e){if(this.dead)return;if(this.health<=0){u.GameScene.events.emit(ot.Died,this.maxHealth,this),this.destroy(),this.dead=!0;return}if(this.pathIndex+1==this.path.length){if(this.escaped)return;this.events.emit(ot.Escaped,this),this.escaped=!0;return}const s=this.path[this.pathIndex],n=this.path[this.pathIndex+1],r=this.pathIndex-1!=0?this.path[this.pathIndex-1]:this.path[0];let a=!1;for(let m=this.effects.length-1;m>=0;m--){let y=this.effects[m];if(y.ticks+=e*u.GameScene.gameSpeedMultiplier,y.ticks>=y.durationInMS)this.effects.splice(m,1);else if(y.effectEnum=="MovingBackwards")return a=!0}let o,h,l,c;a?(o=r[0]*u.GridCellSize+u.GridCellSize/2,h=r[1]*u.GridCellSize+u.GridCellSize/2,l=s[0]-r[0],c=r[1]-s[1]):(o=n[0]*u.GridCellSize+u.GridCellSize/2,h=n[1]*u.GridCellSize+u.GridCellSize/2,l=n[0]-s[0],c=n[1]-s[1]),l>0?this.direction!=1&&(this.direction=1,this.sprite.scale.x*=-1):l<0&&this.direction!=-1&&(this.direction=-1,this.sprite.scale.x*=-1);let d=this.speed*e*l*u.GameScene.gameSpeedMultiplier,f=this.speed*e*c*u.GameScene.gameSpeedMultiplier,g=!1;d>0&&this.x+d>o&&(d=o-this.x,g=!0),d<0&&this.x+d0&&this.y+f>h&&(f=h-this.y,g=!0),f<0&&this.y+f=0;e--){let s=i.projectiles[e];s.deleteMe||i.sold?(s.collidedCreepIDs.forEach(()=>{i.damageDealt+=i.computedDamageToDeal}),s.collidedCreepIDs=[],s.destroy(),i.projectiles.splice(e,1)):s.update(t)}}function Ot(i){let t=0,e=0,s=0,n=0,r=0;if(i.totalGemResistanceModifications={fire:0,frostfire:0,divine:0,ice:0,physical:0},i.slottedGems.forEach(a=>{let o=a.currentGemImprovement();t+=o.damageUp,e+=o.attackSpeedUp,s+=o.rangeUp,n+=o.timeToLiveUp,r+=o.pierceUp;let h=a.currentGemResistanceModifications();i.totalGemResistanceModifications.physical+=Number(h.physical.toFixed(2)),i.totalGemResistanceModifications.ice+=Number(h.ice.toFixed(2)),i.totalGemResistanceModifications.fire+=Number(h.fire.toFixed(2)),i.totalGemResistanceModifications.divine+=Number(h.divine.toFixed(2)),i.totalGemResistanceModifications.frostfire+=Number(h.frostfire.toFixed(2))}),i.computedDamageToDeal=i.definition.stats.damage+t,i.computedCooldown=i.definition.stats.cooldown-e,i.computedRange=i.definition.stats.range+s,i.computedTimeToLive=i.definition.stats.timeToLive+n,i.computedPierce=i.definition.stats.pierce+r,i.parent.isBuffedBy.length>0&&i.definition.name!=C.Towers[qe.Buff].name){let a=i.parent.isBuffedBy[0];i.computedDamageToDeal+=Number((a.computedDamageToDeal/2).toFixed(1)),i.computedCooldown-=Number((a.computedCooldown/5).toFixed(1)),i.computedRange+=Number((a.computedRange/10).toFixed(1)),i.computedTimeToLive+=Number((a.computedTimeToLive/5).toFixed(1)),i.computedPierce+=Number((a.computedPierce/4).toFixed(1)),i.totalGemResistanceModifications.physical+=Number((a.totalGemResistanceModifications.physical/2).toFixed(2)),i.totalGemResistanceModifications.ice+=Number((a.totalGemResistanceModifications.ice/2).toFixed(2)),i.totalGemResistanceModifications.fire+=Number((a.totalGemResistanceModifications.fire/2).toFixed(2)),i.totalGemResistanceModifications.divine+=Number((a.totalGemResistanceModifications.divine/2).toFixed(2)),i.totalGemResistanceModifications.frostfire+=Number((a.totalGemResistanceModifications.frostfire/2).toFixed(2))}}function Pd(i,t){if(Ot(i),oe(i,t),i.millisecondsUntilNextShot>0)i.millisecondsUntilNextShot-=t*u.GameScene.gameSpeedMultiplier;else{let e=i.GetCreepsInRange();if(e.length>0){let s=e[0],n=i.column*u.GridCellSize+u.GridCellSize/2,r=i.row*u.GridCellSize+u.GridCellSize/2;i.millisecondsUntilNextShot=i.computedCooldown,i.Shoot(ct(n,r,s.x,s.y))}}}function Gd(i,t){if(Ot(i),oe(i,t),i.millisecondsUntilNextShot>0)i.millisecondsUntilNextShot-=t*u.GameScene.gameSpeedMultiplier;else if(i.GetCreepsInRange().length>0){i.millisecondsUntilNextShot=i.computedCooldown;let s=i.column*u.GridCellSize+u.GridCellSize/2,n=i.row*u.GridCellSize+u.GridCellSize/2;i.Shoot(ct(s,n,s,n+10)),i.Shoot(ct(s,n,s+10,n)),i.Shoot(ct(s,n,s-10,n)),i.Shoot(ct(s,n,s,n-10)),i.Shoot(ct(s,n,s+10,n+10)),i.Shoot(ct(s,n,s-10,n+10)),i.Shoot(ct(s,n,s-10,n-10)),i.Shoot(ct(s,n,s+10,n-10))}}function kd(i,t){if(Ot(i),oe(i,t),i.millisecondsUntilNextShot>0)i.millisecondsUntilNextShot-=t*u.GameScene.gameSpeedMultiplier;else{let e=i.GetCreepsInRange();if(e.length>0){let s=e[0],n=i.column*u.GridCellSize+u.GridCellSize/2,r=i.row*u.GridCellSize+u.GridCellSize/2;i.millisecondsUntilNextShot=i.computedCooldown;let a=i.Shoot(ct(n,r,s.x,s.y));a.onCollide=(o,h)=>{let l=[];h.pierce=0;let c=0;function d(f){if(c>=50){u.GameScene.PauseGame(),u.NotificationManager.Notify("Electric Tower max recursion exceeded! Please tell koneko! (game paused)","danger");return}c++,u.Grid.creeps.forEach(g=>{if(g.id!=o.id){const m=g.x,y=g.y,x=1.5*u.GridCellSize;if(be(f.x,f.y,m,y)_==g.id)!=null)return;l.push(g.id),new Td(f,g),u.GameScene.events.emit(ot.TakenDamage,g.id,Math.round(h.damage/2),h.gemResistanceModifications),d(g)}}})}u.GameScene.events.emit(ot.TakenDamage,o.id,h.damage,h.gemResistanceModifications),l.push(o.id),d(o)}}}}function Bd(i,t){Ot(i)}function Id(i,t){if(Ot(i),oe(i,t),i.millisecondsUntilNextShot>0)i.millisecondsUntilNextShot-=t*u.GameScene.gameSpeedMultiplier;else{let e=i.GetCreepsInRange();if(e.length>0){let s=e[0],n=i.column*u.GridCellSize+u.GridCellSize/2,r=i.row*u.GridCellSize+u.GridCellSize/2;i.millisecondsUntilNextShot=i.computedCooldown;let a=i.Shoot(ct(n,r,s.x,s.y));a.onCollide=(o,h)=>{u.GameScene.events.emit(ot.GiveEffect,o.id,Xs.MovingBackwards,750),u.GameScene.events.emit(ot.TakenDamage,o.id,h.damage/2,h.gemResistanceModifications)}}}}function Ed(i,t){if(Ot(i),oe(i,t),i.millisecondsUntilNextShot>0)i.millisecondsUntilNextShot-=t*u.GameScene.gameSpeedMultiplier;else{let e=i.GetCreepsInRange();if(e.length>0){let s=e[0],n=i.column*u.GridCellSize+u.GridCellSize/2,r=i.row*u.GridCellSize+u.GridCellSize/2;i.millisecondsUntilNextShot=i.computedCooldown,i.Shoot(ct(n,r,s.x,s.y))}}}function Rd(i,t){if(Ot(i),oe(i,t),i.millisecondsUntilNextShot>0)i.millisecondsUntilNextShot-=t*u.GameScene.gameSpeedMultiplier;else{if(u.GameScene.roundMode!=Fa.Combat)return;let e=i.column*u.GridCellSize+u.GridCellSize/2,s=i.row*u.GridCellSize+u.GridCellSize/2,n=u.Grid.GetPathCellsInRange(i.row,i.column,i.computedRange);if(n.length>0){let r=Math.floor(Math.random()*n.length),a=n[r],o=a.column*u.GridCellSize+u.GridCellSize/2,h=a.row*u.GridCellSize+u.GridCellSize/2,l=new Y("white");if(i.slottedGems.length>0){let d=new Y(i.slottedGems[0].definition.color);for(let f=1;f0&&(i.millisecondsUntilNextShot-=t*u.GameScene.gameSpeedMultiplier);let e=i.GetCreepsInRange();if(e.length>0){let s=e[0];if(i.millisecondsUntilNextShot<=0){let n=i.column*u.GridCellSize+u.GridCellSize/2,r=i.row*u.GridCellSize+u.GridCellSize/2;i.millisecondsUntilNextShot=i.computedCooldown;let a=i.Shoot(ct(n,r,s.x,s.y));a.onCollide=(o,h)=>{u.GameScene.events.emit(ot.GiveEffect,o.id,Xs.DebuffTowerDebuff,5e3),u.GameScene.events.emit(ot.TakenDamage,o.id,h.damage/1.5,h.gemResistanceModifications)}}}}function be(i,t,e,s){return Math.sqrt((e-i)*(e-i)+(s-t)*(s-t))}class Ld extends Mt{constructor(e,s,n,r,a){super();p(this,"row");p(this,"column");p(this,"setAsSold",!1);p(this,"sold",!1);p(this,"definition");p(this,"slottedGems",[]);p(this,"damageDealt",0);p(this,"projectiles",[]);p(this,"behaviour");p(this,"sprite");p(this,"millisecondsUntilNextShot");p(this,"graphics",new Ct);p(this,"computedDamageToDeal",0);p(this,"computedCooldown",0);p(this,"computedRange",0);p(this,"computedTimeToLive",0);p(this,"computedPierce",0);p(this,"totalGemResistanceModifications",{fire:0,frostfire:0,divine:0,ice:0,physical:0});p(this,"parent");p(this,"onParentCellEnter",e=>{!u.TowerManager.isPlacingTower&&u.Grid.gridInteractionEnabled&&!u.GameScene.towerPanel.isShown&&this.parent.showRangePreview(!1,this.computedRange)});p(this,"onParentCellLeave",e=>{this.graphics.clear()});this.row=e,this.column=s,this.behaviour=a,this.definition=r,this.millisecondsUntilNextShot=0,this.parent=u.Grid.getCellByRowAndCol(e,s),this.sprite=new $({texture:n,height:u.GridCellSize,width:u.GridCellSize,zIndex:130}),this.container.addChild(this.sprite),this.computedDamageToDeal=this.definition.stats.damage,this.computedRange=this.definition.stats.range,this.parent.container.addChild(this.container),this.container.interactiveChildren=!0,this.parent.clickDetector.on("pointerenter",this.onParentCellEnter),this.parent.clickDetector.on("pointerleave",this.onParentCellLeave),u.GameMaster.currentScene.stage.addChild(this.graphics)}SlotGem(e,s){this.slottedGems[s]=e,u.GameScene.towerPanel.Hide(),u.GameScene.towerPanel.Show(this)}UnslotGem(e){const s=this.slottedGems.splice(e,1)[0];if(s==null||!s)return console.warn("UnslotGem: Gem is null.");u.GameScene.MissionStats.giveGem(s,!0);for(let n=e;nn!=null),u.NotificationManager.Notify(`Lv. ${s.level} ${s.definition.name} unslotted and placed back in your inventory.`,"info")}GetCreepsInRange(){return u.Grid.creeps.filter(s=>{const n=s.x,r=s.y,a=this.column*u.GridCellSize+u.GridCellSize/2,o=this.row*u.GridCellSize+u.GridCellSize/2,h=this.computedRange*u.GridCellSize;return be(a,o,n,r)0){let o=new Y(this.slottedGems[0].definition.color);for(let h=1;h{u.Grid.gridInteractionEnabled&&(u.TowerManager.isPlacingTower?u.Grid.onGridCellClicked(s,n):this.OpenSelectedTowerPanel())}),this.clickDetector.on("pointerenter",a=>{!u.Grid.gridInteractionEnabled||u.GameScene.towerPanel.isShown||u.GameScene.events.emit(Ke.CellMouseOver,this)}),this.clickDetector.on("pointerleave",a=>{!u.Grid.gridInteractionEnabled||u.GameScene.towerPanel.isShown||u.GameScene.events.emit(Ke.CellMouseLeave,this)}),u.GameScene.events.on(_e.TowerPlacedEvent,(a,o,h)=>{if(o==this.row&&h==this.column)this.hasTowerPlaced=!0,u.Grid.rangePreview.clear();else if(a==C.Towers[qe.Buff].name){let l=u.TowerManager.GetTowerByRowAndCol(o,h);u.Grid.IsCellInRangeOfOtherCell(o,h,l.computedRange,this)&&this.isBuffedBy.push(l)}}),u.GameScene.events.on(_e.TowerSoldEvent,(a,o,h)=>{if(console.log(a,o,h),o==this.row&&h==this.column)this.hasTowerPlaced=!1,u.Grid.rangePreview.clear();else if(a==C.Towers[qe.Buff].name){let l=u.TowerManager.GetTowerByRowAndCol(o,h);u.Grid.IsCellInRangeOfOtherCell(o,h,l.computedRange,this)&&(console.log("REMOVED!"),this.isBuffedBy.splice(this.isBuffedBy.indexOf(l),1),console.log(this.isBuffedBy))}})}showRangePreview(e,s){let n=16777215;e&&(n=16711680),u.Grid.rangePreview.clear(),u.Grid.rangePreview.circle(this.column*u.GridCellSize+u.GridCellSize/2,this.row*u.GridCellSize+u.GridCellSize/2,s*u.GridCellSize),u.Grid.rangePreview.fill({color:n,alpha:.3})}OpenSelectedTowerPanel(){if(this.hasTowerPlaced){const e=u.TowerManager.GetTowerByRowAndCol(this.row,this.column);u.GameScene.towerPanel.Show(e)}}checkIfCantPlace(){return this.hasTowerPlaced||this.isPath||this.type==Dt.Path||this.type==Dt.Restricted}gDraw(){this.g.rect(0,0,this.bb.width,this.bb.height),this.type==Dt.Restricted?this.g.fill({color:2236962,alpha:.5}):this.hasTowerPlaced?this.g.fill({color:16711680,alpha:.5}):this.type==Dt.Path?this.g.fill({color:2236962,alpha:.5}):this.type==Dt.Buildable&&this.g.stroke({color:65280,alpha:.9})}gClear(){this.g.clear()}update(){}}class zd extends Mt{constructor(e,s){super();p(this,"gameMap");p(this,"cells",[]);p(this,"rangePreview");p(this,"creeps",[]);p(this,"gridShown",!1);p(this,"gridInteractionEnabled",!0);this.gameMap=e,u.Grid=this,this.bb.x=0,this.bb.y=0,this.bb.width=u.GridCellSize*u.GridColumns,this.bb.height=u.GridCellSize*u.GridRows,u.GameMaster.currentScene.stage.addChild(this.container);let n=new $(C.MissionBackgrounds[s]);this.container.addChild(n);for(let r=0;rc.some(d=>d[1]===a&&d[0]===r));h&&(o=Dt.Path);let l=new Dd(o,a,r,h);this.cells.push(l)}this.rangePreview=new Ct({zIndex:10,x:0,y:0,width:u.app.canvas.width,height:u.app.canvas.height}),this.container.addChild(this.rangePreview)}generateCells(){const e=Array.from({length:this.gameMap.rows},()=>Array(this.gameMap.columns).fill(1));this.cells.forEach(s=>{if(s.isPath){e[s.row][s.column]=9;for(let n=-1;n<=1;n++)for(let r=-1;r<=1;r++){const a=s.row+n,o=s.column+r;a>=0&&a=0&&o{a.isPath&&this.IsCellInRangeOfOtherCell(e,s,n,a)&&r.push(a)}),r}toggleGrid(e){this.cells.forEach(s=>{if(e){e=="hide"?s.gClear():s.gDraw();return}this.gridShown?s.gClear():s.gDraw()}),e=="hide"?this.gridShown=!1:e=="show"?this.gridShown=!0:this.gridShown=!this.gridShown}addCreep(e){this.creeps.push(e),e.events.on(ot.Died,s=>{this.onCreepDiedOrEscaped(s)}),e.events.on(ot.Escaped,s=>{this.onCreepDiedOrEscaped(s)})}onCreepDiedOrEscaped(e){this.creeps.splice(this.creeps.indexOf(e),1),e.destroy()}update(e){this.creeps.forEach(s=>{s.dead?(this.creeps.splice(this.creeps.indexOf(s),1),s=null):s.update(e)})}getCellByRowAndCol(e,s){return this.cells.filter(n=>n.row==e&&n.column==s)[0]}onGridCellClicked(e,s){}}class Ud extends Mt{constructor(e,s){super();p(this,"creeps",[]);p(this,"rounds");p(this,"paths");p(this,"ticks",0);p(this,"started",!1);p(this,"internalCreepId",0);p(this,"pathsIndex");p(this,"finished",!1);u.WaveManager=this,this.rounds=e,this.paths=s,this.pathsIndex=0}start(e){this.started=!0,this.ticks=0,this.creeps=[],this.finished=!1,this.pathsIndex+1==this.paths.length?this.pathsIndex=0:this.pathsIndex++;let s=0;this.rounds[e].waves.forEach(n=>{s+=n.firstCreepSpawnTick,n.creeps.forEach(r=>{const a=new Md(r,this.paths[this.pathsIndex],this.internalCreepId);this.internalCreepId++;const o={creep:a,tickToSpawnAt:s,spawned:!1};s+=n.spawnIntervalTicks,this.creeps.push(o)})}),console.log(this.creeps)}end(){this.started=!1}update(e){this.started!=!1&&(this.ticks+=e*u.GameScene.gameSpeedMultiplier,this.creeps.forEach(s=>{!s.spawned&&s.tickToSpawnAt<=this.ticks?(s.spawned=!0,this.events.emit(re.CreepSpawned,s.creep),!this.finished&&this.creeps.every(n=>n.spawned)&&(this.finished=!0,this.events.emit(re.Finished))):s.spawned&&s.creep.update(e)}))}}class Ht extends At{constructor(e,s,n,r,a,o,h,l){if(e>3||s>2||e<0||s<0)throw"Index/row out of bounds for TowerButton.";super(!0);p(this,"frameSprite");p(this,"background");p(this,"towerName");p(this,"iconSprite");p(this,"i",0);this.towerName=h,this.container.x=e*n+5,this.container.y=s*r+5,this.background=new $({texture:o}),this.iconSprite=new $({texture:l}),this.background.width=n,this.background.height=r,this.iconSprite.x=n/2,this.iconSprite.y=r/2,this.iconSprite.width=n/2,this.iconSprite.height=r/2,this.iconSprite.anchor.set(.5,.5),this.container.addChild(this.background),this.container.addChild(this.iconSprite),this.frameSprite=new _t({texture:C.Frame02Texture,leftWidth:100,topHeight:100,rightWidth:100,bottomHeight:100,roundPixels:!0,height:r,width:n}),this.container.addChild(this.frameSprite),a.addChild(this.container),u.GameScene.events.on(_e.TowerPlacedEvent,c=>{this.resetTint()}),this.container.onpointermove=c=>{u.Grid.gridInteractionEnabled!=!1&&(u.TowerManager.isPlacingTower||this.ShowTooltip())},this.container.onpointerleave=c=>{u.GameScene.tooltip.Hide()}}ShowTooltip(){let e;C.Towers.forEach(s=>{s.name==this.towerName&&(e=s)}),u.GameScene.tooltip.SetContentTower(this.towerName,e.stats.damage,e.stats.cost,e.stats.gemSlotsAmount),u.GameScene.tooltip.Show(u.MouseX,u.MouseY)}onClick(e){u.Grid.gridInteractionEnabled!=!1&&(u.TowerManager.isPlacingTower&&u.TowerManager.selectedTower.name!=this.towerName&&(u.GameScene.sidebar.towerTab.resetTint(),u.TowerManager.ResetChooseTower()),u.GameScene.towerPanel.Hide(),u.GameScene.tooltip.Hide(),this.frameSprite.tint==65280?(this.frameSprite.tint=16777215,this.ShowTooltip()):this.frameSprite.tint=65280,u.TowerManager.ToggleChoosingTowerLocation(this.towerName))}resetTint(){this.frameSprite.tint=16777215}}class Nd extends At{constructor(e){super(!1);p(this,"bounds");p(this,"towerTabSprite");p(this,"towerButtons",[]);this.bounds=e,this.container.x=this.bounds.x,this.container.y=this.bounds.y,this.towerTabSprite=new _t({texture:C.FrameTowerTab,leftWidth:500,topHeight:500,rightWidth:500,bottomHeight:500,roundPixels:!0}),this.towerTabSprite.width=this.bounds.width,this.towerTabSprite.height=this.bounds.height,this.container.addChild(this.towerTabSprite),this.towerButtons.push(new Ht(0,0,70,70,this.container,C.RedBackground,C.Towers[0].name,C.Towers[0].texture)),this.towerButtons.push(new Ht(1,0,70,70,this.container,C.RedBackground,C.Towers[1].name,C.Towers[1].texture)),this.towerButtons.push(new Ht(2,0,70,70,this.container,C.BlueBackground,C.Towers[2].name,C.Towers[2].texture)),this.towerButtons.push(new Ht(3,0,70,70,this.container,C.BlueBackground,C.Towers[3].name,C.Towers[3].texture)),this.towerButtons.push(new Ht(0,1,70,70,this.container,C.GreenBackground,C.Towers[4].name,C.Towers[4].texture)),this.towerButtons.push(new Ht(1,1,70,70,this.container,C.GreenBackground,C.Towers[5].name,C.Towers[5].texture)),this.towerButtons.push(new Ht(2,1,70,70,this.container,C.YellowBackground,C.Towers[6].name,C.Towers[6].texture)),this.towerButtons.push(new Ht(3,1,70,70,this.container,C.YellowBackground,C.Towers[7].name,C.Towers[7].texture))}resetTint(){this.towerButtons.forEach(e=>e.resetTint())}}const se=class se{static init(){se.SidebarRect=new I(u.app.canvas.width-360,0,360,u.app.canvas.height),se.ChangeRoundButtonRect=new I(50,u.app.canvas.height-100,310,100)}};p(se,"SidebarRect"),p(se,"ChangeRoundButtonRect"),p(se,"MaximumPlayerNameLength",20);let Yt=se;class Ze extends At{constructor(e,s,n,r){super(!0);p(this,"iconSprite");p(this,"background");p(this,"frame");p(this,"i",0);p(this,"gem",null);let a;this.i=e,this.container.x=10,this.container.y=e*(u.GridCellSize+6)+300,this.background=new $({texture:C.Frame01Texture}),n==null&&!r?a=C.PlusIconTexture:r=="SELL"?a=C.GoldTexture:r=="UPGRADE"?a=C.PlusIconTexture:(a=n.texture,this.gem=n),this.iconSprite=new $({texture:a,zIndex:10}),this.background.width=u.GridCellSize,this.background.height=u.GridCellSize,n==null&&!r?(this.iconSprite.x=u.GridCellSize/2,this.iconSprite.y=u.GridCellSize/2,this.iconSprite.width=u.GridCellSize/2,this.iconSprite.height=u.GridCellSize/2,this.iconSprite.anchor.set(.5,.5)):r=="SELL"?(this.iconSprite.x=4,this.iconSprite.y=4,this.iconSprite.width=u.GridCellSize-8,this.iconSprite.height=u.GridCellSize-8):r=="UPGRADE"?(this.iconSprite.x=u.GridCellSize/2,this.iconSprite.y=u.GridCellSize/2,this.iconSprite.width=u.GridCellSize/2,this.iconSprite.height=u.GridCellSize/2,this.iconSprite.tint=3012919,this.iconSprite.anchor.set(.5,.5)):(this.iconSprite.x=4,this.iconSprite.y=4,this.iconSprite.width=u.GridCellSize-8,this.iconSprite.height=u.GridCellSize-8),this.frame=new $({texture:C.Frame05Texture,width:64,height:64}),this.container.addChild(this.background),this.container.addChild(this.iconSprite),this.container.addChild(this.frame);let o=n?n.level:"",h=new N({text:o,zIndex:11,style:{fill:"white",stroke:{color:0,width:5}}});this.container.addChild(h),s.addChild(this.container)}setTint(e){this.frame.tint=e}resetTint(){this.frame.tint=16777215}}class Od extends At{constructor(e){super(!1);p(this,"bounds");p(this,"towerPanel");p(this,"closeBtn");p(this,"vGems",[]);p(this,"showingTower",null);p(this,"isShown",!1);p(this,"titleText");p(this,"damageText");p(this,"totalDamage");p(this,"attackSpeedText");p(this,"fireResDamage");p(this,"iceResDamage");p(this,"frostFireResDamage");p(this,"divineResDamage");p(this,"physicalResDamage");p(this,"sellButton");this.bounds=e,this.towerPanel=new _t({texture:C.Frame03Texture,leftWidth:100,topHeight:100,rightWidth:100,bottomHeight:100}),this.towerPanel.width=this.bounds.width,this.towerPanel.height=this.bounds.height-this.bounds.height/3.5,this.closeBtn=new ut(new I(-20,-20,60,60),"",ht.Button01,!0),this.closeBtn.container.removeFromParent(),this.closeBtn.CustomButtonLogic=()=>{this.closeBtn.buttonIcon=new $({texture:C.XIconTexture,x:this.closeBtn.container.width/2,y:this.closeBtn.container.height/2,scale:.2}),this.closeBtn.buttonIcon.anchor.set(.5,.5),this.closeBtn.container.addChild(this.closeBtn.buttonIcon)},this.closeBtn.onClick=()=>{this.Hide()},this.Hide(),this.closeBtn.CustomButtonLogic(),this.container.y=u.app.canvas.height/2-u.app.canvas.height/2.7,this.container.addChild(this.towerPanel),this.container.addChild(this.closeBtn.container),u.GameMaster.currentScene.stage.addChild(this.container),this.titleText=new N({x:this.bounds.width/3,y:50,zIndex:5,style:new W({fill:16777215,fontSize:25,stroke:{color:0,width:2}})}),this.titleText.anchor.set(.5,0),this.container.addChild(this.titleText),this.damageText=new N({x:10,y:100,zIndex:5,style:new W({fill:16753920,fontSize:18,stroke:{color:0,width:2}})}),this.container.addChild(this.damageText),this.attackSpeedText=new N({x:100,y:100,zIndex:5,style:new W({fill:16777215,fontSize:18,stroke:{color:0,width:2}})}),this.container.addChild(this.attackSpeedText),this.totalDamage=new N({x:10,y:130,zIndex:5,style:new W({fill:16711680,fontSize:18,stroke:{color:0,width:2}})}),this.container.addChild(this.totalDamage),this.fireResDamage=new N({x:10,y:170,zIndex:5,style:new W({fill:16536403,fontSize:18,stroke:{color:0,width:2}})}),this.container.addChild(this.fireResDamage),this.iceResDamage=new N({x:10,y:190,zIndex:5,style:new W({fill:3335420,fontSize:18,stroke:{color:0,width:2}})}),this.container.addChild(this.iceResDamage),this.frostFireResDamage=new N({x:10,y:210,zIndex:5,style:new W({fill:14111740,fontSize:18,stroke:{color:0,width:2}})}),this.container.addChild(this.frostFireResDamage),this.divineResDamage=new N({x:10,y:230,zIndex:5,style:new W({fill:16576083,fontSize:18,stroke:{color:0,width:2}})}),this.container.addChild(this.divineResDamage),this.physicalResDamage=new N({x:10,y:250,zIndex:5,style:new W({fill:16777215,fontSize:18,stroke:{color:0,width:2}})}),this.container.addChild(this.physicalResDamage),this.sellButton=new ut(new I(5,this.towerPanel.height-70,this.towerPanel.width-115,60),"Sell",ht.Button02,!0),this.sellButton.container.removeFromParent(),this.container.addChild(this.sellButton.container)}MakeSlots(e){this.vGems.forEach(n=>{n.destroy()}),this.vGems=[];let s=e.definition.stats.gemSlotsAmount;for(let n=0;n{r&&(u.GameScene.tooltip.SetContentGem(r),u.GameScene.tooltip.Show(u.MouseX,u.MouseY))},a.container.onpointerleave=()=>{u.GameScene.tooltip.Hide()},a.onClick=()=>{u.GameScene.tooltip.Hide(),console.warn("EMITTING TOWER PANEL SELECT GEM",r,a.i,n,e),u.GameScene.events.emit(Vs.TowerPanelSelectGem,r,a.i,e),!r&&u.GameScene.sidebar.gemTab.isSelectingGem?a.setTint(65535):a.resetTint()}}}Show(e){this.isShown=!0,Ot(e),this.SetContent(e),this.MakeSlots(e),this.showingTower=e,u.GameScene.sidebar.gemTab.selectingGemTowerObject=e,e.container.parent.x<1270?this.ShowRight():this.ShowLeft(),e.parent.showRangePreview(!1,e.computedRange)}SetContent(e){this.titleText.text=e.definition.name,this.damageText.text="Deals "+e.computedDamageToDeal+" damage",this.totalDamage.text="Damage dealt: "+e.damageDealt+" damage",this.attackSpeedText.x=this.damageText.width+10,this.attackSpeedText.text=` every ${Math.floor(e.computedCooldown/1e3*100)/100}s`,this.fireResDamage.text=`+${e.totalGemResistanceModifications.fire*100}% Fire damage`,this.iceResDamage.text=`+${e.totalGemResistanceModifications.ice*100}% Ice damage`,this.frostFireResDamage.text=`+${e.totalGemResistanceModifications.frostfire*100}% FrostFire damage`,this.divineResDamage.text=`+${e.totalGemResistanceModifications.divine*100}% Divine damage`,this.physicalResDamage.text=`+${e.totalGemResistanceModifications.physical*100}% Physical damage`,this.sellButton.setCaption("Sell for "+e.definition.stats.cost+" gold"),this.sellButton.onClick=()=>{e.Sell(),this.Hide()}}ShowLeft(){this.towerPanel.x=-100,this.container.x=0,this.container.alpha=1,this.closeBtn.container.x=this.bounds.width-150}ShowRight(){this.towerPanel.x=-10,this.container.x=Yt.SidebarRect.x-210,this.closeBtn.container.x=-20,this.container.alpha=1}Hide(){this.isShown=!1,this.container.alpha=0,this.container.x=-1e3,u.Grid.rangePreview.clear()}}class Wd extends At{constructor(e){super(!1);p(this,"bounds");p(this,"gemTabSprite");p(this,"vGems",[]);p(this,"isSelectingGem",!1);p(this,"selectingGemSlotIndex",-1);p(this,"selectingGemTowerObject",null);p(this,"isDragAndDroppingGem",!1);p(this,"dragAndDroppingGem",null);this.bounds=e,this.container.x=this.bounds.x,this.container.y=this.bounds.y,this.gemTabSprite=new _t({texture:C.FrameTowerTab,leftWidth:1e3,topHeight:1e3,rightWidth:1e3,bottomHeight:1e3}),this.gemTabSprite.x=0,this.gemTabSprite.y=0,this.gemTabSprite.width=this.bounds.width,this.gemTabSprite.height=this.bounds.height,this.container.addChild(this.gemTabSprite),u.app.canvas.addEventListener("pointermove",()=>{this.pointerMoveEvent()}),u.GameScene.events.on($s.GemGivenEvent,()=>{this.RebuildInventoryVisual()})}TowerPanelSelectingGem(e,s,n){console.log("TOWER PANEL SELECTING GEM "+s),s<0&&console.error("TOWER PANEL SELECTING GEM INDEX IS LESS THAN 0, ",s),this.isSelectingGem?e==null&&(this.isSelectingGem=!1,this.selectingGemSlotIndex=-1,this.selectingGemTowerObject=null):(this.isSelectingGem=!0,e==null?(u.NotificationManager.Notify("Click on any Gem in your inventory to slot it into this Gem slot.","info"),this.selectingGemSlotIndex=s,this.selectingGemTowerObject=n):(n.UnslotGem(s),this.RebuildInventoryVisual(),u.GameScene.towerPanel.Hide(),u.GameScene.towerPanel.Show(n),this.isSelectingGem=!1,this.selectingGemSlotIndex=-1,this.selectingGemTowerObject=null))}pointerMoveEvent(){!this.isDragAndDroppingGem||!this.dragAndDroppingGem||(this.dragAndDroppingGem.container.x=u.MouseX-32,this.dragAndDroppingGem.container.y=u.MouseY-32)}isOverlappingGemsmith(e,s,n){let r=e.copyContainerToBB(),a=s.copyContainerToBB(),o=n.x+a.x+u.GameScene.sidebar.container.x,h=n.y+a.y+u.GameScene.sidebar.container.y,l=new I(o,h,a.width,a.height);if(r.getBounds().intersects(l)&&s&&s.gem==null)return!0}RebuildInventoryVisual(){this.vGems.forEach(e=>e.destroy()),this.vGems=[],u.GameScene.MissionStats.getInventory().forEach((e,s)=>{let n=new Ze(0,this.container,e),r=10,a=s%4*70+10,o=s;for(;!(o<=3);)r+=66,o-=4;n.container.x=a,n.container.y=r,n.container.onpointermove=()=>{e==null||this.isDragAndDroppingGem||(u.GameScene.tooltip.SetContentGem(e),u.GameScene.tooltip.Show(u.MouseX,u.MouseY))},n.container.onpointerleave=()=>{u.GameScene.tooltip.Hide()},n.container.onpointerdown=()=>{if(u.GameScene.tooltip.Hide(),this.isSelectingGem){this.isSelectingGem=!1;let h=u.GameScene.MissionStats.takeGem(e);this.selectingGemTowerObject.SlotGem(h,this.selectingGemSlotIndex),this.RebuildInventoryVisual()}else this.isDragAndDroppingGem=!0,this.dragAndDroppingGem=n,n.container.removeFromParent(),u.GameScene.stage.addChild(n.container),this.pointerMoveEvent()},n.container.onpointerup=()=>{if(this.isSelectingGem)return;let h=null;if(this.isOverlappingGemsmith(this.dragAndDroppingGem,u.GameScene.sidebar.gemsmith.sellVGem,u.GameScene.sidebar.gemsmith.container)){let d=this.dragAndDroppingGem.gem.definition.initialGemValue+this.dragAndDroppingGem.gem.currentGemImprovement().gemValueUp;u.GameScene.MissionStats.earnGold(Math.ceil(d*.8)),u.NotificationManager.Notify(`Sold Lv. ${this.dragAndDroppingGem.gem.level} ${this.dragAndDroppingGem.gem.definition.name} for ${Math.ceil(d*.8)} gold.`,"info"),u.GameScene.MissionStats.takeGem(this.dragAndDroppingGem.gem),this.isDragAndDroppingGem=!1,this.dragAndDroppingGem=null,this.RebuildInventoryVisual();return}if(this.isOverlappingGemsmith(this.dragAndDroppingGem,u.GameScene.sidebar.gemsmith.upgradeVGem,u.GameScene.sidebar.gemsmith.container)){if(this.dragAndDroppingGem.gem.isMaxLevel())u.NotificationManager.Notify("Gem is max level.","warn");else{let d=this.dragAndDroppingGem.gem.definition.genericImprovements[this.dragAndDroppingGem.gem.level].gemValueUp;u.GameScene.MissionStats.hasEnoughGold(d)?(u.GameScene.MissionStats.spendGold(d),this.dragAndDroppingGem.gem.levelUp(1),u.NotificationManager.Notify(`Spent ${d} gold to upgrade ${this.dragAndDroppingGem.gem.definition.name} Lv. ${this.dragAndDroppingGem.gem.level-1} -> Lv. ${this.dragAndDroppingGem.gem.level}!`,"warn")):u.NotificationManager.Notify("You don't have enough, you need "+d+" gold to upgrade this gem.","warn")}this.isDragAndDroppingGem=!1,this.dragAndDroppingGem=null,this.RebuildInventoryVisual();return}if(u.GameScene.towerPanel.vGems.forEach(d=>{if(h||!this.dragAndDroppingGem)return;let f=this.dragAndDroppingGem.copyContainerToBB(),g=d.copyContainerToBB(),m=u.GameScene.towerPanel.container.x+g.x,y=u.GameScene.towerPanel.container.y+g.y,x=new I(m,y,g.width,g.height);f.getBounds().intersects(x)&&d&&d.gem==null&&(h=d)}),h){let d=u.GameScene.MissionStats.takeGem(e);u.GameScene.towerPanel.showingTower.SlotGem(d,h.i)}this.isDragAndDroppingGem=!1,this.dragAndDroppingGem=null,this.RebuildInventoryVisual()},this.vGems.push(n)})}}class Hd extends At{constructor(e){super(!1);p(this,"bounds");p(this,"sellVGem");p(this,"upgradeVGem");this.bounds=e,this.container.x=this.bounds.x,this.container.y=this.bounds.y;let s=new $({x:0,y:0,width:this.bounds.width,height:this.bounds.height,texture:C.BannerGemsmith});this.container.addChild(s);let n=new N({x:40,y:this.bounds.height/6.5,text:"Sell gem",style:new W({fill:16767744,fontSize:18,stroke:{color:0,width:2}})});this.container.addChild(n);let r=new N({x:155,y:this.bounds.height/6.5,text:"Upgrade gem",style:new W({fill:3012919,fontSize:18,stroke:{color:0,width:2}})});this.container.addChild(r),this.sellVGem=new Ze(0,this.container,null,"SELL"),this.sellVGem.container.x=45,this.sellVGem.container.y=this.bounds.height/4,this.upgradeVGem=new Ze(0,this.container,null,"UPGRADE"),this.upgradeVGem.container.x=180,this.upgradeVGem.container.y=this.bounds.height/4}}class $d extends At{constructor(e){super(!1);p(this,"towerTab");p(this,"gemTab");p(this,"gemsmith");p(this,"bounds");p(this,"sidebarSprite");this.bounds=e,this.container.x=this.bounds.x,this.container.y=this.bounds.y,this.sidebarSprite=new _t({texture:C.Frame01Texture,leftWidth:100,topHeight:100,rightWidth:100,bottomHeight:100}),this.sidebarSprite.x=40,this.sidebarSprite.y=-40,this.sidebarSprite.width=this.bounds.width+40,this.sidebarSprite.height=this.bounds.height+80,this.container.addChild(this.sidebarSprite);const s=new I(60,20,this.bounds.width-65,150);this.towerTab=new Nd(s),this.container.addChild(this.towerTab.container);const n=new I(60,180,this.bounds.width-65,this.bounds.height-280-255);this.gemTab=new Wd(n),this.container.addChild(this.gemTab.container);const r=new I(60,185+n.height,this.bounds.width-65,this.bounds.height-840);this.gemsmith=new Hd(r),this.container.addChild(this.gemsmith.container)}}class Vd extends Mt{constructor(e,s){super();p(this,"hp",100);p(this,"gold",0);p(this,"goldEarned",0);p(this,"goldSpent",0);p(this,"wavesSurvived",0);p(this,"damageDealt",0);p(this,"creepsKilled",0);p(this,"goldText");p(this,"healthText");p(this,"waveText");p(this,"inventory",[]);this.hp=e,this.gold=s,this.container.x=0,this.container.y=20,u.GameMaster.currentScene.stage.addChild(this.container),this.healthText=new N({text:`${this.hp}`,style:new W({fill:"red",fontSize:36,fontWeight:"bold",dropShadow:!0})}),this.goldText=new N({text:`${this.gold}`,style:new W({fill:"gold",fontSize:36,fontWeight:"bold",dropShadow:!0})}),this.waveText=new N({text:`0/${u.GameScene.mission.rounds.length}`,style:new W({fill:"dodgerblue",fontSize:36,fontWeight:"bold",dropShadow:!0})});const n=new $(C.HealthTexture),r=new $(C.GoldTexture),a=new $(C.WaveTexture);this.healthText.x=200,this.healthText.y=-15,n.x=160,n.width=36,n.height=32,n.y=-10,this.goldText.x=200,this.goldText.y=20,r.x=150,r.width=56,r.height=56,r.y=15,this.waveText.x=200,this.waveText.y=55,a.x=155,a.width=46,a.height=32,a.y=65,this.container.addChild(this.healthText),this.container.addChild(this.goldText),this.container.addChild(this.waveText),this.container.addChild(n),this.container.addChild(r),this.container.addChild(a),u.GameScene.events.on(re.NewWave,o=>{this.waveText.text=`${o}/${u.GameScene.mission.rounds.length}`})}getHP(){return this.hp}hasEnoughGold(e){return e<=this.gold}setHP(e){this.hp=e,this.healthText.text=this.hp}takeDamage(e){this.hp-=e,this.healthText.text=this.hp}setGold(e){this.gold=e,this.goldText.text=this.gold}earnGold(e){this.gold+=e,this.goldText.text=this.gold}spendGold(e){this.gold-=e,this.goldText.text=this.gold}giveGem(e,s){if(this.inventory.length>=32)return u.NotificationManager.Notify("Can't hold more than 32 Gems. Extra Gem was thrown away.","danger");this.inventory.push(e),s||u.NotificationManager.Notify(`Lv. ${e.level} ${e.definition.name} added to your inventory.`,"gemaward"),u.GameScene.events.emit($s.GemGivenEvent,e)}takeGem(e){return this.inventory.splice(this.inventory.indexOf(e),1)[0]}getInventory(){return this.inventory}checkIfPlayerHasAnyGems(){return this.inventory.length>0}getStats(){return{hp:this.hp,gold:this.gold,wavesSurvived:this.wavesSurvived,goldEarned:this.goldEarned,goldSpent:this.goldSpent,score:this.calculateScore()}}calculateScore(){const e=[];for(const s of this.inventory)e.includes(s.definition.name)||e.push(s.definition.name);return this.damageDealt*2+this.hp*10+(this.goldEarned-this.goldSpent)*3+this.wavesSurvived*100+e.length*100}update(){}}class Yd extends At{constructor(e){super(!1);p(this,"bounds");p(this,"tooltipSprite");p(this,"titleText");p(this,"costText");p(this,"damageText");p(this,"gemAmount");p(this,"gemAmountSprite");p(this,"title");p(this,"costSprite");p(this,"damageSprite");p(this,"gemDescriptionText");this.bounds=e,this.container.x=-500,this.container.y=-500,this.container.zIndex=150,this.tooltipSprite=new _t({texture:C.Frame04Texture,leftWidth:200,topHeight:200,rightWidth:200,bottomHeight:200}),this.tooltipSprite.width=this.bounds.width,this.tooltipSprite.height=this.bounds.height,this.titleText=new N({x:this.tooltipSprite.width/2,y:-20,zIndex:5,style:new W({fill:16777215,stroke:{color:0,width:2}})}),this.titleText.anchor.set(.5,0),this.title=new $({x:this.tooltipSprite.width/2,y:-20,width:250,height:40,texture:C.TitleTexture}),this.title.anchor.set(.5,0),this.costSprite=new $({texture:C.GoldTexture,x:10,y:20,width:56,height:50}),this.costText=new N({x:54,y:26,zIndex:5,text:"Something went wrong if you see this.",style:{fill:"gold",fontWeight:"bold",stroke:{color:0,width:5}}}),this.damageText=new N({x:54,y:65,zIndex:5,text:"Something went wrong if you see this.",style:{fill:"red",fontWeight:"bold",stroke:{color:0,width:5}}}),this.damageSprite=new $({texture:C.SwordsTexture,x:22,y:70,width:32,height:32}),this.gemAmountSprite=new $({texture:C.GemAmountIcons[0],x:22,y:110,width:32,height:32}),this.gemAmount=new N({x:54,y:105,zIndex:5,text:"Something went wrong if you see this.",style:{fill:"white",fontWeight:"bold",stroke:{color:0,width:5}}}),this.gemDescriptionText=new N({x:10,y:20,text:"",style:{fontSize:18,wordWrap:!0,wordWrapWidth:this.tooltipSprite.width-30,fill:"white",fontWeight:"bold",fontStyle:"italic",stroke:{color:0,width:5}}}),this.container.addChild(this.tooltipSprite),this.container.addChild(this.title),this.container.addChild(this.costSprite),this.container.addChild(this.damageSprite),this.container.addChild(this.gemAmountSprite),this.container.addChild(this.costText),this.container.addChild(this.titleText),this.container.addChild(this.damageText),this.container.addChild(this.gemAmount),this.container.addChild(this.gemDescriptionText),u.app.stage.addChildAt(this.container,0)}SetContentTower(e,s,n,r){this.costSprite.alpha=1,this.damageSprite.alpha=1,this.gemAmountSprite.alpha=1,this.costText.alpha=1,this.damageText.alpha=1,this.gemAmount.alpha=1,this.gemDescriptionText.alpha=0,this.titleText.text=e,this.gemAmount.text=`Has ${r} Gem slots.`,this.gemAmountSprite.texture=C.GemAmountIcons[r],this.costText.text=`Costs ${n} gold.`,this.damageText.text=`Deals ${s} base damage.`}SetContentGem(e){this.costSprite.alpha=0,this.damageSprite.alpha=0,this.gemAmountSprite.alpha=0,this.costText.alpha=0,this.damageText.alpha=0,this.gemAmount.alpha=0,this.gemDescriptionText.alpha=1,this.titleText.text=`Lv. ${e.level} `+e.definition.name;let s;e.isMaxLevel()?s="Max level.":s=`Costs ${e.definition.genericImprovements[e.level].gemValueUp} gold to level up.`,this.gemDescriptionText.text=`${s} Valued at ${e.definition.initialGemValue+e.currentGemImprovement().gemValueUp} gold. `+e.definition.description}Show(e,s){this.container.alpha=1,e+this.container.width>u.app.canvas.width?this.container.x=e-this.container.width:this.container.x=e,this.container.y=s}Hide(){this.container.alpha=0,this.container.x=-500,this.container.y=-500}}const ft=class ft{static init(){window.addEventListener("keydown",ft.handleKeyDown)}static onKeyPressed(t){return ft.listeners=[...ft.listeners,t],()=>ft.offKey(t)}static offKey(t){const e=ft.listeners.indexOf(t);e>=0&&(ft.listeners=[...ft.listeners.slice(0,e),...ft.listeners.slice(e+1)])}static handleKeyDown(t){if(ft.listeners.length>0)for(let e=ft.listeners.length-1;e>=0&&(ft.listeners[e](t),!t.defaultPrevented);e--);}};p(ft,"listeners",[]);let Se=ft;class Bi extends At{constructor(e,s,n){super();p(this,"overlay");p(this,"buttonHeight",65);p(this,"buttonCaptions");p(this,"buttons",[]);p(this,"dialogContent");p(this,"dialogContainer");p(this,"background");p(this,"generated",!1);p(this,"escapeKeyButton");p(this,"enterKeyButton");p(this,"keyboardManagerUnsubscribe");p(this,"onClosed");if(this.buttonCaptions=e,n&&!e.includes(n))throw new Error(`Escape key button "${n}" not found in buttons: ${e}`);if(this.escapeKeyButton=n,s&&!e.includes(s))throw new Error(`Enter key button "${s}" not found in buttons: ${e}`);this.enterKeyButton=s,this.keyboardManagerUnsubscribe=Se.onKeyPressed(this.onKeyPress.bind(this))}show(){return this.generate(),`${Math.round(this.dialogContainer.x)}${Math.round(this.dialogContainer.y)}${Math.round(this.dialogContainer.width)}${Math.round(this.dialogContainer.height)}`,`${Math.round(this.dialogContent.x)}${Math.round(this.dialogContent.y)}${Math.round(this.dialogContent.width)}${Math.round(this.dialogContent.height)}`,new Promise((e,s)=>{u.app.stage.addChild(this.container),this.onClosed=n=>{this.destroy(),e(n)}})}createDialogBackground(){return new _t({texture:C.Frame04Texture,leftWidth:60,topHeight:60,rightWidth:60,bottomHeight:60})}getWidth(){}getHeight(){}generate(){if(this.generated)return;this.generated=!0,this.overlay=new Ct,this.overlay.rect(0,0,u.app.canvas.width,u.app.canvas.height),this.overlay.fill({color:0,alpha:.5}),this.overlay.interactive=!0,this.container.addChild(this.overlay);const e=this.buttonCaptions.map(l=>({caption:l,width:l.length*14+60,height:this.buttonHeight,click:()=>this.close(l)}));this.background=this.createDialogBackground(),this.dialogContent=this.createContent();let s=0;for(const l of e)s>0&&(s+=10),s+=l.width;const n=this.buttonCaptions.length>0?this.buttonHeight+10:0;let r=this.getWidth()||Math.max(s,this.dialogContent.width)+this.background.leftWidth+this.background.rightWidth,a=this.getHeight()||this.dialogContent.height+n+this.background.topHeight+this.background.bottomHeight;const o=new I(u.app.canvas.width/2-r/2,u.app.canvas.height/2-a/2,r,a);this.dialogContainer=new tt,this.dialogContainer.x=o.x,this.dialogContainer.y=o.y,this.background.width=r,this.background.height=a,this.dialogContainer.addChild(this.background),this.dialogContent.width0&&(r=s[0]),!n&&s.length>0&&(n=s[s.length-1]);super(s,n,r);p(this,"caption");this.caption=e}createContent(){return new N({text:this.caption,style:new W({fill:16777215,fontSize:24})})}static show(e,s,n=0){return new js(e,s).show()}}const Lt=class Lt{constructor(t){p(this,"missionName");p(this,"scores");this.missionName=t,this.scores=this.loadScores(),this.scores.sort((e,s)=>s.score-e.score||e.timestamp-s.timestamp)}loadScores(){const t=localStorage.getItem(Lt.STORAGE_KEY_PREFIX+this.missionName);return Lt.parseStoredScores(t)}saveScores(){localStorage.setItem(Lt.STORAGE_KEY_PREFIX+this.missionName,JSON.stringify(this.scores))}addScore(t){this.scores.push(t),this.scores.sort((e,s)=>s.score-e.score),this.scores.length>Lt.MAX_SCORES&&(this.scores.length=Lt.MAX_SCORES),this.saveScores()}getScores(){return this.scores}static parseStoredScores(t){if(!t)return[];try{const e=JSON.parse(t);if(Array.isArray(e)&&e.every(s=>typeof s.playerName=="string"&&typeof s.score=="number"&&typeof s.timestamp=="number"))return e.map(s=>({playerName:s.playerName,score:s.score,timestamp:s.timestamp}))}catch(e){console.error("Failed to parse stored scores:",e)}return[]}};p(Lt,"STORAGE_KEY_PREFIX","highscore_"),p(Lt,"MAX_SCORES",10);let Si=Lt;const Le={Confirm:"OK",Skip:"Skip"};class jd extends Bi{constructor(e,s,n){super([Le.Confirm,Le.Skip],Le.Confirm,Le.Skip);p(this,"dialogCaption");p(this,"playerNameTextInput");p(this,"lost");p(this,"highScore");p(this,"missionStats");this.lost=n,this.highScore=new Si(e),this.missionStats=s}generate(){super.generate(),this.dialogCaption=new N({text:this.lost?"You lost!":"You won!",style:new W({fill:16777215,fontSize:36,stroke:{color:0,width:2},dropShadow:{color:0,blur:8,distance:0}})}),this.dialogCaption.anchor.set(.5,.5),this.dialogCaption.x=this.dialogContainer.width/2,this.dialogCaption.y=50,this.dialogContainer.addChild(this.dialogCaption)}createDialogBackground(){return new _t({texture:C.EndScreenDialog,leftWidth:50,topHeight:100,rightWidth:50,bottomHeight:50})}createContent(){const e=new tt,s=35,n=this.createText("Mission details:","#fee",!0);e.addChild(n);const r=this.missionStats.getStats(),a=this.getWidth()-this.background.leftWidth-this.background.rightWidth-20,o=[this.createText("HP:"),this.createText("Gold:"),this.createText("Waves Survived:"),this.createText("Gold Earned:"),this.createText("Gold Spent:"),this.createText("----"),this.createText("Score:")],h=[this.createText(r.hp.toString(),"yellow"),this.createText(r.gold.toString(),"yellow"),this.createText(r.wavesSurvived.toString(),"yellow"),this.createText(r.goldEarned.toString(),"yellow"),this.createText(r.goldSpent.toString(),"yellow"),this.createText("----","yellow"),this.createText(r.score.toString(),"yellow")],l=300;for(let f=0;fthis.createText((f+1).toString()))],o=[this.createText("Player","#fee",!0),...r.map(d=>this.createText(d.playerName))],h=[this.createText("Score","#fee",!0),...r.map(d=>this.createText(d.score.toString()))],l=a.reduce((d,f)=>Math.max(d,f.width),0)+20,c=l+o.reduce((d,f)=>Math.max(d,f.width),0)+20;for(let d=0;d(i[i.Purchase=0]="Purchase",i[i.Combat=1]="Combat",i[i.Misc=2]="Misc",i))(Fa||{});class ve extends ki{constructor(e){super();p(this,"isGameOver",!1);p(this,"mission");p(this,"missionIndex");p(this,"MissionStats");p(this,"roundMode");p(this,"ticker");p(this,"changeRoundButton");p(this,"sidebar");p(this,"tooltip");p(this,"towerPanel");p(this,"isPaused",!1);p(this,"gameSpeedMultiplier",1);p(this,"pauseButton");p(this,"visualGems",[]);p(this,"currentRound",0);p(this,"isWaveManagerFinished",!1);p(this,"playerWon",!1);p(this,"destroyTicker",!1);p(this,"offerGemsSprite");p(this,"dimGraphics",new Ct({x:0,y:0,zIndex:120}));p(this,"windowTitle");u.GameScene=this,this.windowTitle=document.title,C.Missions.forEach((s,n)=>{s.name==e&&(this.mission=s,this.missionIndex=n)})}init(){u.latestGemId=0,new zd(this.mission.gameMap,this.missionIndex),new Sd,new Ud(this.mission.rounds,this.mission.gameMap.paths),u.Grid.onGridCellClicked=(e,s)=>{u.TowerManager.isPlacingTower&&u.TowerManager.PlayerClickOnGrid(e,s)},u.WaveManager.events.on(re.CreepSpawned,e=>{u.Grid.addCreep(e),e.events.on(ot.Escaped,()=>{this.onCreepEscaped(e)})}),u.WaveManager.events.on(re.Finished,()=>{this.isWaveManagerFinished=!0}),this.events.on(ot.Died,(e,s)=>{this.MissionStats.earnGold(e)}),this.towerPanel=new Od(Yt.SidebarRect),this.sidebar=new $d(Yt.SidebarRect),this.changeRoundButton=new ut(Yt.ChangeRoundButtonRect,"",ht.Button01,!0),this.changeRoundButton.container.removeFromParent(),this.sidebar.container.addChild(this.changeRoundButton.container),u.GameMaster.currentScene.stage.addChildAt(this.dimGraphics,0),this.tooltip=new Yd(new I(0,0,350,160)),this.changeRoundButton.CustomButtonLogic=()=>{this.changeRoundButton.buttonIcon=new $({texture:C.PlayIconTexture,x:this.changeRoundButton.container.width/2,y:this.changeRoundButton.container.height/2,scale:.2}),this.changeRoundButton.buttonIcon.anchor.set(.5,.5),this.changeRoundButton.container.addChild(this.changeRoundButton.buttonIcon)},this.changeRoundButton.CustomButtonLogic(),this.changeRoundButton.onClick=()=>{if(this.playerWon)return this.ReturnToMain();if(this.roundMode==1){this.gameSpeedMultiplier!==1?this.UpdateGameSpeedMultiplier(1):this.UpdateGameSpeedMultiplier(2);return}this.roundMode!=2&&(this.setRoundMode(1),this.changeRoundButton.buttonIcon.texture=C.FastForwardIconTexture,this.events.emit(re.NewWave,`${this.currentRound+1}`))},this.MissionStats=new Vd(100,250),this.events.on(Vs.TowerPanelSelectGem,(e,s,n)=>{if(e==null&&!this.MissionStats.checkIfPlayerHasAnyGems())return u.NotificationManager.Notify("You require atleast 1 Gem in your inventory to slot it in a Gem slot.","warn");this.sidebar.gemTab.TowerPanelSelectingGem(e,s,n)}),this.pauseButton=new ut(new I(5,5,120,80),"",ht.Button01,!0),this.pauseButton.container.removeFromParent(),this.stage.addChild(this.pauseButton.container),this.pauseButton.CustomButtonLogic=()=>{this.pauseButton.buttonIcon=new $({texture:C.PauseIconTexture,x:this.pauseButton.container.width/2,y:this.pauseButton.container.height/2,scale:.2}),this.pauseButton.buttonIcon.anchor.set(.5,.5),this.pauseButton.container.addChild(this.pauseButton.buttonIcon)},this.pauseButton.CustomButtonLogic(),this.pauseButton.onClick=()=>{this.isPaused?this.UnpauseGame():(this.ShowPauseDialog(),this.PauseGame())},this.ticker=new It,this.ticker.maxFPS=60,this.ticker.minFPS=30,this.tooltip.SetContentTower(0,0,0,0),this.tooltip.Show(u.MouseX,u.MouseY),this.tooltip.Hide(),this.ticker.add(()=>{this.update&&this.update(this.ticker.elapsedMS)}),this.ticker.start()}update(e){if(this.isGameOver){this.destroyTicker&&(this.destroyTicker=!1,this.ticker.destroy());return}u.WaveManager.update(e),u.Grid.update(e),u.TowerManager.update(e),this.isWaveManagerFinished&&u.Grid.creeps.length==0&&(this.isWaveManagerFinished=!1,this.setRoundMode(0),this.changeRoundButton.buttonIcon.texture=C.PlayIconTexture,u.NotificationManager.Notify(`Round ${this.currentRound+1}/${this.mission.rounds.length} completed.`,"info"),this.currentRound+1==this.mission.rounds.length?(u.NotificationManager.Notify("Mission victory!!","reward"),this.playerWon=!0):(this.OfferPlayerGems(),this.currentRound++)),this.MissionStats.getHP()<=0?(this.isGameOver=!0,this.ShowEndgameDialog(!0)):this.playerWon&&(this.isGameOver=!0,this.ShowEndgameDialog(!1))}DarkenScreen(){this.dimGraphics.rect(0,0,u.app.canvas.width,u.app.canvas.height),this.dimGraphics.fill({color:0,alpha:.5})}UndarkenScreen(){this.dimGraphics.clear()}OfferPlayerGems(){u.Grid.gridInteractionEnabled=!1,u.GameScene.sidebar.towerTab.resetTint(),u.TowerManager.ResetChooseTower(),this.setRoundMode(2);let e=this.mission.rounds[this.currentRound].offeredGems;this.DarkenScreen(),this.offerGemsSprite=new _t({width:380,height:150,texture:C.Frame01Texture,leftWidth:100,topHeight:100,rightWidth:100,bottomHeight:100,zIndex:this.dimGraphics.zIndex+1,x:u.app.canvas.width/2-190,y:u.app.canvas.height/2-75}),u.GameMaster.currentScene.stage.addChildAt(this.offerGemsSprite,0);let s=new N({x:u.app.canvas.width/4,y:u.app.canvas.height/4,zIndex:this.dimGraphics.zIndex+1,text:"Choose a Gem as your reward for beating this round!",style:{fontSize:40,fill:"orange",fontWeight:"bold",stroke:{color:0,width:5}}});u.GameMaster.currentScene.stage.addChildAt(s,0),e.forEach((n,r)=>{let a=new Ps(n,!0),o=new Ze(0,u.app.stage,a);this.visualGems.push(o),o.container.x=this.offerGemsSprite.x-15+69*(r+1),o.container.y=this.offerGemsSprite.y+40,o.container.onpointermove=()=>{u.GameScene.tooltip.SetContentGem(a),u.GameScene.tooltip.Show(u.MouseX,u.MouseY)},o.container.onpointerleave=()=>{u.GameScene.tooltip.Hide()},o.onClick=()=>{u.GameScene.tooltip.Hide(),s.destroy(),this.PlayerPickedGem(new Ps(n))}})}PlayerPickedGem(e){this.offerGemsSprite.destroy(),this.UndarkenScreen(),this.visualGems.forEach(s=>s.destroy()),u.Grid.gridInteractionEnabled=!0,this.MissionStats.giveGem(e),this.setRoundMode(0)}PauseGame(){this.isPaused=!0,this.ticker.stop(),document.title="[PAUSED] "+this.windowTitle}UnpauseGame(){this.isPaused=!1,this.ticker.start(),document.title=this.windowTitle}ShowPauseDialog(){new Kd().show()}async ShowEndgameDialog(e){await new jd(this.mission.name,this.MissionStats,e).show();const r=await new qd(this.mission.name,e,!e&&this.missionIndex+1{u.GameMaster.changeScene(new qs)},C.Missions.forEach((e,s)=>{const n=new ut(new I(u.app.canvas.width/2-150,400+s*70,300,60),e.name,ht.Button01);n.onClick=r=>{u.GameMaster.changeScene(new ve(e.name))}})}}class qs extends ki{init(){this.addMainBackground();const t={caption:"Play",rect:new I(u.app.canvas.width/2-300/2,400+0*70,300,60),texture:ht.Button01},e={caption:"How to play",rect:new I(u.app.canvas.width/2-300/2,400+1*70,300,60),texture:ht.Button01};new I(u.app.canvas.width/2-300/2,400+2*70,300,60),ht.Button01;let s=new N({x:0,y:0,text:"Latest commit: "+u.latestCommit,style:{fill:16777215,fontSize:10,fontWeight:"bold"}});this.stage.addChild(s);const n=new ut(t.rect,t.caption,t.texture,!0);n.onClick=a=>{u.GameMaster.changeScene(new ge)};let r=new ut(e.rect,e.caption,e.texture,!0);r.onClick=a=>{u.GameMaster.changeScene(new bd)}}}class Zd{constructor(){p(this,"finished",!1);p(this,"calledBack",!1);p(this,"callbackFn")}Finish(){this.finished=!0}update(t){this.finished}}class Qd extends Zd{constructor(e,s,n,r){super();p(this,"fadeType");p(this,"fadeTime");p(this,"pixiObject");p(this,"ticks",0);this.fadeType=e,this.fadeTime=s,this.pixiObject=n,this.callbackFn=r,e=="in"?this.pixiObject.alpha=0:this.pixiObject.alpha=1}update(e){if(super.update(e),this.pixiObject==null)return this.Finish();this.ticks++,this.fadeType=="in"?this.pixiObject.alpha=this.ticks/this.fadeTime:this.pixiObject.alpha-=1/this.fadeTime,this.ticks>=this.fadeTime&&this.Finish()}}class Jd{constructor(){p(this,"AnimationQueue",[])}Animate(t){this.AnimationQueue.push(t)}update(t){for(let e=this.AnimationQueue.length-1;e>=0;e--){const s=this.AnimationQueue[e];s.finished?(s.callbackFn(),this.AnimationQueue.splice(e,1)):s.update(t)}}}class tu{constructor(t,e,s,n,r){p(this,"textObj");p(this,"ticksToFadeAway");p(this,"animating",!1);p(this,"destroyed",!1);let a=16777215;e=="info"?a=2143228:e=="warn"?a=16570144:e=="danger"?a=16517642:e=="reward"?a=14047996:e=="gemaward"?a=16777215:e=="green"&&(a=65280),this.ticksToFadeAway=r,this.textObj=new N({text:t,style:new W({fill:a,fontSize:36,fontWeight:"bold",dropShadow:!0,align:"center"}),x:s,y:n,zIndex:100}),this.textObj.anchor.set(.5,.5),u.NotificationManager.container.addChild(this.textObj)}destroy(){this.textObj.destroy(),this.destroyed=!0}}class eu extends Mt{constructor(){super();p(this,"notifications",[]);p(this,"ticks",0);this.bb.x=u.app.canvas.width/2,this.bb.y=40,this.copyBBToContainer(),this.container.zIndex=200,u.app.stage.addChild(this.container)}Notify(e,s){let n=0,r=this.notifications.length*32;this.notifications.push(new tu(e,s,n,r,this.ticks+180))}update(e){this.ticks++;for(let s=this.notifications.length-1;s>=0;s--){const n=this.notifications[s];if(n.destroyed){this.notifications.splice(s,1);continue}this.ticks>=n.ticksToFadeAway&&!n.animating&&(n.animating=!0,u.AnimationManager.Animate(new Qd("out",300,n.textObj,()=>{n.destroy()})))}}}class iu{constructor(t,e){p(this,"ticksToDestroyAt");p(this,"debris");this.debris=t,this.ticksToDestroyAt=e}destroy(){this.debris.destroy()}update(t){this.debris instanceof Mt&&this.debris.update(t)}}class su extends Mt{constructor(){super(...arguments);p(this,"ticks",0);p(this,"debris",[])}update(e){this.ticks++;for(let s=this.debris.length-1;s>=0;s--){const n=this.debris[s];this.ticks>=n.ticksToDestroyAt?(n.destroy(),this.debris.splice(s,1)):n.update(e)}}CreateDebris(e,s){s||(s=120),this.debris.push(new iu(e,this.ticks+s))}}(async()=>{const i=new Zr;u.app=i,await i.init({width:1920,height:1080,resolution:1,autoDensity:!0,backgroundColor:16777215,sharedTicker:!0}),document.body.appendChild(i.canvas);function t(){const n=window.innerWidth,r=window.innerHeight,a=n/i.screen.width,o=r/i.screen.height,h=Math.min(a,o),l=Math.round(i.screen.width*h),c=Math.round(i.screen.height*h),d=(n-l)/2,f=(r-c)/2;i.canvas.style.width=`${l}px`,i.canvas.style.height=`${c}px`,i.canvas.style.marginLeft=`${d}px`,i.canvas.style.marginTop=`${f}px`,i.canvas.style.marginRight="0",i.canvas.style.marginBottom="0",i.canvas.style.display="block"}u.latestCommit=await fetch("./latest_commit").then(n=>n.text()),window.addEventListener("resize",t),t(),await C.LoadAssets(),Yt.init(),Se.init(),new _d,u.AnimationManager=new Jd,u.NotificationManager=new eu,u.DebrisManager=new su,globalThis.Engine=u,It.shared.add(n=>{u.NotificationManager.update(n.elapsedMS),u.AnimationManager.update(n.elapsedMS),u.DebrisManager.update(n.elapsedMS)}),i.canvas.addEventListener("pointermove",function(n){u.MouseX=(n.clientX-i.canvas.offsetLeft)/i.canvas.offsetWidth*1920,u.MouseY=(n.clientY-i.canvas.offsetTop)/i.canvas.offsetHeight*1080}),u.GameMaster.changeScene(new qs),new URLSearchParams(location.href).entries().next().value[1]=="game"&&u.GameMaster.changeScene(new ve("The Turn")),u.latestCommit!="DEVELOPMENT"?window.onbeforeunload=()=>"You are about to leave.":u.TestSuite();let s=!1;window.addEventListener("blur",()=>{u.GameScene&&!u.GameScene.isPaused&&(u.GameScene.PauseGame(),s=!0)}),window.addEventListener("focus",()=>{u.GameScene&&s&&u.GameScene.isPaused&&(s=!1,u.GameScene.UnpauseGame())})})();export{U as $,Xr as A,it as B,tt as C,Q as D,G as E,pr as F,Ti as G,Et as H,mn as I,$ as J,Zo as K,ah as L,H as M,nt as N,I as O,lt as P,Ch as Q,ps as R,$h as S,Nt as T,yi as U,yn as V,ko as W,Wi as X,Y,mr as Z,jr as _,z as a,O as a0,Gh as a1,ra as a2,pl as a3,ml as a4,bl as a5,vl as a6,Cl as a7,xe as a8,W as a9,pc as aa,As as ab,da as ac,Mn as ad,ce as ae,md as af,Zn as ag,_c as ah,Ct as ai,q as aj,so as ak,Ts as al,qn as am,fa as an,It as b,gt as c,Vt as d,dt as e,An as f,Oh as g,pi as h,Is as i,$r as j,Ar as k,Nr as l,jn as m,nn as n,fl as o,gl as p,wl as q,mo as r,ta as s,Sl as t,Es as u,Lr as v,st as w,io as x,Al as y,zt as z}; diff --git a/assets/json/Creeps.json b/assets/json/Creeps.json index 90b9153..d1ad5fc 100644 --- a/assets/json/Creeps.json +++ b/assets/json/Creeps.json @@ -1,6 +1,7 @@ [ { "name": "basic", + "sprite": "wood", "textures": [], "textureArrayLength": 12, "stats": { @@ -18,6 +19,7 @@ }, { "name": "quick", + "sprite": "zombie", "textures": [], "textureArrayLength": 8, "stats": { @@ -35,6 +37,7 @@ }, { "name": "tank", + "sprite": "skeleton", "textures": [], "textureArrayLength": 12, "stats": { @@ -52,6 +55,7 @@ }, { "name": "cloaker", + "sprite": "hood", "textures": [], "textureArrayLength": 12, "stats": { @@ -69,6 +73,7 @@ }, { "name": "demon", + "sprite": "demon", "textures": [], "textureArrayLength": 8, "stats": { @@ -86,6 +91,7 @@ }, { "name": "maker", + "sprite": "pumpkin", "textures": [], "textureArrayLength": 11, "stats": { diff --git a/assets/json/Gems.json b/assets/json/Gems.json index 1407ee7..685f8f6 100644 --- a/assets/json/Gems.json +++ b/assets/json/Gems.json @@ -1,22 +1,22 @@ [ { "name": "Fire Gem", - "description": "Forged from molten lava, the Fire Gem imbues your tower's attacks and adds 50% extra fire damage. It can be merged with any gem and is common.", + "description": "Forged from molten lava, the Fire Gem imbues your tower's attacks and add extra fire damage. Well researched and common.", "color": "red", "type": "Fire", - "totalLevels": 2, + "totalLevels": 9, "textures": [], "cantCombineWith": [], "specialCombine": [], - "initialGemValue": 100, + "initialGemValue": 50, "genericImprovements": [ { - "damageUp": 2, + "damageUp": 1, "attackSpeedUp": 0, "rangeUp": 0, "timeToLiveUp": 0, - "pierceUp": 1, - "gemValueUp": 50 + "pierceUp": 0, + "gemValueUp": 100 }, { "damageUp": 2, @@ -24,10 +24,73 @@ "rangeUp": 0, "timeToLiveUp": 0, "pierceUp": 1, - "gemValueUp": 100 + "gemValueUp": 150 + }, + { + "damageUp": 2, + "attackSpeedUp": 0, + "rangeUp": 0, + "timeToLiveUp": 0, + "pierceUp": 1, + "gemValueUp": 250 + }, + { + "damageUp": 2, + "attackSpeedUp": 0, + "rangeUp": 0, + "timeToLiveUp": 0, + "pierceUp": 1, + "gemValueUp": 400 + }, + { + "damageUp": 2, + "attackSpeedUp": 0, + "rangeUp": 0, + "timeToLiveUp": 0, + "pierceUp": 1, + "gemValueUp": 650 + }, + { + "damageUp": 2, + "attackSpeedUp": 0, + "rangeUp": 0, + "timeToLiveUp": 0, + "pierceUp": 1, + "gemValueUp": 750 + }, + { + "damageUp": 2, + "attackSpeedUp": 0, + "rangeUp": 0, + "timeToLiveUp": 0, + "pierceUp": 1, + "gemValueUp": 900 + }, + { + "damageUp": 2, + "attackSpeedUp": 0, + "rangeUp": 0, + "timeToLiveUp": 0, + "pierceUp": 1, + "gemValueUp": 1000 + }, + { + "damageUp": 2, + "attackSpeedUp": 0, + "rangeUp": 0, + "timeToLiveUp": 0, + "pierceUp": 1, + "gemValueUp": 1200 } ], "gemResistanceModifications": [ + { + "physical": 0, + "divine": 0, + "fire": 0.05, + "ice": 0, + "frostfire": 0 + }, { "physical": 0, "divine": 0, @@ -35,26 +98,116 @@ "ice": 0, "frostfire": 0 }, + { + "physical": 0, + "divine": 0, + "fire": 0.15, + "ice": 0, + "frostfire": 0 + }, + { + "physical": 0, + "divine": 0, + "fire": 0.2, + "ice": 0, + "frostfire": 0 + }, { "physical": 0, "divine": 0, "fire": 0.25, "ice": 0, "frostfire": 0 + }, + { + "physical": 0, + "divine": 0, + "fire": 0.3, + "ice": 0, + "frostfire": 0 + }, + { + "physical": 0, + "divine": 0, + "fire": 0.35, + "ice": 0, + "frostfire": 0 + }, + { + "physical": 0, + "divine": 0, + "fire": 0.4, + "ice": 0, + "frostfire": 0 + }, + { + "physical": 0, + "divine": 0, + "fire": 0.45, + "ice": 0, + "frostfire": 0 } ] }, { "name": "Yeti Gem", - "description": "Yeti gem description. Something something, write this while drunk or something.", + "description": "Crafted from the essence of the frozen bears, the Yeti Gem enhances your tower's attacks with the chilling power of ice. It gives ice damage and is known for its rarity.", "color": "#32e4fc", "type": "Yeti", - "totalLevels": 2, + "totalLevels": 8, "textures": [], "cantCombineWith": [], "specialCombine": [], "initialGemValue": 10, "genericImprovements": [ + { + "damageUp": 2, + "attackSpeedUp": 10, + "rangeUp": 0, + "timeToLiveUp": 0, + "pierceUp": 1, + "gemValueUp": 0 + }, + { + "damageUp": 2, + "attackSpeedUp": 10, + "rangeUp": 0, + "timeToLiveUp": 0, + "pierceUp": 1, + "gemValueUp": 10 + }, + { + "damageUp": 2, + "attackSpeedUp": 10, + "rangeUp": 0, + "timeToLiveUp": 0, + "pierceUp": 1, + "gemValueUp": 0 + }, + { + "damageUp": 2, + "attackSpeedUp": 10, + "rangeUp": 0, + "timeToLiveUp": 0, + "pierceUp": 1, + "gemValueUp": 10 + }, + { + "damageUp": 2, + "attackSpeedUp": 10, + "rangeUp": 0, + "timeToLiveUp": 0, + "pierceUp": 1, + "gemValueUp": 0 + }, + { + "damageUp": 2, + "attackSpeedUp": 10, + "rangeUp": 0, + "timeToLiveUp": 0, + "pierceUp": 1, + "gemValueUp": 10 + }, { "damageUp": 2, "attackSpeedUp": 10, @@ -73,6 +226,48 @@ } ], "gemResistanceModifications": [ + { + "physical": 0, + "divine": 0, + "fire": 0, + "ice": 0.1, + "frostfire": 0 + }, + { + "physical": 0, + "divine": 0, + "fire": 0, + "ice": 0.2, + "frostfire": 0 + }, + { + "physical": 0, + "divine": 0, + "fire": 0, + "ice": 0.1, + "frostfire": 0 + }, + { + "physical": 0, + "divine": 0, + "fire": 0, + "ice": 0.2, + "frostfire": 0 + }, + { + "physical": 0, + "divine": 0, + "fire": 0, + "ice": 0.1, + "frostfire": 0 + }, + { + "physical": 0, + "divine": 0, + "fire": 0, + "ice": 0.2, + "frostfire": 0 + }, { "physical": 0, "divine": 0, @@ -91,10 +286,10 @@ }, { "name": "Titalium Gem", - "description": "Titalium gem description. Something something zombie creeps working for you something something.", + "description": "Created from distilled creep eyes, the Titalium gem is known for boosting tower range, at the sacrifice for other stats.", "color": "pink", "type": "Titalium", - "totalLevels": 3, + "totalLevels": 7, "textures": [], "cantCombineWith": [], "specialCombine": [], @@ -116,6 +311,14 @@ "pierceUp": 1, "gemValueUp": 10 }, + { + "damageUp": 2, + "attackSpeedUp": 10, + "rangeUp": 0, + "timeToLiveUp": 0, + "pierceUp": 1, + "gemValueUp": 0 + }, { "damageUp": 2, "attackSpeedUp": 10, @@ -123,35 +326,87 @@ "timeToLiveUp": 0, "pierceUp": 1, "gemValueUp": 10 + }, + { + "damageUp": 2, + "attackSpeedUp": 10, + "rangeUp": 0, + "timeToLiveUp": 0, + "pierceUp": 1, + "gemValueUp": 0 + }, + { + "damageUp": 2, + "attackSpeedUp": 10, + "rangeUp": 0, + "timeToLiveUp": 0, + "pierceUp": 1, + "gemValueUp": 10 + }, + { + "damageUp": 2, + "attackSpeedUp": 10, + "rangeUp": 0, + "timeToLiveUp": 0, + "pierceUp": 1, + "gemValueUp": 0 } ], "gemResistanceModifications": [ { - "physical": 0.1, + "physical": 0, "divine": 0, "fire": 0, - "ice": 0, + "ice": 0.1, "frostfire": 0 }, { - "physical": 0.1, + "physical": 0, "divine": 0, "fire": 0, - "ice": 0, + "ice": 0.2, "frostfire": 0 }, { - "physical": 0.25, + "physical": 0, "divine": 0, "fire": 0, - "ice": 0, + "ice": 0.1, + "frostfire": 0 + }, + { + "physical": 0, + "divine": 0, + "fire": 0, + "ice": 0.2, + "frostfire": 0 + }, + { + "physical": 0, + "divine": 0, + "fire": 0, + "ice": 0.1, + "frostfire": 0 + }, + { + "physical": 0, + "divine": 0, + "fire": 0, + "ice": 0.2, + "frostfire": 0 + }, + { + "physical": 0, + "divine": 0, + "fire": 0, + "ice": 0.1, "frostfire": 0 } ] }, { "name": "Soulforge Gem", - "description": "Soulforge gem description, have to write later.", + "description": "Made from the wandering souls of the damned, the Soulforge gem accelerates your towers cooldowns and acts as a repellant for all things unholy.", "color": "gray", "type": "Soulforge", "totalLevels": 2, @@ -160,6 +415,54 @@ "specialCombine": [], "initialGemValue": 10, "genericImprovements": [ + { + "damageUp": 2, + "attackSpeedUp": 10, + "rangeUp": 0, + "timeToLiveUp": 0, + "pierceUp": 1, + "gemValueUp": 0 + }, + { + "damageUp": 2, + "attackSpeedUp": 10, + "rangeUp": 0, + "timeToLiveUp": 0, + "pierceUp": 1, + "gemValueUp": 10 + }, + { + "damageUp": 2, + "attackSpeedUp": 10, + "rangeUp": 0, + "timeToLiveUp": 0, + "pierceUp": 1, + "gemValueUp": 0 + }, + { + "damageUp": 2, + "attackSpeedUp": 10, + "rangeUp": 0, + "timeToLiveUp": 0, + "pierceUp": 1, + "gemValueUp": 10 + }, + { + "damageUp": 2, + "attackSpeedUp": 10, + "rangeUp": 0, + "timeToLiveUp": 0, + "pierceUp": 1, + "gemValueUp": 0 + }, + { + "damageUp": 2, + "attackSpeedUp": 10, + "rangeUp": 0, + "timeToLiveUp": 0, + "pierceUp": 1, + "gemValueUp": 10 + }, { "damageUp": 2, "attackSpeedUp": 10, @@ -179,18 +482,120 @@ ], "gemResistanceModifications": [ { - "physical": 0.05, - "divine": 0.05, - "fire": 0.05, - "ice": 0.05, - "frostfire": 0.05 + "physical": 0, + "divine": 0, + "fire": 0, + "ice": 0.1, + "frostfire": 0 }, { - "physical": 0.05, - "divine": 0.05, - "fire": 0.05, - "ice": 0.05, - "frostfire": 0.05 + "physical": 0, + "divine": 0, + "fire": 0, + "ice": 0.2, + "frostfire": 0 + }, + { + "physical": 0, + "divine": 0, + "fire": 0, + "ice": 0.1, + "frostfire": 0 + }, + { + "physical": 0, + "divine": 0, + "fire": 0, + "ice": 0.2, + "frostfire": 0 + }, + { + "physical": 0, + "divine": 0, + "fire": 0, + "ice": 0.1, + "frostfire": 0 + }, + { + "physical": 0, + "divine": 0, + "fire": 0, + "ice": 0.2, + "frostfire": 0 + }, + { + "physical": 0, + "divine": 0, + "fire": 0, + "ice": 0.1, + "frostfire": 0 + }, + { + "physical": 0, + "divine": 0, + "fire": 0, + "ice": 0.2, + "frostfire": 0 + } + ] + }, + { + "name": "Golden Gem", + "description": "An inherently useless gem, providing no tower buffs, but high in monetary value. Highly sought after by all rich people.", + "color": "gold", + "type": "Gold", + "totalLevels": 1, + "textures": [], + "cantCombineWith": [], + "specialCombine": [], + "initialGemValue": 250, + "genericImprovements": [ + { + "damageUp": 0, + "attackSpeedUp": 0, + "rangeUp": 0, + "timeToLiveUp": 0, + "pierceUp": 0, + "gemValueUp": 0 + } + ], + "gemResistanceModifications": [ + { + "physical": 0, + "divine": 0, + "fire": 0, + "ice": 0, + "frostfire": 0 + } + ] + }, + { + "name": "Artifact", + "description": "An insanely rare gem of unknown origin, packed with power. No one knows how it works, yet your towers oddly resonate stronger with it.", + "color": "blue", + "type": "Artifact", + "totalLevels": 1, + "textures": [], + "cantCombineWith": [], + "specialCombine": [], + "initialGemValue": 1000, + "genericImprovements": [ + { + "damageUp": 10, + "attackSpeedUp": 100, + "rangeUp": 2, + "timeToLiveUp": 200, + "pierceUp": 20, + "gemValueUp": 0 + } + ], + "gemResistanceModifications": [ + { + "physical": 0.25, + "divine": 0.25, + "fire": 0.25, + "ice": 0.25, + "frostfire": 0.25 } ] } diff --git a/assets/json/Towers.json b/assets/json/Towers.json index e69c100..2d4b497 100644 --- a/assets/json/Towers.json +++ b/assets/json/Towers.json @@ -26,7 +26,7 @@ "projectile": "blue", "projectileTextures": [], "projectileTexturesArrayLength": 4, - "description": "If you feel a little circular.", + "description": "If you feel like shooting in a circle around you, projectiles may miss.", "stats": { "damage": 3, "cooldown": 4000, @@ -45,7 +45,7 @@ "projectile": "yellow", "projectileTextures": [], "projectileTexturesArrayLength": 4, - "description": "Zap zap zap!", + "description": "Zap zap zap! This towers shots connect to other enemies!", "stats": { "damage": 3, "cooldown": 3500, @@ -64,7 +64,7 @@ "projectile": "blue", "projectileTextures": [], "projectileTexturesArrayLength": 4, - "description": "", + "description": "Doesn't shoot, instead buffs other towers with 50% of its power.", "stats": { "damage": 4, "cooldown": 1000, @@ -83,7 +83,7 @@ "projectile": "white", "projectileTextures": [], "projectileTexturesArrayLength": 5, - "description": "", + "description": "Like a regular tower, just slows down creeps.", "stats": { "damage": 2, "cooldown": 2000, @@ -102,7 +102,7 @@ "projectile": "red", "projectileTextures": [], "projectileTexturesArrayLength": 4, - "description": "If you feel a little circular.", + "description": "Shoots a quick, high pierce rail projectile at creeps.", "stats": { "damage": 2, "cooldown": 2000, @@ -121,7 +121,7 @@ "projectile": "stone", "projectileTextures": [], "projectileTexturesArrayLength": 1, - "description": "If you feel a little circular.", + "description": "Randomly places traps on the track, instead of attacking creeps.", "stats": { "damage": 2, "cooldown": 2000, @@ -140,7 +140,7 @@ "projectile": "red", "projectileTextures": [], "projectileTexturesArrayLength": 4, - "description": "If you feel a little circular.", + "description": "On top of a regular attack, this tower gives creeps a debuff, making them take more damage.", "stats": { "damage": 2, "cooldown": 2000, diff --git a/assets/webworkerAll-Yj3NqXCQ.js b/assets/webworkerAll-Cp5jyL-l.js similarity index 99% rename from assets/webworkerAll-Yj3NqXCQ.js rename to assets/webworkerAll-Cp5jyL-l.js index 62d4967..234f36d 100644 --- a/assets/webworkerAll-Yj3NqXCQ.js +++ b/assets/webworkerAll-Cp5jyL-l.js @@ -1,4 +1,4 @@ -import{E as h,U as Xe,b as se,a8 as L,M as R,a2 as Ne,l as D,h as me,w as O,a as k,P as Qe,R as q,H as xe,Y as G,a9 as Y,aa as Je,ab as P,z as b,ac as Ze,ad as _e,ae as et,u as be,o as Te,a3 as ye,t as Se,a6 as ve,af as we,s as tt,p as rt,q as st,a4 as at,a5 as nt,a7 as it,ag as ot,ah as dt,ai as lt,aj as j,ak as K,D as Be,m as A,O as ae,$ as ut,al as ct,am as ne,n as ie,e as S,an as ht}from"./index-2UyWUVAY.js";import{T as w,S as Ce,c as X,a as ft,b as pt,B as Re}from"./colorToUniform-Bdgu2gC3.js";class Me{static init(e){Object.defineProperty(this,"resizeTo",{set(t){globalThis.removeEventListener("resize",this.queueResize),this._resizeTo=t,t&&(globalThis.addEventListener("resize",this.queueResize),this.resize())},get(){return this._resizeTo}}),this.queueResize=()=>{this._resizeTo&&(this._cancelResize(),this._resizeId=requestAnimationFrame(()=>this.resize()))},this._cancelResize=()=>{this._resizeId&&(cancelAnimationFrame(this._resizeId),this._resizeId=null)},this.resize=()=>{if(!this._resizeTo)return;this._cancelResize();let t,r;if(this._resizeTo===globalThis.window)t=globalThis.innerWidth,r=globalThis.innerHeight;else{const{clientWidth:s,clientHeight:n}=this._resizeTo;t=s,r=n}this.renderer.resize(t,r),this.render()},this._resizeId=null,this._resizeTo=null,this.resizeTo=e.resizeTo||null}static destroy(){globalThis.removeEventListener("resize",this.queueResize),this._cancelResize(),this._cancelResize=null,this.queueResize=null,this.resizeTo=null,this.resize=null}}Me.extension=h.Application;class Pe{static init(e){e=Object.assign({autoStart:!0,sharedTicker:!1},e),Object.defineProperty(this,"ticker",{set(t){this._ticker&&this._ticker.remove(this.render,this),this._ticker=t,t&&t.add(this.render,this,Xe.LOW)},get(){return this._ticker}}),this.stop=()=>{this._ticker.stop()},this.start=()=>{this._ticker.start()},this._ticker=null,this.ticker=e.sharedTicker?se.shared:new se,e.autoStart&&this.start()}static destroy(){if(this._ticker){const e=this._ticker;this.ticker=null,e.destroy()}}}Pe.extension=h.Application;class Ue{constructor(e){this._renderer=e}push(e,t,r){this._renderer.renderPipes.batch.break(r),r.add({renderPipeId:"filter",canBundle:!1,action:"pushFilter",container:t,filterEffect:e})}pop(e,t,r){this._renderer.renderPipes.batch.break(r),r.add({renderPipeId:"filter",action:"popFilter",canBundle:!1})}execute(e){e.action==="pushFilter"?this._renderer.filter.push(e):e.action==="popFilter"&&this._renderer.filter.pop()}destroy(){this._renderer=null}}Ue.extension={type:[h.WebGLPipes,h.WebGPUPipes,h.CanvasPipes],name:"filter"};const gt=new R;function mt(a,e){return e.clear(),ke(a,e),e.isValid||e.set(0,0,0,0),a.renderGroup?e.applyMatrix(a.renderGroup.localTransform):e.applyMatrix(a.parentRenderGroup.worldTransform),e}function ke(a,e){if(a.localDisplayStatus!==7||!a.measurable)return;const t=!!a.effects.length;let r=e;if((a.renderGroup||t)&&(r=L.get().clear()),a.boundsArea)e.addRect(a.boundsArea,a.worldTransform);else{if(a.renderPipeId){const n=a.bounds;r.addFrame(n.minX,n.minY,n.maxX,n.maxY,a.groupTransform)}const s=a.children;for(let n=0;n"},uInputPixel:{value:new Float32Array(4),type:"vec4"},uInputClamp:{value:new Float32Array(4),type:"vec4"},uOutputFrame:{value:new Float32Array(4),type:"vec4"},uGlobalFrame:{value:new Float32Array(4),type:"vec4"},uOutputTexture:{value:new Float32Array(4),type:"vec4"}}),this._globalFilterBindGroup=new me({}),this.renderer=e}get activeBackTexture(){var e;return(e=this._activeFilterData)==null?void 0:e.backTexture}push(e){var f;const t=this.renderer,r=e.filterEffect.filters;this._filterStack[this._filterStackIndex]||(this._filterStack[this._filterStackIndex]=this._getFilterData());const s=this._filterStack[this._filterStackIndex];if(this._filterStackIndex++,r.length===0){s.skip=!0;return}const n=s.bounds;e.renderables?xt(e.renderables,n):e.filterEffect.filterArea?(n.clear(),n.addRect(e.filterEffect.filterArea),n.applyMatrix(e.container.worldTransform)):mt(e.container,n);const i=t.renderTarget.renderTarget.colorTexture.source;let o=1/0,d=0,l=!0,u=!1,c=!1;for(let m=0;m0?this._filterStack[this._filterStackIndex-1].bounds:null,d=e.renderTarget.getRenderTarget(t.previousRenderSurface);n=this.getBackTexture(d,s,o)}t.backTexture=n;const i=t.filterEffect.filters;if(this._globalFilterBindGroup.setResource(r.source.style,2),this._globalFilterBindGroup.setResource(n.source,3),e.globalUniforms.pop(),i.length===1)i[0].apply(this,r,t.previousRenderSurface,!1),w.returnTexture(r);else{let o=t.inputTexture,d=w.getOptimalTexture(s.width,s.height,o.source._resolution,!1),l=0;for(l=0;l0&&this._filterStack[g].skip;)--g;g>0&&(c=this._filterStack[g].inputTexture.source._resolution);const f=this._filterGlobalUniforms,m=f.uniforms,p=m.uOutputFrame,_=m.uInputSize,x=m.uInputPixel,B=m.uInputClamp,T=m.uGlobalFrame,C=m.uOutputTexture;if(u){let M=this._filterStackIndex;for(;M>0;){M--;const v=this._filterStack[this._filterStackIndex-1];if(!v.skip){d.x=v.bounds.minX,d.y=v.bounds.minY;break}}p[0]=o.minX-d.x,p[1]=o.minY-d.y}else p[0]=0,p[1]=0;p[2]=t.frame.width,p[3]=t.frame.height,_[0]=t.source.width,_[1]=t.source.height,_[2]=1/_[0],_[3]=1/_[1],x[0]=t.source.pixelWidth,x[1]=t.source.pixelHeight,x[2]=1/x[0],x[3]=1/x[1],B[0]=.5*x[2],B[1]=.5*x[3],B[2]=t.frame.width*_[2]-.5*x[2],B[3]=t.frame.height*_[3]-.5*x[3];const F=this.renderer.renderTarget.rootRenderTarget.colorTexture;T[0]=d.x*c,T[1]=d.y*c,T[2]=F.source.width*c,T[3]=F.source.height*c;const U=this.renderer.renderTarget.getRenderTarget(r);if(n.renderTarget.bind(r,!!s),r instanceof k?(C[0]=r.frame.width,C[1]=r.frame.height):(C[0]=U.width,C[1]=U.height),C[2]=U.isRoot?-1:1,f.update(),n.renderPipes.uniformBatch){const M=n.renderPipes.uniformBatch.getUboResource(f);this._globalFilterBindGroup.setResource(M,0)}else this._globalFilterBindGroup.setResource(f,0);this._globalFilterBindGroup.setResource(t.source,1),this._globalFilterBindGroup.setResource(t.source.style,2),e.groups[0]=this._globalFilterBindGroup,n.encoder.draw({geometry:_t,shader:e,state:e._state,topology:"triangle-list"}),n.type===q.WEBGL&&n.renderTarget.finishRenderPass()}_getFilterData(){return{skip:!1,inputTexture:null,bounds:new xe,container:null,filterEffect:null,blendRequired:!1,previousRenderSurface:null}}calculateSpriteMatrix(e,t){const r=this._activeFilterData,s=e.set(r.inputTexture._source.width,0,0,r.inputTexture._source.height,r.bounds.minX,r.bounds.minY),n=t.worldTransform.copyTo(R.shared);return n.invert(),s.prepend(n),s.scale(1/t.texture.frame.width,1/t.texture.frame.height),s.translate(t.anchor.x,t.anchor.y),s}}Ge.extension={type:[h.WebGLSystem,h.WebGPUSystem],name:"filter"};function bt(a){const e=a._stroke,t=a._fill,s=[`div { ${[`color: ${G.shared.setValue(t.color).toHex()}`,`font-size: ${a.fontSize}px`,`font-family: ${a.fontFamily}`,`font-weight: ${a.fontWeight}`,`font-style: ${a.fontStyle}`,`font-variant: ${a.fontVariant}`,`letter-spacing: ${a.letterSpacing}px`,`text-align: ${a.align}`,`padding: ${a.padding}px`,`white-space: ${a.whiteSpace==="pre"&&a.wordWrap?"pre-wrap":a.whiteSpace}`,...a.lineHeight?[`line-height: ${a.lineHeight}px`]:[],...a.wordWrap?[`word-wrap: ${a.breakWords?"break-all":"break-word"}`,`max-width: ${a.wordWrapWidth}px`]:[],...e?[Ae(e)]:[],...a.dropShadow?[Fe(a.dropShadow)]:[],...a.cssOverrides].join(";")} }`];return Tt(a.tagStyles,s),s.join(" ")}function Fe(a){const e=G.shared.setValue(a.color).setAlpha(a.alpha).toHexa(),t=Math.round(Math.cos(a.angle)*a.distance),r=Math.round(Math.sin(a.angle)*a.distance),s=`${t}px ${r}px`;return a.blur>0?`text-shadow: ${s} ${a.blur}px ${e}`:`text-shadow: ${s} ${e}`}function Ae(a){return[`-webkit-text-stroke-width: ${a.width}px`,`-webkit-text-stroke-color: ${G.shared.setValue(a.color).toHex()}`,`text-stroke-width: ${a.width}px`,`text-stroke-color: ${G.shared.setValue(a.color).toHex()}`,"paint-order: stroke"].join(";")}const oe={fontSize:"font-size: {{VALUE}}px",fontFamily:"font-family: {{VALUE}}",fontWeight:"font-weight: {{VALUE}}",fontStyle:"font-style: {{VALUE}}",fontVariant:"font-variant: {{VALUE}}",letterSpacing:"letter-spacing: {{VALUE}}px",align:"text-align: {{VALUE}}",padding:"padding: {{VALUE}}px",whiteSpace:"white-space: {{VALUE}}",lineHeight:"line-height: {{VALUE}}px",wordWrapWidth:"max-width: {{VALUE}}px"},de={fill:a=>`color: ${G.shared.setValue(a).toHex()}`,breakWords:a=>`word-wrap: ${a?"break-all":"break-word"}`,stroke:Ae,dropShadow:Fe};function Tt(a,e){for(const t in a){const r=a[t],s=[];for(const n in r)de[n]?s.push(de[n](r[n])):oe[n]&&s.push(oe[n].replace("{{VALUE}}",r[n]));e.push(`${t} { ${s.join(";")} }`)}}class N extends Y{constructor(e={}){super(e),this._cssOverrides=[],this.cssOverrides??(this.cssOverrides=e.cssOverrides),this.tagStyles=e.tagStyles??{}}set cssOverrides(e){this._cssOverrides=e instanceof Array?e:[e],this.update()}get cssOverrides(){return this._cssOverrides}_generateKey(){return this._styleKey=Je(this)+this._cssOverrides.join("-"),this._styleKey}update(){this._cssStyle=null,super.update()}clone(){return new N({align:this.align,breakWords:this.breakWords,dropShadow:this.dropShadow?{...this.dropShadow}:null,fill:this._fill,fontFamily:this.fontFamily,fontSize:this.fontSize,fontStyle:this.fontStyle,fontVariant:this.fontVariant,fontWeight:this.fontWeight,letterSpacing:this.letterSpacing,lineHeight:this.lineHeight,padding:this.padding,stroke:this._stroke,whiteSpace:this.whiteSpace,wordWrap:this.wordWrap,wordWrapWidth:this.wordWrapWidth,cssOverrides:this.cssOverrides})}get cssStyle(){return this._cssStyle||(this._cssStyle=bt(this)),this._cssStyle}addOverride(...e){const t=e.filter(r=>!this.cssOverrides.includes(r));t.length>0&&(this.cssOverrides.push(...t),this.update())}removeOverride(...e){const t=e.filter(r=>this.cssOverrides.includes(r));t.length>0&&(this.cssOverrides=this.cssOverrides.filter(r=>!t.includes(r)),this.update())}set fill(e){typeof e!="string"&&typeof e!="number"&&O("[HTMLTextStyle] only color fill is not supported by HTMLText"),super.fill=e}set stroke(e){e&&typeof e!="string"&&typeof e!="number"&&O("[HTMLTextStyle] only color stroke is not supported by HTMLText"),super.stroke=e}}const le="http://www.w3.org/2000/svg",ue="http://www.w3.org/1999/xhtml";class De{constructor(){this.svgRoot=document.createElementNS(le,"svg"),this.foreignObject=document.createElementNS(le,"foreignObject"),this.domElement=document.createElementNS(ue,"div"),this.styleElement=document.createElementNS(ue,"style"),this.image=new Image;const{foreignObject:e,svgRoot:t,styleElement:r,domElement:s}=this;e.setAttribute("width","10000"),e.setAttribute("height","10000"),e.style.overflow="hidden",t.appendChild(e),e.appendChild(r),e.appendChild(s)}}let ce;function yt(a,e,t,r){r=r||ce||(ce=new De);const{domElement:s,styleElement:n,svgRoot:i}=r;s.innerHTML=`
${a}
`,s.setAttribute("style","transform-origin: top left; display: inline-block"),t&&(n.textContent=t),document.body.appendChild(i);const o=s.getBoundingClientRect();i.remove();const d=P.measureFont(e.fontStyle).descent,l=e.padding*2;return{width:o.width-l,height:o.height+d-l}}class ze{constructor(e,t){this.state=Ce.for2d(),this._graphicsBatchesHash=Object.create(null),this._destroyRenderableBound=this.destroyRenderable.bind(this),this.renderer=e,this._adaptor=t,this._adaptor.init()}validateRenderable(e){const t=e.context,r=!!this._graphicsBatchesHash[e.uid],s=this.renderer.graphicsContext.updateGpuContext(t);return!!(s.isBatchable||r!==s.isBatchable)}addRenderable(e,t){const r=this.renderer.graphicsContext.updateGpuContext(e.context);e._didGraphicsUpdate&&(e._didGraphicsUpdate=!1,this._rebuild(e)),r.isBatchable?this._addToBatcher(e,t):(this.renderer.renderPipes.batch.break(t),t.add(e))}updateRenderable(e){const t=this._graphicsBatchesHash[e.uid];if(t)for(let r=0;r{const o=b.get(Ze);return i.copyTo(o),o.renderable=e,o.roundPixels=s,o});return this._graphicsBatchesHash[e.uid]===void 0&&e.on("destroyed",this._destroyRenderableBound),this._graphicsBatchesHash[e.uid]=n,n}_removeBatchForRenderable(e){this._graphicsBatchesHash[e].forEach(t=>{b.return(t)}),this._graphicsBatchesHash[e]=null}destroy(){this.renderer=null,this._adaptor.destroy(),this._adaptor=null,this.state=null;for(const e in this._graphicsBatchesHash)this._removeBatchForRenderable(e);this._graphicsBatchesHash=null}}ze.extension={type:[h.WebGLPipes,h.WebGPUPipes,h.CanvasPipes],name:"graphics"};class Q{constructor(){this.batcherName="default",this.packAsQuad=!1,this.indexOffset=0,this.attributeOffset=0,this.roundPixels=0,this._batcher=null,this._batch=null,this._uvUpdateId=-1,this._textureMatrixUpdateId=-1}get blendMode(){return this.renderable.groupBlendMode}reset(){this.renderable=null,this.texture=null,this._batcher=null,this._batch=null,this.geometry=null,this._uvUpdateId=-1,this._textureMatrixUpdateId=-1}get uvs(){const t=this.geometry.getBuffer("aUV"),r=t.data;let s=r;const n=this.texture.textureMatrix;return n.isSimple||(s=this._transformedUvs,(this._textureMatrixUpdateId!==n._updateID||this._uvUpdateId!==t._updateID)&&((!s||s.length"},uColor:{value:new Float32Array([1,1,1,1]),type:"vec4"},uRound:{value:0,type:"f32"}}),this.localUniformsBindGroup=new me({0:this.localUniforms}),this._meshDataHash=Object.create(null),this._gpuBatchableMeshHash=Object.create(null),this._destroyRenderableBound=this.destroyRenderable.bind(this),this.renderer=e,this._adaptor=t,this._adaptor.init()}validateRenderable(e){const t=this._getMeshData(e),r=t.batched,s=e.batched;if(t.batched=s,r!==s)return!0;if(s){const n=e._geometry;if(n.indices.length!==t.indexSize||n.positions.length!==t.vertexSize)return t.indexSize=n.indices.length,t.vertexSize=n.positions.length,!0;const i=this._getBatchableMesh(e),o=e.texture;if(i.texture._source!==o._source&&i.texture._source!==o._source)return!i._batcher.checkAndUpdateTexture(i,o)}return!1}addRenderable(e,t){const r=this.renderer.renderPipes.batch,{batched:s}=this._getMeshData(e);if(s){const n=this._getBatchableMesh(e);n.texture=e._texture,n.geometry=e._geometry,r.addToBatch(n,t)}else r.break(t),t.add(e)}updateRenderable(e){if(e.batched){const t=this._gpuBatchableMeshHash[e.uid];t.texture=e._texture,t.geometry=e._geometry,t._batcher.updateElement(t)}}destroyRenderable(e){this._meshDataHash[e.uid]=null;const t=this._gpuBatchableMeshHash[e.uid];t&&(b.return(t),this._gpuBatchableMeshHash[e.uid]=null),e.off("destroyed",this._destroyRenderableBound)}execute(e){if(!e.isRenderable)return;e.state.blendMode=_e(e.groupBlendMode,e.texture._source);const t=this.localUniforms;t.uniforms.uTransformMatrix=e.groupTransform,t.uniforms.uRound=this.renderer._roundPixels|e._roundPixels,t.update(),X(e.groupColorAlpha,t.uniforms.uColor,0),this._adaptor.execute(this,e)}_getMeshData(e){return this._meshDataHash[e.uid]||this._initMeshData(e)}_initMeshData(e){var t,r;return this._meshDataHash[e.uid]={batched:e.batched,indexSize:(t=e._geometry.indices)==null?void 0:t.length,vertexSize:(r=e._geometry.positions)==null?void 0:r.length},e.on("destroyed",this._destroyRenderableBound),this._meshDataHash[e.uid]}_getBatchableMesh(e){return this._gpuBatchableMeshHash[e.uid]||this._initBatchableMesh(e)}_initBatchableMesh(e){const t=b.get(Q);return t.renderable=e,t.texture=e._texture,t.transform=e.groupTransform,t.roundPixels=this.renderer._roundPixels|e._roundPixels,this._gpuBatchableMeshHash[e.uid]=t,t}destroy(){for(const e in this._gpuBatchableMeshHash)this._gpuBatchableMeshHash[e]&&b.return(this._gpuBatchableMeshHash[e]);this._gpuBatchableMeshHash=null,this._meshDataHash=null,this.localUniforms=null,this.localUniformsBindGroup=null,this._adaptor.destroy(),this._adaptor=null,this.renderer=null}}He.extension={type:[h.WebGLPipes,h.WebGPUPipes,h.CanvasPipes],name:"mesh"};class Oe{constructor(e){this._gpuSpriteHash=Object.create(null),this._destroyRenderableBound=this.destroyRenderable.bind(this),this._renderer=e}addRenderable(e,t){const r=this._getGpuSprite(e);e._didSpriteUpdate&&this._updateBatchableSprite(e,r),this._renderer.renderPipes.batch.addToBatch(r,t)}updateRenderable(e){const t=this._gpuSpriteHash[e.uid];e._didSpriteUpdate&&this._updateBatchableSprite(e,t),t._batcher.updateElement(t)}validateRenderable(e){const t=e._texture,r=this._getGpuSprite(e);return r.texture._source!==t._source?!r._batcher.checkAndUpdateTexture(r,t):!1}destroyRenderable(e){const t=this._gpuSpriteHash[e.uid];b.return(t.geometry),b.return(t),this._gpuSpriteHash[e.uid]=null,e.off("destroyed",this._destroyRenderableBound)}_updateBatchableSprite(e,t){e._didSpriteUpdate=!1,t.geometry.update(e),t.texture=e._texture}_getGpuSprite(e){return this._gpuSpriteHash[e.uid]||this._initGPUSprite(e)}_initGPUSprite(e){const t=b.get(Q);return t.geometry=b.get(et),t.renderable=e,t.transform=e.groupTransform,t.texture=e._texture,t.roundPixels=this._renderer._roundPixels|e._roundPixels,e._didSpriteUpdate=!0,this._gpuSpriteHash[e.uid]=t,e.on("destroyed",this._destroyRenderableBound),t}destroy(){for(const e in this._gpuSpriteHash)this._gpuSpriteHash[e].geometry.destroy();this._gpuSpriteHash=null,this._renderer=null}}Oe.extension={type:[h.WebGLPipes,h.WebGPUPipes,h.CanvasPipes],name:"nineSliceSprite"};const St={name:"tiling-bit",vertex:{header:` +import{E as h,U as Xe,b as se,a8 as L,M as R,a2 as Ne,l as D,h as me,w as O,a as k,P as Qe,R as q,H as xe,Y as G,a9 as Y,aa as Je,ab as P,z as b,ac as Ze,ad as _e,ae as et,u as be,o as Te,a3 as ye,t as Se,a6 as ve,af as we,s as tt,p as rt,q as st,a4 as at,a5 as nt,a7 as it,ag as ot,ah as dt,ai as lt,aj as j,ak as K,D as Be,m as A,O as ae,$ as ut,al as ct,am as ne,n as ie,e as S,an as ht}from"./index-WJSjzvvL.js";import{T as w,S as Ce,c as X,a as ft,b as pt,B as Re}from"./colorToUniform-Dzvfc6yy.js";class Me{static init(e){Object.defineProperty(this,"resizeTo",{set(t){globalThis.removeEventListener("resize",this.queueResize),this._resizeTo=t,t&&(globalThis.addEventListener("resize",this.queueResize),this.resize())},get(){return this._resizeTo}}),this.queueResize=()=>{this._resizeTo&&(this._cancelResize(),this._resizeId=requestAnimationFrame(()=>this.resize()))},this._cancelResize=()=>{this._resizeId&&(cancelAnimationFrame(this._resizeId),this._resizeId=null)},this.resize=()=>{if(!this._resizeTo)return;this._cancelResize();let t,r;if(this._resizeTo===globalThis.window)t=globalThis.innerWidth,r=globalThis.innerHeight;else{const{clientWidth:s,clientHeight:n}=this._resizeTo;t=s,r=n}this.renderer.resize(t,r),this.render()},this._resizeId=null,this._resizeTo=null,this.resizeTo=e.resizeTo||null}static destroy(){globalThis.removeEventListener("resize",this.queueResize),this._cancelResize(),this._cancelResize=null,this.queueResize=null,this.resizeTo=null,this.resize=null}}Me.extension=h.Application;class Pe{static init(e){e=Object.assign({autoStart:!0,sharedTicker:!1},e),Object.defineProperty(this,"ticker",{set(t){this._ticker&&this._ticker.remove(this.render,this),this._ticker=t,t&&t.add(this.render,this,Xe.LOW)},get(){return this._ticker}}),this.stop=()=>{this._ticker.stop()},this.start=()=>{this._ticker.start()},this._ticker=null,this.ticker=e.sharedTicker?se.shared:new se,e.autoStart&&this.start()}static destroy(){if(this._ticker){const e=this._ticker;this.ticker=null,e.destroy()}}}Pe.extension=h.Application;class Ue{constructor(e){this._renderer=e}push(e,t,r){this._renderer.renderPipes.batch.break(r),r.add({renderPipeId:"filter",canBundle:!1,action:"pushFilter",container:t,filterEffect:e})}pop(e,t,r){this._renderer.renderPipes.batch.break(r),r.add({renderPipeId:"filter",action:"popFilter",canBundle:!1})}execute(e){e.action==="pushFilter"?this._renderer.filter.push(e):e.action==="popFilter"&&this._renderer.filter.pop()}destroy(){this._renderer=null}}Ue.extension={type:[h.WebGLPipes,h.WebGPUPipes,h.CanvasPipes],name:"filter"};const gt=new R;function mt(a,e){return e.clear(),ke(a,e),e.isValid||e.set(0,0,0,0),a.renderGroup?e.applyMatrix(a.renderGroup.localTransform):e.applyMatrix(a.parentRenderGroup.worldTransform),e}function ke(a,e){if(a.localDisplayStatus!==7||!a.measurable)return;const t=!!a.effects.length;let r=e;if((a.renderGroup||t)&&(r=L.get().clear()),a.boundsArea)e.addRect(a.boundsArea,a.worldTransform);else{if(a.renderPipeId){const n=a.bounds;r.addFrame(n.minX,n.minY,n.maxX,n.maxY,a.groupTransform)}const s=a.children;for(let n=0;n"},uInputPixel:{value:new Float32Array(4),type:"vec4"},uInputClamp:{value:new Float32Array(4),type:"vec4"},uOutputFrame:{value:new Float32Array(4),type:"vec4"},uGlobalFrame:{value:new Float32Array(4),type:"vec4"},uOutputTexture:{value:new Float32Array(4),type:"vec4"}}),this._globalFilterBindGroup=new me({}),this.renderer=e}get activeBackTexture(){var e;return(e=this._activeFilterData)==null?void 0:e.backTexture}push(e){var f;const t=this.renderer,r=e.filterEffect.filters;this._filterStack[this._filterStackIndex]||(this._filterStack[this._filterStackIndex]=this._getFilterData());const s=this._filterStack[this._filterStackIndex];if(this._filterStackIndex++,r.length===0){s.skip=!0;return}const n=s.bounds;e.renderables?xt(e.renderables,n):e.filterEffect.filterArea?(n.clear(),n.addRect(e.filterEffect.filterArea),n.applyMatrix(e.container.worldTransform)):mt(e.container,n);const i=t.renderTarget.renderTarget.colorTexture.source;let o=1/0,d=0,l=!0,u=!1,c=!1;for(let m=0;m0?this._filterStack[this._filterStackIndex-1].bounds:null,d=e.renderTarget.getRenderTarget(t.previousRenderSurface);n=this.getBackTexture(d,s,o)}t.backTexture=n;const i=t.filterEffect.filters;if(this._globalFilterBindGroup.setResource(r.source.style,2),this._globalFilterBindGroup.setResource(n.source,3),e.globalUniforms.pop(),i.length===1)i[0].apply(this,r,t.previousRenderSurface,!1),w.returnTexture(r);else{let o=t.inputTexture,d=w.getOptimalTexture(s.width,s.height,o.source._resolution,!1),l=0;for(l=0;l0&&this._filterStack[g].skip;)--g;g>0&&(c=this._filterStack[g].inputTexture.source._resolution);const f=this._filterGlobalUniforms,m=f.uniforms,p=m.uOutputFrame,_=m.uInputSize,x=m.uInputPixel,B=m.uInputClamp,T=m.uGlobalFrame,C=m.uOutputTexture;if(u){let M=this._filterStackIndex;for(;M>0;){M--;const v=this._filterStack[this._filterStackIndex-1];if(!v.skip){d.x=v.bounds.minX,d.y=v.bounds.minY;break}}p[0]=o.minX-d.x,p[1]=o.minY-d.y}else p[0]=0,p[1]=0;p[2]=t.frame.width,p[3]=t.frame.height,_[0]=t.source.width,_[1]=t.source.height,_[2]=1/_[0],_[3]=1/_[1],x[0]=t.source.pixelWidth,x[1]=t.source.pixelHeight,x[2]=1/x[0],x[3]=1/x[1],B[0]=.5*x[2],B[1]=.5*x[3],B[2]=t.frame.width*_[2]-.5*x[2],B[3]=t.frame.height*_[3]-.5*x[3];const F=this.renderer.renderTarget.rootRenderTarget.colorTexture;T[0]=d.x*c,T[1]=d.y*c,T[2]=F.source.width*c,T[3]=F.source.height*c;const U=this.renderer.renderTarget.getRenderTarget(r);if(n.renderTarget.bind(r,!!s),r instanceof k?(C[0]=r.frame.width,C[1]=r.frame.height):(C[0]=U.width,C[1]=U.height),C[2]=U.isRoot?-1:1,f.update(),n.renderPipes.uniformBatch){const M=n.renderPipes.uniformBatch.getUboResource(f);this._globalFilterBindGroup.setResource(M,0)}else this._globalFilterBindGroup.setResource(f,0);this._globalFilterBindGroup.setResource(t.source,1),this._globalFilterBindGroup.setResource(t.source.style,2),e.groups[0]=this._globalFilterBindGroup,n.encoder.draw({geometry:_t,shader:e,state:e._state,topology:"triangle-list"}),n.type===q.WEBGL&&n.renderTarget.finishRenderPass()}_getFilterData(){return{skip:!1,inputTexture:null,bounds:new xe,container:null,filterEffect:null,blendRequired:!1,previousRenderSurface:null}}calculateSpriteMatrix(e,t){const r=this._activeFilterData,s=e.set(r.inputTexture._source.width,0,0,r.inputTexture._source.height,r.bounds.minX,r.bounds.minY),n=t.worldTransform.copyTo(R.shared);return n.invert(),s.prepend(n),s.scale(1/t.texture.frame.width,1/t.texture.frame.height),s.translate(t.anchor.x,t.anchor.y),s}}Ge.extension={type:[h.WebGLSystem,h.WebGPUSystem],name:"filter"};function bt(a){const e=a._stroke,t=a._fill,s=[`div { ${[`color: ${G.shared.setValue(t.color).toHex()}`,`font-size: ${a.fontSize}px`,`font-family: ${a.fontFamily}`,`font-weight: ${a.fontWeight}`,`font-style: ${a.fontStyle}`,`font-variant: ${a.fontVariant}`,`letter-spacing: ${a.letterSpacing}px`,`text-align: ${a.align}`,`padding: ${a.padding}px`,`white-space: ${a.whiteSpace==="pre"&&a.wordWrap?"pre-wrap":a.whiteSpace}`,...a.lineHeight?[`line-height: ${a.lineHeight}px`]:[],...a.wordWrap?[`word-wrap: ${a.breakWords?"break-all":"break-word"}`,`max-width: ${a.wordWrapWidth}px`]:[],...e?[Ae(e)]:[],...a.dropShadow?[Fe(a.dropShadow)]:[],...a.cssOverrides].join(";")} }`];return Tt(a.tagStyles,s),s.join(" ")}function Fe(a){const e=G.shared.setValue(a.color).setAlpha(a.alpha).toHexa(),t=Math.round(Math.cos(a.angle)*a.distance),r=Math.round(Math.sin(a.angle)*a.distance),s=`${t}px ${r}px`;return a.blur>0?`text-shadow: ${s} ${a.blur}px ${e}`:`text-shadow: ${s} ${e}`}function Ae(a){return[`-webkit-text-stroke-width: ${a.width}px`,`-webkit-text-stroke-color: ${G.shared.setValue(a.color).toHex()}`,`text-stroke-width: ${a.width}px`,`text-stroke-color: ${G.shared.setValue(a.color).toHex()}`,"paint-order: stroke"].join(";")}const oe={fontSize:"font-size: {{VALUE}}px",fontFamily:"font-family: {{VALUE}}",fontWeight:"font-weight: {{VALUE}}",fontStyle:"font-style: {{VALUE}}",fontVariant:"font-variant: {{VALUE}}",letterSpacing:"letter-spacing: {{VALUE}}px",align:"text-align: {{VALUE}}",padding:"padding: {{VALUE}}px",whiteSpace:"white-space: {{VALUE}}",lineHeight:"line-height: {{VALUE}}px",wordWrapWidth:"max-width: {{VALUE}}px"},de={fill:a=>`color: ${G.shared.setValue(a).toHex()}`,breakWords:a=>`word-wrap: ${a?"break-all":"break-word"}`,stroke:Ae,dropShadow:Fe};function Tt(a,e){for(const t in a){const r=a[t],s=[];for(const n in r)de[n]?s.push(de[n](r[n])):oe[n]&&s.push(oe[n].replace("{{VALUE}}",r[n]));e.push(`${t} { ${s.join(";")} }`)}}class N extends Y{constructor(e={}){super(e),this._cssOverrides=[],this.cssOverrides??(this.cssOverrides=e.cssOverrides),this.tagStyles=e.tagStyles??{}}set cssOverrides(e){this._cssOverrides=e instanceof Array?e:[e],this.update()}get cssOverrides(){return this._cssOverrides}_generateKey(){return this._styleKey=Je(this)+this._cssOverrides.join("-"),this._styleKey}update(){this._cssStyle=null,super.update()}clone(){return new N({align:this.align,breakWords:this.breakWords,dropShadow:this.dropShadow?{...this.dropShadow}:null,fill:this._fill,fontFamily:this.fontFamily,fontSize:this.fontSize,fontStyle:this.fontStyle,fontVariant:this.fontVariant,fontWeight:this.fontWeight,letterSpacing:this.letterSpacing,lineHeight:this.lineHeight,padding:this.padding,stroke:this._stroke,whiteSpace:this.whiteSpace,wordWrap:this.wordWrap,wordWrapWidth:this.wordWrapWidth,cssOverrides:this.cssOverrides})}get cssStyle(){return this._cssStyle||(this._cssStyle=bt(this)),this._cssStyle}addOverride(...e){const t=e.filter(r=>!this.cssOverrides.includes(r));t.length>0&&(this.cssOverrides.push(...t),this.update())}removeOverride(...e){const t=e.filter(r=>this.cssOverrides.includes(r));t.length>0&&(this.cssOverrides=this.cssOverrides.filter(r=>!t.includes(r)),this.update())}set fill(e){typeof e!="string"&&typeof e!="number"&&O("[HTMLTextStyle] only color fill is not supported by HTMLText"),super.fill=e}set stroke(e){e&&typeof e!="string"&&typeof e!="number"&&O("[HTMLTextStyle] only color stroke is not supported by HTMLText"),super.stroke=e}}const le="http://www.w3.org/2000/svg",ue="http://www.w3.org/1999/xhtml";class De{constructor(){this.svgRoot=document.createElementNS(le,"svg"),this.foreignObject=document.createElementNS(le,"foreignObject"),this.domElement=document.createElementNS(ue,"div"),this.styleElement=document.createElementNS(ue,"style"),this.image=new Image;const{foreignObject:e,svgRoot:t,styleElement:r,domElement:s}=this;e.setAttribute("width","10000"),e.setAttribute("height","10000"),e.style.overflow="hidden",t.appendChild(e),e.appendChild(r),e.appendChild(s)}}let ce;function yt(a,e,t,r){r=r||ce||(ce=new De);const{domElement:s,styleElement:n,svgRoot:i}=r;s.innerHTML=`
${a}
`,s.setAttribute("style","transform-origin: top left; display: inline-block"),t&&(n.textContent=t),document.body.appendChild(i);const o=s.getBoundingClientRect();i.remove();const d=P.measureFont(e.fontStyle).descent,l=e.padding*2;return{width:o.width-l,height:o.height+d-l}}class ze{constructor(e,t){this.state=Ce.for2d(),this._graphicsBatchesHash=Object.create(null),this._destroyRenderableBound=this.destroyRenderable.bind(this),this.renderer=e,this._adaptor=t,this._adaptor.init()}validateRenderable(e){const t=e.context,r=!!this._graphicsBatchesHash[e.uid],s=this.renderer.graphicsContext.updateGpuContext(t);return!!(s.isBatchable||r!==s.isBatchable)}addRenderable(e,t){const r=this.renderer.graphicsContext.updateGpuContext(e.context);e._didGraphicsUpdate&&(e._didGraphicsUpdate=!1,this._rebuild(e)),r.isBatchable?this._addToBatcher(e,t):(this.renderer.renderPipes.batch.break(t),t.add(e))}updateRenderable(e){const t=this._graphicsBatchesHash[e.uid];if(t)for(let r=0;r{const o=b.get(Ze);return i.copyTo(o),o.renderable=e,o.roundPixels=s,o});return this._graphicsBatchesHash[e.uid]===void 0&&e.on("destroyed",this._destroyRenderableBound),this._graphicsBatchesHash[e.uid]=n,n}_removeBatchForRenderable(e){this._graphicsBatchesHash[e].forEach(t=>{b.return(t)}),this._graphicsBatchesHash[e]=null}destroy(){this.renderer=null,this._adaptor.destroy(),this._adaptor=null,this.state=null;for(const e in this._graphicsBatchesHash)this._removeBatchForRenderable(e);this._graphicsBatchesHash=null}}ze.extension={type:[h.WebGLPipes,h.WebGPUPipes,h.CanvasPipes],name:"graphics"};class Q{constructor(){this.batcherName="default",this.packAsQuad=!1,this.indexOffset=0,this.attributeOffset=0,this.roundPixels=0,this._batcher=null,this._batch=null,this._uvUpdateId=-1,this._textureMatrixUpdateId=-1}get blendMode(){return this.renderable.groupBlendMode}reset(){this.renderable=null,this.texture=null,this._batcher=null,this._batch=null,this.geometry=null,this._uvUpdateId=-1,this._textureMatrixUpdateId=-1}get uvs(){const t=this.geometry.getBuffer("aUV"),r=t.data;let s=r;const n=this.texture.textureMatrix;return n.isSimple||(s=this._transformedUvs,(this._textureMatrixUpdateId!==n._updateID||this._uvUpdateId!==t._updateID)&&((!s||s.length"},uColor:{value:new Float32Array([1,1,1,1]),type:"vec4"},uRound:{value:0,type:"f32"}}),this.localUniformsBindGroup=new me({0:this.localUniforms}),this._meshDataHash=Object.create(null),this._gpuBatchableMeshHash=Object.create(null),this._destroyRenderableBound=this.destroyRenderable.bind(this),this.renderer=e,this._adaptor=t,this._adaptor.init()}validateRenderable(e){const t=this._getMeshData(e),r=t.batched,s=e.batched;if(t.batched=s,r!==s)return!0;if(s){const n=e._geometry;if(n.indices.length!==t.indexSize||n.positions.length!==t.vertexSize)return t.indexSize=n.indices.length,t.vertexSize=n.positions.length,!0;const i=this._getBatchableMesh(e),o=e.texture;if(i.texture._source!==o._source&&i.texture._source!==o._source)return!i._batcher.checkAndUpdateTexture(i,o)}return!1}addRenderable(e,t){const r=this.renderer.renderPipes.batch,{batched:s}=this._getMeshData(e);if(s){const n=this._getBatchableMesh(e);n.texture=e._texture,n.geometry=e._geometry,r.addToBatch(n,t)}else r.break(t),t.add(e)}updateRenderable(e){if(e.batched){const t=this._gpuBatchableMeshHash[e.uid];t.texture=e._texture,t.geometry=e._geometry,t._batcher.updateElement(t)}}destroyRenderable(e){this._meshDataHash[e.uid]=null;const t=this._gpuBatchableMeshHash[e.uid];t&&(b.return(t),this._gpuBatchableMeshHash[e.uid]=null),e.off("destroyed",this._destroyRenderableBound)}execute(e){if(!e.isRenderable)return;e.state.blendMode=_e(e.groupBlendMode,e.texture._source);const t=this.localUniforms;t.uniforms.uTransformMatrix=e.groupTransform,t.uniforms.uRound=this.renderer._roundPixels|e._roundPixels,t.update(),X(e.groupColorAlpha,t.uniforms.uColor,0),this._adaptor.execute(this,e)}_getMeshData(e){return this._meshDataHash[e.uid]||this._initMeshData(e)}_initMeshData(e){var t,r;return this._meshDataHash[e.uid]={batched:e.batched,indexSize:(t=e._geometry.indices)==null?void 0:t.length,vertexSize:(r=e._geometry.positions)==null?void 0:r.length},e.on("destroyed",this._destroyRenderableBound),this._meshDataHash[e.uid]}_getBatchableMesh(e){return this._gpuBatchableMeshHash[e.uid]||this._initBatchableMesh(e)}_initBatchableMesh(e){const t=b.get(Q);return t.renderable=e,t.texture=e._texture,t.transform=e.groupTransform,t.roundPixels=this.renderer._roundPixels|e._roundPixels,this._gpuBatchableMeshHash[e.uid]=t,t}destroy(){for(const e in this._gpuBatchableMeshHash)this._gpuBatchableMeshHash[e]&&b.return(this._gpuBatchableMeshHash[e]);this._gpuBatchableMeshHash=null,this._meshDataHash=null,this.localUniforms=null,this.localUniformsBindGroup=null,this._adaptor.destroy(),this._adaptor=null,this.renderer=null}}He.extension={type:[h.WebGLPipes,h.WebGPUPipes,h.CanvasPipes],name:"mesh"};class Oe{constructor(e){this._gpuSpriteHash=Object.create(null),this._destroyRenderableBound=this.destroyRenderable.bind(this),this._renderer=e}addRenderable(e,t){const r=this._getGpuSprite(e);e._didSpriteUpdate&&this._updateBatchableSprite(e,r),this._renderer.renderPipes.batch.addToBatch(r,t)}updateRenderable(e){const t=this._gpuSpriteHash[e.uid];e._didSpriteUpdate&&this._updateBatchableSprite(e,t),t._batcher.updateElement(t)}validateRenderable(e){const t=e._texture,r=this._getGpuSprite(e);return r.texture._source!==t._source?!r._batcher.checkAndUpdateTexture(r,t):!1}destroyRenderable(e){const t=this._gpuSpriteHash[e.uid];b.return(t.geometry),b.return(t),this._gpuSpriteHash[e.uid]=null,e.off("destroyed",this._destroyRenderableBound)}_updateBatchableSprite(e,t){e._didSpriteUpdate=!1,t.geometry.update(e),t.texture=e._texture}_getGpuSprite(e){return this._gpuSpriteHash[e.uid]||this._initGPUSprite(e)}_initGPUSprite(e){const t=b.get(Q);return t.geometry=b.get(et),t.renderable=e,t.transform=e.groupTransform,t.texture=e._texture,t.roundPixels=this._renderer._roundPixels|e._roundPixels,e._didSpriteUpdate=!0,this._gpuSpriteHash[e.uid]=t,e.on("destroyed",this._destroyRenderableBound),t}destroy(){for(const e in this._gpuSpriteHash)this._gpuSpriteHash[e].geometry.destroy();this._gpuSpriteHash=null,this._renderer=null}}Oe.extension={type:[h.WebGLPipes,h.WebGPUPipes,h.CanvasPipes],name:"nineSliceSprite"};const St={name:"tiling-bit",vertex:{header:` struct TilingUniforms { uMapCoord:mat3x3, uClampFrame:vec4, diff --git a/index.html b/index.html index d822cf3..c4ab88d 100644 --- a/index.html +++ b/index.html @@ -6,7 +6,19 @@ Bastion: The Watcher's Lament - + + + + + + + diff --git a/latest_commit b/latest_commit index a67432c..e85cbf3 100644 --- a/latest_commit +++ b/latest_commit @@ -1 +1 @@ -ca8bf01 +bdeb67e