From e96aca07a5ef693b4f721f7129c5ee2361ae3a56 Mon Sep 17 00:00:00 2001 From: koneko Date: Wed, 8 Jan 2025 19:29:04 +0000 Subject: [PATCH] deploy: 3ae4c1de07dbce31691484339b284a2716fe9edb --- ...-BULM2rgc.js => SharedSystems-E-3P56Bk.js} | 2 +- ...-D6LquuM7.js => WebGLRenderer-D3v_pegD.js} | 2 +- ...CfuoxGKf.js => WebGPURenderer-CZKrr91q.js} | 2 +- ...All-CInIu0XO.js => browserAll-De6ljYqO.js} | 2 +- ...BCodWS3f.js => colorToUniform-B5sTP_KK.js} | 2 +- .../{index-SIvHqos0.js => index-CcvfyLBm.js} | 74 +++++++++---------- ...l-CsosBdqh.js => webworkerAll-CjjN_d2H.js} | 2 +- index.html | 3 +- latest_commit | 1 + 9 files changed, 46 insertions(+), 44 deletions(-) rename assets/{SharedSystems-BULM2rgc.js => SharedSystems-E-3P56Bk.js} (99%) rename assets/{WebGLRenderer-D6LquuM7.js => WebGLRenderer-D3v_pegD.js} (99%) rename assets/{WebGPURenderer-CfuoxGKf.js => WebGPURenderer-CZKrr91q.js} (99%) rename assets/{browserAll-CInIu0XO.js => browserAll-De6ljYqO.js} (99%) rename assets/{colorToUniform-BCodWS3f.js => colorToUniform-B5sTP_KK.js} (98%) rename assets/{index-SIvHqos0.js => index-CcvfyLBm.js} (77%) rename assets/{webworkerAll-CsosBdqh.js => webworkerAll-CjjN_d2H.js} (99%) create mode 100644 latest_commit diff --git a/assets/SharedSystems-BULM2rgc.js b/assets/SharedSystems-E-3P56Bk.js similarity index 99% rename from assets/SharedSystems-BULM2rgc.js rename to assets/SharedSystems-E-3P56Bk.js index 3d28905..233df77 100644 --- a/assets/SharedSystems-BULM2rgc.js +++ b/assets/SharedSystems-E-3P56Bk.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-SIvHqos0.js";import{S as fe,T as J,B as tt,c as rt}from"./colorToUniform-BCodWS3f.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-CcvfyLBm.js";import{S as fe,T as J,B as tt,c as rt}from"./colorToUniform-B5sTP_KK.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-D6LquuM7.js b/assets/WebGLRenderer-D3v_pegD.js similarity index 99% rename from assets/WebGLRenderer-D6LquuM7.js rename to assets/WebGLRenderer-D3v_pegD.js index 0d0884b..4284b0b 100644 --- a/assets/WebGLRenderer-D6LquuM7.js +++ b/assets/WebGLRenderer-D3v_pegD.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-SIvHqos0.js";import{S as O,b as Q}from"./colorToUniform-BCodWS3f.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-BULM2rgc.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-CcvfyLBm.js";import{S as O,b as Q}from"./colorToUniform-B5sTP_KK.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-E-3P56Bk.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-CfuoxGKf.js b/assets/WebGPURenderer-CZKrr91q.js similarity index 99% rename from assets/WebGPURenderer-CfuoxGKf.js rename to assets/WebGPURenderer-CZKrr91q.js index fdfec42..b021679 100644 --- a/assets/WebGPURenderer-CfuoxGKf.js +++ b/assets/WebGPURenderer-CZKrr91q.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-SIvHqos0.js";import{S as F,l as fe,a as ge}from"./colorToUniform-BCodWS3f.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-BULM2rgc.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-CcvfyLBm.js";import{S as F,l as fe,a as ge}from"./colorToUniform-B5sTP_KK.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-E-3P56Bk.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-CInIu0XO.js b/assets/browserAll-De6ljYqO.js similarity index 99% rename from assets/browserAll-CInIu0XO.js rename to assets/browserAll-De6ljYqO.js index ad902f9..ac141c0 100644 --- a/assets/browserAll-CInIu0XO.js +++ b/assets/browserAll-De6ljYqO.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-SIvHqos0.js";import"./webworkerAll-CsosBdqh.js";import"./colorToUniform-BCodWS3f.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-CcvfyLBm.js";import"./webworkerAll-CjjN_d2H.js";import"./colorToUniform-B5sTP_KK.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-BCodWS3f.js b/assets/colorToUniform-B5sTP_KK.js similarity index 98% rename from assets/colorToUniform-BCodWS3f.js rename to assets/colorToUniform-B5sTP_KK.js index 8f80bb5..f28a141 100644 --- a/assets/colorToUniform-BCodWS3f.js +++ b/assets/colorToUniform-B5sTP_KK.js @@ -1,4 +1,4 @@ -import{T as _,a as M,n as g}from"./index-SIvHqos0.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/index-SIvHqos0.js b/assets/index-CcvfyLBm.js similarity index 77% rename from assets/index-SIvHqos0.js rename to assets/index-CcvfyLBm.js index 4a75cc7..6cca53d 100644 --- a/assets/index-SIvHqos0.js +++ b/assets/index-CcvfyLBm.js @@ -1,10 +1,10 @@ -const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/browserAll-CInIu0XO.js","assets/webworkerAll-CsosBdqh.js","assets/colorToUniform-BCodWS3f.js","assets/WebGPURenderer-CfuoxGKf.js","assets/SharedSystems-BULM2rgc.js","assets/WebGLRenderer-D6LquuM7.js"])))=>i.map(i=>d[i]); -var fa=Object.defineProperty;var pa=(s,t,e)=>t in s?fa(s,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):s[t]=e;var w=(s,t,e)=>pa(s,typeof t!="symbol"?t+"":t,e);(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const r of document.querySelectorAll('link[rel="modulepreload"]'))i(r);new MutationObserver(r=>{for(const n of r)if(n.type==="childList")for(const a of n.addedNodes)a.tagName==="LINK"&&a.rel==="modulepreload"&&i(a)}).observe(document,{childList:!0,subtree:!0});function e(r){const n={};return r.integrity&&(n.integrity=r.integrity),r.referrerPolicy&&(n.referrerPolicy=r.referrerPolicy),r.crossOrigin==="use-credentials"?n.credentials="include":r.crossOrigin==="anonymous"?n.credentials="omit":n.credentials="same-origin",n}function i(r){if(r.ep)return;r.ep=!0;const n=e(r);fetch(r.href,n)}})();const ga="modulepreload",ma=function(s){return"/"+s},Ci={},Ye=function(t,e,i){let r=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"));r=Promise.allSettled(e.map(h=>{if(h=ma(h),h in Ci)return;Ci[h]=!0;const c=h.endsWith(".css"),l=c?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${h}"]${l}`))return;const u=document.createElement("link");if(u.rel=c?"stylesheet":ga,c||(u.as="script"),u.crossOrigin="",u.href=h,o&&u.setAttribute("nonce",o),document.head.appendChild(u),c)return new Promise((d,f)=>{u.addEventListener("load",d),u.addEventListener("error",()=>f(new Error(`Unable to preload CSS for ${h}`)))})}))}function n(a){const o=new Event("vite:preloadError",{cancelable:!0});if(o.payload=a,window.dispatchEvent(o),!o.defaultPrevented)throw a}return r.then(a=>{for(const o of a||[])o.status==="rejected"&&n(o.reason);return t().catch(n)})};var P=(s=>(s.Application="application",s.WebGLPipes="webgl-pipes",s.WebGLPipesAdaptor="webgl-pipes-adaptor",s.WebGLSystem="webgl-system",s.WebGPUPipes="webgpu-pipes",s.WebGPUPipesAdaptor="webgpu-pipes-adaptor",s.WebGPUSystem="webgpu-system",s.CanvasSystem="canvas-system",s.CanvasPipesAdaptor="canvas-pipes-adaptor",s.CanvasPipes="canvas-pipes",s.Asset="asset",s.LoadParser="load-parser",s.ResolveParser="resolve-parser",s.CacheParser="cache-parser",s.DetectionParser="detection-parser",s.MaskEffect="mask-effect",s.BlendMode="blend-mode",s.TextureSource="texture-source",s.Environment="environment",s.ShapeBuilder="shape-builder",s.Batcher="batcher",s))(P||{});const Rs=s=>{if(typeof s=="function"||typeof s=="object"&&s.extension){if(!s.extension)throw new Error("Extension class must have an extension object");s={...typeof s.extension!="object"?{type:s.extension}:s.extension,ref:s}}if(typeof s=="object")s={...s};else throw new Error("Invalid extension type");return typeof s.type=="string"&&(s.type=[s.type]),s},Ie=(s,t)=>Rs(s).priority??t,nt={_addHandlers:{},_removeHandlers:{},_queue:{},remove(...s){return s.map(Rs).forEach(t=>{t.type.forEach(e=>{var i,r;return(r=(i=this._removeHandlers)[e])==null?void 0:r.call(i,t)})}),this},add(...s){return s.map(Rs).forEach(t=>{t.type.forEach(e=>{var n,a;const i=this._addHandlers,r=this._queue;i[e]?(a=i[e])==null||a.call(i,t):(r[e]=r[e]||[],(n=r[e])==null||n.push(t))})}),this},handle(s,t,e){var a;const i=this._addHandlers,r=this._removeHandlers;if(i[s]||r[s])throw new Error(`Extension type ${s} already has a handler`);i[s]=t,r[s]=e;const n=this._queue;return n[s]&&((a=n[s])==null||a.forEach(o=>t(o)),delete n[s]),this},handleByMap(s,t){return this.handle(s,e=>{e.name&&(t[e.name]=e.ref)},e=>{e.name&&delete t[e.name]})},handleByNamedList(s,t,e=-1){return this.handle(s,i=>{t.findIndex(n=>n.name===i.name)>=0||(t.push({name:i.name,value:i.ref}),t.sort((n,a)=>Ie(a.value,e)-Ie(n.value,e)))},i=>{const r=t.findIndex(n=>n.name===i.name);r!==-1&&t.splice(r,1)})},handleByList(s,t,e=-1){return this.handle(s,i=>{t.includes(i.ref)||(t.push(i.ref),t.sort((r,n)=>Ie(n,e)-Ie(r,e)))},i=>{const r=t.indexOf(i.ref);r!==-1&&t.splice(r,1)})}},xa={extension:{type:P.Environment,name:"browser",priority:-1},test:()=>!0,load:async()=>{await Ye(()=>import("./browserAll-CInIu0XO.js"),__vite__mapDeps([0,1,2]))}},ya={extension:{type:P.Environment,name:"webworker",priority:0},test:()=>typeof self<"u"&&self.WorkerGlobalScope!==void 0,load:async()=>{await Ye(()=>import("./webworkerAll-CsosBdqh.js"),__vite__mapDeps([1,2]))}};class ot{constructor(t,e,i){this._x=e||0,this._y=i||0,this._observer=t}clone(t){return new ot(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 ii(s){return s&&s.__esModule&&Object.prototype.hasOwnProperty.call(s,"default")?s.default:s}var kr={exports:{}};(function(s){var t=Object.prototype.hasOwnProperty,e="~";function i(){}Object.create&&(i.prototype=Object.create(null),new i().__proto__||(e=!1));function r(h,c,l){this.fn=h,this.context=c,this.once=l||!1}function n(h,c,l,u,d){if(typeof l!="function")throw new TypeError("The listener must be a function");var f=new r(l,u||h,d),p=e?e+c:c;return h._events[p]?h._events[p].fn?h._events[p]=[h._events[p],f]:h._events[p].push(f):(h._events[p]=f,h._eventsCount++),h}function a(h,c){--h._eventsCount===0?h._events=new i:delete h._events[c]}function o(){this._events=new i,this._eventsCount=0}o.prototype.eventNames=function(){var c=[],l,u;if(this._eventsCount===0)return c;for(u in l=this._events)t.call(l,u)&&c.push(e?u.slice(1):u);return Object.getOwnPropertySymbols?c.concat(Object.getOwnPropertySymbols(l)):c},o.prototype.listeners=function(c){var l=e?e+c:c,u=this._events[l];if(!u)return[];if(u.fn)return[u.fn];for(var d=0,f=u.length,p=new Array(f);dLt[s],uY:s=>Gt[s],vX:s=>Wt[s],vY:s=>Ot[s],inv:s=>s&8?s&15:-s&7,add:(s,t)=>Ls[s][t],sub:(s,t)=>Ls[s][V.inv(t)],rotate180:s=>s^4,isVertical:s=>(s&3)===2,byDirection:(s,t)=>Math.abs(s)*2<=Math.abs(t)?t>=0?V.S:V.N:Math.abs(t)*2<=Math.abs(s)?s>0?V.E:V.W:t>0?s>0?V.SE:V.SW:s>0?V.NE:V.NW,matrixAppendRotationInv:(s,t,e=0,i=0)=>{const r=Er[V.inv(t)];r.tx=e,r.ty=i,s.append(r)}},Re=[new it,new it,new it,new it];class U{constructor(t=0,e=0,i=0,r=0){this.type="rectangle",this.x=Number(t),this.y=Number(e),this.width=Number(i),this.height=Number(r)}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 U(0,0,0,0)}clone(){return new U(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<=c&&e>=l&&e<=u&&!(t>d&&tp&&et.right?t.right:this.right)<=k)return!1;const A=this.yt.bottom?t.bottom:this.bottom)>A}const i=this.left,r=this.right,n=this.top,a=this.bottom;if(r<=i||a<=n)return!1;const o=Re[0].set(t.left,t.top),h=Re[1].set(t.left,t.bottom),c=Re[2].set(t.right,t.top),l=Re[3].set(t.right,t.bottom);if(c.x<=o.x||h.y<=o.y)return!1;const u=Math.sign(e.a*e.d-e.b*e.c);if(u===0||(e.apply(o,o),e.apply(h,h),e.apply(c,c),e.apply(l,l),Math.max(o.x,h.x,c.x,l.x)<=i||Math.min(o.x,h.x,c.x,l.x)>=r||Math.max(o.y,h.y,c.y,l.y)<=n||Math.min(o.y,h.y,c.y,l.y)>=a))return!1;const d=u*(h.y-o.y),f=u*(o.x-h.x),p=d*i+f*n,m=d*r+f*n,g=d*i+f*a,x=d*r+f*a;if(Math.max(p,m,g,x)<=d*o.x+f*o.y||Math.min(p,m,g,x)>=d*l.x+f*l.y)return!1;const y=u*(o.y-c.y),_=u*(c.x-o.x),b=y*i+_*n,S=y*r+_*n,I=y*i+_*a,M=y*r+_*a;return!(Math.max(b,S,I,M)<=y*o.x+_*o.y||Math.min(b,S,I,M)>=y*l.x+_*l.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),i=Math.min(this.x+this.width,t.x+t.width),r=Math.max(this.y,t.y),n=Math.min(this.y+this.height,t.y+t.height);return this.x=e,this.width=Math.max(i-e,0),this.y=r,this.height=Math.max(n-r,0),this}ceil(t=1,e=.001){const i=Math.ceil((this.x+this.width-e)*t)/t,r=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=i-this.x,this.height=r-this.y,this}enlarge(t){const e=Math.min(this.x,t.x),i=Math.max(this.x+this.width,t.x+t.width),r=Math.min(this.y,t.y),n=Math.max(this.y+this.height,t.y+t.height);return this.x=e,this.width=i-e,this.y=r,this.height=n-r,this}getBounds(t){return t=t||new U,t.copyFrom(this),t}toString(){return`[pixi.js/math:Rectangle x=${this.x} y=${this.y} width=${this.width} height=${this.height}]`}}const os={default:-1};function tt(s="default"){return os[s]===void 0&&(os[s]=-1),++os[s]}const Ti={},O="8.0.0",Ta="8.3.4";function W(s,t,e=3){if(Ti[t])return;let i=new Error().stack;typeof i>"u"?console.warn("PixiJS Deprecation Warning: ",`${t} +const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/browserAll-De6ljYqO.js","assets/webworkerAll-CjjN_d2H.js","assets/colorToUniform-B5sTP_KK.js","assets/WebGPURenderer-CZKrr91q.js","assets/SharedSystems-E-3P56Bk.js","assets/WebGLRenderer-D3v_pegD.js"])))=>i.map(i=>d[i]); +var pa=Object.defineProperty;var ga=(s,t,e)=>t in s?pa(s,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):s[t]=e;var w=(s,t,e)=>ga(s,typeof t!="symbol"?t+"":t,e);(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const r of document.querySelectorAll('link[rel="modulepreload"]'))i(r);new MutationObserver(r=>{for(const n of r)if(n.type==="childList")for(const a of n.addedNodes)a.tagName==="LINK"&&a.rel==="modulepreload"&&i(a)}).observe(document,{childList:!0,subtree:!0});function e(r){const n={};return r.integrity&&(n.integrity=r.integrity),r.referrerPolicy&&(n.referrerPolicy=r.referrerPolicy),r.crossOrigin==="use-credentials"?n.credentials="include":r.crossOrigin==="anonymous"?n.credentials="omit":n.credentials="same-origin",n}function i(r){if(r.ep)return;r.ep=!0;const n=e(r);fetch(r.href,n)}})();const ma="modulepreload",xa=function(s){return"/"+s},Ci={},je=function(t,e,i){let r=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"));r=Promise.allSettled(e.map(h=>{if(h=xa(h),h in Ci)return;Ci[h]=!0;const c=h.endsWith(".css"),l=c?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${h}"]${l}`))return;const u=document.createElement("link");if(u.rel=c?"stylesheet":ma,c||(u.as="script"),u.crossOrigin="",u.href=h,o&&u.setAttribute("nonce",o),document.head.appendChild(u),c)return new Promise((d,f)=>{u.addEventListener("load",d),u.addEventListener("error",()=>f(new Error(`Unable to preload CSS for ${h}`)))})}))}function n(a){const o=new Event("vite:preloadError",{cancelable:!0});if(o.payload=a,window.dispatchEvent(o),!o.defaultPrevented)throw a}return r.then(a=>{for(const o of a||[])o.status==="rejected"&&n(o.reason);return t().catch(n)})};var P=(s=>(s.Application="application",s.WebGLPipes="webgl-pipes",s.WebGLPipesAdaptor="webgl-pipes-adaptor",s.WebGLSystem="webgl-system",s.WebGPUPipes="webgpu-pipes",s.WebGPUPipesAdaptor="webgpu-pipes-adaptor",s.WebGPUSystem="webgpu-system",s.CanvasSystem="canvas-system",s.CanvasPipesAdaptor="canvas-pipes-adaptor",s.CanvasPipes="canvas-pipes",s.Asset="asset",s.LoadParser="load-parser",s.ResolveParser="resolve-parser",s.CacheParser="cache-parser",s.DetectionParser="detection-parser",s.MaskEffect="mask-effect",s.BlendMode="blend-mode",s.TextureSource="texture-source",s.Environment="environment",s.ShapeBuilder="shape-builder",s.Batcher="batcher",s))(P||{});const Rs=s=>{if(typeof s=="function"||typeof s=="object"&&s.extension){if(!s.extension)throw new Error("Extension class must have an extension object");s={...typeof s.extension!="object"?{type:s.extension}:s.extension,ref:s}}if(typeof s=="object")s={...s};else throw new Error("Invalid extension type");return typeof s.type=="string"&&(s.type=[s.type]),s},Fe=(s,t)=>Rs(s).priority??t,nt={_addHandlers:{},_removeHandlers:{},_queue:{},remove(...s){return s.map(Rs).forEach(t=>{t.type.forEach(e=>{var i,r;return(r=(i=this._removeHandlers)[e])==null?void 0:r.call(i,t)})}),this},add(...s){return s.map(Rs).forEach(t=>{t.type.forEach(e=>{var n,a;const i=this._addHandlers,r=this._queue;i[e]?(a=i[e])==null||a.call(i,t):(r[e]=r[e]||[],(n=r[e])==null||n.push(t))})}),this},handle(s,t,e){var a;const i=this._addHandlers,r=this._removeHandlers;if(i[s]||r[s])throw new Error(`Extension type ${s} already has a handler`);i[s]=t,r[s]=e;const n=this._queue;return n[s]&&((a=n[s])==null||a.forEach(o=>t(o)),delete n[s]),this},handleByMap(s,t){return this.handle(s,e=>{e.name&&(t[e.name]=e.ref)},e=>{e.name&&delete t[e.name]})},handleByNamedList(s,t,e=-1){return this.handle(s,i=>{t.findIndex(n=>n.name===i.name)>=0||(t.push({name:i.name,value:i.ref}),t.sort((n,a)=>Fe(a.value,e)-Fe(n.value,e)))},i=>{const r=t.findIndex(n=>n.name===i.name);r!==-1&&t.splice(r,1)})},handleByList(s,t,e=-1){return this.handle(s,i=>{t.includes(i.ref)||(t.push(i.ref),t.sort((r,n)=>Fe(n,e)-Fe(r,e)))},i=>{const r=t.indexOf(i.ref);r!==-1&&t.splice(r,1)})}},ya={extension:{type:P.Environment,name:"browser",priority:-1},test:()=>!0,load:async()=>{await je(()=>import("./browserAll-De6ljYqO.js"),__vite__mapDeps([0,1,2]))}},_a={extension:{type:P.Environment,name:"webworker",priority:0},test:()=>typeof self<"u"&&self.WorkerGlobalScope!==void 0,load:async()=>{await je(()=>import("./webworkerAll-CjjN_d2H.js"),__vite__mapDeps([1,2]))}};class ot{constructor(t,e,i){this._x=e||0,this._y=i||0,this._observer=t}clone(t){return new ot(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 ii(s){return s&&s.__esModule&&Object.prototype.hasOwnProperty.call(s,"default")?s.default:s}var kr={exports:{}};(function(s){var t=Object.prototype.hasOwnProperty,e="~";function i(){}Object.create&&(i.prototype=Object.create(null),new i().__proto__||(e=!1));function r(h,c,l){this.fn=h,this.context=c,this.once=l||!1}function n(h,c,l,u,d){if(typeof l!="function")throw new TypeError("The listener must be a function");var f=new r(l,u||h,d),p=e?e+c:c;return h._events[p]?h._events[p].fn?h._events[p]=[h._events[p],f]:h._events[p].push(f):(h._events[p]=f,h._eventsCount++),h}function a(h,c){--h._eventsCount===0?h._events=new i:delete h._events[c]}function o(){this._events=new i,this._eventsCount=0}o.prototype.eventNames=function(){var c=[],l,u;if(this._eventsCount===0)return c;for(u in l=this._events)t.call(l,u)&&c.push(e?u.slice(1):u);return Object.getOwnPropertySymbols?c.concat(Object.getOwnPropertySymbols(l)):c},o.prototype.listeners=function(c){var l=e?e+c:c,u=this._events[l];if(!u)return[];if(u.fn)return[u.fn];for(var d=0,f=u.length,p=new Array(f);dLt[s],uY:s=>Gt[s],vX:s=>Wt[s],vY:s=>Ot[s],inv:s=>s&8?s&15:-s&7,add:(s,t)=>Ls[s][t],sub:(s,t)=>Ls[s][V.inv(t)],rotate180:s=>s^4,isVertical:s=>(s&3)===2,byDirection:(s,t)=>Math.abs(s)*2<=Math.abs(t)?t>=0?V.S:V.N:Math.abs(t)*2<=Math.abs(s)?s>0?V.E:V.W:t>0?s>0?V.SE:V.SW:s>0?V.NE:V.NW,matrixAppendRotationInv:(s,t,e=0,i=0)=>{const r=Er[V.inv(t)];r.tx=e,r.ty=i,s.append(r)}},Le=[new it,new it,new it,new it];class U{constructor(t=0,e=0,i=0,r=0){this.type="rectangle",this.x=Number(t),this.y=Number(e),this.width=Number(i),this.height=Number(r)}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 U(0,0,0,0)}clone(){return new U(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<=c&&e>=l&&e<=u&&!(t>d&&tp&&et.right?t.right:this.right)<=k)return!1;const A=this.yt.bottom?t.bottom:this.bottom)>A}const i=this.left,r=this.right,n=this.top,a=this.bottom;if(r<=i||a<=n)return!1;const o=Le[0].set(t.left,t.top),h=Le[1].set(t.left,t.bottom),c=Le[2].set(t.right,t.top),l=Le[3].set(t.right,t.bottom);if(c.x<=o.x||h.y<=o.y)return!1;const u=Math.sign(e.a*e.d-e.b*e.c);if(u===0||(e.apply(o,o),e.apply(h,h),e.apply(c,c),e.apply(l,l),Math.max(o.x,h.x,c.x,l.x)<=i||Math.min(o.x,h.x,c.x,l.x)>=r||Math.max(o.y,h.y,c.y,l.y)<=n||Math.min(o.y,h.y,c.y,l.y)>=a))return!1;const d=u*(h.y-o.y),f=u*(o.x-h.x),p=d*i+f*n,m=d*r+f*n,g=d*i+f*a,x=d*r+f*a;if(Math.max(p,m,g,x)<=d*o.x+f*o.y||Math.min(p,m,g,x)>=d*l.x+f*l.y)return!1;const y=u*(o.y-c.y),_=u*(c.x-o.x),b=y*i+_*n,C=y*r+_*n,I=y*i+_*a,M=y*r+_*a;return!(Math.max(b,C,I,M)<=y*o.x+_*o.y||Math.min(b,C,I,M)>=y*l.x+_*l.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),i=Math.min(this.x+this.width,t.x+t.width),r=Math.max(this.y,t.y),n=Math.min(this.y+this.height,t.y+t.height);return this.x=e,this.width=Math.max(i-e,0),this.y=r,this.height=Math.max(n-r,0),this}ceil(t=1,e=.001){const i=Math.ceil((this.x+this.width-e)*t)/t,r=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=i-this.x,this.height=r-this.y,this}enlarge(t){const e=Math.min(this.x,t.x),i=Math.max(this.x+this.width,t.x+t.width),r=Math.min(this.y,t.y),n=Math.max(this.y+this.height,t.y+t.height);return this.x=e,this.width=i-e,this.y=r,this.height=n-r,this}getBounds(t){return t=t||new U,t.copyFrom(this),t}toString(){return`[pixi.js/math:Rectangle x=${this.x} y=${this.y} width=${this.width} height=${this.height}]`}}const os={default:-1};function tt(s="default"){return os[s]===void 0&&(os[s]=-1),++os[s]}const Ti={},O="8.0.0",Ma="8.3.4";function W(s,t,e=3){if(Ti[t])return;let i=new Error().stack;typeof i>"u"?console.warn("PixiJS Deprecation Warning: ",`${t} Deprecated since v${s}`):(i=i.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${s}`),console.warn(i),console.groupEnd()):(console.warn("PixiJS Deprecation Warning: ",`${t} -Deprecated since v${s}`),console.warn(i))),Ti[t]=!0}const Br=()=>{};function Mi(s){return s+=s===0?1:0,--s,s|=s>>>1,s|=s>>>2,s|=s>>>4,s|=s>>>8,s|=s>>>16,s+1}function Pi(s){return!(s&s-1)&&!!s}function Ma(s){const t={};for(const e in s)s[e]!==void 0&&(t[e]=s[e]);return t}const ki=Object.create(null);function Pa(s){const t=ki[s];return t===void 0&&(ki[s]=tt("resource")),t}const Ir=class Fr extends at{constructor(t={}){super(),this._resourceType="textureSampler",this._touched=0,this._maxAnisotropy=1,this.destroyed=!1,t={...Fr.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){W(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=Pa(t),this._resourceId}destroy(){this.destroyed=!0,this.emit("destroy",this),this.emit("change",this),this.removeAllListeners()}};Ir.defaultOptions={addressMode:"clamp-to-edge",scaleMode:"linear"};let ka=Ir;const Rr=class Lr extends at{constructor(t={}){super(),this.options=t,this.uid=tt("textureSource"),this._resourceType="textureSource",this._resourceId=tt("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={...Lr.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 ka(Ma(t)),this.destroyed=!1,this._refreshPOT()}get source(){return this}get style(){return this._style}set style(t){var e,i;this.style!==t&&((e=this._style)==null||e.off("change",this._onStyleChange,this),this._style=t,(i=this._style)==null||i.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=tt("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,i){i=i||this._resolution,t=t||this.width,e=e||this.height;const r=Math.round(t*i),n=Math.round(e*i);return this.width=r/i,this.height=n/i,this._resolution=i,this.pixelWidth===r&&this.pixelHeight===n?!1:(this._refreshPOT(),this.pixelWidth=r,this.pixelHeight=n,this.emit("resize",this),this._resourceId=tt("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=Pi(this.pixelWidth)&&Pi(this.pixelHeight)}static test(t){throw new Error("Unimplemented")}};Rr.defaultOptions={resolution:1,format:"bgra8unorm",alphaMode:"premultiply-alpha-on-upload",dimensions:"2d",mipLevelCount:1,autoGenerateMipmaps:!1,sampleCount:1,antialias:!1,autoGarbageCollect:!1};let Ct=Rr;class ri extends Ct{constructor(t){const e=t.resource||new Float32Array(t.width*t.height*4);let i=t.format;i||(e instanceof Float32Array?i="rgba32float":e instanceof Int32Array||e instanceof Uint32Array?i="rgba32uint":e instanceof Int16Array||e instanceof Uint16Array?i="rgba16uint":(e instanceof Int8Array,i="bgra8unorm")),super({...t,resource:e,format:i}),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}}ri.extension=P.TextureSource;const Ei=new D;class Ea{constructor(t,e){this.mapCoord=new D,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 i=this.mapCoord;for(let r=0;rthis.maxX||this.minY>this.maxY}get rectangle(){this._rectangle||(this._rectangle=new U);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=Bi,this}set(t,e,i,r){this.minX=t,this.minY=e,this.maxX=i,this.maxY=r}addFrame(t,e,i,r,n){n||(n=this.matrix);const a=n.a,o=n.b,h=n.c,c=n.d,l=n.tx,u=n.ty;let d=this.minX,f=this.minY,p=this.maxX,m=this.maxY,g=a*t+h*e+l,x=o*t+c*e+u;gp&&(p=g),x>m&&(m=x),g=a*i+h*e+l,x=o*i+c*e+u,gp&&(p=g),x>m&&(m=x),g=a*t+h*r+l,x=o*t+c*r+u,gp&&(p=g),x>m&&(m=x),g=a*i+h*r+l,x=o*i+c*r+u,gp&&(p=g),x>m&&(m=x),this.minX=d,this.minY=f,this.maxX=p,this.maxY=m}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?d:this.maxX,this.maxY=f>this.maxY?f:this.maxY,d=a*e+h*n+l,f=o*e+c*n+u,this.minX=dthis.maxX?d:this.maxX,this.maxY=f>this.maxY?f:this.maxY,d=a*r+h*n+l,f=o*r+c*n+u,this.minX=dthis.maxX?d:this.maxX,this.maxY=f>this.maxY?f:this.maxY}fit(t){return this.minXt.right&&(this.maxX=t.right),this.minYt.bottom&&(this.maxY=t.bottom),this}fitBounds(t,e,i,r){return this.minXe&&(this.maxX=e),this.minYr&&(this.maxY=r),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 bt(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,i,r){let n=this.minX,a=this.minY,o=this.maxX,h=this.maxY;r||(r=this.matrix);const c=r.a,l=r.b,u=r.c,d=r.d,f=r.tx,p=r.ty;for(let m=e;mo?y:o,h=_>h?_:h}this.minX=n,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 Ia={grad:.9,turn:360,rad:360/(2*Math.PI)},vt=function(s){return typeof s=="string"?s.length>0:typeof s=="number"},st=function(s,t,e){return t===void 0&&(t=0),e===void 0&&(e=Math.pow(10,t)),Math.round(e*s)/e+0},ut=function(s,t,e){return t===void 0&&(t=0),e===void 0&&(e=1),s>e?e:s>t?s:t},Gr=function(s){return(s=isFinite(s)?s%360:0)>0?s:s+360},Ii=function(s){return{r:ut(s.r,0,255),g:ut(s.g,0,255),b:ut(s.b,0,255),a:ut(s.a)}},hs=function(s){return{r:st(s.r),g:st(s.g),b:st(s.b),a:st(s.a,3)}},Fa=/^#([0-9a-f]{3,8})$/i,Le=function(s){var t=s.toString(16);return t.length<2?"0"+t:t},Wr=function(s){var t=s.r,e=s.g,i=s.b,r=s.a,n=Math.max(t,e,i),a=n-Math.min(t,e,i),o=a?n===t?(e-i)/a:n===e?2+(i-t)/a:4+(t-e)/a:0;return{h:60*(o<0?o+6:o),s:n?a/n*100:0,v:n/255*100,a:r}},Or=function(s){var t=s.h,e=s.s,i=s.v,r=s.a;t=t/360*6,e/=100,i/=100;var n=Math.floor(t),a=i*(1-e),o=i*(1-(t-n)*e),h=i*(1-(1-t+n)*e),c=n%6;return{r:255*[i,o,a,a,h,i][c],g:255*[h,i,i,o,a,a][c],b:255*[a,a,h,i,i,o][c],a:r}},Fi=function(s){return{h:Gr(s.h),s:ut(s.s,0,100),l:ut(s.l,0,100),a:ut(s.a)}},Ri=function(s){return{h:st(s.h),s:st(s.s),l:st(s.l),a:st(s.a,3)}},Li=function(s){return Or((e=(t=s).s,{h:t.h,s:(e*=((i=t.l)<50?i:100-i)/100)>0?2*e/(i+e)*100:0,v:i+e,a:t.a}));var t,e,i},xe=function(s){return{h:(t=Wr(s)).h,s:(r=(200-(e=t.s))*(i=t.v)/100)>0&&r<200?e*i/100/(r<=100?r:200-r)*100:0,l:r/2,a:t.a};var t,e,i,r},Ra=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,La=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Ga=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Wa=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Gs={string:[[function(s){var t=Fa.exec(s);return t?(s=t[1]).length<=4?{r:parseInt(s[0]+s[0],16),g:parseInt(s[1]+s[1],16),b:parseInt(s[2]+s[2],16),a:s.length===4?st(parseInt(s[3]+s[3],16)/255,2):1}:s.length===6||s.length===8?{r:parseInt(s.substr(0,2),16),g:parseInt(s.substr(2,2),16),b:parseInt(s.substr(4,2),16),a:s.length===8?st(parseInt(s.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(s){var t=Ga.exec(s)||Wa.exec(s);return t?t[2]!==t[4]||t[4]!==t[6]?null:Ii({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(s){var t=Ra.exec(s)||La.exec(s);if(!t)return null;var e,i,r=Fi({h:(e=t[1],i=t[2],i===void 0&&(i="deg"),Number(e)*(Ia[i]||1)),s:Number(t[3]),l:Number(t[4]),a:t[5]===void 0?1:Number(t[5])/(t[6]?100:1)});return Li(r)},"hsl"]],object:[[function(s){var t=s.r,e=s.g,i=s.b,r=s.a,n=r===void 0?1:r;return vt(t)&&vt(e)&&vt(i)?Ii({r:Number(t),g:Number(e),b:Number(i),a:Number(n)}):null},"rgb"],[function(s){var t=s.h,e=s.s,i=s.l,r=s.a,n=r===void 0?1:r;if(!vt(t)||!vt(e)||!vt(i))return null;var a=Fi({h:Number(t),s:Number(e),l:Number(i),a:Number(n)});return Li(a)},"hsl"],[function(s){var t=s.h,e=s.s,i=s.v,r=s.a,n=r===void 0?1:r;if(!vt(t)||!vt(e)||!vt(i))return null;var a=function(o){return{h:Gr(o.h),s:ut(o.s,0,100),v:ut(o.v,0,100),a:ut(o.a)}}({h:Number(t),s:Number(e),v:Number(i),a:Number(n)});return Or(a)},"hsv"]]},Gi=function(s,t){for(var e=0;e=.5},s.prototype.toHex=function(){return t=hs(this.rgba),e=t.r,i=t.g,r=t.b,a=(n=t.a)<1?Le(st(255*n)):"","#"+Le(e)+Le(i)+Le(r)+a;var t,e,i,r,n,a},s.prototype.toRgb=function(){return hs(this.rgba)},s.prototype.toRgbString=function(){return t=hs(this.rgba),e=t.r,i=t.g,r=t.b,(n=t.a)<1?"rgba("+e+", "+i+", "+r+", "+n+")":"rgb("+e+", "+i+", "+r+")";var t,e,i,r,n},s.prototype.toHsl=function(){return Ri(xe(this.rgba))},s.prototype.toHslString=function(){return t=Ri(xe(this.rgba)),e=t.h,i=t.s,r=t.l,(n=t.a)<1?"hsla("+e+", "+i+"%, "+r+"%, "+n+")":"hsl("+e+", "+i+"%, "+r+"%)";var t,e,i,r,n},s.prototype.toHsv=function(){return t=Wr(this.rgba),{h:st(t.h),s:st(t.s),v:st(t.v),a:st(t.a,3)};var t},s.prototype.invert=function(){return yt({r:255-(t=this.rgba).r,g:255-t.g,b:255-t.b,a:t.a});var t},s.prototype.saturate=function(t){return t===void 0&&(t=.1),yt(ls(this.rgba,t))},s.prototype.desaturate=function(t){return t===void 0&&(t=.1),yt(ls(this.rgba,-t))},s.prototype.grayscale=function(){return yt(ls(this.rgba,-1))},s.prototype.lighten=function(t){return t===void 0&&(t=.1),yt(Wi(this.rgba,t))},s.prototype.darken=function(t){return t===void 0&&(t=.1),yt(Wi(this.rgba,-t))},s.prototype.rotate=function(t){return t===void 0&&(t=15),this.hue(this.hue()+t)},s.prototype.alpha=function(t){return typeof t=="number"?yt({r:(e=this.rgba).r,g:e.g,b:e.b,a:t}):st(this.rgba.a,3);var e},s.prototype.hue=function(t){var e=xe(this.rgba);return typeof t=="number"?yt({h:t,s:e.s,l:e.l,a:e.a}):st(e.h)},s.prototype.isEqual=function(t){return this.toHex()===yt(t).toHex()},s}(),yt=function(s){return s instanceof Ws?s:new Ws(s)},Oi=[],Da=function(s){s.forEach(function(t){Oi.indexOf(t)<0&&(t(Ws,Gs),Oi.push(t))})};function Ua(s,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"},i={};for(var r in e)i[e[r]]=r;var n={};s.prototype.toName=function(a){if(!(this.rgba.a||this.rgba.r||this.rgba.g||this.rgba.b))return"transparent";var o,h,c=i[this.toHex()];if(c)return c;if(a!=null&&a.closest){var l=this.toRgb(),u=1/0,d="black";if(!n.length)for(var f in e)n[f]=new s(e[f]).toRgb();for(var p in e){var m=(o=l,h=n[p],Math.pow(o.r-h.r,2)+Math.pow(o.g-h.g,2)+Math.pow(o.b-h.b,2));mn===e[a]);if(t!==null&&e!==null){const n=Object.keys(t),a=Object.keys(e);return n.length!==a.length?!1:n.every(o=>t[o]===e[o])}return t===e}toRgba(){const[t,e,i,r]=this._components;return{r:t,g:e,b:i,a:r}}toRgb(){const[t,e,i]=this._components;return{r:t,g:e,b:i}}toRgbaString(){const[t,e,i]=this.toUint8RgbArray();return`rgba(${t},${e},${i},${this.alpha})`}toUint8RgbArray(t){const[e,i,r]=this._components;return this._arrayRgb||(this._arrayRgb=[]),t=t||this._arrayRgb,t[0]=Math.round(e*255),t[1]=Math.round(i*255),t[2]=Math.round(r*255),t}toArray(t){this._arrayRgba||(this._arrayRgba=[]),t=t||this._arrayRgba;const[e,i,r,n]=this._components;return t[0]=e,t[1]=i,t[2]=r,t[3]=n,t}toRgbArray(t){this._arrayRgb||(this._arrayRgb=[]),t=t||this._arrayRgb;const[e,i,r]=this._components;return t[0]=e,t[1]=i,t[2]=r,t}toNumber(){return this._int}toBgrNumber(){const[t,e,i]=this.toUint8RgbArray();return(i<<16)+(e<<8)+t}toLittleEndianNumber(){const t=this._int;return(t>>16)+(t&65280)+((t&255)<<16)}multiply(t){const[e,i,r,n]=fe._temp.setValue(t)._components;return this._components[0]*=e,this._components[1]*=i,this._components[2]*=r,this._components[3]*=n,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 i=this._int>>16&255,r=this._int>>8&255,n=this._int&255;return e&&(i=i*t+.5|0,r=r*t+.5|0,n=n*t+.5|0),(t*255<<24)+(i<<16)+(r<<8)+n}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,i,r,n;if((typeof t=="number"||t instanceof Number)&&t>=0&&t<=16777215){const a=t;e=(a>>16&255)/255,i=(a>>8&255)/255,r=(a&255)/255,n=1}else if((Array.isArray(t)||t instanceof Float32Array)&&t.length>=3&&t.length<=4)t=this._clamp(t),[e,i,r,n=1]=t;else if((t instanceof Uint8Array||t instanceof Uint8ClampedArray)&&t.length>=3&&t.length<=4)t=this._clamp(t,0,255),[e,i,r,n=255]=t,e/=255,i/=255,r/=255,n/=255;else if(typeof t=="string"||typeof t=="object"){if(typeof t=="string"){const o=fe.HEX_PATTERN.exec(t);o&&(t=`#${o[2]}`)}const a=yt(t);a.isValid()&&({r:e,g:i,b:r,a:n}=a.rgba,e/=255,i/=255,r/=255)}if(e!==void 0)this._components[0]=e,this._components[1]=i,this._components[2]=r,this._components[3]=n,this._refreshInt();else throw new Error(`Unable to convert color ${t}`)}_refreshInt(){this._clamp(this._components);const[t,e,i]=this._components;this._int=(t*255<<16)+(e*255<<8)+(i*255|0)}_clamp(t,e=0,i=1){return typeof t=="number"?Math.min(Math.max(t,e),i):(t.forEach((r,n)=>{t[n]=Math.min(Math.max(r,e),i)}),t)}static isColorLike(t){return typeof t=="number"||typeof t=="string"||t instanceof Number||t instanceof fe||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}};qt.shared=new qt;qt._temp=new qt;qt.HEX_PATTERN=/^(#|0x)?(([a-f0-9]{3}){1,2}([a-f0-9]{2})?)$/i;let Q=qt;const za={cullArea:null,cullable:!1,cullableChildren:!0};class ni{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,(i=e.init)==null||i.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 Ha{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 ni(t)),this._poolsByClass.get(t)}stats(){const t={};return this._poolsByClass.forEach(e=>{const i=t[e._classType.name]?e._classType.name+e._classType.ID:e._classType.name;t[i]={free:e.totalFree,used:e.totalUsed,size:e.totalSize}}),t}}const At=new Ha;function Na(s,t,e){const i=s.length;let r;if(t>=i||e===0)return;e=t+e>i?i-t:e;const n=i-e;for(r=t;r0&&i<=e){for(let a=e-1;a>=s;a--){const o=this.children[a];o&&(r.push(o),o.parent=null)}Na(this.children,s,e);const n=this.renderGroup||this.parentRenderGroup;n&&n.removeChildren(r);for(let a=0;a=this.children.length)throw new Error(`getChildAt: Index (${s}) does not exist.`);return this.children[s]},setChildIndex(s,t){if(t<0||t>=this.children.length)throw new Error(`The index ${t} supplied is out of bounds ${this.children.length}`);this.getChildIndex(s),this.addChildAt(s,t)},getChildIndex(s){const t=this.children.indexOf(s);if(t===-1)throw new Error("The supplied Container must be a child of the caller");return t},addChildAt(s,t){this.allowChildren||W(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(`${s}addChildAt: The index ${t} supplied is out of bounds ${e.length}`);if(s.parent){const r=s.parent.children.indexOf(s);if(s.parent===this&&r===t)return s;r!==-1&&s.parent.children.splice(r,1)}t===e.length?e.push(s):e.splice(t,0,s),s.parent=this,s.didChange=!0,s.didViewUpdate=!1,s._updateFlags=15;const i=this.renderGroup||this.parentRenderGroup;return i&&i.addChild(s),this.sortableChildren&&(this.sortDirty=!0),this.emit("childAdded",s,this,t),s.emit("added",this),s},swapChildren(s,t){if(s===t)return;const e=this.getChildIndex(s),i=this.getChildIndex(t);this.children[e]=t,this.children[i]=s;const r=this.renderGroup||this.parentRenderGroup;r&&(r.structureDidChange=!0),this._didContainerChangeTick++},removeFromParent(){var s;(s=this.parent)==null||s.removeChild(this)},reparentChild(...s){return s.length===1?this.reparentChildAt(s[0],this.children.length):(s.forEach(t=>this.reparentChildAt(t,this.children.length)),s[0])},reparentChildAt(s,t){if(s.parent===this)return this.setChildIndex(s,t),s;const e=s.worldTransform.clone();s.removeFromParent(),this.addChildAt(s,t);const i=this.worldTransform.clone();return i.invert(),e.prepend(i),s.setFromMatrix(e),s}};class Di{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;ei.priority-r.priority);const e=this.renderGroup||this.parentRenderGroup;e&&(e.structureDidChange=!0),this._updateIsSimple()},removeEffect(s){const t=this.effects.indexOf(s);t!==-1&&(this.effects.splice(t,1),this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._updateIsSimple())},set mask(s){const t=this._maskEffect;(t==null?void 0:t.mask)!==s&&(t&&(this.removeEffect(t),Os.returnMaskEffect(t),this._maskEffect=null),s!=null&&(this._maskEffect=Os.getMaskEffect(s),this.addEffect(this._maskEffect)))},get mask(){var s;return(s=this._maskEffect)==null?void 0:s.mask},set filters(s){var n;!Array.isArray(s)&&s&&(s=[s]);const t=this._filterEffect||(this._filterEffect=new Di);s=s;const e=(s==null?void 0:s.length)>0,i=((n=t.filters)==null?void 0:n.length)>0,r=e!==i;s=Array.isArray(s)?s.slice(0):s,t.filters=Object.freeze(s),r&&(e?this.addEffect(t):(this.removeEffect(t),t.filters=s??null))},get filters(){var s;return(s=this._filterEffect)==null?void 0:s.filters},set filterArea(s){this._filterEffect||(this._filterEffect=new Di),this._filterEffect.filterArea=s},get filterArea(){var s;return(s=this._filterEffect)==null?void 0:s.filterArea}},Ya={label:null,get name(){return W(O,"Container.name property has been removed, use Container.label instead"),this.label},set name(s){W(O,"Container.name property has been removed, use Container.label instead"),this.label=s},getChildByName(s,t=!1){return this.getChildByLabel(s,t)},getChildByLabel(s,t=!1){const e=this.children;for(let i=0;i-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 i=0;i0}addOnRender(t){this._onRenderContainers.push(t)}removeOnRender(t){this._onRenderContainers.splice(this._onRenderContainers.indexOf(t),1)}runOnRender(){for(let t=0;tthis.addChild(r)),(i=t.parent)==null||i.addChild(this)}static mixin(t){Object.defineProperties(rt.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||W(O,"addChild: Only Containers will be allowed to add children in v8.0.0"),t.length>1){for(let r=0;r1){for(let r=0;r-1&&(this._didViewChangeTick++,this.children.splice(i,1),this.renderGroup?this.renderGroup.removeChild(e):this.parentRenderGroup&&this.parentRenderGroup.removeChild(e),e.parent=null,this.emit("childRemoved",e,this,i),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=At.get(eo,this),this.groupTransform=D.IDENTITY,t==null||t.addChild(this),this._updateIsSimple()}disableRenderGroup(){if(!this.renderGroup)return;const t=this.parentRenderGroup;t==null||t.removeChild(this),At.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 D),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*wa}set angle(t){this.rotation=t*va}get pivot(){return this._pivot===fs&&(this._pivot=new ot(this,0,0)),this._pivot}set pivot(t){this._pivot===fs&&(this._pivot=new ot(this,0,0)),typeof t=="number"?this._pivot.set(t):this._pivot.copyFrom(t)}get skew(){return this._skew===ds&&(this._skew=new ot(this,0,0)),this._skew}set skew(t){this._skew===ds&&(this._skew=new ot(this,0,0)),this._skew.copyFrom(t)}get scale(){return this._scale===ps&&(this._scale=new ot(this,1,1)),this._scale}set scale(t){this._scale===ps&&(this._scale=new ot(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 i=this.getLocalBounds();typeof t=="object"?(e=t.height??t.width,t=t.width):e??(e=t),t!==void 0&&this._setWidth(t,i.width),e!==void 0&&this._setHeight(e,i.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,i=this._scale,r=this._pivot,n=this._position,a=i._x,o=i._y,h=r._x,c=r._y;e.a=this._cx*a,e.b=this._sx*a,e.c=this._cy*o,e.d=this._sy*o,e.tx=n._x-(h*e.a+c*e.c),e.ty=n._y-(h*e.b+c*e.d)}set alpha(t){t!==this.localAlpha&&(this.localAlpha=t,this._updateFlags|=zi,this._onUpdate())}get alpha(){return this.localAlpha}set tint(t){const i=Q.shared.setValue(t??16777215).toBgrNumber();i!==this.localColor&&(this.localColor=i,this._updateFlags|=zi,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|=io,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|=gs,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|=gs,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|=gs,this.localDisplayStatus^=1,this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._onUpdate())}get isRenderable(){return this.localDisplayStatus===7&&this.groupAlpha>0}destroy(t=!1){var r;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 n=0;n=e.minX&&i<=e.maxX&&r>=e.minY&&r<=e.maxY}destroy(t){super.destroy(t),this._bounds=null}}class dt extends Qe{constructor(t=G.EMPTY){t instanceof G&&(t={texture:t});const{texture:e=G.EMPTY,anchor:i,roundPixels:r,width:n,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 ot({_onUpdate:()=>{this.onViewUpdate()}}),i?this.anchor=i:e.defaultAnchor&&(this.anchor=e.defaultAnchor),this.texture=e,this.allowChildren=!1,this.roundPixels=r??!1,n!==void 0&&(this.width=n),a!==void 0&&(this.height=a)}static from(t,e=!1){return t instanceof G?new dt(t):new dt(G.from(t,e))}set texture(t){t||(t=G.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(){Ba(this._bounds,this._anchor,this._texture,0)}_updateSourceBounds(){const t=this._anchor,e=this._texture,i=this._sourceBounds,{width:r,height:n}=e.orig;i.maxX=-t._x*r,i.minX=i.maxX+r,i.maxY=-t._y*n,i.minY=i.maxY+n}destroy(t=!1){if(super.destroy(t),typeof t=="boolean"?t:t==null?void 0:t.texture){const i=typeof t=="boolean"?t:t==null?void 0:t.textureSource;this._texture.destroy(i)}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 ro=new bt;function $r(s,t,e){const i=ro;s.measurable=!0,Dr(s,e,i),t.addBoundsMask(i),s.measurable=!1}function Xr(s,t,e){const i=Kt.get();s.measurable=!0;const r=St.get().identity(),n=Yr(s,e,r);zr(s,i,n),s.measurable=!1,t.addBoundsMask(i),St.return(r),Kt.return(i)}function Yr(s,t,e){return s?(s!==t&&(Yr(s.parent,t,e),s.updateLocalTransform(),e.append(s.localTransform)),e):(J("Mask bounds, renderable is not inside the root container"),e)}class jr{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 dt),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){Xr(this.mask,t,e)}containsPoint(t,e){const i=this.mask;return e(i,t)}destroy(){this.reset()}static test(t){return t instanceof dt}}jr.extension=P.MaskEffect;class qr{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"}}qr.extension=P.MaskEffect;class Kr{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){Xr(this.mask,t,e)}containsPoint(t,e){const i=this.mask;return e(i,t)}destroy(){this.reset()}static test(t){return t instanceof rt}}Kr.extension=P.MaskEffect;const no={createCanvas:(s,t)=>{const e=document.createElement("canvas");return e.width=s,e.height=t,e},getCanvasRenderingContext2D:()=>CanvasRenderingContext2D,getWebGLRenderingContext:()=>WebGLRenderingContext,getNavigator:()=>navigator,getBaseUrl:()=>document.baseURI??window.location.href,getFontFaceSet:()=>document.fonts,fetch:(s,t)=>fetch(s,t),parseXML:s=>new DOMParser().parseFromString(s,"text/xml")};let Hi=no;const j={get(){return Hi},set(s){Hi=s}};class Zr extends Ct{constructor(t){t.resource||(t.resource=j.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,i=this._resolution){const r=super.resize(t,e,i);return r&&this.resizeCanvas(),r}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"))}}Zr.extension=P.TextureSource;class te extends Ct{constructor(t){if(t.resource&&globalThis.HTMLImageElement&&t.resource instanceof HTMLImageElement){const e=j.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,J("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}}te.extension=P.TextureSource;var Ds=(s=>(s[s.INTERACTION=50]="INTERACTION",s[s.HIGH=25]="HIGH",s[s.NORMAL=0]="NORMAL",s[s.LOW=-25]="LOW",s[s.UTILITY=-50]="UTILITY",s))(Ds||{});class ms{constructor(t,e=null,i=0,r=!1){this.next=null,this.previous=null,this._destroyed=!1,this._fn=t,this._context=e,this.priority=i,this._once=r}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 Qr=class ht{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 ms(null,null,1/0),this.deltaMS=1/ht.targetFPMS,this.elapsedMS=1/ht.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,i=Ds.NORMAL){return this._addListener(new ms(t,e,i))}addOnce(t,e,i=Ds.NORMAL){return this._addListener(new ms(t,e,i,!0))}_addListener(t){let e=this._head.next,i=this._head;if(!e)t.connect(i);else{for(;e;){if(t.priority>e.priority){t.connect(i);break}i=e,e=e.next}t.previous||t.connect(i)}return this._startIfPossible(),this}remove(t,e){let i=this._head.next;for(;i;)i.match(t,e)?i=i.destroy():i=i.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 n=t-this._lastFrame|0;if(n{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 i=t.createTexture();t.bindTexture(t.TEXTURE_2D,i);const r=t.createFramebuffer();t.bindFramebuffer(t.FRAMEBUFFER,r),t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,i,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 n=new Uint8Array(4);return t.readPixels(0,0,1,1,t.RGBA,t.UNSIGNED_BYTE,n),t.deleteFramebuffer(r),t.deleteTexture(i),(a=t.getExtension("WEBGL_lose_context"))==null||a.loseContext(),n[0]<=n[3]?"premultiplied-alpha":"premultiply-alpha-on-upload"})()),xs}const Je=class tn extends Ct{constructor(t){super(t),this.isReady=!1,this.uploadMethodId="video",t={...tn.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=pe.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 Jr(),this._load=new Promise((i,r)=>{this.isValid?i(this):(this._resolve=i,this._reject=r,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&&(pe.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||(pe.shared.add(this.updateFrame,this),this._isConnectedToTicker=!0,this._msToNextUpdate=0)):(this._videoFrameRequestCallbackHandle!==null&&(this.resource.cancelVideoFrameCallback(this._videoFrameRequestCallbackHandle),this._videoFrameRequestCallbackHandle=null),this._isConnectedToTicker&&(pe.shared.remove(this.updateFrame,this),this._isConnectedToTicker=!1,this._msToNextUpdate=0))}static test(t){return globalThis.HTMLVideoElement&&t instanceof HTMLVideoElement}};Je.extension=P.TextureSource;Je.defaultOptions={...Ct.defaultOptions,autoLoad:!0,autoPlay:!0,updateFPS:0,crossorigin:!0,loop:!1,muted:!0,playsinline:!0,preload:!1};Je.MIME_TYPES={ogv:"video/ogg",mov:"video/quicktime",m4v:"video/mp4"};let Ve=Je;const gt=(s,t,e=!1)=>(Array.isArray(s)||(s=[s]),t?s.map(i=>typeof i=="string"||e?t(i):i):s);class ao{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||J(`[Assets] Asset id ${t} was not found in the Cache`),e}set(t,e){const i=gt(t);let r;for(let h=0;h{n.set(h,e)});const a=[...n.keys()],o={cacheKeys:a,keys:i};i.forEach(h=>{this._cacheMap.set(h,o)}),a.forEach(h=>{const c=r?r[h]:e;this._cache.has(h)&&this._cache.get(h)!==c&&J("[Cache] already has key:",h),this._cache.set(h,n.get(h))})}remove(t){if(!this._cacheMap.has(t)){J(`[Assets] Asset id ${t} was not found in the Cache`);return}const e=this._cacheMap.get(t);e.cacheKeys.forEach(r=>{this._cache.delete(r)}),e.keys.forEach(r=>{this._cacheMap.delete(r)})}get parsers(){return this._parsers}}const $=new ao,Us=[];nt.handleByList(P.TextureSource,Us);function en(s={}){const t=s&&s.resource,e=t?s.resource:s,i=t?s:{resource:s};for(let r=0;r{$.has(i)&&$.remove(i)}),t||$.set(i,n),n}function ho(s,t=!1){return typeof s=="string"?$.get(s):s instanceof Ct?new G({source:s}):oo(s,t)}G.from=ho;Ct.from=en;nt.add(jr,qr,Kr,Ve,te,Zr,ri);var kt=(s=>(s[s.Low=0]="Low",s[s.Normal=1]="Normal",s[s.High=2]="High",s))(kt||{});function pt(s){if(typeof s!="string")throw new TypeError(`Path must be a string. Received ${JSON.stringify(s)}`)}function le(s){return s.split("?")[0].split("#")[0]}function lo(s){return s.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function co(s,t,e){return s.replace(new RegExp(lo(t),"g"),e)}function uo(s,t){let e="",i=0,r=-1,n=0,a=-1;for(let o=0;o<=s.length;++o){if(o2){const h=e.lastIndexOf("/");if(h!==e.length-1){h===-1?(e="",i=0):(e=e.slice(0,h),i=e.length-1-e.lastIndexOf("/")),r=o,n=0;continue}}else if(e.length===2||e.length===1){e="",i=0,r=o,n=0;continue}}}else e.length>0?e+=`/${s.slice(r+1,o)}`:e=s.slice(r+1,o),i=o-r-1;r=o,n=0}else a===46&&n!==-1?++n:n=-1}return e}const lt={toPosix(s){return co(s,"\\","/")},isUrl(s){return/^https?:/.test(this.toPosix(s))},isDataUrl(s){return/^data:([a-z]+\/[a-z0-9-+.]+(;[a-z0-9-.!#$%*+.{}|~`]+=[a-z0-9-.!#$%*+.{}()_|~`]+)*)?(;base64)?,([a-z0-9!$&',()*+;=\-._~:@\/?%\s<>]*?)$/i.test(s)},isBlobUrl(s){return s.startsWith("blob:")},hasProtocol(s){return/^[^/:]+:/.test(this.toPosix(s))},getProtocol(s){pt(s),s=this.toPosix(s);const t=/^file:\/\/\//.exec(s);if(t)return t[0];const e=/^[^/:]+:\/{0,2}/.exec(s);return e?e[0]:""},toAbsolute(s,t,e){if(pt(s),this.isDataUrl(s)||this.isBlobUrl(s))return s;const i=le(this.toPosix(t??j.get().getBaseUrl())),r=le(this.toPosix(e??this.rootname(i)));return s=this.toPosix(s),s.startsWith("/")?lt.join(r,s.slice(1)):this.isAbsolute(s)?s:this.join(i,s)},normalize(s){if(pt(s),s.length===0)return".";if(this.isDataUrl(s)||this.isBlobUrl(s))return s;s=this.toPosix(s);let t="";const e=s.startsWith("/");this.hasProtocol(s)&&(t=this.rootname(s),s=s.slice(t.length));const i=s.endsWith("/");return s=uo(s),s.length>0&&i&&(s+="/"),e?`/${s}`:t+s},isAbsolute(s){return pt(s),s=this.toPosix(s),this.hasProtocol(s)?!0:s.startsWith("/")},join(...s){if(s.length===0)return".";let t;for(let e=0;e0)if(t===void 0)t=i;else{const r=s[e-1]??"";this.joinExtensions.includes(this.extname(r).toLowerCase())?t+=`/../${i}`:t+=`/${i}`}}return t===void 0?".":this.normalize(t)},dirname(s){if(pt(s),s.length===0)return".";s=this.toPosix(s);let t=s.charCodeAt(0);const e=t===47;let i=-1,r=!0;const n=this.getProtocol(s),a=s;s=s.slice(n.length);for(let o=s.length-1;o>=1;--o)if(t=s.charCodeAt(o),t===47){if(!r){i=o;break}}else r=!1;return i===-1?e?"/":this.isUrl(a)?n+s:n:e&&i===1?"//":n+s.slice(0,i)},rootname(s){pt(s),s=this.toPosix(s);let t="";if(s.startsWith("/")?t="/":t=this.getProtocol(s),this.isUrl(s)){const e=s.indexOf("/",t.length);e!==-1?t=s.slice(0,e):t=s,t.endsWith("/")||(t+="/")}return t},basename(s,t){pt(s),t&&pt(t),s=le(this.toPosix(s));let e=0,i=-1,r=!0,n;if(t!==void 0&&t.length>0&&t.length<=s.length){if(t.length===s.length&&t===s)return"";let a=t.length-1,o=-1;for(n=s.length-1;n>=0;--n){const h=s.charCodeAt(n);if(h===47){if(!r){e=n+1;break}}else o===-1&&(r=!1,o=n+1),a>=0&&(h===t.charCodeAt(a)?--a===-1&&(i=n):(a=-1,i=o))}return e===i?i=o:i===-1&&(i=s.length),s.slice(e,i)}for(n=s.length-1;n>=0;--n)if(s.charCodeAt(n)===47){if(!r){e=n+1;break}}else i===-1&&(r=!1,i=n+1);return i===-1?"":s.slice(e,i)},extname(s){pt(s),s=le(this.toPosix(s));let t=-1,e=0,i=-1,r=!0,n=0;for(let a=s.length-1;a>=0;--a){const o=s.charCodeAt(a);if(o===47){if(!r){e=a+1;break}continue}i===-1&&(r=!1,i=a+1),o===46?t===-1?t=a:n!==1&&(n=1):t!==-1&&(n=-1)}return t===-1||i===-1||n===0||n===1&&t===i-1&&t===e+1?"":s.slice(t,i)},parse(s){pt(s);const t={root:"",dir:"",base:"",ext:"",name:""};if(s.length===0)return t;s=le(this.toPosix(s));let e=s.charCodeAt(0);const i=this.isAbsolute(s);let r;t.root=this.rootname(s),i||this.hasProtocol(s)?r=1:r=0;let n=-1,a=0,o=-1,h=!0,c=s.length-1,l=0;for(;c>=r;--c){if(e=s.charCodeAt(c),e===47){if(!h){a=c+1;break}continue}o===-1&&(h=!1,o=c+1),e===46?n===-1?n=c:l!==1&&(l=1):n!==-1&&(l=-1)}return n===-1||o===-1||l===0||l===1&&n===o-1&&n===a+1?o!==-1&&(a===0&&i?t.base=t.name=s.slice(1,o):t.base=t.name=s.slice(a,o)):(a===0&&i?(t.name=s.slice(1,n),t.base=s.slice(1,o)):(t.name=s.slice(a,n),t.base=s.slice(a,o)),t.ext=s.slice(n,o)),t.dir=this.dirname(s),t},sep:"/",delimiter:":",joinExtensions:[".html"]};function sn(s,t,e,i,r){const n=t[e];for(let a=0;a{const a=n.substring(1,n.length-1).split(",");r.push(a)}),sn(s,r,0,e,i)}else i.push(s);return i}const qe=s=>!Array.isArray(s);class ee{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(i=>`${encodeURIComponent(i)}=${encodeURIComponent(e[i])}`).join("&")}}getAlias(t){const{alias:e,src:i}=t;return gt(e||i,n=>typeof n=="string"?n:Array.isArray(n)?n.map(a=>(a==null?void 0:a.src)??a):n!=null&&n.src?n.src:n,!0)}addManifest(t){this._manifest&&J("[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 i=[];let r=e;Array.isArray(e)||(r=Object.entries(e).map(([n,a])=>typeof a=="string"||Array.isArray(a)?{alias:n,src:a}:{alias:n,...a})),r.forEach(n=>{const a=n.src,o=n.alias;let h;if(typeof o=="string"){const c=this._createBundleAssetId(t,o);i.push(c),h=[o,c]}else{const c=o.map(l=>this._createBundleAssetId(t,l));i.push(...c),h=[...o,...c]}this.add({...n,alias:h,src:a})}),this._bundles[t]=i}add(t){const e=[];Array.isArray(t)?e.push(...t):e.push(t);let i;i=n=>{this.hasKey(n)&&J(`[Resolver] already has key: ${n} overwriting`)},gt(e).forEach(n=>{const{src:a}=n;let{data:o,format:h,loadParser:c}=n;const l=gt(a).map(f=>typeof f=="string"?fo(f):Array.isArray(f)?f:[f]),u=this.getAlias(n);Array.isArray(u)?u.forEach(i):i(u);const d=[];l.forEach(f=>{f.forEach(p=>{let m={};if(typeof p!="object"){m.src=p;for(let g=0;g{this._assetMap[f]=d})})}resolveBundle(t){const e=qe(t);t=gt(t);const i={};return t.forEach(r=>{const n=this._bundles[r];if(n){const a=this.resolve(n),o={};for(const h in a){const c=a[h];o[this._extractAssetIdFromBundle(r,h)]=c}i[r]=o}}),e?i[t[0]]:i}resolveUrl(t){const e=this.resolve(t);if(typeof t!="string"){const i={};for(const r in e)i[r]=e[r].src;return i}return e.src}resolve(t){const e=qe(t);t=gt(t);const i={};return t.forEach(r=>{if(!this._resolverHash[r])if(this._assetMap[r]){let n=this._assetMap[r];const a=this._getPreferredOrder(n);a==null||a.priority.forEach(o=>{a.params[o].forEach(h=>{const c=n.filter(l=>l[o]?l[o]===h:!1);c.length&&(n=c)})}),this._resolverHash[r]=n[0]}else this._resolverHash[r]=this._buildResolvedAsset({alias:[r],src:r},{});i[r]=this._resolverHash[r]}),e?i[t[0]]:i}hasKey(t){return!!this._assetMap[t]}hasBundle(t){return!!this._bundles[t]}_getPreferredOrder(t){for(let e=0;en.params.format.includes(i.format));if(r)return r}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:i,data:r,loadParser:n,format:a}=e;return(this._basePath||this._rootPath)&&(t.src=lt.toAbsolute(t.src,this._basePath,this._rootPath)),t.alias=i??t.alias??[t.src],t.src=this._appendDefaultSearchParams(t.src),t.data={...r||{},...t.data},t.loadParser=n??t.loadParser,t.format=a??t.format??po(t.src),t}}ee.RETINA_PREFIX=/@([0-9\.]+)x/;function po(s){return s.split(".").pop().split("?").shift().split("#").shift()}const zs=(s,t)=>{const e=t.split("?")[1];return e&&(s+=`?${e}`),s},rn=class ge{constructor(t,e){this.linkedSheets=[],this._texture=t instanceof G?t:null,this.textureSource=t.source,this.textures={},this.animations={},this.data=e;const i=parseFloat(e.meta.scale);i?(this.resolution=i,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<=ge.BATCH_SIZE?(this._processFrames(0),this._processAnimations(),this._parseComplete()):this._nextBatch()})}_processFrames(t){let e=t;const i=ge.BATCH_SIZE;for(;e-t{this._batchIndex*ge.BATCH_SIZE{i[r]=t}),Object.keys(t.textures).forEach(r=>{i[r]=t.textures[r]}),!e){const r=lt.dirname(s[0]);t.linkedSheets.forEach((n,a)=>{const o=nn([`${r}/${t.data.meta.related_multi_packs[a]}`],n,!0);Object.assign(i,o)})}return i}const mo={extension:P.Asset,cache:{test:s=>s instanceof Ni,getCacheableAssets:(s,t)=>nn(s,t,!1)},resolver:{extension:{type:P.ResolveParser,name:"resolveSpritesheet"},test:s=>{const e=s.split("?")[0].split("."),i=e.pop(),r=e.pop();return i==="json"&&go.includes(r)},parse:s=>{var e;const t=s.split(".");return{resolution:parseFloat(((e=ee.RETINA_PREFIX.exec(s))==null?void 0:e[1])??"1"),format:t[t.length-2],src:s}}},loader:{name:"spritesheetLoader",extension:{type:P.LoadParser,priority:kt.Normal,name:"spritesheetLoader"},async testParse(s,t){return lt.extname(t.src).toLowerCase()===".json"&&!!s.frames},async parse(s,t,e){var c,l;const{texture:i,imageFilename:r}=(t==null?void 0:t.data)??{};let n=lt.dirname(t.src);n&&n.lastIndexOf("/")!==n.length-1&&(n+="/");let a;if(i instanceof G)a=i;else{const u=zs(n+(r??s.meta.image),t.src);a=(await e.load([u]))[u]}const o=new Ni(a.source,s);await o.parse();const h=(c=s==null?void 0:s.meta)==null?void 0:c.related_multi_packs;if(Array.isArray(h)){const u=[];for(const f of h){if(typeof f!="string")continue;let p=n+f;(l=t.data)!=null&&l.ignoreMultiPack||(p=zs(p,t.src),u.push(e.load({src:p,data:{ignoreMultiPack:!0}})))}const d=await Promise.all(u);o.linkedSheets=d,d.forEach(f=>{f.linkedSheets=[o].concat(o.linkedSheets.filter(p=>p!==f))})}return o},async unload(s,t,e){await e.unload(s.textureSource._sourceOrigin),s.destroy(!1)}}};nt.add(mo);const ys=Object.create(null),Vi=Object.create(null);function ai(s,t){let e=Vi[s];return e===void 0&&(ys[t]===void 0&&(ys[t]=1),Vi[s]=e=ys[t]++),e}let Ht;function an(){return(!Ht||Ht!=null&&Ht.isContextLost())&&(Ht=j.get().createCanvas().getContext("webgl",{})),Ht}let Ge;function xo(){if(!Ge){Ge="mediump";const s=an();s&&s.getShaderPrecisionFormat&&(Ge=s.getShaderPrecisionFormat(s.FRAGMENT_SHADER,s.HIGH_FLOAT).precision?"highp":"mediump")}return Ge}function yo(s,t,e){return t?s:e?(s=s.replace("out vec4 finalColor;",""),` +Deprecated since v${s}`),console.warn(i))),Ti[t]=!0}const Br=()=>{};function Mi(s){return s+=s===0?1:0,--s,s|=s>>>1,s|=s>>>2,s|=s>>>4,s|=s>>>8,s|=s>>>16,s+1}function Pi(s){return!(s&s-1)&&!!s}function Pa(s){const t={};for(const e in s)s[e]!==void 0&&(t[e]=s[e]);return t}const ki=Object.create(null);function ka(s){const t=ki[s];return t===void 0&&(ki[s]=tt("resource")),t}const Ir=class Fr extends at{constructor(t={}){super(),this._resourceType="textureSampler",this._touched=0,this._maxAnisotropy=1,this.destroyed=!1,t={...Fr.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){W(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=ka(t),this._resourceId}destroy(){this.destroyed=!0,this.emit("destroy",this),this.emit("change",this),this.removeAllListeners()}};Ir.defaultOptions={addressMode:"clamp-to-edge",scaleMode:"linear"};let Ea=Ir;const Rr=class Lr extends at{constructor(t={}){super(),this.options=t,this.uid=tt("textureSource"),this._resourceType="textureSource",this._resourceId=tt("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={...Lr.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 Ea(Pa(t)),this.destroyed=!1,this._refreshPOT()}get source(){return this}get style(){return this._style}set style(t){var e,i;this.style!==t&&((e=this._style)==null||e.off("change",this._onStyleChange,this),this._style=t,(i=this._style)==null||i.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=tt("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,i){i=i||this._resolution,t=t||this.width,e=e||this.height;const r=Math.round(t*i),n=Math.round(e*i);return this.width=r/i,this.height=n/i,this._resolution=i,this.pixelWidth===r&&this.pixelHeight===n?!1:(this._refreshPOT(),this.pixelWidth=r,this.pixelHeight=n,this.emit("resize",this),this._resourceId=tt("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=Pi(this.pixelWidth)&&Pi(this.pixelHeight)}static test(t){throw new Error("Unimplemented")}};Rr.defaultOptions={resolution:1,format:"bgra8unorm",alphaMode:"premultiply-alpha-on-upload",dimensions:"2d",mipLevelCount:1,autoGenerateMipmaps:!1,sampleCount:1,antialias:!1,autoGarbageCollect:!1};let Ct=Rr;class ri extends Ct{constructor(t){const e=t.resource||new Float32Array(t.width*t.height*4);let i=t.format;i||(e instanceof Float32Array?i="rgba32float":e instanceof Int32Array||e instanceof Uint32Array?i="rgba32uint":e instanceof Int16Array||e instanceof Uint16Array?i="rgba16uint":(e instanceof Int8Array,i="bgra8unorm")),super({...t,resource:e,format:i}),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}}ri.extension=P.TextureSource;const Ei=new D;class Ba{constructor(t,e){this.mapCoord=new D,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 i=this.mapCoord;for(let r=0;rthis.maxX||this.minY>this.maxY}get rectangle(){this._rectangle||(this._rectangle=new U);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=Bi,this}set(t,e,i,r){this.minX=t,this.minY=e,this.maxX=i,this.maxY=r}addFrame(t,e,i,r,n){n||(n=this.matrix);const a=n.a,o=n.b,h=n.c,c=n.d,l=n.tx,u=n.ty;let d=this.minX,f=this.minY,p=this.maxX,m=this.maxY,g=a*t+h*e+l,x=o*t+c*e+u;gp&&(p=g),x>m&&(m=x),g=a*i+h*e+l,x=o*i+c*e+u,gp&&(p=g),x>m&&(m=x),g=a*t+h*r+l,x=o*t+c*r+u,gp&&(p=g),x>m&&(m=x),g=a*i+h*r+l,x=o*i+c*r+u,gp&&(p=g),x>m&&(m=x),this.minX=d,this.minY=f,this.maxX=p,this.maxY=m}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?d:this.maxX,this.maxY=f>this.maxY?f:this.maxY,d=a*e+h*n+l,f=o*e+c*n+u,this.minX=dthis.maxX?d:this.maxX,this.maxY=f>this.maxY?f:this.maxY,d=a*r+h*n+l,f=o*r+c*n+u,this.minX=dthis.maxX?d:this.maxX,this.maxY=f>this.maxY?f:this.maxY}fit(t){return this.minXt.right&&(this.maxX=t.right),this.minYt.bottom&&(this.maxY=t.bottom),this}fitBounds(t,e,i,r){return this.minXe&&(this.maxX=e),this.minYr&&(this.maxY=r),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 bt(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,i,r){let n=this.minX,a=this.minY,o=this.maxX,h=this.maxY;r||(r=this.matrix);const c=r.a,l=r.b,u=r.c,d=r.d,f=r.tx,p=r.ty;for(let m=e;mo?y:o,h=_>h?_:h}this.minX=n,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 Fa={grad:.9,turn:360,rad:360/(2*Math.PI)},vt=function(s){return typeof s=="string"?s.length>0:typeof s=="number"},st=function(s,t,e){return t===void 0&&(t=0),e===void 0&&(e=Math.pow(10,t)),Math.round(e*s)/e+0},ut=function(s,t,e){return t===void 0&&(t=0),e===void 0&&(e=1),s>e?e:s>t?s:t},Gr=function(s){return(s=isFinite(s)?s%360:0)>0?s:s+360},Ii=function(s){return{r:ut(s.r,0,255),g:ut(s.g,0,255),b:ut(s.b,0,255),a:ut(s.a)}},hs=function(s){return{r:st(s.r),g:st(s.g),b:st(s.b),a:st(s.a,3)}},Ra=/^#([0-9a-f]{3,8})$/i,Ge=function(s){var t=s.toString(16);return t.length<2?"0"+t:t},Wr=function(s){var t=s.r,e=s.g,i=s.b,r=s.a,n=Math.max(t,e,i),a=n-Math.min(t,e,i),o=a?n===t?(e-i)/a:n===e?2+(i-t)/a:4+(t-e)/a:0;return{h:60*(o<0?o+6:o),s:n?a/n*100:0,v:n/255*100,a:r}},Or=function(s){var t=s.h,e=s.s,i=s.v,r=s.a;t=t/360*6,e/=100,i/=100;var n=Math.floor(t),a=i*(1-e),o=i*(1-(t-n)*e),h=i*(1-(1-t+n)*e),c=n%6;return{r:255*[i,o,a,a,h,i][c],g:255*[h,i,i,o,a,a][c],b:255*[a,a,h,i,i,o][c],a:r}},Fi=function(s){return{h:Gr(s.h),s:ut(s.s,0,100),l:ut(s.l,0,100),a:ut(s.a)}},Ri=function(s){return{h:st(s.h),s:st(s.s),l:st(s.l),a:st(s.a,3)}},Li=function(s){return Or((e=(t=s).s,{h:t.h,s:(e*=((i=t.l)<50?i:100-i)/100)>0?2*e/(i+e)*100:0,v:i+e,a:t.a}));var t,e,i},_e=function(s){return{h:(t=Wr(s)).h,s:(r=(200-(e=t.s))*(i=t.v)/100)>0&&r<200?e*i/100/(r<=100?r:200-r)*100:0,l:r/2,a:t.a};var t,e,i,r},La=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Ga=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Wa=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Oa=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Gs={string:[[function(s){var t=Ra.exec(s);return t?(s=t[1]).length<=4?{r:parseInt(s[0]+s[0],16),g:parseInt(s[1]+s[1],16),b:parseInt(s[2]+s[2],16),a:s.length===4?st(parseInt(s[3]+s[3],16)/255,2):1}:s.length===6||s.length===8?{r:parseInt(s.substr(0,2),16),g:parseInt(s.substr(2,2),16),b:parseInt(s.substr(4,2),16),a:s.length===8?st(parseInt(s.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(s){var t=Wa.exec(s)||Oa.exec(s);return t?t[2]!==t[4]||t[4]!==t[6]?null:Ii({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(s){var t=La.exec(s)||Ga.exec(s);if(!t)return null;var e,i,r=Fi({h:(e=t[1],i=t[2],i===void 0&&(i="deg"),Number(e)*(Fa[i]||1)),s:Number(t[3]),l:Number(t[4]),a:t[5]===void 0?1:Number(t[5])/(t[6]?100:1)});return Li(r)},"hsl"]],object:[[function(s){var t=s.r,e=s.g,i=s.b,r=s.a,n=r===void 0?1:r;return vt(t)&&vt(e)&&vt(i)?Ii({r:Number(t),g:Number(e),b:Number(i),a:Number(n)}):null},"rgb"],[function(s){var t=s.h,e=s.s,i=s.l,r=s.a,n=r===void 0?1:r;if(!vt(t)||!vt(e)||!vt(i))return null;var a=Fi({h:Number(t),s:Number(e),l:Number(i),a:Number(n)});return Li(a)},"hsl"],[function(s){var t=s.h,e=s.s,i=s.v,r=s.a,n=r===void 0?1:r;if(!vt(t)||!vt(e)||!vt(i))return null;var a=function(o){return{h:Gr(o.h),s:ut(o.s,0,100),v:ut(o.v,0,100),a:ut(o.a)}}({h:Number(t),s:Number(e),v:Number(i),a:Number(n)});return Or(a)},"hsv"]]},Gi=function(s,t){for(var e=0;e=.5},s.prototype.toHex=function(){return t=hs(this.rgba),e=t.r,i=t.g,r=t.b,a=(n=t.a)<1?Ge(st(255*n)):"","#"+Ge(e)+Ge(i)+Ge(r)+a;var t,e,i,r,n,a},s.prototype.toRgb=function(){return hs(this.rgba)},s.prototype.toRgbString=function(){return t=hs(this.rgba),e=t.r,i=t.g,r=t.b,(n=t.a)<1?"rgba("+e+", "+i+", "+r+", "+n+")":"rgb("+e+", "+i+", "+r+")";var t,e,i,r,n},s.prototype.toHsl=function(){return Ri(_e(this.rgba))},s.prototype.toHslString=function(){return t=Ri(_e(this.rgba)),e=t.h,i=t.s,r=t.l,(n=t.a)<1?"hsla("+e+", "+i+"%, "+r+"%, "+n+")":"hsl("+e+", "+i+"%, "+r+"%)";var t,e,i,r,n},s.prototype.toHsv=function(){return t=Wr(this.rgba),{h:st(t.h),s:st(t.s),v:st(t.v),a:st(t.a,3)};var t},s.prototype.invert=function(){return yt({r:255-(t=this.rgba).r,g:255-t.g,b:255-t.b,a:t.a});var t},s.prototype.saturate=function(t){return t===void 0&&(t=.1),yt(ls(this.rgba,t))},s.prototype.desaturate=function(t){return t===void 0&&(t=.1),yt(ls(this.rgba,-t))},s.prototype.grayscale=function(){return yt(ls(this.rgba,-1))},s.prototype.lighten=function(t){return t===void 0&&(t=.1),yt(Wi(this.rgba,t))},s.prototype.darken=function(t){return t===void 0&&(t=.1),yt(Wi(this.rgba,-t))},s.prototype.rotate=function(t){return t===void 0&&(t=15),this.hue(this.hue()+t)},s.prototype.alpha=function(t){return typeof t=="number"?yt({r:(e=this.rgba).r,g:e.g,b:e.b,a:t}):st(this.rgba.a,3);var e},s.prototype.hue=function(t){var e=_e(this.rgba);return typeof t=="number"?yt({h:t,s:e.s,l:e.l,a:e.a}):st(e.h)},s.prototype.isEqual=function(t){return this.toHex()===yt(t).toHex()},s}(),yt=function(s){return s instanceof Ws?s:new Ws(s)},Oi=[],Ua=function(s){s.forEach(function(t){Oi.indexOf(t)<0&&(t(Ws,Gs),Oi.push(t))})};function za(s,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"},i={};for(var r in e)i[e[r]]=r;var n={};s.prototype.toName=function(a){if(!(this.rgba.a||this.rgba.r||this.rgba.g||this.rgba.b))return"transparent";var o,h,c=i[this.toHex()];if(c)return c;if(a!=null&&a.closest){var l=this.toRgb(),u=1/0,d="black";if(!n.length)for(var f in e)n[f]=new s(e[f]).toRgb();for(var p in e){var m=(o=l,h=n[p],Math.pow(o.r-h.r,2)+Math.pow(o.g-h.g,2)+Math.pow(o.b-h.b,2));mn===e[a]);if(t!==null&&e!==null){const n=Object.keys(t),a=Object.keys(e);return n.length!==a.length?!1:n.every(o=>t[o]===e[o])}return t===e}toRgba(){const[t,e,i,r]=this._components;return{r:t,g:e,b:i,a:r}}toRgb(){const[t,e,i]=this._components;return{r:t,g:e,b:i}}toRgbaString(){const[t,e,i]=this.toUint8RgbArray();return`rgba(${t},${e},${i},${this.alpha})`}toUint8RgbArray(t){const[e,i,r]=this._components;return this._arrayRgb||(this._arrayRgb=[]),t=t||this._arrayRgb,t[0]=Math.round(e*255),t[1]=Math.round(i*255),t[2]=Math.round(r*255),t}toArray(t){this._arrayRgba||(this._arrayRgba=[]),t=t||this._arrayRgba;const[e,i,r,n]=this._components;return t[0]=e,t[1]=i,t[2]=r,t[3]=n,t}toRgbArray(t){this._arrayRgb||(this._arrayRgb=[]),t=t||this._arrayRgb;const[e,i,r]=this._components;return t[0]=e,t[1]=i,t[2]=r,t}toNumber(){return this._int}toBgrNumber(){const[t,e,i]=this.toUint8RgbArray();return(i<<16)+(e<<8)+t}toLittleEndianNumber(){const t=this._int;return(t>>16)+(t&65280)+((t&255)<<16)}multiply(t){const[e,i,r,n]=ge._temp.setValue(t)._components;return this._components[0]*=e,this._components[1]*=i,this._components[2]*=r,this._components[3]*=n,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 i=this._int>>16&255,r=this._int>>8&255,n=this._int&255;return e&&(i=i*t+.5|0,r=r*t+.5|0,n=n*t+.5|0),(t*255<<24)+(i<<16)+(r<<8)+n}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,i,r,n;if((typeof t=="number"||t instanceof Number)&&t>=0&&t<=16777215){const a=t;e=(a>>16&255)/255,i=(a>>8&255)/255,r=(a&255)/255,n=1}else if((Array.isArray(t)||t instanceof Float32Array)&&t.length>=3&&t.length<=4)t=this._clamp(t),[e,i,r,n=1]=t;else if((t instanceof Uint8Array||t instanceof Uint8ClampedArray)&&t.length>=3&&t.length<=4)t=this._clamp(t,0,255),[e,i,r,n=255]=t,e/=255,i/=255,r/=255,n/=255;else if(typeof t=="string"||typeof t=="object"){if(typeof t=="string"){const o=ge.HEX_PATTERN.exec(t);o&&(t=`#${o[2]}`)}const a=yt(t);a.isValid()&&({r:e,g:i,b:r,a:n}=a.rgba,e/=255,i/=255,r/=255)}if(e!==void 0)this._components[0]=e,this._components[1]=i,this._components[2]=r,this._components[3]=n,this._refreshInt();else throw new Error(`Unable to convert color ${t}`)}_refreshInt(){this._clamp(this._components);const[t,e,i]=this._components;this._int=(t*255<<16)+(e*255<<8)+(i*255|0)}_clamp(t,e=0,i=1){return typeof t=="number"?Math.min(Math.max(t,e),i):(t.forEach((r,n)=>{t[n]=Math.min(Math.max(r,e),i)}),t)}static isColorLike(t){return typeof t=="number"||typeof t=="string"||t instanceof Number||t instanceof ge||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}};Kt.shared=new Kt;Kt._temp=new Kt;Kt.HEX_PATTERN=/^(#|0x)?(([a-f0-9]{3}){1,2}([a-f0-9]{2})?)$/i;let Q=Kt;const Ha={cullArea:null,cullable:!1,cullableChildren:!0};class ni{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,(i=e.init)==null||i.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 Na{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 ni(t)),this._poolsByClass.get(t)}stats(){const t={};return this._poolsByClass.forEach(e=>{const i=t[e._classType.name]?e._classType.name+e._classType.ID:e._classType.name;t[i]={free:e.totalFree,used:e.totalUsed,size:e.totalSize}}),t}}const At=new Na;function Va(s,t,e){const i=s.length;let r;if(t>=i||e===0)return;e=t+e>i?i-t:e;const n=i-e;for(r=t;r0&&i<=e){for(let a=e-1;a>=s;a--){const o=this.children[a];o&&(r.push(o),o.parent=null)}Va(this.children,s,e);const n=this.renderGroup||this.parentRenderGroup;n&&n.removeChildren(r);for(let a=0;a=this.children.length)throw new Error(`getChildAt: Index (${s}) does not exist.`);return this.children[s]},setChildIndex(s,t){if(t<0||t>=this.children.length)throw new Error(`The index ${t} supplied is out of bounds ${this.children.length}`);this.getChildIndex(s),this.addChildAt(s,t)},getChildIndex(s){const t=this.children.indexOf(s);if(t===-1)throw new Error("The supplied Container must be a child of the caller");return t},addChildAt(s,t){this.allowChildren||W(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(`${s}addChildAt: The index ${t} supplied is out of bounds ${e.length}`);if(s.parent){const r=s.parent.children.indexOf(s);if(s.parent===this&&r===t)return s;r!==-1&&s.parent.children.splice(r,1)}t===e.length?e.push(s):e.splice(t,0,s),s.parent=this,s.didChange=!0,s.didViewUpdate=!1,s._updateFlags=15;const i=this.renderGroup||this.parentRenderGroup;return i&&i.addChild(s),this.sortableChildren&&(this.sortDirty=!0),this.emit("childAdded",s,this,t),s.emit("added",this),s},swapChildren(s,t){if(s===t)return;const e=this.getChildIndex(s),i=this.getChildIndex(t);this.children[e]=t,this.children[i]=s;const r=this.renderGroup||this.parentRenderGroup;r&&(r.structureDidChange=!0),this._didContainerChangeTick++},removeFromParent(){var s;(s=this.parent)==null||s.removeChild(this)},reparentChild(...s){return s.length===1?this.reparentChildAt(s[0],this.children.length):(s.forEach(t=>this.reparentChildAt(t,this.children.length)),s[0])},reparentChildAt(s,t){if(s.parent===this)return this.setChildIndex(s,t),s;const e=s.worldTransform.clone();s.removeFromParent(),this.addChildAt(s,t);const i=this.worldTransform.clone();return i.invert(),e.prepend(i),s.setFromMatrix(e),s}};class Di{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;ei.priority-r.priority);const e=this.renderGroup||this.parentRenderGroup;e&&(e.structureDidChange=!0),this._updateIsSimple()},removeEffect(s){const t=this.effects.indexOf(s);t!==-1&&(this.effects.splice(t,1),this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._updateIsSimple())},set mask(s){const t=this._maskEffect;(t==null?void 0:t.mask)!==s&&(t&&(this.removeEffect(t),Os.returnMaskEffect(t),this._maskEffect=null),s!=null&&(this._maskEffect=Os.getMaskEffect(s),this.addEffect(this._maskEffect)))},get mask(){var s;return(s=this._maskEffect)==null?void 0:s.mask},set filters(s){var n;!Array.isArray(s)&&s&&(s=[s]);const t=this._filterEffect||(this._filterEffect=new Di);s=s;const e=(s==null?void 0:s.length)>0,i=((n=t.filters)==null?void 0:n.length)>0,r=e!==i;s=Array.isArray(s)?s.slice(0):s,t.filters=Object.freeze(s),r&&(e?this.addEffect(t):(this.removeEffect(t),t.filters=s??null))},get filters(){var s;return(s=this._filterEffect)==null?void 0:s.filters},set filterArea(s){this._filterEffect||(this._filterEffect=new Di),this._filterEffect.filterArea=s},get filterArea(){var s;return(s=this._filterEffect)==null?void 0:s.filterArea}},ja={label:null,get name(){return W(O,"Container.name property has been removed, use Container.label instead"),this.label},set name(s){W(O,"Container.name property has been removed, use Container.label instead"),this.label=s},getChildByName(s,t=!1){return this.getChildByLabel(s,t)},getChildByLabel(s,t=!1){const e=this.children;for(let i=0;i-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 i=0;i0}addOnRender(t){this._onRenderContainers.push(t)}removeOnRender(t){this._onRenderContainers.splice(this._onRenderContainers.indexOf(t),1)}runOnRender(){for(let t=0;tthis.addChild(r)),(i=t.parent)==null||i.addChild(this)}static mixin(t){Object.defineProperties(rt.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||W(O,"addChild: Only Containers will be allowed to add children in v8.0.0"),t.length>1){for(let r=0;r1){for(let r=0;r-1&&(this._didViewChangeTick++,this.children.splice(i,1),this.renderGroup?this.renderGroup.removeChild(e):this.parentRenderGroup&&this.parentRenderGroup.removeChild(e),e.parent=null,this.emit("childRemoved",e,this,i),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=At.get(so,this),this.groupTransform=D.IDENTITY,t==null||t.addChild(this),this._updateIsSimple()}disableRenderGroup(){if(!this.renderGroup)return;const t=this.parentRenderGroup;t==null||t.removeChild(this),At.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 D),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*va}set angle(t){this.rotation=t*Aa}get pivot(){return this._pivot===fs&&(this._pivot=new ot(this,0,0)),this._pivot}set pivot(t){this._pivot===fs&&(this._pivot=new ot(this,0,0)),typeof t=="number"?this._pivot.set(t):this._pivot.copyFrom(t)}get skew(){return this._skew===ds&&(this._skew=new ot(this,0,0)),this._skew}set skew(t){this._skew===ds&&(this._skew=new ot(this,0,0)),this._skew.copyFrom(t)}get scale(){return this._scale===ps&&(this._scale=new ot(this,1,1)),this._scale}set scale(t){this._scale===ps&&(this._scale=new ot(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 i=this.getLocalBounds();typeof t=="object"?(e=t.height??t.width,t=t.width):e??(e=t),t!==void 0&&this._setWidth(t,i.width),e!==void 0&&this._setHeight(e,i.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,i=this._scale,r=this._pivot,n=this._position,a=i._x,o=i._y,h=r._x,c=r._y;e.a=this._cx*a,e.b=this._sx*a,e.c=this._cy*o,e.d=this._sy*o,e.tx=n._x-(h*e.a+c*e.c),e.ty=n._y-(h*e.b+c*e.d)}set alpha(t){t!==this.localAlpha&&(this.localAlpha=t,this._updateFlags|=zi,this._onUpdate())}get alpha(){return this.localAlpha}set tint(t){const i=Q.shared.setValue(t??16777215).toBgrNumber();i!==this.localColor&&(this.localColor=i,this._updateFlags|=zi,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|=ro,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|=gs,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|=gs,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|=gs,this.localDisplayStatus^=1,this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._onUpdate())}get isRenderable(){return this.localDisplayStatus===7&&this.groupAlpha>0}destroy(t=!1){var r;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 n=0;n=e.minX&&i<=e.maxX&&r>=e.minY&&r<=e.maxY}destroy(t){super.destroy(t),this._bounds=null}}class dt extends Qe{constructor(t=G.EMPTY){t instanceof G&&(t={texture:t});const{texture:e=G.EMPTY,anchor:i,roundPixels:r,width:n,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 ot({_onUpdate:()=>{this.onViewUpdate()}}),i?this.anchor=i:e.defaultAnchor&&(this.anchor=e.defaultAnchor),this.texture=e,this.allowChildren=!1,this.roundPixels=r??!1,n!==void 0&&(this.width=n),a!==void 0&&(this.height=a)}static from(t,e=!1){return t instanceof G?new dt(t):new dt(G.from(t,e))}set texture(t){t||(t=G.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(){Ia(this._bounds,this._anchor,this._texture,0)}_updateSourceBounds(){const t=this._anchor,e=this._texture,i=this._sourceBounds,{width:r,height:n}=e.orig;i.maxX=-t._x*r,i.minX=i.maxX+r,i.maxY=-t._y*n,i.minY=i.maxY+n}destroy(t=!1){if(super.destroy(t),typeof t=="boolean"?t:t==null?void 0:t.texture){const i=typeof t=="boolean"?t:t==null?void 0:t.textureSource;this._texture.destroy(i)}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 no=new bt;function $r(s,t,e){const i=no;s.measurable=!0,Dr(s,e,i),t.addBoundsMask(i),s.measurable=!1}function Xr(s,t,e){const i=Zt.get();s.measurable=!0;const r=St.get().identity(),n=Yr(s,e,r);zr(s,i,n),s.measurable=!1,t.addBoundsMask(i),St.return(r),Zt.return(i)}function Yr(s,t,e){return s?(s!==t&&(Yr(s.parent,t,e),s.updateLocalTransform(),e.append(s.localTransform)),e):(J("Mask bounds, renderable is not inside the root container"),e)}class jr{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 dt),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){Xr(this.mask,t,e)}containsPoint(t,e){const i=this.mask;return e(i,t)}destroy(){this.reset()}static test(t){return t instanceof dt}}jr.extension=P.MaskEffect;class qr{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"}}qr.extension=P.MaskEffect;class Kr{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){Xr(this.mask,t,e)}containsPoint(t,e){const i=this.mask;return e(i,t)}destroy(){this.reset()}static test(t){return t instanceof rt}}Kr.extension=P.MaskEffect;const ao={createCanvas:(s,t)=>{const e=document.createElement("canvas");return e.width=s,e.height=t,e},getCanvasRenderingContext2D:()=>CanvasRenderingContext2D,getWebGLRenderingContext:()=>WebGLRenderingContext,getNavigator:()=>navigator,getBaseUrl:()=>document.baseURI??window.location.href,getFontFaceSet:()=>document.fonts,fetch:(s,t)=>fetch(s,t),parseXML:s=>new DOMParser().parseFromString(s,"text/xml")};let Hi=ao;const j={get(){return Hi},set(s){Hi=s}};class Zr extends Ct{constructor(t){t.resource||(t.resource=j.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,i=this._resolution){const r=super.resize(t,e,i);return r&&this.resizeCanvas(),r}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"))}}Zr.extension=P.TextureSource;class se extends Ct{constructor(t){if(t.resource&&globalThis.HTMLImageElement&&t.resource instanceof HTMLImageElement){const e=j.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,J("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}}se.extension=P.TextureSource;var Ds=(s=>(s[s.INTERACTION=50]="INTERACTION",s[s.HIGH=25]="HIGH",s[s.NORMAL=0]="NORMAL",s[s.LOW=-25]="LOW",s[s.UTILITY=-50]="UTILITY",s))(Ds||{});class ms{constructor(t,e=null,i=0,r=!1){this.next=null,this.previous=null,this._destroyed=!1,this._fn=t,this._context=e,this.priority=i,this._once=r}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 Qr=class ht{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 ms(null,null,1/0),this.deltaMS=1/ht.targetFPMS,this.elapsedMS=1/ht.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,i=Ds.NORMAL){return this._addListener(new ms(t,e,i))}addOnce(t,e,i=Ds.NORMAL){return this._addListener(new ms(t,e,i,!0))}_addListener(t){let e=this._head.next,i=this._head;if(!e)t.connect(i);else{for(;e;){if(t.priority>e.priority){t.connect(i);break}i=e,e=e.next}t.previous||t.connect(i)}return this._startIfPossible(),this}remove(t,e){let i=this._head.next;for(;i;)i.match(t,e)?i=i.destroy():i=i.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 n=t-this._lastFrame|0;if(n{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 i=t.createTexture();t.bindTexture(t.TEXTURE_2D,i);const r=t.createFramebuffer();t.bindFramebuffer(t.FRAMEBUFFER,r),t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,i,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 n=new Uint8Array(4);return t.readPixels(0,0,1,1,t.RGBA,t.UNSIGNED_BYTE,n),t.deleteFramebuffer(r),t.deleteTexture(i),(a=t.getExtension("WEBGL_lose_context"))==null||a.loseContext(),n[0]<=n[3]?"premultiplied-alpha":"premultiply-alpha-on-upload"})()),xs}const Je=class tn extends Ct{constructor(t){super(t),this.isReady=!1,this.uploadMethodId="video",t={...tn.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=me.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 Jr(),this._load=new Promise((i,r)=>{this.isValid?i(this):(this._resolve=i,this._reject=r,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&&(me.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||(me.shared.add(this.updateFrame,this),this._isConnectedToTicker=!0,this._msToNextUpdate=0)):(this._videoFrameRequestCallbackHandle!==null&&(this.resource.cancelVideoFrameCallback(this._videoFrameRequestCallbackHandle),this._videoFrameRequestCallbackHandle=null),this._isConnectedToTicker&&(me.shared.remove(this.updateFrame,this),this._isConnectedToTicker=!1,this._msToNextUpdate=0))}static test(t){return globalThis.HTMLVideoElement&&t instanceof HTMLVideoElement}};Je.extension=P.TextureSource;Je.defaultOptions={...Ct.defaultOptions,autoLoad:!0,autoPlay:!0,updateFPS:0,crossorigin:!0,loop:!1,muted:!0,playsinline:!0,preload:!1};Je.MIME_TYPES={ogv:"video/ogg",mov:"video/quicktime",m4v:"video/mp4"};let $e=Je;const gt=(s,t,e=!1)=>(Array.isArray(s)||(s=[s]),t?s.map(i=>typeof i=="string"||e?t(i):i):s);class oo{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||J(`[Assets] Asset id ${t} was not found in the Cache`),e}set(t,e){const i=gt(t);let r;for(let h=0;h{n.set(h,e)});const a=[...n.keys()],o={cacheKeys:a,keys:i};i.forEach(h=>{this._cacheMap.set(h,o)}),a.forEach(h=>{const c=r?r[h]:e;this._cache.has(h)&&this._cache.get(h)!==c&&J("[Cache] already has key:",h),this._cache.set(h,n.get(h))})}remove(t){if(!this._cacheMap.has(t)){J(`[Assets] Asset id ${t} was not found in the Cache`);return}const e=this._cacheMap.get(t);e.cacheKeys.forEach(r=>{this._cache.delete(r)}),e.keys.forEach(r=>{this._cacheMap.delete(r)})}get parsers(){return this._parsers}}const $=new oo,Us=[];nt.handleByList(P.TextureSource,Us);function en(s={}){const t=s&&s.resource,e=t?s.resource:s,i=t?s:{resource:s};for(let r=0;r{$.has(i)&&$.remove(i)}),t||$.set(i,n),n}function lo(s,t=!1){return typeof s=="string"?$.get(s):s instanceof Ct?new G({source:s}):ho(s,t)}G.from=lo;Ct.from=en;nt.add(jr,qr,Kr,$e,se,Zr,ri);var kt=(s=>(s[s.Low=0]="Low",s[s.Normal=1]="Normal",s[s.High=2]="High",s))(kt||{});function pt(s){if(typeof s!="string")throw new TypeError(`Path must be a string. Received ${JSON.stringify(s)}`)}function ue(s){return s.split("?")[0].split("#")[0]}function co(s){return s.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function uo(s,t,e){return s.replace(new RegExp(co(t),"g"),e)}function fo(s,t){let e="",i=0,r=-1,n=0,a=-1;for(let o=0;o<=s.length;++o){if(o2){const h=e.lastIndexOf("/");if(h!==e.length-1){h===-1?(e="",i=0):(e=e.slice(0,h),i=e.length-1-e.lastIndexOf("/")),r=o,n=0;continue}}else if(e.length===2||e.length===1){e="",i=0,r=o,n=0;continue}}}else e.length>0?e+=`/${s.slice(r+1,o)}`:e=s.slice(r+1,o),i=o-r-1;r=o,n=0}else a===46&&n!==-1?++n:n=-1}return e}const lt={toPosix(s){return uo(s,"\\","/")},isUrl(s){return/^https?:/.test(this.toPosix(s))},isDataUrl(s){return/^data:([a-z]+\/[a-z0-9-+.]+(;[a-z0-9-.!#$%*+.{}|~`]+=[a-z0-9-.!#$%*+.{}()_|~`]+)*)?(;base64)?,([a-z0-9!$&',()*+;=\-._~:@\/?%\s<>]*?)$/i.test(s)},isBlobUrl(s){return s.startsWith("blob:")},hasProtocol(s){return/^[^/:]+:/.test(this.toPosix(s))},getProtocol(s){pt(s),s=this.toPosix(s);const t=/^file:\/\/\//.exec(s);if(t)return t[0];const e=/^[^/:]+:\/{0,2}/.exec(s);return e?e[0]:""},toAbsolute(s,t,e){if(pt(s),this.isDataUrl(s)||this.isBlobUrl(s))return s;const i=ue(this.toPosix(t??j.get().getBaseUrl())),r=ue(this.toPosix(e??this.rootname(i)));return s=this.toPosix(s),s.startsWith("/")?lt.join(r,s.slice(1)):this.isAbsolute(s)?s:this.join(i,s)},normalize(s){if(pt(s),s.length===0)return".";if(this.isDataUrl(s)||this.isBlobUrl(s))return s;s=this.toPosix(s);let t="";const e=s.startsWith("/");this.hasProtocol(s)&&(t=this.rootname(s),s=s.slice(t.length));const i=s.endsWith("/");return s=fo(s),s.length>0&&i&&(s+="/"),e?`/${s}`:t+s},isAbsolute(s){return pt(s),s=this.toPosix(s),this.hasProtocol(s)?!0:s.startsWith("/")},join(...s){if(s.length===0)return".";let t;for(let e=0;e0)if(t===void 0)t=i;else{const r=s[e-1]??"";this.joinExtensions.includes(this.extname(r).toLowerCase())?t+=`/../${i}`:t+=`/${i}`}}return t===void 0?".":this.normalize(t)},dirname(s){if(pt(s),s.length===0)return".";s=this.toPosix(s);let t=s.charCodeAt(0);const e=t===47;let i=-1,r=!0;const n=this.getProtocol(s),a=s;s=s.slice(n.length);for(let o=s.length-1;o>=1;--o)if(t=s.charCodeAt(o),t===47){if(!r){i=o;break}}else r=!1;return i===-1?e?"/":this.isUrl(a)?n+s:n:e&&i===1?"//":n+s.slice(0,i)},rootname(s){pt(s),s=this.toPosix(s);let t="";if(s.startsWith("/")?t="/":t=this.getProtocol(s),this.isUrl(s)){const e=s.indexOf("/",t.length);e!==-1?t=s.slice(0,e):t=s,t.endsWith("/")||(t+="/")}return t},basename(s,t){pt(s),t&&pt(t),s=ue(this.toPosix(s));let e=0,i=-1,r=!0,n;if(t!==void 0&&t.length>0&&t.length<=s.length){if(t.length===s.length&&t===s)return"";let a=t.length-1,o=-1;for(n=s.length-1;n>=0;--n){const h=s.charCodeAt(n);if(h===47){if(!r){e=n+1;break}}else o===-1&&(r=!1,o=n+1),a>=0&&(h===t.charCodeAt(a)?--a===-1&&(i=n):(a=-1,i=o))}return e===i?i=o:i===-1&&(i=s.length),s.slice(e,i)}for(n=s.length-1;n>=0;--n)if(s.charCodeAt(n)===47){if(!r){e=n+1;break}}else i===-1&&(r=!1,i=n+1);return i===-1?"":s.slice(e,i)},extname(s){pt(s),s=ue(this.toPosix(s));let t=-1,e=0,i=-1,r=!0,n=0;for(let a=s.length-1;a>=0;--a){const o=s.charCodeAt(a);if(o===47){if(!r){e=a+1;break}continue}i===-1&&(r=!1,i=a+1),o===46?t===-1?t=a:n!==1&&(n=1):t!==-1&&(n=-1)}return t===-1||i===-1||n===0||n===1&&t===i-1&&t===e+1?"":s.slice(t,i)},parse(s){pt(s);const t={root:"",dir:"",base:"",ext:"",name:""};if(s.length===0)return t;s=ue(this.toPosix(s));let e=s.charCodeAt(0);const i=this.isAbsolute(s);let r;t.root=this.rootname(s),i||this.hasProtocol(s)?r=1:r=0;let n=-1,a=0,o=-1,h=!0,c=s.length-1,l=0;for(;c>=r;--c){if(e=s.charCodeAt(c),e===47){if(!h){a=c+1;break}continue}o===-1&&(h=!1,o=c+1),e===46?n===-1?n=c:l!==1&&(l=1):n!==-1&&(l=-1)}return n===-1||o===-1||l===0||l===1&&n===o-1&&n===a+1?o!==-1&&(a===0&&i?t.base=t.name=s.slice(1,o):t.base=t.name=s.slice(a,o)):(a===0&&i?(t.name=s.slice(1,n),t.base=s.slice(1,o)):(t.name=s.slice(a,n),t.base=s.slice(a,o)),t.ext=s.slice(n,o)),t.dir=this.dirname(s),t},sep:"/",delimiter:":",joinExtensions:[".html"]};function sn(s,t,e,i,r){const n=t[e];for(let a=0;a{const a=n.substring(1,n.length-1).split(",");r.push(a)}),sn(s,r,0,e,i)}else i.push(s);return i}const Ke=s=>!Array.isArray(s);class ie{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(i=>`${encodeURIComponent(i)}=${encodeURIComponent(e[i])}`).join("&")}}getAlias(t){const{alias:e,src:i}=t;return gt(e||i,n=>typeof n=="string"?n:Array.isArray(n)?n.map(a=>(a==null?void 0:a.src)??a):n!=null&&n.src?n.src:n,!0)}addManifest(t){this._manifest&&J("[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 i=[];let r=e;Array.isArray(e)||(r=Object.entries(e).map(([n,a])=>typeof a=="string"||Array.isArray(a)?{alias:n,src:a}:{alias:n,...a})),r.forEach(n=>{const a=n.src,o=n.alias;let h;if(typeof o=="string"){const c=this._createBundleAssetId(t,o);i.push(c),h=[o,c]}else{const c=o.map(l=>this._createBundleAssetId(t,l));i.push(...c),h=[...o,...c]}this.add({...n,alias:h,src:a})}),this._bundles[t]=i}add(t){const e=[];Array.isArray(t)?e.push(...t):e.push(t);let i;i=n=>{this.hasKey(n)&&J(`[Resolver] already has key: ${n} overwriting`)},gt(e).forEach(n=>{const{src:a}=n;let{data:o,format:h,loadParser:c}=n;const l=gt(a).map(f=>typeof f=="string"?po(f):Array.isArray(f)?f:[f]),u=this.getAlias(n);Array.isArray(u)?u.forEach(i):i(u);const d=[];l.forEach(f=>{f.forEach(p=>{let m={};if(typeof p!="object"){m.src=p;for(let g=0;g{this._assetMap[f]=d})})}resolveBundle(t){const e=Ke(t);t=gt(t);const i={};return t.forEach(r=>{const n=this._bundles[r];if(n){const a=this.resolve(n),o={};for(const h in a){const c=a[h];o[this._extractAssetIdFromBundle(r,h)]=c}i[r]=o}}),e?i[t[0]]:i}resolveUrl(t){const e=this.resolve(t);if(typeof t!="string"){const i={};for(const r in e)i[r]=e[r].src;return i}return e.src}resolve(t){const e=Ke(t);t=gt(t);const i={};return t.forEach(r=>{if(!this._resolverHash[r])if(this._assetMap[r]){let n=this._assetMap[r];const a=this._getPreferredOrder(n);a==null||a.priority.forEach(o=>{a.params[o].forEach(h=>{const c=n.filter(l=>l[o]?l[o]===h:!1);c.length&&(n=c)})}),this._resolverHash[r]=n[0]}else this._resolverHash[r]=this._buildResolvedAsset({alias:[r],src:r},{});i[r]=this._resolverHash[r]}),e?i[t[0]]:i}hasKey(t){return!!this._assetMap[t]}hasBundle(t){return!!this._bundles[t]}_getPreferredOrder(t){for(let e=0;en.params.format.includes(i.format));if(r)return r}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:i,data:r,loadParser:n,format:a}=e;return(this._basePath||this._rootPath)&&(t.src=lt.toAbsolute(t.src,this._basePath,this._rootPath)),t.alias=i??t.alias??[t.src],t.src=this._appendDefaultSearchParams(t.src),t.data={...r||{},...t.data},t.loadParser=n??t.loadParser,t.format=a??t.format??go(t.src),t}}ie.RETINA_PREFIX=/@([0-9\.]+)x/;function go(s){return s.split(".").pop().split("?").shift().split("#").shift()}const zs=(s,t)=>{const e=t.split("?")[1];return e&&(s+=`?${e}`),s},rn=class xe{constructor(t,e){this.linkedSheets=[],this._texture=t instanceof G?t:null,this.textureSource=t.source,this.textures={},this.animations={},this.data=e;const i=parseFloat(e.meta.scale);i?(this.resolution=i,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<=xe.BATCH_SIZE?(this._processFrames(0),this._processAnimations(),this._parseComplete()):this._nextBatch()})}_processFrames(t){let e=t;const i=xe.BATCH_SIZE;for(;e-t{this._batchIndex*xe.BATCH_SIZE{i[r]=t}),Object.keys(t.textures).forEach(r=>{i[r]=t.textures[r]}),!e){const r=lt.dirname(s[0]);t.linkedSheets.forEach((n,a)=>{const o=nn([`${r}/${t.data.meta.related_multi_packs[a]}`],n,!0);Object.assign(i,o)})}return i}const xo={extension:P.Asset,cache:{test:s=>s instanceof Ni,getCacheableAssets:(s,t)=>nn(s,t,!1)},resolver:{extension:{type:P.ResolveParser,name:"resolveSpritesheet"},test:s=>{const e=s.split("?")[0].split("."),i=e.pop(),r=e.pop();return i==="json"&&mo.includes(r)},parse:s=>{var e;const t=s.split(".");return{resolution:parseFloat(((e=ie.RETINA_PREFIX.exec(s))==null?void 0:e[1])??"1"),format:t[t.length-2],src:s}}},loader:{name:"spritesheetLoader",extension:{type:P.LoadParser,priority:kt.Normal,name:"spritesheetLoader"},async testParse(s,t){return lt.extname(t.src).toLowerCase()===".json"&&!!s.frames},async parse(s,t,e){var c,l;const{texture:i,imageFilename:r}=(t==null?void 0:t.data)??{};let n=lt.dirname(t.src);n&&n.lastIndexOf("/")!==n.length-1&&(n+="/");let a;if(i instanceof G)a=i;else{const u=zs(n+(r??s.meta.image),t.src);a=(await e.load([u]))[u]}const o=new Ni(a.source,s);await o.parse();const h=(c=s==null?void 0:s.meta)==null?void 0:c.related_multi_packs;if(Array.isArray(h)){const u=[];for(const f of h){if(typeof f!="string")continue;let p=n+f;(l=t.data)!=null&&l.ignoreMultiPack||(p=zs(p,t.src),u.push(e.load({src:p,data:{ignoreMultiPack:!0}})))}const d=await Promise.all(u);o.linkedSheets=d,d.forEach(f=>{f.linkedSheets=[o].concat(o.linkedSheets.filter(p=>p!==f))})}return o},async unload(s,t,e){await e.unload(s.textureSource._sourceOrigin),s.destroy(!1)}}};nt.add(xo);const ys=Object.create(null),Vi=Object.create(null);function ai(s,t){let e=Vi[s];return e===void 0&&(ys[t]===void 0&&(ys[t]=1),Vi[s]=e=ys[t]++),e}let Nt;function an(){return(!Nt||Nt!=null&&Nt.isContextLost())&&(Nt=j.get().createCanvas().getContext("webgl",{})),Nt}let We;function yo(){if(!We){We="mediump";const s=an();s&&s.getShaderPrecisionFormat&&(We=s.getShaderPrecisionFormat(s.FRAGMENT_SHADER,s.HIGH_FLOAT).precision?"highp":"mediump")}return We}function _o(s,t,e){return t?s:e?(s=s.replace("out vec4 finalColor;",""),` #ifdef GL_ES // This checks if it is WebGL1 #define in varying @@ -19,18 +19,18 @@ Deprecated since v${s}`),console.warn(i))),Ti[t]=!0}const Br=()=>{};function Mi( #define out varying #endif ${s} - `}function _o(s,t,e){const i=e?t.maxSupportedFragmentPrecision:t.maxSupportedVertexPrecision;if(s.substring(0,9)!=="precision"){let r=e?t.requestedFragmentPrecision:t.requestedVertexPrecision;return r==="highp"&&i!=="highp"&&(r="mediump"),`precision ${r} float; -${s}`}else if(i!=="highp"&&s.substring(0,15)==="precision highp")return s.replace("precision highp","precision mediump");return s}function bo(s,t){return t?`#version 300 es -${s}`:s}const wo={},vo={};function Ao(s,{name:t="pixi-program"},e=!0){t=t.replace(/\s+/g,"-"),t+=e?"-fragment":"-vertex";const i=e?wo:vo;return i[t]?(i[t]++,t+=`-${i[t]}`):i[t]=1,s.indexOf("#define SHADER_NAME")!==-1?s:`${`#define SHADER_NAME ${t}`} -${s}`}function So(s,t){return t?s.replace("#version 300 es",""):s}const _s={stripVersion:So,ensurePrecision:_o,addProgramDefines:yo,setProgramName:Ao,insertVersion:bo},bs=Object.create(null),on=class Hs{constructor(t){t={...Hs.defaultOptions,...t};const e=t.fragment.indexOf("#version 300 es")!==-1,i={stripVersion:e,ensurePrecision:{requestedFragmentPrecision:t.preferredFragmentPrecision,requestedVertexPrecision:t.preferredVertexPrecision,maxSupportedVertexPrecision:"highp",maxSupportedFragmentPrecision:xo()},setProgramName:{name:t.name},addProgramDefines:e,insertVersion:e};let r=t.fragment,n=t.vertex;Object.keys(_s).forEach(a=>{const o=i[a];r=_s[a](r,o,!0),n=_s[a](n,o,!1)}),this.fragment=r,this.vertex=n,this._key=ai(`${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 bs[e]||(bs[e]=new Hs(t)),bs[e]}};on.defaultOptions={preferredVertexPrecision:"highp",preferredFragmentPrecision:"mediump"};let hn=on;const $i={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 Co(s){return $i[s]??$i.float32}const To={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 Mo({source:s,entryPoint:t}){const e={},i=s.indexOf(`fn ${t}`);if(i!==-1){const r=s.indexOf("->",i);if(r!==-1){const n=s.substring(i,r),a=/@location\((\d+)\)\s+([a-zA-Z0-9_]+)\s*:\s*([a-zA-Z0-9_<>]+)(?:,|\s|$)/g;let o;for(;(o=a.exec(n))!==null;){const h=To[o[3]]??"float32";e[o[2]]={location:parseInt(o[1],10),format:h,stride:Co(h).stride,offset:0,instance:!1,start:0}}}}return e}function ws(s){var u,d;const t=/(^|[^/])@(group|binding)\(\d+\)[^;]+;/g,e=/@group\((\d+)\)/,i=/@binding\((\d+)\)/,r=/var(<[^>]+>)? (\w+)/,n=/:\s*(\w+)/,a=/struct\s+(\w+)\s*{([^}]+)}/g,o=/(\w+)\s*:\s*([\w\<\>]+)/g,h=/struct\s+(\w+)/,c=(u=s.match(t))==null?void 0:u.map(f=>({group:parseInt(f.match(e)[1],10),binding:parseInt(f.match(i)[1],10),name:f.match(r)[2],isUniform:f.match(r)[1]==="",type:f.match(n)[1]}));if(!c)return{groups:[],structs:[]};const l=((d=s.match(a))==null?void 0:d.map(f=>{const p=f.match(h)[1],m=f.match(o).reduce((g,x)=>{const[y,_]=x.split(":");return g[y.trim()]=_.trim(),g},{});return m?{name:p,members:m}:null}).filter(({name:f})=>c.some(p=>p.type===f)))??[];return{groups:c,structs:l}}var me=(s=>(s[s.VERTEX=1]="VERTEX",s[s.FRAGMENT=2]="FRAGMENT",s[s.COMPUTE=4]="COMPUTE",s))(me||{});function Po({groups:s}){const t=[];for(let e=0;ee.has(a.name)?!1:(e.add(a.name),!0)),n=[...s.groups,...t.groups].filter(a=>{const o=`${a.name}-${a.binding}`;return i.has(o)?!1:(i.add(o),!0)});return{structs:r,groups:n}}const vs=Object.create(null);class ts{constructor(t){var o,h;this._layoutKey=0,this._attributeLocationsKey=0;const{fragment:e,vertex:i,layout:r,gpuLayout:n,name:a}=t;if(this.name=a,this.fragment=e,this.vertex=i,e.source===i.source){const c=ws(e.source);this.structsAndGroups=c}else{const c=ws(i.source),l=ws(e.source);this.structsAndGroups=Eo(c,l)}this.layout=r??ko(this.structsAndGroups),this.gpuLayout=n??Po(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,i=t.source+e.source+t.entryPoint+e.entryPoint;this._layoutKey=ai(i,"program")}get attributeData(){return this._attributeData??(this._attributeData=Mo(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 vs[e]||(vs[e]=new ts(t)),vs[e]}}const ln=["f32","i32","vec2","vec3","vec4","mat2x2","mat3x3","mat4x4","mat3x2","mat4x2","mat2x3","mat4x3","mat2x4","mat3x4"],Bo=ln.reduce((s,t)=>(s[t]=!0,s),{});function Io(s,t){switch(s){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 cn=class un{constructor(t,e){this._touched=0,this.uid=tt("uniform"),this._resourceType="uniformGroup",this._resourceId=tt("resource"),this.isUniformGroup=!0,this._dirtyId=0,this.destroyed=!1,e={...un.defaultOptions,...e},this.uniformStructures=t;const i={};for(const r in t){const n=t[r];if(n.name=r,n.size=n.size??1,!Bo[n.type])throw new Error(`Uniform type ${n.type} is not supported. Supported uniform types are: ${ln.join(", ")}`);n.value??(n.value=Io(n.type,n.size)),i[r]=n.value}this.uniforms=i,this._dirtyId=1,this.ubo=e.ubo,this.isStatic=e.isStatic,this._signature=ai(Object.keys(i).map(r=>`${r}-${t[r].type}`).join("-"),"uniform-group")}update(){this._dirtyId++}};cn.defaultOptions={ubo:!1,isStatic:!1};let dn=cn;class $e{constructor(t){this.resources=Object.create(null),this._dirty=!0;let e=0;for(const i in t){const r=t[i];this.setResource(r,e++)}this._updateKey()}_updateKey(){if(!this._dirty)return;this._dirty=!1;const t=[];let e=0;for(const i in this.resources)t[e++]=this.resources[i]._resourceId;this._key=t.join("|")}setResource(t,e){var r,n;const i=this.resources[e];t!==i&&(i&&((r=t.off)==null||r.call(t,"change",this.onResourceChange,this)),(n=t.on)==null||n.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 i in e)e[i]._touched=t}destroy(){var e;const t=this.resources;for(const i in t){const r=t[i];(e=r.off)==null||e.call(r,"change",this.onResourceChange,this)}this.resources=null}onResourceChange(t){if(this._dirty=!0,t.destroyed){const e=this.resources;for(const i in e)e[i]===t&&(e[i]=null)}else this._updateKey()}}var Ns=(s=>(s[s.WEBGL=1]="WEBGL",s[s.WEBGPU=2]="WEBGPU",s[s.BOTH=3]="BOTH",s))(Ns||{});class oi extends at{constructor(t){super(),this._uniformBindMap=Object.create(null),this._ownedBindGroups=[];let{gpuProgram:e,glProgram:i,groups:r,resources:n,compatibleRenderers:a,groupMap:o}=t;this.gpuProgram=e,this.glProgram=i,a===void 0&&(a=0,e&&(a|=Ns.WEBGPU),i&&(a|=Ns.WEBGL)),this.compatibleRenderers=a;const h={};if(!n&&!r&&(n={}),n&&r)throw new Error("[Shader] Cannot have both resources and groups");if(!e&&r&&!o)throw new Error("[Shader] No group map or WebGPU shader provided - consider using resources instead.");if(!e&&r&&o)for(const c in o)for(const l in o[c]){const u=o[c][l];h[u]={group:c,binding:l,name:u}}else if(e&&r&&!o){const c=e.structsAndGroups.groups;o={},c.forEach(l=>{o[l.group]=o[l.group]||{},o[l.group][l.binding]=l.name,h[l.name]=l})}else if(n){r={},o={},e&&e.structsAndGroups.groups.forEach(u=>{o[u.group]=o[u.group]||{},o[u.group][u.binding]=u.name,h[u.name]=u});let c=0;for(const l in n)h[l]||(r[99]||(r[99]=new $e,this._ownedBindGroups.push(r[99])),h[l]={group:99,binding:c,name:l},o[99]=o[99]||{},o[99][c]=l,c++);for(const l in n){const u=l;let d=n[l];!d.source&&!d._resourceType&&(d=new dn(d));const f=h[u];f&&(r[f.group]||(r[f.group]=new $e,this._ownedBindGroups.push(r[f.group])),r[f.group].setResource(d,f.binding))}}this.groups=r,this._uniformBindMap=o,this.resources=this._buildResourceAccessor(r,h)}addResource(t,e,i){var r,n;(r=this._uniformBindMap)[e]||(r[e]={}),(n=this._uniformBindMap[e])[i]||(n[i]=t),this.groups[e]||(this.groups[e]=new $e,this._ownedBindGroups.push(this.groups[e]))}_buildResourceAccessor(t,e){const i={};for(const r in e){const n=e[r];Object.defineProperty(i,n.name,{get(){return t[n.group].getResource(n.binding)},set(a){t[n.group].setResource(a,n.binding)}})}return i}destroy(t=!1){var e,i;this.emit("destroy",this),t&&((e=this.gpuProgram)==null||e.destroy(),(i=this.glProgram)==null||i.destroy()),this.gpuProgram=null,this.glProgram=null,this.removeAllListeners(),this._uniformBindMap=null,this._ownedBindGroups.forEach(r=>{r.destroy()}),this._ownedBindGroups=null,this.resources=null,this.groups=null}static from(t){const{gpu:e,gl:i,...r}=t;let n,a;return e&&(n=ts.from(e)),i&&(a=hn.from(i)),new oi({gpuProgram:n,glProgram:a,...r})}}const Vs=[];nt.handleByNamedList(P.Environment,Vs);async function Fo(s){if(!s)for(let t=0;t80*e){o=c=s[0],h=l=s[1];for(var p=e;pc&&(c=u),d>l&&(l=d);f=Math.max(c-o,l-h),f=f!==0?32767/f:0}return be(n,a,e,o,h,f,0),a}function fn(s,t,e,i,r){var n,a;if(r===Ys(s,t,e,i)>0)for(n=t;n=t;n-=i)a=Xi(n,s[n],s[n+1],a);return a&&ss(a,a.next)&&(ve(a),a=a.next),a}function zt(s,t){if(!s)return s;t||(t=s);var e=s,i;do if(i=!1,!e.steiner&&(ss(e,e.next)||X(e.prev,e,e.next)===0)){if(ve(e),e=t=e.prev,e===e.next)break;i=!0}else e=e.next;while(i||e!==t);return t}function be(s,t,e,i,r,n,a){if(s){!a&&n&&Vo(s,i,r,n);for(var o=s,h,c;s.prev!==s.next;){if(h=s.prev,c=s.next,n?Go(s,i,r,n):Lo(s)){t.push(h.i/e|0),t.push(s.i/e|0),t.push(c.i/e|0),ve(s),s=c.next,o=c.next;continue}if(s=c,s===o){a?a===1?(s=Wo(zt(s),t,e),be(s,t,e,i,r,n,2)):a===2&&Oo(s,t,e,i,r,n):be(zt(s),t,e,i,r,n,1);break}}}}function Lo(s){var t=s.prev,e=s,i=s.next;if(X(t,e,i)>=0)return!1;for(var r=t.x,n=e.x,a=i.x,o=t.y,h=e.y,c=i.y,l=rn?r>a?r:a:n>a?n:a,f=o>h?o>c?o:c:h>c?h:c,p=i.next;p!==t;){if(p.x>=l&&p.x<=d&&p.y>=u&&p.y<=f&&Xt(r,o,n,h,a,c,p.x,p.y)&&X(p.prev,p,p.next)>=0)return!1;p=p.next}return!0}function Go(s,t,e,i){var r=s.prev,n=s,a=s.next;if(X(r,n,a)>=0)return!1;for(var o=r.x,h=n.x,c=a.x,l=r.y,u=n.y,d=a.y,f=oh?o>c?o:c:h>c?h:c,g=l>u?l>d?l:d:u>d?u:d,x=$s(f,p,t,e,i),y=$s(m,g,t,e,i),_=s.prevZ,b=s.nextZ;_&&_.z>=x&&b&&b.z<=y;){if(_.x>=f&&_.x<=m&&_.y>=p&&_.y<=g&&_!==r&&_!==a&&Xt(o,l,h,u,c,d,_.x,_.y)&&X(_.prev,_,_.next)>=0||(_=_.prevZ,b.x>=f&&b.x<=m&&b.y>=p&&b.y<=g&&b!==r&&b!==a&&Xt(o,l,h,u,c,d,b.x,b.y)&&X(b.prev,b,b.next)>=0))return!1;b=b.nextZ}for(;_&&_.z>=x;){if(_.x>=f&&_.x<=m&&_.y>=p&&_.y<=g&&_!==r&&_!==a&&Xt(o,l,h,u,c,d,_.x,_.y)&&X(_.prev,_,_.next)>=0)return!1;_=_.prevZ}for(;b&&b.z<=y;){if(b.x>=f&&b.x<=m&&b.y>=p&&b.y<=g&&b!==r&&b!==a&&Xt(o,l,h,u,c,d,b.x,b.y)&&X(b.prev,b,b.next)>=0)return!1;b=b.nextZ}return!0}function Wo(s,t,e){var i=s;do{var r=i.prev,n=i.next.next;!ss(r,n)&&pn(r,i,i.next,n)&&we(r,n)&&we(n,r)&&(t.push(r.i/e|0),t.push(i.i/e|0),t.push(n.i/e|0),ve(i),ve(i.next),i=s=n),i=i.next}while(i!==s);return zt(i)}function Oo(s,t,e,i,r,n){var a=s;do{for(var o=a.next.next;o!==a.prev;){if(a.i!==o.i&&Yo(a,o)){var h=gn(a,o);a=zt(a,a.next),h=zt(h,h.next),be(a,t,e,i,r,n,0),be(h,t,e,i,r,n,0);return}o=o.next}a=a.next}while(a!==s)}function Do(s,t,e,i){var r=[],n,a,o,h,c;for(n=0,a=t.length;n=e.next.y&&e.next.y!==e.y){var o=e.x+(r-e.y)*(e.next.x-e.x)/(e.next.y-e.y);if(o<=i&&o>n&&(n=o,a=e.x=e.x&&e.x>=c&&i!==e.x&&Xt(ra.x||e.x===a.x&&No(a,e)))&&(a=e,u=d)),e=e.next;while(e!==h);return a}function No(s,t){return X(s.prev,s,t.prev)<0&&X(t.next,s,s.next)<0}function Vo(s,t,e,i){var r=s;do r.z===0&&(r.z=$s(r.x,r.y,t,e,i)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next;while(r!==s);r.prevZ.nextZ=null,r.prevZ=null,$o(r)}function $o(s){var t,e,i,r,n,a,o,h,c=1;do{for(e=s,s=null,n=null,a=0;e;){for(a++,i=e,o=0,t=0;t0||h>0&&i;)o!==0&&(h===0||!i||e.z<=i.z)?(r=e,e=e.nextZ,o--):(r=i,i=i.nextZ,h--),n?n.nextZ=r:s=r,r.prevZ=n,n=r;e=i}n.nextZ=null,c*=2}while(a>1);return s}function $s(s,t,e,i,r){return s=(s-e)*r|0,t=(t-i)*r|0,s=(s|s<<8)&16711935,s=(s|s<<4)&252645135,s=(s|s<<2)&858993459,s=(s|s<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,s|t<<1}function Xo(s){var t=s,e=s;do(t.x=(s-a)*(n-o)&&(s-a)*(i-o)>=(e-a)*(t-o)&&(e-a)*(n-o)>=(r-a)*(i-o)}function Yo(s,t){return s.next.i!==t.i&&s.prev.i!==t.i&&!jo(s,t)&&(we(s,t)&&we(t,s)&&qo(s,t)&&(X(s.prev,s,t.prev)||X(s,t.prev,t))||ss(s,t)&&X(s.prev,s,s.next)>0&&X(t.prev,t,t.next)>0)}function X(s,t,e){return(t.y-s.y)*(e.x-t.x)-(t.x-s.x)*(e.y-t.y)}function ss(s,t){return s.x===t.x&&s.y===t.y}function pn(s,t,e,i){var r=Oe(X(s,t,e)),n=Oe(X(s,t,i)),a=Oe(X(e,i,s)),o=Oe(X(e,i,t));return!!(r!==n&&a!==o||r===0&&We(s,e,t)||n===0&&We(s,i,t)||a===0&&We(e,s,i)||o===0&&We(e,t,i))}function We(s,t,e){return t.x<=Math.max(s.x,e.x)&&t.x>=Math.min(s.x,e.x)&&t.y<=Math.max(s.y,e.y)&&t.y>=Math.min(s.y,e.y)}function Oe(s){return s>0?1:s<0?-1:0}function jo(s,t){var e=s;do{if(e.i!==s.i&&e.next.i!==s.i&&e.i!==t.i&&e.next.i!==t.i&&pn(e,e.next,s,t))return!0;e=e.next}while(e!==s);return!1}function we(s,t){return X(s.prev,s,s.next)<0?X(s,t,s.next)>=0&&X(s,s.prev,t)>=0:X(s,t,s.prev)<0||X(s,s.next,t)<0}function qo(s,t){var e=s,i=!1,r=(s.x+t.x)/2,n=(s.y+t.y)/2;do e.y>n!=e.next.y>n&&e.next.y!==e.y&&r<(e.next.x-e.x)*(n-e.y)/(e.next.y-e.y)+e.x&&(i=!i),e=e.next;while(e!==s);return i}function gn(s,t){var e=new Xs(s.i,s.x,s.y),i=new Xs(t.i,t.x,t.y),r=s.next,n=t.prev;return s.next=t,t.prev=s,e.next=r,r.prev=e,i.next=e,e.prev=i,n.next=i,i.prev=n,i}function Xi(s,t,e,i){var r=new Xs(s,t,e);return i?(r.next=i.next,r.prev=i,i.next.prev=r,i.next=r):(r.prev=r,r.next=r),r}function ve(s){s.next.prev=s.prev,s.prev.next=s.next,s.prevZ&&(s.prevZ.nextZ=s.nextZ),s.nextZ&&(s.nextZ.prevZ=s.prevZ)}function Xs(s,t,e){this.i=s,this.x=t,this.y=e,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}es.deviation=function(s,t,e,i){var r=t&&t.length,n=r?t[0]*e:s.length,a=Math.abs(Ys(s,0,n,e));if(r)for(var o=0,h=t.length;o0&&(i+=s[r-1].length,e.holes.push(i))}return e};var Ko=hi.exports;const Zo=ii(Ko);var mn=(s=>(s[s.NONE=0]="NONE",s[s.COLOR=16384]="COLOR",s[s.STENCIL=1024]="STENCIL",s[s.DEPTH=256]="DEPTH",s[s.COLOR_DEPTH=16640]="COLOR_DEPTH",s[s.COLOR_STENCIL=17408]="COLOR_STENCIL",s[s.DEPTH_STENCIL=1280]="DEPTH_STENCIL",s[s.ALL=17664]="ALL",s))(mn||{});class Qo{constructor(t){this.items=[],this._name=t}emit(t,e,i,r,n,a,o,h){const{name:c,items:l}=this;for(let u=0,d=l.length;u{this.runners[e]=new Qo(e)})}_addSystems(t){let e;for(e in t){const i=t[e];this._addSystem(i.value,i.name)}}_addSystem(t,e){const i=new t(this);if(this[e])throw new Error(`Whoops! The name "${e}" is already in use`);this[e]=i,this._systemsHash[e]=i;for(const r in this.runners)this.runners[r].add(i);return this}_addPipes(t,e){const i=e.reduce((r,n)=>(r[n.name]=n.value,r),{});t.forEach(r=>{const n=r.value,a=r.name,o=i[a];this.renderPipes[a]=new n(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(!Ro())throw new Error("Current environment does not allow unsafe-eval, please use pixi.js/unsafe-eval module to enable support.")}};xn.defaultOptions={resolution:1,failIfMajorPerformanceCaveat:!1,roundPixels:!1};let _n=xn,De;function th(s){return De!==void 0||(De=(()=>{var e;const t={stencil:!0,failIfMajorPerformanceCaveat:s??_n.defaultOptions.failIfMajorPerformanceCaveat};try{if(!j.get().getWebGLRenderingContext())return!1;let r=j.get().createCanvas().getContext("webgl",t);const n=!!((e=r==null?void 0:r.getContextAttributes())!=null&&e.stencil);if(r){const a=r.getExtension("WEBGL_lose_context");a&&a.loseContext()}return r=null,n}catch{return!1}})()),De}let Ue;async function eh(s={}){return Ue!==void 0||(Ue=await(async()=>{const t=j.get().getNavigator().gpu;if(!t)return!1;try{return await(await t.requestAdapter(s)).requestDevice(),!0}catch{return!1}})()),Ue}const Yi=["webgl","webgpu","canvas"];async function sh(s){let t=[];s.preference?(t.push(s.preference),Yi.forEach(n=>{n!==s.preference&&t.push(n)})):t=Yi.slice();let e,i={};for(let n=0;n{const{WebGPURenderer:h}=await import("./WebGPURenderer-CfuoxGKf.js");return{WebGPURenderer:h}},__vite__mapDeps([3,2,4]));e=o,i={...s,...s.webgpu};break}else if(a==="webgl"&&th(s.failIfMajorPerformanceCaveat??_n.defaultOptions.failIfMajorPerformanceCaveat)){const{WebGLRenderer:o}=await Ye(async()=>{const{WebGLRenderer:h}=await import("./WebGLRenderer-D6LquuM7.js");return{WebGLRenderer:h}},__vite__mapDeps([5,2,4]));e=o,i={...s,...s.webgl};break}else if(a==="canvas")throw i={...s},new Error("CanvasRenderer is not yet implemented")}if(delete i.webgpu,delete i.webgl,!e)throw new Error("No available renderer for the current environment");const r=new e;return await r.init(i),r}const bn="8.4.0";class wn{static init(){var t;(t=globalThis.__PIXI_APP_INIT__)==null||t.call(globalThis,this,bn)}static destroy(){}}wn.extension=P.Application;class ih{constructor(t){this._renderer=t}init(){var t;(t=globalThis.__PIXI_RENDERER_INIT__)==null||t.call(globalThis,this._renderer,bn)}destroy(){this._renderer=null}}ih.extension={type:[P.WebGLSystem,P.WebGPUSystem],name:"initHook",priority:-10};const vn=class js{constructor(...t){this.stage=new rt,t[0]!==void 0&&W(O,"Application constructor options are deprecated, please use Application.init() instead.")}async init(t){t={...t},this.renderer=await sh(t),js._plugins.forEach(e=>{e.init.call(this,t)})}render(){this.renderer.render({container:this.stage})}get canvas(){return this.renderer.canvas}get view(){return W(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 i=js._plugins.slice(0);i.reverse(),i.forEach(r=>{r.destroy.call(this)}),this.stage.destroy(e),this.stage=null,this.renderer.destroy(t),this.renderer=null}};vn._plugins=[];let An=vn;nt.handleByList(P.Application,An._plugins);nt.add(wn);class Sn extends at{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 W(O,"BitmapFont.font is deprecated, please use BitmapFont.fontFamily instead."),this.fontFamily}get pageTextures(){return W(O,"BitmapFont.pageTextures is deprecated, please use BitmapFont.pages instead."),this.pages}get size(){return W(O,"BitmapFont.size is deprecated, please use BitmapFont.fontMetrics.fontSize instead."),this.fontMetrics.fontSize}get distanceFieldRange(){return W(O,"BitmapFont.distanceFieldRange is deprecated, please use BitmapFont.distanceField.range instead."),this.distanceField.range}get distanceFieldType(){return W(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 i in this.chars)(e=this.chars[i].texture)==null||e.destroy();this.chars=null,t&&(this.pages.forEach(i=>i.texture.destroy(!0)),this.pages=null)}}const Cn=class qs{constructor(t,e,i,r){this.uid=tt("fillGradient"),this.type="linear",this.gradientStops=[],this._styleKey=null,this.x0=t,this.y0=e,this.x1=i,this.y1=r}addColorStop(t,e){return this.gradientStops.push({offset:t,color:Q.shared.setValue(e).toHexa()}),this._styleKey=null,this}buildLinearGradient(){const t=qs.defaultTextureSize,{gradientStops:e}=this,i=j.get().createCanvas();i.width=t,i.height=t;const r=i.getContext("2d"),n=r.createLinearGradient(0,0,qs.defaultTextureSize,1);for(let m=0;m`${r.offset}-${r.color}`).join("-"),e=this.texture.uid,i=this.transform.toArray().join("-");return`fill-gradient-${this.uid}-${t}-${e}-${i}-${this.x0}-${this.y0}-${this.x1}-${this.y1}`}};Cn.defaultTextureSize=256;let Ae=Cn;const ji={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 is{constructor(t,e){this.uid=tt("fillPattern"),this.transform=new D,this._styleKey=null,this.texture=t,this.transform.scale(1/t.frame.width,1/t.frame.height),e&&(t.source.style.addressModeU=ji[e].addressModeU,t.source.style.addressModeV=ji[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 rh=ah,As={a:7,c:6,h:1,l:2,m:2,q:4,s:4,t:2,v:1,z:0},nh=/([astvzqmhlc])([^astvzqmhlc]*)/ig;function ah(s){var t=[];return s.replace(nh,function(e,i,r){var n=i.toLowerCase();for(r=hh(r),n=="m"&&r.length>2&&(t.push([i].concat(r.splice(0,2))),n="l",i=i=="m"?"l":"L");;){if(r.length==As[n])return r.unshift(i),t.push(r);if(r.length0&&(r=i.pop(),r?(n=r.startX,a=r.startY):(n=0,a=0)),r=null;break;default:J(`Unknown SVG path command: ${c}`)}c!=="Z"&&c!=="z"&&r===null&&(r={startX:n,startY:a},i.push(r))}return t}class li{constructor(t=0,e=0,i=0){this.type="circle",this.x=t,this.y=e,this.radius=i}clone(){return new li(this.x,this.y,this.radius)}contains(t,e){if(this.radius<=0)return!1;const i=this.radius*this.radius;let r=this.x-t,n=this.y-e;return r*=r,n*=n,r+n<=i}strokeContains(t,e,i){if(this.radius===0)return!1;const r=this.x-t,n=this.y-e,a=this.radius,o=i/2,h=Math.sqrt(r*r+n*n);return ha-o}getBounds(t){return t=t||new U,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 ci{constructor(t=0,e=0,i=0,r=0){this.type="ellipse",this.x=t,this.y=e,this.halfWidth=i,this.halfHeight=r}clone(){return new ci(this.x,this.y,this.halfWidth,this.halfHeight)}contains(t,e){if(this.halfWidth<=0||this.halfHeight<=0)return!1;let i=(t-this.x)/this.halfWidth,r=(e-this.y)/this.halfHeight;return i*=i,r*=r,i+r<=1}strokeContains(t,e,i){const{halfWidth:r,halfHeight:n}=this;if(r<=0||n<=0)return!1;const a=i/2,o=r-a,h=n-a,c=r+a,l=n+a,u=t-this.x,d=e-this.y,f=u*u/(o*o)+d*d/(h*h),p=u*u/(c*c)+d*d/(l*l);return f>1&&p<=1}getBounds(t){return t=t||new U,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 uh(s,t,e,i,r,n){const a=s-e,o=t-i,h=r-e,c=n-i,l=a*h+o*c,u=h*h+c*c;let d=-1;u!==0&&(d=l/u);let f,p;d<0?(f=e,p=i):d>1?(f=r,p=n):(f=e+d*h,p=i+d*c);const m=s-f,g=t-p;return m*m+g*g}class ye{constructor(...t){this.type="polygon";let e=Array.isArray(t[0])?t[0]:t;if(typeof e[0]!="number"){const i=[];for(let r=0,n=e.length;re!=l>e&&t<(c-o)*((e-h)/(l-h))+o&&(i=!i)}return i}strokeContains(t,e,i){const r=i/2,n=r*r,{points:a}=this,o=a.length-(this.closePath?0:2);for(let h=0;hr?c:r,n=la?l:a}return t.x=i,t.width=r-i,t.y=n,t.height=a-n,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 ze=(s,t,e,i,r,n)=>{const a=s-e,o=t-i,h=Math.sqrt(a*a+o*o);return h>=r-n&&h<=r+n};class ui{constructor(t=0,e=0,i=0,r=0,n=20){this.type="roundedRectangle",this.x=t,this.y=e,this.width=i,this.height=r,this.radius=n}getBounds(t){return t=t||new U,t.x=this.x,t.y=this.y,t.width=this.width,t.height=this.height,t}clone(){return new ui(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 i=Math.max(0,Math.min(this.radius,Math.min(this.width,this.height)/2));if(e>=this.y+i&&e<=this.y+this.height-i||t>=this.x+i&&t<=this.x+this.width-i)return!0;let r=t-(this.x+i),n=e-(this.y+i);const a=i*i;if(r*r+n*n<=a||(r=t-(this.x+this.width-i),r*r+n*n<=a)||(n=e-(this.y+this.height-i),r*r+n*n<=a)||(r=t-(this.x+i),r*r+n*n<=a))return!0}return!1}strokeContains(t,e,i){const{x:r,y:n,width:a,height:o,radius:h}=this,c=i/2,l=r+h,u=n+h,d=a-h*2,f=o-h*2,p=r+a,m=n+o;return(t>=r-c&&t<=r+c||t>=p-c&&t<=p+c)&&e>=u&&e<=u+f||(e>=n-c&&e<=n+c||e>=m-c&&e<=m+c)&&t>=l&&t<=l+d?!0:tp-h&&ep-h&&e>m-h&&ze(t,e,p-h,m-h,h,c)||tm-h&&ze(t,e,l,m-h,h,c)}toString(){return`[pixi.js/math:RoundedRectangle x=${this.x} y=${this.y}width=${this.width} height=${this.height} radius=${this.radius}]`}}const dh=["precision mediump float;","void main(void){","float test = 0.1;","%forloop%","gl_FragColor = vec4(0.0);","}"].join(` -`);function fh(s){let t="";for(let e=0;e0&&(t+=` -else `),e>>=0;return Mn[e]||mh(s,t,e)}let Ss=0;function mh(s,t,e){const i={};let r=0;Ss||(Ss=Tn());for(let a=0;a0){const a=new Uint8Array(s,e*8,n);new Uint8Array(t,e*8,n).set(a)}}const xh={normal:"normal-npm",add:"add-npm",screen:"screen-npm"};var yh=(s=>(s[s.DISABLED=0]="DISABLED",s[s.RENDERING_MASK_ADD=1]="RENDERING_MASK_ADD",s[s.MASK_ACTIVE=2]="MASK_ACTIVE",s[s.RENDERING_MASK_REMOVE=3]="RENDERING_MASK_REMOVE",s[s.NONE=4]="NONE",s))(yh||{});function Zi(s,t){return t.alphaMode==="no-premultiply-alpha"&&xh[s]||s}class _h{constructor(){this.ids=Object.create(null),this.textures=[],this.count=0}clear(){for(let t=0;t0?Pn[--Ks]:new bh}function Ji(s){Pn[Ks++]=s}let ue=0;const kn=class Xe{constructor(t={}){this.uid=tt("batcher"),this.dirty=!0,this.batchIndex=0,this.batches=[],this._elements=[],Xe.defaultOptions.maxTextures=Xe.defaultOptions.maxTextures??Tn(),t={...Xe.defaultOptions,...t};const{maxTextures:e,attributesInitialSize:i,indicesInitialSize:r}=t;this.attributeBuffer=new qi(i*4),this.indexBuffer=new Uint16Array(r),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,c=this.indexBuffer;let l=this._batchIndexSize,u=this._batchIndexStart,d="startBatch";const f=this.maxTextures;for(let p=this.elementStart;p=f||_)&&(this._finishBatch(i,u,l-u,r,a,t,d),d="renderBatch",u=l,a=y,i=Qi(),r=i.textures,r.clear(),++ue),m._textureId=x._textureBindLocation=r.count,r.ids[x.uid]=r.count,r.textures[r.count++]=x,m._batch=i,l+=m.indexSize,m.packAsQuad?(this.packQuadAttributes(m,o,h,m._attributeStart,m._textureId),this.packQuadIndex(c,m._indexStart,m._attributeStart/this.vertexSize)):(this.packAttributes(m,o,h,m._attributeStart,m._textureId),this.packIndex(m,c,m._indexStart,m._attributeStart/this.vertexSize))}r.count>0&&(this._finishBatch(i,u,l-u,r,a,t,d),u=l,++ue),this.elementStart=this.elementSize,this._batchIndexStart=u,this._batchIndexSize=l}_finishBatch(t,e,i,r,n,a,o){t.gpuBindGroup=null,t.bindGroup=null,t.action=o,t.batcher=this,t.textures=r,t.blendMode=n,t.start=e,t.size=i,++ue,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),i=new qi(e);Ki(this.attributeBuffer.rawBinaryData,i.rawBinaryData),this.attributeBuffer=i}_resizeIndexBuffer(t){const e=this.indexBuffer;let i=Math.max(t,e.length*1.5);i+=i%2;const r=i>65535?new Uint32Array(i):new Uint16Array(i);if(r.BYTES_PER_ELEMENT!==e.BYTES_PER_ELEMENT)for(let n=0;n(s[s.MAP_READ=1]="MAP_READ",s[s.MAP_WRITE=2]="MAP_WRITE",s[s.COPY_SRC=4]="COPY_SRC",s[s.COPY_DST=8]="COPY_DST",s[s.INDEX=16]="INDEX",s[s.VERTEX=32]="VERTEX",s[s.UNIFORM=64]="UNIFORM",s[s.STORAGE=128]="STORAGE",s[s.INDIRECT=256]="INDIRECT",s[s.QUERY_RESOLVE=512]="QUERY_RESOLVE",s[s.STATIC=1024]="STATIC",s))(Z||{});class Pt extends at{constructor(t){let{data:e,size:i}=t;const{usage:r,label:n,shrinkToFit:a}=t;super(),this.uid=tt("buffer"),this._resourceType="buffer",this._resourceId=tt("resource"),this._touched=0,this._updateID=1,this.shrinkToFit=!0,this.destroyed=!1,e instanceof Array&&(e=new Float32Array(e)),this._data=e,i=i??(e==null?void 0:e.byteLength);const o=!!e;this.descriptor={size:i,usage:r,mappedAtCreation:o,label:n},this.shrinkToFit=a??!0}get data(){return this._data}set data(t){this.setDataWithSize(t,t.length,!0)}get static(){return!!(this.descriptor.usage&Z.STATIC)}set static(t){t?this.descriptor.usage|=Z.STATIC:this.descriptor.usage&=~Z.STATIC}setDataWithSize(t,e,i){if(this._updateID++,this._updateSize=e*t.BYTES_PER_ELEMENT,this._data===t){i&&this.emit("update",this);return}const r=this._data;if(this._data=t,r.length!==t.length){!this.shrinkToFit&&t.byteLengtho&&(o=f),p>h&&(h=p),fe.destroy()),this.attributes=null,this.buffers=null,this.indexBuffer=null,this._bounds=null}}const Sh=new Float32Array(1),Ch=new Uint32Array(1);class Th extends Bn{constructor(){const e=new Pt({data:Sh,label:"attribute-batch-buffer",usage:Z.VERTEX|Z.COPY_DST,shrinkToFit:!1}),i=new Pt({data:Ch,label:"index-batch-buffer",usage:Z.INDEX|Z.COPY_DST,shrinkToFit:!1}),r=6*4;super({attributes:{aPosition:{buffer:e,format:"float32x2",stride:r,offset:0},aUV:{buffer:e,format:"float32x2",stride:r,offset:2*4},aColor:{buffer:e,format:"unorm8x4",stride:r,offset:4*4},aTextureIdAndRound:{buffer:e,format:"uint16x2",stride:r,offset:5*4}},indexBuffer:i})}}function tr(s,t,e){if(s)for(const i in s){const r=i.toLocaleLowerCase(),n=t[r];if(n){let a=s[i];i==="header"&&(a=a.replace(/@in\s+[^;]+;\s*/g,"").replace(/@out\s+[^;]+;\s*/g,"")),e&&n.push(`//----${e}----//`),n.push(a)}else J(`${i} placement hook does not exist in shader`)}}const Mh=/\{\{(.*?)\}\}/g;function er(s){var i;const t={};return(((i=s.match(Mh))==null?void 0:i.map(r=>r.replace(/[{()}]/g,"")))??[]).forEach(r=>{t[r]=[]}),t}function sr(s,t){let e;const i=/@in\s+([^;]+);/g;for(;(e=i.exec(s))!==null;)t.push(e[1])}function ir(s,t,e=!1){const i=[];sr(t,i),s.forEach(o=>{o.header&&sr(o.header,i)});const r=i;e&&r.sort();const n=r.map((o,h)=>` @location(${h}) ${o},`).join(` + `}function bo(s,t,e){const i=e?t.maxSupportedFragmentPrecision:t.maxSupportedVertexPrecision;if(s.substring(0,9)!=="precision"){let r=e?t.requestedFragmentPrecision:t.requestedVertexPrecision;return r==="highp"&&i!=="highp"&&(r="mediump"),`precision ${r} float; +${s}`}else if(i!=="highp"&&s.substring(0,15)==="precision highp")return s.replace("precision highp","precision mediump");return s}function wo(s,t){return t?`#version 300 es +${s}`:s}const vo={},Ao={};function So(s,{name:t="pixi-program"},e=!0){t=t.replace(/\s+/g,"-"),t+=e?"-fragment":"-vertex";const i=e?vo:Ao;return i[t]?(i[t]++,t+=`-${i[t]}`):i[t]=1,s.indexOf("#define SHADER_NAME")!==-1?s:`${`#define SHADER_NAME ${t}`} +${s}`}function Co(s,t){return t?s.replace("#version 300 es",""):s}const _s={stripVersion:Co,ensurePrecision:bo,addProgramDefines:_o,setProgramName:So,insertVersion:wo},bs=Object.create(null),on=class Hs{constructor(t){t={...Hs.defaultOptions,...t};const e=t.fragment.indexOf("#version 300 es")!==-1,i={stripVersion:e,ensurePrecision:{requestedFragmentPrecision:t.preferredFragmentPrecision,requestedVertexPrecision:t.preferredVertexPrecision,maxSupportedVertexPrecision:"highp",maxSupportedFragmentPrecision:yo()},setProgramName:{name:t.name},addProgramDefines:e,insertVersion:e};let r=t.fragment,n=t.vertex;Object.keys(_s).forEach(a=>{const o=i[a];r=_s[a](r,o,!0),n=_s[a](n,o,!1)}),this.fragment=r,this.vertex=n,this._key=ai(`${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 bs[e]||(bs[e]=new Hs(t)),bs[e]}};on.defaultOptions={preferredVertexPrecision:"highp",preferredFragmentPrecision:"mediump"};let hn=on;const $i={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 To(s){return $i[s]??$i.float32}const Mo={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 Po({source:s,entryPoint:t}){const e={},i=s.indexOf(`fn ${t}`);if(i!==-1){const r=s.indexOf("->",i);if(r!==-1){const n=s.substring(i,r),a=/@location\((\d+)\)\s+([a-zA-Z0-9_]+)\s*:\s*([a-zA-Z0-9_<>]+)(?:,|\s|$)/g;let o;for(;(o=a.exec(n))!==null;){const h=Mo[o[3]]??"float32";e[o[2]]={location:parseInt(o[1],10),format:h,stride:To(h).stride,offset:0,instance:!1,start:0}}}}return e}function ws(s){var u,d;const t=/(^|[^/])@(group|binding)\(\d+\)[^;]+;/g,e=/@group\((\d+)\)/,i=/@binding\((\d+)\)/,r=/var(<[^>]+>)? (\w+)/,n=/:\s*(\w+)/,a=/struct\s+(\w+)\s*{([^}]+)}/g,o=/(\w+)\s*:\s*([\w\<\>]+)/g,h=/struct\s+(\w+)/,c=(u=s.match(t))==null?void 0:u.map(f=>({group:parseInt(f.match(e)[1],10),binding:parseInt(f.match(i)[1],10),name:f.match(r)[2],isUniform:f.match(r)[1]==="",type:f.match(n)[1]}));if(!c)return{groups:[],structs:[]};const l=((d=s.match(a))==null?void 0:d.map(f=>{const p=f.match(h)[1],m=f.match(o).reduce((g,x)=>{const[y,_]=x.split(":");return g[y.trim()]=_.trim(),g},{});return m?{name:p,members:m}:null}).filter(({name:f})=>c.some(p=>p.type===f)))??[];return{groups:c,structs:l}}var ye=(s=>(s[s.VERTEX=1]="VERTEX",s[s.FRAGMENT=2]="FRAGMENT",s[s.COMPUTE=4]="COMPUTE",s))(ye||{});function ko({groups:s}){const t=[];for(let e=0;ee.has(a.name)?!1:(e.add(a.name),!0)),n=[...s.groups,...t.groups].filter(a=>{const o=`${a.name}-${a.binding}`;return i.has(o)?!1:(i.add(o),!0)});return{structs:r,groups:n}}const vs=Object.create(null);class ts{constructor(t){var o,h;this._layoutKey=0,this._attributeLocationsKey=0;const{fragment:e,vertex:i,layout:r,gpuLayout:n,name:a}=t;if(this.name=a,this.fragment=e,this.vertex=i,e.source===i.source){const c=ws(e.source);this.structsAndGroups=c}else{const c=ws(i.source),l=ws(e.source);this.structsAndGroups=Bo(c,l)}this.layout=r??Eo(this.structsAndGroups),this.gpuLayout=n??ko(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,i=t.source+e.source+t.entryPoint+e.entryPoint;this._layoutKey=ai(i,"program")}get attributeData(){return this._attributeData??(this._attributeData=Po(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 vs[e]||(vs[e]=new ts(t)),vs[e]}}const ln=["f32","i32","vec2","vec3","vec4","mat2x2","mat3x3","mat4x4","mat3x2","mat4x2","mat2x3","mat4x3","mat2x4","mat3x4"],Io=ln.reduce((s,t)=>(s[t]=!0,s),{});function Fo(s,t){switch(s){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 cn=class un{constructor(t,e){this._touched=0,this.uid=tt("uniform"),this._resourceType="uniformGroup",this._resourceId=tt("resource"),this.isUniformGroup=!0,this._dirtyId=0,this.destroyed=!1,e={...un.defaultOptions,...e},this.uniformStructures=t;const i={};for(const r in t){const n=t[r];if(n.name=r,n.size=n.size??1,!Io[n.type])throw new Error(`Uniform type ${n.type} is not supported. Supported uniform types are: ${ln.join(", ")}`);n.value??(n.value=Fo(n.type,n.size)),i[r]=n.value}this.uniforms=i,this._dirtyId=1,this.ubo=e.ubo,this.isStatic=e.isStatic,this._signature=ai(Object.keys(i).map(r=>`${r}-${t[r].type}`).join("-"),"uniform-group")}update(){this._dirtyId++}};cn.defaultOptions={ubo:!1,isStatic:!1};let dn=cn;class Xe{constructor(t){this.resources=Object.create(null),this._dirty=!0;let e=0;for(const i in t){const r=t[i];this.setResource(r,e++)}this._updateKey()}_updateKey(){if(!this._dirty)return;this._dirty=!1;const t=[];let e=0;for(const i in this.resources)t[e++]=this.resources[i]._resourceId;this._key=t.join("|")}setResource(t,e){var r,n;const i=this.resources[e];t!==i&&(i&&((r=t.off)==null||r.call(t,"change",this.onResourceChange,this)),(n=t.on)==null||n.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 i in e)e[i]._touched=t}destroy(){var e;const t=this.resources;for(const i in t){const r=t[i];(e=r.off)==null||e.call(r,"change",this.onResourceChange,this)}this.resources=null}onResourceChange(t){if(this._dirty=!0,t.destroyed){const e=this.resources;for(const i in e)e[i]===t&&(e[i]=null)}else this._updateKey()}}var Ns=(s=>(s[s.WEBGL=1]="WEBGL",s[s.WEBGPU=2]="WEBGPU",s[s.BOTH=3]="BOTH",s))(Ns||{});class oi extends at{constructor(t){super(),this._uniformBindMap=Object.create(null),this._ownedBindGroups=[];let{gpuProgram:e,glProgram:i,groups:r,resources:n,compatibleRenderers:a,groupMap:o}=t;this.gpuProgram=e,this.glProgram=i,a===void 0&&(a=0,e&&(a|=Ns.WEBGPU),i&&(a|=Ns.WEBGL)),this.compatibleRenderers=a;const h={};if(!n&&!r&&(n={}),n&&r)throw new Error("[Shader] Cannot have both resources and groups");if(!e&&r&&!o)throw new Error("[Shader] No group map or WebGPU shader provided - consider using resources instead.");if(!e&&r&&o)for(const c in o)for(const l in o[c]){const u=o[c][l];h[u]={group:c,binding:l,name:u}}else if(e&&r&&!o){const c=e.structsAndGroups.groups;o={},c.forEach(l=>{o[l.group]=o[l.group]||{},o[l.group][l.binding]=l.name,h[l.name]=l})}else if(n){r={},o={},e&&e.structsAndGroups.groups.forEach(u=>{o[u.group]=o[u.group]||{},o[u.group][u.binding]=u.name,h[u.name]=u});let c=0;for(const l in n)h[l]||(r[99]||(r[99]=new Xe,this._ownedBindGroups.push(r[99])),h[l]={group:99,binding:c,name:l},o[99]=o[99]||{},o[99][c]=l,c++);for(const l in n){const u=l;let d=n[l];!d.source&&!d._resourceType&&(d=new dn(d));const f=h[u];f&&(r[f.group]||(r[f.group]=new Xe,this._ownedBindGroups.push(r[f.group])),r[f.group].setResource(d,f.binding))}}this.groups=r,this._uniformBindMap=o,this.resources=this._buildResourceAccessor(r,h)}addResource(t,e,i){var r,n;(r=this._uniformBindMap)[e]||(r[e]={}),(n=this._uniformBindMap[e])[i]||(n[i]=t),this.groups[e]||(this.groups[e]=new Xe,this._ownedBindGroups.push(this.groups[e]))}_buildResourceAccessor(t,e){const i={};for(const r in e){const n=e[r];Object.defineProperty(i,n.name,{get(){return t[n.group].getResource(n.binding)},set(a){t[n.group].setResource(a,n.binding)}})}return i}destroy(t=!1){var e,i;this.emit("destroy",this),t&&((e=this.gpuProgram)==null||e.destroy(),(i=this.glProgram)==null||i.destroy()),this.gpuProgram=null,this.glProgram=null,this.removeAllListeners(),this._uniformBindMap=null,this._ownedBindGroups.forEach(r=>{r.destroy()}),this._ownedBindGroups=null,this.resources=null,this.groups=null}static from(t){const{gpu:e,gl:i,...r}=t;let n,a;return e&&(n=ts.from(e)),i&&(a=hn.from(i)),new oi({gpuProgram:n,glProgram:a,...r})}}const Vs=[];nt.handleByNamedList(P.Environment,Vs);async function Ro(s){if(!s)for(let t=0;t80*e){o=c=s[0],h=l=s[1];for(var p=e;pc&&(c=u),d>l&&(l=d);f=Math.max(c-o,l-h),f=f!==0?32767/f:0}return ve(n,a,e,o,h,f,0),a}function fn(s,t,e,i,r){var n,a;if(r===Ys(s,t,e,i)>0)for(n=t;n=t;n-=i)a=Xi(n,s[n],s[n+1],a);return a&&ss(a,a.next)&&(Se(a),a=a.next),a}function zt(s,t){if(!s)return s;t||(t=s);var e=s,i;do if(i=!1,!e.steiner&&(ss(e,e.next)||X(e.prev,e,e.next)===0)){if(Se(e),e=t=e.prev,e===e.next)break;i=!0}else e=e.next;while(i||e!==t);return t}function ve(s,t,e,i,r,n,a){if(s){!a&&n&&$o(s,i,r,n);for(var o=s,h,c;s.prev!==s.next;){if(h=s.prev,c=s.next,n?Wo(s,i,r,n):Go(s)){t.push(h.i/e|0),t.push(s.i/e|0),t.push(c.i/e|0),Se(s),s=c.next,o=c.next;continue}if(s=c,s===o){a?a===1?(s=Oo(zt(s),t,e),ve(s,t,e,i,r,n,2)):a===2&&Do(s,t,e,i,r,n):ve(zt(s),t,e,i,r,n,1);break}}}}function Go(s){var t=s.prev,e=s,i=s.next;if(X(t,e,i)>=0)return!1;for(var r=t.x,n=e.x,a=i.x,o=t.y,h=e.y,c=i.y,l=rn?r>a?r:a:n>a?n:a,f=o>h?o>c?o:c:h>c?h:c,p=i.next;p!==t;){if(p.x>=l&&p.x<=d&&p.y>=u&&p.y<=f&&Yt(r,o,n,h,a,c,p.x,p.y)&&X(p.prev,p,p.next)>=0)return!1;p=p.next}return!0}function Wo(s,t,e,i){var r=s.prev,n=s,a=s.next;if(X(r,n,a)>=0)return!1;for(var o=r.x,h=n.x,c=a.x,l=r.y,u=n.y,d=a.y,f=oh?o>c?o:c:h>c?h:c,g=l>u?l>d?l:d:u>d?u:d,x=$s(f,p,t,e,i),y=$s(m,g,t,e,i),_=s.prevZ,b=s.nextZ;_&&_.z>=x&&b&&b.z<=y;){if(_.x>=f&&_.x<=m&&_.y>=p&&_.y<=g&&_!==r&&_!==a&&Yt(o,l,h,u,c,d,_.x,_.y)&&X(_.prev,_,_.next)>=0||(_=_.prevZ,b.x>=f&&b.x<=m&&b.y>=p&&b.y<=g&&b!==r&&b!==a&&Yt(o,l,h,u,c,d,b.x,b.y)&&X(b.prev,b,b.next)>=0))return!1;b=b.nextZ}for(;_&&_.z>=x;){if(_.x>=f&&_.x<=m&&_.y>=p&&_.y<=g&&_!==r&&_!==a&&Yt(o,l,h,u,c,d,_.x,_.y)&&X(_.prev,_,_.next)>=0)return!1;_=_.prevZ}for(;b&&b.z<=y;){if(b.x>=f&&b.x<=m&&b.y>=p&&b.y<=g&&b!==r&&b!==a&&Yt(o,l,h,u,c,d,b.x,b.y)&&X(b.prev,b,b.next)>=0)return!1;b=b.nextZ}return!0}function Oo(s,t,e){var i=s;do{var r=i.prev,n=i.next.next;!ss(r,n)&&pn(r,i,i.next,n)&&Ae(r,n)&&Ae(n,r)&&(t.push(r.i/e|0),t.push(i.i/e|0),t.push(n.i/e|0),Se(i),Se(i.next),i=s=n),i=i.next}while(i!==s);return zt(i)}function Do(s,t,e,i,r,n){var a=s;do{for(var o=a.next.next;o!==a.prev;){if(a.i!==o.i&&jo(a,o)){var h=gn(a,o);a=zt(a,a.next),h=zt(h,h.next),ve(a,t,e,i,r,n,0),ve(h,t,e,i,r,n,0);return}o=o.next}a=a.next}while(a!==s)}function Uo(s,t,e,i){var r=[],n,a,o,h,c;for(n=0,a=t.length;n=e.next.y&&e.next.y!==e.y){var o=e.x+(r-e.y)*(e.next.x-e.x)/(e.next.y-e.y);if(o<=i&&o>n&&(n=o,a=e.x=e.x&&e.x>=c&&i!==e.x&&Yt(ra.x||e.x===a.x&&Vo(a,e)))&&(a=e,u=d)),e=e.next;while(e!==h);return a}function Vo(s,t){return X(s.prev,s,t.prev)<0&&X(t.next,s,s.next)<0}function $o(s,t,e,i){var r=s;do r.z===0&&(r.z=$s(r.x,r.y,t,e,i)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next;while(r!==s);r.prevZ.nextZ=null,r.prevZ=null,Xo(r)}function Xo(s){var t,e,i,r,n,a,o,h,c=1;do{for(e=s,s=null,n=null,a=0;e;){for(a++,i=e,o=0,t=0;t0||h>0&&i;)o!==0&&(h===0||!i||e.z<=i.z)?(r=e,e=e.nextZ,o--):(r=i,i=i.nextZ,h--),n?n.nextZ=r:s=r,r.prevZ=n,n=r;e=i}n.nextZ=null,c*=2}while(a>1);return s}function $s(s,t,e,i,r){return s=(s-e)*r|0,t=(t-i)*r|0,s=(s|s<<8)&16711935,s=(s|s<<4)&252645135,s=(s|s<<2)&858993459,s=(s|s<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,s|t<<1}function Yo(s){var t=s,e=s;do(t.x=(s-a)*(n-o)&&(s-a)*(i-o)>=(e-a)*(t-o)&&(e-a)*(n-o)>=(r-a)*(i-o)}function jo(s,t){return s.next.i!==t.i&&s.prev.i!==t.i&&!qo(s,t)&&(Ae(s,t)&&Ae(t,s)&&Ko(s,t)&&(X(s.prev,s,t.prev)||X(s,t.prev,t))||ss(s,t)&&X(s.prev,s,s.next)>0&&X(t.prev,t,t.next)>0)}function X(s,t,e){return(t.y-s.y)*(e.x-t.x)-(t.x-s.x)*(e.y-t.y)}function ss(s,t){return s.x===t.x&&s.y===t.y}function pn(s,t,e,i){var r=De(X(s,t,e)),n=De(X(s,t,i)),a=De(X(e,i,s)),o=De(X(e,i,t));return!!(r!==n&&a!==o||r===0&&Oe(s,e,t)||n===0&&Oe(s,i,t)||a===0&&Oe(e,s,i)||o===0&&Oe(e,t,i))}function Oe(s,t,e){return t.x<=Math.max(s.x,e.x)&&t.x>=Math.min(s.x,e.x)&&t.y<=Math.max(s.y,e.y)&&t.y>=Math.min(s.y,e.y)}function De(s){return s>0?1:s<0?-1:0}function qo(s,t){var e=s;do{if(e.i!==s.i&&e.next.i!==s.i&&e.i!==t.i&&e.next.i!==t.i&&pn(e,e.next,s,t))return!0;e=e.next}while(e!==s);return!1}function Ae(s,t){return X(s.prev,s,s.next)<0?X(s,t,s.next)>=0&&X(s,s.prev,t)>=0:X(s,t,s.prev)<0||X(s,s.next,t)<0}function Ko(s,t){var e=s,i=!1,r=(s.x+t.x)/2,n=(s.y+t.y)/2;do e.y>n!=e.next.y>n&&e.next.y!==e.y&&r<(e.next.x-e.x)*(n-e.y)/(e.next.y-e.y)+e.x&&(i=!i),e=e.next;while(e!==s);return i}function gn(s,t){var e=new Xs(s.i,s.x,s.y),i=new Xs(t.i,t.x,t.y),r=s.next,n=t.prev;return s.next=t,t.prev=s,e.next=r,r.prev=e,i.next=e,e.prev=i,n.next=i,i.prev=n,i}function Xi(s,t,e,i){var r=new Xs(s,t,e);return i?(r.next=i.next,r.prev=i,i.next.prev=r,i.next=r):(r.prev=r,r.next=r),r}function Se(s){s.next.prev=s.prev,s.prev.next=s.next,s.prevZ&&(s.prevZ.nextZ=s.nextZ),s.nextZ&&(s.nextZ.prevZ=s.prevZ)}function Xs(s,t,e){this.i=s,this.x=t,this.y=e,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}es.deviation=function(s,t,e,i){var r=t&&t.length,n=r?t[0]*e:s.length,a=Math.abs(Ys(s,0,n,e));if(r)for(var o=0,h=t.length;o0&&(i+=s[r-1].length,e.holes.push(i))}return e};var Zo=hi.exports;const Qo=ii(Zo);var mn=(s=>(s[s.NONE=0]="NONE",s[s.COLOR=16384]="COLOR",s[s.STENCIL=1024]="STENCIL",s[s.DEPTH=256]="DEPTH",s[s.COLOR_DEPTH=16640]="COLOR_DEPTH",s[s.COLOR_STENCIL=17408]="COLOR_STENCIL",s[s.DEPTH_STENCIL=1280]="DEPTH_STENCIL",s[s.ALL=17664]="ALL",s))(mn||{});class Jo{constructor(t){this.items=[],this._name=t}emit(t,e,i,r,n,a,o,h){const{name:c,items:l}=this;for(let u=0,d=l.length;u{this.runners[e]=new Jo(e)})}_addSystems(t){let e;for(e in t){const i=t[e];this._addSystem(i.value,i.name)}}_addSystem(t,e){const i=new t(this);if(this[e])throw new Error(`Whoops! The name "${e}" is already in use`);this[e]=i,this._systemsHash[e]=i;for(const r in this.runners)this.runners[r].add(i);return this}_addPipes(t,e){const i=e.reduce((r,n)=>(r[n.name]=n.value,r),{});t.forEach(r=>{const n=r.value,a=r.name,o=i[a];this.renderPipes[a]=new n(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(!Lo())throw new Error("Current environment does not allow unsafe-eval, please use pixi.js/unsafe-eval module to enable support.")}};xn.defaultOptions={resolution:1,failIfMajorPerformanceCaveat:!1,roundPixels:!1};let _n=xn,Ue;function eh(s){return Ue!==void 0||(Ue=(()=>{var e;const t={stencil:!0,failIfMajorPerformanceCaveat:s??_n.defaultOptions.failIfMajorPerformanceCaveat};try{if(!j.get().getWebGLRenderingContext())return!1;let r=j.get().createCanvas().getContext("webgl",t);const n=!!((e=r==null?void 0:r.getContextAttributes())!=null&&e.stencil);if(r){const a=r.getExtension("WEBGL_lose_context");a&&a.loseContext()}return r=null,n}catch{return!1}})()),Ue}let ze;async function sh(s={}){return ze!==void 0||(ze=await(async()=>{const t=j.get().getNavigator().gpu;if(!t)return!1;try{return await(await t.requestAdapter(s)).requestDevice(),!0}catch{return!1}})()),ze}const Yi=["webgl","webgpu","canvas"];async function ih(s){let t=[];s.preference?(t.push(s.preference),Yi.forEach(n=>{n!==s.preference&&t.push(n)})):t=Yi.slice();let e,i={};for(let n=0;n{const{WebGPURenderer:h}=await import("./WebGPURenderer-CZKrr91q.js");return{WebGPURenderer:h}},__vite__mapDeps([3,2,4]));e=o,i={...s,...s.webgpu};break}else if(a==="webgl"&&eh(s.failIfMajorPerformanceCaveat??_n.defaultOptions.failIfMajorPerformanceCaveat)){const{WebGLRenderer:o}=await je(async()=>{const{WebGLRenderer:h}=await import("./WebGLRenderer-D3v_pegD.js");return{WebGLRenderer:h}},__vite__mapDeps([5,2,4]));e=o,i={...s,...s.webgl};break}else if(a==="canvas")throw i={...s},new Error("CanvasRenderer is not yet implemented")}if(delete i.webgpu,delete i.webgl,!e)throw new Error("No available renderer for the current environment");const r=new e;return await r.init(i),r}const bn="8.4.0";class wn{static init(){var t;(t=globalThis.__PIXI_APP_INIT__)==null||t.call(globalThis,this,bn)}static destroy(){}}wn.extension=P.Application;class rh{constructor(t){this._renderer=t}init(){var t;(t=globalThis.__PIXI_RENDERER_INIT__)==null||t.call(globalThis,this._renderer,bn)}destroy(){this._renderer=null}}rh.extension={type:[P.WebGLSystem,P.WebGPUSystem],name:"initHook",priority:-10};const vn=class js{constructor(...t){this.stage=new rt,t[0]!==void 0&&W(O,"Application constructor options are deprecated, please use Application.init() instead.")}async init(t){t={...t},this.renderer=await ih(t),js._plugins.forEach(e=>{e.init.call(this,t)})}render(){this.renderer.render({container:this.stage})}get canvas(){return this.renderer.canvas}get view(){return W(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 i=js._plugins.slice(0);i.reverse(),i.forEach(r=>{r.destroy.call(this)}),this.stage.destroy(e),this.stage=null,this.renderer.destroy(t),this.renderer=null}};vn._plugins=[];let An=vn;nt.handleByList(P.Application,An._plugins);nt.add(wn);class Sn extends at{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 W(O,"BitmapFont.font is deprecated, please use BitmapFont.fontFamily instead."),this.fontFamily}get pageTextures(){return W(O,"BitmapFont.pageTextures is deprecated, please use BitmapFont.pages instead."),this.pages}get size(){return W(O,"BitmapFont.size is deprecated, please use BitmapFont.fontMetrics.fontSize instead."),this.fontMetrics.fontSize}get distanceFieldRange(){return W(O,"BitmapFont.distanceFieldRange is deprecated, please use BitmapFont.distanceField.range instead."),this.distanceField.range}get distanceFieldType(){return W(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 i in this.chars)(e=this.chars[i].texture)==null||e.destroy();this.chars=null,t&&(this.pages.forEach(i=>i.texture.destroy(!0)),this.pages=null)}}const Cn=class qs{constructor(t,e,i,r){this.uid=tt("fillGradient"),this.type="linear",this.gradientStops=[],this._styleKey=null,this.x0=t,this.y0=e,this.x1=i,this.y1=r}addColorStop(t,e){return this.gradientStops.push({offset:t,color:Q.shared.setValue(e).toHexa()}),this._styleKey=null,this}buildLinearGradient(){const t=qs.defaultTextureSize,{gradientStops:e}=this,i=j.get().createCanvas();i.width=t,i.height=t;const r=i.getContext("2d"),n=r.createLinearGradient(0,0,qs.defaultTextureSize,1);for(let m=0;m`${r.offset}-${r.color}`).join("-"),e=this.texture.uid,i=this.transform.toArray().join("-");return`fill-gradient-${this.uid}-${t}-${e}-${i}-${this.x0}-${this.y0}-${this.x1}-${this.y1}`}};Cn.defaultTextureSize=256;let Ce=Cn;const ji={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 is{constructor(t,e){this.uid=tt("fillPattern"),this.transform=new D,this._styleKey=null,this.texture=t,this.transform.scale(1/t.frame.width,1/t.frame.height),e&&(t.source.style.addressModeU=ji[e].addressModeU,t.source.style.addressModeV=ji[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 nh=oh,As={a:7,c:6,h:1,l:2,m:2,q:4,s:4,t:2,v:1,z:0},ah=/([astvzqmhlc])([^astvzqmhlc]*)/ig;function oh(s){var t=[];return s.replace(ah,function(e,i,r){var n=i.toLowerCase();for(r=lh(r),n=="m"&&r.length>2&&(t.push([i].concat(r.splice(0,2))),n="l",i=i=="m"?"l":"L");;){if(r.length==As[n])return r.unshift(i),t.push(r);if(r.length0&&(r=i.pop(),r?(n=r.startX,a=r.startY):(n=0,a=0)),r=null;break;default:J(`Unknown SVG path command: ${c}`)}c!=="Z"&&c!=="z"&&r===null&&(r={startX:n,startY:a},i.push(r))}return t}class li{constructor(t=0,e=0,i=0){this.type="circle",this.x=t,this.y=e,this.radius=i}clone(){return new li(this.x,this.y,this.radius)}contains(t,e){if(this.radius<=0)return!1;const i=this.radius*this.radius;let r=this.x-t,n=this.y-e;return r*=r,n*=n,r+n<=i}strokeContains(t,e,i){if(this.radius===0)return!1;const r=this.x-t,n=this.y-e,a=this.radius,o=i/2,h=Math.sqrt(r*r+n*n);return ha-o}getBounds(t){return t=t||new U,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 ci{constructor(t=0,e=0,i=0,r=0){this.type="ellipse",this.x=t,this.y=e,this.halfWidth=i,this.halfHeight=r}clone(){return new ci(this.x,this.y,this.halfWidth,this.halfHeight)}contains(t,e){if(this.halfWidth<=0||this.halfHeight<=0)return!1;let i=(t-this.x)/this.halfWidth,r=(e-this.y)/this.halfHeight;return i*=i,r*=r,i+r<=1}strokeContains(t,e,i){const{halfWidth:r,halfHeight:n}=this;if(r<=0||n<=0)return!1;const a=i/2,o=r-a,h=n-a,c=r+a,l=n+a,u=t-this.x,d=e-this.y,f=u*u/(o*o)+d*d/(h*h),p=u*u/(c*c)+d*d/(l*l);return f>1&&p<=1}getBounds(t){return t=t||new U,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(s,t,e,i,r,n){const a=s-e,o=t-i,h=r-e,c=n-i,l=a*h+o*c,u=h*h+c*c;let d=-1;u!==0&&(d=l/u);let f,p;d<0?(f=e,p=i):d>1?(f=r,p=n):(f=e+d*h,p=i+d*c);const m=s-f,g=t-p;return m*m+g*g}class be{constructor(...t){this.type="polygon";let e=Array.isArray(t[0])?t[0]:t;if(typeof e[0]!="number"){const i=[];for(let r=0,n=e.length;re!=l>e&&t<(c-o)*((e-h)/(l-h))+o&&(i=!i)}return i}strokeContains(t,e,i){const r=i/2,n=r*r,{points:a}=this,o=a.length-(this.closePath?0:2);for(let h=0;hr?c:r,n=la?l:a}return t.x=i,t.width=r-i,t.y=n,t.height=a-n,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 He=(s,t,e,i,r,n)=>{const a=s-e,o=t-i,h=Math.sqrt(a*a+o*o);return h>=r-n&&h<=r+n};class ui{constructor(t=0,e=0,i=0,r=0,n=20){this.type="roundedRectangle",this.x=t,this.y=e,this.width=i,this.height=r,this.radius=n}getBounds(t){return t=t||new U,t.x=this.x,t.y=this.y,t.width=this.width,t.height=this.height,t}clone(){return new ui(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 i=Math.max(0,Math.min(this.radius,Math.min(this.width,this.height)/2));if(e>=this.y+i&&e<=this.y+this.height-i||t>=this.x+i&&t<=this.x+this.width-i)return!0;let r=t-(this.x+i),n=e-(this.y+i);const a=i*i;if(r*r+n*n<=a||(r=t-(this.x+this.width-i),r*r+n*n<=a)||(n=e-(this.y+this.height-i),r*r+n*n<=a)||(r=t-(this.x+i),r*r+n*n<=a))return!0}return!1}strokeContains(t,e,i){const{x:r,y:n,width:a,height:o,radius:h}=this,c=i/2,l=r+h,u=n+h,d=a-h*2,f=o-h*2,p=r+a,m=n+o;return(t>=r-c&&t<=r+c||t>=p-c&&t<=p+c)&&e>=u&&e<=u+f||(e>=n-c&&e<=n+c||e>=m-c&&e<=m+c)&&t>=l&&t<=l+d?!0:tp-h&&ep-h&&e>m-h&&He(t,e,p-h,m-h,h,c)||tm-h&&He(t,e,l,m-h,h,c)}toString(){return`[pixi.js/math:RoundedRectangle x=${this.x} y=${this.y}width=${this.width} height=${this.height} radius=${this.radius}]`}}const fh=["precision mediump float;","void main(void){","float test = 0.1;","%forloop%","gl_FragColor = vec4(0.0);","}"].join(` +`);function ph(s){let t="";for(let e=0;e0&&(t+=` +else `),e>>=0;return Mn[e]||xh(s,t,e)}let Ss=0;function xh(s,t,e){const i={};let r=0;Ss||(Ss=Tn());for(let a=0;a0){const a=new Uint8Array(s,e*8,n);new Uint8Array(t,e*8,n).set(a)}}const yh={normal:"normal-npm",add:"add-npm",screen:"screen-npm"};var _h=(s=>(s[s.DISABLED=0]="DISABLED",s[s.RENDERING_MASK_ADD=1]="RENDERING_MASK_ADD",s[s.MASK_ACTIVE=2]="MASK_ACTIVE",s[s.RENDERING_MASK_REMOVE=3]="RENDERING_MASK_REMOVE",s[s.NONE=4]="NONE",s))(_h||{});function Zi(s,t){return t.alphaMode==="no-premultiply-alpha"&&yh[s]||s}class bh{constructor(){this.ids=Object.create(null),this.textures=[],this.count=0}clear(){for(let t=0;t0?Pn[--Ks]:new wh}function Ji(s){Pn[Ks++]=s}let fe=0;const kn=class Ye{constructor(t={}){this.uid=tt("batcher"),this.dirty=!0,this.batchIndex=0,this.batches=[],this._elements=[],Ye.defaultOptions.maxTextures=Ye.defaultOptions.maxTextures??Tn(),t={...Ye.defaultOptions,...t};const{maxTextures:e,attributesInitialSize:i,indicesInitialSize:r}=t;this.attributeBuffer=new qi(i*4),this.indexBuffer=new Uint16Array(r),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,c=this.indexBuffer;let l=this._batchIndexSize,u=this._batchIndexStart,d="startBatch";const f=this.maxTextures;for(let p=this.elementStart;p=f||_)&&(this._finishBatch(i,u,l-u,r,a,t,d),d="renderBatch",u=l,a=y,i=Qi(),r=i.textures,r.clear(),++fe),m._textureId=x._textureBindLocation=r.count,r.ids[x.uid]=r.count,r.textures[r.count++]=x,m._batch=i,l+=m.indexSize,m.packAsQuad?(this.packQuadAttributes(m,o,h,m._attributeStart,m._textureId),this.packQuadIndex(c,m._indexStart,m._attributeStart/this.vertexSize)):(this.packAttributes(m,o,h,m._attributeStart,m._textureId),this.packIndex(m,c,m._indexStart,m._attributeStart/this.vertexSize))}r.count>0&&(this._finishBatch(i,u,l-u,r,a,t,d),u=l,++fe),this.elementStart=this.elementSize,this._batchIndexStart=u,this._batchIndexSize=l}_finishBatch(t,e,i,r,n,a,o){t.gpuBindGroup=null,t.bindGroup=null,t.action=o,t.batcher=this,t.textures=r,t.blendMode=n,t.start=e,t.size=i,++fe,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),i=new qi(e);Ki(this.attributeBuffer.rawBinaryData,i.rawBinaryData),this.attributeBuffer=i}_resizeIndexBuffer(t){const e=this.indexBuffer;let i=Math.max(t,e.length*1.5);i+=i%2;const r=i>65535?new Uint32Array(i):new Uint16Array(i);if(r.BYTES_PER_ELEMENT!==e.BYTES_PER_ELEMENT)for(let n=0;n(s[s.MAP_READ=1]="MAP_READ",s[s.MAP_WRITE=2]="MAP_WRITE",s[s.COPY_SRC=4]="COPY_SRC",s[s.COPY_DST=8]="COPY_DST",s[s.INDEX=16]="INDEX",s[s.VERTEX=32]="VERTEX",s[s.UNIFORM=64]="UNIFORM",s[s.STORAGE=128]="STORAGE",s[s.INDIRECT=256]="INDIRECT",s[s.QUERY_RESOLVE=512]="QUERY_RESOLVE",s[s.STATIC=1024]="STATIC",s))(Z||{});class Pt extends at{constructor(t){let{data:e,size:i}=t;const{usage:r,label:n,shrinkToFit:a}=t;super(),this.uid=tt("buffer"),this._resourceType="buffer",this._resourceId=tt("resource"),this._touched=0,this._updateID=1,this.shrinkToFit=!0,this.destroyed=!1,e instanceof Array&&(e=new Float32Array(e)),this._data=e,i=i??(e==null?void 0:e.byteLength);const o=!!e;this.descriptor={size:i,usage:r,mappedAtCreation:o,label:n},this.shrinkToFit=a??!0}get data(){return this._data}set data(t){this.setDataWithSize(t,t.length,!0)}get static(){return!!(this.descriptor.usage&Z.STATIC)}set static(t){t?this.descriptor.usage|=Z.STATIC:this.descriptor.usage&=~Z.STATIC}setDataWithSize(t,e,i){if(this._updateID++,this._updateSize=e*t.BYTES_PER_ELEMENT,this._data===t){i&&this.emit("update",this);return}const r=this._data;if(this._data=t,r.length!==t.length){!this.shrinkToFit&&t.byteLengtho&&(o=f),p>h&&(h=p),fe.destroy()),this.attributes=null,this.buffers=null,this.indexBuffer=null,this._bounds=null}}const Ch=new Float32Array(1),Th=new Uint32Array(1);class Mh extends Bn{constructor(){const e=new Pt({data:Ch,label:"attribute-batch-buffer",usage:Z.VERTEX|Z.COPY_DST,shrinkToFit:!1}),i=new Pt({data:Th,label:"index-batch-buffer",usage:Z.INDEX|Z.COPY_DST,shrinkToFit:!1}),r=6*4;super({attributes:{aPosition:{buffer:e,format:"float32x2",stride:r,offset:0},aUV:{buffer:e,format:"float32x2",stride:r,offset:2*4},aColor:{buffer:e,format:"unorm8x4",stride:r,offset:4*4},aTextureIdAndRound:{buffer:e,format:"uint16x2",stride:r,offset:5*4}},indexBuffer:i})}}function tr(s,t,e){if(s)for(const i in s){const r=i.toLocaleLowerCase(),n=t[r];if(n){let a=s[i];i==="header"&&(a=a.replace(/@in\s+[^;]+;\s*/g,"").replace(/@out\s+[^;]+;\s*/g,"")),e&&n.push(`//----${e}----//`),n.push(a)}else J(`${i} placement hook does not exist in shader`)}}const Ph=/\{\{(.*?)\}\}/g;function er(s){var i;const t={};return(((i=s.match(Ph))==null?void 0:i.map(r=>r.replace(/[{()}]/g,"")))??[]).forEach(r=>{t[r]=[]}),t}function sr(s,t){let e;const i=/@in\s+([^;]+);/g;for(;(e=i.exec(s))!==null;)t.push(e[1])}function ir(s,t,e=!1){const i=[];sr(t,i),s.forEach(o=>{o.header&&sr(o.header,i)});const r=i;e&&r.sort();const n=r.map((o,h)=>` @location(${h}) ${o},`).join(` `);let a=t.replace(/@in\s+[^;]+;\s*/g,"");return a=a.replace("{{in}}",` ${n} -`),a}function rr(s,t){let e;const i=/@out\s+([^;]+);/g;for(;(e=i.exec(s))!==null;)t.push(e[1])}function Ph(s){const e=/\b(\w+)\s*:/g.exec(s);return e?e[1]:""}function kh(s){const t=/@.*?\s+/g;return s.replace(t,"")}function Eh(s,t){const e=[];rr(t,e),s.forEach(h=>{h.header&&rr(h.header,e)});let i=0;const r=e.sort().map(h=>h.indexOf("builtin")>-1?h:`@location(${i++}) ${h}`).join(`, -`),n=e.sort().map(h=>` var ${kh(h)};`).join(` +`),a}function rr(s,t){let e;const i=/@out\s+([^;]+);/g;for(;(e=i.exec(s))!==null;)t.push(e[1])}function kh(s){const e=/\b(\w+)\s*:/g.exec(s);return e?e[1]:""}function Eh(s){const t=/@.*?\s+/g;return s.replace(t,"")}function Bh(s,t){const e=[];rr(t,e),s.forEach(h=>{h.header&&rr(h.header,e)});let i=0;const r=e.sort().map(h=>h.indexOf("builtin")>-1?h:`@location(${i++}) ${h}`).join(`, +`),n=e.sort().map(h=>` var ${Eh(h)};`).join(` `),a=`return VSOutput( - ${e.sort().map(h=>` ${Ph(h)}`).join(`, + ${e.sort().map(h=>` ${kh(h)}`).join(`, `)});`;let o=t.replace(/@out\s+[^;]+;\s*/g,"");return o=o.replace("{{struct}}",` ${r} `),o=o.replace("{{start}}",` @@ -41,7 +41,7 @@ ${a} `).length?e=e.replace(`{{${i}}}`,`//-----${i} START-----// ${r.join(` `)} -//----${i} FINISH----//`):e=e.replace(`{{${i}}}`,"")}return e}const Mt=Object.create(null),Cs=new Map;let Bh=0;function Ih({template:s,bits:t}){const e=In(s,t);if(Mt[e])return Mt[e];const{vertex:i,fragment:r}=Rh(s,t);return Mt[e]=Fn(i,r,t),Mt[e]}function Fh({template:s,bits:t}){const e=In(s,t);return Mt[e]||(Mt[e]=Fn(s.vertex,s.fragment,t)),Mt[e]}function Rh(s,t){const e=t.map(a=>a.vertex).filter(a=>!!a),i=t.map(a=>a.fragment).filter(a=>!!a);let r=ir(e,s.vertex,!0);r=Eh(e,r);const n=ir(i,s.fragment,!0);return{vertex:r,fragment:n}}function In(s,t){return t.map(e=>(Cs.has(e)||Cs.set(e,Bh++),Cs.get(e))).sort((e,i)=>e-i).join("-")+s.vertex+s.fragment}function Fn(s,t,e){const i=er(s),r=er(t);return e.forEach(n=>{tr(n.vertex,i,n.name),tr(n.fragment,r,n.name)}),{vertex:nr(s,i),fragment:nr(t,r)}}const Lh=` +//----${i} FINISH----//`):e=e.replace(`{{${i}}}`,"")}return e}const Mt=Object.create(null),Cs=new Map;let Ih=0;function Fh({template:s,bits:t}){const e=In(s,t);if(Mt[e])return Mt[e];const{vertex:i,fragment:r}=Lh(s,t);return Mt[e]=Fn(i,r,t),Mt[e]}function Rh({template:s,bits:t}){const e=In(s,t);return Mt[e]||(Mt[e]=Fn(s.vertex,s.fragment,t)),Mt[e]}function Lh(s,t){const e=t.map(a=>a.vertex).filter(a=>!!a),i=t.map(a=>a.fragment).filter(a=>!!a);let r=ir(e,s.vertex,!0);r=Bh(e,r);const n=ir(i,s.fragment,!0);return{vertex:r,fragment:n}}function In(s,t){return t.map(e=>(Cs.has(e)||Cs.set(e,Ih++),Cs.get(e))).sort((e,i)=>e-i).join("-")+s.vertex+s.fragment}function Fn(s,t,e){const i=er(s),r=er(t);return e.forEach(n=>{tr(n.vertex,i,n.name),tr(n.fragment,r,n.name)}),{vertex:nr(s,i),fragment:nr(t,r)}}const Gh=` @in aPosition: vec2; @in aUV: vec2; @@ -85,7 +85,7 @@ ${r.join(` {{return}} }; -`,Gh=` +`,Wh=` @in vUV : vec2; @in vColor : vec4; @@ -108,7 +108,7 @@ ${r.join(` return finalColor; }; -`,Wh=` +`,Oh=` in vec2 aPosition; in vec2 aUV; @@ -144,7 +144,7 @@ ${r.join(` {{end}} } -`,Oh=` +`,Dh=` in vec4 vColor; in vec2 vUV; @@ -165,7 +165,7 @@ ${r.join(` {{end}} } -`,Dh={name:"global-uniforms-bit",vertex:{header:` +`,Uh={name:"global-uniforms-bit",vertex:{header:` struct GlobalUniforms { uProjectionMatrix:mat3x3, uWorldTransformMatrix:mat3x3, @@ -174,22 +174,22 @@ ${r.join(` } @group(0) @binding(0) var globalUniforms : GlobalUniforms; - `}},Uh={name:"global-uniforms-bit",vertex:{header:` + `}},zh={name:"global-uniforms-bit",vertex:{header:` uniform mat3 uProjectionMatrix; uniform mat3 uWorldTransformMatrix; uniform vec4 uWorldColorAlpha; uniform vec2 uResolution; - `}};function zh({bits:s,name:t}){const e=Ih({template:{fragment:Gh,vertex:Lh},bits:[Dh,...s]});return ts.from({name:t,vertex:{source:e.vertex,entryPoint:"main"},fragment:{source:e.fragment,entryPoint:"main"}})}function Hh({bits:s,name:t}){return new hn({name:t,...Fh({template:{vertex:Wh,fragment:Oh},bits:[Uh,...s]})})}const Nh={name:"color-bit",vertex:{header:` + `}};function Hh({bits:s,name:t}){const e=Fh({template:{fragment:Wh,vertex:Gh},bits:[Uh,...s]});return ts.from({name:t,vertex:{source:e.vertex,entryPoint:"main"},fragment:{source:e.fragment,entryPoint:"main"}})}function Nh({bits:s,name:t}){return new hn({name:t,...Rh({template:{vertex:Oh,fragment:Dh},bits:[zh,...s]})})}const Vh={name:"color-bit",vertex:{header:` @in aColor: vec4; `,main:` vColor *= vec4(aColor.rgb * aColor.a, aColor.a); - `}},Vh={name:"color-bit",vertex:{header:` + `}},$h={name:"color-bit",vertex:{header:` in vec4 aColor; `,main:` vColor *= vec4(aColor.rgb * aColor.a, aColor.a); - `}},Ts={};function $h(s){const t=[];if(s===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 i=0;i;`),t.push(`@group(1) @binding(${e++}) var textureSampler${i+1}: sampler;`)}return t.join(` -`)}function Xh(s){const t=[];if(s===1)t.push("outColor = textureSampleGrad(textureSource1, textureSampler1, vUV, uvDx, uvDy);");else{t.push("switch vTextureId {");for(let e=0;e;"),t.push("@group(1) @binding(1) var textureSampler1: sampler;");else{let e=0;for(let i=0;i;`),t.push(`@group(1) @binding(${e++}) var textureSampler${i+1}: sampler;`)}return t.join(` +`)}function Yh(s){const t=[];if(s===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:` @@ -202,14 +202,14 @@ ${r.join(` `},fragment:{header:` @in @interpolate(flat) vTextureId: u32; - ${$h(s)} + ${Xh(s)} `,main:` var uvDx = dpdx(vUV); var uvDy = dpdy(vUV); - ${Xh(s)} - `}}),Ts[s]}const Ms={};function jh(s){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; } - `}},Zh={name:"round-pixels-bit",vertex:{header:` + `}},Qh={name:"round-pixels-bit",vertex:{header:` vec2 roundPixels(vec2 position, vec2 targetSize) { return (floor(((position * 0.5 + 0.5) * targetSize) + 0.5) / targetSize) * 2.0 - 1.0; } - `}},ar={};function Qh(s){let t=ar[s];if(t)return t;const e=new Int32Array(s);for(let i=0;i>16&255,i=s>>8&255,r=s&255,n=t>>16&255,a=t>>8&255,o=t&255,h=e*n/255,c=i*a/255,l=r*o/255;return(h<<16)+(c<<8)+l}const rl=new D;class Wn{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,i=this.renderable;return i?il(e,i.groupColor)+(this.alpha*i.groupAlpha*255<<24):e+(this.alpha*255<<24)}get transform(){var t;return((t=this.renderable)==null?void 0:t.groupTransform)||rl}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 Se={extension:{type:P.ShapeBuilder,name:"circle"},build(s,t){let e,i,r,n,a,o;if(s.type==="circle"){const b=s;e=b.x,i=b.y,a=o=b.radius,r=n=0}else if(s.type==="ellipse"){const b=s;e=b.x,i=b.y,a=b.halfWidth,o=b.halfHeight,r=n=0}else{const b=s,S=b.width/2,I=b.height/2;e=b.x+S,i=b.y+I,a=o=Math.max(0,Math.min(b.radius,Math.min(S,I))),r=S-a,n=I-o}if(!(a>=0&&o>=0&&r>=0&&n>=0))return t;const h=Math.ceil(2.3*Math.sqrt(a+o)),c=h*8+(r?4:0)+(n?4:0);if(c===0)return t;if(h===0)return t[0]=t[6]=e+r,t[1]=t[3]=i+n,t[2]=t[4]=e-r,t[5]=t[7]=i-n,t;let l=0,u=h*4+(r?2:0)+2,d=u,f=c,p=r+a,m=n,g=e+p,x=e-p,y=i+m;if(t[l++]=g,t[l++]=y,t[--u]=y,t[--u]=x,n){const b=i-m;t[d++]=x,t[d++]=b,t[--f]=b,t[--f]=g}for(let b=1;b0&&(r[n++]=h,r[n++]=c,r[n++]=h-1),h++;r[n++]=c+1,r[n++]=c,r[n++]=h-1}},nl={...Se,extension:{...Se.extension,name:"ellipse"}},al={...Se,extension:{...Se.extension,name:"roundedRectangle"}},ol=1e-4,hr=1e-4;function hl(s){const t=s.length;if(t<6)return 1;let e=0;for(let i=0,r=s[t-2],n=s[t-1];iu&&(u+=Math.PI*2);let d=l;const f=u-l,p=Math.abs(f),m=Math.sqrt(h*h+c*c),g=(15*p*Math.sqrt(m)/Math.PI>>0)+1,x=f/g;if(d+=x,o){a.push(s,t),a.push(e,i);for(let y=1,_=d;y=0&&(l.join==="round"?y+=Rt(v,A,v-F*E,A-B*E,v-N*E,A-q*E,g,!1)+4:y+=2,g.push(v-N*R,A-q*R),g.push(v+N*E,A+q*E));continue}const vi=(-F+M)*(-B+A)-(-F+v)*(-B+k),Ai=(-N+Y)*(-q+A)-(-N+v)*(-q+wt),Ee=(Tt*Ai-ae*vi)/ke,Be=(oe*vi-ne*Ai)/ke,ns=(Ee-v)*(Ee-v)+(Be-A)*(Be-A),Et=v+(Ee-v)*E,Bt=A+(Be-A)*E,It=v-(Ee-v)*R,Ft=A-(Be-A)*R,ua=Math.min(Tt*Tt+ne*ne,ae*ae+oe*oe),Si=he?E:R,da=ua+Si*Si*S;ns<=da?l.join==="bevel"||ns/S>I?(he?(g.push(Et,Bt),g.push(v+F*R,A+B*R),g.push(Et,Bt),g.push(v+N*R,A+q*R)):(g.push(v-F*E,A-B*E),g.push(It,Ft),g.push(v-N*E,A-q*E),g.push(It,Ft)),y+=2):l.join==="round"?he?(g.push(Et,Bt),g.push(v+F*R,A+B*R),y+=Rt(v,A,v+F*R,A+B*R,v+N*R,A+q*R,g,!0)+4,g.push(Et,Bt),g.push(v+N*R,A+q*R)):(g.push(v-F*E,A-B*E),g.push(It,Ft),y+=Rt(v,A,v-F*E,A-B*E,v-N*E,A-q*E,g,!1)+4,g.push(v-N*E,A-q*E),g.push(It,Ft)):(g.push(Et,Bt),g.push(It,Ft)):(g.push(v-F*E,A-B*E),g.push(v+F*R,A+B*R),l.join==="round"?he?y+=Rt(v,A,v+F*R,A+B*R,v+N*R,A+q*R,g,!0)+2:y+=Rt(v,A,v-F*E,A-B*E,v-N*E,A-q*E,g,!1)+2:l.join==="miter"&&ns/S<=I&&(he?(g.push(It,Ft),g.push(It,Ft)):(g.push(Et,Bt),g.push(Et,Bt)),y+=2),g.push(v-N*E,A-q*E),g.push(v+N*R,A+q*R),y+=2)}M=s[(x-2)*2],k=s[(x-2)*2+1],v=s[(x-1)*2],A=s[(x-1)*2+1],F=-(k-A),B=M-v,ft=Math.sqrt(F*F+B*B),F/=ft,B/=ft,F*=b,B*=b,g.push(v-F*E,A-B*E),g.push(v+F*R,A+B*R),p||(l.cap==="round"?y+=Rt(v-F*(E-R)*.5,A-B*(E-R)*.5,v-F*E,A-B*E,v+F*R,A+B*R,g,!1)+2:l.cap==="square"&&(y+=lr(v,A,F,B,E,R,!1,g)));const ca=hr*hr;for(let z=_;z=0&&a>=0&&(t[0]=i,t[1]=r,t[2]=i+n,t[3]=r,t[4]=i+n,t[5]=r+a,t[6]=i,t[7]=r+a),t},triangulate(s,t,e,i,r,n){let a=0;i*=e,t[i+a]=s[0],t[i+a+1]=s[1],a+=e,t[i+a]=s[2],t[i+a+1]=s[3],a+=e,t[i+a]=s[6],t[i+a+1]=s[7],a+=e,t[i+a]=s[4],t[i+a+1]=s[5],a+=e;const o=i/e;r[n++]=o,r[n++]=o+1,r[n++]=o+2,r[n++]=o+1,r[n++]=o+3,r[n++]=o+2}},fl={extension:{type:P.ShapeBuilder,name:"triangle"},build(s,t){return t[0]=s.x,t[1]=s.y,t[2]=s.x2,t[3]=s.y2,t[4]=s.x3,t[5]=s.y3,t},triangulate(s,t,e,i,r,n){let a=0;i*=e,t[i+a]=s[0],t[i+a+1]=s[1],a+=e,t[i+a]=s[2],t[i+a+1]=s[3],a+=e,t[i+a]=s[4],t[i+a+1]=s[5];const o=i/e;r[n++]=o,r[n++]=o+1,r[n++]=o+2}},rs={};nt.handleByMap(P.ShapeBuilder,rs);nt.add(dl,ul,fl,Se,nl,al);const pl=new U;function gl(s,t){const{geometryData:e,batches:i}=t;i.length=0,e.indices.length=0,e.vertices.length=0,e.uvs.length=0;for(let r=0;r{const f=h.length,p=a.length/2,m=[],g=rs[l.type];if(g.build(l,m),u&&Gn(m,u),i){const b=l.closePath??!0;ll(m,t,!1,b,a,2,p,h)}else if(e&&c===d){c!==0&&console.warn("[Pixi Graphics] only the last shape have be cut out");const b=[],S=m.slice();xl(e.shapePath).forEach(M=>{b.push(S.length/2),S.push(...M)}),On(S,b,a,2,p,h,f)}else g.triangulate(m,a,2,p,h,f);const x=o.length/2,y=t.texture;if(y!==G.WHITE){const b=t.matrix;b&&(u&&b.append(u.clone().invert()),el(a,2,p,o,x,2,a.length/2-p,b))}else sl(o,x,2,a.length/2-p);const _=At.get(Wn);_.indexOffset=f,_.indexSize=h.length-f,_.attributeOffset=p,_.attributeSize=a.length/2-p,_.baseColor=t.color,_.alpha=t.alpha,_.texture=y,_.geometryData=n,r.push(_)})}function xl(s){if(!s)return[];const t=s.shapePrimitives,e=[];for(let i=0;i{At.return(i)})}destroy(){for(const t in this._gpuContextHash)this._gpuContextHash[t]&&this.onGraphicsContextDestroy(this._gpuContextHash[t].context)}};di.extension={type:[P.WebGLSystem,P.WebGPUSystem,P.CanvasSystem],name:"graphicsContext"};di.defaultOptions={bezierSmoothness:.5};let Dn=di;const bl=8,He=11920929e-14,wl=1;function Un(s,t,e,i,r,n,a,o,h,c){const u=Math.min(.99,Math.max(0,c??Dn.defaultOptions.bezierSmoothness));let d=(wl-u)/1;return d*=d,vl(t,e,i,r,n,a,o,h,s,d),s}function vl(s,t,e,i,r,n,a,o,h,c){Qs(s,t,e,i,r,n,a,o,h,c,0),h.push(a,o)}function Qs(s,t,e,i,r,n,a,o,h,c,l){if(l>bl)return;const u=(s+e)/2,d=(t+i)/2,f=(e+r)/2,p=(i+n)/2,m=(r+a)/2,g=(n+o)/2,x=(u+f)/2,y=(d+p)/2,_=(f+m)/2,b=(p+g)/2,S=(x+_)/2,I=(y+b)/2;if(l>0){let M=a-s,k=o-t;const v=Math.abs((e-a)*k-(i-o)*M),A=Math.abs((r-a)*k-(n-o)*M);if(v>He&&A>He){if((v+A)*(v+A)<=c*(M*M+k*k)){h.push(S,I);return}}else if(v>He){if(v*v<=c*(M*M+k*k)){h.push(S,I);return}}else if(A>He){if(A*A<=c*(M*M+k*k)){h.push(S,I);return}}else if(M=S-(s+a)/2,k=I-(t+o)/2,M*M+k*k<=c){h.push(S,I);return}}Qs(s,t,u,d,x,y,S,I,h,c,l+1),Qs(S,I,_,b,m,g,a,o,h,c,l+1)}const Al=8,Sl=11920929e-14,Cl=1;function Tl(s,t,e,i,r,n,a,o){const c=Math.min(.99,Math.max(0,o??Dn.defaultOptions.bezierSmoothness));let l=(Cl-c)/1;return l*=l,Ml(t,e,i,r,n,a,s,l),s}function Ml(s,t,e,i,r,n,a,o){Js(a,s,t,e,i,r,n,o,0),a.push(r,n)}function Js(s,t,e,i,r,n,a,o,h){if(h>Al)return;const c=(t+i)/2,l=(e+r)/2,u=(i+n)/2,d=(r+a)/2,f=(c+u)/2,p=(l+d)/2;let m=n-t,g=a-e;const x=Math.abs((i-n)*g-(r-a)*m);if(x>Sl){if(x*x<=o*(m*m+g*g)){s.push(f,p);return}}else if(m=f-(t+n)/2,g=p-(e+a)/2,m*m+g*g<=o){s.push(f,p);return}Js(s,t,e,c,l,f,p,o,h+1),Js(s,f,p,u,d,n,a,o,h+1)}function zn(s,t,e,i,r,n,a,o){let h=Math.abs(r-n);(!a&&r>n||a&&n>r)&&(h=2*Math.PI-h),o=o||Math.max(6,Math.floor(6*Math.pow(i,1/3)*(h/Math.PI))),o=Math.max(o,3);let c=h/o,l=r;c*=a?-1:1;for(let u=0;uu*h)}const _e=Math.PI*2,Ps={centerX:0,centerY:0,ang1:0,ang2:0},ks=({x:s,y:t},e,i,r,n,a,o,h)=>{s*=e,t*=i;const c=r*s-n*t,l=n*s+r*t;return h.x=c+a,h.y=l+o,h};function kl(s,t){const e=t===-1.5707963267948966?-.551915024494:1.3333333333333333*Math.tan(t/4),i=t===1.5707963267948966?.551915024494:e,r=Math.cos(s),n=Math.sin(s),a=Math.cos(s+t),o=Math.sin(s+t);return[{x:r-n*i,y:n+r*i},{x:a+o*i,y:o-a*i},{x:a,y:o}]}const ur=(s,t,e,i)=>{const r=s*i-t*e<0?-1:1;let n=s*e+t*i;return n>1&&(n=1),n<-1&&(n=-1),r*Math.acos(n)},El=(s,t,e,i,r,n,a,o,h,c,l,u,d)=>{const f=Math.pow(r,2),p=Math.pow(n,2),m=Math.pow(l,2),g=Math.pow(u,2);let x=f*p-f*g-p*m;x<0&&(x=0),x/=f*g+p*m,x=Math.sqrt(x)*(a===o?-1:1);const y=x*r/n*u,_=x*-n/r*l,b=c*y-h*_+(s+e)/2,S=h*y+c*_+(t+i)/2,I=(l-y)/r,M=(u-_)/n,k=(-l-y)/r,v=(-u-_)/n,A=ur(1,0,I,M);let Y=ur(I,M,k,v);o===0&&Y>0&&(Y-=_e),o===1&&Y<0&&(Y+=_e),d.centerX=b,d.centerY=S,d.ang1=A,d.ang2=Y};function Bl(s,t,e,i,r,n,a,o=0,h=0,c=0){if(n===0||a===0)return;const l=Math.sin(o*_e/360),u=Math.cos(o*_e/360),d=u*(t-i)/2+l*(e-r)/2,f=-l*(t-i)/2+u*(e-r)/2;if(d===0&&f===0)return;n=Math.abs(n),a=Math.abs(a);const p=Math.pow(d,2)/Math.pow(n,2)+Math.pow(f,2)/Math.pow(a,2);p>1&&(n*=Math.sqrt(p),a*=Math.sqrt(p)),El(t,e,i,r,n,a,h,c,l,u,d,f,Ps);let{ang1:m,ang2:g}=Ps;const{centerX:x,centerY:y}=Ps;let _=Math.abs(g)/(_e/4);Math.abs(1-_)<1e-7&&(_=1);const b=Math.max(Math.ceil(_),1);g/=b;let S=s[s.length-2],I=s[s.length-1];const M={x:0,y:0};for(let k=0;k{const h=o.x-a.x,c=o.y-a.y,l=Math.sqrt(h*h+c*c),u=h/l,d=c/l;return{len:l,nx:u,ny:d}},r=(a,o)=>{a===0?s.moveTo(o.x,o.y):s.lineTo(o.x,o.y)};let n=t[t.length-1];for(let a=0;a0&&(f=-1,p=!0);const m=d/2;let g,x=Math.abs(Math.cos(m)*h/Math.sin(m));x>Math.min(l.len/2,u.len/2)?(x=Math.min(l.len/2,u.len/2),g=Math.abs(x*Math.sin(m)/Math.cos(m))):g=h;const y=o.x+u.nx*x+-u.ny*g*f,_=o.y+u.ny*x+u.nx*g*f,b=Math.atan2(l.ny,l.nx)+Math.PI/2*f,S=Math.atan2(u.ny,u.nx)-Math.PI/2*f;a===0&&s.moveTo(y+Math.cos(b)*g,_+Math.sin(b)*g),s.arc(y,_,g,b,S,p),n=o}}function Fl(s,t,e,i){const r=(o,h)=>Math.sqrt((o.x-h.x)**2+(o.y-h.y)**2),n=(o,h,c)=>({x:o.x+(h.x-o.x)*c,y:o.y+(h.y-o.y)*c}),a=t.length;for(let o=0;o=2;u-=2)l[u]===l[u-2]&&l[u-1]===l[u-3]&&l.splice(u-1,2);return this.poly(l,!0,a)}ellipse(t,e,i,r,n){return this.drawShape(new ci(t,e,i,r),n),this}roundRect(t,e,i,r,n,a){return this.drawShape(new ui(t,e,i,r,n),a),this}drawShape(t,e){return this.endPoly(),this.shapePrimitives.push({shape:t,transform:e}),this}startPoly(t,e){let i=this._currentPoly;return i&&this.endPoly(),i=new ye,i.points.push(t,e),this._currentPoly=i,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 ye,t)){const e=this.shapePrimitives[this.shapePrimitives.length-1];if(e){let i=e.shape.x,r=e.shape.y;if(e.transform&&!e.transform.isIdentity()){const n=e.transform,a=i;i=n.a*i+n.c*r+n.tx,r=n.b*a+n.d*r+n.ty}this._currentPoly.points.push(i,r)}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(y,!0),e&&t.context.fill(),i&&t.context.stroke();break;case"polyline":_=s.getAttribute("points"),y=_.match(/\d+/g).map(k=>parseInt(k,10)),t.context.poly(y,!1),i&&t.context.stroke();break;case"g":case"svg":break;default:{console.info(`[SVG parser] <${s.nodeName}> elements unsupported`);break}}for(let k=0;k{this._fill=Dt({...this._originalFill},ct.defaultFillStyle)})),this._fill=Dt(t===0?"black":t,ct.defaultFillStyle),this.update())}get stroke(){return this._originalStroke}set stroke(t){t!==this._originalStroke&&(this._originalStroke=t,this._isFillStyle(t)&&(this._originalStroke=this._createProxy({...ct.defaultStrokeStyle,...t},()=>{this._stroke=Ke({...this._originalStroke},ct.defaultStrokeStyle)})),this._stroke=Ke(t,ct.defaultStrokeStyle),this.update())}_generateKey(){return this._styleKey=Hl(this),this._styleKey}update(){this._styleKey=null,this.emit("update",this)}reset(){const t=$t.defaultTextStyle;for(const e in t)this[e]=t[e]}get styleKey(){return this._styleKey||this._generateKey()}clone(){return new $t({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 i,r,n,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;(i=this._fill)!=null&&i.texture&&this._fill.texture.destroy(o),(r=this._originalFill)!=null&&r.texture&&this._originalFill.texture.destroy(o),(n=this._stroke)!=null&&n.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:(i,r,n)=>(i[r]=n,e==null||e(r,n),this.update(),!0)})}_isFillStyle(t){return(t??null)!==null&&!(Q.isColorLike(t)||t instanceof Ae||t instanceof is)}};pi.defaultDropShadow={alpha:1,angle:Math.PI/6,blur:0,color:"black",distance:5};pi.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 mt=pi;function $l(s){const t=s;if(typeof t.dropShadow=="boolean"&&t.dropShadow){const e=mt.defaultDropShadow;s.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){W(O,"strokeThickness is now a part of stroke");const e=t.stroke;let i={};if(Q.isColorLike(e))i.color=e;else if(e instanceof Ae||e instanceof is)i.fill=e;else if(Object.hasOwnProperty.call(e,"color")||Object.hasOwnProperty.call(e,"fill"))i=e;else throw new Error("Invalid stroke value.");s.stroke={...i,width:t.strokeThickness}}if(Array.isArray(t.fillGradientStops)){W(O,"gradient fill is now a fill pattern: `new FillGradient(...)`");let e;s.fontSize==null?s.fontSize=mt.defaultTextStyle.fontSize:typeof s.fontSize=="string"?e=parseInt(s.fontSize,10):e=s.fontSize;const i=new Ae(0,0,0,e*1.7),r=t.fillGradientStops.map(n=>Q.shared.setValue(n).toNumber());r.forEach((n,a)=>{const o=a/(r.length-1);i.addColorStop(o,n)}),s.fill={fill:i}}}class Xl{constructor(t){this._canvasPool=Object.create(null),this.canvasOptions=t||{},this.enableFullScreen=!1}_createCanvasAndContext(t,e){const i=j.get().createCanvas();i.width=t,i.height=e;const r=i.getContext("2d");return{canvas:i,context:r}}getOptimalCanvasAndContext(t,e,i=1){t=Math.ceil(t*i-1e-6),e=Math.ceil(e*i-1e-6),t=Mi(t),e=Mi(e);const r=(t<<17)+(e<<1);this._canvasPool[r]||(this._canvasPool[r]=[]);let n=this._canvasPool[r].pop();return n||(n=this._createCanvasAndContext(t,e)),n}returnCanvasAndContext(t){const e=t.canvas,{width:i,height:r}=e,n=(i<<17)+(r<<1);this._canvasPool[n].push(t)}clear(){this._canvasPool={}}}const yr=new Xl,Yl=["serif","sans-serif","monospace","cursive","fantasy","system-ui"];function ti(s){const t=typeof s.fontSize=="number"?`${s.fontSize}px`:s.fontSize;let e=s.fontFamily;Array.isArray(s.fontFamily)||(e=s.fontFamily.split(","));for(let i=e.length-1;i>=0;i--){let r=e[i].trim();!/([\"\'])[^\'\"]+\1/.test(r)&&!Yl.includes(r)&&(r=`"${r}"`),e[i]=r}return`${s.fontStyle} ${s.fontVariant} ${s.fontWeight} ${t} ${e.join(",")}`}const Es={willReadFrequently:!0},xt=class T{static get experimentalLetterSpacingSupported(){let t=T._experimentalLetterSpacingSupported;if(t!==void 0){const e=j.get().getCanvasRenderingContext2D().prototype;t=T._experimentalLetterSpacingSupported="letterSpacing"in e||"textLetterSpacing"in e}return t}constructor(t,e,i,r,n,a,o,h,c){this.text=t,this.style=e,this.width=i,this.height=r,this.lines=n,this.lineWidths=a,this.lineHeight=o,this.maxLineWidth=h,this.fontProperties=c}static measureText(t=" ",e,i=T._canvas,r=e.wordWrap){var y;const n=`${t}:${e.styleKey}`;if(T._measurementCache[n])return T._measurementCache[n];const a=ti(e),o=T.measureFont(a);o.fontSize===0&&(o.fontSize=e.fontSize,o.ascent=e.fontSize);const h=T.__context;h.font=a;const l=(r?T._wordWrap(t,e,i):t).split(/(?:\r\n|\r|\n)/),u=new Array(l.length);let d=0;for(let _=0;_0&&(r?n-=e:n+=(T.graphemeSegmenter(t).length-1)*e),n}static _wordWrap(t,e,i=T._canvas){const r=i.getContext("2d",Es);let n=0,a="",o="";const h=Object.create(null),{letterSpacing:c,whiteSpace:l}=e,u=T._collapseSpaces(l),d=T._collapseNewlines(l);let f=!u;const p=e.wordWrapWidth+c,m=T._tokenize(t);for(let g=0;gp)if(a!==""&&(o+=T._addLine(a),a="",n=0),T.canBreakWords(x,e.breakWords)){const _=T.wordWrapSplit(x);for(let b=0;b<_.length;b++){let S=_[b],I=S,M=1;for(;_[b+M];){const v=_[b+M];if(!T.canBreakChars(I,v,x,b,e.breakWords))S+=v;else break;I=v,M++}b+=M-1;const k=T._getFromCache(S,c,h,r);k+n>p&&(o+=T._addLine(a),f=!1,a="",n=0),a+=S,n+=k}}else{a.length>0&&(o+=T._addLine(a),a="",n=0);const _=g===m.length-1;o+=T._addLine(x,!_),f=!1,a="",n=0}else y+n>p&&(f=!1,o+=T._addLine(a),a="",n=0),(a.length>0||!T.isBreakingSpace(x)||f)&&(a+=x,n+=y)}return o+=T._addLine(a,!1),o}static _addLine(t,e=!0){return t=T._trimRight(t),t=e?`${t} -`:t,t}static _getFromCache(t,e,i,r){let n=i[t];return typeof n!="number"&&(n=T._measureText(t,e,r)+e,i[t]=n),n}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 i=t[e];if(!T.isBreakingSpace(i))break;t=t.slice(0,-1)}return t}static _isNewline(t){return typeof t!="string"?!1:T._newlines.includes(t.charCodeAt(0))}static isBreakingSpace(t,e){return typeof t!="string"?!1:T._breakingSpaces.includes(t.charCodeAt(0))}static _tokenize(t){const e=[];let i="";if(typeof t!="string")return e;for(let r=0;r{if(typeof(Intl==null?void 0:Intl.Segmenter)=="function"){const s=new Intl.Segmenter;return t=>[...s.segment(t)].map(e=>e.segment)}return s=>[...s]})();xt.experimentalLetterSpacing=!1;xt._fonts={};xt._newlines=[10,13];xt._breakingSpaces=[9,32,8192,8193,8194,8195,8196,8197,8198,8200,8201,8202,8287,12288];xt._measurementCache={};let ei=xt;function _r(s,t){if(s.texture===G.WHITE&&!s.fill)return Q.shared.setValue(s.color).setAlpha(s.alpha??1).toHexa();if(s.fill){if(s.fill instanceof is){const e=s.fill,i=t.createPattern(e.texture.source.resource,"repeat"),r=e.transform.copyTo(D.shared);return r.scale(e.texture.frame.width,e.texture.frame.height),i.setTransform(r),i}else if(s.fill instanceof Ae){const e=s.fill;if(e.type==="linear"){const i=t.createLinearGradient(e.x0,e.y0,e.x1,e.y1);return e.gradientStops.forEach(r=>{i.addColorStop(r.offset,Q.shared.setValue(r.color).toHex())}),i}}}else{const e=t.createPattern(s.texture.source.resource,"repeat"),i=s.matrix.copyTo(D.shared);return i.scale(s.texture.frame.width,s.texture.frame.height),e.setTransform(i),e}return J("FillStyle not recognised",s),"red"}function Vn(s){if(s==="")return[];typeof s=="string"&&(s=[s]);const t=[];for(let e=0,i=s.length;e!this._currentChars.includes(x)).filter((x,y,_)=>_.indexOf(x)===y);if(!e.length)return;this._currentChars=[...this._currentChars,...e];let i;this._currentPageIndex===-1?i=this._nextPage():i=this.pages[this._currentPageIndex];let{canvas:r,context:n}=i.canvasAndContext,a=i.texture.source;const o=this._style;let h=this._currentX,c=this._currentY;const l=this.baseRenderedFontSize/this.baseMeasurementFontSize,u=this._padding*l,d=o.fontStyle==="italic"?2:1;let f=0,p=!1;for(let x=0;xthis._textureSize&&(c+=f,f=M,h=0,c+f>this._textureSize)){a.update();const v=this._nextPage();r=v.canvasAndContext.canvas,n=v.canvasAndContext.context,a=v.texture.source,c=0}const k=b/l-(((m=o.dropShadow)==null?void 0:m.distance)??0)-(((g=o._stroke)==null?void 0:g.width)??0);if(this.chars[y]={id:y.codePointAt(0),xOffset:-this._padding,yOffset:-this._padding,xAdvance:k,kerning:{}},p){this._drawGlyph(n,_,h+u,c+u,l,o);const v=a.width*l,A=a.height*l,Y=new U(h/v*a.width,c/A*a.height,I/v*a.width,M/A*a.height);this.chars[y].texture=new G({source:a,frame:Y}),h+=Math.ceil(I)}}a.update(),this._currentX=h,this._currentY=c,this._skipKerning&&this._applyKerning(e,n)}get pageTextures(){return W(O,"BitmapFont.pageTextures is deprecated, please use BitmapFont.pages instead."),this.pages}_applyKerning(t,e){const i=this._measureCache;for(let r=0;r{const m=n.width;for(let g=0;g{let p=n.chars.length-1;if(i){let m=n.chars[p];for(;m===" ";)n.width-=e.chars[m].xAdvance,m=n.chars[--p]}r.width=Math.max(r.width,n.width),n={width:0,charPositions:[],chars:[],spaceWidth:0,spacesIndex:[]},o=!0,r.lines.push(n),r.height+=e.lineHeight},u=e.baseMeasurementFontSize/t.fontSize,d=t.letterSpacing*u,f=t.wordWrapWidth*u;for(let p=0;p>16&255,i=s>>8&255,r=s&255,n=t>>16&255,a=t>>8&255,o=t&255,h=e*n/255,c=i*a/255,l=r*o/255;return(h<<16)+(c<<8)+l}const nl=new D;class Wn{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,i=this.renderable;return i?rl(e,i.groupColor)+(this.alpha*i.groupAlpha*255<<24):e+(this.alpha*255<<24)}get transform(){var t;return((t=this.renderable)==null?void 0:t.groupTransform)||nl}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 Te={extension:{type:P.ShapeBuilder,name:"circle"},build(s,t){let e,i,r,n,a,o;if(s.type==="circle"){const b=s;e=b.x,i=b.y,a=o=b.radius,r=n=0}else if(s.type==="ellipse"){const b=s;e=b.x,i=b.y,a=b.halfWidth,o=b.halfHeight,r=n=0}else{const b=s,C=b.width/2,I=b.height/2;e=b.x+C,i=b.y+I,a=o=Math.max(0,Math.min(b.radius,Math.min(C,I))),r=C-a,n=I-o}if(!(a>=0&&o>=0&&r>=0&&n>=0))return t;const h=Math.ceil(2.3*Math.sqrt(a+o)),c=h*8+(r?4:0)+(n?4:0);if(c===0)return t;if(h===0)return t[0]=t[6]=e+r,t[1]=t[3]=i+n,t[2]=t[4]=e-r,t[5]=t[7]=i-n,t;let l=0,u=h*4+(r?2:0)+2,d=u,f=c,p=r+a,m=n,g=e+p,x=e-p,y=i+m;if(t[l++]=g,t[l++]=y,t[--u]=y,t[--u]=x,n){const b=i-m;t[d++]=x,t[d++]=b,t[--f]=b,t[--f]=g}for(let b=1;b0&&(r[n++]=h,r[n++]=c,r[n++]=h-1),h++;r[n++]=c+1,r[n++]=c,r[n++]=h-1}},al={...Te,extension:{...Te.extension,name:"ellipse"}},ol={...Te,extension:{...Te.extension,name:"roundedRectangle"}},hl=1e-4,hr=1e-4;function ll(s){const t=s.length;if(t<6)return 1;let e=0;for(let i=0,r=s[t-2],n=s[t-1];iu&&(u+=Math.PI*2);let d=l;const f=u-l,p=Math.abs(f),m=Math.sqrt(h*h+c*c),g=(15*p*Math.sqrt(m)/Math.PI>>0)+1,x=f/g;if(d+=x,o){a.push(s,t),a.push(e,i);for(let y=1,_=d;y=0&&(l.join==="round"?y+=Rt(v,A,v-F*E,A-B*E,v-N*E,A-K*E,g,!1)+4:y+=2,g.push(v-N*R,A-K*R),g.push(v+N*E,A+K*E));continue}const vi=(-F+M)*(-B+A)-(-F+v)*(-B+k),Ai=(-N+Y)*(-K+A)-(-N+v)*(-K+wt),Be=(Tt*Ai-he*vi)/Ee,Ie=(le*vi-oe*Ai)/Ee,ns=(Be-v)*(Be-v)+(Ie-A)*(Ie-A),Et=v+(Be-v)*E,Bt=A+(Ie-A)*E,It=v-(Be-v)*R,Ft=A-(Ie-A)*R,da=Math.min(Tt*Tt+oe*oe,he*he+le*le),Si=ce?E:R,fa=da+Si*Si*C;ns<=fa?l.join==="bevel"||ns/C>I?(ce?(g.push(Et,Bt),g.push(v+F*R,A+B*R),g.push(Et,Bt),g.push(v+N*R,A+K*R)):(g.push(v-F*E,A-B*E),g.push(It,Ft),g.push(v-N*E,A-K*E),g.push(It,Ft)),y+=2):l.join==="round"?ce?(g.push(Et,Bt),g.push(v+F*R,A+B*R),y+=Rt(v,A,v+F*R,A+B*R,v+N*R,A+K*R,g,!0)+4,g.push(Et,Bt),g.push(v+N*R,A+K*R)):(g.push(v-F*E,A-B*E),g.push(It,Ft),y+=Rt(v,A,v-F*E,A-B*E,v-N*E,A-K*E,g,!1)+4,g.push(v-N*E,A-K*E),g.push(It,Ft)):(g.push(Et,Bt),g.push(It,Ft)):(g.push(v-F*E,A-B*E),g.push(v+F*R,A+B*R),l.join==="round"?ce?y+=Rt(v,A,v+F*R,A+B*R,v+N*R,A+K*R,g,!0)+2:y+=Rt(v,A,v-F*E,A-B*E,v-N*E,A-K*E,g,!1)+2:l.join==="miter"&&ns/C<=I&&(ce?(g.push(It,Ft),g.push(It,Ft)):(g.push(Et,Bt),g.push(Et,Bt)),y+=2),g.push(v-N*E,A-K*E),g.push(v+N*R,A+K*R),y+=2)}M=s[(x-2)*2],k=s[(x-2)*2+1],v=s[(x-1)*2],A=s[(x-1)*2+1],F=-(k-A),B=M-v,ft=Math.sqrt(F*F+B*B),F/=ft,B/=ft,F*=b,B*=b,g.push(v-F*E,A-B*E),g.push(v+F*R,A+B*R),p||(l.cap==="round"?y+=Rt(v-F*(E-R)*.5,A-B*(E-R)*.5,v-F*E,A-B*E,v+F*R,A+B*R,g,!1)+2:l.cap==="square"&&(y+=lr(v,A,F,B,E,R,!1,g)));const ua=hr*hr;for(let z=_;z=0&&a>=0&&(t[0]=i,t[1]=r,t[2]=i+n,t[3]=r,t[4]=i+n,t[5]=r+a,t[6]=i,t[7]=r+a),t},triangulate(s,t,e,i,r,n){let a=0;i*=e,t[i+a]=s[0],t[i+a+1]=s[1],a+=e,t[i+a]=s[2],t[i+a+1]=s[3],a+=e,t[i+a]=s[6],t[i+a+1]=s[7],a+=e,t[i+a]=s[4],t[i+a+1]=s[5],a+=e;const o=i/e;r[n++]=o,r[n++]=o+1,r[n++]=o+2,r[n++]=o+1,r[n++]=o+3,r[n++]=o+2}},pl={extension:{type:P.ShapeBuilder,name:"triangle"},build(s,t){return t[0]=s.x,t[1]=s.y,t[2]=s.x2,t[3]=s.y2,t[4]=s.x3,t[5]=s.y3,t},triangulate(s,t,e,i,r,n){let a=0;i*=e,t[i+a]=s[0],t[i+a+1]=s[1],a+=e,t[i+a]=s[2],t[i+a+1]=s[3],a+=e,t[i+a]=s[4],t[i+a+1]=s[5];const o=i/e;r[n++]=o,r[n++]=o+1,r[n++]=o+2}},rs={};nt.handleByMap(P.ShapeBuilder,rs);nt.add(fl,dl,pl,Te,al,ol);const gl=new U;function ml(s,t){const{geometryData:e,batches:i}=t;i.length=0,e.indices.length=0,e.vertices.length=0,e.uvs.length=0;for(let r=0;r{const f=h.length,p=a.length/2,m=[],g=rs[l.type];if(g.build(l,m),u&&Gn(m,u),i){const b=l.closePath??!0;cl(m,t,!1,b,a,2,p,h)}else if(e&&c===d){c!==0&&console.warn("[Pixi Graphics] only the last shape have be cut out");const b=[],C=m.slice();yl(e.shapePath).forEach(M=>{b.push(C.length/2),C.push(...M)}),On(C,b,a,2,p,h,f)}else g.triangulate(m,a,2,p,h,f);const x=o.length/2,y=t.texture;if(y!==G.WHITE){const b=t.matrix;b&&(u&&b.append(u.clone().invert()),sl(a,2,p,o,x,2,a.length/2-p,b))}else il(o,x,2,a.length/2-p);const _=At.get(Wn);_.indexOffset=f,_.indexSize=h.length-f,_.attributeOffset=p,_.attributeSize=a.length/2-p,_.baseColor=t.color,_.alpha=t.alpha,_.texture=y,_.geometryData=n,r.push(_)})}function yl(s){if(!s)return[];const t=s.shapePrimitives,e=[];for(let i=0;i{At.return(i)})}destroy(){for(const t in this._gpuContextHash)this._gpuContextHash[t]&&this.onGraphicsContextDestroy(this._gpuContextHash[t].context)}};di.extension={type:[P.WebGLSystem,P.WebGPUSystem,P.CanvasSystem],name:"graphicsContext"};di.defaultOptions={bezierSmoothness:.5};let Dn=di;const wl=8,Ne=11920929e-14,vl=1;function Un(s,t,e,i,r,n,a,o,h,c){const u=Math.min(.99,Math.max(0,c??Dn.defaultOptions.bezierSmoothness));let d=(vl-u)/1;return d*=d,Al(t,e,i,r,n,a,o,h,s,d),s}function Al(s,t,e,i,r,n,a,o,h,c){Qs(s,t,e,i,r,n,a,o,h,c,0),h.push(a,o)}function Qs(s,t,e,i,r,n,a,o,h,c,l){if(l>wl)return;const u=(s+e)/2,d=(t+i)/2,f=(e+r)/2,p=(i+n)/2,m=(r+a)/2,g=(n+o)/2,x=(u+f)/2,y=(d+p)/2,_=(f+m)/2,b=(p+g)/2,C=(x+_)/2,I=(y+b)/2;if(l>0){let M=a-s,k=o-t;const v=Math.abs((e-a)*k-(i-o)*M),A=Math.abs((r-a)*k-(n-o)*M);if(v>Ne&&A>Ne){if((v+A)*(v+A)<=c*(M*M+k*k)){h.push(C,I);return}}else if(v>Ne){if(v*v<=c*(M*M+k*k)){h.push(C,I);return}}else if(A>Ne){if(A*A<=c*(M*M+k*k)){h.push(C,I);return}}else if(M=C-(s+a)/2,k=I-(t+o)/2,M*M+k*k<=c){h.push(C,I);return}}Qs(s,t,u,d,x,y,C,I,h,c,l+1),Qs(C,I,_,b,m,g,a,o,h,c,l+1)}const Sl=8,Cl=11920929e-14,Tl=1;function Ml(s,t,e,i,r,n,a,o){const c=Math.min(.99,Math.max(0,o??Dn.defaultOptions.bezierSmoothness));let l=(Tl-c)/1;return l*=l,Pl(t,e,i,r,n,a,s,l),s}function Pl(s,t,e,i,r,n,a,o){Js(a,s,t,e,i,r,n,o,0),a.push(r,n)}function Js(s,t,e,i,r,n,a,o,h){if(h>Sl)return;const c=(t+i)/2,l=(e+r)/2,u=(i+n)/2,d=(r+a)/2,f=(c+u)/2,p=(l+d)/2;let m=n-t,g=a-e;const x=Math.abs((i-n)*g-(r-a)*m);if(x>Cl){if(x*x<=o*(m*m+g*g)){s.push(f,p);return}}else if(m=f-(t+n)/2,g=p-(e+a)/2,m*m+g*g<=o){s.push(f,p);return}Js(s,t,e,c,l,f,p,o,h+1),Js(s,f,p,u,d,n,a,o,h+1)}function zn(s,t,e,i,r,n,a,o){let h=Math.abs(r-n);(!a&&r>n||a&&n>r)&&(h=2*Math.PI-h),o=o||Math.max(6,Math.floor(6*Math.pow(i,1/3)*(h/Math.PI))),o=Math.max(o,3);let c=h/o,l=r;c*=a?-1:1;for(let u=0;uu*h)}const we=Math.PI*2,Ps={centerX:0,centerY:0,ang1:0,ang2:0},ks=({x:s,y:t},e,i,r,n,a,o,h)=>{s*=e,t*=i;const c=r*s-n*t,l=n*s+r*t;return h.x=c+a,h.y=l+o,h};function El(s,t){const e=t===-1.5707963267948966?-.551915024494:1.3333333333333333*Math.tan(t/4),i=t===1.5707963267948966?.551915024494:e,r=Math.cos(s),n=Math.sin(s),a=Math.cos(s+t),o=Math.sin(s+t);return[{x:r-n*i,y:n+r*i},{x:a+o*i,y:o-a*i},{x:a,y:o}]}const ur=(s,t,e,i)=>{const r=s*i-t*e<0?-1:1;let n=s*e+t*i;return n>1&&(n=1),n<-1&&(n=-1),r*Math.acos(n)},Bl=(s,t,e,i,r,n,a,o,h,c,l,u,d)=>{const f=Math.pow(r,2),p=Math.pow(n,2),m=Math.pow(l,2),g=Math.pow(u,2);let x=f*p-f*g-p*m;x<0&&(x=0),x/=f*g+p*m,x=Math.sqrt(x)*(a===o?-1:1);const y=x*r/n*u,_=x*-n/r*l,b=c*y-h*_+(s+e)/2,C=h*y+c*_+(t+i)/2,I=(l-y)/r,M=(u-_)/n,k=(-l-y)/r,v=(-u-_)/n,A=ur(1,0,I,M);let Y=ur(I,M,k,v);o===0&&Y>0&&(Y-=we),o===1&&Y<0&&(Y+=we),d.centerX=b,d.centerY=C,d.ang1=A,d.ang2=Y};function Il(s,t,e,i,r,n,a,o=0,h=0,c=0){if(n===0||a===0)return;const l=Math.sin(o*we/360),u=Math.cos(o*we/360),d=u*(t-i)/2+l*(e-r)/2,f=-l*(t-i)/2+u*(e-r)/2;if(d===0&&f===0)return;n=Math.abs(n),a=Math.abs(a);const p=Math.pow(d,2)/Math.pow(n,2)+Math.pow(f,2)/Math.pow(a,2);p>1&&(n*=Math.sqrt(p),a*=Math.sqrt(p)),Bl(t,e,i,r,n,a,h,c,l,u,d,f,Ps);let{ang1:m,ang2:g}=Ps;const{centerX:x,centerY:y}=Ps;let _=Math.abs(g)/(we/4);Math.abs(1-_)<1e-7&&(_=1);const b=Math.max(Math.ceil(_),1);g/=b;let C=s[s.length-2],I=s[s.length-1];const M={x:0,y:0};for(let k=0;k{const h=o.x-a.x,c=o.y-a.y,l=Math.sqrt(h*h+c*c),u=h/l,d=c/l;return{len:l,nx:u,ny:d}},r=(a,o)=>{a===0?s.moveTo(o.x,o.y):s.lineTo(o.x,o.y)};let n=t[t.length-1];for(let a=0;a0&&(f=-1,p=!0);const m=d/2;let g,x=Math.abs(Math.cos(m)*h/Math.sin(m));x>Math.min(l.len/2,u.len/2)?(x=Math.min(l.len/2,u.len/2),g=Math.abs(x*Math.sin(m)/Math.cos(m))):g=h;const y=o.x+u.nx*x+-u.ny*g*f,_=o.y+u.ny*x+u.nx*g*f,b=Math.atan2(l.ny,l.nx)+Math.PI/2*f,C=Math.atan2(u.ny,u.nx)-Math.PI/2*f;a===0&&s.moveTo(y+Math.cos(b)*g,_+Math.sin(b)*g),s.arc(y,_,g,b,C,p),n=o}}function Rl(s,t,e,i){const r=(o,h)=>Math.sqrt((o.x-h.x)**2+(o.y-h.y)**2),n=(o,h,c)=>({x:o.x+(h.x-o.x)*c,y:o.y+(h.y-o.y)*c}),a=t.length;for(let o=0;o=2;u-=2)l[u]===l[u-2]&&l[u-1]===l[u-3]&&l.splice(u-1,2);return this.poly(l,!0,a)}ellipse(t,e,i,r,n){return this.drawShape(new ci(t,e,i,r),n),this}roundRect(t,e,i,r,n,a){return this.drawShape(new ui(t,e,i,r,n),a),this}drawShape(t,e){return this.endPoly(),this.shapePrimitives.push({shape:t,transform:e}),this}startPoly(t,e){let i=this._currentPoly;return i&&this.endPoly(),i=new be,i.points.push(t,e),this._currentPoly=i,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 be,t)){const e=this.shapePrimitives[this.shapePrimitives.length-1];if(e){let i=e.shape.x,r=e.shape.y;if(e.transform&&!e.transform.isIdentity()){const n=e.transform,a=i;i=n.a*i+n.c*r+n.tx,r=n.b*a+n.d*r+n.ty}this._currentPoly.points.push(i,r)}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(y,!0),e&&t.context.fill(),i&&t.context.stroke();break;case"polyline":_=s.getAttribute("points"),y=_.match(/\d+/g).map(k=>parseInt(k,10)),t.context.poly(y,!1),i&&t.context.stroke();break;case"g":case"svg":break;default:{console.info(`[SVG parser] <${s.nodeName}> elements unsupported`);break}}for(let k=0;k{this._fill=Dt({...this._originalFill},ct.defaultFillStyle)})),this._fill=Dt(t===0?"black":t,ct.defaultFillStyle),this.update())}get stroke(){return this._originalStroke}set stroke(t){t!==this._originalStroke&&(this._originalStroke=t,this._isFillStyle(t)&&(this._originalStroke=this._createProxy({...ct.defaultStrokeStyle,...t},()=>{this._stroke=Ze({...this._originalStroke},ct.defaultStrokeStyle)})),this._stroke=Ze(t,ct.defaultStrokeStyle),this.update())}_generateKey(){return this._styleKey=Nl(this),this._styleKey}update(){this._styleKey=null,this.emit("update",this)}reset(){const t=Xt.defaultTextStyle;for(const e in t)this[e]=t[e]}get styleKey(){return this._styleKey||this._generateKey()}clone(){return new Xt({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 i,r,n,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;(i=this._fill)!=null&&i.texture&&this._fill.texture.destroy(o),(r=this._originalFill)!=null&&r.texture&&this._originalFill.texture.destroy(o),(n=this._stroke)!=null&&n.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:(i,r,n)=>(i[r]=n,e==null||e(r,n),this.update(),!0)})}_isFillStyle(t){return(t??null)!==null&&!(Q.isColorLike(t)||t instanceof Ce||t instanceof is)}};pi.defaultDropShadow={alpha:1,angle:Math.PI/6,blur:0,color:"black",distance:5};pi.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 mt=pi;function Xl(s){const t=s;if(typeof t.dropShadow=="boolean"&&t.dropShadow){const e=mt.defaultDropShadow;s.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){W(O,"strokeThickness is now a part of stroke");const e=t.stroke;let i={};if(Q.isColorLike(e))i.color=e;else if(e instanceof Ce||e instanceof is)i.fill=e;else if(Object.hasOwnProperty.call(e,"color")||Object.hasOwnProperty.call(e,"fill"))i=e;else throw new Error("Invalid stroke value.");s.stroke={...i,width:t.strokeThickness}}if(Array.isArray(t.fillGradientStops)){W(O,"gradient fill is now a fill pattern: `new FillGradient(...)`");let e;s.fontSize==null?s.fontSize=mt.defaultTextStyle.fontSize:typeof s.fontSize=="string"?e=parseInt(s.fontSize,10):e=s.fontSize;const i=new Ce(0,0,0,e*1.7),r=t.fillGradientStops.map(n=>Q.shared.setValue(n).toNumber());r.forEach((n,a)=>{const o=a/(r.length-1);i.addColorStop(o,n)}),s.fill={fill:i}}}class Yl{constructor(t){this._canvasPool=Object.create(null),this.canvasOptions=t||{},this.enableFullScreen=!1}_createCanvasAndContext(t,e){const i=j.get().createCanvas();i.width=t,i.height=e;const r=i.getContext("2d");return{canvas:i,context:r}}getOptimalCanvasAndContext(t,e,i=1){t=Math.ceil(t*i-1e-6),e=Math.ceil(e*i-1e-6),t=Mi(t),e=Mi(e);const r=(t<<17)+(e<<1);this._canvasPool[r]||(this._canvasPool[r]=[]);let n=this._canvasPool[r].pop();return n||(n=this._createCanvasAndContext(t,e)),n}returnCanvasAndContext(t){const e=t.canvas,{width:i,height:r}=e,n=(i<<17)+(r<<1);this._canvasPool[n].push(t)}clear(){this._canvasPool={}}}const yr=new Yl,jl=["serif","sans-serif","monospace","cursive","fantasy","system-ui"];function ti(s){const t=typeof s.fontSize=="number"?`${s.fontSize}px`:s.fontSize;let e=s.fontFamily;Array.isArray(s.fontFamily)||(e=s.fontFamily.split(","));for(let i=e.length-1;i>=0;i--){let r=e[i].trim();!/([\"\'])[^\'\"]+\1/.test(r)&&!jl.includes(r)&&(r=`"${r}"`),e[i]=r}return`${s.fontStyle} ${s.fontVariant} ${s.fontWeight} ${t} ${e.join(",")}`}const Es={willReadFrequently:!0},xt=class T{static get experimentalLetterSpacingSupported(){let t=T._experimentalLetterSpacingSupported;if(t!==void 0){const e=j.get().getCanvasRenderingContext2D().prototype;t=T._experimentalLetterSpacingSupported="letterSpacing"in e||"textLetterSpacing"in e}return t}constructor(t,e,i,r,n,a,o,h,c){this.text=t,this.style=e,this.width=i,this.height=r,this.lines=n,this.lineWidths=a,this.lineHeight=o,this.maxLineWidth=h,this.fontProperties=c}static measureText(t=" ",e,i=T._canvas,r=e.wordWrap){var y;const n=`${t}:${e.styleKey}`;if(T._measurementCache[n])return T._measurementCache[n];const a=ti(e),o=T.measureFont(a);o.fontSize===0&&(o.fontSize=e.fontSize,o.ascent=e.fontSize);const h=T.__context;h.font=a;const l=(r?T._wordWrap(t,e,i):t).split(/(?:\r\n|\r|\n)/),u=new Array(l.length);let d=0;for(let _=0;_0&&(r?n-=e:n+=(T.graphemeSegmenter(t).length-1)*e),n}static _wordWrap(t,e,i=T._canvas){const r=i.getContext("2d",Es);let n=0,a="",o="";const h=Object.create(null),{letterSpacing:c,whiteSpace:l}=e,u=T._collapseSpaces(l),d=T._collapseNewlines(l);let f=!u;const p=e.wordWrapWidth+c,m=T._tokenize(t);for(let g=0;gp)if(a!==""&&(o+=T._addLine(a),a="",n=0),T.canBreakWords(x,e.breakWords)){const _=T.wordWrapSplit(x);for(let b=0;b<_.length;b++){let C=_[b],I=C,M=1;for(;_[b+M];){const v=_[b+M];if(!T.canBreakChars(I,v,x,b,e.breakWords))C+=v;else break;I=v,M++}b+=M-1;const k=T._getFromCache(C,c,h,r);k+n>p&&(o+=T._addLine(a),f=!1,a="",n=0),a+=C,n+=k}}else{a.length>0&&(o+=T._addLine(a),a="",n=0);const _=g===m.length-1;o+=T._addLine(x,!_),f=!1,a="",n=0}else y+n>p&&(f=!1,o+=T._addLine(a),a="",n=0),(a.length>0||!T.isBreakingSpace(x)||f)&&(a+=x,n+=y)}return o+=T._addLine(a,!1),o}static _addLine(t,e=!0){return t=T._trimRight(t),t=e?`${t} +`:t,t}static _getFromCache(t,e,i,r){let n=i[t];return typeof n!="number"&&(n=T._measureText(t,e,r)+e,i[t]=n),n}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 i=t[e];if(!T.isBreakingSpace(i))break;t=t.slice(0,-1)}return t}static _isNewline(t){return typeof t!="string"?!1:T._newlines.includes(t.charCodeAt(0))}static isBreakingSpace(t,e){return typeof t!="string"?!1:T._breakingSpaces.includes(t.charCodeAt(0))}static _tokenize(t){const e=[];let i="";if(typeof t!="string")return e;for(let r=0;r{if(typeof(Intl==null?void 0:Intl.Segmenter)=="function"){const s=new Intl.Segmenter;return t=>[...s.segment(t)].map(e=>e.segment)}return s=>[...s]})();xt.experimentalLetterSpacing=!1;xt._fonts={};xt._newlines=[10,13];xt._breakingSpaces=[9,32,8192,8193,8194,8195,8196,8197,8198,8200,8201,8202,8287,12288];xt._measurementCache={};let ei=xt;function _r(s,t){if(s.texture===G.WHITE&&!s.fill)return Q.shared.setValue(s.color).setAlpha(s.alpha??1).toHexa();if(s.fill){if(s.fill instanceof is){const e=s.fill,i=t.createPattern(e.texture.source.resource,"repeat"),r=e.transform.copyTo(D.shared);return r.scale(e.texture.frame.width,e.texture.frame.height),i.setTransform(r),i}else if(s.fill instanceof Ce){const e=s.fill;if(e.type==="linear"){const i=t.createLinearGradient(e.x0,e.y0,e.x1,e.y1);return e.gradientStops.forEach(r=>{i.addColorStop(r.offset,Q.shared.setValue(r.color).toHex())}),i}}}else{const e=t.createPattern(s.texture.source.resource,"repeat"),i=s.matrix.copyTo(D.shared);return i.scale(s.texture.frame.width,s.texture.frame.height),e.setTransform(i),e}return J("FillStyle not recognised",s),"red"}function Vn(s){if(s==="")return[];typeof s=="string"&&(s=[s]);const t=[];for(let e=0,i=s.length;e!this._currentChars.includes(x)).filter((x,y,_)=>_.indexOf(x)===y);if(!e.length)return;this._currentChars=[...this._currentChars,...e];let i;this._currentPageIndex===-1?i=this._nextPage():i=this.pages[this._currentPageIndex];let{canvas:r,context:n}=i.canvasAndContext,a=i.texture.source;const o=this._style;let h=this._currentX,c=this._currentY;const l=this.baseRenderedFontSize/this.baseMeasurementFontSize,u=this._padding*l,d=o.fontStyle==="italic"?2:1;let f=0,p=!1;for(let x=0;xthis._textureSize&&(c+=f,f=M,h=0,c+f>this._textureSize)){a.update();const v=this._nextPage();r=v.canvasAndContext.canvas,n=v.canvasAndContext.context,a=v.texture.source,c=0}const k=b/l-(((m=o.dropShadow)==null?void 0:m.distance)??0)-(((g=o._stroke)==null?void 0:g.width)??0);if(this.chars[y]={id:y.codePointAt(0),xOffset:-this._padding,yOffset:-this._padding,xAdvance:k,kerning:{}},p){this._drawGlyph(n,_,h+u,c+u,l,o);const v=a.width*l,A=a.height*l,Y=new U(h/v*a.width,c/A*a.height,I/v*a.width,M/A*a.height);this.chars[y].texture=new G({source:a,frame:Y}),h+=Math.ceil(I)}}a.update(),this._currentX=h,this._currentY=c,this._skipKerning&&this._applyKerning(e,n)}get pageTextures(){return W(O,"BitmapFont.pageTextures is deprecated, please use BitmapFont.pages instead."),this.pages}_applyKerning(t,e){const i=this._measureCache;for(let r=0;r{const m=n.width;for(let g=0;g{let p=n.chars.length-1;if(i){let m=n.chars[p];for(;m===" ";)n.width-=e.chars[m].xAdvance,m=n.chars[--p]}r.width=Math.max(r.width,n.width),n={width:0,charPositions:[],chars:[],spaceWidth:0,spacesIndex:[]},o=!0,r.lines.push(n),r.height+=e.lineHeight},u=e.baseMeasurementFontSize/t.fontSize,d=t.letterSpacing*u,f=t.wordWrapWidth*u;for(let p=0;pf?(l(),c(h),g||n.charPositions.push(0)):(h.start=n.width,c(h),g||n.charPositions.push(0)),m==="\r"||m===` -`)n.width!==0&&l();else if(!g){const S=x.xAdvance+(x.kerning[a]||0)+d;n.width+=S,n.spaceWidth=S,n.spacesIndex.push(n.charPositions.length),n.chars.push(m)}}else{const b=x.kerning[a]||0,S=x.xAdvance+b+d;h.positions[h.index++]=h.width+b,h.chars.push(m),h.width+=S}a=m}return l(),t.align==="center"?ql(r):t.align==="right"?Kl(r):t.align==="justify"&&Zl(r),r}function ql(s){for(let t=0;t50&&J("BitmapText",`You have dynamically created ${Ne} bitmap fonts, this can be inefficient. Try pre installing your font styles using \`BitmapFont.install({name:"style1", style})\``),o.once("destroy",()=>{Ne--,$.remove(i)}),$.set(i,o)}const n=$.get(i);return(a=n.ensureCharacters)==null||a.call(n,t),n}getLayout(t,e,i=!0){const r=this.getFont(t,e);return jl([...t],e,r,i)}measureText(t,e,i=!0){return this.getLayout(t,e,i)}install(...t){var c,l,u,d;let e=t[0];typeof e=="string"&&(e={name:e,style:t[1],chars:(c=t[2])==null?void 0:c.chars,resolution:(l=t[2])==null?void 0:l.resolution,padding:(u=t[2])==null?void 0:u.padding,skipKerning:(d=t[2])==null?void 0:d.skipKerning},W(O,"BitmapFontManager.install(name, style, options) is deprecated, use BitmapFontManager.install({name, style, ...options})"));const i=e==null?void 0:e.name;if(!i)throw new Error("[BitmapFontManager] Property `name` is required.");e={...this.defaultOptions,...e};const r=e.style,n=r instanceof mt?r:new mt(r),a=n._fill.fill!==null&&n._fill.fill!==void 0,o=new br({style:n,overrideFill:a,skipKerning:e.skipKerning,padding:e.padding,resolution:e.resolution,overrideSize:!1}),h=Vn(e.chars);return o.ensureCharacters(h.join("")),$.set(`${i}-bitmap`,o),o.once("destroy",()=>$.remove(`${i}-bitmap`)),o}uninstall(t){const e=`${t}-bitmap`,i=$.get(e);i&&($.remove(e),i.destroy())}}const wr=new Ql;class Yn extends Sn{constructor(t,e){super();const{textures:i,data:r}=t;Object.keys(r.pages).forEach(n=>{const a=r.pages[parseInt(n,10)],o=i[a.id];this.pages.push({texture:o})}),Object.keys(r.chars).forEach(n=>{const a=r.chars[n],{frame:o,source:h}=i[a.page],c=new U(a.x+o.x,a.y+o.y,a.width,a.height),l=new G({source:h,frame:c});this.chars[n]={id:n.codePointAt(0),xOffset:a.xOffset,yOffset:a.yOffset,xAdvance:a.xAdvance,kerning:a.kerning??{},texture:l}}),this.baseRenderedFontSize=r.fontSize,this.baseMeasurementFontSize=r.fontSize,this.fontMetrics={ascent:0,descent:0,fontSize:r.fontSize},this.baseLineOffset=r.baseLineOffset,this.lineHeight=r.lineHeight,this.fontFamily=r.fontFamily,this.distanceField=r.distanceField??{type:"none",range:0},this.url=e}destroy(){super.destroy();for(let t=0;t")?vr.test(j.get().parseXML(s)):!1},parse(s){return vr.parse(j.get().parseXML(s))}},Jl=[".xml",".fnt"],tc={extension:{type:P.CacheParser,name:"cacheBitmapFont"},test:s=>s instanceof Yn,getCacheableAssets(s,t){const e={};return s.forEach(i=>{e[i]=t,e[`${i}-bitmap`]=t}),e[`${t.fontFamily}-bitmap`]=t,e}},ec={extension:{type:P.LoadParser,priority:kt.Normal},name:"loadBitmapFont",test(s){return Jl.includes(lt.extname(s).toLowerCase())},async testParse(s){return Bs.test(s)||Ar.test(s)},async parse(s,t,e){const i=Bs.test(s)?Bs.parse(s):Ar.parse(s),{src:r}=t,{pages:n}=i,a=[],o=i.distanceField?{scaleMode:"linear",alphaMode:"premultiply-alpha-on-upload",autoGenerateMipmaps:!1,resolution:1}:{};for(let u=0;uh[u.src]);return new Yn({data:i,textures:c},r)},async load(s,t){return await(await j.get().fetch(s)).text()},async unload(s,t,e){await Promise.all(s.pages.map(i=>e.unload(i.texture.source._sourceOrigin))),s.destroy()}};class sc{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 i=0;iArray.isArray(s)&&s.every(t=>t instanceof G),getCacheableAssets:(s,t)=>{const e={};return s.forEach(i=>{t.forEach((r,n)=>{e[i+(n===0?"":n+1)]=r})}),e}};async function jn(s){if("Image"in globalThis)return new Promise(t=>{const e=new Image;e.onload=()=>{t(!0)},e.onerror=()=>{t(!1)},e.src=s});if("createImageBitmap"in globalThis&&"fetch"in globalThis){try{const t=await(await fetch(s)).blob();await createImageBitmap(t)}catch{return!1}return!0}return!1}const rc={extension:{type:P.DetectionParser,priority:1},test:async()=>jn("data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAAB0AAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAIAAAACAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQ0MAAAAABNjb2xybmNseAACAAIAAYAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAACVtZGF0EgAKCBgANogQEAwgMg8f8D///8WfhwB8+ErK42A="),add:async s=>[...s,"avif"],remove:async s=>s.filter(t=>t!=="avif")},Sr=["png","jpg","jpeg"],nc={extension:{type:P.DetectionParser,priority:-1},test:()=>Promise.resolve(!0),add:async s=>[...s,...Sr],remove:async s=>s.filter(t=>!Sr.includes(t))},ac="WorkerGlobalScope"in globalThis&&globalThis instanceof globalThis.WorkerGlobalScope;function gi(s){return ac?!1:document.createElement("video").canPlayType(s)!==""}const oc={extension:{type:P.DetectionParser,priority:0},test:async()=>gi("video/mp4"),add:async s=>[...s,"mp4","m4v"],remove:async s=>s.filter(t=>t!=="mp4"&&t!=="m4v")},hc={extension:{type:P.DetectionParser,priority:0},test:async()=>gi("video/ogg"),add:async s=>[...s,"ogv"],remove:async s=>s.filter(t=>t!=="ogv")},lc={extension:{type:P.DetectionParser,priority:0},test:async()=>gi("video/webm"),add:async s=>[...s,"webm"],remove:async s=>s.filter(t=>t!=="webm")},cc={extension:{type:P.DetectionParser,priority:0},test:async()=>jn("data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAAAAAAfQ//73v/+BiOh/AAA="),add:async s=>[...s,"webp"],remove:async s=>s.filter(t=>t!=="webp")};class uc{constructor(){this._parsers=[],this._parsersValidated=!1,this.parsers=new Proxy(this._parsers,{set:(t,e,i)=>(this._parsersValidated=!1,t[e]=i,!0)}),this.promiseCache={}}reset(){this._parsersValidated=!1,this.promiseCache={}}_getLoadPromiseAndParser(t,e){const i={promise:null,parser:null};return i.promise=(async()=>{var a,o;let r=null,n=null;if(e.loadParser&&(n=this._parserHash[e.loadParser],n||J(`[Assets] specified load parser "${e.loadParser}" not found while loading ${t}`)),!n){for(let h=0;h({alias:[c],src:c,data:{}})),o=a.length,h=a.map(async c=>{const l=lt.toAbsolute(c.src);if(!r[c.src])try{this.promiseCache[l]||(this.promiseCache[l]=this._getLoadPromiseAndParser(l,c)),r[c.src]=await this.promiseCache[l].promise,e&&e(++i/o)}catch(u){throw delete this.promiseCache[l],delete r[c.src],new Error(`[Loader.load] Failed to load ${l}. -${u}`)}});return await Promise.all(h),n?r[a[0].src]:r}async unload(t){const i=gt(t,r=>({alias:[r],src:r})).map(async r=>{var o,h;const n=lt.toAbsolute(r.src),a=this.promiseCache[n];if(a){const c=await a.promise;delete this.promiseCache[n],await((h=(o=a.parser)==null?void 0:o.unload)==null?void 0:h.call(o,c,r,this))}});await Promise.all(i)}_validateParsers(){this._parsersValidated=!0,this._parserHash=this._parsers.filter(t=>t.name).reduce((t,e)=>(e.name?t[e.name]&&J(`[Assets] loadParser name conflict "${e.name}"`):J("[Assets] loadParser should have a name"),{...t,[e.name]:e}),{})}}function se(s,t){if(Array.isArray(t)){for(const e of t)if(s.startsWith(`data:${e}`))return!0;return!1}return s.startsWith(`data:${t}`)}function ie(s,t){const e=s.split("?")[0],i=lt.extname(e).toLowerCase();return Array.isArray(t)?t.includes(i):i===t}const dc=".json",fc="application/json",pc={extension:{type:P.LoadParser,priority:kt.Low},name:"loadJson",test(s){return se(s,fc)||ie(s,dc)},async load(s){return await(await j.get().fetch(s)).json()}},gc=".txt",mc="text/plain",xc={name:"loadTxt",extension:{type:P.LoadParser,priority:kt.Low,name:"loadTxt"},test(s){return se(s,mc)||ie(s,gc)},async load(s){return await(await j.get().fetch(s)).text()}},yc=["normal","bold","100","200","300","400","500","600","700","800","900"],_c=[".ttf",".otf",".woff",".woff2"],bc=["font/ttf","font/otf","font/woff","font/woff2"],wc=/^(--|-?[A-Z_])[0-9A-Z_-]*$/i;function vc(s){const t=lt.extname(s),r=lt.basename(s,t).replace(/(-|_)/g," ").toLowerCase().split(" ").map(o=>o.charAt(0).toUpperCase()+o.slice(1));let n=r.length>0;for(const o of r)if(!o.match(wc)){n=!1;break}let a=r.join(" ");return n||(a=`"${a.replace(/[\\"]/g,"\\$&")}"`),a}const Ac=/^[0-9A-Za-z%:/?#\[\]@!\$&'()\*\+,;=\-._~]*$/;function Sc(s){return Ac.test(s)?s:encodeURI(s)}const Cc={extension:{type:P.LoadParser,priority:kt.Low},name:"loadWebFont",test(s){return se(s,bc)||ie(s,_c)},async load(s,t){var i,r,n;const e=j.get().getFontFaceSet();if(e){const a=[],o=((i=t.data)==null?void 0:i.family)??vc(s),h=((n=(r=t.data)==null?void 0:r.weights)==null?void 0:n.filter(l=>yc.includes(l)))??["normal"],c=t.data??{};for(let l=0;l{$.remove(t.family),j.get().getFontFaceSet().delete(t)})}};function mi(s,t=1){var i;const e=(i=ee.RETINA_PREFIX)==null?void 0:i.exec(s);return e?parseFloat(e[1]):t}function xi(s,t,e){s.label=e,s._sourceOrigin=e;const i=new G({source:s,label:e}),r=()=>{delete t.promiseCache[e],$.has(e)&&$.remove(e)};return i.source.once("destroy",()=>{t.promiseCache[e]&&(J("[Assets] A TextureSource managed by Assets was destroyed instead of unloaded! Use Assets.unload() instead of destroying the TextureSource."),r())}),i.once("destroy",()=>{s.destroyed||(J("[Assets] A Texture managed by Assets was destroyed instead of unloaded! Use Assets.unload() instead of destroying the Texture."),r())}),i}const Tc=".svg",Mc="image/svg+xml",Pc={extension:{type:P.LoadParser,priority:kt.Low,name:"loadSVG"},name:"loadSVG",config:{crossOrigin:"anonymous",parseAsGraphicsContext:!1},test(s){return se(s,Mc)||ie(s,Tc)},async load(s,t,e){return t.data.parseAsGraphicsContext??this.config.parseAsGraphicsContext?Ec(s):kc(s,t,e,this.config.crossOrigin)},unload(s){s.destroy(!0)}};async function kc(s,t,e,i){var g,x,y;const n=await(await j.get().fetch(s)).blob(),a=URL.createObjectURL(n),o=new Image;o.src=a,o.crossOrigin=i,await o.decode(),URL.revokeObjectURL(a);const h=document.createElement("canvas"),c=h.getContext("2d"),l=((g=t.data)==null?void 0:g.resolution)||mi(s),u=((x=t.data)==null?void 0:x.width)??o.width,d=((y=t.data)==null?void 0:y.height)??o.height;h.width=u*l,h.height=d*l,c.drawImage(o,0,0,u*l,d*l);const{parseAsGraphicsContext:f,...p}=t.data,m=new te({resource:h,alphaMode:"premultiply-alpha-on-upload",resolution:l,...p});return xi(m,e,s)}async function Ec(s){const e=await(await j.get().fetch(s)).text(),i=new ct;return i.svg(e),i}const Bc=`(function () { +`)n.width!==0&&l();else if(!g){const C=x.xAdvance+(x.kerning[a]||0)+d;n.width+=C,n.spaceWidth=C,n.spacesIndex.push(n.charPositions.length),n.chars.push(m)}}else{const b=x.kerning[a]||0,C=x.xAdvance+b+d;h.positions[h.index++]=h.width+b,h.chars.push(m),h.width+=C}a=m}return l(),t.align==="center"?Kl(r):t.align==="right"?Zl(r):t.align==="justify"&&Ql(r),r}function Kl(s){for(let t=0;t50&&J("BitmapText",`You have dynamically created ${Ve} bitmap fonts, this can be inefficient. Try pre installing your font styles using \`BitmapFont.install({name:"style1", style})\``),o.once("destroy",()=>{Ve--,$.remove(i)}),$.set(i,o)}const n=$.get(i);return(a=n.ensureCharacters)==null||a.call(n,t),n}getLayout(t,e,i=!0){const r=this.getFont(t,e);return ql([...t],e,r,i)}measureText(t,e,i=!0){return this.getLayout(t,e,i)}install(...t){var c,l,u,d;let e=t[0];typeof e=="string"&&(e={name:e,style:t[1],chars:(c=t[2])==null?void 0:c.chars,resolution:(l=t[2])==null?void 0:l.resolution,padding:(u=t[2])==null?void 0:u.padding,skipKerning:(d=t[2])==null?void 0:d.skipKerning},W(O,"BitmapFontManager.install(name, style, options) is deprecated, use BitmapFontManager.install({name, style, ...options})"));const i=e==null?void 0:e.name;if(!i)throw new Error("[BitmapFontManager] Property `name` is required.");e={...this.defaultOptions,...e};const r=e.style,n=r instanceof mt?r:new mt(r),a=n._fill.fill!==null&&n._fill.fill!==void 0,o=new br({style:n,overrideFill:a,skipKerning:e.skipKerning,padding:e.padding,resolution:e.resolution,overrideSize:!1}),h=Vn(e.chars);return o.ensureCharacters(h.join("")),$.set(`${i}-bitmap`,o),o.once("destroy",()=>$.remove(`${i}-bitmap`)),o}uninstall(t){const e=`${t}-bitmap`,i=$.get(e);i&&($.remove(e),i.destroy())}}const wr=new Jl;class Yn extends Sn{constructor(t,e){super();const{textures:i,data:r}=t;Object.keys(r.pages).forEach(n=>{const a=r.pages[parseInt(n,10)],o=i[a.id];this.pages.push({texture:o})}),Object.keys(r.chars).forEach(n=>{const a=r.chars[n],{frame:o,source:h}=i[a.page],c=new U(a.x+o.x,a.y+o.y,a.width,a.height),l=new G({source:h,frame:c});this.chars[n]={id:n.codePointAt(0),xOffset:a.xOffset,yOffset:a.yOffset,xAdvance:a.xAdvance,kerning:a.kerning??{},texture:l}}),this.baseRenderedFontSize=r.fontSize,this.baseMeasurementFontSize=r.fontSize,this.fontMetrics={ascent:0,descent:0,fontSize:r.fontSize},this.baseLineOffset=r.baseLineOffset,this.lineHeight=r.lineHeight,this.fontFamily=r.fontFamily,this.distanceField=r.distanceField??{type:"none",range:0},this.url=e}destroy(){super.destroy();for(let t=0;t")?vr.test(j.get().parseXML(s)):!1},parse(s){return vr.parse(j.get().parseXML(s))}},tc=[".xml",".fnt"],ec={extension:{type:P.CacheParser,name:"cacheBitmapFont"},test:s=>s instanceof Yn,getCacheableAssets(s,t){const e={};return s.forEach(i=>{e[i]=t,e[`${i}-bitmap`]=t}),e[`${t.fontFamily}-bitmap`]=t,e}},sc={extension:{type:P.LoadParser,priority:kt.Normal},name:"loadBitmapFont",test(s){return tc.includes(lt.extname(s).toLowerCase())},async testParse(s){return Bs.test(s)||Ar.test(s)},async parse(s,t,e){const i=Bs.test(s)?Bs.parse(s):Ar.parse(s),{src:r}=t,{pages:n}=i,a=[],o=i.distanceField?{scaleMode:"linear",alphaMode:"premultiply-alpha-on-upload",autoGenerateMipmaps:!1,resolution:1}:{};for(let u=0;uh[u.src]);return new Yn({data:i,textures:c},r)},async load(s,t){return await(await j.get().fetch(s)).text()},async unload(s,t,e){await Promise.all(s.pages.map(i=>e.unload(i.texture.source._sourceOrigin))),s.destroy()}};class ic{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 i=0;iArray.isArray(s)&&s.every(t=>t instanceof G),getCacheableAssets:(s,t)=>{const e={};return s.forEach(i=>{t.forEach((r,n)=>{e[i+(n===0?"":n+1)]=r})}),e}};async function jn(s){if("Image"in globalThis)return new Promise(t=>{const e=new Image;e.onload=()=>{t(!0)},e.onerror=()=>{t(!1)},e.src=s});if("createImageBitmap"in globalThis&&"fetch"in globalThis){try{const t=await(await fetch(s)).blob();await createImageBitmap(t)}catch{return!1}return!0}return!1}const nc={extension:{type:P.DetectionParser,priority:1},test:async()=>jn("data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAAB0AAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAIAAAACAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQ0MAAAAABNjb2xybmNseAACAAIAAYAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAACVtZGF0EgAKCBgANogQEAwgMg8f8D///8WfhwB8+ErK42A="),add:async s=>[...s,"avif"],remove:async s=>s.filter(t=>t!=="avif")},Sr=["png","jpg","jpeg"],ac={extension:{type:P.DetectionParser,priority:-1},test:()=>Promise.resolve(!0),add:async s=>[...s,...Sr],remove:async s=>s.filter(t=>!Sr.includes(t))},oc="WorkerGlobalScope"in globalThis&&globalThis instanceof globalThis.WorkerGlobalScope;function gi(s){return oc?!1:document.createElement("video").canPlayType(s)!==""}const hc={extension:{type:P.DetectionParser,priority:0},test:async()=>gi("video/mp4"),add:async s=>[...s,"mp4","m4v"],remove:async s=>s.filter(t=>t!=="mp4"&&t!=="m4v")},lc={extension:{type:P.DetectionParser,priority:0},test:async()=>gi("video/ogg"),add:async s=>[...s,"ogv"],remove:async s=>s.filter(t=>t!=="ogv")},cc={extension:{type:P.DetectionParser,priority:0},test:async()=>gi("video/webm"),add:async s=>[...s,"webm"],remove:async s=>s.filter(t=>t!=="webm")},uc={extension:{type:P.DetectionParser,priority:0},test:async()=>jn("data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAAAAAAfQ//73v/+BiOh/AAA="),add:async s=>[...s,"webp"],remove:async s=>s.filter(t=>t!=="webp")};class dc{constructor(){this._parsers=[],this._parsersValidated=!1,this.parsers=new Proxy(this._parsers,{set:(t,e,i)=>(this._parsersValidated=!1,t[e]=i,!0)}),this.promiseCache={}}reset(){this._parsersValidated=!1,this.promiseCache={}}_getLoadPromiseAndParser(t,e){const i={promise:null,parser:null};return i.promise=(async()=>{var a,o;let r=null,n=null;if(e.loadParser&&(n=this._parserHash[e.loadParser],n||J(`[Assets] specified load parser "${e.loadParser}" not found while loading ${t}`)),!n){for(let h=0;h({alias:[c],src:c,data:{}})),o=a.length,h=a.map(async c=>{const l=lt.toAbsolute(c.src);if(!r[c.src])try{this.promiseCache[l]||(this.promiseCache[l]=this._getLoadPromiseAndParser(l,c)),r[c.src]=await this.promiseCache[l].promise,e&&e(++i/o)}catch(u){throw delete this.promiseCache[l],delete r[c.src],new Error(`[Loader.load] Failed to load ${l}. +${u}`)}});return await Promise.all(h),n?r[a[0].src]:r}async unload(t){const i=gt(t,r=>({alias:[r],src:r})).map(async r=>{var o,h;const n=lt.toAbsolute(r.src),a=this.promiseCache[n];if(a){const c=await a.promise;delete this.promiseCache[n],await((h=(o=a.parser)==null?void 0:o.unload)==null?void 0:h.call(o,c,r,this))}});await Promise.all(i)}_validateParsers(){this._parsersValidated=!0,this._parserHash=this._parsers.filter(t=>t.name).reduce((t,e)=>(e.name?t[e.name]&&J(`[Assets] loadParser name conflict "${e.name}"`):J("[Assets] loadParser should have a name"),{...t,[e.name]:e}),{})}}function re(s,t){if(Array.isArray(t)){for(const e of t)if(s.startsWith(`data:${e}`))return!0;return!1}return s.startsWith(`data:${t}`)}function ne(s,t){const e=s.split("?")[0],i=lt.extname(e).toLowerCase();return Array.isArray(t)?t.includes(i):i===t}const fc=".json",pc="application/json",gc={extension:{type:P.LoadParser,priority:kt.Low},name:"loadJson",test(s){return re(s,pc)||ne(s,fc)},async load(s){return await(await j.get().fetch(s)).json()}},mc=".txt",xc="text/plain",yc={name:"loadTxt",extension:{type:P.LoadParser,priority:kt.Low,name:"loadTxt"},test(s){return re(s,xc)||ne(s,mc)},async load(s){return await(await j.get().fetch(s)).text()}},_c=["normal","bold","100","200","300","400","500","600","700","800","900"],bc=[".ttf",".otf",".woff",".woff2"],wc=["font/ttf","font/otf","font/woff","font/woff2"],vc=/^(--|-?[A-Z_])[0-9A-Z_-]*$/i;function Ac(s){const t=lt.extname(s),r=lt.basename(s,t).replace(/(-|_)/g," ").toLowerCase().split(" ").map(o=>o.charAt(0).toUpperCase()+o.slice(1));let n=r.length>0;for(const o of r)if(!o.match(vc)){n=!1;break}let a=r.join(" ");return n||(a=`"${a.replace(/[\\"]/g,"\\$&")}"`),a}const Sc=/^[0-9A-Za-z%:/?#\[\]@!\$&'()\*\+,;=\-._~]*$/;function Cc(s){return Sc.test(s)?s:encodeURI(s)}const Tc={extension:{type:P.LoadParser,priority:kt.Low},name:"loadWebFont",test(s){return re(s,wc)||ne(s,bc)},async load(s,t){var i,r,n;const e=j.get().getFontFaceSet();if(e){const a=[],o=((i=t.data)==null?void 0:i.family)??Ac(s),h=((n=(r=t.data)==null?void 0:r.weights)==null?void 0:n.filter(l=>_c.includes(l)))??["normal"],c=t.data??{};for(let l=0;l{$.remove(t.family),j.get().getFontFaceSet().delete(t)})}};function mi(s,t=1){var i;const e=(i=ie.RETINA_PREFIX)==null?void 0:i.exec(s);return e?parseFloat(e[1]):t}function xi(s,t,e){s.label=e,s._sourceOrigin=e;const i=new G({source:s,label:e}),r=()=>{delete t.promiseCache[e],$.has(e)&&$.remove(e)};return i.source.once("destroy",()=>{t.promiseCache[e]&&(J("[Assets] A TextureSource managed by Assets was destroyed instead of unloaded! Use Assets.unload() instead of destroying the TextureSource."),r())}),i.once("destroy",()=>{s.destroyed||(J("[Assets] A Texture managed by Assets was destroyed instead of unloaded! Use Assets.unload() instead of destroying the Texture."),r())}),i}const Mc=".svg",Pc="image/svg+xml",kc={extension:{type:P.LoadParser,priority:kt.Low,name:"loadSVG"},name:"loadSVG",config:{crossOrigin:"anonymous",parseAsGraphicsContext:!1},test(s){return re(s,Pc)||ne(s,Mc)},async load(s,t,e){return t.data.parseAsGraphicsContext??this.config.parseAsGraphicsContext?Bc(s):Ec(s,t,e,this.config.crossOrigin)},unload(s){s.destroy(!0)}};async function Ec(s,t,e,i){var g,x,y;const n=await(await j.get().fetch(s)).blob(),a=URL.createObjectURL(n),o=new Image;o.src=a,o.crossOrigin=i,await o.decode(),URL.revokeObjectURL(a);const h=document.createElement("canvas"),c=h.getContext("2d"),l=((g=t.data)==null?void 0:g.resolution)||mi(s),u=((x=t.data)==null?void 0:x.width)??o.width,d=((y=t.data)==null?void 0:y.height)??o.height;h.width=u*l,h.height=d*l,c.drawImage(o,0,0,u*l,d*l);const{parseAsGraphicsContext:f,...p}=t.data,m=new se({resource:h,alphaMode:"premultiply-alpha-on-upload",resolution:l,...p});return xi(m,e,s)}async function Bc(s){const e=await(await j.get().fetch(s)).text(),i=new ct;return i.svg(e),i}const Ic=`(function () { 'use strict'; const WHITE_PNG = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8/x8AAwMCAO+ip1sAAAAASUVORK5CYII="; @@ -264,7 +264,7 @@ ${u}`)}});return await Promise.all(h),n?r[a[0].src]:r}async unload(t){const i=gt }); })(); -`;let Yt=null,si=class{constructor(){Yt||(Yt=URL.createObjectURL(new Blob([Bc],{type:"application/javascript"}))),this.worker=new Worker(Yt)}};si.revokeObjectURL=function(){Yt&&(URL.revokeObjectURL(Yt),Yt=null)};const Ic=`(function () { +`;let jt=null,si=class{constructor(){jt||(jt=URL.createObjectURL(new Blob([Ic],{type:"application/javascript"}))),this.worker=new Worker(jt)}};si.revokeObjectURL=function(){jt&&(URL.revokeObjectURL(jt),jt=null)};const Fc=`(function () { 'use strict'; async function loadImageBitmap(url, alphaMode) { @@ -293,4 +293,4 @@ ${u}`)}});return await Promise.all(h),n?r[a[0].src]:r}async unload(t){const i=gt }; })(); -`;let jt=null;class qn{constructor(){jt||(jt=URL.createObjectURL(new Blob([Ic],{type:"application/javascript"}))),this.worker=new Worker(jt)}}qn.revokeObjectURL=function(){jt&&(URL.revokeObjectURL(jt),jt=null)};let Cr=0,Is;class Fc{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 si;e.addEventListener("message",i=>{e.terminate(),si.revokeObjectURL(),t(i.data)})}),this._isImageBitmapSupported)}loadImageBitmap(t,e){var i;return this._run("loadImageBitmap",[t,(i=e==null?void 0:e.data)==null?void 0:i.alphaMode])}async _initWorkers(){this._initialized||(this._initialized=!0)}_getWorker(){Is===void 0&&(Is=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 i=new Promise((r,n)=>{this._queue.push({id:t,arguments:e,resolve:r,reject:n})});return this._next(),i}_next(){if(!this._queue.length)return;const t=this._getWorker();if(!t)return;const e=this._queue.pop(),i=e.id;this._resolveHash[Cr]={resolve:e.resolve,reject:e.reject},t.postMessage({data:e.arguments,uuid:Cr++,id:i})}}const Tr=new Fc,Rc=[".jpeg",".jpg",".png",".webp",".avif"],Lc=["image/jpeg","image/png","image/webp","image/avif"];async function Gc(s,t){var r;const e=await j.get().fetch(s);if(!e.ok)throw new Error(`[loadImageBitmap] Failed to fetch ${s}: ${e.status} ${e.statusText}`);const i=await e.blob();return((r=t==null?void 0:t.data)==null?void 0:r.alphaMode)==="premultiplied-alpha"?createImageBitmap(i,{premultiplyAlpha:"none"}):createImageBitmap(i)}const Kn={name:"loadTextures",extension:{type:P.LoadParser,priority:kt.High,name:"loadTextures"},config:{preferWorkers:!0,preferCreateImageBitmap:!0,crossOrigin:"anonymous"},test(s){return se(s,Lc)||ie(s,Rc)},async load(s,t,e){var n;let i=null;globalThis.createImageBitmap&&this.config.preferCreateImageBitmap?this.config.preferWorkers&&await Tr.isImageBitmapSupported()?i=await Tr.loadImageBitmap(s,t):i=await Gc(s,t):i=await new Promise(a=>{i=new Image,i.crossOrigin=this.config.crossOrigin,i.src=s,i.complete?a(i):i.onload=()=>{a(i)}});const r=new te({resource:i,alphaMode:"premultiply-alpha-on-upload",resolution:((n=t.data)==null?void 0:n.resolution)||mi(s),...t.data});return xi(r,e,s)},unload(s){s.destroy(!0)}},Zn=[".mp4",".m4v",".webm",".ogg",".ogv",".h264",".avi",".mov"],Wc=Zn.map(s=>`video/${s.substring(1)}`);function Oc(s,t,e){e===void 0&&!t.startsWith("data:")?s.crossOrigin=Uc(t):e!==!1&&(s.crossOrigin=typeof e=="string"?e:"anonymous")}function Dc(s){return new Promise((t,e)=>{s.addEventListener("canplaythrough",i),s.addEventListener("error",r),s.load();function i(){n(),t()}function r(a){n(),e(a)}function n(){s.removeEventListener("canplaythrough",i),s.removeEventListener("error",r)}})}function Uc(s,t=globalThis.location){if(s.startsWith("data:"))return"";t=t||globalThis.location;const e=new URL(s,document.baseURI);return e.hostname!==t.hostname||e.port!==t.port||e.protocol!==t.protocol?"anonymous":""}const zc={name:"loadVideo",extension:{type:P.LoadParser,name:"loadVideo"},test(s){const t=se(s,Wc),e=ie(s,Zn);return t||e},async load(s,t,e){var h,c;const i={...Ve.defaultOptions,resolution:((h=t.data)==null?void 0:h.resolution)||mi(s),alphaMode:((c=t.data)==null?void 0:c.alphaMode)||await Jr(),...t.data},r=document.createElement("video"),n={preload:i.autoLoad!==!1?"auto":void 0,"webkit-playsinline":i.playsinline!==!1?"":void 0,playsinline:i.playsinline!==!1?"":void 0,muted:i.muted===!0?"":void 0,loop:i.loop===!0?"":void 0,autoplay:i.autoPlay!==!1?"":void 0};Object.keys(n).forEach(l=>{const u=n[l];u!==void 0&&r.setAttribute(l,u)}),i.muted===!0&&(r.muted=!0),Oc(r,s,i.crossorigin);const a=document.createElement("source");let o;if(s.startsWith("data:"))o=s.slice(5,s.indexOf(";"));else if(!s.startsWith("blob:")){const l=s.split("?")[0].slice(s.lastIndexOf(".")+1).toLowerCase();o=Ve.MIME_TYPES[l]||`video/${l}`}return a.src=s,o&&(a.type=o),new Promise(l=>{const u=async()=>{const d=new Ve({...i,resource:r});r.removeEventListener("canplay",u),t.data.preload&&await Dc(r),l(xi(d,e,s))};r.addEventListener("canplay",u),r.appendChild(a)})},unload(s){s.destroy(!0)}},Qn={extension:{type:P.ResolveParser,name:"resolveTexture"},test:Kn.test,parse:s=>{var t;return{resolution:parseFloat(((t=ee.RETINA_PREFIX.exec(s))==null?void 0:t[1])??"1"),format:s.split(".").pop(),src:s}}},Hc={extension:{type:P.ResolveParser,priority:-2,name:"resolveJson"},test:s=>ee.RETINA_PREFIX.test(s)&&s.endsWith(".json"),parse:Qn.parse};class Nc{constructor(){this._detections=[],this._initialized=!1,this.resolver=new ee,this.loader=new uc,this.cache=$,this._backgroundLoader=new sc(this.loader),this._backgroundLoader.active=!0,this.reset()}async init(t={}){var n,a;if(this._initialized){J("[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=((n=t.texturePreference)==null?void 0:n.resolution)??1,i=typeof e=="number"?[e]:e,r=await this._detectFormats({preferredFormats:(a=t.texturePreference)==null?void 0:a.format,skipDetections:t.skipDetections,detections:this._detections});this.resolver.prefer({params:{format:r,resolution:i}}),t.preferences&&this.setPreferences(t.preferences)}add(t){this.resolver.add(t)}async load(t,e){this._initialized||await this.init();const i=qe(t),r=gt(t).map(o=>{if(typeof o!="string"){const h=this.resolver.getAlias(o);return h.some(c=>!this.resolver.hasKey(c))&&this.add(o),Array.isArray(h)?h[0]:h}return this.resolver.hasKey(o)||this.add({alias:o,src:o}),o}),n=this.resolver.resolve(r),a=await this._mapLoadToResolve(n,e);return i?a[r[0]]:a}addBundle(t,e){this.resolver.addBundle(t,e)}async loadBundle(t,e){this._initialized||await this.init();let i=!1;typeof t=="string"&&(i=!0,t=[t]);const r=this.resolver.resolveBundle(t),n={},a=Object.keys(r);let o=0,h=0;const c=()=>{e==null||e(++o/h)},l=a.map(u=>{const d=r[u];return h+=Object.keys(d).length,this._mapLoadToResolve(d,c).then(f=>{n[u]=f})});return await Promise.all(l),i?n[t[0]]:n}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(i=>{this._backgroundLoader.add(Object.values(i))})}reset(){this.resolver.reset(),this.loader.reset(),this.cache.reset(),this._initialized=!1}get(t){if(typeof t=="string")return $.get(t);const e={};for(let i=0;i{const o=r[a.src],h=[a.src];a.alias&&h.push(...a.alias),h.forEach(c=>{n[c]=o}),$.set(h,o)}),n}async unload(t){this._initialized||await this.init();const e=gt(t).map(r=>typeof r!="string"?r.src:r),i=this.resolver.resolve(e);await this._unloadFromResolved(i)}async unloadBundle(t){this._initialized||await this.init(),t=gt(t);const e=this.resolver.resolveBundle(t),i=Object.keys(e).map(r=>this._unloadFromResolved(e[r]));await Promise.all(i)}async _unloadFromResolved(t){const e=Object.values(t);e.forEach(i=>{$.remove(i.src)}),await this.loader.unload(e)}async _detectFormats(t){let e=[];t.preferredFormats&&(e=Array.isArray(t.preferredFormats)?t.preferredFormats:[t.preferredFormats]);for(const i of t.detections)t.skipDetections||await i.test()?e=await i.add(e):t.skipDetections||(e=await i.remove(e));return e=e.filter((i,r)=>e.indexOf(i)===r),e}get detections(){return this._detections}setPreferences(t){this.loader.parsers.forEach(e=>{e.config&&Object.keys(e.config).filter(i=>i in t).forEach(i=>{e.config[i]=t[i]})})}}const K=new Nc;nt.handleByList(P.LoadParser,K.loader.parsers).handleByList(P.ResolveParser,K.resolver.parsers).handleByList(P.CacheParser,K.cache.parsers).handleByList(P.DetectionParser,K.detections);nt.add(ic,nc,rc,cc,oc,hc,lc,pc,xc,Cc,Pc,Kn,zc,ec,tc,Qn,Hc);const Mr={loader:P.LoadParser,resolver:P.ResolveParser,cache:P.CacheParser,detection:P.DetectionParser};nt.handle(P.Asset,s=>{const t=s.ref;Object.entries(Mr).filter(([e])=>!!t[e]).forEach(([e,i])=>nt.add(Object.assign(t[e],{extension:t[e].extension??i})))},s=>{const t=s.ref;Object.keys(Mr).filter(e=>!!t[e]).forEach(e=>nt.remove(t[e]))});class Qt extends Qe{constructor(t){t instanceof ct&&(t={context:t});const{context:e,roundPixels:i,...r}=t||{};super({label:"Graphics",...r}),this.renderPipeId="graphics",e?this._context=e:this._context=this._ownedContext=new ct,this._context.on("update",this.onViewUpdate,this),this.allowChildren=!1,this.roundPixels=i??!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 Qt(this._context.clone()):(this._ownedContext=null,new Qt(this._context))}lineStyle(t,e,i){W(O,"Graphics#lineStyle is no longer needed. Use Graphics#setStrokeStyle to set the stroke style.");const r={};return t&&(r.width=t),e&&(r.color=e),i&&(r.alpha=i),this.context.strokeStyle=r,this}beginFill(t,e){W(O,"Graphics#beginFill is no longer needed. Use Graphics#fill to fill the shape with the desired style.");const i={};return t&&(i.color=t),e&&(i.alpha=e),this.context.fillStyle=i,this}endFill(){W(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!==ct.defaultStrokeStyle.width||t.color!==ct.defaultStrokeStyle.color||t.alpha!==ct.defaultStrokeStyle.alpha)&&this.context.stroke(),this}drawCircle(...t){return W(O,"Graphics#drawCircle has been renamed to Graphics#circle"),this._callContextMethod("circle",t)}drawEllipse(...t){return W(O,"Graphics#drawEllipse has been renamed to Graphics#ellipse"),this._callContextMethod("ellipse",t)}drawPolygon(...t){return W(O,"Graphics#drawPolygon has been renamed to Graphics#poly"),this._callContextMethod("poly",t)}drawRect(...t){return W(O,"Graphics#drawRect has been renamed to Graphics#rect"),this._callContextMethod("rect",t)}drawRoundedRect(...t){return W(O,"Graphics#drawRoundedRect has been renamed to Graphics#roundRect"),this._callContextMethod("roundRect",t)}drawStar(...t){return W(O,"Graphics#drawStar has been renamed to Graphics#star"),this._callContextMethod("star",t)}}const Jn=class ta extends Bn{constructor(...t){let e=t[0]??{};e instanceof Float32Array&&(W(O,"use new MeshGeometry({ positions, uvs, indices }) instead"),e={positions:e,uvs:t[1],indices:t[2]}),e={...ta.defaultOptions,...e};const i=e.positions||new Float32Array([0,0,1,0,1,1,0,1]),r=e.uvs||new Float32Array([0,0,1,0,1,1,0,1]),n=e.indices||new Uint32Array([0,1,2,0,2,3]),a=e.shrinkBuffersToFit,o=new Pt({data:i,label:"attribute-mesh-positions",shrinkToFit:a,usage:Z.VERTEX|Z.COPY_DST}),h=new Pt({data:r,label:"attribute-mesh-uvs",shrinkToFit:a,usage:Z.VERTEX|Z.COPY_DST}),c=new Pt({data:n,label:"index-mesh-buffer",shrinkToFit:a,usage:Z.INDEX|Z.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:c,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}};Jn.defaultOptions={topology:"triangle-list",shrinkBuffersToFit:!1};let Vc=Jn;class $c extends Qe{constructor(t,e){const{text:i,resolution:r,style:n,anchor:a,width:o,height:h,roundPixels:c,...l}=t;super({...l}),this.batched=!0,this._resolution=null,this._autoResolution=!0,this._didTextUpdate=!0,this._styleClass=e,this.text=i??"",this.style=n,this.resolution=r??null,this.allowChildren=!1,this._anchor=new ot({_onUpdate:()=>{this.onViewUpdate()}}),a&&(this.anchor=a),this.roundPixels=c??!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,i=this.bounds.height,r=-e*this.anchor.x;let n=0;return t.x>=r&&t.x<=r+e&&(n=-i*this.anchor.y,t.y>=n&&t.y<=n+i)}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 Xc(s,t){let e=s[0]??{};return(typeof e=="string"||s[1])&&(W(O,`use new ${t}({ text: "hi!", style }) instead`),e={text:e,style:s[1]}),e}class Ce extends $c{constructor(...t){const e=Xc(t,"Text");super(e,mt),this.renderPipeId="text"}_updateBounds(){const t=this._bounds,e=this._anchor,i=ei.measureText(this._text,this._style),{width:r,height:n}=i;t.minX=-e._x*r,t.maxX=t.minX+r,t.minY=-e._y*n,t.maxY=t.minY+n}}const ea=class sa extends Vc{constructor(...t){super({});let e=t[0]??{};typeof e=="number"&&(W(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={...sa.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,i=[],r=[],n=[],a=this.verticesX-1,o=this.verticesY-1,h=this.width/a,c=this.height/o;for(let u=0;ue?1:this.width/e,r=this._topHeight+this._bottomHeight,n=this.height>r?1:this.height/r,a=Math.min(i,n);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,i=1/this._originalHeight;t[2]=t[10]=t[18]=t[26]=e*this._leftWidth,t[9]=t[11]=t[13]=t[15]=i*this._topHeight,t[4]=t[12]=t[20]=t[28]=1-e*this._rightWidth,t[17]=t[19]=t[21]=t[23]=1-i*this._bottomHeight,this.getBuffer("aUV").update()}};ia.defaultOptions={width:100,height:100,leftWidth:10,topHeight:10,rightWidth:10,bottomHeight:10,originalWidth:100,originalHeight:100};let Vt=ia;const na=class aa extends Qe{constructor(t){var u,d,f,p;t instanceof G&&(t={texture:t});const{width:e,height:i,leftWidth:r,rightWidth:n,topHeight:a,bottomHeight:o,texture:h,roundPixels:c,...l}=t;super({label:"NineSliceSprite",...l}),this.renderPipeId="nineSliceSprite",this.batched=!0,this._didSpriteUpdate=!0,this._leftWidth=r??((u=h==null?void 0:h.defaultBorders)==null?void 0:u.left)??Vt.defaultOptions.leftWidth,this._topHeight=a??((d=h==null?void 0:h.defaultBorders)==null?void 0:d.top)??Vt.defaultOptions.topHeight,this._rightWidth=n??((f=h==null?void 0:h.defaultBorders)==null?void 0:f.right)??Vt.defaultOptions.rightWidth,this._bottomHeight=o??((p=h==null?void 0:h.defaultBorders)==null?void 0:p.bottom)??Vt.defaultOptions.bottomHeight,this.bounds.maxX=this._width=e??h.width??Vt.defaultOptions.width,this.bounds.maxY=this._height=i??h.height??Vt.defaultOptions.height,this.allowChildren=!1,this.texture=h??aa.defaultOptions.texture,this.roundPixels=c??!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=G.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 i=typeof t=="boolean"?t:t==null?void 0:t.textureSource;this._texture.destroy(i)}this._texture=null}};na.defaultOptions={texture:G.EMPTY};let Me=na;nt.add(xa,ya);class C{}w(C,"app"),w(C,"GameMaster"),w(C,"WindowHeight"),w(C,"WindowWidth"),w(C,"AspectRatio",16/9),w(C,"Grid"),w(C,"WaveManager"),w(C,"TowerManager"),w(C,"GameScene");class jc{constructor(){w(this,"currentScene");w(this,"gameScene");w(this,"GameObjects",[]);C.GameMaster=this}_CreateGuiObject(t){this.currentScene.gui.push(t),C.app.stage.addChild(t.container)}_RemoveGuiObject(t){this.currentScene.gui.splice(this.currentScene.gui.indexOf(t),1),C.app.stage.removeChild(t.container)}changeScene(t){this.currentScene&&this.currentScene.destroy(),this.GameObjects.forEach(e=>{e.destroy()}),this.currentScene=t,this.currentScene.init()}}const L=class L{static async LoadAssets(){console.log("Loading Texture Assets");const t=new Ce({text:"Loading textures. This might take a while.",style:new mt({fill:3355443,fontSize:50})});t.x=C.app.canvas.width/2,t.y=C.app.canvas.height/2,t.anchor.set(.5,.5),C.app.stage.addChild(t),L.Button01Texture=await K.load({src:"/assets/gui/button_01.png"}),L.Button02Texture=await K.load({src:"/assets/gui/button_02.png"}),L.Frame01Texture=await K.load({src:"/assets/gui/frame_01.png"}),L.Frame02Texture=await K.load({src:"/assets/gui/frame_02.png"}),L.FrameBackground=await K.load({src:"/assets/gui/background_01.png"}),L.FrameTowerTab=await K.load({src:"/assets/gui/background_02.png"}),L.VioletBackground=await K.load({src:"/assets/gui/frame_violet.png"}),L.RedBackground=await K.load({src:"/assets/gui/frame_red.png"}),L.GreenBackground=await K.load({src:"/assets/gui/frame_green.png"}),L.HealthTexture=await K.load({src:"/assets/gui/heart.png"}),L.GoldTexture=await K.load({src:"/assets/gui/money.png"}),L.BasicCreepTexture=await K.load({src:"/assets/creeps/basic.jpg"}),L.BasicTowerTexture=await K.load({src:"/assets/towers/basic_tower.png"}),L.BasicProjectileTexture=await K.load({src:"/assets/projectiles/basic_tower.png"}),await this.LoadMissions(),await this.LoadTowers(),await this.LoadCreepStats(),t.destroy()}static async LoadCreepStats(){const e=await(await fetch("/assets/CreepStats.json")).json();this.CreepStats=e}static async LoadMissions(){L.Missions=[await this.LoadMission("/assets/missions/mission_01.json")]}static async LoadTowers(){const e=await(await fetch("/assets/Towers.json")).json();L.Towers=e,e.forEach(async i=>{let r=this.TowerSprites.length-1;r==-1&&(r=0),this.TowerSprites[r]=await K.load({src:`/assets/towers/${i.sprite}.png`})})}static async LoadMission(t){const i=await(await fetch(t)).json();return await this.LoadBackground(i.mapImage.url),i}static async LoadBackground(t){let e=this.MissionBackgrounds.length-1;e==-1&&(e=0),this.MissionBackgrounds[e]=await K.load({src:t})}};w(L,"BasicCreepTexture"),w(L,"BasicTowerTexture"),w(L,"BasicProjectileTexture"),w(L,"Frame01Texture"),w(L,"Frame02Texture"),w(L,"FrameBackground"),w(L,"FrameTowerTab"),w(L,"VioletBackground"),w(L,"RedBackground"),w(L,"GreenBackground"),w(L,"Button01Texture"),w(L,"Button02Texture"),w(L,"HealthTexture"),w(L,"GoldTexture"),w(L,"MissionBackgrounds",[]),w(L,"TowerSprites",[]),w(L,"Missions"),w(L,"Towers"),w(L,"CreepStats"),w(L,"DebuggingEnabled",!1);let H=L;class Pe{constructor(t){w(this,"name",this.constructor.name);w(this,"_container",new rt);w(this,"_events",new at);w(this,"enabled",!0);C.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}}var Te=(s=>(s[s.Button01=0]="Button01",s[s.Button02=1]="Button02",s))(Te||{});class Ze extends Pe{constructor(e,i,r,n=!0){super(!0);w(this,"caption");w(this,"bounds");w(this,"buttonTexture");w(this,"buttonSprite");w(this,"buttonText");r==0&&(this.buttonTexture=H.Button01Texture),r==1&&(this.buttonTexture=H.Button02Texture),this.caption=i,this.enabled=n,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 Me({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 Ce({text:this.caption,style:new mt({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}}class re{constructor(){w(this,"name",this.constructor.name);w(this,"_container",new rt);w(this,"bb",new U);w(this,"_events",new at)}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.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}}var Jt=(s=>(s.Died="died",s.TakenDamage="takenDamage",s.Escaped="escaped",s.Moved="moved",s))(Jt||{});class qc extends re{constructor(e,i,r){super();w(this,"id");w(this,"creepType");w(this,"sprite");w(this,"path");w(this,"stats");w(this,"pathIndex",0);w(this,"speed");w(this,"health");w(this,"maxHealth");w(this,"escaped",!1);w(this,"died",!1);w(this,"x");w(this,"y");w(this,"dead",!1);this.creepType=e,this.stats=structuredClone(H.CreepStats[this.creepType]),this.sprite=new dt({texture:H.BasicCreepTexture}),this.id=r,this.container.x=-70,this.container.y=-50,this.sprite.width=64,this.sprite.height=64,this.speed=this.stats.speed,this.health=this.stats.health,this.maxHealth=this.stats.health,this.path=i,this.x=i[0][1]*64+32,this.y=i[0][0]*64+32,C.GameScene.events.on("takenDamage",(n,a)=>{n==this.id&&(this.health-=a)}),C.Grid.container.addChild(this.container),this.container.addChild(this.sprite)}update(e){if(this.dead)return;if(this.health<=0){C.GameScene.events.emit("died",this.maxHealth,this),this.destroy(),this.dead=!0;return}if(this.pathIndex+1==this.path.length){if(this.escaped)return;this.events.emit("escaped",this),this.escaped=!0;return}const i=this.path[this.pathIndex],r=this.path[this.pathIndex+1],n=r[1]*64+32,a=r[0]*64+32,o=r[1]-i[1],h=r[0]-i[0];let c=this.speed*e*o,l=this.speed*e*h,u=!1;c>0&&this.x+c>n&&(c=n-this.x,u=!0),c<0&&this.x+c0&&this.y+l>a&&(l=a-this.y,u=!0),l<0&&this.y+l(s[s.Restricted=0]="Restricted",s[s.Buildable=1]="Buildable",s[s.Path=9]="Path",s))(Ut||{});class Kc extends re{constructor(e,i,r,n){super();w(this,"type");w(this,"row");w(this,"column");w(this,"isPath",!1);w(this,"g");w(this,"clickDetector");if(this.type=e,this.row=i,this.column=r,this.isPath=n,this.bb.x=this.column*64,this.bb.y=this.row*64,this.bb.width=64,this.bb.height=64,C.Grid.container.addChild(this.container),this.container.x=this.bb.x,this.container.y=this.bb.y,this.clickDetector=new Qt({zIndex:99,interactive:!0}),this.clickDetector.rect(0,0,this.bb.width,this.bb.height),this.clickDetector.fill({color:16711680,alpha:0}),this.container.addChild(this.clickDetector),this.clickDetector.onclick=o=>{C.Grid._gridCellClicked(i,r)},!H.DebuggingEnabled)return;const a=new Ce({text:`${this.row}|${this.column}`,style:new mt({fill:16777215,dropShadow:!0,fontSize:16})});this.container.addChild(a),a.anchor.set(.5,.5),a.x=this.bb.width/2,a.y=this.bb.height/2,n&&(a.text+="p")}gDraw(){switch(this.g=new Qt({zIndex:5}),this.g.rect(0,0,this.bb.width,this.bb.height),this.type){case Ut.Restricted:this.g.fill({color:2236962,alpha:.5});break;case Ut.Path:this.g.fill({color:2236962,alpha:.5});break;case Ut.Buildable:this.g.stroke({color:65280,alpha:.9});break}this.container.addChild(this.g)}gClear(){this.g!=null&&(this.container.removeChild(this.g),this.g.destroy())}update(){}}class Zc extends re{constructor(e,i){super();w(this,"gameMap");w(this,"cells",[]);w(this,"creeps",[]);w(this,"gridShown",!1);this.gameMap=e,C.Grid=this,this.bb.x=0,this.bb.y=0,this.bb.width=64*30,this.bb.height=64*17,C.app.stage.addChild(this.container);let r=new dt(H.MissionBackgrounds[i]);r.x=0,r.y=0,r.width=this.bb.width,r.height=this.bb.height,this.container.addChild(r);for(let n=0;nl.some(u=>u[0]===a&&u[1]===n));h&&(o=Ut.Path);let c=new Kc(o,a,n,h);this.cells.push(c)}}toggleGrid(){this.cells.forEach(e=>{this.gridShown?e.gClear():e.gDraw()}),this.gridShown=!this.gridShown}addCreep(e){console.log("ADD CREEP"),this.creeps.push(e),e.events.on(Jt.Died,i=>{this.onCreepDiedOrEscaped(i)}),e.events.on(Jt.Escaped,i=>{this.onCreepDiedOrEscaped(i)})}onCreepDiedOrEscaped(e){this.creeps.splice(this.creeps.indexOf(e),1),e.destroy()}update(e){this.creeps.forEach(i=>{i.dead?(this.creeps.splice(this.creeps.indexOf(i),1),i=null):i.update(e)})}getCellByRowAndCol(e,i){return this.cells.filter(r=>r.row==e&&r.column==i)[0]}_gridCellClicked(e,i){this.onGridCellClicked(e,i)}onGridCellClicked(e,i){}}var oa=(s=>(s.CreepSpawned="creepSpawned",s.Finished="finished",s))(oa||{});class Qc{constructor(t,e){w(this,"creeps",[]);w(this,"rounds");w(this,"paths");w(this,"ticks",0);w(this,"started",!1);w(this,"finished",!1);w(this,"events",new at);w(this,"internalCreepId",0);C.WaveManager=this,this.rounds=t,this.paths=e}start(t){this.started=!0,this.ticks=0,this.creeps=[],this.finished=!1;let e=0;this.rounds[t].waves.forEach(i=>{e+=i.firstCreepSpawnTick,i.creeps.forEach(r=>{const n=new qc(r,this.paths[0],this.internalCreepId);this.internalCreepId++;const a={creep:n,tickToSpawnAt:e,spawned:!1};console.log("CREAWTASEDASD"),e+=i.spawnIntervalTicks,this.creeps.push(a)})}),console.log(this.creeps)}end(){this.started=!1}update(t){this.started!=!1&&(this.ticks+=t,this.creeps.forEach(e=>{!e.spawned&&e.tickToSpawnAt<=this.ticks?(e.spawned=!0,this.events.emit("creepSpawned",e.creep),console.log("Wave manager creep spawned, ",e,this.ticks),!this.finished&&this.creeps.every(i=>i.spawned)&&(this.finished=!0,console.log("wave maanger finisehd"),this.events.emit("finished"))):e.spawned&&e.creep.update(t)}))}}var ha=(s=>(s.BasicTowerBehaviour="BasicTowerBehaviour",s))(ha||{});class Jc{constructor(){w(this,"isPlacingTower",!1);w(this,"canPlaceTowers",!0);w(this,"selectedTower",null);w(this,"towers",[]);C.TowerManager=this}ToggleChoosingTowerLocation(t){this.canPlaceTowers&&(C.Grid.toggleGrid(),this.isPlacingTower?this.selectedTower=null:H.Towers.forEach(e=>{e.name==t&&(this.selectedTower=e)}),this.isPlacingTower=!this.isPlacingTower)}PlayerClickOnGrid(t,e){if(this.canPlaceTowers&&this.isPlacingTower){if(!this.selectedTower)throw console.warn("TowerManager.selectedTower is null when trying to place tower.");this.PlaceTower(this.selectedTower,t,e,this.selectedTower.behaviour)}}GetTowerByRowAndCol(t,e){let i=null;return this.towers.forEach(r=>{r.row==t&&r.column==e&&(i=r)}),i}PlaceTower(t,e,i,r,n){let a=0;H.Towers.forEach((h,c)=>{h.sprite==t.sprite&&(a=c)});const o=H.TowerSprites[a];if(!C.GameScene.MissionStats.hasEnoughGold(t.stats.cost)&&!n)return console.warn("Does not have enough gold.");if(!this.GetTowerByRowAndCol(e,i)&&C.Grid.getCellByRowAndCol(e,i).type!=Ut.Path&&C.Grid.getCellByRowAndCol(e,i).type!=Ut.Restricted){C.GameScene.MissionStats.spendGold(t.stats.cost);let h=new iu(e,i,o,t,r);this.towers.push(h),this.ToggleChoosingTowerLocation("RESET"),console.log("SHOULDVE PLACED TOWER"),console.log(this.selectedTower),this.selectedTower=null,C.GameScene.events.emit(yi.TowerPlacedEvent,t.name)}else console.warn("Can not place tower on occupied spot or path. Try again.")}update(t){this.towers.forEach(e=>{e.update(t)})}}function tu(s,t,e,i){const r=e-s,n=i-t;return Math.atan2(n,r)}class eu extends re{constructor(e,i,r,n,a){super();w(this,"deleteMe",!1);w(this,"sprite");w(this,"x");w(this,"y");w(this,"angle");w(this,"speed");w(this,"damage");w(this,"timeToLive",1);console.log("I SHOOTTED!"),this.x=e,this.y=i,this.damage=a,this.sprite=new dt({texture:r,scale:.5,rotation:n}),this.sprite.anchor.set(.5),this.container.x=this.x,this.container.y=this.y,this.container.addChild(this.sprite),C.app.stage.addChild(this.container),this.angle=n,this.speed=.9}destroy(){super.destroy(),this.deleteMe=!0}update(e){if(!this.deleteMe){if(this.x>2e3||this.x<0||this.y>2e3||this.y<0||this.timeToLive<=0)return this.destroy();C.Grid.creeps.forEach(i=>{if(!(this.timeToLive<=0)&&i.container&&this.checkCollision(i)){this.timeToLive--,this.onCollide(i);return}}),this.x+=Math.cos(this.angle)*this.speed*e,this.y+=Math.sin(this.angle)*this.speed*e,this.container.x=this.x,this.container.y=this.y}}onCollide(e){console.log("COLLIDED WITH"+e),C.GameScene.events.emit(Jt.TakenDamage,e.id,this.damage)}checkCollision(e){if(e==null)return;let i=this.copyContainerToBB(),r=e.copyContainerToBB();return i.getBounds().intersects(r.getBounds())}}function su(s,t,e,i){return Math.sqrt((e-s)*(e-s)+(i-t)*(i-t))}var yi=(s=>(s.TowerPlacedEvent="towerPlacedEvent",s))(yi||{});class iu extends re{constructor(e,i,r,n,a){super();w(this,"row");w(this,"column");w(this,"projectiles",[]);w(this,"behaviour");w(this,"definition");w(this,"sprite");w(this,"ticksUntilNextShot");w(this,"graphics",new Qt);this.row=e,this.column=i,this.behaviour=a,this.definition=n,this.ticksUntilNextShot=0;let o=C.Grid.getCellByRowAndCol(e,i);this.sprite=new dt({texture:r,height:64,width:64,zIndex:10}),this.container.addChild(this.sprite),o.container.addChild(this.container),o.clickDetector.onmouseenter=h=>{this.graphics.circle(this.column*64+32,this.row*64+32,this.definition.stats.range*64),this.graphics.fill({color:16711680,alpha:.5})},o.clickDetector.onmouseleave=h=>{this.graphics.clear()},C.app.stage.addChild(this.graphics)}GetCreepsInRange(){return C.Grid.creeps.filter(i=>{const r=i.x,n=i.y,a=this.column*64+32,o=this.row*64+32,h=this.definition.stats.range*64;return su(a,o,r,n){i.deleteMe?(this.projectiles.splice(this.projectiles.indexOf(i),1),i=null):i.update(e)}),this.behaviour==ha.BasicTowerBehaviour){this.ticksUntilNextShot>0&&this.ticksUntilNextShot--;let i=this.GetCreepsInRange();if(i.length>0){let r=i[0];this.ticksUntilNextShot==0&&(this.ticksUntilNextShot=this.definition.stats.cooldown,this.Shoot(r))}}}}class Pr extends Pe{constructor(e,i,r,n,a,o,h){if(e>3||i>2||e<0||i<0)throw"Index/row out of bounds for TowerButton.";super(!0);w(this,"frameSprite");w(this,"background");w(this,"towerName");this.towerName=h,this.container.x=e*r+5,this.container.y=i*n+5,this.background=new dt({texture:o}),this.background.width=r,this.background.height=n,this.container.addChild(this.background),this.frameSprite=new Me({texture:H.Frame02Texture,leftWidth:100,topHeight:100,rightWidth:100,bottomHeight:100,roundPixels:!0,height:n,width:r}),this.container.addChild(this.frameSprite),a.addChild(this.container),C.GameScene.events.on(yi.TowerPlacedEvent,c=>{this.frameSprite.tint=16777215}),this.container.onmouseenter=c=>{},this.container.onmouseleave=c=>{}}onClick(e){this.frameSprite.tint==65280?this.frameSprite.tint=16777215:this.frameSprite.tint=65280,C.TowerManager.ToggleChoosingTowerLocation(this.towerName)}}class ru extends Pe{constructor(e){super(!1);w(this,"bounds");w(this,"towerTabSprite");w(this,"towerList",[]);this.bounds=e,H.Towers.forEach(i=>{let r={name:i.name,description:i.description,cost:i.stats.cost};this.towerList.push(r)}),this.container.x=this.bounds.x,this.container.y=this.bounds.y,this.towerTabSprite=new Me({texture:H.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),new Pr(0,0,70,70,this.container,H.RedBackground,"Basic Tower"),new Pr(0,1,70,70,this.container,H.GreenBackground,"Basic Tower")}}class nu extends Pe{constructor(e){super(!1);w(this,"bounds");w(this,"gemTabSprite");this.bounds=e,this.container.x=this.bounds.x,this.container.y=this.bounds.y,this.gemTabSprite=new Me({texture:H.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)}}class au extends Pe{constructor(e){super(!1);w(this,"bounds");w(this,"sidebarSprite");w(this,"towerTab");w(this,"gemTab");this.bounds=e,this.container.x=this.bounds.x,this.container.y=this.bounds.y,this.sidebarSprite=new Me({texture:H.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 i=new U(60,20,this.bounds.width-65,150);this.towerTab=new ru(i),this.container.addChild(this.towerTab.container);const r=new U(60,180,this.bounds.width-65,this.bounds.height-280);this.gemTab=new nu(r),this.container.addChild(this.gemTab.container)}}class _i{constructor(){w(this,"gui",[]);w(this,"_events",new at)}destroy(){this.gui.forEach(t=>{t.destroy()})}GetGuiObject(t){return this.gui.find(e=>e==t)}GetGuiObjectByName(t){return this.gui.filter(e=>e.name==t)}get events(){return this._events}init(){}}class ou extends re{constructor(e,i){super();w(this,"hp",100);w(this,"gold",0);w(this,"goldText");w(this,"healthText");this.hp=e,this.gold=i,this.container.x=0,this.container.y=20,C.app.stage.addChild(this.container),this.healthText=new Ce({text:`${this.hp}`,style:new mt({fill:"red",fontSize:36,fontWeight:"bold",dropShadow:!0})}),this.goldText=new Ce({text:`${this.gold}`,style:new mt({fill:"gold",fontSize:36,fontWeight:"bold",dropShadow:!0})});const r=new dt(H.HealthTexture),n=new dt(H.GoldTexture);this.healthText.x=200,this.healthText.y=-15,r.x=160,r.width=36,r.height=32,r.y=-10,this.goldText.x=200,this.goldText.y=20,n.x=150,n.width=56,n.height=56,n.y=15,this.container.addChild(this.healthText),this.container.addChild(this.goldText),this.container.addChild(r),this.container.addChild(n)}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}update(){}}class la extends _i{constructor(e){super();w(this,"mission");w(this,"missionIndex");w(this,"MissionStats");w(this,"roundMode");w(this,"ticker");w(this,"changeRoundButton");w(this,"sidebar");w(this,"currentRound",0);C.GameScene=this,H.Missions.forEach((i,r)=>{i.name==e&&(this.mission=i,this.missionIndex=r)})}init(){this.ticker=new pe,this.ticker.maxFPS=60,this.ticker.minFPS=30,this.ticker.add(()=>this.update(this.ticker.elapsedMS)),this.ticker.start();const e=new U(64*30-360,0,360,C.app.canvas.height),i=new U(50,C.app.canvas.height-100,310,100);new Zc(this.mission.gameMap,this.missionIndex),new Jc,new Qc(this.mission.rounds,this.mission.gameMap.paths),C.Grid.onGridCellClicked=(r,n)=>{C.TowerManager.isPlacingTower&&C.TowerManager.PlayerClickOnGrid(r,n)},C.WaveManager.events.on(oa.CreepSpawned,r=>{C.Grid.addCreep(r),r.events.on(Jt.Escaped,()=>{this.onCreepEscaped(r)})}),this.events.on(Jt.Died,(r,n)=>{this.MissionStats.earnGold(r)}),this.sidebar=new au(e),this.changeRoundButton=new Ze(i,"Start",Te.Button01,!0),this.changeRoundButton.container.removeFromParent(),this.sidebar.container.addChild(this.changeRoundButton.container),this.changeRoundButton.onClick=()=>{console.log("clicked"),this.changeRoundButton.setEnabled(!1),this.changeRoundButton.setCaption("[X]"),this.setRoundMode(1)},this.MissionStats=new ou(100,200)}update(e){C.WaveManager.update(e),C.Grid.update(e),C.TowerManager.update(e)}onCreepEscaped(e){this.MissionStats.takeDamage(e.health)}setRoundMode(e){this.roundMode=e,this.roundMode==1?C.WaveManager.start(this.currentRound):C.WaveManager.end()}onTowerPlaced(){}}class hu extends _i{init(){H.Missions.forEach((t,e)=>{const i=new Ze(new U(C.app.canvas.width/2-150,C.app.canvas.height/5+e*80,300,60),t.name,Te.Button01);i.onClick=r=>{C.GameMaster.changeScene(new la(t.name))}})}}class lu extends _i{init(){const t={caption:"New Game",rect:new U(C.WindowWidth/2-150,C.WindowHeight/2-80,300,60),texture:Te.Button01},e={caption:"Settings",rect:new U(C.WindowWidth/2-300/2,C.WindowHeight/2+20,300,60),texture:Te.Button01},i=new Ze(t.rect,t.caption,t.texture,!0);i.onClick=r=>{C.GameMaster.changeScene(new hu)},new Ze(e.rect,e.caption,e.texture,!0)}}function Fs(s){console.log(s)}(async()=>{const s=new An;C.app=s,Fs("main - init()"),await s.init({width:1920,height:1080,resolution:1,autoDensity:!0,backgroundColor:16777215,sharedTicker:!0}),Fs("main - init() complete"),document.body.appendChild(s.canvas);function t(){const i=window.innerWidth,r=window.innerHeight;C.WindowHeight=r,C.WindowWidth=i;const n=i/s.screen.width,a=r/s.screen.height,o=Math.min(n,a),h=Math.round(s.screen.width*o),c=Math.round(s.screen.height*o);Fs(`main - resize(); window: ${window.innerWidth}x${window.innerHeight}}; game ${h}x${c}`);const l=(i-h)/2,u=(r-c)/2;s.canvas.style.width=`${h}px`,s.canvas.style.height=`${c}px`,s.canvas.style.marginLeft=`${l}px`,s.canvas.style.marginTop=`${u}px`,s.canvas.style.marginRight="0",s.canvas.style.marginBottom="0",s.canvas.style.display="block"}window.addEventListener("resize",t),t(),await H.LoadAssets(),new jc,globalThis.Globals=C,C.GameMaster.changeScene(new lu),new URLSearchParams(location.href).entries().next().value[1]=="game"&&C.GameMaster.changeScene(new la("Mission 1"))})();export{W as $,_n as A,Z as B,rt as C,j as D,P as E,Dr as F,ts as G,bt as H,Di as I,dt as J,Co as K,Ro as L,D as M,tt as N,U as O,it as P,Qo as Q,Ns as R,yh as S,Ct as T,Ds as U,zi as V,io as W,gs as X,Q as Y,zr as Z,bn as _,G as a,O as a0,ih as a1,Bn as a2,Hh as a3,Vh as a4,qh as a5,Zh as a6,Qh as a7,Kt as a8,mt as a9,Hl as aa,ei as ab,Wn as ac,Zi as ad,Vt as ae,Vc as af,wr as ag,jl as ah,Qt as ai,$ as aj,Ba as ak,ti as al,_r as am,Dn as an,pe as b,at as c,Pt as d,nt as e,Ki as f,gh as g,$e as h,ai as i,mn as j,Zr as k,dn as l,yr as m,Mi as n,zh as o,Nh as p,Yh as q,Na as r,Tn as s,Kh as t,oi as u,hn as v,J as w,Ea as x,tl as y,At as z}; +`;let qt=null;class qn{constructor(){qt||(qt=URL.createObjectURL(new Blob([Fc],{type:"application/javascript"}))),this.worker=new Worker(qt)}}qn.revokeObjectURL=function(){qt&&(URL.revokeObjectURL(qt),qt=null)};let Cr=0,Is;class Rc{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 si;e.addEventListener("message",i=>{e.terminate(),si.revokeObjectURL(),t(i.data)})}),this._isImageBitmapSupported)}loadImageBitmap(t,e){var i;return this._run("loadImageBitmap",[t,(i=e==null?void 0:e.data)==null?void 0:i.alphaMode])}async _initWorkers(){this._initialized||(this._initialized=!0)}_getWorker(){Is===void 0&&(Is=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 i=new Promise((r,n)=>{this._queue.push({id:t,arguments:e,resolve:r,reject:n})});return this._next(),i}_next(){if(!this._queue.length)return;const t=this._getWorker();if(!t)return;const e=this._queue.pop(),i=e.id;this._resolveHash[Cr]={resolve:e.resolve,reject:e.reject},t.postMessage({data:e.arguments,uuid:Cr++,id:i})}}const Tr=new Rc,Lc=[".jpeg",".jpg",".png",".webp",".avif"],Gc=["image/jpeg","image/png","image/webp","image/avif"];async function Wc(s,t){var r;const e=await j.get().fetch(s);if(!e.ok)throw new Error(`[loadImageBitmap] Failed to fetch ${s}: ${e.status} ${e.statusText}`);const i=await e.blob();return((r=t==null?void 0:t.data)==null?void 0:r.alphaMode)==="premultiplied-alpha"?createImageBitmap(i,{premultiplyAlpha:"none"}):createImageBitmap(i)}const Kn={name:"loadTextures",extension:{type:P.LoadParser,priority:kt.High,name:"loadTextures"},config:{preferWorkers:!0,preferCreateImageBitmap:!0,crossOrigin:"anonymous"},test(s){return re(s,Gc)||ne(s,Lc)},async load(s,t,e){var n;let i=null;globalThis.createImageBitmap&&this.config.preferCreateImageBitmap?this.config.preferWorkers&&await Tr.isImageBitmapSupported()?i=await Tr.loadImageBitmap(s,t):i=await Wc(s,t):i=await new Promise(a=>{i=new Image,i.crossOrigin=this.config.crossOrigin,i.src=s,i.complete?a(i):i.onload=()=>{a(i)}});const r=new se({resource:i,alphaMode:"premultiply-alpha-on-upload",resolution:((n=t.data)==null?void 0:n.resolution)||mi(s),...t.data});return xi(r,e,s)},unload(s){s.destroy(!0)}},Zn=[".mp4",".m4v",".webm",".ogg",".ogv",".h264",".avi",".mov"],Oc=Zn.map(s=>`video/${s.substring(1)}`);function Dc(s,t,e){e===void 0&&!t.startsWith("data:")?s.crossOrigin=zc(t):e!==!1&&(s.crossOrigin=typeof e=="string"?e:"anonymous")}function Uc(s){return new Promise((t,e)=>{s.addEventListener("canplaythrough",i),s.addEventListener("error",r),s.load();function i(){n(),t()}function r(a){n(),e(a)}function n(){s.removeEventListener("canplaythrough",i),s.removeEventListener("error",r)}})}function zc(s,t=globalThis.location){if(s.startsWith("data:"))return"";t=t||globalThis.location;const e=new URL(s,document.baseURI);return e.hostname!==t.hostname||e.port!==t.port||e.protocol!==t.protocol?"anonymous":""}const Hc={name:"loadVideo",extension:{type:P.LoadParser,name:"loadVideo"},test(s){const t=re(s,Oc),e=ne(s,Zn);return t||e},async load(s,t,e){var h,c;const i={...$e.defaultOptions,resolution:((h=t.data)==null?void 0:h.resolution)||mi(s),alphaMode:((c=t.data)==null?void 0:c.alphaMode)||await Jr(),...t.data},r=document.createElement("video"),n={preload:i.autoLoad!==!1?"auto":void 0,"webkit-playsinline":i.playsinline!==!1?"":void 0,playsinline:i.playsinline!==!1?"":void 0,muted:i.muted===!0?"":void 0,loop:i.loop===!0?"":void 0,autoplay:i.autoPlay!==!1?"":void 0};Object.keys(n).forEach(l=>{const u=n[l];u!==void 0&&r.setAttribute(l,u)}),i.muted===!0&&(r.muted=!0),Dc(r,s,i.crossorigin);const a=document.createElement("source");let o;if(s.startsWith("data:"))o=s.slice(5,s.indexOf(";"));else if(!s.startsWith("blob:")){const l=s.split("?")[0].slice(s.lastIndexOf(".")+1).toLowerCase();o=$e.MIME_TYPES[l]||`video/${l}`}return a.src=s,o&&(a.type=o),new Promise(l=>{const u=async()=>{const d=new $e({...i,resource:r});r.removeEventListener("canplay",u),t.data.preload&&await Uc(r),l(xi(d,e,s))};r.addEventListener("canplay",u),r.appendChild(a)})},unload(s){s.destroy(!0)}},Qn={extension:{type:P.ResolveParser,name:"resolveTexture"},test:Kn.test,parse:s=>{var t;return{resolution:parseFloat(((t=ie.RETINA_PREFIX.exec(s))==null?void 0:t[1])??"1"),format:s.split(".").pop(),src:s}}},Nc={extension:{type:P.ResolveParser,priority:-2,name:"resolveJson"},test:s=>ie.RETINA_PREFIX.test(s)&&s.endsWith(".json"),parse:Qn.parse};class Vc{constructor(){this._detections=[],this._initialized=!1,this.resolver=new ie,this.loader=new dc,this.cache=$,this._backgroundLoader=new ic(this.loader),this._backgroundLoader.active=!0,this.reset()}async init(t={}){var n,a;if(this._initialized){J("[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=((n=t.texturePreference)==null?void 0:n.resolution)??1,i=typeof e=="number"?[e]:e,r=await this._detectFormats({preferredFormats:(a=t.texturePreference)==null?void 0:a.format,skipDetections:t.skipDetections,detections:this._detections});this.resolver.prefer({params:{format:r,resolution:i}}),t.preferences&&this.setPreferences(t.preferences)}add(t){this.resolver.add(t)}async load(t,e){this._initialized||await this.init();const i=Ke(t),r=gt(t).map(o=>{if(typeof o!="string"){const h=this.resolver.getAlias(o);return h.some(c=>!this.resolver.hasKey(c))&&this.add(o),Array.isArray(h)?h[0]:h}return this.resolver.hasKey(o)||this.add({alias:o,src:o}),o}),n=this.resolver.resolve(r),a=await this._mapLoadToResolve(n,e);return i?a[r[0]]:a}addBundle(t,e){this.resolver.addBundle(t,e)}async loadBundle(t,e){this._initialized||await this.init();let i=!1;typeof t=="string"&&(i=!0,t=[t]);const r=this.resolver.resolveBundle(t),n={},a=Object.keys(r);let o=0,h=0;const c=()=>{e==null||e(++o/h)},l=a.map(u=>{const d=r[u];return h+=Object.keys(d).length,this._mapLoadToResolve(d,c).then(f=>{n[u]=f})});return await Promise.all(l),i?n[t[0]]:n}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(i=>{this._backgroundLoader.add(Object.values(i))})}reset(){this.resolver.reset(),this.loader.reset(),this.cache.reset(),this._initialized=!1}get(t){if(typeof t=="string")return $.get(t);const e={};for(let i=0;i{const o=r[a.src],h=[a.src];a.alias&&h.push(...a.alias),h.forEach(c=>{n[c]=o}),$.set(h,o)}),n}async unload(t){this._initialized||await this.init();const e=gt(t).map(r=>typeof r!="string"?r.src:r),i=this.resolver.resolve(e);await this._unloadFromResolved(i)}async unloadBundle(t){this._initialized||await this.init(),t=gt(t);const e=this.resolver.resolveBundle(t),i=Object.keys(e).map(r=>this._unloadFromResolved(e[r]));await Promise.all(i)}async _unloadFromResolved(t){const e=Object.values(t);e.forEach(i=>{$.remove(i.src)}),await this.loader.unload(e)}async _detectFormats(t){let e=[];t.preferredFormats&&(e=Array.isArray(t.preferredFormats)?t.preferredFormats:[t.preferredFormats]);for(const i of t.detections)t.skipDetections||await i.test()?e=await i.add(e):t.skipDetections||(e=await i.remove(e));return e=e.filter((i,r)=>e.indexOf(i)===r),e}get detections(){return this._detections}setPreferences(t){this.loader.parsers.forEach(e=>{e.config&&Object.keys(e.config).filter(i=>i in t).forEach(i=>{e.config[i]=t[i]})})}}const q=new Vc;nt.handleByList(P.LoadParser,q.loader.parsers).handleByList(P.ResolveParser,q.resolver.parsers).handleByList(P.CacheParser,q.cache.parsers).handleByList(P.DetectionParser,q.detections);nt.add(rc,ac,nc,uc,hc,lc,cc,gc,yc,Tc,kc,Kn,Hc,sc,ec,Qn,Nc);const Mr={loader:P.LoadParser,resolver:P.ResolveParser,cache:P.CacheParser,detection:P.DetectionParser};nt.handle(P.Asset,s=>{const t=s.ref;Object.entries(Mr).filter(([e])=>!!t[e]).forEach(([e,i])=>nt.add(Object.assign(t[e],{extension:t[e].extension??i})))},s=>{const t=s.ref;Object.keys(Mr).filter(e=>!!t[e]).forEach(e=>nt.remove(t[e]))});class Jt extends Qe{constructor(t){t instanceof ct&&(t={context:t});const{context:e,roundPixels:i,...r}=t||{};super({label:"Graphics",...r}),this.renderPipeId="graphics",e?this._context=e:this._context=this._ownedContext=new ct,this._context.on("update",this.onViewUpdate,this),this.allowChildren=!1,this.roundPixels=i??!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 Jt(this._context.clone()):(this._ownedContext=null,new Jt(this._context))}lineStyle(t,e,i){W(O,"Graphics#lineStyle is no longer needed. Use Graphics#setStrokeStyle to set the stroke style.");const r={};return t&&(r.width=t),e&&(r.color=e),i&&(r.alpha=i),this.context.strokeStyle=r,this}beginFill(t,e){W(O,"Graphics#beginFill is no longer needed. Use Graphics#fill to fill the shape with the desired style.");const i={};return t&&(i.color=t),e&&(i.alpha=e),this.context.fillStyle=i,this}endFill(){W(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!==ct.defaultStrokeStyle.width||t.color!==ct.defaultStrokeStyle.color||t.alpha!==ct.defaultStrokeStyle.alpha)&&this.context.stroke(),this}drawCircle(...t){return W(O,"Graphics#drawCircle has been renamed to Graphics#circle"),this._callContextMethod("circle",t)}drawEllipse(...t){return W(O,"Graphics#drawEllipse has been renamed to Graphics#ellipse"),this._callContextMethod("ellipse",t)}drawPolygon(...t){return W(O,"Graphics#drawPolygon has been renamed to Graphics#poly"),this._callContextMethod("poly",t)}drawRect(...t){return W(O,"Graphics#drawRect has been renamed to Graphics#rect"),this._callContextMethod("rect",t)}drawRoundedRect(...t){return W(O,"Graphics#drawRoundedRect has been renamed to Graphics#roundRect"),this._callContextMethod("roundRect",t)}drawStar(...t){return W(O,"Graphics#drawStar has been renamed to Graphics#star"),this._callContextMethod("star",t)}}const Jn=class ta extends Bn{constructor(...t){let e=t[0]??{};e instanceof Float32Array&&(W(O,"use new MeshGeometry({ positions, uvs, indices }) instead"),e={positions:e,uvs:t[1],indices:t[2]}),e={...ta.defaultOptions,...e};const i=e.positions||new Float32Array([0,0,1,0,1,1,0,1]),r=e.uvs||new Float32Array([0,0,1,0,1,1,0,1]),n=e.indices||new Uint32Array([0,1,2,0,2,3]),a=e.shrinkBuffersToFit,o=new Pt({data:i,label:"attribute-mesh-positions",shrinkToFit:a,usage:Z.VERTEX|Z.COPY_DST}),h=new Pt({data:r,label:"attribute-mesh-uvs",shrinkToFit:a,usage:Z.VERTEX|Z.COPY_DST}),c=new Pt({data:n,label:"index-mesh-buffer",shrinkToFit:a,usage:Z.INDEX|Z.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:c,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}};Jn.defaultOptions={topology:"triangle-list",shrinkBuffersToFit:!1};let $c=Jn;class Xc extends Qe{constructor(t,e){const{text:i,resolution:r,style:n,anchor:a,width:o,height:h,roundPixels:c,...l}=t;super({...l}),this.batched=!0,this._resolution=null,this._autoResolution=!0,this._didTextUpdate=!0,this._styleClass=e,this.text=i??"",this.style=n,this.resolution=r??null,this.allowChildren=!1,this._anchor=new ot({_onUpdate:()=>{this.onViewUpdate()}}),a&&(this.anchor=a),this.roundPixels=c??!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,i=this.bounds.height,r=-e*this.anchor.x;let n=0;return t.x>=r&&t.x<=r+e&&(n=-i*this.anchor.y,t.y>=n&&t.y<=n+i)}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 Yc(s,t){let e=s[0]??{};return(typeof e=="string"||s[1])&&(W(O,`use new ${t}({ text: "hi!", style }) instead`),e={text:e,style:s[1]}),e}class Ht extends Xc{constructor(...t){const e=Yc(t,"Text");super(e,mt),this.renderPipeId="text"}_updateBounds(){const t=this._bounds,e=this._anchor,i=ei.measureText(this._text,this._style),{width:r,height:n}=i;t.minX=-e._x*r,t.maxX=t.minX+r,t.minY=-e._y*n,t.maxY=t.minY+n}}const ea=class sa extends $c{constructor(...t){super({});let e=t[0]??{};typeof e=="number"&&(W(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={...sa.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,i=[],r=[],n=[],a=this.verticesX-1,o=this.verticesY-1,h=this.width/a,c=this.height/o;for(let u=0;ue?1:this.width/e,r=this._topHeight+this._bottomHeight,n=this.height>r?1:this.height/r,a=Math.min(i,n);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,i=1/this._originalHeight;t[2]=t[10]=t[18]=t[26]=e*this._leftWidth,t[9]=t[11]=t[13]=t[15]=i*this._topHeight,t[4]=t[12]=t[20]=t[28]=1-e*this._rightWidth,t[17]=t[19]=t[21]=t[23]=1-i*this._bottomHeight,this.getBuffer("aUV").update()}};ia.defaultOptions={width:100,height:100,leftWidth:10,topHeight:10,rightWidth:10,bottomHeight:10,originalWidth:100,originalHeight:100};let $t=ia;const na=class aa extends Qe{constructor(t){var u,d,f,p;t instanceof G&&(t={texture:t});const{width:e,height:i,leftWidth:r,rightWidth:n,topHeight:a,bottomHeight:o,texture:h,roundPixels:c,...l}=t;super({label:"NineSliceSprite",...l}),this.renderPipeId="nineSliceSprite",this.batched=!0,this._didSpriteUpdate=!0,this._leftWidth=r??((u=h==null?void 0:h.defaultBorders)==null?void 0:u.left)??$t.defaultOptions.leftWidth,this._topHeight=a??((d=h==null?void 0:h.defaultBorders)==null?void 0:d.top)??$t.defaultOptions.topHeight,this._rightWidth=n??((f=h==null?void 0:h.defaultBorders)==null?void 0:f.right)??$t.defaultOptions.rightWidth,this._bottomHeight=o??((p=h==null?void 0:h.defaultBorders)==null?void 0:p.bottom)??$t.defaultOptions.bottomHeight,this.bounds.maxX=this._width=e??h.width??$t.defaultOptions.width,this.bounds.maxY=this._height=i??h.height??$t.defaultOptions.height,this.allowChildren=!1,this.texture=h??aa.defaultOptions.texture,this.roundPixels=c??!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=G.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 i=typeof t=="boolean"?t:t==null?void 0:t.textureSource;this._texture.destroy(i)}this._texture=null}};na.defaultOptions={texture:G.EMPTY};let Pe=na;nt.add(ya,_a);class S{}w(S,"app"),w(S,"GameMaster"),w(S,"WindowHeight"),w(S,"WindowWidth"),w(S,"AspectRatio",16/9),w(S,"Grid"),w(S,"WaveManager"),w(S,"TowerManager"),w(S,"GameScene"),w(S,"latestCommit");class qc{constructor(){w(this,"currentScene");w(this,"gameScene");w(this,"GameObjects",[]);S.GameMaster=this}_CreateGuiObject(t){this.currentScene.gui.push(t),S.app.stage.addChild(t.container)}_RemoveGuiObject(t){this.currentScene.gui.splice(this.currentScene.gui.indexOf(t),1),S.app.stage.removeChild(t.container)}changeScene(t){this.currentScene&&this.currentScene.destroy(),this.GameObjects.forEach(e=>{e.destroy()}),this.currentScene=t,this.currentScene.init()}}const L=class L{static async LoadAssets(){console.log("Loading Texture Assets");const t=new Ht({text:"Loading textures. This might take a while.",style:new mt({fill:3355443,fontSize:50})});t.x=S.app.canvas.width/2,t.y=S.app.canvas.height/2,t.anchor.set(.5,.5),S.app.stage.addChild(t),L.Button01Texture=await q.load({src:"/assets/gui/button_01.png"}),L.Button02Texture=await q.load({src:"/assets/gui/button_02.png"}),L.Frame01Texture=await q.load({src:"/assets/gui/frame_01.png"}),L.Frame02Texture=await q.load({src:"/assets/gui/frame_02.png"}),L.FrameBackground=await q.load({src:"/assets/gui/background_01.png"}),L.FrameTowerTab=await q.load({src:"/assets/gui/background_02.png"}),L.VioletBackground=await q.load({src:"/assets/gui/frame_violet.png"}),L.RedBackground=await q.load({src:"/assets/gui/frame_red.png"}),L.GreenBackground=await q.load({src:"/assets/gui/frame_green.png"}),L.HealthTexture=await q.load({src:"/assets/gui/heart.png"}),L.GoldTexture=await q.load({src:"/assets/gui/money.png"}),L.BasicCreepTexture=await q.load({src:"/assets/creeps/basic.jpg"}),L.BasicTowerTexture=await q.load({src:"/assets/towers/basic_tower.png"}),L.BasicProjectileTexture=await q.load({src:"/assets/projectiles/basic_tower.png"}),await q.load({src:"https://fonts.googleapis.com/css?family=Aclonica"}),await this.LoadMissions(),await this.LoadTowers(),await this.LoadCreepStats(),t.destroy()}static async LoadCreepStats(){const e=await(await fetch("/assets/CreepStats.json")).json();this.CreepStats=e}static async LoadMissions(){L.Missions=[await this.LoadMission("/assets/missions/mission_01.json")]}static async LoadTowers(){const e=await(await fetch("/assets/Towers.json")).json();L.Towers=e,e.forEach(async i=>{let r=this.TowerSprites.length-1;r==-1&&(r=0),this.TowerSprites[r]=await q.load({src:`/assets/towers/${i.sprite}.png`})})}static async LoadMission(t){const i=await(await fetch(t)).json();return await this.LoadBackground(i.mapImage.url),i}static async LoadBackground(t){let e=this.MissionBackgrounds.length-1;e==-1&&(e=0),this.MissionBackgrounds[e]=await q.load({src:t})}};w(L,"BasicCreepTexture"),w(L,"BasicTowerTexture"),w(L,"BasicProjectileTexture"),w(L,"Frame01Texture"),w(L,"Frame02Texture"),w(L,"FrameBackground"),w(L,"FrameTowerTab"),w(L,"VioletBackground"),w(L,"RedBackground"),w(L,"GreenBackground"),w(L,"Button01Texture"),w(L,"Button02Texture"),w(L,"HealthTexture"),w(L,"GoldTexture"),w(L,"MissionBackgrounds",[]),w(L,"TowerSprites",[]),w(L,"Missions"),w(L,"Towers"),w(L,"CreepStats"),w(L,"DebuggingEnabled",!1);let H=L;class ke{constructor(t){w(this,"name",this.constructor.name);w(this,"_container",new rt);w(this,"_events",new at);w(this,"enabled",!0);S.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}}var te=(s=>(s[s.Button01=0]="Button01",s[s.Button02=1]="Button02",s))(te||{});class Me extends ke{constructor(e,i,r,n=!0){super(!0);w(this,"caption");w(this,"bounds");w(this,"buttonTexture");w(this,"buttonSprite");w(this,"buttonText");r==0&&(this.buttonTexture=H.Button01Texture),r==1&&(this.buttonTexture=H.Button02Texture),this.caption=i,this.enabled=n,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 Pe({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 Ht({text:this.caption,style:new mt({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}}class ae{constructor(){w(this,"name",this.constructor.name);w(this,"_container",new rt);w(this,"bb",new U);w(this,"_events",new at)}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.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}}var ee=(s=>(s.Died="died",s.TakenDamage="takenDamage",s.Escaped="escaped",s.Moved="moved",s))(ee||{});class Kc extends ae{constructor(e,i,r){super();w(this,"id");w(this,"creepType");w(this,"sprite");w(this,"path");w(this,"stats");w(this,"pathIndex",0);w(this,"speed");w(this,"health");w(this,"maxHealth");w(this,"escaped",!1);w(this,"died",!1);w(this,"x");w(this,"y");w(this,"dead",!1);this.creepType=e,this.stats=structuredClone(H.CreepStats[this.creepType]),this.sprite=new dt({texture:H.BasicCreepTexture}),this.id=r,this.container.x=-70,this.container.y=-50,this.sprite.width=64,this.sprite.height=64,this.speed=this.stats.speed,this.health=this.stats.health,this.maxHealth=this.stats.health,this.path=i,this.x=i[0][1]*64+32,this.y=i[0][0]*64+32,S.GameScene.events.on("takenDamage",(n,a)=>{n==this.id&&(this.health-=a)}),S.Grid.container.addChild(this.container),this.container.addChild(this.sprite)}update(e){if(this.dead)return;if(this.health<=0){S.GameScene.events.emit("died",this.maxHealth,this),this.destroy(),this.dead=!0;return}if(this.pathIndex+1==this.path.length){if(this.escaped)return;this.events.emit("escaped",this),this.escaped=!0;return}const i=this.path[this.pathIndex],r=this.path[this.pathIndex+1],n=r[1]*64+32,a=r[0]*64+32,o=r[1]-i[1],h=r[0]-i[0];let c=this.speed*e*o,l=this.speed*e*h,u=!1;c>0&&this.x+c>n&&(c=n-this.x,u=!0),c<0&&this.x+c0&&this.y+l>a&&(l=a-this.y,u=!0),l<0&&this.y+l(s[s.Restricted=0]="Restricted",s[s.Buildable=1]="Buildable",s[s.Path=9]="Path",s))(Ut||{});class Zc extends ae{constructor(e,i,r,n){super();w(this,"type");w(this,"row");w(this,"column");w(this,"isPath",!1);w(this,"g");w(this,"clickDetector");if(this.type=e,this.row=i,this.column=r,this.isPath=n,this.bb.x=this.column*64,this.bb.y=this.row*64,this.bb.width=64,this.bb.height=64,S.Grid.container.addChild(this.container),this.container.x=this.bb.x,this.container.y=this.bb.y,this.clickDetector=new Jt({zIndex:99,interactive:!0}),this.clickDetector.rect(0,0,this.bb.width,this.bb.height),this.clickDetector.fill({color:16711680,alpha:0}),this.container.addChild(this.clickDetector),this.clickDetector.onclick=o=>{S.Grid._gridCellClicked(i,r)},!H.DebuggingEnabled)return;const a=new Ht({text:`${this.row}|${this.column}`,style:new mt({fill:16777215,dropShadow:!0,fontSize:16})});this.container.addChild(a),a.anchor.set(.5,.5),a.x=this.bb.width/2,a.y=this.bb.height/2,n&&(a.text+="p")}gDraw(){switch(this.g=new Jt({zIndex:5}),this.g.rect(0,0,this.bb.width,this.bb.height),this.type){case Ut.Restricted:this.g.fill({color:2236962,alpha:.5});break;case Ut.Path:this.g.fill({color:2236962,alpha:.5});break;case Ut.Buildable:this.g.stroke({color:65280,alpha:.9});break}this.container.addChild(this.g)}gClear(){this.g!=null&&(this.container.removeChild(this.g),this.g.destroy())}update(){}}class Qc extends ae{constructor(e,i){super();w(this,"gameMap");w(this,"cells",[]);w(this,"creeps",[]);w(this,"gridShown",!1);this.gameMap=e,S.Grid=this,this.bb.x=0,this.bb.y=0,this.bb.width=64*30,this.bb.height=64*17,S.app.stage.addChild(this.container);let r=new dt(H.MissionBackgrounds[i]);r.x=0,r.y=0,r.width=this.bb.width,r.height=this.bb.height,this.container.addChild(r);for(let n=0;nl.some(u=>u[0]===a&&u[1]===n));h&&(o=Ut.Path);let c=new Zc(o,a,n,h);this.cells.push(c)}}toggleGrid(){this.cells.forEach(e=>{this.gridShown?e.gClear():e.gDraw()}),this.gridShown=!this.gridShown}addCreep(e){console.log("ADD CREEP"),this.creeps.push(e),e.events.on(ee.Died,i=>{this.onCreepDiedOrEscaped(i)}),e.events.on(ee.Escaped,i=>{this.onCreepDiedOrEscaped(i)})}onCreepDiedOrEscaped(e){this.creeps.splice(this.creeps.indexOf(e),1),e.destroy()}update(e){this.creeps.forEach(i=>{i.dead?(this.creeps.splice(this.creeps.indexOf(i),1),i=null):i.update(e)})}getCellByRowAndCol(e,i){return this.cells.filter(r=>r.row==e&&r.column==i)[0]}_gridCellClicked(e,i){this.onGridCellClicked(e,i)}onGridCellClicked(e,i){}}var oa=(s=>(s.CreepSpawned="creepSpawned",s.Finished="finished",s))(oa||{});class Jc{constructor(t,e){w(this,"creeps",[]);w(this,"rounds");w(this,"paths");w(this,"ticks",0);w(this,"started",!1);w(this,"finished",!1);w(this,"events",new at);w(this,"internalCreepId",0);S.WaveManager=this,this.rounds=t,this.paths=e}start(t){this.started=!0,this.ticks=0,this.creeps=[],this.finished=!1;let e=0;this.rounds[t].waves.forEach(i=>{e+=i.firstCreepSpawnTick,i.creeps.forEach(r=>{const n=new Kc(r,this.paths[0],this.internalCreepId);this.internalCreepId++;const a={creep:n,tickToSpawnAt:e,spawned:!1};console.log("CREAWTASEDASD"),e+=i.spawnIntervalTicks,this.creeps.push(a)})}),console.log(this.creeps)}end(){this.started=!1}update(t){this.started!=!1&&(this.ticks+=t,this.creeps.forEach(e=>{!e.spawned&&e.tickToSpawnAt<=this.ticks?(e.spawned=!0,this.events.emit("creepSpawned",e.creep),console.log("Wave manager creep spawned, ",e,this.ticks),!this.finished&&this.creeps.every(i=>i.spawned)&&(this.finished=!0,console.log("wave maanger finisehd"),this.events.emit("finished"))):e.spawned&&e.creep.update(t)}))}}var ha=(s=>(s.BasicTowerBehaviour="BasicTowerBehaviour",s))(ha||{});class tu{constructor(){w(this,"isPlacingTower",!1);w(this,"canPlaceTowers",!0);w(this,"selectedTower",null);w(this,"towers",[]);S.TowerManager=this}ToggleChoosingTowerLocation(t){this.canPlaceTowers&&(S.Grid.toggleGrid(),this.isPlacingTower?this.selectedTower=null:H.Towers.forEach(e=>{e.name==t&&(this.selectedTower=e)}),this.isPlacingTower=!this.isPlacingTower)}PlayerClickOnGrid(t,e){if(this.canPlaceTowers&&this.isPlacingTower){if(!this.selectedTower)throw console.warn("TowerManager.selectedTower is null when trying to place tower.");this.PlaceTower(this.selectedTower,t,e,this.selectedTower.behaviour)}}GetTowerByRowAndCol(t,e){let i=null;return this.towers.forEach(r=>{r.row==t&&r.column==e&&(i=r)}),i}PlaceTower(t,e,i,r,n){let a=0;H.Towers.forEach((h,c)=>{h.sprite==t.sprite&&(a=c)});const o=H.TowerSprites[a];if(!S.GameScene.MissionStats.hasEnoughGold(t.stats.cost)&&!n)return console.warn("Does not have enough gold.");if(!this.GetTowerByRowAndCol(e,i)&&S.Grid.getCellByRowAndCol(e,i).type!=Ut.Path&&S.Grid.getCellByRowAndCol(e,i).type!=Ut.Restricted){S.GameScene.MissionStats.spendGold(t.stats.cost);let h=new ru(e,i,o,t,r);this.towers.push(h),this.ToggleChoosingTowerLocation("RESET"),console.log("SHOULDVE PLACED TOWER"),console.log(this.selectedTower),this.selectedTower=null,S.GameScene.events.emit(yi.TowerPlacedEvent,t.name)}else console.warn("Can not place tower on occupied spot or path. Try again.")}update(t){this.towers.forEach(e=>{e.update(t)})}}function eu(s,t,e,i){const r=e-s,n=i-t;return Math.atan2(n,r)}class su extends ae{constructor(e,i,r,n,a){super();w(this,"deleteMe",!1);w(this,"sprite");w(this,"x");w(this,"y");w(this,"angle");w(this,"speed");w(this,"damage");w(this,"timeToLive",1);console.log("I SHOOTTED!"),this.x=e,this.y=i,this.damage=a,this.sprite=new dt({texture:r,scale:.5,rotation:n}),this.sprite.anchor.set(.5),this.container.x=this.x,this.container.y=this.y,this.container.addChild(this.sprite),S.app.stage.addChild(this.container),this.angle=n,this.speed=.9}destroy(){super.destroy(),this.deleteMe=!0}update(e){if(!this.deleteMe){if(this.x>2e3||this.x<0||this.y>2e3||this.y<0||this.timeToLive<=0)return this.destroy();S.Grid.creeps.forEach(i=>{if(!(this.timeToLive<=0)&&i.container&&this.checkCollision(i)){this.timeToLive--,this.onCollide(i);return}}),this.x+=Math.cos(this.angle)*this.speed*e,this.y+=Math.sin(this.angle)*this.speed*e,this.container.x=this.x,this.container.y=this.y}}onCollide(e){console.log("COLLIDED WITH"+e),S.GameScene.events.emit(ee.TakenDamage,e.id,this.damage)}checkCollision(e){if(e==null)return;let i=this.copyContainerToBB(),r=e.copyContainerToBB();return i.getBounds().intersects(r.getBounds())}}function iu(s,t,e,i){return Math.sqrt((e-s)*(e-s)+(i-t)*(i-t))}var yi=(s=>(s.TowerPlacedEvent="towerPlacedEvent",s))(yi||{});class ru extends ae{constructor(e,i,r,n,a){super();w(this,"row");w(this,"column");w(this,"projectiles",[]);w(this,"behaviour");w(this,"definition");w(this,"sprite");w(this,"ticksUntilNextShot");w(this,"graphics",new Jt);this.row=e,this.column=i,this.behaviour=a,this.definition=n,this.ticksUntilNextShot=0;let o=S.Grid.getCellByRowAndCol(e,i);this.sprite=new dt({texture:r,height:64,width:64,zIndex:10}),this.container.addChild(this.sprite),o.container.addChild(this.container),o.clickDetector.onmouseenter=h=>{this.graphics.circle(this.column*64+32,this.row*64+32,this.definition.stats.range*64),this.graphics.fill({color:16711680,alpha:.5})},o.clickDetector.onmouseleave=h=>{this.graphics.clear()},S.app.stage.addChild(this.graphics)}GetCreepsInRange(){return S.Grid.creeps.filter(i=>{const r=i.x,n=i.y,a=this.column*64+32,o=this.row*64+32,h=this.definition.stats.range*64;return iu(a,o,r,n){i.deleteMe?(this.projectiles.splice(this.projectiles.indexOf(i),1),i=null):i.update(e)}),this.behaviour==ha.BasicTowerBehaviour){this.ticksUntilNextShot>0&&this.ticksUntilNextShot--;let i=this.GetCreepsInRange();if(i.length>0){let r=i[0];this.ticksUntilNextShot==0&&(this.ticksUntilNextShot=this.definition.stats.cooldown,this.Shoot(r))}}}}class Pr extends ke{constructor(e,i,r,n,a,o,h){if(e>3||i>2||e<0||i<0)throw"Index/row out of bounds for TowerButton.";super(!0);w(this,"frameSprite");w(this,"background");w(this,"towerName");this.towerName=h,this.container.x=e*r+5,this.container.y=i*n+5,this.background=new dt({texture:o}),this.background.width=r,this.background.height=n,this.container.addChild(this.background),this.frameSprite=new Pe({texture:H.Frame02Texture,leftWidth:100,topHeight:100,rightWidth:100,bottomHeight:100,roundPixels:!0,height:n,width:r}),this.container.addChild(this.frameSprite),a.addChild(this.container),S.GameScene.events.on(yi.TowerPlacedEvent,c=>{this.frameSprite.tint=16777215}),this.container.onmouseenter=c=>{},this.container.onmouseleave=c=>{}}onClick(e){this.frameSprite.tint==65280?this.frameSprite.tint=16777215:this.frameSprite.tint=65280,S.TowerManager.ToggleChoosingTowerLocation(this.towerName)}}class nu extends ke{constructor(e){super(!1);w(this,"bounds");w(this,"towerTabSprite");w(this,"towerList",[]);this.bounds=e,H.Towers.forEach(i=>{let r={name:i.name,description:i.description,cost:i.stats.cost};this.towerList.push(r)}),this.container.x=this.bounds.x,this.container.y=this.bounds.y,this.towerTabSprite=new Pe({texture:H.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),new Pr(0,0,70,70,this.container,H.RedBackground,"Basic Tower"),new Pr(0,1,70,70,this.container,H.GreenBackground,"Basic Tower")}}class au extends ke{constructor(e){super(!1);w(this,"bounds");w(this,"gemTabSprite");this.bounds=e,this.container.x=this.bounds.x,this.container.y=this.bounds.y,this.gemTabSprite=new Pe({texture:H.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)}}class ou extends ke{constructor(e){super(!1);w(this,"bounds");w(this,"sidebarSprite");w(this,"towerTab");w(this,"gemTab");this.bounds=e,this.container.x=this.bounds.x,this.container.y=this.bounds.y,this.sidebarSprite=new Pe({texture:H.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 i=new U(60,20,this.bounds.width-65,150);this.towerTab=new nu(i),this.container.addChild(this.towerTab.container);const r=new U(60,180,this.bounds.width-65,this.bounds.height-280);this.gemTab=new au(r),this.container.addChild(this.gemTab.container)}}class _i{constructor(){w(this,"gui",[]);w(this,"_events",new at)}destroy(){this.gui.forEach(t=>{t.destroy()})}GetGuiObject(t){return this.gui.find(e=>e==t)}GetGuiObjectByName(t){return this.gui.filter(e=>e.name==t)}get events(){return this._events}init(){}}class hu extends ae{constructor(e,i){super();w(this,"hp",100);w(this,"gold",0);w(this,"goldText");w(this,"healthText");this.hp=e,this.gold=i,this.container.x=0,this.container.y=20,S.app.stage.addChild(this.container),this.healthText=new Ht({text:`${this.hp}`,style:new mt({fill:"red",fontSize:36,fontWeight:"bold",dropShadow:!0})}),this.goldText=new Ht({text:`${this.gold}`,style:new mt({fill:"gold",fontSize:36,fontWeight:"bold",dropShadow:!0})});const r=new dt(H.HealthTexture),n=new dt(H.GoldTexture);this.healthText.x=200,this.healthText.y=-15,r.x=160,r.width=36,r.height=32,r.y=-10,this.goldText.x=200,this.goldText.y=20,n.x=150,n.width=56,n.height=56,n.y=15,this.container.addChild(this.healthText),this.container.addChild(this.goldText),this.container.addChild(r),this.container.addChild(n)}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}update(){}}class la extends _i{constructor(e){super();w(this,"mission");w(this,"missionIndex");w(this,"MissionStats");w(this,"roundMode");w(this,"ticker");w(this,"changeRoundButton");w(this,"sidebar");w(this,"currentRound",0);S.GameScene=this,H.Missions.forEach((i,r)=>{i.name==e&&(this.mission=i,this.missionIndex=r)})}init(){this.ticker=new me,this.ticker.maxFPS=60,this.ticker.minFPS=30,this.ticker.add(()=>this.update(this.ticker.elapsedMS)),this.ticker.start();const e=new U(64*30-360,0,360,S.app.canvas.height),i=new U(50,S.app.canvas.height-100,310,100);new Qc(this.mission.gameMap,this.missionIndex),new tu,new Jc(this.mission.rounds,this.mission.gameMap.paths),S.Grid.onGridCellClicked=(r,n)=>{S.TowerManager.isPlacingTower&&S.TowerManager.PlayerClickOnGrid(r,n)},S.WaveManager.events.on(oa.CreepSpawned,r=>{S.Grid.addCreep(r),r.events.on(ee.Escaped,()=>{this.onCreepEscaped(r)})}),this.events.on(ee.Died,(r,n)=>{this.MissionStats.earnGold(r)}),this.sidebar=new ou(e),this.changeRoundButton=new Me(i,"Start",te.Button01,!0),this.changeRoundButton.container.removeFromParent(),this.sidebar.container.addChild(this.changeRoundButton.container),this.changeRoundButton.onClick=()=>{console.log("clicked"),this.changeRoundButton.setEnabled(!1),this.changeRoundButton.setCaption("[X]"),this.setRoundMode(1)},this.MissionStats=new hu(100,200)}update(e){S.WaveManager.update(e),S.Grid.update(e),S.TowerManager.update(e)}onCreepEscaped(e){this.MissionStats.takeDamage(e.health)}setRoundMode(e){this.roundMode=e,this.roundMode==1?S.WaveManager.start(this.currentRound):S.WaveManager.end()}onTowerPlaced(){}}class lu extends _i{init(){const t=new Me(new U(0,0,300,60),"Back to main",te.Button01);t.onClick=e=>{S.GameMaster.changeScene(new ca)},H.Missions.forEach((e,i)=>{const r=new Me(new U(S.app.canvas.width/2-150,S.app.canvas.height/5+i*80,300,60),e.name,te.Button01);r.onClick=n=>{S.GameMaster.changeScene(new la(e.name))}})}}class ca extends _i{init(){const t={caption:"New Game",rect:new U(S.app.canvas.width/2-150,S.app.canvas.height/5+240,300,60),texture:te.Button02},e={caption:"Settings",rect:new U(S.app.canvas.width/2-300/2,S.app.canvas.height/5+4*80,300,60),texture:te.Button02};let i=new Ht({x:S.app.canvas.width/2-300/2,y:S.app.canvas.height/5+1*80,text:"BASTION",style:{fill:16755200,fontFamily:"Aclonica",fontSize:100}});i.x=i.x-i.width/5,S.app.stage.addChild(i);let r=new Ht({x:0,y:0,text:"Latest commit: "+S.latestCommit,style:{fill:0,fontSize:10,fontWeight:"bold"}});S.app.stage.addChild(r);const n=new Me(t.rect,t.caption,t.texture,!0);n.onClick=o=>{S.app.stage.removeChild(i),S.app.stage.removeChild(r),S.GameMaster.changeScene(new lu)};let a=new Me(e.rect,e.caption,e.texture,!0);a.onClick=o=>{alert("Does nothing for now, just placeholder.")}}}function Fs(s){console.log(s)}(async()=>{const s=new An;S.app=s,Fs("main - init()"),await s.init({width:1920,height:1080,resolution:1,autoDensity:!0,backgroundColor:16777215,sharedTicker:!0}),Fs("main - init() complete"),document.body.appendChild(s.canvas);function t(){const i=window.innerWidth,r=window.innerHeight;S.WindowHeight=r,S.WindowWidth=i;const n=i/s.screen.width,a=r/s.screen.height,o=Math.min(n,a),h=Math.round(s.screen.width*o),c=Math.round(s.screen.height*o);Fs(`main - resize(); window: ${window.innerWidth}x${window.innerHeight}}; game ${h}x${c}`);const l=(i-h)/2,u=(r-c)/2;s.canvas.style.width=`${h}px`,s.canvas.style.height=`${c}px`,s.canvas.style.marginLeft=`${l}px`,s.canvas.style.marginTop=`${u}px`,s.canvas.style.marginRight="0",s.canvas.style.marginBottom="0",s.canvas.style.display="block"}S.latestCommit=await fetch("/latest_commit").then(i=>i.text()),window.addEventListener("resize",t),t(),await H.LoadAssets(),new qc,globalThis.Globals=S,S.GameMaster.changeScene(new ca),new URLSearchParams(location.href).entries().next().value[1]=="game"&&S.GameMaster.changeScene(new la("Mission 1"))})();export{W as $,_n as A,Z as B,rt as C,j as D,P as E,Dr as F,ts as G,bt as H,Di as I,dt as J,To as K,Lo as L,D as M,tt as N,U as O,it as P,Jo as Q,Ns as R,_h as S,Ct as T,Ds as U,zi as V,ro as W,gs as X,Q as Y,zr as Z,bn as _,G as a,O as a0,rh as a1,Bn as a2,Nh as a3,$h as a4,Kh as a5,Qh as a6,Jh as a7,Zt as a8,mt as a9,Nl as aa,ei as ab,Wn as ac,Zi as ad,$t as ae,$c as af,wr as ag,ql as ah,Jt as ai,$ as aj,Ia as ak,ti as al,_r as am,Dn as an,me as b,at as c,Pt as d,nt as e,Ki as f,mh as g,Xe as h,ai as i,mn as j,Zr as k,dn as l,yr as m,Mi as n,Hh as o,Vh as p,jh as q,Va as r,Tn as s,Zh as t,oi as u,hn as v,J as w,Ba as x,el as y,At as z}; diff --git a/assets/webworkerAll-CsosBdqh.js b/assets/webworkerAll-CjjN_d2H.js similarity index 99% rename from assets/webworkerAll-CsosBdqh.js rename to assets/webworkerAll-CjjN_d2H.js index f4b2b96..fec2924 100644 --- a/assets/webworkerAll-CsosBdqh.js +++ b/assets/webworkerAll-CjjN_d2H.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-SIvHqos0.js";import{T as w,S as Ce,c as X,a as ft,b as pt,B as Re}from"./colorToUniform-BCodWS3f.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-CcvfyLBm.js";import{T as w,S as Ce,c as X,a as ft,b as pt,B as Re}from"./colorToUniform-B5sTP_KK.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 41829ad..637c4fe 100644 --- a/index.html +++ b/index.html @@ -5,8 +5,9 @@ + Bastion App - + diff --git a/latest_commit b/latest_commit new file mode 100644 index 0000000..6b61ab3 --- /dev/null +++ b/latest_commit @@ -0,0 +1 @@ +2f2a5s3ae4c1d