route-graphics 0.0.17 → 0.0.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/RouteGraphics.js +1 -1
- package/package.json +1 -1
package/dist/RouteGraphics.js
CHANGED
|
@@ -1625,7 +1625,7 @@ void main(void)
|
|
|
1625
1625
|
`)}}return o.push(`
|
|
1626
1626
|
renderer.buffer.update(buffer);
|
|
1627
1627
|
`),{size:s,syncFunc:new Function("ud","uv","renderer","syncData","buffer",o.join(`
|
|
1628
|
-
`))}}var fO=0,Dd={textureCount:0,uboCount:0},Wi=class{constructor(t){this.destroyed=!1,this.renderer=t,this.systemCheck(),this.gl=null,this.shader=null,this.program=null,this.cache={},this._uboCache={},this.id=fO++}systemCheck(){if(!kd())throw new Error("Current environment does not allow unsafe-eval, please use @pixi/unsafe-eval module to enable support.")}contextChange(t){this.gl=t,this.reset()}bind(t,e){t.disposeRunner.add(this),t.uniforms.globals=this.renderer.globalUniforms;let i=t.program,s=i.glPrograms[this.renderer.CONTEXT_UID]||this.generateProgram(t);return this.shader=t,this.program!==i&&(this.program=i,this.gl.useProgram(s.program)),e||(Dd.textureCount=0,Dd.uboCount=0,this.syncUniformGroup(t.uniformGroup,Dd)),s}setUniforms(t){let e=this.shader.program,i=e.glPrograms[this.renderer.CONTEXT_UID];e.syncUniforms(i.uniformData,t,this.renderer)}syncUniformGroup(t,e){let i=this.getGlProgram();(!t.static||t.dirtyId!==i.uniformDirtyGroups[t.id])&&(i.uniformDirtyGroups[t.id]=t.dirtyId,this.syncUniforms(t,i,e))}syncUniforms(t,e,i){(t.syncUniforms[this.shader.program.id]||this.createSyncGroups(t))(e.uniformData,t.uniforms,this.renderer,i)}createSyncGroups(t){let e=this.getSignature(t,this.shader.program.uniformData,"u");return this.cache[e]||(this.cache[e]=$x(t,this.shader.program.uniformData)),t.syncUniforms[this.shader.program.id]=this.cache[e],t.syncUniforms[this.shader.program.id]}syncUniformBufferGroup(t,e){let i=this.getGlProgram();if(!t.static||t.dirtyId!==0||!i.uniformGroups[t.id]){t.dirtyId=0;let s=i.uniformGroups[t.id]||this.createSyncBufferGroup(t,i,e);t.buffer.update(),s(i.uniformData,t.uniforms,this.renderer,Dd,t.buffer)}this.renderer.buffer.bindBufferBase(t.buffer,i.uniformBufferBindings[e])}createSyncBufferGroup(t,e,i){let{gl:s}=this.renderer;this.renderer.buffer.bind(t.buffer);let o=this.gl.getUniformBlockIndex(e.program,i);e.uniformBufferBindings[i]=this.shader.uniformBindCount,s.uniformBlockBinding(e.program,o,this.shader.uniformBindCount),this.shader.uniformBindCount++;let n=this.getSignature(t,this.shader.program.uniformData,"ubo"),a=this._uboCache[n];if(a||(a=this._uboCache[n]=ty(t,this.shader.program.uniformData)),t.autoManage){let l=new Float32Array(a.size/4);t.buffer.update(l)}return e.uniformGroups[t.id]=a.syncFunc,e.uniformGroups[t.id]}getSignature(t,e,i){let s=t.uniforms,o=[`${i}-`];for(let n in s)o.push(n),e[n]&&o.push(e[n].type);return o.join("-")}getGlProgram(){return this.shader?this.shader.program.glPrograms[this.renderer.CONTEXT_UID]:null}generateProgram(t){let e=this.gl,i=t.program,s=Jx(e,i);return i.glPrograms[this.renderer.CONTEXT_UID]=s,s}reset(){this.program=null,this.shader=null}disposeShader(t){this.shader===t&&(this.shader=null)}destroy(){this.renderer=null,this.destroyed=!0}};Wi.extension={type:V.RendererSystem,name:"shader"};q.add(Wi);var _i=class{constructor(t){this.renderer=t}run(t){let{renderer:e}=this;e.runners.init.emit(e.options),t.hello&&console.log(`PixiJS 7.4.3 - ${e.rendererLogId} - https://pixijs.com`),e.resize(e.screen.width,e.screen.height)}destroy(){}};_i.defaultOptions={hello:!1},_i.extension={type:[V.RendererSystem,V.CanvasRendererSystem],name:"startup"};q.add(_i);function IM(r,t=[]){return t[Z.NORMAL]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[Z.ADD]=[r.ONE,r.ONE],t[Z.MULTIPLY]=[r.DST_COLOR,r.ONE_MINUS_SRC_ALPHA,r.ONE,r.ONE_MINUS_SRC_ALPHA],t[Z.SCREEN]=[r.ONE,r.ONE_MINUS_SRC_COLOR,r.ONE,r.ONE_MINUS_SRC_ALPHA],t[Z.OVERLAY]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[Z.DARKEN]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[Z.LIGHTEN]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[Z.COLOR_DODGE]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[Z.COLOR_BURN]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[Z.HARD_LIGHT]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[Z.SOFT_LIGHT]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[Z.DIFFERENCE]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[Z.EXCLUSION]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[Z.HUE]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[Z.SATURATION]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[Z.COLOR]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[Z.LUMINOSITY]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[Z.NONE]=[0,0],t[Z.NORMAL_NPM]=[r.SRC_ALPHA,r.ONE_MINUS_SRC_ALPHA,r.ONE,r.ONE_MINUS_SRC_ALPHA],t[Z.ADD_NPM]=[r.SRC_ALPHA,r.ONE,r.ONE,r.ONE],t[Z.SCREEN_NPM]=[r.SRC_ALPHA,r.ONE_MINUS_SRC_COLOR,r.ONE,r.ONE_MINUS_SRC_ALPHA],t[Z.SRC_IN]=[r.DST_ALPHA,r.ZERO],t[Z.SRC_OUT]=[r.ONE_MINUS_DST_ALPHA,r.ZERO],t[Z.SRC_ATOP]=[r.DST_ALPHA,r.ONE_MINUS_SRC_ALPHA],t[Z.DST_OVER]=[r.ONE_MINUS_DST_ALPHA,r.ONE],t[Z.DST_IN]=[r.ZERO,r.SRC_ALPHA],t[Z.DST_OUT]=[r.ZERO,r.ONE_MINUS_SRC_ALPHA],t[Z.DST_ATOP]=[r.ONE_MINUS_DST_ALPHA,r.SRC_ALPHA],t[Z.XOR]=[r.ONE_MINUS_DST_ALPHA,r.ONE_MINUS_SRC_ALPHA],t[Z.SUBTRACT]=[r.ONE,r.ONE,r.ONE,r.ONE,r.FUNC_REVERSE_SUBTRACT,r.FUNC_ADD],t}var pO=0,mO=1,gO=2,xO=3,yO=4,_O=5,FM=class ey{constructor(){this.gl=null,this.stateId=0,this.polygonOffset=0,this.blendMode=Z.NONE,this._blendEq=!1,this.map=[],this.map[pO]=this.setBlend,this.map[mO]=this.setOffset,this.map[gO]=this.setCullFace,this.map[xO]=this.setDepthTest,this.map[yO]=this.setFrontFace,this.map[_O]=this.setDepthMask,this.checks=[],this.defaultState=new Yr,this.defaultState.blend=!0}contextChange(t){this.gl=t,this.blendModes=IM(t),this.set(this.defaultState),this.reset()}set(t){if(t=t||this.defaultState,this.stateId!==t.data){let e=this.stateId^t.data,i=0;for(;e;)e&1&&this.map[i].call(this,!!(t.data&1<<i)),e=e>>1,i++;this.stateId=t.data}for(let e=0;e<this.checks.length;e++)this.checks[e](this,t)}forceState(t){t=t||this.defaultState;for(let e=0;e<this.map.length;e++)this.map[e].call(this,!!(t.data&1<<e));for(let e=0;e<this.checks.length;e++)this.checks[e](this,t);this.stateId=t.data}setBlend(t){this.updateCheck(ey.checkBlendMode,t),this.gl[t?"enable":"disable"](this.gl.BLEND)}setOffset(t){this.updateCheck(ey.checkPolygonOffset,t),this.gl[t?"enable":"disable"](this.gl.POLYGON_OFFSET_FILL)}setDepthTest(t){this.gl[t?"enable":"disable"](this.gl.DEPTH_TEST)}setDepthMask(t){this.gl.depthMask(t)}setCullFace(t){this.gl[t?"enable":"disable"](this.gl.CULL_FACE)}setFrontFace(t){this.gl.frontFace(this.gl[t?"CW":"CCW"])}setBlendMode(t){if(t===this.blendMode)return;this.blendMode=t;let e=this.blendModes[t],i=this.gl;e.length===2?i.blendFunc(e[0],e[1]):i.blendFuncSeparate(e[0],e[1],e[2],e[3]),e.length===6?(this._blendEq=!0,i.blendEquationSeparate(e[4],e[5])):this._blendEq&&(this._blendEq=!1,i.blendEquationSeparate(i.FUNC_ADD,i.FUNC_ADD))}setPolygonOffset(t,e){this.gl.polygonOffset(t,e)}reset(){this.gl.pixelStorei(this.gl.UNPACK_FLIP_Y_WEBGL,!1),this.forceState(this.defaultState),this._blendEq=!0,this.blendMode=-1,this.setBlendMode(0)}updateCheck(t,e){let i=this.checks.indexOf(t);e&&i===-1?this.checks.push(t):!e&&i!==-1&&this.checks.splice(i,1)}static checkBlendMode(t,e){t.setBlendMode(e.blendMode)}static checkPolygonOffset(t,e){t.setPolygonOffset(1,e.polygonOffset)}destroy(){this.gl=null}};FM.extension={type:V.RendererSystem,name:"state"};var ry=FM;q.add(ry);var _n=class extends Ts.default{constructor(){super(...arguments),this.runners={},this._systemsHash={}}setup(t){this.addRunners(...t.runners);let e=(t.priority??[]).filter(s=>t.systems[s]),i=[...e,...Object.keys(t.systems).filter(s=>!e.includes(s))];for(let s of i)this.addSystem(t.systems[s],s)}addRunners(...t){t.forEach(e=>{this.runners[e]=new Kt(e)})}addSystem(t,e){let 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(let s in this.runners)this.runners[s].add(i);return this}emitWithCustomOptions(t,e){let i=Object.keys(this._systemsHash);t.items.forEach(s=>{let o=i.find(n=>this._systemsHash[n]===s);s[t.name](e[o])})}destroy(){Object.values(this.runners).forEach(t=>{t.destroy()}),this._systemsHash={}}};var nh=class Nd{constructor(t){this.renderer=t,this.count=0,this.checkCount=0,this.maxIdle=Nd.defaultMaxIdle,this.checkCountMax=Nd.defaultCheckCountMax,this.mode=Nd.defaultMode}postrender(){this.renderer.objectRenderer.renderingToScreen&&(this.count++,this.mode!==Qu.MANUAL&&(this.checkCount++,this.checkCount>this.checkCountMax&&(this.checkCount=0,this.run())))}run(){let t=this.renderer.texture,e=t.managedTextures,i=!1;for(let s=0;s<e.length;s++){let o=e[s];o.resource&&this.count-o.touched>this.maxIdle&&(t.destroyTexture(o,!0),e[s]=null,i=!0)}if(i){let s=0;for(let o=0;o<e.length;o++)e[o]!==null&&(e[s++]=e[o]);e.length=s}}unload(t){let e=this.renderer.texture,i=t._texture;i&&!i.framebuffer&&e.destroyTexture(i);for(let s=t.children.length-1;s>=0;s--)this.unload(t.children[s])}destroy(){this.renderer=null}};nh.defaultMode=Qu.AUTO,nh.defaultMaxIdle=60*60,nh.defaultCheckCountMax=60*10,nh.extension={type:V.RendererSystem,name:"textureGC"};var Zr=nh;q.add(Zr);var Gs=class{constructor(t){this.texture=t,this.width=-1,this.height=-1,this.dirtyId=-1,this.dirtyStyleId=-1,this.mipmap=!1,this.wrapMode=33071,this.type=it.UNSIGNED_BYTE,this.internalFormat=G.RGBA,this.samplerType=0}};function kM(r){let t;return"WebGL2RenderingContext"in globalThis&&r instanceof globalThis.WebGL2RenderingContext?t={[r.RGB]:N.FLOAT,[r.RGBA]:N.FLOAT,[r.ALPHA]:N.FLOAT,[r.LUMINANCE]:N.FLOAT,[r.LUMINANCE_ALPHA]:N.FLOAT,[r.R8]:N.FLOAT,[r.R8_SNORM]:N.FLOAT,[r.RG8]:N.FLOAT,[r.RG8_SNORM]:N.FLOAT,[r.RGB8]:N.FLOAT,[r.RGB8_SNORM]:N.FLOAT,[r.RGB565]:N.FLOAT,[r.RGBA4]:N.FLOAT,[r.RGB5_A1]:N.FLOAT,[r.RGBA8]:N.FLOAT,[r.RGBA8_SNORM]:N.FLOAT,[r.RGB10_A2]:N.FLOAT,[r.RGB10_A2UI]:N.FLOAT,[r.SRGB8]:N.FLOAT,[r.SRGB8_ALPHA8]:N.FLOAT,[r.R16F]:N.FLOAT,[r.RG16F]:N.FLOAT,[r.RGB16F]:N.FLOAT,[r.RGBA16F]:N.FLOAT,[r.R32F]:N.FLOAT,[r.RG32F]:N.FLOAT,[r.RGB32F]:N.FLOAT,[r.RGBA32F]:N.FLOAT,[r.R11F_G11F_B10F]:N.FLOAT,[r.RGB9_E5]:N.FLOAT,[r.R8I]:N.INT,[r.R8UI]:N.UINT,[r.R16I]:N.INT,[r.R16UI]:N.UINT,[r.R32I]:N.INT,[r.R32UI]:N.UINT,[r.RG8I]:N.INT,[r.RG8UI]:N.UINT,[r.RG16I]:N.INT,[r.RG16UI]:N.UINT,[r.RG32I]:N.INT,[r.RG32UI]:N.UINT,[r.RGB8I]:N.INT,[r.RGB8UI]:N.UINT,[r.RGB16I]:N.INT,[r.RGB16UI]:N.UINT,[r.RGB32I]:N.INT,[r.RGB32UI]:N.UINT,[r.RGBA8I]:N.INT,[r.RGBA8UI]:N.UINT,[r.RGBA16I]:N.INT,[r.RGBA16UI]:N.UINT,[r.RGBA32I]:N.INT,[r.RGBA32UI]:N.UINT,[r.DEPTH_COMPONENT16]:N.FLOAT,[r.DEPTH_COMPONENT24]:N.FLOAT,[r.DEPTH_COMPONENT32F]:N.FLOAT,[r.DEPTH_STENCIL]:N.FLOAT,[r.DEPTH24_STENCIL8]:N.FLOAT,[r.DEPTH32F_STENCIL8]:N.FLOAT}:t={[r.RGB]:N.FLOAT,[r.RGBA]:N.FLOAT,[r.ALPHA]:N.FLOAT,[r.LUMINANCE]:N.FLOAT,[r.LUMINANCE_ALPHA]:N.FLOAT,[r.DEPTH_STENCIL]:N.FLOAT},t}function GM(r){let t;return"WebGL2RenderingContext"in globalThis&&r instanceof globalThis.WebGL2RenderingContext?t={[it.UNSIGNED_BYTE]:{[G.RGBA]:r.RGBA8,[G.RGB]:r.RGB8,[G.RG]:r.RG8,[G.RED]:r.R8,[G.RGBA_INTEGER]:r.RGBA8UI,[G.RGB_INTEGER]:r.RGB8UI,[G.RG_INTEGER]:r.RG8UI,[G.RED_INTEGER]:r.R8UI,[G.ALPHA]:r.ALPHA,[G.LUMINANCE]:r.LUMINANCE,[G.LUMINANCE_ALPHA]:r.LUMINANCE_ALPHA},[it.BYTE]:{[G.RGBA]:r.RGBA8_SNORM,[G.RGB]:r.RGB8_SNORM,[G.RG]:r.RG8_SNORM,[G.RED]:r.R8_SNORM,[G.RGBA_INTEGER]:r.RGBA8I,[G.RGB_INTEGER]:r.RGB8I,[G.RG_INTEGER]:r.RG8I,[G.RED_INTEGER]:r.R8I},[it.UNSIGNED_SHORT]:{[G.RGBA_INTEGER]:r.RGBA16UI,[G.RGB_INTEGER]:r.RGB16UI,[G.RG_INTEGER]:r.RG16UI,[G.RED_INTEGER]:r.R16UI,[G.DEPTH_COMPONENT]:r.DEPTH_COMPONENT16},[it.SHORT]:{[G.RGBA_INTEGER]:r.RGBA16I,[G.RGB_INTEGER]:r.RGB16I,[G.RG_INTEGER]:r.RG16I,[G.RED_INTEGER]:r.R16I},[it.UNSIGNED_INT]:{[G.RGBA_INTEGER]:r.RGBA32UI,[G.RGB_INTEGER]:r.RGB32UI,[G.RG_INTEGER]:r.RG32UI,[G.RED_INTEGER]:r.R32UI,[G.DEPTH_COMPONENT]:r.DEPTH_COMPONENT24},[it.INT]:{[G.RGBA_INTEGER]:r.RGBA32I,[G.RGB_INTEGER]:r.RGB32I,[G.RG_INTEGER]:r.RG32I,[G.RED_INTEGER]:r.R32I},[it.FLOAT]:{[G.RGBA]:r.RGBA32F,[G.RGB]:r.RGB32F,[G.RG]:r.RG32F,[G.RED]:r.R32F,[G.DEPTH_COMPONENT]:r.DEPTH_COMPONENT32F},[it.HALF_FLOAT]:{[G.RGBA]:r.RGBA16F,[G.RGB]:r.RGB16F,[G.RG]:r.RG16F,[G.RED]:r.R16F},[it.UNSIGNED_SHORT_5_6_5]:{[G.RGB]:r.RGB565},[it.UNSIGNED_SHORT_4_4_4_4]:{[G.RGBA]:r.RGBA4},[it.UNSIGNED_SHORT_5_5_5_1]:{[G.RGBA]:r.RGB5_A1},[it.UNSIGNED_INT_2_10_10_10_REV]:{[G.RGBA]:r.RGB10_A2,[G.RGBA_INTEGER]:r.RGB10_A2UI},[it.UNSIGNED_INT_10F_11F_11F_REV]:{[G.RGB]:r.R11F_G11F_B10F},[it.UNSIGNED_INT_5_9_9_9_REV]:{[G.RGB]:r.RGB9_E5},[it.UNSIGNED_INT_24_8]:{[G.DEPTH_STENCIL]:r.DEPTH24_STENCIL8},[it.FLOAT_32_UNSIGNED_INT_24_8_REV]:{[G.DEPTH_STENCIL]:r.DEPTH32F_STENCIL8}}:t={[it.UNSIGNED_BYTE]:{[G.RGBA]:r.RGBA,[G.RGB]:r.RGB,[G.ALPHA]:r.ALPHA,[G.LUMINANCE]:r.LUMINANCE,[G.LUMINANCE_ALPHA]:r.LUMINANCE_ALPHA},[it.UNSIGNED_SHORT_5_6_5]:{[G.RGB]:r.RGB},[it.UNSIGNED_SHORT_4_4_4_4]:{[G.RGBA]:r.RGBA},[it.UNSIGNED_SHORT_5_5_5_1]:{[G.RGBA]:r.RGBA}},t}var bn=class{constructor(t){this.renderer=t,this.boundTextures=[],this.currentLocation=-1,this.managedTextures=[],this._unknownBoundTextures=!1,this.unknownTexture=new dt,this.hasIntegerTextures=!1}contextChange(){let t=this.gl=this.renderer.gl;this.CONTEXT_UID=this.renderer.CONTEXT_UID,this.webGLVersion=this.renderer.context.webGLVersion,this.internalFormats=GM(t),this.samplerTypes=kM(t);let e=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS);this.boundTextures.length=e;for(let s=0;s<e;s++)this.boundTextures[s]=null;this.emptyTextures={};let i=new Gs(t.createTexture());t.bindTexture(t.TEXTURE_2D,i.texture),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,1,1,0,t.RGBA,t.UNSIGNED_BYTE,new Uint8Array(4)),this.emptyTextures[t.TEXTURE_2D]=i,this.emptyTextures[t.TEXTURE_CUBE_MAP]=new Gs(t.createTexture()),t.bindTexture(t.TEXTURE_CUBE_MAP,this.emptyTextures[t.TEXTURE_CUBE_MAP].texture);for(let s=0;s<6;s++)t.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+s,0,t.RGBA,1,1,0,t.RGBA,t.UNSIGNED_BYTE,null);t.texParameteri(t.TEXTURE_CUBE_MAP,t.TEXTURE_MAG_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_CUBE_MAP,t.TEXTURE_MIN_FILTER,t.LINEAR);for(let s=0;s<this.boundTextures.length;s++)this.bind(null,s)}bind(t,e=0){let{gl:i}=this;if(t=t?.castToBaseTexture(),t?.valid&&!t.parentTextureArray){t.touched=this.renderer.textureGC.count;let s=t._glTextures[this.CONTEXT_UID]||this.initTexture(t);this.boundTextures[e]!==t&&(this.currentLocation!==e&&(this.currentLocation=e,i.activeTexture(i.TEXTURE0+e)),i.bindTexture(t.target,s.texture)),s.dirtyId!==t.dirtyId?(this.currentLocation!==e&&(this.currentLocation=e,i.activeTexture(i.TEXTURE0+e)),this.updateTexture(t)):s.dirtyStyleId!==t.dirtyStyleId&&this.updateTextureStyle(t),this.boundTextures[e]=t}else this.currentLocation!==e&&(this.currentLocation=e,i.activeTexture(i.TEXTURE0+e)),i.bindTexture(i.TEXTURE_2D,this.emptyTextures[i.TEXTURE_2D].texture),this.boundTextures[e]=null}reset(){this._unknownBoundTextures=!0,this.hasIntegerTextures=!1,this.currentLocation=-1;for(let t=0;t<this.boundTextures.length;t++)this.boundTextures[t]=this.unknownTexture}unbind(t){let{gl:e,boundTextures:i}=this;if(this._unknownBoundTextures){this._unknownBoundTextures=!1;for(let s=0;s<i.length;s++)i[s]===this.unknownTexture&&this.bind(null,s)}for(let s=0;s<i.length;s++)i[s]===t&&(this.currentLocation!==s&&(e.activeTexture(e.TEXTURE0+s),this.currentLocation=s),e.bindTexture(t.target,this.emptyTextures[t.target].texture),i[s]=null)}ensureSamplerType(t){let{boundTextures:e,hasIntegerTextures:i,CONTEXT_UID:s}=this;if(i)for(let o=t-1;o>=0;--o){let n=e[o];n&&n._glTextures[s].samplerType!==N.FLOAT&&this.renderer.texture.unbind(n)}}initTexture(t){let e=new Gs(this.gl.createTexture());return e.dirtyId=-1,t._glTextures[this.CONTEXT_UID]=e,this.managedTextures.push(t),t.on("dispose",this.destroyTexture,this),e}initTextureType(t,e){e.internalFormat=this.internalFormats[t.type]?.[t.format]??t.format,e.samplerType=this.samplerTypes[e.internalFormat]??N.FLOAT,this.webGLVersion===2&&t.type===it.HALF_FLOAT?e.type=this.gl.HALF_FLOAT:e.type=t.type}updateTexture(t){let e=t._glTextures[this.CONTEXT_UID];if(!e)return;let i=this.renderer;if(this.initTextureType(t,e),t.resource?.upload(i,t,e))e.samplerType!==N.FLOAT&&(this.hasIntegerTextures=!0);else{let s=t.realWidth,o=t.realHeight,n=i.gl;(e.width!==s||e.height!==o||e.dirtyId<0)&&(e.width=s,e.height=o,n.texImage2D(t.target,0,e.internalFormat,s,o,0,t.format,e.type,null))}t.dirtyStyleId!==e.dirtyStyleId&&this.updateTextureStyle(t),e.dirtyId=t.dirtyId}destroyTexture(t,e){let{gl:i}=this;if(t=t.castToBaseTexture(),t._glTextures[this.CONTEXT_UID]&&(this.unbind(t),i.deleteTexture(t._glTextures[this.CONTEXT_UID].texture),t.off("dispose",this.destroyTexture,this),delete t._glTextures[this.CONTEXT_UID],!e)){let s=this.managedTextures.indexOf(t);s!==-1&&Bx(this.managedTextures,s,1)}}updateTextureStyle(t){let e=t._glTextures[this.CONTEXT_UID];e&&((t.mipmap===Ar.POW2||this.webGLVersion!==2)&&!t.isPowerOfTwo?e.mipmap=!1:e.mipmap=t.mipmap>=1,this.webGLVersion!==2&&!t.isPowerOfTwo?e.wrapMode=El.CLAMP:e.wrapMode=t.wrapMode,t.resource?.style(this.renderer,t,e)||this.setStyle(t,e),e.dirtyStyleId=t.dirtyStyleId)}setStyle(t,e){let i=this.gl;if(e.mipmap&&t.mipmap!==Ar.ON_MANUAL&&i.generateMipmap(t.target),i.texParameteri(t.target,i.TEXTURE_WRAP_S,e.wrapMode),i.texParameteri(t.target,i.TEXTURE_WRAP_T,e.wrapMode),e.mipmap){i.texParameteri(t.target,i.TEXTURE_MIN_FILTER,t.scaleMode===fr.LINEAR?i.LINEAR_MIPMAP_LINEAR:i.NEAREST_MIPMAP_NEAREST);let s=this.renderer.context.extensions.anisotropicFiltering;if(s&&t.anisotropicLevel>0&&t.scaleMode===fr.LINEAR){let o=Math.min(t.anisotropicLevel,i.getParameter(s.MAX_TEXTURE_MAX_ANISOTROPY_EXT));i.texParameterf(t.target,s.TEXTURE_MAX_ANISOTROPY_EXT,o)}}else i.texParameteri(t.target,i.TEXTURE_MIN_FILTER,t.scaleMode===fr.LINEAR?i.LINEAR:i.NEAREST);i.texParameteri(t.target,i.TEXTURE_MAG_FILTER,t.scaleMode===fr.LINEAR?i.LINEAR:i.NEAREST)}destroy(){this.renderer=null}};bn.extension={type:V.RendererSystem,name:"texture"};q.add(bn);var vn=class{constructor(t){this.renderer=t}contextChange(){this.gl=this.renderer.gl,this.CONTEXT_UID=this.renderer.CONTEXT_UID}bind(t){let{gl:e,CONTEXT_UID:i}=this,s=t._glTransformFeedbacks[i]||this.createGLTransformFeedback(t);e.bindTransformFeedback(e.TRANSFORM_FEEDBACK,s)}unbind(){let{gl:t}=this;t.bindTransformFeedback(t.TRANSFORM_FEEDBACK,null)}beginTransformFeedback(t,e){let{gl:i,renderer:s}=this;e&&s.shader.bind(e),i.beginTransformFeedback(t)}endTransformFeedback(){let{gl:t}=this;t.endTransformFeedback()}createGLTransformFeedback(t){let{gl:e,renderer:i,CONTEXT_UID:s}=this,o=e.createTransformFeedback();t._glTransformFeedbacks[s]=o,e.bindTransformFeedback(e.TRANSFORM_FEEDBACK,o);for(let n=0;n<t.buffers.length;n++){let a=t.buffers[n];a&&(i.buffer.update(a),a._glBuffers[s].refCount++,e.bindBufferBase(e.TRANSFORM_FEEDBACK_BUFFER,n,a._glBuffers[s].buffer||null))}return e.bindTransformFeedback(e.TRANSFORM_FEEDBACK,null),t.disposeRunner.add(this),o}disposeTransformFeedback(t,e){let i=t._glTransformFeedbacks[this.CONTEXT_UID],s=this.gl;t.disposeRunner.remove(this);let o=this.renderer.buffer;if(o)for(let n=0;n<t.buffers.length;n++){let a=t.buffers[n];if(!a)continue;let l=a._glBuffers[this.CONTEXT_UID];l&&(l.refCount--,l.refCount===0&&!e&&o.dispose(a,e))}i&&(e||s.deleteTransformFeedback(i),delete t._glTransformFeedbacks[this.CONTEXT_UID])}destroy(){this.renderer=null}};vn.extension={type:V.RendererSystem,name:"transformFeedback"};q.add(vn);var bi=class{constructor(t){this.renderer=t}init(t){this.screen=new mt(0,0,t.width,t.height),this.element=t.view||Y.ADAPTER.createCanvas(),this.resolution=t.resolution||Y.RESOLUTION,this.autoDensity=!!t.autoDensity}resizeView(t,e){this.element.width=Math.round(t*this.resolution),this.element.height=Math.round(e*this.resolution);let i=this.element.width/this.resolution,s=this.element.height/this.resolution;this.screen.width=i,this.screen.height=s,this.autoDensity&&(this.element.style.width=`${i}px`,this.element.style.height=`${s}px`),this.renderer.emit("resize",i,s),this.renderer.runners.resize.emit(this.screen.width,this.screen.height)}destroy(t){t&&this.element.parentNode?.removeChild(this.element),this.renderer=null,this.element=null,this.screen=null}};bi.defaultOptions={width:800,height:600,resolution:void 0,autoDensity:!1},bi.extension={type:[V.RendererSystem,V.CanvasRendererSystem],name:"_view"};q.add(bi);Y.PREFER_ENV=Ze.WEBGL2;Y.STRICT_TEXTURE_CACHE=!1;Y.RENDER_OPTIONS={...yi.defaultOptions,...xi.defaultOptions,...bi.defaultOptions,..._i.defaultOptions};Object.defineProperties(Y,{WRAP_MODE:{get(){return dt.defaultOptions.wrapMode},set(r){ht("7.1.0","settings.WRAP_MODE is deprecated, use BaseTexture.defaultOptions.wrapMode"),dt.defaultOptions.wrapMode=r}},SCALE_MODE:{get(){return dt.defaultOptions.scaleMode},set(r){ht("7.1.0","settings.SCALE_MODE is deprecated, use BaseTexture.defaultOptions.scaleMode"),dt.defaultOptions.scaleMode=r}},MIPMAP_TEXTURES:{get(){return dt.defaultOptions.mipmap},set(r){ht("7.1.0","settings.MIPMAP_TEXTURES is deprecated, use BaseTexture.defaultOptions.mipmap"),dt.defaultOptions.mipmap=r}},ANISOTROPIC_LEVEL:{get(){return dt.defaultOptions.anisotropicLevel},set(r){ht("7.1.0","settings.ANISOTROPIC_LEVEL is deprecated, use BaseTexture.defaultOptions.anisotropicLevel"),dt.defaultOptions.anisotropicLevel=r}},FILTER_RESOLUTION:{get(){return ht("7.1.0","settings.FILTER_RESOLUTION is deprecated, use Filter.defaultResolution"),Kr.defaultResolution},set(r){Kr.defaultResolution=r}},FILTER_MULTISAMPLE:{get(){return ht("7.1.0","settings.FILTER_MULTISAMPLE is deprecated, use Filter.defaultMultisample"),Kr.defaultMultisample},set(r){Kr.defaultMultisample=r}},SPRITE_MAX_TEXTURES:{get(){return gi.defaultMaxTextures},set(r){ht("7.1.0","settings.SPRITE_MAX_TEXTURES is deprecated, use BatchRenderer.defaultMaxTextures"),gi.defaultMaxTextures=r}},SPRITE_BATCH_SIZE:{get(){return gi.defaultBatchSize},set(r){ht("7.1.0","settings.SPRITE_BATCH_SIZE is deprecated, use BatchRenderer.defaultBatchSize"),gi.defaultBatchSize=r}},CAN_UPLOAD_SAME_BUFFER:{get(){return gi.canUploadSameBuffer},set(r){ht("7.1.0","settings.CAN_UPLOAD_SAME_BUFFER is deprecated, use BatchRenderer.canUploadSameBuffer"),gi.canUploadSameBuffer=r}},GC_MODE:{get(){return Zr.defaultMode},set(r){ht("7.1.0","settings.GC_MODE is deprecated, use TextureGCSystem.defaultMode"),Zr.defaultMode=r}},GC_MAX_IDLE:{get(){return Zr.defaultMaxIdle},set(r){ht("7.1.0","settings.GC_MAX_IDLE is deprecated, use TextureGCSystem.defaultMaxIdle"),Zr.defaultMaxIdle=r}},GC_MAX_CHECK_COUNT:{get(){return Zr.defaultCheckCountMax},set(r){ht("7.1.0","settings.GC_MAX_CHECK_COUNT is deprecated, use TextureGCSystem.defaultCheckCountMax"),Zr.defaultCheckCountMax=r}},PRECISION_VERTEX:{get(){return gr.defaultVertexPrecision},set(r){ht("7.1.0","settings.PRECISION_VERTEX is deprecated, use Program.defaultVertexPrecision"),gr.defaultVertexPrecision=r}},PRECISION_FRAGMENT:{get(){return gr.defaultFragmentPrecision},set(r){ht("7.1.0","settings.PRECISION_FRAGMENT is deprecated, use Program.defaultFragmentPrecision"),gr.defaultFragmentPrecision=r}}});var Us=(r=>(r[r.INTERACTION=50]="INTERACTION",r[r.HIGH=25]="HIGH",r[r.NORMAL=0]="NORMAL",r[r.LOW=-25]="LOW",r[r.UTILITY=-50]="UTILITY",r))(Us||{});var Tn=class{constructor(t,e=null,i=0,s=!1){this.next=null,this.previous=null,this._destroyed=!1,this.fn=t,this.context=e,this.priority=i,this.once=s}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));let 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);let e=this.next;return this.next=t?null:e,this.previous=null,e}};var UM=class rr{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 Tn(null,null,1/0),this.deltaMS=1/rr.targetFPMS,this.elapsedMS=1/rr.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=Us.NORMAL){return this._addListener(new Tn(t,e,i))}addOnce(t,e,i=Us.NORMAL){return this._addListener(new Tn(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){let o=t-this._lastFrame|0;if(o<this._minElapsedMS)return;this._lastFrame=t-o%this._minElapsedMS}this.deltaMS=e,this.deltaTime=this.deltaMS*rr.targetFPMS;let i=this._head,s=i.next;for(;s;)s=s.emit(this.deltaTime);i.next||this._cancelIfNeeded()}else this.deltaTime=this.deltaMS=this.elapsedMS=0;this.lastTime=t}get FPS(){return 1e3/this.elapsedMS}get minFPS(){return 1e3/this._maxElapsedMS}set minFPS(t){let e=Math.min(this.maxFPS,t),i=Math.min(Math.max(0,e)/1e3,rr.targetFPMS);this._maxElapsedMS=1/i}get maxFPS(){return this._minElapsedMS?Math.round(1e3/this._minElapsedMS):0}set maxFPS(t){if(t===0)this._minElapsedMS=0;else{let e=Math.max(this.minFPS,t);this._minElapsedMS=1/(e/1e3)}}static get shared(){if(!rr._shared){let t=rr._shared=new rr;t.autoStart=!0,t._protected=!0}return rr._shared}static get system(){if(!rr._system){let t=rr._system=new rr;t.autoStart=!0,t._protected=!0}return rr._system}};UM.targetFPMS=.06;var xr=UM;Object.defineProperties(Y,{TARGET_FPMS:{get(){return xr.targetFPMS},set(r){ht("7.1.0","settings.TARGET_FPMS is deprecated, use Ticker.targetFPMS"),xr.targetFPMS=r}}});var ah=class{static init(t){t=Object.assign({autoStart:!0,sharedTicker:!1},t),Object.defineProperty(this,"ticker",{set(e){this._ticker&&this._ticker.remove(this.render,this),this._ticker=e,e&&e.add(this.render,this,Us.LOW)},get(){return this._ticker}}),this.stop=()=>{this._ticker.stop()},this.start=()=>{this._ticker.start()},this._ticker=null,this.ticker=t.sharedTicker?xr.shared:new xr,t.autoStart&&this.start()}static destroy(){if(this._ticker){let t=this._ticker;this.ticker=null,t.destroy()}}};ah.extension=V.Application;q.add(ah);var bO=[];q.handleByList(V.Renderer,bO);var lh=class{constructor(t){this.renderer=t}contextChange(t){let e;if(this.renderer.context.webGLVersion===1){let i=t.getParameter(t.FRAMEBUFFER_BINDING);t.bindFramebuffer(t.FRAMEBUFFER,null),e=t.getParameter(t.SAMPLES),t.bindFramebuffer(t.FRAMEBUFFER,i)}else{let i=t.getParameter(t.DRAW_FRAMEBUFFER_BINDING);t.bindFramebuffer(t.DRAW_FRAMEBUFFER,null),e=t.getParameter(t.SAMPLES),t.bindFramebuffer(t.DRAW_FRAMEBUFFER,i)}e>=Pt.HIGH?this.multisample=Pt.HIGH:e>=Pt.MEDIUM?this.multisample=Pt.MEDIUM:e>=Pt.LOW?this.multisample=Pt.LOW:this.multisample=Pt.NONE}destroy(){}};lh.extension={type:V.RendererSystem,name:"_multisample"};q.add(lh);var Hd=class{constructor(t){this.buffer=t||null,this.updateID=-1,this.byteLength=-1,this.refCount=0}};var hh=class{constructor(t){this.renderer=t,this.managedBuffers={},this.boundBufferBases={}}destroy(){this.renderer=null}contextChange(){this.disposeAll(!0),this.gl=this.renderer.gl,this.CONTEXT_UID=this.renderer.CONTEXT_UID}bind(t){let{gl:e,CONTEXT_UID:i}=this,s=t._glBuffers[i]||this.createGLBuffer(t);e.bindBuffer(t.type,s.buffer)}unbind(t){let{gl:e}=this;e.bindBuffer(t,null)}bindBufferBase(t,e){let{gl:i,CONTEXT_UID:s}=this;if(this.boundBufferBases[e]!==t){let o=t._glBuffers[s]||this.createGLBuffer(t);this.boundBufferBases[e]=t,i.bindBufferBase(i.UNIFORM_BUFFER,e,o.buffer)}}bindBufferRange(t,e,i){let{gl:s,CONTEXT_UID:o}=this;i=i||0;let n=t._glBuffers[o]||this.createGLBuffer(t);s.bindBufferRange(s.UNIFORM_BUFFER,e||0,n.buffer,i*256,256)}update(t){let{gl:e,CONTEXT_UID:i}=this,s=t._glBuffers[i]||this.createGLBuffer(t);if(t._updateID!==s.updateID)if(s.updateID=t._updateID,e.bindBuffer(t.type,s.buffer),s.byteLength>=t.data.byteLength)e.bufferSubData(t.type,0,t.data);else{let o=t.static?e.STATIC_DRAW:e.DYNAMIC_DRAW;s.byteLength=t.data.byteLength,e.bufferData(t.type,t.data,o)}}dispose(t,e){if(!this.managedBuffers[t.id])return;delete this.managedBuffers[t.id];let i=t._glBuffers[this.CONTEXT_UID],s=this.gl;t.disposeRunner.remove(this),i&&(e||s.deleteBuffer(i.buffer),delete t._glBuffers[this.CONTEXT_UID])}disposeAll(t){let e=Object.keys(this.managedBuffers);for(let i=0;i<e.length;i++)this.dispose(this.managedBuffers[e[i]],t)}createGLBuffer(t){let{CONTEXT_UID:e,gl:i}=this;return t._glBuffers[e]=new Hd(i.createBuffer()),this.managedBuffers[t.id]=t,t.disposeRunner.add(this),t._glBuffers[e]}};hh.extension={type:V.RendererSystem,name:"buffer"};q.add(hh);var ch=class{constructor(t){this.renderer=t}render(t,e){let i=this.renderer,s,o,n,a;if(e&&(s=e.renderTexture,o=e.clear,n=e.transform,a=e.skipUpdateTransform),this.renderingToScreen=!s,i.runners.prerender.emit(),i.emit("prerender"),i.projection.transform=n,!i.context.isLost){if(s||(this.lastObjectRendered=t),!a){let l=t.enableTempParent();t.updateTransform(),t.disableTempParent(l)}i.renderTexture.bind(s),i.batch.currentRenderer.start(),(o??i.background.clearBeforeRender)&&i.renderTexture.clear(),t.render(i),i.batch.currentRenderer.flush(),s&&(e.blit&&i.framebuffer.blit(),s.baseTexture.update()),i.runners.postrender.emit(),i.projection.transform=null,i.emit("postrender")}}destroy(){this.renderer=null,this.lastObjectRendered=null}};ch.extension={type:V.RendererSystem,name:"objectRenderer"};q.add(ch);var Vd=class iy extends _n{constructor(t){super(),this.type=Xg.WEBGL,t=Object.assign({},Y.RENDER_OPTIONS,t),this.gl=null,this.CONTEXT_UID=0,this.globalUniforms=new er({projectionMatrix:new Bt},!0);let e={runners:["init","destroy","contextChange","resolutionChange","reset","update","postrender","prerender","resize"],systems:iy.__systems,priority:["_view","textureGenerator","background","_plugin","startup","context","state","texture","buffer","geometry","framebuffer","transformFeedback","mask","scissor","stencil","projection","textureGC","filter","renderTexture","batch","objectRenderer","_multisample"]};this.setup(e),"useContextAlpha"in t&&(ht("7.0.0","options.useContextAlpha is deprecated, use options.premultipliedAlpha and options.backgroundAlpha instead"),t.premultipliedAlpha=t.useContextAlpha&&t.useContextAlpha!=="notMultiplied",t.backgroundAlpha=t.useContextAlpha===!1?1:t.backgroundAlpha),this._plugin.rendererPlugins=iy.__plugins,this.options=t,this.startup.run(this.options)}static test(t){return t?.forceCanvas?!1:Rx()}render(t,e){this.objectRenderer.render(t,e)}resize(t,e){this._view.resizeView(t,e)}reset(){return this.runners.reset.emit(),this}clear(){this.renderTexture.bind(),this.renderTexture.clear()}destroy(t=!1){this.runners.destroy.items.reverse(),this.emitWithCustomOptions(this.runners.destroy,{_view:t}),super.destroy()}get plugins(){return this._plugin.plugins}get multisample(){return this._multisample.multisample}get width(){return this._view.element.width}get height(){return this._view.element.height}get resolution(){return this._view.resolution}set resolution(t){this._view.resolution=t,this.runners.resolutionChange.emit(t)}get autoDensity(){return this._view.autoDensity}get view(){return this._view.element}get screen(){return this._view.screen}get lastObjectRendered(){return this.objectRenderer.lastObjectRendered}get renderingToScreen(){return this.objectRenderer.renderingToScreen}get rendererLogId(){return`WebGL ${this.context.webGLVersion}`}get clearBeforeRender(){return ht("7.0.0","renderer.clearBeforeRender has been deprecated, please use renderer.background.clearBeforeRender instead."),this.background.clearBeforeRender}get useContextAlpha(){return ht("7.0.0","renderer.useContextAlpha has been deprecated, please use renderer.context.premultipliedAlpha instead."),this.context.useContextAlpha}get preserveDrawingBuffer(){return ht("7.0.0","renderer.preserveDrawingBuffer has been deprecated, we cannot truly know this unless pixi created the context"),this.context.preserveDrawingBuffer}get backgroundColor(){return ht("7.0.0","renderer.backgroundColor has been deprecated, use renderer.background.color instead."),this.background.color}set backgroundColor(t){ht("7.0.0","renderer.backgroundColor has been deprecated, use renderer.background.color instead."),this.background.color=t}get backgroundAlpha(){return ht("7.0.0","renderer.backgroundAlpha has been deprecated, use renderer.background.alpha instead."),this.background.alpha}set backgroundAlpha(t){ht("7.0.0","renderer.backgroundAlpha has been deprecated, use renderer.background.alpha instead."),this.background.alpha=t}get powerPreference(){return ht("7.0.0","renderer.powerPreference has been deprecated, we can only know this if pixi creates the context"),this.context.powerPreference}generateTexture(t,e){return this.textureGenerator.generateTexture(t,e)}};Vd.extension={type:V.Renderer,priority:1},Vd.__plugins={},Vd.__systems={};var Wd=Vd;q.handleByMap(V.RendererPlugin,Wd.__plugins);q.handleByMap(V.RendererSystem,Wd.__systems);q.add(Wd);var zi=class extends tr{constructor(t,e){let{width:i,height:s}=e||{};super(i,s),this.items=[],this.itemDirtyIds=[];for(let o=0;o<t;o++){let n=new dt;this.items.push(n),this.itemDirtyIds.push(-2)}this.length=t,this._load=null,this.baseTexture=null}initFromArray(t,e){for(let i=0;i<this.length;i++)t[i]&&(t[i].castToBaseTexture?this.addBaseTextureAt(t[i].castToBaseTexture(),i):t[i]instanceof tr?this.addResourceAt(t[i],i):this.addResourceAt(rn(t[i],e),i))}dispose(){for(let t=0,e=this.length;t<e;t++)this.items[t].destroy();this.items=null,this.itemDirtyIds=null,this._load=null}addResourceAt(t,e){if(!this.items[e])throw new Error(`Index ${e} is out of bounds`);return t.valid&&!this.valid&&this.resize(t.width,t.height),this.items[e].setResource(t),this}bind(t){if(this.baseTexture!==null)throw new Error("Only one base texture per TextureArray is allowed");super.bind(t);for(let e=0;e<this.length;e++)this.items[e].parentTextureArray=t,this.items[e].on("update",t.update,t)}unbind(t){super.unbind(t);for(let e=0;e<this.length;e++)this.items[e].parentTextureArray=null,this.items[e].off("update",t.update,t)}load(){if(this._load)return this._load;let t=this.items.map(e=>e.resource).filter(e=>e).map(e=>e.load());return this._load=Promise.all(t).then(()=>{let{realWidth:e,realHeight:i}=this.items[0];return this.resize(e,i),this.update(),Promise.resolve(this)}),this._load}};var uh=class extends zi{constructor(t,e){let{width:i,height:s}=e||{},o,n;Array.isArray(t)?(o=t,n=t.length):n=t,super(n,{width:i,height:s}),o&&this.initFromArray(o,e)}addBaseTextureAt(t,e){if(t.resource)this.addResourceAt(t.resource,e);else throw new Error("ArrayResource does not support RenderTexture");return this}bind(t){super.bind(t),t.target=ui.TEXTURE_2D_ARRAY}upload(t,e,i){let{length:s,itemDirtyIds:o,items:n}=this,{gl:a}=t;i.dirtyId<0&&a.texImage3D(a.TEXTURE_2D_ARRAY,0,i.internalFormat,this._width,this._height,s,0,e.format,i.type,null);for(let l=0;l<s;l++){let h=n[l];o[l]<h.dirtyId&&(o[l]=h.dirtyId,h.valid&&a.texSubImage3D(a.TEXTURE_2D_ARRAY,0,0,0,l,h.resource.width,h.resource.height,1,e.format,i.type,h.resource.source))}return!0}};var dh=class extends ue{constructor(t){super(t)}static test(t){let{OffscreenCanvas:e}=globalThis;return e&&t instanceof e?!0:globalThis.HTMLCanvasElement&&t instanceof HTMLCanvasElement}};var OM=class fh extends zi{constructor(t,e){let{width:i,height:s,autoLoad:o,linkBaseTexture:n}=e||{};if(t&&t.length!==fh.SIDES)throw new Error(`Invalid length. Got ${t.length}, expected 6`);super(6,{width:i,height:s});for(let a=0;a<fh.SIDES;a++)this.items[a].target=ui.TEXTURE_CUBE_MAP_POSITIVE_X+a;this.linkBaseTexture=n!==!1,t&&this.initFromArray(t,e),o!==!1&&this.load()}bind(t){super.bind(t),t.target=ui.TEXTURE_CUBE_MAP}addBaseTextureAt(t,e,i){if(i===void 0&&(i=this.linkBaseTexture),!this.items[e])throw new Error(`Index ${e} is out of bounds`);if(!this.linkBaseTexture||t.parentTextureArray||Object.keys(t._glTextures).length>0)if(t.resource)this.addResourceAt(t.resource,e);else throw new Error("CubeResource does not support copying of renderTexture.");else t.target=ui.TEXTURE_CUBE_MAP_POSITIVE_X+e,t.parentTextureArray=this.baseTexture,this.items[e]=t;return t.valid&&!this.valid&&this.resize(t.realWidth,t.realHeight),this.items[e]=t,this}upload(t,e,i){let s=this.itemDirtyIds;for(let o=0;o<fh.SIDES;o++){let n=this.items[o];(s[o]<n.dirtyId||i.dirtyId<e.dirtyId)&&(n.valid&&n.resource?(n.resource.upload(t,n,i),s[o]=n.dirtyId):s[o]<-1&&(t.gl.texImage2D(n.target,0,i.internalFormat,e.realWidth,e.realHeight,0,e.format,i.type,null),s[o]=-1))}return!0}static test(t){return Array.isArray(t)&&t.length===fh.SIDES}};OM.SIDES=6;var sy=OM;var ph=class r extends ue{constructor(t,e){e=e||{};let i,s,o;typeof t=="string"?(i=r.EMPTY,s=t,o=!0):(i=t,s=null,o=!1),super(i),this.url=s,this.crossOrigin=e.crossOrigin??!0,this.alphaMode=typeof e.alphaMode=="number"?e.alphaMode:null,this.ownsImageBitmap=e.ownsImageBitmap??o,this._load=null,e.autoLoad!==!1&&this.load()}load(){return this._load?this._load:(this._load=new Promise(async(t,e)=>{if(this.url===null){t(this);return}try{let i=await Y.ADAPTER.fetch(this.url,{mode:this.crossOrigin?"cors":"no-cors"});if(this.destroyed)return;let s=await i.blob();if(this.destroyed)return;let o=await createImageBitmap(s,{premultiplyAlpha:this.alphaMode===null||this.alphaMode===Qe.UNPACK?"premultiply":"none"});if(this.destroyed){o.close();return}this.source=o,this.update(),t(this)}catch(i){if(this.destroyed)return;e(i),this.onError.emit(i)}}),this._load)}upload(t,e,i){return this.source instanceof ImageBitmap?(typeof this.alphaMode=="number"&&(e.alphaMode=this.alphaMode),super.upload(t,e,i)):(this.load(),!1)}dispose(){this.ownsImageBitmap&&this.source instanceof ImageBitmap&&this.source.close(),super.dispose(),this._load=null}static test(t){return!!globalThis.createImageBitmap&&typeof ImageBitmap<"u"&&(typeof t=="string"||t instanceof ImageBitmap)}static get EMPTY(){return r._EMPTY=r._EMPTY??Y.ADAPTER.createCanvas(0,0),r._EMPTY}};var oy=class zd extends ue{constructor(t,e){e=e||{},super(Y.ADAPTER.createCanvas()),this._width=0,this._height=0,this.svg=t,this.scale=e.scale||1,this._overrideWidth=e.width,this._overrideHeight=e.height,this._resolve=null,this._crossorigin=e.crossorigin,this._load=null,e.autoLoad!==!1&&this.load()}load(){return this._load?this._load:(this._load=new Promise(t=>{if(this._resolve=()=>{this.update(),t(this)},zd.SVG_XML.test(this.svg.trim())){if(!btoa)throw new Error("Your browser doesn't support base64 conversions.");this.svg=`data:image/svg+xml;base64,${btoa(unescape(encodeURIComponent(this.svg)))}`}this._loadSvg()}),this._load)}_loadSvg(){let t=new Image;ue.crossOrigin(t,this.svg,this._crossorigin),t.src=this.svg,t.onerror=e=>{this._resolve&&(t.onerror=null,this.onError.emit(e))},t.onload=()=>{if(!this._resolve)return;let e=t.width,i=t.height;if(!e||!i)throw new Error("The SVG image must have width and height defined (in pixels), canvas API needs them.");let s=e*this.scale,o=i*this.scale;(this._overrideWidth||this._overrideHeight)&&(s=this._overrideWidth||this._overrideHeight/i*e,o=this._overrideHeight||this._overrideWidth/e*i),s=Math.round(s),o=Math.round(o);let n=this.source;n.width=s,n.height=o,n._pixiId=`canvas_${fi()}`,n.getContext("2d").drawImage(t,0,0,e,i,0,0,s,o),this._resolve(),this._resolve=null}}static getSize(t){let e=zd.SVG_SIZE.exec(t),i={};return e&&(i[e[1]]=Math.round(parseFloat(e[3])),i[e[5]]=Math.round(parseFloat(e[7]))),i}dispose(){super.dispose(),this._resolve=null,this._crossorigin=null}static test(t,e){return e==="svg"||typeof t=="string"&&t.startsWith("data:image/svg+xml")||typeof t=="string"&&zd.SVG_XML.test(t)}};oy.SVG_XML=/^(<\?xml[^?]+\?>)?\s*(<!--[^(-->)]*-->)?\s*\<svg/m,oy.SVG_SIZE=/<svg[^>]*(?:\s(width|height)=('|")(\d*(?:\.\d+)?)(?:px)?('|"))[^>]*(?:\s(width|height)=('|")(\d*(?:\.\d+)?)(?:px)?('|"))[^>]*>/i;var ny=oy;var $d=class extends ue{constructor(t){super(t)}static test(t){return!!globalThis.VideoFrame&&t instanceof globalThis.VideoFrame}};var ay=class ly extends ue{constructor(t,e){if(e=e||{},!(t instanceof HTMLVideoElement)){let i=document.createElement("video");e.autoLoad!==!1&&i.setAttribute("preload","auto"),e.playsinline!==!1&&(i.setAttribute("webkit-playsinline",""),i.setAttribute("playsinline","")),e.muted===!0&&(i.setAttribute("muted",""),i.muted=!0),e.loop===!0&&i.setAttribute("loop",""),e.autoPlay!==!1&&i.setAttribute("autoplay",""),typeof t=="string"&&(t=[t]);let s=t[0].src||t[0];ue.crossOrigin(i,s,e.crossorigin);for(let o=0;o<t.length;++o){let n=document.createElement("source"),{src:a,mime:l}=t[o];if(a=a||t[o],a.startsWith("data:"))l=a.slice(5,a.indexOf(";"));else if(!a.startsWith("blob:")){let h=a.split("?").shift().toLowerCase(),c=h.slice(h.lastIndexOf(".")+1);l=l||ly.MIME_TYPES[c]||`video/${c}`}n.src=a,l&&(n.type=l),i.appendChild(n)}t=i}super(t),this.noSubImage=!0,this._autoUpdate=!0,this._isConnectedToTicker=!1,this._updateFPS=e.updateFPS||0,this._msToNextUpdate=0,this.autoPlay=e.autoPlay!==!1,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._onError=this._onError.bind(this),this._onPlayStart=this._onPlayStart.bind(this),this._onPlayStop=this._onPlayStop.bind(this),this._onSeeked=this._onSeeked.bind(this),e.autoLoad!==!1&&this.load()}update(t=0){if(!this.destroyed){if(this._updateFPS){let e=xr.shared.elapsedMS*this.source.playbackRate;this._msToNextUpdate=Math.floor(this._msToNextUpdate-e)}(!this._updateFPS||this._msToNextUpdate<=0)&&(super.update(),this._msToNextUpdate=this._updateFPS?Math.floor(1e3/this._updateFPS):0)}}_videoFrameRequestCallback(){this.update(),this.destroyed?this._videoFrameRequestCallbackHandle=null:this._videoFrameRequestCallbackHandle=this.source.requestVideoFrameCallback(this._videoFrameRequestCallback)}load(){if(this._load)return this._load;let t=this.source;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._onCanPlay():(t.addEventListener("canplay",this._onCanPlay),t.addEventListener("canplaythrough",this._onCanPlay),t.addEventListener("error",this._onError,!0)),this._load=new Promise((e,i)=>{this.valid?e(this):(this._resolve=e,this._reject=i,t.load())}),this._load}_onError(t){this.source.removeEventListener("error",this._onError,!0),this.onError.emit(t),this._reject&&(this._reject(t),this._reject=null,this._resolve=null)}_isSourcePlaying(){let t=this.source;return!t.paused&&!t.ended}_isSourceReady(){return this.source.readyState>2}_onPlayStart(){this.valid||this._onCanPlay(),this._configureAutoUpdate()}_onPlayStop(){this._configureAutoUpdate()}_onSeeked(){this._autoUpdate&&!this._isSourcePlaying()&&(this._msToNextUpdate=0,this.update(),this._msToNextUpdate=0)}_onCanPlay(){let t=this.source;t.removeEventListener("canplay",this._onCanPlay),t.removeEventListener("canplaythrough",this._onCanPlay);let e=this.valid;this._msToNextUpdate=0,this.update(),this._msToNextUpdate=0,!e&&this._resolve&&(this._resolve(this),this._resolve=null,this._reject=null),this._isSourcePlaying()?this._onPlayStart():this.autoPlay&&t.play()}dispose(){this._configureAutoUpdate();let t=this.source;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._onCanPlay),t.removeEventListener("error",this._onError,!0),t.pause(),t.src="",t.load()),super.dispose()}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.source.requestVideoFrameCallback?(this._isConnectedToTicker&&(xr.shared.remove(this.update,this),this._isConnectedToTicker=!1,this._msToNextUpdate=0),this._videoFrameRequestCallbackHandle===null&&(this._videoFrameRequestCallbackHandle=this.source.requestVideoFrameCallback(this._videoFrameRequestCallback))):(this._videoFrameRequestCallbackHandle!==null&&(this.source.cancelVideoFrameCallback(this._videoFrameRequestCallbackHandle),this._videoFrameRequestCallbackHandle=null),this._isConnectedToTicker||(xr.shared.add(this.update,this),this._isConnectedToTicker=!0,this._msToNextUpdate=0)):(this._videoFrameRequestCallbackHandle!==null&&(this.source.cancelVideoFrameCallback(this._videoFrameRequestCallbackHandle),this._videoFrameRequestCallbackHandle=null),this._isConnectedToTicker&&(xr.shared.remove(this.update,this),this._isConnectedToTicker=!1,this._msToNextUpdate=0))}static test(t,e){return globalThis.HTMLVideoElement&&t instanceof HTMLVideoElement||ly.TYPES.includes(e)}};ay.TYPES=["mp4","m4v","webm","ogg","ogv","h264","avi","mov"],ay.MIME_TYPES={ogv:"video/ogg",mov:"video/quicktime",m4v:"video/mp4"};var hy=ay;Dl.push(ph,Bs,dh,hy,$d,ny,Ss,sy,uh);var vO={vec3(r,t,e,i){(e[0]!==i[0]||e[1]!==i[1]||e[2]!==i[2])&&(e[0]=i[0],e[1]=i[1],e[2]=i[2],r.uniform3f(t,i[0],i[1],i[2]))},int(r,t,e,i){r.uniform1i(t,i)},ivec2(r,t,e,i){r.uniform2i(t,i[0],i[1])},ivec3(r,t,e,i){r.uniform3i(t,i[0],i[1],i[2])},ivec4(r,t,e,i){r.uniform4i(t,i[0],i[1],i[2],i[3])},uint(r,t,e,i){r.uniform1ui(t,i)},uvec2(r,t,e,i){r.uniform2ui(t,i[0],i[1])},uvec3(r,t,e,i){r.uniform3ui(t,i[0],i[1],i[2])},uvec4(r,t,e,i){r.uniform4ui(t,i[0],i[1],i[2],i[3])},bvec2(r,t,e,i){r.uniform2i(t,i[0],i[1])},bvec3(r,t,e,i){r.uniform3i(t,i[0],i[1],i[2])},bvec4(r,t,e,i){r.uniform4i(t,i[0],i[1],i[2],i[3])},mat2(r,t,e,i){r.uniformMatrix2fv(t,!1,i)},mat4(r,t,e,i){r.uniformMatrix4fv(t,!1,i)}},TO={float(r,t,e,i){r.uniform1fv(t,i)},vec2(r,t,e,i){r.uniform2fv(t,i)},vec3(r,t,e,i){r.uniform3fv(t,i)},vec4(r,t,e,i){r.uniform4fv(t,i)},int(r,t,e,i){r.uniform1iv(t,i)},ivec2(r,t,e,i){r.uniform2iv(t,i)},ivec3(r,t,e,i){r.uniform3iv(t,i)},ivec4(r,t,e,i){r.uniform4iv(t,i)},uint(r,t,e,i){r.uniform1uiv(t,i)},uvec2(r,t,e,i){r.uniform2uiv(t,i)},uvec3(r,t,e,i){r.uniform3uiv(t,i)},uvec4(r,t,e,i){r.uniform4uiv(t,i)},bool(r,t,e,i){r.uniform1iv(t,i)},bvec2(r,t,e,i){r.uniform2iv(t,i)},bvec3(r,t,e,i){r.uniform3iv(t,i)},bvec4(r,t,e,i){r.uniform4iv(t,i)},sampler2D(r,t,e,i){r.uniform1iv(t,i)},samplerCube(r,t,e,i){r.uniform1iv(t,i)},sampler2DArray(r,t,e,i){r.uniform1iv(t,i)}};function LM(r,t,e,i,s){let o=0,n=null,a=null,l=s.gl;for(let h in r.uniforms){let c=t[h],u=i[h],d=e[h],f=r.uniforms[h];if(!c){f.group===!0&&s.shader.syncUniformGroup(u);continue}c.type==="float"&&c.size===1&&!c.isArray?u!==d.value&&(d.value=u,l.uniform1f(d.location,u)):c.type==="bool"&&c.size===1&&!c.isArray?u!==d.value&&(d.value=u,l.uniform1i(d.location,Number(u))):(c.type==="sampler2D"||c.type==="samplerCube"||c.type==="sampler2DArray")&&c.size===1&&!c.isArray?(s.texture.bind(u,o),d.value!==o&&(d.value=o,l.uniform1i(d.location,o)),o++):c.type==="mat3"&&c.size===1&&!c.isArray?f.a!==void 0?l.uniformMatrix3fv(d.location,!1,u.toArray(!0)):l.uniformMatrix3fv(d.location,!1,u):c.type==="vec2"&&c.size===1&&!c.isArray?f.x!==void 0?(a=d.value,n=u,(a[0]!==n.x||a[1]!==n.y)&&(a[0]=n.x,a[1]=n.y,l.uniform2f(d.location,n.x,n.y))):(a=d.value,n=u,(a[0]!==n[0]||a[1]!==n[1])&&(a[0]=n[0],a[1]=n[1],l.uniform2f(d.location,n[0],n[1]))):c.type==="vec4"&&c.size===1&&!c.isArray?f.width!==void 0?(a=d.value,n=u,(a[0]!==n.x||a[1]!==n.y||a[2]!==n.width||a[3]!==n.height)&&(a[0]=n.x,a[1]=n.y,a[2]=n.width,a[3]=n.height,l.uniform4f(d.location,n.x,n.y,n.width,n.height))):(a=d.value,n=u,(a[0]!==n[0]||a[1]!==n[1]||a[2]!==n[2]||a[3]!==n[3])&&(a[0]=n[0],a[1]=n[1],a[2]=n[2],a[3]=n[3],l.uniform4f(d.location,n[0],n[1],n[2],n[3]))):(c.size===1&&!c.isArray?vO:TO)[c.type].call(null,l,d.location,d.value,u)}}function SO(){Object.assign(Wi.prototype,{systemCheck(){},syncUniforms(r,t){let{shader:e,renderer:i}=this;LM(r,e.program.uniformData,t.uniformData,r.uniforms,i)}})}SO();var mh=new(window.AudioContext||window.webkitAudioContext),EO=(r,t)=>{let e,i=mh.createGain();i.gain.value=t.volume??1,i.connect(mh.destination);let s={id:r,url:t.url,loop:t.loop||!1,volume:t.volume??1};return{play:()=>{let m=No.getAsset(s.url);if(!m){console.warn("AudioPlayer.play: Asset not found",s.url);return}e=mh.createBufferSource(),e.buffer=m,e.loop=s.loop,i.gain.setValueAtTime(s.volume,mh.currentTime),e.connect(i),e.start(0)},stop:()=>{e&&(e.stop(),e.disconnect(),i.disconnect(),i.connect(mh.destination))},update:m=>{s={...s,...m}},getId:()=>s.id,getUrl:()=>s.url,getLoop:()=>s.loop,getVolume:()=>s.volume,setUrl:m=>{s.url=m},setLoop:m=>{s.loop=m},setVolume:m=>{s.volume=m,i.gain.value=m},id:s.id,url:s.url,loop:s.loop,volume:s.volume,gainNode:i}},DM=()=>{let r=[],t=[];return{add:a=>{t.push(a)},remove:a=>{t=t.filter(l=>l.id!==a)},getById:a=>t.find(l=>l.id===a),tick:()=>{for(let l of t){let h=r.find(c=>c.id===l.id);if(!h){let c=EO(l.id,{url:l.url,loop:l.loop,volume:l.volume??1});r.push(c),c.play();return}(h.url!==l.url||h.loop!==l.loop)&&(h.stop(),h.setUrl(l.url),h.setLoop(l.loop??!1),h.play()),h.getVolume()!==(l.volume??1)&&h.setVolume(l.volume??1)}let a=[];for(let l of r)t.find(h=>h.id===l.id)||(l.stop(),a.push(l.id));r=r.filter(l=>!a.includes(l.id))},destroy:()=>{for(let a of r)a.stop();r=[],t=[]}}};var wO=({JSONObject:r,parserPlugins:t=[]})=>r.map(i=>{let s=t.find(o=>o.type===i.type);return s?s.parse({state:i,parserPlugins:t}):r}),cy=wO;var NM=({type:r,parse:t})=>({type:r,parse:t});var uy=typeof navigator<"u"?navigator.userAgent.toLowerCase().indexOf("firefox")>0:!1;function dy(r,t,e,i){r.addEventListener?r.addEventListener(t,e,i):r.attachEvent&&r.attachEvent(`on${t}`,e)}function gh(r,t,e,i){r&&(r.removeEventListener?r.removeEventListener(t,e,i):r.detachEvent&&r.detachEvent(`on${t}`,e))}function WM(r,t){let e=t.slice(0,t.length-1),i=[];for(let s=0;s<e.length;s++)i.push(r[e[s].toLowerCase()]);return i}function zM(r){typeof r!="string"&&(r=""),r=r.replace(/\s/g,"");let t=r.split(","),e=t.lastIndexOf("");for(;e>=0;)t[e-1]+=",",t.splice(e,1),e=t.lastIndexOf("");return t}function AO(r,t){let e=r.length>=t.length?r:t,i=r.length>=t.length?t:r,s=!0;for(let o=0;o<e.length;o++)i.indexOf(e[o])===-1&&(s=!1);return s}function $M(r){let t=r.keyCode||r.which||r.charCode;return r.code&&/^Key[A-Z]$/.test(r.code)&&(t=r.code.charCodeAt(3)),t}var _h={backspace:8,"\u232B":8,tab:9,clear:12,enter:13,"\u21A9":13,return:13,esc:27,escape:27,space:32,left:37,up:38,right:39,down:40,arrowup:38,arrowdown:40,arrowleft:37,arrowright:39,del:46,delete:46,ins:45,insert:45,home:36,end:35,pageup:33,pagedown:34,capslock:20,num_0:96,num_1:97,num_2:98,num_3:99,num_4:100,num_5:101,num_6:102,num_7:103,num_8:104,num_9:105,num_multiply:106,num_add:107,num_enter:108,num_subtract:109,num_decimal:110,num_divide:111,"\u21EA":20,",":188,".":190,"/":191,"`":192,"-":uy?173:189,"=":uy?61:187,";":uy?59:186,"'":222,"{":219,"}":221,"[":219,"]":221,"\\":220},Mr={"\u21E7":16,shift:16,"\u2325":18,alt:18,option:18,"\u2303":17,ctrl:17,control:17,"\u2318":91,cmd:91,meta:91,command:91},xh={16:"shiftKey",18:"altKey",17:"ctrlKey",91:"metaKey",shiftKey:16,ctrlKey:17,altKey:18,metaKey:91},Te={16:!1,18:!1,17:!1,91:!1},zt={};for(let r=1;r<20;r++)_h[`f${r}`]=111+r;var Lt=[],yh=null,XM="all",vi=new Map,Sn=r=>_h[r.toLowerCase()]||Mr[r.toLowerCase()]||r.toUpperCase().charCodeAt(0),PO=r=>Object.keys(_h).find(t=>_h[t]===r),CO=r=>Object.keys(Mr).find(t=>Mr[t]===r),jM=r=>{XM=r||"all"},bh=()=>XM||"all",RO=()=>Lt.slice(0),MO=()=>Lt.map(r=>PO(r)||CO(r)||String.fromCharCode(r)),BO=()=>{let r=[];return Object.keys(zt).forEach(t=>{zt[t].forEach(({key:e,scope:i,mods:s,shortcut:o})=>{r.push({scope:i,shortcut:o,mods:s,keys:e.split("+").map(n=>Sn(n))})})}),r},YM=r=>{let t=r.target||r.srcElement,{tagName:e}=t,i=!0,s=e==="INPUT"&&!["checkbox","radio","range","button","file","reset","submit","color"].includes(t.type);return(t.isContentEditable||(s||e==="TEXTAREA"||e==="SELECT")&&!t.readOnly)&&(i=!1),i},IO=r=>(typeof r=="string"&&(r=Sn(r)),Lt.indexOf(r)!==-1),FO=(r,t)=>{let e,i;r||(r=bh());for(let s in zt)if(Object.prototype.hasOwnProperty.call(zt,s))for(e=zt[s],i=0;i<e.length;)e[i].scope===r?e.splice(i,1).forEach(({element:o})=>py(o)):i++;bh()===r&&jM(t||"all")};function kO(r){let t=$M(r);r.key&&r.key.toLowerCase()==="capslock"&&(t=Sn(r.key));let e=Lt.indexOf(t);if(e>=0&&Lt.splice(e,1),r.key&&r.key.toLowerCase()==="meta"&&Lt.splice(0,Lt.length),(t===93||t===224)&&(t=91),t in Te){Te[t]=!1;for(let i in Mr)Mr[i]===t&&(yr[i]=!1)}}var qM=(r,...t)=>{if(typeof r>"u")Object.keys(zt).forEach(e=>{Array.isArray(zt[e])&&zt[e].forEach(i=>Xd(i)),delete zt[e]}),py(null);else if(Array.isArray(r))r.forEach(e=>{e.key&&Xd(e)});else if(typeof r=="object")r.key&&Xd(r);else if(typeof r=="string"){let[e,i]=t;typeof e=="function"&&(i=e,e=""),Xd({key:r,scope:e,method:i,splitKey:"+"})}},Xd=({key:r,scope:t,method:e,splitKey:i="+"})=>{zM(r).forEach(s=>{let o=s.split(i),n=o.length,a=o[n-1],l=a==="*"?"*":Sn(a);if(!zt[l])return;t||(t=bh());let h=n>1?WM(Mr,o):[],c=[];zt[l]=zt[l].filter(u=>{let d=(e?u.method===e:!0)&&u.scope===t&&AO(u.mods,h);return d&&c.push(u.element),!d}),c.forEach(u=>py(u))})};function HM(r,t,e,i){if(t.element!==i)return;let s;if(t.scope===e||t.scope==="all"){s=t.mods.length>0;for(let o in Te)Object.prototype.hasOwnProperty.call(Te,o)&&(!Te[o]&&t.mods.indexOf(+o)>-1||Te[o]&&t.mods.indexOf(+o)===-1)&&(s=!1);(t.mods.length===0&&!Te[16]&&!Te[18]&&!Te[17]&&!Te[91]||s||t.shortcut==="*")&&(t.keys=[],t.keys=t.keys.concat(Lt),t.method(r,t)===!1&&(r.preventDefault?r.preventDefault():r.returnValue=!1,r.stopPropagation&&r.stopPropagation(),r.cancelBubble&&(r.cancelBubble=!0)))}}function VM(r,t){let e=zt["*"],i=$M(r);if(r.key&&r.key.toLowerCase()==="capslock"||!(yr.filter||YM).call(this,r))return;if((i===93||i===224)&&(i=91),Lt.indexOf(i)===-1&&i!==229&&Lt.push(i),["metaKey","ctrlKey","altKey","shiftKey"].forEach(a=>{let l=xh[a];r[a]&&Lt.indexOf(l)===-1?Lt.push(l):!r[a]&&Lt.indexOf(l)>-1?Lt.splice(Lt.indexOf(l),1):a==="metaKey"&&r[a]&&(Lt=Lt.filter(h=>h in xh||h===i))}),i in Te){Te[i]=!0;for(let a in Mr)if(Object.prototype.hasOwnProperty.call(Mr,a)){let l=xh[Mr[a]];yr[a]=r[l]}if(!e)return}for(let a in Te)Object.prototype.hasOwnProperty.call(Te,a)&&(Te[a]=r[xh[a]]);r.getModifierState&&!(r.altKey&&!r.ctrlKey)&&r.getModifierState("AltGraph")&&(Lt.indexOf(17)===-1&&Lt.push(17),Lt.indexOf(18)===-1&&Lt.push(18),Te[17]=!0,Te[18]=!0);let s=bh();if(e)for(let a=0;a<e.length;a++)e[a].scope===s&&(r.type==="keydown"&&e[a].keydown||r.type==="keyup"&&e[a].keyup)&&HM(r,e[a],s,t);if(!(i in zt))return;let o=zt[i],n=o.length;for(let a=0;a<n;a++)if((r.type==="keydown"&&o[a].keydown||r.type==="keyup"&&o[a].keyup)&&o[a].key){let l=o[a],{splitKey:h}=l,c=l.key.split(h),u=[];for(let d=0;d<c.length;d++)u.push(Sn(c[d]));u.sort().join("")===Lt.sort().join("")&&HM(r,l,s,t)}}var yr=function(r,t,e){Lt=[];let i=zM(r),s=[],o="all",n=document,a=0,l=!1,h=!0,c="+",u=!1,d=!1;if(e===void 0&&typeof t=="function"&&(e=t),Object.prototype.toString.call(t)==="[object Object]"){let f=t;f.scope&&(o=f.scope),f.element&&(n=f.element),f.keyup&&(l=f.keyup),f.keydown!==void 0&&(h=f.keydown),f.capture!==void 0&&(u=f.capture),typeof f.splitKey=="string"&&(c=f.splitKey),f.single===!0&&(d=!0)}for(typeof t=="string"&&(o=t),d&&qM(r,o);a<i.length;a++){let f=i[a].split(c);s=[],f.length>1&&(s=WM(Mr,f));let p=f[f.length-1];p=p==="*"?"*":Sn(p),p in zt||(zt[p]=[]),zt[p].push({keyup:l,keydown:h,scope:o,mods:s,shortcut:i[a],method:e,key:i[a],splitKey:c,element:n})}if(typeof n<"u"&&typeof window<"u"){if(!vi.has(n)){let f=(m=window.event)=>VM(m,n),p=(m=window.event)=>{VM(m,n),kO(m)};vi.set(n,{keydownListener:f,keyupListenr:p,capture:u}),dy(n,"keydown",f,u),dy(n,"keyup",p,u)}if(!yh){let f=()=>{Lt=[]};yh={listener:f,capture:u},dy(window,"focus",f,u)}}};function GO(r,t="all"){Object.keys(zt).forEach(e=>{zt[e].filter(i=>i.scope===t&&i.shortcut===r).forEach(i=>{i&&i.method&&i.method({},i)})})}function py(r){let t=Object.values(zt).flat();if(t.findIndex(({element:e})=>e===r)<0&&r){let{keydownListener:e,keyupListenr:i,capture:s}=vi.get(r)||{};e&&i&&(gh(r,"keyup",i,s),gh(r,"keydown",e,s),vi.delete(r))}if((t.length<=0||vi.size<=0)&&(Array.from(vi.keys()).forEach(e=>{let{keydownListener:i,keyupListenr:s,capture:o}=vi.get(e)||{};i&&s&&(gh(e,"keyup",s,o),gh(e,"keydown",i,o),vi.delete(e))}),vi.clear(),Object.keys(zt).forEach(e=>delete zt[e]),yh)){let{listener:e,capture:i}=yh;gh(window,"focus",e,i),yh=null}}var fy={getPressedKeyString:MO,setScope:jM,getScope:bh,deleteScope:FO,getPressedKeyCodes:RO,getAllKeyCodes:BO,isPressed:IO,filter:YM,trigger:GO,unbind:qM,keyMap:_h,modifier:Mr,modifierMap:xh};for(let r in fy){let t=r;Object.prototype.hasOwnProperty.call(fy,t)&&(yr[t]=fy[t])}if(typeof window<"u"){let r=window.hotkeys;yr.noConflict=t=>(t&&window.hotkeys===yr&&(window.hotkeys=r),yr),window.hotkeys=yr}var KM=r=>{let t=new Map;return{registerHotkeys:(i={})=>{if(typeof i!="object"||i===null)return;let s=[],o=[],n=[];Object.keys(i).forEach(a=>{let l=t.get(a);l?JSON.stringify(l.payload)!==JSON.stringify(i[a].actionPayload)&&(o.push(a),yr.unbind(a)):s.push(a)}),t.forEach((a,l)=>{i.hasOwnProperty(l)||n.push(l)}),n.forEach(a=>{yr.unbind(a),t.delete(a)}),[...s,...o].forEach(a=>{let h=i[a].actionPayload??{};yr(a,()=>{r&&r("keydown",{_event:{key:a},...h})}),t.set(a,{value:a,payload:h})})}}};var UO=r=>r.split("/").pop(),OO=r=>({name:"advancedBufferLoader",priority:2,bufferMap:r,load:async t=>{let e=t.startsWith("file:")?t:UO(t),i=r[e];if(!i)throw new Error(`Buffer not found for key: ${e}`);return{data:i.buffer,type:i.type,metadata:null}},test:async t=>!0,testParse:async t=>!0,parse:async t=>{if(t instanceof w)return t;let e=new Blob([t.data],{type:t.type}),i=await createImageBitmap(e);return new w.from(i)},unload:async t=>t.destroy(!0)}),LO=()=>{let r,t=DM(),e={elements:[],animations:[],audio:[]},i,s={animations:[],elements:[],audio:[],parsers:[]},o,n,a=!1,l,h=f=>f?f.startsWith("audio/")?"audio":f.startsWith("font/")||["application/font-woff","application/font-woff2","application/x-font-ttf","application/x-font-otf"].includes(f)?"font":f.startsWith("video/")?"video":"texture":"texture",c=(f,p,m)=>{o&&o.registerHotkeys(m?.keyboard??{}),f.renderer.events.cursorStyles||(f.renderer.events.cursorStyles={}),f.renderer.events.cursorStyles.default||(f.renderer.events.cursorStyles.default="default"),f.renderer.events.cursorStyles.hover||(f.renderer.events.cursorStyles.hover="pointer");let g=p?.cursorStyles,_=m?.cursorStyles;JSON.stringify(g)!==JSON.stringify(_)&&(_?(_.default&&(f.renderer.events.cursorStyles.default=_.default,f.canvas.style.cursor=_.default),_.hover&&(f.renderer.events.cursorStyles.hover=_.hover)):g&&(f.renderer.events.cursorStyles.default="default",f.renderer.events.cursorStyles.hover="pointer"))},u=async(f,p,m,g)=>{c(f,e.global,m.global),n&&a&&n.abort(),n=new AbortController;let _=n.signal;for(;a;)await new Promise(y=>setTimeout(y,0));a=!0,await bl({app:f,parent:p,prevASTTree:e.elements,nextASTTree:m.elements,animations:m.animations,elementPlugins:s.elements,animationPlugins:s.animations,eventHandler:g,signal:_}),await $g({app:f,prevAudioTree:e.audio,nextAudioTree:m.audio,audioPlugins:s.audio,signal:_}),a=!1,e=m},d={rendererName:"pixi",get canvas(){return r.canvas},findElementByLabel:f=>{if(r.stage.children&&r.stage.children.length>0)for(let p of r.stage.children){let m=findElementByLabel(p,f);if(m)return m}return null},extractBase64:async f=>{let p=(void 0).findElementByLabel(f);if(!p)throw new Error(`Element with label '${f}' not found`);await r.renderer.extract.base64(p)},assignStageEvent:(f,p)=>{r.stage.eventMode="static",r.stage.on(f,p)},init:async f=>{let{eventHandler:p,plugins:m,width:g,height:_,backgroundColor:y,debug:b=!1}=f,T=[];m?.elements?.forEach(S=>{S?.parse&&T.push(NM({type:S.type,parse:S.parse}))}),s={animations:m.animations??[],elements:m.elements??[],audio:m.audio??[],parsers:T},i=p,o=KM(p),r=new ml,r.audioStage=t,await r.init({width:g,height:_,backgroundColor:y,preference:"webgl"}),r.debug=b;let E=new le;return E.rect(0,0,g,_),E.fill(y||0),r.stage.addChild(E),r.stage.width=g,r.stage.height=_,r.ticker.add(r.audioStage.tick),d},destroy:()=>{r.audioStage.destroy(),r.destroy()},loadAssets:async f=>{if(!f)throw new Error("assetBufferMap is required");let p={audio:{},font:{},video:{},texture:{}};for(let[g,_]of Object.entries(f)){let y=h(_.type);p[y][g]=_}await Promise.all(Object.entries(p.audio).map(([g,_])=>No.load(g,_.buffer))),await Promise.all(Object.entries(p.font).map(async([g,_])=>{let y=new Blob([_.buffer],{type:_.type}),b=URL.createObjectURL(y),T=new FontFace(g,`url(${b})`);try{await T.load(),document.fonts.add(T)}catch(E){console.error(`Failed to load font ${g}:`,E)}finally{URL.revokeObjectURL(b)}})),l?Object.assign(l.bufferMap,p.texture):(l=OO(p.texture),ur.loader.parsers.length=0,ur.reset(),k.add({name:"advanced-buffer-loader",extension:v.Asset,priority:pe.High,loader:l}),typeof ur.registerPlugin=="function"&&ur.registerPlugin(l));let m=Object.keys(p.texture);return Promise.all(m.map(g=>ur.load(g)))},loadAudioAssets:async f=>Promise.all(f.map(async p=>{let g=await(await fetch(p)).arrayBuffer();return No.load(p,g)})),updatedBackgroundColor:f=>{r.renderer.background.color=f},render:f=>{let p=cy({JSONObject:f.elements,parserPlugins:s.parsers}),m={...f,elements:p};u(r,r.stage,m,i)},parse:f=>{let p=cy({JSONObject:f.elements,parserPlugins:s.parsers});return{...f,elements:p}}};return d},ZM=LO;var HSt=ZM;export{ml as Application,ur as Assets,No as AudioAsset,ms as Emitter,ps as Particle,Gk as animatedSpritePlugin,Bk as containerPlugin,kg as createAnimationPlugin,nB as createAssetBufferManager,Gg as createAudioPlugin,he as createElementPlugin,HSt as default,RP as loadParticlePresets,e2 as particlesPlugin,Ak as rectPlugin,xe as registerParticleBehavior,ci as registerParticlePreset,Tl as registerParticleTexture,$g as renderAudio,bl as renderElements,Rk as sliderPlugin,zk as soundPlugin,Pk as spritePlugin,wk as textPlugin,kk as textRevealingPlugin,Wk as tweenPlugin,Ck as videoPlugin};
|
|
1628
|
+
`))}}var fO=0,Dd={textureCount:0,uboCount:0},Wi=class{constructor(t){this.destroyed=!1,this.renderer=t,this.systemCheck(),this.gl=null,this.shader=null,this.program=null,this.cache={},this._uboCache={},this.id=fO++}systemCheck(){if(!kd())throw new Error("Current environment does not allow unsafe-eval, please use @pixi/unsafe-eval module to enable support.")}contextChange(t){this.gl=t,this.reset()}bind(t,e){t.disposeRunner.add(this),t.uniforms.globals=this.renderer.globalUniforms;let i=t.program,s=i.glPrograms[this.renderer.CONTEXT_UID]||this.generateProgram(t);return this.shader=t,this.program!==i&&(this.program=i,this.gl.useProgram(s.program)),e||(Dd.textureCount=0,Dd.uboCount=0,this.syncUniformGroup(t.uniformGroup,Dd)),s}setUniforms(t){let e=this.shader.program,i=e.glPrograms[this.renderer.CONTEXT_UID];e.syncUniforms(i.uniformData,t,this.renderer)}syncUniformGroup(t,e){let i=this.getGlProgram();(!t.static||t.dirtyId!==i.uniformDirtyGroups[t.id])&&(i.uniformDirtyGroups[t.id]=t.dirtyId,this.syncUniforms(t,i,e))}syncUniforms(t,e,i){(t.syncUniforms[this.shader.program.id]||this.createSyncGroups(t))(e.uniformData,t.uniforms,this.renderer,i)}createSyncGroups(t){let e=this.getSignature(t,this.shader.program.uniformData,"u");return this.cache[e]||(this.cache[e]=$x(t,this.shader.program.uniformData)),t.syncUniforms[this.shader.program.id]=this.cache[e],t.syncUniforms[this.shader.program.id]}syncUniformBufferGroup(t,e){let i=this.getGlProgram();if(!t.static||t.dirtyId!==0||!i.uniformGroups[t.id]){t.dirtyId=0;let s=i.uniformGroups[t.id]||this.createSyncBufferGroup(t,i,e);t.buffer.update(),s(i.uniformData,t.uniforms,this.renderer,Dd,t.buffer)}this.renderer.buffer.bindBufferBase(t.buffer,i.uniformBufferBindings[e])}createSyncBufferGroup(t,e,i){let{gl:s}=this.renderer;this.renderer.buffer.bind(t.buffer);let o=this.gl.getUniformBlockIndex(e.program,i);e.uniformBufferBindings[i]=this.shader.uniformBindCount,s.uniformBlockBinding(e.program,o,this.shader.uniformBindCount),this.shader.uniformBindCount++;let n=this.getSignature(t,this.shader.program.uniformData,"ubo"),a=this._uboCache[n];if(a||(a=this._uboCache[n]=ty(t,this.shader.program.uniformData)),t.autoManage){let l=new Float32Array(a.size/4);t.buffer.update(l)}return e.uniformGroups[t.id]=a.syncFunc,e.uniformGroups[t.id]}getSignature(t,e,i){let s=t.uniforms,o=[`${i}-`];for(let n in s)o.push(n),e[n]&&o.push(e[n].type);return o.join("-")}getGlProgram(){return this.shader?this.shader.program.glPrograms[this.renderer.CONTEXT_UID]:null}generateProgram(t){let e=this.gl,i=t.program,s=Jx(e,i);return i.glPrograms[this.renderer.CONTEXT_UID]=s,s}reset(){this.program=null,this.shader=null}disposeShader(t){this.shader===t&&(this.shader=null)}destroy(){this.renderer=null,this.destroyed=!0}};Wi.extension={type:V.RendererSystem,name:"shader"};q.add(Wi);var _i=class{constructor(t){this.renderer=t}run(t){let{renderer:e}=this;e.runners.init.emit(e.options),t.hello&&console.log(`PixiJS 7.4.3 - ${e.rendererLogId} - https://pixijs.com`),e.resize(e.screen.width,e.screen.height)}destroy(){}};_i.defaultOptions={hello:!1},_i.extension={type:[V.RendererSystem,V.CanvasRendererSystem],name:"startup"};q.add(_i);function IM(r,t=[]){return t[Z.NORMAL]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[Z.ADD]=[r.ONE,r.ONE],t[Z.MULTIPLY]=[r.DST_COLOR,r.ONE_MINUS_SRC_ALPHA,r.ONE,r.ONE_MINUS_SRC_ALPHA],t[Z.SCREEN]=[r.ONE,r.ONE_MINUS_SRC_COLOR,r.ONE,r.ONE_MINUS_SRC_ALPHA],t[Z.OVERLAY]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[Z.DARKEN]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[Z.LIGHTEN]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[Z.COLOR_DODGE]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[Z.COLOR_BURN]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[Z.HARD_LIGHT]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[Z.SOFT_LIGHT]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[Z.DIFFERENCE]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[Z.EXCLUSION]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[Z.HUE]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[Z.SATURATION]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[Z.COLOR]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[Z.LUMINOSITY]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[Z.NONE]=[0,0],t[Z.NORMAL_NPM]=[r.SRC_ALPHA,r.ONE_MINUS_SRC_ALPHA,r.ONE,r.ONE_MINUS_SRC_ALPHA],t[Z.ADD_NPM]=[r.SRC_ALPHA,r.ONE,r.ONE,r.ONE],t[Z.SCREEN_NPM]=[r.SRC_ALPHA,r.ONE_MINUS_SRC_COLOR,r.ONE,r.ONE_MINUS_SRC_ALPHA],t[Z.SRC_IN]=[r.DST_ALPHA,r.ZERO],t[Z.SRC_OUT]=[r.ONE_MINUS_DST_ALPHA,r.ZERO],t[Z.SRC_ATOP]=[r.DST_ALPHA,r.ONE_MINUS_SRC_ALPHA],t[Z.DST_OVER]=[r.ONE_MINUS_DST_ALPHA,r.ONE],t[Z.DST_IN]=[r.ZERO,r.SRC_ALPHA],t[Z.DST_OUT]=[r.ZERO,r.ONE_MINUS_SRC_ALPHA],t[Z.DST_ATOP]=[r.ONE_MINUS_DST_ALPHA,r.SRC_ALPHA],t[Z.XOR]=[r.ONE_MINUS_DST_ALPHA,r.ONE_MINUS_SRC_ALPHA],t[Z.SUBTRACT]=[r.ONE,r.ONE,r.ONE,r.ONE,r.FUNC_REVERSE_SUBTRACT,r.FUNC_ADD],t}var pO=0,mO=1,gO=2,xO=3,yO=4,_O=5,FM=class ey{constructor(){this.gl=null,this.stateId=0,this.polygonOffset=0,this.blendMode=Z.NONE,this._blendEq=!1,this.map=[],this.map[pO]=this.setBlend,this.map[mO]=this.setOffset,this.map[gO]=this.setCullFace,this.map[xO]=this.setDepthTest,this.map[yO]=this.setFrontFace,this.map[_O]=this.setDepthMask,this.checks=[],this.defaultState=new Yr,this.defaultState.blend=!0}contextChange(t){this.gl=t,this.blendModes=IM(t),this.set(this.defaultState),this.reset()}set(t){if(t=t||this.defaultState,this.stateId!==t.data){let e=this.stateId^t.data,i=0;for(;e;)e&1&&this.map[i].call(this,!!(t.data&1<<i)),e=e>>1,i++;this.stateId=t.data}for(let e=0;e<this.checks.length;e++)this.checks[e](this,t)}forceState(t){t=t||this.defaultState;for(let e=0;e<this.map.length;e++)this.map[e].call(this,!!(t.data&1<<e));for(let e=0;e<this.checks.length;e++)this.checks[e](this,t);this.stateId=t.data}setBlend(t){this.updateCheck(ey.checkBlendMode,t),this.gl[t?"enable":"disable"](this.gl.BLEND)}setOffset(t){this.updateCheck(ey.checkPolygonOffset,t),this.gl[t?"enable":"disable"](this.gl.POLYGON_OFFSET_FILL)}setDepthTest(t){this.gl[t?"enable":"disable"](this.gl.DEPTH_TEST)}setDepthMask(t){this.gl.depthMask(t)}setCullFace(t){this.gl[t?"enable":"disable"](this.gl.CULL_FACE)}setFrontFace(t){this.gl.frontFace(this.gl[t?"CW":"CCW"])}setBlendMode(t){if(t===this.blendMode)return;this.blendMode=t;let e=this.blendModes[t],i=this.gl;e.length===2?i.blendFunc(e[0],e[1]):i.blendFuncSeparate(e[0],e[1],e[2],e[3]),e.length===6?(this._blendEq=!0,i.blendEquationSeparate(e[4],e[5])):this._blendEq&&(this._blendEq=!1,i.blendEquationSeparate(i.FUNC_ADD,i.FUNC_ADD))}setPolygonOffset(t,e){this.gl.polygonOffset(t,e)}reset(){this.gl.pixelStorei(this.gl.UNPACK_FLIP_Y_WEBGL,!1),this.forceState(this.defaultState),this._blendEq=!0,this.blendMode=-1,this.setBlendMode(0)}updateCheck(t,e){let i=this.checks.indexOf(t);e&&i===-1?this.checks.push(t):!e&&i!==-1&&this.checks.splice(i,1)}static checkBlendMode(t,e){t.setBlendMode(e.blendMode)}static checkPolygonOffset(t,e){t.setPolygonOffset(1,e.polygonOffset)}destroy(){this.gl=null}};FM.extension={type:V.RendererSystem,name:"state"};var ry=FM;q.add(ry);var _n=class extends Ts.default{constructor(){super(...arguments),this.runners={},this._systemsHash={}}setup(t){this.addRunners(...t.runners);let e=(t.priority??[]).filter(s=>t.systems[s]),i=[...e,...Object.keys(t.systems).filter(s=>!e.includes(s))];for(let s of i)this.addSystem(t.systems[s],s)}addRunners(...t){t.forEach(e=>{this.runners[e]=new Kt(e)})}addSystem(t,e){let 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(let s in this.runners)this.runners[s].add(i);return this}emitWithCustomOptions(t,e){let i=Object.keys(this._systemsHash);t.items.forEach(s=>{let o=i.find(n=>this._systemsHash[n]===s);s[t.name](e[o])})}destroy(){Object.values(this.runners).forEach(t=>{t.destroy()}),this._systemsHash={}}};var nh=class Nd{constructor(t){this.renderer=t,this.count=0,this.checkCount=0,this.maxIdle=Nd.defaultMaxIdle,this.checkCountMax=Nd.defaultCheckCountMax,this.mode=Nd.defaultMode}postrender(){this.renderer.objectRenderer.renderingToScreen&&(this.count++,this.mode!==Qu.MANUAL&&(this.checkCount++,this.checkCount>this.checkCountMax&&(this.checkCount=0,this.run())))}run(){let t=this.renderer.texture,e=t.managedTextures,i=!1;for(let s=0;s<e.length;s++){let o=e[s];o.resource&&this.count-o.touched>this.maxIdle&&(t.destroyTexture(o,!0),e[s]=null,i=!0)}if(i){let s=0;for(let o=0;o<e.length;o++)e[o]!==null&&(e[s++]=e[o]);e.length=s}}unload(t){let e=this.renderer.texture,i=t._texture;i&&!i.framebuffer&&e.destroyTexture(i);for(let s=t.children.length-1;s>=0;s--)this.unload(t.children[s])}destroy(){this.renderer=null}};nh.defaultMode=Qu.AUTO,nh.defaultMaxIdle=60*60,nh.defaultCheckCountMax=60*10,nh.extension={type:V.RendererSystem,name:"textureGC"};var Zr=nh;q.add(Zr);var Gs=class{constructor(t){this.texture=t,this.width=-1,this.height=-1,this.dirtyId=-1,this.dirtyStyleId=-1,this.mipmap=!1,this.wrapMode=33071,this.type=it.UNSIGNED_BYTE,this.internalFormat=G.RGBA,this.samplerType=0}};function kM(r){let t;return"WebGL2RenderingContext"in globalThis&&r instanceof globalThis.WebGL2RenderingContext?t={[r.RGB]:N.FLOAT,[r.RGBA]:N.FLOAT,[r.ALPHA]:N.FLOAT,[r.LUMINANCE]:N.FLOAT,[r.LUMINANCE_ALPHA]:N.FLOAT,[r.R8]:N.FLOAT,[r.R8_SNORM]:N.FLOAT,[r.RG8]:N.FLOAT,[r.RG8_SNORM]:N.FLOAT,[r.RGB8]:N.FLOAT,[r.RGB8_SNORM]:N.FLOAT,[r.RGB565]:N.FLOAT,[r.RGBA4]:N.FLOAT,[r.RGB5_A1]:N.FLOAT,[r.RGBA8]:N.FLOAT,[r.RGBA8_SNORM]:N.FLOAT,[r.RGB10_A2]:N.FLOAT,[r.RGB10_A2UI]:N.FLOAT,[r.SRGB8]:N.FLOAT,[r.SRGB8_ALPHA8]:N.FLOAT,[r.R16F]:N.FLOAT,[r.RG16F]:N.FLOAT,[r.RGB16F]:N.FLOAT,[r.RGBA16F]:N.FLOAT,[r.R32F]:N.FLOAT,[r.RG32F]:N.FLOAT,[r.RGB32F]:N.FLOAT,[r.RGBA32F]:N.FLOAT,[r.R11F_G11F_B10F]:N.FLOAT,[r.RGB9_E5]:N.FLOAT,[r.R8I]:N.INT,[r.R8UI]:N.UINT,[r.R16I]:N.INT,[r.R16UI]:N.UINT,[r.R32I]:N.INT,[r.R32UI]:N.UINT,[r.RG8I]:N.INT,[r.RG8UI]:N.UINT,[r.RG16I]:N.INT,[r.RG16UI]:N.UINT,[r.RG32I]:N.INT,[r.RG32UI]:N.UINT,[r.RGB8I]:N.INT,[r.RGB8UI]:N.UINT,[r.RGB16I]:N.INT,[r.RGB16UI]:N.UINT,[r.RGB32I]:N.INT,[r.RGB32UI]:N.UINT,[r.RGBA8I]:N.INT,[r.RGBA8UI]:N.UINT,[r.RGBA16I]:N.INT,[r.RGBA16UI]:N.UINT,[r.RGBA32I]:N.INT,[r.RGBA32UI]:N.UINT,[r.DEPTH_COMPONENT16]:N.FLOAT,[r.DEPTH_COMPONENT24]:N.FLOAT,[r.DEPTH_COMPONENT32F]:N.FLOAT,[r.DEPTH_STENCIL]:N.FLOAT,[r.DEPTH24_STENCIL8]:N.FLOAT,[r.DEPTH32F_STENCIL8]:N.FLOAT}:t={[r.RGB]:N.FLOAT,[r.RGBA]:N.FLOAT,[r.ALPHA]:N.FLOAT,[r.LUMINANCE]:N.FLOAT,[r.LUMINANCE_ALPHA]:N.FLOAT,[r.DEPTH_STENCIL]:N.FLOAT},t}function GM(r){let t;return"WebGL2RenderingContext"in globalThis&&r instanceof globalThis.WebGL2RenderingContext?t={[it.UNSIGNED_BYTE]:{[G.RGBA]:r.RGBA8,[G.RGB]:r.RGB8,[G.RG]:r.RG8,[G.RED]:r.R8,[G.RGBA_INTEGER]:r.RGBA8UI,[G.RGB_INTEGER]:r.RGB8UI,[G.RG_INTEGER]:r.RG8UI,[G.RED_INTEGER]:r.R8UI,[G.ALPHA]:r.ALPHA,[G.LUMINANCE]:r.LUMINANCE,[G.LUMINANCE_ALPHA]:r.LUMINANCE_ALPHA},[it.BYTE]:{[G.RGBA]:r.RGBA8_SNORM,[G.RGB]:r.RGB8_SNORM,[G.RG]:r.RG8_SNORM,[G.RED]:r.R8_SNORM,[G.RGBA_INTEGER]:r.RGBA8I,[G.RGB_INTEGER]:r.RGB8I,[G.RG_INTEGER]:r.RG8I,[G.RED_INTEGER]:r.R8I},[it.UNSIGNED_SHORT]:{[G.RGBA_INTEGER]:r.RGBA16UI,[G.RGB_INTEGER]:r.RGB16UI,[G.RG_INTEGER]:r.RG16UI,[G.RED_INTEGER]:r.R16UI,[G.DEPTH_COMPONENT]:r.DEPTH_COMPONENT16},[it.SHORT]:{[G.RGBA_INTEGER]:r.RGBA16I,[G.RGB_INTEGER]:r.RGB16I,[G.RG_INTEGER]:r.RG16I,[G.RED_INTEGER]:r.R16I},[it.UNSIGNED_INT]:{[G.RGBA_INTEGER]:r.RGBA32UI,[G.RGB_INTEGER]:r.RGB32UI,[G.RG_INTEGER]:r.RG32UI,[G.RED_INTEGER]:r.R32UI,[G.DEPTH_COMPONENT]:r.DEPTH_COMPONENT24},[it.INT]:{[G.RGBA_INTEGER]:r.RGBA32I,[G.RGB_INTEGER]:r.RGB32I,[G.RG_INTEGER]:r.RG32I,[G.RED_INTEGER]:r.R32I},[it.FLOAT]:{[G.RGBA]:r.RGBA32F,[G.RGB]:r.RGB32F,[G.RG]:r.RG32F,[G.RED]:r.R32F,[G.DEPTH_COMPONENT]:r.DEPTH_COMPONENT32F},[it.HALF_FLOAT]:{[G.RGBA]:r.RGBA16F,[G.RGB]:r.RGB16F,[G.RG]:r.RG16F,[G.RED]:r.R16F},[it.UNSIGNED_SHORT_5_6_5]:{[G.RGB]:r.RGB565},[it.UNSIGNED_SHORT_4_4_4_4]:{[G.RGBA]:r.RGBA4},[it.UNSIGNED_SHORT_5_5_5_1]:{[G.RGBA]:r.RGB5_A1},[it.UNSIGNED_INT_2_10_10_10_REV]:{[G.RGBA]:r.RGB10_A2,[G.RGBA_INTEGER]:r.RGB10_A2UI},[it.UNSIGNED_INT_10F_11F_11F_REV]:{[G.RGB]:r.R11F_G11F_B10F},[it.UNSIGNED_INT_5_9_9_9_REV]:{[G.RGB]:r.RGB9_E5},[it.UNSIGNED_INT_24_8]:{[G.DEPTH_STENCIL]:r.DEPTH24_STENCIL8},[it.FLOAT_32_UNSIGNED_INT_24_8_REV]:{[G.DEPTH_STENCIL]:r.DEPTH32F_STENCIL8}}:t={[it.UNSIGNED_BYTE]:{[G.RGBA]:r.RGBA,[G.RGB]:r.RGB,[G.ALPHA]:r.ALPHA,[G.LUMINANCE]:r.LUMINANCE,[G.LUMINANCE_ALPHA]:r.LUMINANCE_ALPHA},[it.UNSIGNED_SHORT_5_6_5]:{[G.RGB]:r.RGB},[it.UNSIGNED_SHORT_4_4_4_4]:{[G.RGBA]:r.RGBA},[it.UNSIGNED_SHORT_5_5_5_1]:{[G.RGBA]:r.RGBA}},t}var bn=class{constructor(t){this.renderer=t,this.boundTextures=[],this.currentLocation=-1,this.managedTextures=[],this._unknownBoundTextures=!1,this.unknownTexture=new dt,this.hasIntegerTextures=!1}contextChange(){let t=this.gl=this.renderer.gl;this.CONTEXT_UID=this.renderer.CONTEXT_UID,this.webGLVersion=this.renderer.context.webGLVersion,this.internalFormats=GM(t),this.samplerTypes=kM(t);let e=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS);this.boundTextures.length=e;for(let s=0;s<e;s++)this.boundTextures[s]=null;this.emptyTextures={};let i=new Gs(t.createTexture());t.bindTexture(t.TEXTURE_2D,i.texture),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,1,1,0,t.RGBA,t.UNSIGNED_BYTE,new Uint8Array(4)),this.emptyTextures[t.TEXTURE_2D]=i,this.emptyTextures[t.TEXTURE_CUBE_MAP]=new Gs(t.createTexture()),t.bindTexture(t.TEXTURE_CUBE_MAP,this.emptyTextures[t.TEXTURE_CUBE_MAP].texture);for(let s=0;s<6;s++)t.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+s,0,t.RGBA,1,1,0,t.RGBA,t.UNSIGNED_BYTE,null);t.texParameteri(t.TEXTURE_CUBE_MAP,t.TEXTURE_MAG_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_CUBE_MAP,t.TEXTURE_MIN_FILTER,t.LINEAR);for(let s=0;s<this.boundTextures.length;s++)this.bind(null,s)}bind(t,e=0){let{gl:i}=this;if(t=t?.castToBaseTexture(),t?.valid&&!t.parentTextureArray){t.touched=this.renderer.textureGC.count;let s=t._glTextures[this.CONTEXT_UID]||this.initTexture(t);this.boundTextures[e]!==t&&(this.currentLocation!==e&&(this.currentLocation=e,i.activeTexture(i.TEXTURE0+e)),i.bindTexture(t.target,s.texture)),s.dirtyId!==t.dirtyId?(this.currentLocation!==e&&(this.currentLocation=e,i.activeTexture(i.TEXTURE0+e)),this.updateTexture(t)):s.dirtyStyleId!==t.dirtyStyleId&&this.updateTextureStyle(t),this.boundTextures[e]=t}else this.currentLocation!==e&&(this.currentLocation=e,i.activeTexture(i.TEXTURE0+e)),i.bindTexture(i.TEXTURE_2D,this.emptyTextures[i.TEXTURE_2D].texture),this.boundTextures[e]=null}reset(){this._unknownBoundTextures=!0,this.hasIntegerTextures=!1,this.currentLocation=-1;for(let t=0;t<this.boundTextures.length;t++)this.boundTextures[t]=this.unknownTexture}unbind(t){let{gl:e,boundTextures:i}=this;if(this._unknownBoundTextures){this._unknownBoundTextures=!1;for(let s=0;s<i.length;s++)i[s]===this.unknownTexture&&this.bind(null,s)}for(let s=0;s<i.length;s++)i[s]===t&&(this.currentLocation!==s&&(e.activeTexture(e.TEXTURE0+s),this.currentLocation=s),e.bindTexture(t.target,this.emptyTextures[t.target].texture),i[s]=null)}ensureSamplerType(t){let{boundTextures:e,hasIntegerTextures:i,CONTEXT_UID:s}=this;if(i)for(let o=t-1;o>=0;--o){let n=e[o];n&&n._glTextures[s].samplerType!==N.FLOAT&&this.renderer.texture.unbind(n)}}initTexture(t){let e=new Gs(this.gl.createTexture());return e.dirtyId=-1,t._glTextures[this.CONTEXT_UID]=e,this.managedTextures.push(t),t.on("dispose",this.destroyTexture,this),e}initTextureType(t,e){e.internalFormat=this.internalFormats[t.type]?.[t.format]??t.format,e.samplerType=this.samplerTypes[e.internalFormat]??N.FLOAT,this.webGLVersion===2&&t.type===it.HALF_FLOAT?e.type=this.gl.HALF_FLOAT:e.type=t.type}updateTexture(t){let e=t._glTextures[this.CONTEXT_UID];if(!e)return;let i=this.renderer;if(this.initTextureType(t,e),t.resource?.upload(i,t,e))e.samplerType!==N.FLOAT&&(this.hasIntegerTextures=!0);else{let s=t.realWidth,o=t.realHeight,n=i.gl;(e.width!==s||e.height!==o||e.dirtyId<0)&&(e.width=s,e.height=o,n.texImage2D(t.target,0,e.internalFormat,s,o,0,t.format,e.type,null))}t.dirtyStyleId!==e.dirtyStyleId&&this.updateTextureStyle(t),e.dirtyId=t.dirtyId}destroyTexture(t,e){let{gl:i}=this;if(t=t.castToBaseTexture(),t._glTextures[this.CONTEXT_UID]&&(this.unbind(t),i.deleteTexture(t._glTextures[this.CONTEXT_UID].texture),t.off("dispose",this.destroyTexture,this),delete t._glTextures[this.CONTEXT_UID],!e)){let s=this.managedTextures.indexOf(t);s!==-1&&Bx(this.managedTextures,s,1)}}updateTextureStyle(t){let e=t._glTextures[this.CONTEXT_UID];e&&((t.mipmap===Ar.POW2||this.webGLVersion!==2)&&!t.isPowerOfTwo?e.mipmap=!1:e.mipmap=t.mipmap>=1,this.webGLVersion!==2&&!t.isPowerOfTwo?e.wrapMode=El.CLAMP:e.wrapMode=t.wrapMode,t.resource?.style(this.renderer,t,e)||this.setStyle(t,e),e.dirtyStyleId=t.dirtyStyleId)}setStyle(t,e){let i=this.gl;if(e.mipmap&&t.mipmap!==Ar.ON_MANUAL&&i.generateMipmap(t.target),i.texParameteri(t.target,i.TEXTURE_WRAP_S,e.wrapMode),i.texParameteri(t.target,i.TEXTURE_WRAP_T,e.wrapMode),e.mipmap){i.texParameteri(t.target,i.TEXTURE_MIN_FILTER,t.scaleMode===fr.LINEAR?i.LINEAR_MIPMAP_LINEAR:i.NEAREST_MIPMAP_NEAREST);let s=this.renderer.context.extensions.anisotropicFiltering;if(s&&t.anisotropicLevel>0&&t.scaleMode===fr.LINEAR){let o=Math.min(t.anisotropicLevel,i.getParameter(s.MAX_TEXTURE_MAX_ANISOTROPY_EXT));i.texParameterf(t.target,s.TEXTURE_MAX_ANISOTROPY_EXT,o)}}else i.texParameteri(t.target,i.TEXTURE_MIN_FILTER,t.scaleMode===fr.LINEAR?i.LINEAR:i.NEAREST);i.texParameteri(t.target,i.TEXTURE_MAG_FILTER,t.scaleMode===fr.LINEAR?i.LINEAR:i.NEAREST)}destroy(){this.renderer=null}};bn.extension={type:V.RendererSystem,name:"texture"};q.add(bn);var vn=class{constructor(t){this.renderer=t}contextChange(){this.gl=this.renderer.gl,this.CONTEXT_UID=this.renderer.CONTEXT_UID}bind(t){let{gl:e,CONTEXT_UID:i}=this,s=t._glTransformFeedbacks[i]||this.createGLTransformFeedback(t);e.bindTransformFeedback(e.TRANSFORM_FEEDBACK,s)}unbind(){let{gl:t}=this;t.bindTransformFeedback(t.TRANSFORM_FEEDBACK,null)}beginTransformFeedback(t,e){let{gl:i,renderer:s}=this;e&&s.shader.bind(e),i.beginTransformFeedback(t)}endTransformFeedback(){let{gl:t}=this;t.endTransformFeedback()}createGLTransformFeedback(t){let{gl:e,renderer:i,CONTEXT_UID:s}=this,o=e.createTransformFeedback();t._glTransformFeedbacks[s]=o,e.bindTransformFeedback(e.TRANSFORM_FEEDBACK,o);for(let n=0;n<t.buffers.length;n++){let a=t.buffers[n];a&&(i.buffer.update(a),a._glBuffers[s].refCount++,e.bindBufferBase(e.TRANSFORM_FEEDBACK_BUFFER,n,a._glBuffers[s].buffer||null))}return e.bindTransformFeedback(e.TRANSFORM_FEEDBACK,null),t.disposeRunner.add(this),o}disposeTransformFeedback(t,e){let i=t._glTransformFeedbacks[this.CONTEXT_UID],s=this.gl;t.disposeRunner.remove(this);let o=this.renderer.buffer;if(o)for(let n=0;n<t.buffers.length;n++){let a=t.buffers[n];if(!a)continue;let l=a._glBuffers[this.CONTEXT_UID];l&&(l.refCount--,l.refCount===0&&!e&&o.dispose(a,e))}i&&(e||s.deleteTransformFeedback(i),delete t._glTransformFeedbacks[this.CONTEXT_UID])}destroy(){this.renderer=null}};vn.extension={type:V.RendererSystem,name:"transformFeedback"};q.add(vn);var bi=class{constructor(t){this.renderer=t}init(t){this.screen=new mt(0,0,t.width,t.height),this.element=t.view||Y.ADAPTER.createCanvas(),this.resolution=t.resolution||Y.RESOLUTION,this.autoDensity=!!t.autoDensity}resizeView(t,e){this.element.width=Math.round(t*this.resolution),this.element.height=Math.round(e*this.resolution);let i=this.element.width/this.resolution,s=this.element.height/this.resolution;this.screen.width=i,this.screen.height=s,this.autoDensity&&(this.element.style.width=`${i}px`,this.element.style.height=`${s}px`),this.renderer.emit("resize",i,s),this.renderer.runners.resize.emit(this.screen.width,this.screen.height)}destroy(t){t&&this.element.parentNode?.removeChild(this.element),this.renderer=null,this.element=null,this.screen=null}};bi.defaultOptions={width:800,height:600,resolution:void 0,autoDensity:!1},bi.extension={type:[V.RendererSystem,V.CanvasRendererSystem],name:"_view"};q.add(bi);Y.PREFER_ENV=Ze.WEBGL2;Y.STRICT_TEXTURE_CACHE=!1;Y.RENDER_OPTIONS={...yi.defaultOptions,...xi.defaultOptions,...bi.defaultOptions,..._i.defaultOptions};Object.defineProperties(Y,{WRAP_MODE:{get(){return dt.defaultOptions.wrapMode},set(r){ht("7.1.0","settings.WRAP_MODE is deprecated, use BaseTexture.defaultOptions.wrapMode"),dt.defaultOptions.wrapMode=r}},SCALE_MODE:{get(){return dt.defaultOptions.scaleMode},set(r){ht("7.1.0","settings.SCALE_MODE is deprecated, use BaseTexture.defaultOptions.scaleMode"),dt.defaultOptions.scaleMode=r}},MIPMAP_TEXTURES:{get(){return dt.defaultOptions.mipmap},set(r){ht("7.1.0","settings.MIPMAP_TEXTURES is deprecated, use BaseTexture.defaultOptions.mipmap"),dt.defaultOptions.mipmap=r}},ANISOTROPIC_LEVEL:{get(){return dt.defaultOptions.anisotropicLevel},set(r){ht("7.1.0","settings.ANISOTROPIC_LEVEL is deprecated, use BaseTexture.defaultOptions.anisotropicLevel"),dt.defaultOptions.anisotropicLevel=r}},FILTER_RESOLUTION:{get(){return ht("7.1.0","settings.FILTER_RESOLUTION is deprecated, use Filter.defaultResolution"),Kr.defaultResolution},set(r){Kr.defaultResolution=r}},FILTER_MULTISAMPLE:{get(){return ht("7.1.0","settings.FILTER_MULTISAMPLE is deprecated, use Filter.defaultMultisample"),Kr.defaultMultisample},set(r){Kr.defaultMultisample=r}},SPRITE_MAX_TEXTURES:{get(){return gi.defaultMaxTextures},set(r){ht("7.1.0","settings.SPRITE_MAX_TEXTURES is deprecated, use BatchRenderer.defaultMaxTextures"),gi.defaultMaxTextures=r}},SPRITE_BATCH_SIZE:{get(){return gi.defaultBatchSize},set(r){ht("7.1.0","settings.SPRITE_BATCH_SIZE is deprecated, use BatchRenderer.defaultBatchSize"),gi.defaultBatchSize=r}},CAN_UPLOAD_SAME_BUFFER:{get(){return gi.canUploadSameBuffer},set(r){ht("7.1.0","settings.CAN_UPLOAD_SAME_BUFFER is deprecated, use BatchRenderer.canUploadSameBuffer"),gi.canUploadSameBuffer=r}},GC_MODE:{get(){return Zr.defaultMode},set(r){ht("7.1.0","settings.GC_MODE is deprecated, use TextureGCSystem.defaultMode"),Zr.defaultMode=r}},GC_MAX_IDLE:{get(){return Zr.defaultMaxIdle},set(r){ht("7.1.0","settings.GC_MAX_IDLE is deprecated, use TextureGCSystem.defaultMaxIdle"),Zr.defaultMaxIdle=r}},GC_MAX_CHECK_COUNT:{get(){return Zr.defaultCheckCountMax},set(r){ht("7.1.0","settings.GC_MAX_CHECK_COUNT is deprecated, use TextureGCSystem.defaultCheckCountMax"),Zr.defaultCheckCountMax=r}},PRECISION_VERTEX:{get(){return gr.defaultVertexPrecision},set(r){ht("7.1.0","settings.PRECISION_VERTEX is deprecated, use Program.defaultVertexPrecision"),gr.defaultVertexPrecision=r}},PRECISION_FRAGMENT:{get(){return gr.defaultFragmentPrecision},set(r){ht("7.1.0","settings.PRECISION_FRAGMENT is deprecated, use Program.defaultFragmentPrecision"),gr.defaultFragmentPrecision=r}}});var Us=(r=>(r[r.INTERACTION=50]="INTERACTION",r[r.HIGH=25]="HIGH",r[r.NORMAL=0]="NORMAL",r[r.LOW=-25]="LOW",r[r.UTILITY=-50]="UTILITY",r))(Us||{});var Tn=class{constructor(t,e=null,i=0,s=!1){this.next=null,this.previous=null,this._destroyed=!1,this.fn=t,this.context=e,this.priority=i,this.once=s}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));let 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);let e=this.next;return this.next=t?null:e,this.previous=null,e}};var UM=class rr{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 Tn(null,null,1/0),this.deltaMS=1/rr.targetFPMS,this.elapsedMS=1/rr.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=Us.NORMAL){return this._addListener(new Tn(t,e,i))}addOnce(t,e,i=Us.NORMAL){return this._addListener(new Tn(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){let o=t-this._lastFrame|0;if(o<this._minElapsedMS)return;this._lastFrame=t-o%this._minElapsedMS}this.deltaMS=e,this.deltaTime=this.deltaMS*rr.targetFPMS;let i=this._head,s=i.next;for(;s;)s=s.emit(this.deltaTime);i.next||this._cancelIfNeeded()}else this.deltaTime=this.deltaMS=this.elapsedMS=0;this.lastTime=t}get FPS(){return 1e3/this.elapsedMS}get minFPS(){return 1e3/this._maxElapsedMS}set minFPS(t){let e=Math.min(this.maxFPS,t),i=Math.min(Math.max(0,e)/1e3,rr.targetFPMS);this._maxElapsedMS=1/i}get maxFPS(){return this._minElapsedMS?Math.round(1e3/this._minElapsedMS):0}set maxFPS(t){if(t===0)this._minElapsedMS=0;else{let e=Math.max(this.minFPS,t);this._minElapsedMS=1/(e/1e3)}}static get shared(){if(!rr._shared){let t=rr._shared=new rr;t.autoStart=!0,t._protected=!0}return rr._shared}static get system(){if(!rr._system){let t=rr._system=new rr;t.autoStart=!0,t._protected=!0}return rr._system}};UM.targetFPMS=.06;var xr=UM;Object.defineProperties(Y,{TARGET_FPMS:{get(){return xr.targetFPMS},set(r){ht("7.1.0","settings.TARGET_FPMS is deprecated, use Ticker.targetFPMS"),xr.targetFPMS=r}}});var ah=class{static init(t){t=Object.assign({autoStart:!0,sharedTicker:!1},t),Object.defineProperty(this,"ticker",{set(e){this._ticker&&this._ticker.remove(this.render,this),this._ticker=e,e&&e.add(this.render,this,Us.LOW)},get(){return this._ticker}}),this.stop=()=>{this._ticker.stop()},this.start=()=>{this._ticker.start()},this._ticker=null,this.ticker=t.sharedTicker?xr.shared:new xr,t.autoStart&&this.start()}static destroy(){if(this._ticker){let t=this._ticker;this.ticker=null,t.destroy()}}};ah.extension=V.Application;q.add(ah);var bO=[];q.handleByList(V.Renderer,bO);var lh=class{constructor(t){this.renderer=t}contextChange(t){let e;if(this.renderer.context.webGLVersion===1){let i=t.getParameter(t.FRAMEBUFFER_BINDING);t.bindFramebuffer(t.FRAMEBUFFER,null),e=t.getParameter(t.SAMPLES),t.bindFramebuffer(t.FRAMEBUFFER,i)}else{let i=t.getParameter(t.DRAW_FRAMEBUFFER_BINDING);t.bindFramebuffer(t.DRAW_FRAMEBUFFER,null),e=t.getParameter(t.SAMPLES),t.bindFramebuffer(t.DRAW_FRAMEBUFFER,i)}e>=Pt.HIGH?this.multisample=Pt.HIGH:e>=Pt.MEDIUM?this.multisample=Pt.MEDIUM:e>=Pt.LOW?this.multisample=Pt.LOW:this.multisample=Pt.NONE}destroy(){}};lh.extension={type:V.RendererSystem,name:"_multisample"};q.add(lh);var Hd=class{constructor(t){this.buffer=t||null,this.updateID=-1,this.byteLength=-1,this.refCount=0}};var hh=class{constructor(t){this.renderer=t,this.managedBuffers={},this.boundBufferBases={}}destroy(){this.renderer=null}contextChange(){this.disposeAll(!0),this.gl=this.renderer.gl,this.CONTEXT_UID=this.renderer.CONTEXT_UID}bind(t){let{gl:e,CONTEXT_UID:i}=this,s=t._glBuffers[i]||this.createGLBuffer(t);e.bindBuffer(t.type,s.buffer)}unbind(t){let{gl:e}=this;e.bindBuffer(t,null)}bindBufferBase(t,e){let{gl:i,CONTEXT_UID:s}=this;if(this.boundBufferBases[e]!==t){let o=t._glBuffers[s]||this.createGLBuffer(t);this.boundBufferBases[e]=t,i.bindBufferBase(i.UNIFORM_BUFFER,e,o.buffer)}}bindBufferRange(t,e,i){let{gl:s,CONTEXT_UID:o}=this;i=i||0;let n=t._glBuffers[o]||this.createGLBuffer(t);s.bindBufferRange(s.UNIFORM_BUFFER,e||0,n.buffer,i*256,256)}update(t){let{gl:e,CONTEXT_UID:i}=this,s=t._glBuffers[i]||this.createGLBuffer(t);if(t._updateID!==s.updateID)if(s.updateID=t._updateID,e.bindBuffer(t.type,s.buffer),s.byteLength>=t.data.byteLength)e.bufferSubData(t.type,0,t.data);else{let o=t.static?e.STATIC_DRAW:e.DYNAMIC_DRAW;s.byteLength=t.data.byteLength,e.bufferData(t.type,t.data,o)}}dispose(t,e){if(!this.managedBuffers[t.id])return;delete this.managedBuffers[t.id];let i=t._glBuffers[this.CONTEXT_UID],s=this.gl;t.disposeRunner.remove(this),i&&(e||s.deleteBuffer(i.buffer),delete t._glBuffers[this.CONTEXT_UID])}disposeAll(t){let e=Object.keys(this.managedBuffers);for(let i=0;i<e.length;i++)this.dispose(this.managedBuffers[e[i]],t)}createGLBuffer(t){let{CONTEXT_UID:e,gl:i}=this;return t._glBuffers[e]=new Hd(i.createBuffer()),this.managedBuffers[t.id]=t,t.disposeRunner.add(this),t._glBuffers[e]}};hh.extension={type:V.RendererSystem,name:"buffer"};q.add(hh);var ch=class{constructor(t){this.renderer=t}render(t,e){let i=this.renderer,s,o,n,a;if(e&&(s=e.renderTexture,o=e.clear,n=e.transform,a=e.skipUpdateTransform),this.renderingToScreen=!s,i.runners.prerender.emit(),i.emit("prerender"),i.projection.transform=n,!i.context.isLost){if(s||(this.lastObjectRendered=t),!a){let l=t.enableTempParent();t.updateTransform(),t.disableTempParent(l)}i.renderTexture.bind(s),i.batch.currentRenderer.start(),(o??i.background.clearBeforeRender)&&i.renderTexture.clear(),t.render(i),i.batch.currentRenderer.flush(),s&&(e.blit&&i.framebuffer.blit(),s.baseTexture.update()),i.runners.postrender.emit(),i.projection.transform=null,i.emit("postrender")}}destroy(){this.renderer=null,this.lastObjectRendered=null}};ch.extension={type:V.RendererSystem,name:"objectRenderer"};q.add(ch);var Vd=class iy extends _n{constructor(t){super(),this.type=Xg.WEBGL,t=Object.assign({},Y.RENDER_OPTIONS,t),this.gl=null,this.CONTEXT_UID=0,this.globalUniforms=new er({projectionMatrix:new Bt},!0);let e={runners:["init","destroy","contextChange","resolutionChange","reset","update","postrender","prerender","resize"],systems:iy.__systems,priority:["_view","textureGenerator","background","_plugin","startup","context","state","texture","buffer","geometry","framebuffer","transformFeedback","mask","scissor","stencil","projection","textureGC","filter","renderTexture","batch","objectRenderer","_multisample"]};this.setup(e),"useContextAlpha"in t&&(ht("7.0.0","options.useContextAlpha is deprecated, use options.premultipliedAlpha and options.backgroundAlpha instead"),t.premultipliedAlpha=t.useContextAlpha&&t.useContextAlpha!=="notMultiplied",t.backgroundAlpha=t.useContextAlpha===!1?1:t.backgroundAlpha),this._plugin.rendererPlugins=iy.__plugins,this.options=t,this.startup.run(this.options)}static test(t){return t?.forceCanvas?!1:Rx()}render(t,e){this.objectRenderer.render(t,e)}resize(t,e){this._view.resizeView(t,e)}reset(){return this.runners.reset.emit(),this}clear(){this.renderTexture.bind(),this.renderTexture.clear()}destroy(t=!1){this.runners.destroy.items.reverse(),this.emitWithCustomOptions(this.runners.destroy,{_view:t}),super.destroy()}get plugins(){return this._plugin.plugins}get multisample(){return this._multisample.multisample}get width(){return this._view.element.width}get height(){return this._view.element.height}get resolution(){return this._view.resolution}set resolution(t){this._view.resolution=t,this.runners.resolutionChange.emit(t)}get autoDensity(){return this._view.autoDensity}get view(){return this._view.element}get screen(){return this._view.screen}get lastObjectRendered(){return this.objectRenderer.lastObjectRendered}get renderingToScreen(){return this.objectRenderer.renderingToScreen}get rendererLogId(){return`WebGL ${this.context.webGLVersion}`}get clearBeforeRender(){return ht("7.0.0","renderer.clearBeforeRender has been deprecated, please use renderer.background.clearBeforeRender instead."),this.background.clearBeforeRender}get useContextAlpha(){return ht("7.0.0","renderer.useContextAlpha has been deprecated, please use renderer.context.premultipliedAlpha instead."),this.context.useContextAlpha}get preserveDrawingBuffer(){return ht("7.0.0","renderer.preserveDrawingBuffer has been deprecated, we cannot truly know this unless pixi created the context"),this.context.preserveDrawingBuffer}get backgroundColor(){return ht("7.0.0","renderer.backgroundColor has been deprecated, use renderer.background.color instead."),this.background.color}set backgroundColor(t){ht("7.0.0","renderer.backgroundColor has been deprecated, use renderer.background.color instead."),this.background.color=t}get backgroundAlpha(){return ht("7.0.0","renderer.backgroundAlpha has been deprecated, use renderer.background.alpha instead."),this.background.alpha}set backgroundAlpha(t){ht("7.0.0","renderer.backgroundAlpha has been deprecated, use renderer.background.alpha instead."),this.background.alpha=t}get powerPreference(){return ht("7.0.0","renderer.powerPreference has been deprecated, we can only know this if pixi creates the context"),this.context.powerPreference}generateTexture(t,e){return this.textureGenerator.generateTexture(t,e)}};Vd.extension={type:V.Renderer,priority:1},Vd.__plugins={},Vd.__systems={};var Wd=Vd;q.handleByMap(V.RendererPlugin,Wd.__plugins);q.handleByMap(V.RendererSystem,Wd.__systems);q.add(Wd);var zi=class extends tr{constructor(t,e){let{width:i,height:s}=e||{};super(i,s),this.items=[],this.itemDirtyIds=[];for(let o=0;o<t;o++){let n=new dt;this.items.push(n),this.itemDirtyIds.push(-2)}this.length=t,this._load=null,this.baseTexture=null}initFromArray(t,e){for(let i=0;i<this.length;i++)t[i]&&(t[i].castToBaseTexture?this.addBaseTextureAt(t[i].castToBaseTexture(),i):t[i]instanceof tr?this.addResourceAt(t[i],i):this.addResourceAt(rn(t[i],e),i))}dispose(){for(let t=0,e=this.length;t<e;t++)this.items[t].destroy();this.items=null,this.itemDirtyIds=null,this._load=null}addResourceAt(t,e){if(!this.items[e])throw new Error(`Index ${e} is out of bounds`);return t.valid&&!this.valid&&this.resize(t.width,t.height),this.items[e].setResource(t),this}bind(t){if(this.baseTexture!==null)throw new Error("Only one base texture per TextureArray is allowed");super.bind(t);for(let e=0;e<this.length;e++)this.items[e].parentTextureArray=t,this.items[e].on("update",t.update,t)}unbind(t){super.unbind(t);for(let e=0;e<this.length;e++)this.items[e].parentTextureArray=null,this.items[e].off("update",t.update,t)}load(){if(this._load)return this._load;let t=this.items.map(e=>e.resource).filter(e=>e).map(e=>e.load());return this._load=Promise.all(t).then(()=>{let{realWidth:e,realHeight:i}=this.items[0];return this.resize(e,i),this.update(),Promise.resolve(this)}),this._load}};var uh=class extends zi{constructor(t,e){let{width:i,height:s}=e||{},o,n;Array.isArray(t)?(o=t,n=t.length):n=t,super(n,{width:i,height:s}),o&&this.initFromArray(o,e)}addBaseTextureAt(t,e){if(t.resource)this.addResourceAt(t.resource,e);else throw new Error("ArrayResource does not support RenderTexture");return this}bind(t){super.bind(t),t.target=ui.TEXTURE_2D_ARRAY}upload(t,e,i){let{length:s,itemDirtyIds:o,items:n}=this,{gl:a}=t;i.dirtyId<0&&a.texImage3D(a.TEXTURE_2D_ARRAY,0,i.internalFormat,this._width,this._height,s,0,e.format,i.type,null);for(let l=0;l<s;l++){let h=n[l];o[l]<h.dirtyId&&(o[l]=h.dirtyId,h.valid&&a.texSubImage3D(a.TEXTURE_2D_ARRAY,0,0,0,l,h.resource.width,h.resource.height,1,e.format,i.type,h.resource.source))}return!0}};var dh=class extends ue{constructor(t){super(t)}static test(t){let{OffscreenCanvas:e}=globalThis;return e&&t instanceof e?!0:globalThis.HTMLCanvasElement&&t instanceof HTMLCanvasElement}};var OM=class fh extends zi{constructor(t,e){let{width:i,height:s,autoLoad:o,linkBaseTexture:n}=e||{};if(t&&t.length!==fh.SIDES)throw new Error(`Invalid length. Got ${t.length}, expected 6`);super(6,{width:i,height:s});for(let a=0;a<fh.SIDES;a++)this.items[a].target=ui.TEXTURE_CUBE_MAP_POSITIVE_X+a;this.linkBaseTexture=n!==!1,t&&this.initFromArray(t,e),o!==!1&&this.load()}bind(t){super.bind(t),t.target=ui.TEXTURE_CUBE_MAP}addBaseTextureAt(t,e,i){if(i===void 0&&(i=this.linkBaseTexture),!this.items[e])throw new Error(`Index ${e} is out of bounds`);if(!this.linkBaseTexture||t.parentTextureArray||Object.keys(t._glTextures).length>0)if(t.resource)this.addResourceAt(t.resource,e);else throw new Error("CubeResource does not support copying of renderTexture.");else t.target=ui.TEXTURE_CUBE_MAP_POSITIVE_X+e,t.parentTextureArray=this.baseTexture,this.items[e]=t;return t.valid&&!this.valid&&this.resize(t.realWidth,t.realHeight),this.items[e]=t,this}upload(t,e,i){let s=this.itemDirtyIds;for(let o=0;o<fh.SIDES;o++){let n=this.items[o];(s[o]<n.dirtyId||i.dirtyId<e.dirtyId)&&(n.valid&&n.resource?(n.resource.upload(t,n,i),s[o]=n.dirtyId):s[o]<-1&&(t.gl.texImage2D(n.target,0,i.internalFormat,e.realWidth,e.realHeight,0,e.format,i.type,null),s[o]=-1))}return!0}static test(t){return Array.isArray(t)&&t.length===fh.SIDES}};OM.SIDES=6;var sy=OM;var ph=class r extends ue{constructor(t,e){e=e||{};let i,s,o;typeof t=="string"?(i=r.EMPTY,s=t,o=!0):(i=t,s=null,o=!1),super(i),this.url=s,this.crossOrigin=e.crossOrigin??!0,this.alphaMode=typeof e.alphaMode=="number"?e.alphaMode:null,this.ownsImageBitmap=e.ownsImageBitmap??o,this._load=null,e.autoLoad!==!1&&this.load()}load(){return this._load?this._load:(this._load=new Promise(async(t,e)=>{if(this.url===null){t(this);return}try{let i=await Y.ADAPTER.fetch(this.url,{mode:this.crossOrigin?"cors":"no-cors"});if(this.destroyed)return;let s=await i.blob();if(this.destroyed)return;let o=await createImageBitmap(s,{premultiplyAlpha:this.alphaMode===null||this.alphaMode===Qe.UNPACK?"premultiply":"none"});if(this.destroyed){o.close();return}this.source=o,this.update(),t(this)}catch(i){if(this.destroyed)return;e(i),this.onError.emit(i)}}),this._load)}upload(t,e,i){return this.source instanceof ImageBitmap?(typeof this.alphaMode=="number"&&(e.alphaMode=this.alphaMode),super.upload(t,e,i)):(this.load(),!1)}dispose(){this.ownsImageBitmap&&this.source instanceof ImageBitmap&&this.source.close(),super.dispose(),this._load=null}static test(t){return!!globalThis.createImageBitmap&&typeof ImageBitmap<"u"&&(typeof t=="string"||t instanceof ImageBitmap)}static get EMPTY(){return r._EMPTY=r._EMPTY??Y.ADAPTER.createCanvas(0,0),r._EMPTY}};var oy=class zd extends ue{constructor(t,e){e=e||{},super(Y.ADAPTER.createCanvas()),this._width=0,this._height=0,this.svg=t,this.scale=e.scale||1,this._overrideWidth=e.width,this._overrideHeight=e.height,this._resolve=null,this._crossorigin=e.crossorigin,this._load=null,e.autoLoad!==!1&&this.load()}load(){return this._load?this._load:(this._load=new Promise(t=>{if(this._resolve=()=>{this.update(),t(this)},zd.SVG_XML.test(this.svg.trim())){if(!btoa)throw new Error("Your browser doesn't support base64 conversions.");this.svg=`data:image/svg+xml;base64,${btoa(unescape(encodeURIComponent(this.svg)))}`}this._loadSvg()}),this._load)}_loadSvg(){let t=new Image;ue.crossOrigin(t,this.svg,this._crossorigin),t.src=this.svg,t.onerror=e=>{this._resolve&&(t.onerror=null,this.onError.emit(e))},t.onload=()=>{if(!this._resolve)return;let e=t.width,i=t.height;if(!e||!i)throw new Error("The SVG image must have width and height defined (in pixels), canvas API needs them.");let s=e*this.scale,o=i*this.scale;(this._overrideWidth||this._overrideHeight)&&(s=this._overrideWidth||this._overrideHeight/i*e,o=this._overrideHeight||this._overrideWidth/e*i),s=Math.round(s),o=Math.round(o);let n=this.source;n.width=s,n.height=o,n._pixiId=`canvas_${fi()}`,n.getContext("2d").drawImage(t,0,0,e,i,0,0,s,o),this._resolve(),this._resolve=null}}static getSize(t){let e=zd.SVG_SIZE.exec(t),i={};return e&&(i[e[1]]=Math.round(parseFloat(e[3])),i[e[5]]=Math.round(parseFloat(e[7]))),i}dispose(){super.dispose(),this._resolve=null,this._crossorigin=null}static test(t,e){return e==="svg"||typeof t=="string"&&t.startsWith("data:image/svg+xml")||typeof t=="string"&&zd.SVG_XML.test(t)}};oy.SVG_XML=/^(<\?xml[^?]+\?>)?\s*(<!--[^(-->)]*-->)?\s*\<svg/m,oy.SVG_SIZE=/<svg[^>]*(?:\s(width|height)=('|")(\d*(?:\.\d+)?)(?:px)?('|"))[^>]*(?:\s(width|height)=('|")(\d*(?:\.\d+)?)(?:px)?('|"))[^>]*>/i;var ny=oy;var $d=class extends ue{constructor(t){super(t)}static test(t){return!!globalThis.VideoFrame&&t instanceof globalThis.VideoFrame}};var ay=class ly extends ue{constructor(t,e){if(e=e||{},!(t instanceof HTMLVideoElement)){let i=document.createElement("video");e.autoLoad!==!1&&i.setAttribute("preload","auto"),e.playsinline!==!1&&(i.setAttribute("webkit-playsinline",""),i.setAttribute("playsinline","")),e.muted===!0&&(i.setAttribute("muted",""),i.muted=!0),e.loop===!0&&i.setAttribute("loop",""),e.autoPlay!==!1&&i.setAttribute("autoplay",""),typeof t=="string"&&(t=[t]);let s=t[0].src||t[0];ue.crossOrigin(i,s,e.crossorigin);for(let o=0;o<t.length;++o){let n=document.createElement("source"),{src:a,mime:l}=t[o];if(a=a||t[o],a.startsWith("data:"))l=a.slice(5,a.indexOf(";"));else if(!a.startsWith("blob:")){let h=a.split("?").shift().toLowerCase(),c=h.slice(h.lastIndexOf(".")+1);l=l||ly.MIME_TYPES[c]||`video/${c}`}n.src=a,l&&(n.type=l),i.appendChild(n)}t=i}super(t),this.noSubImage=!0,this._autoUpdate=!0,this._isConnectedToTicker=!1,this._updateFPS=e.updateFPS||0,this._msToNextUpdate=0,this.autoPlay=e.autoPlay!==!1,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._onError=this._onError.bind(this),this._onPlayStart=this._onPlayStart.bind(this),this._onPlayStop=this._onPlayStop.bind(this),this._onSeeked=this._onSeeked.bind(this),e.autoLoad!==!1&&this.load()}update(t=0){if(!this.destroyed){if(this._updateFPS){let e=xr.shared.elapsedMS*this.source.playbackRate;this._msToNextUpdate=Math.floor(this._msToNextUpdate-e)}(!this._updateFPS||this._msToNextUpdate<=0)&&(super.update(),this._msToNextUpdate=this._updateFPS?Math.floor(1e3/this._updateFPS):0)}}_videoFrameRequestCallback(){this.update(),this.destroyed?this._videoFrameRequestCallbackHandle=null:this._videoFrameRequestCallbackHandle=this.source.requestVideoFrameCallback(this._videoFrameRequestCallback)}load(){if(this._load)return this._load;let t=this.source;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._onCanPlay():(t.addEventListener("canplay",this._onCanPlay),t.addEventListener("canplaythrough",this._onCanPlay),t.addEventListener("error",this._onError,!0)),this._load=new Promise((e,i)=>{this.valid?e(this):(this._resolve=e,this._reject=i,t.load())}),this._load}_onError(t){this.source.removeEventListener("error",this._onError,!0),this.onError.emit(t),this._reject&&(this._reject(t),this._reject=null,this._resolve=null)}_isSourcePlaying(){let t=this.source;return!t.paused&&!t.ended}_isSourceReady(){return this.source.readyState>2}_onPlayStart(){this.valid||this._onCanPlay(),this._configureAutoUpdate()}_onPlayStop(){this._configureAutoUpdate()}_onSeeked(){this._autoUpdate&&!this._isSourcePlaying()&&(this._msToNextUpdate=0,this.update(),this._msToNextUpdate=0)}_onCanPlay(){let t=this.source;t.removeEventListener("canplay",this._onCanPlay),t.removeEventListener("canplaythrough",this._onCanPlay);let e=this.valid;this._msToNextUpdate=0,this.update(),this._msToNextUpdate=0,!e&&this._resolve&&(this._resolve(this),this._resolve=null,this._reject=null),this._isSourcePlaying()?this._onPlayStart():this.autoPlay&&t.play()}dispose(){this._configureAutoUpdate();let t=this.source;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._onCanPlay),t.removeEventListener("error",this._onError,!0),t.pause(),t.src="",t.load()),super.dispose()}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.source.requestVideoFrameCallback?(this._isConnectedToTicker&&(xr.shared.remove(this.update,this),this._isConnectedToTicker=!1,this._msToNextUpdate=0),this._videoFrameRequestCallbackHandle===null&&(this._videoFrameRequestCallbackHandle=this.source.requestVideoFrameCallback(this._videoFrameRequestCallback))):(this._videoFrameRequestCallbackHandle!==null&&(this.source.cancelVideoFrameCallback(this._videoFrameRequestCallbackHandle),this._videoFrameRequestCallbackHandle=null),this._isConnectedToTicker||(xr.shared.add(this.update,this),this._isConnectedToTicker=!0,this._msToNextUpdate=0)):(this._videoFrameRequestCallbackHandle!==null&&(this.source.cancelVideoFrameCallback(this._videoFrameRequestCallbackHandle),this._videoFrameRequestCallbackHandle=null),this._isConnectedToTicker&&(xr.shared.remove(this.update,this),this._isConnectedToTicker=!1,this._msToNextUpdate=0))}static test(t,e){return globalThis.HTMLVideoElement&&t instanceof HTMLVideoElement||ly.TYPES.includes(e)}};ay.TYPES=["mp4","m4v","webm","ogg","ogv","h264","avi","mov"],ay.MIME_TYPES={ogv:"video/ogg",mov:"video/quicktime",m4v:"video/mp4"};var hy=ay;Dl.push(ph,Bs,dh,hy,$d,ny,Ss,sy,uh);var vO={vec3(r,t,e,i){(e[0]!==i[0]||e[1]!==i[1]||e[2]!==i[2])&&(e[0]=i[0],e[1]=i[1],e[2]=i[2],r.uniform3f(t,i[0],i[1],i[2]))},int(r,t,e,i){r.uniform1i(t,i)},ivec2(r,t,e,i){r.uniform2i(t,i[0],i[1])},ivec3(r,t,e,i){r.uniform3i(t,i[0],i[1],i[2])},ivec4(r,t,e,i){r.uniform4i(t,i[0],i[1],i[2],i[3])},uint(r,t,e,i){r.uniform1ui(t,i)},uvec2(r,t,e,i){r.uniform2ui(t,i[0],i[1])},uvec3(r,t,e,i){r.uniform3ui(t,i[0],i[1],i[2])},uvec4(r,t,e,i){r.uniform4ui(t,i[0],i[1],i[2],i[3])},bvec2(r,t,e,i){r.uniform2i(t,i[0],i[1])},bvec3(r,t,e,i){r.uniform3i(t,i[0],i[1],i[2])},bvec4(r,t,e,i){r.uniform4i(t,i[0],i[1],i[2],i[3])},mat2(r,t,e,i){r.uniformMatrix2fv(t,!1,i)},mat4(r,t,e,i){r.uniformMatrix4fv(t,!1,i)}},TO={float(r,t,e,i){r.uniform1fv(t,i)},vec2(r,t,e,i){r.uniform2fv(t,i)},vec3(r,t,e,i){r.uniform3fv(t,i)},vec4(r,t,e,i){r.uniform4fv(t,i)},int(r,t,e,i){r.uniform1iv(t,i)},ivec2(r,t,e,i){r.uniform2iv(t,i)},ivec3(r,t,e,i){r.uniform3iv(t,i)},ivec4(r,t,e,i){r.uniform4iv(t,i)},uint(r,t,e,i){r.uniform1uiv(t,i)},uvec2(r,t,e,i){r.uniform2uiv(t,i)},uvec3(r,t,e,i){r.uniform3uiv(t,i)},uvec4(r,t,e,i){r.uniform4uiv(t,i)},bool(r,t,e,i){r.uniform1iv(t,i)},bvec2(r,t,e,i){r.uniform2iv(t,i)},bvec3(r,t,e,i){r.uniform3iv(t,i)},bvec4(r,t,e,i){r.uniform4iv(t,i)},sampler2D(r,t,e,i){r.uniform1iv(t,i)},samplerCube(r,t,e,i){r.uniform1iv(t,i)},sampler2DArray(r,t,e,i){r.uniform1iv(t,i)}};function LM(r,t,e,i,s){let o=0,n=null,a=null,l=s.gl;for(let h in r.uniforms){let c=t[h],u=i[h],d=e[h],f=r.uniforms[h];if(!c){f.group===!0&&s.shader.syncUniformGroup(u);continue}c.type==="float"&&c.size===1&&!c.isArray?u!==d.value&&(d.value=u,l.uniform1f(d.location,u)):c.type==="bool"&&c.size===1&&!c.isArray?u!==d.value&&(d.value=u,l.uniform1i(d.location,Number(u))):(c.type==="sampler2D"||c.type==="samplerCube"||c.type==="sampler2DArray")&&c.size===1&&!c.isArray?(s.texture.bind(u,o),d.value!==o&&(d.value=o,l.uniform1i(d.location,o)),o++):c.type==="mat3"&&c.size===1&&!c.isArray?f.a!==void 0?l.uniformMatrix3fv(d.location,!1,u.toArray(!0)):l.uniformMatrix3fv(d.location,!1,u):c.type==="vec2"&&c.size===1&&!c.isArray?f.x!==void 0?(a=d.value,n=u,(a[0]!==n.x||a[1]!==n.y)&&(a[0]=n.x,a[1]=n.y,l.uniform2f(d.location,n.x,n.y))):(a=d.value,n=u,(a[0]!==n[0]||a[1]!==n[1])&&(a[0]=n[0],a[1]=n[1],l.uniform2f(d.location,n[0],n[1]))):c.type==="vec4"&&c.size===1&&!c.isArray?f.width!==void 0?(a=d.value,n=u,(a[0]!==n.x||a[1]!==n.y||a[2]!==n.width||a[3]!==n.height)&&(a[0]=n.x,a[1]=n.y,a[2]=n.width,a[3]=n.height,l.uniform4f(d.location,n.x,n.y,n.width,n.height))):(a=d.value,n=u,(a[0]!==n[0]||a[1]!==n[1]||a[2]!==n[2]||a[3]!==n[3])&&(a[0]=n[0],a[1]=n[1],a[2]=n[2],a[3]=n[3],l.uniform4f(d.location,n[0],n[1],n[2],n[3]))):(c.size===1&&!c.isArray?vO:TO)[c.type].call(null,l,d.location,d.value,u)}}function SO(){Object.assign(Wi.prototype,{systemCheck(){},syncUniforms(r,t){let{shader:e,renderer:i}=this;LM(r,e.program.uniformData,t.uniformData,r.uniforms,i)}})}SO();var mh=new(window.AudioContext||window.webkitAudioContext),EO=(r,t)=>{let e,i=mh.createGain();i.gain.value=t.volume??1,i.connect(mh.destination);let s={id:r,url:t.url,loop:t.loop||!1,volume:t.volume??1};return{play:()=>{let m=No.getAsset(s.url);if(!m){console.warn("AudioPlayer.play: Asset not found",s.url);return}e=mh.createBufferSource(),e.buffer=m,e.loop=s.loop,i.gain.setValueAtTime(s.volume,mh.currentTime),e.connect(i),e.start(0)},stop:()=>{e&&(e.stop(),e.disconnect(),i.disconnect(),i.connect(mh.destination))},update:m=>{s={...s,...m}},getId:()=>s.id,getUrl:()=>s.url,getLoop:()=>s.loop,getVolume:()=>s.volume,setUrl:m=>{s.url=m},setLoop:m=>{s.loop=m},setVolume:m=>{s.volume=m,i.gain.value=m},id:s.id,url:s.url,loop:s.loop,volume:s.volume,gainNode:i}},DM=()=>{let r=[],t=[];return{add:a=>{t.push(a)},remove:a=>{t=t.filter(l=>l.id!==a)},getById:a=>t.find(l=>l.id===a),tick:()=>{for(let l of t){let h=r.find(c=>c.id===l.id);if(!h){let c=EO(l.id,{url:l.url,loop:l.loop,volume:l.volume??1});r.push(c),c.play();return}(h.url!==l.url||h.loop!==l.loop)&&(h.stop(),h.setUrl(l.url),h.setLoop(l.loop??!1),h.play()),h.getVolume()!==(l.volume??1)&&h.setVolume(l.volume??1)}let a=[];for(let l of r)t.find(h=>h.id===l.id)||(l.stop(),a.push(l.id));r=r.filter(l=>!a.includes(l.id))},destroy:()=>{for(let a of r)a.stop();r=[],t=[]}}};var wO=({JSONObject:r,parserPlugins:t=[]})=>r.map(i=>{let s=t.find(o=>o.type===i.type);return s?s.parse({state:i,parserPlugins:t}):r}),cy=wO;var NM=({type:r,parse:t})=>({type:r,parse:t});var uy=typeof navigator<"u"?navigator.userAgent.toLowerCase().indexOf("firefox")>0:!1;function dy(r,t,e,i){r.addEventListener?r.addEventListener(t,e,i):r.attachEvent&&r.attachEvent(`on${t}`,e)}function gh(r,t,e,i){r&&(r.removeEventListener?r.removeEventListener(t,e,i):r.detachEvent&&r.detachEvent(`on${t}`,e))}function WM(r,t){let e=t.slice(0,t.length-1),i=[];for(let s=0;s<e.length;s++)i.push(r[e[s].toLowerCase()]);return i}function zM(r){typeof r!="string"&&(r=""),r=r.replace(/\s/g,"");let t=r.split(","),e=t.lastIndexOf("");for(;e>=0;)t[e-1]+=",",t.splice(e,1),e=t.lastIndexOf("");return t}function AO(r,t){let e=r.length>=t.length?r:t,i=r.length>=t.length?t:r,s=!0;for(let o=0;o<e.length;o++)i.indexOf(e[o])===-1&&(s=!1);return s}function $M(r){let t=r.keyCode||r.which||r.charCode;return r.code&&/^Key[A-Z]$/.test(r.code)&&(t=r.code.charCodeAt(3)),t}var _h={backspace:8,"\u232B":8,tab:9,clear:12,enter:13,"\u21A9":13,return:13,esc:27,escape:27,space:32,left:37,up:38,right:39,down:40,arrowup:38,arrowdown:40,arrowleft:37,arrowright:39,del:46,delete:46,ins:45,insert:45,home:36,end:35,pageup:33,pagedown:34,capslock:20,num_0:96,num_1:97,num_2:98,num_3:99,num_4:100,num_5:101,num_6:102,num_7:103,num_8:104,num_9:105,num_multiply:106,num_add:107,num_enter:108,num_subtract:109,num_decimal:110,num_divide:111,"\u21EA":20,",":188,".":190,"/":191,"`":192,"-":uy?173:189,"=":uy?61:187,";":uy?59:186,"'":222,"{":219,"}":221,"[":219,"]":221,"\\":220},Mr={"\u21E7":16,shift:16,"\u2325":18,alt:18,option:18,"\u2303":17,ctrl:17,control:17,"\u2318":91,cmd:91,meta:91,command:91},xh={16:"shiftKey",18:"altKey",17:"ctrlKey",91:"metaKey",shiftKey:16,ctrlKey:17,altKey:18,metaKey:91},Te={16:!1,18:!1,17:!1,91:!1},zt={};for(let r=1;r<20;r++)_h[`f${r}`]=111+r;var Lt=[],yh=null,XM="all",vi=new Map,Sn=r=>_h[r.toLowerCase()]||Mr[r.toLowerCase()]||r.toUpperCase().charCodeAt(0),PO=r=>Object.keys(_h).find(t=>_h[t]===r),CO=r=>Object.keys(Mr).find(t=>Mr[t]===r),jM=r=>{XM=r||"all"},bh=()=>XM||"all",RO=()=>Lt.slice(0),MO=()=>Lt.map(r=>PO(r)||CO(r)||String.fromCharCode(r)),BO=()=>{let r=[];return Object.keys(zt).forEach(t=>{zt[t].forEach(({key:e,scope:i,mods:s,shortcut:o})=>{r.push({scope:i,shortcut:o,mods:s,keys:e.split("+").map(n=>Sn(n))})})}),r},YM=r=>{let t=r.target||r.srcElement,{tagName:e}=t,i=!0,s=e==="INPUT"&&!["checkbox","radio","range","button","file","reset","submit","color"].includes(t.type);return(t.isContentEditable||(s||e==="TEXTAREA"||e==="SELECT")&&!t.readOnly)&&(i=!1),i},IO=r=>(typeof r=="string"&&(r=Sn(r)),Lt.indexOf(r)!==-1),FO=(r,t)=>{let e,i;r||(r=bh());for(let s in zt)if(Object.prototype.hasOwnProperty.call(zt,s))for(e=zt[s],i=0;i<e.length;)e[i].scope===r?e.splice(i,1).forEach(({element:o})=>py(o)):i++;bh()===r&&jM(t||"all")};function kO(r){let t=$M(r);r.key&&r.key.toLowerCase()==="capslock"&&(t=Sn(r.key));let e=Lt.indexOf(t);if(e>=0&&Lt.splice(e,1),r.key&&r.key.toLowerCase()==="meta"&&Lt.splice(0,Lt.length),(t===93||t===224)&&(t=91),t in Te){Te[t]=!1;for(let i in Mr)Mr[i]===t&&(yr[i]=!1)}}var qM=(r,...t)=>{if(typeof r>"u")Object.keys(zt).forEach(e=>{Array.isArray(zt[e])&&zt[e].forEach(i=>Xd(i)),delete zt[e]}),py(null);else if(Array.isArray(r))r.forEach(e=>{e.key&&Xd(e)});else if(typeof r=="object")r.key&&Xd(r);else if(typeof r=="string"){let[e,i]=t;typeof e=="function"&&(i=e,e=""),Xd({key:r,scope:e,method:i,splitKey:"+"})}},Xd=({key:r,scope:t,method:e,splitKey:i="+"})=>{zM(r).forEach(s=>{let o=s.split(i),n=o.length,a=o[n-1],l=a==="*"?"*":Sn(a);if(!zt[l])return;t||(t=bh());let h=n>1?WM(Mr,o):[],c=[];zt[l]=zt[l].filter(u=>{let d=(e?u.method===e:!0)&&u.scope===t&&AO(u.mods,h);return d&&c.push(u.element),!d}),c.forEach(u=>py(u))})};function HM(r,t,e,i){if(t.element!==i)return;let s;if(t.scope===e||t.scope==="all"){s=t.mods.length>0;for(let o in Te)Object.prototype.hasOwnProperty.call(Te,o)&&(!Te[o]&&t.mods.indexOf(+o)>-1||Te[o]&&t.mods.indexOf(+o)===-1)&&(s=!1);(t.mods.length===0&&!Te[16]&&!Te[18]&&!Te[17]&&!Te[91]||s||t.shortcut==="*")&&(t.keys=[],t.keys=t.keys.concat(Lt),t.method(r,t)===!1&&(r.preventDefault?r.preventDefault():r.returnValue=!1,r.stopPropagation&&r.stopPropagation(),r.cancelBubble&&(r.cancelBubble=!0)))}}function VM(r,t){let e=zt["*"],i=$M(r);if(r.key&&r.key.toLowerCase()==="capslock"||!(yr.filter||YM).call(this,r))return;if((i===93||i===224)&&(i=91),Lt.indexOf(i)===-1&&i!==229&&Lt.push(i),["metaKey","ctrlKey","altKey","shiftKey"].forEach(a=>{let l=xh[a];r[a]&&Lt.indexOf(l)===-1?Lt.push(l):!r[a]&&Lt.indexOf(l)>-1?Lt.splice(Lt.indexOf(l),1):a==="metaKey"&&r[a]&&(Lt=Lt.filter(h=>h in xh||h===i))}),i in Te){Te[i]=!0;for(let a in Mr)if(Object.prototype.hasOwnProperty.call(Mr,a)){let l=xh[Mr[a]];yr[a]=r[l]}if(!e)return}for(let a in Te)Object.prototype.hasOwnProperty.call(Te,a)&&(Te[a]=r[xh[a]]);r.getModifierState&&!(r.altKey&&!r.ctrlKey)&&r.getModifierState("AltGraph")&&(Lt.indexOf(17)===-1&&Lt.push(17),Lt.indexOf(18)===-1&&Lt.push(18),Te[17]=!0,Te[18]=!0);let s=bh();if(e)for(let a=0;a<e.length;a++)e[a].scope===s&&(r.type==="keydown"&&e[a].keydown||r.type==="keyup"&&e[a].keyup)&&HM(r,e[a],s,t);if(!(i in zt))return;let o=zt[i],n=o.length;for(let a=0;a<n;a++)if((r.type==="keydown"&&o[a].keydown||r.type==="keyup"&&o[a].keyup)&&o[a].key){let l=o[a],{splitKey:h}=l,c=l.key.split(h),u=[];for(let d=0;d<c.length;d++)u.push(Sn(c[d]));u.sort().join("")===Lt.sort().join("")&&HM(r,l,s,t)}}var yr=function(r,t,e){Lt=[];let i=zM(r),s=[],o="all",n=document,a=0,l=!1,h=!0,c="+",u=!1,d=!1;if(e===void 0&&typeof t=="function"&&(e=t),Object.prototype.toString.call(t)==="[object Object]"){let f=t;f.scope&&(o=f.scope),f.element&&(n=f.element),f.keyup&&(l=f.keyup),f.keydown!==void 0&&(h=f.keydown),f.capture!==void 0&&(u=f.capture),typeof f.splitKey=="string"&&(c=f.splitKey),f.single===!0&&(d=!0)}for(typeof t=="string"&&(o=t),d&&qM(r,o);a<i.length;a++){let f=i[a].split(c);s=[],f.length>1&&(s=WM(Mr,f));let p=f[f.length-1];p=p==="*"?"*":Sn(p),p in zt||(zt[p]=[]),zt[p].push({keyup:l,keydown:h,scope:o,mods:s,shortcut:i[a],method:e,key:i[a],splitKey:c,element:n})}if(typeof n<"u"&&typeof window<"u"){if(!vi.has(n)){let f=(m=window.event)=>VM(m,n),p=(m=window.event)=>{VM(m,n),kO(m)};vi.set(n,{keydownListener:f,keyupListenr:p,capture:u}),dy(n,"keydown",f,u),dy(n,"keyup",p,u)}if(!yh){let f=()=>{Lt=[]};yh={listener:f,capture:u},dy(window,"focus",f,u)}}};function GO(r,t="all"){Object.keys(zt).forEach(e=>{zt[e].filter(i=>i.scope===t&&i.shortcut===r).forEach(i=>{i&&i.method&&i.method({},i)})})}function py(r){let t=Object.values(zt).flat();if(t.findIndex(({element:e})=>e===r)<0&&r){let{keydownListener:e,keyupListenr:i,capture:s}=vi.get(r)||{};e&&i&&(gh(r,"keyup",i,s),gh(r,"keydown",e,s),vi.delete(r))}if((t.length<=0||vi.size<=0)&&(Array.from(vi.keys()).forEach(e=>{let{keydownListener:i,keyupListenr:s,capture:o}=vi.get(e)||{};i&&s&&(gh(e,"keyup",s,o),gh(e,"keydown",i,o),vi.delete(e))}),vi.clear(),Object.keys(zt).forEach(e=>delete zt[e]),yh)){let{listener:e,capture:i}=yh;gh(window,"focus",e,i),yh=null}}var fy={getPressedKeyString:MO,setScope:jM,getScope:bh,deleteScope:FO,getPressedKeyCodes:RO,getAllKeyCodes:BO,isPressed:IO,filter:YM,trigger:GO,unbind:qM,keyMap:_h,modifier:Mr,modifierMap:xh};for(let r in fy){let t=r;Object.prototype.hasOwnProperty.call(fy,t)&&(yr[t]=fy[t])}if(typeof window<"u"){let r=window.hotkeys;yr.noConflict=t=>(t&&window.hotkeys===yr&&(window.hotkeys=r),yr),window.hotkeys=yr}var KM=r=>{let t=new Map;return{registerHotkeys:(i={})=>{if(typeof i!="object"||i===null)return;let s=[],o=[],n=[];Object.keys(i).forEach(a=>{let l=t.get(a);l?JSON.stringify(l.payload)!==JSON.stringify(i[a].actionPayload)&&(o.push(a),yr.unbind(a)):s.push(a)}),t.forEach((a,l)=>{i.hasOwnProperty(l)||n.push(l)}),n.forEach(a=>{yr.unbind(a),t.delete(a)}),[...s,...o].forEach(a=>{let h=i[a].actionPayload??{};yr(a,()=>{r&&r("keydown",{_event:{key:a},...h})}),t.set(a,{value:a,payload:h})})}}};var UO=r=>r.split("/").pop(),OO=r=>({name:"advancedBufferLoader",priority:2,bufferMap:r,load:async t=>{let e=t.startsWith("file:")?t:UO(t),i=r[e];if(!i)throw new Error(`Buffer not found for key: ${e}`);return{data:i.buffer,type:i.type,metadata:null}},test:async t=>!0,testParse:async t=>!0,parse:async t=>{if(t instanceof w)return t;let e=new Blob([t.data],{type:t.type}),i=await createImageBitmap(e);return new w.from(i)},unload:async t=>t.destroy(!0)}),LO=()=>{let r,t=DM(),e={elements:[],animations:[],audio:[]},i,s={animations:[],elements:[],audio:[],parsers:[]},o,n,a=!1,l,h=f=>f?f.startsWith("audio/")?"audio":f.startsWith("font/")||["application/font-woff","application/font-woff2","application/x-font-ttf","application/x-font-otf"].includes(f)?"font":f.startsWith("video/")?"video":"texture":"texture",c=(f,p,m)=>{o&&o.registerHotkeys(m?.keyboard??{}),f.renderer.events.cursorStyles||(f.renderer.events.cursorStyles={}),f.renderer.events.cursorStyles.default||(f.renderer.events.cursorStyles.default="default"),f.renderer.events.cursorStyles.hover||(f.renderer.events.cursorStyles.hover="pointer");let g=p?.cursorStyles,_=m?.cursorStyles;JSON.stringify(g)!==JSON.stringify(_)&&(_?(_.default&&(f.renderer.events.cursorStyles.default=_.default,f.canvas.style.cursor=_.default),_.hover&&(f.renderer.events.cursorStyles.hover=_.hover)):g&&(f.renderer.events.cursorStyles.default="default",f.renderer.events.cursorStyles.hover="pointer"))},u=async(f,p,m,g)=>{c(f,e.global,m.global),n&&a&&n.abort(),n=new AbortController;let _=n.signal;for(;a;)await new Promise(y=>setTimeout(y,0));a=!0,await bl({app:f,parent:p,prevASTTree:e.elements,nextASTTree:m.elements,animations:m.animations,elementPlugins:s.elements,animationPlugins:s.animations,eventHandler:g,signal:_}),await $g({app:f,prevAudioTree:e.audio,nextAudioTree:m.audio,audioPlugins:s.audio,signal:_}),a=!1,e=m},d={rendererName:"pixi",get canvas(){return r.canvas},findElementByLabel:f=>{if(r.stage.children&&r.stage.children.length>0)for(let p of r.stage.children){let m=findElementByLabel(p,f);if(m)return m}return null},extractBase64:async f=>{let p=r.stage.getChildByLabel(f,!0);if(!p)throw new Error(`Element with label '${f}' not found`);return await r.renderer.extract.base64(p)},assignStageEvent:(f,p)=>{r.stage.eventMode="static",r.stage.on(f,p)},init:async f=>{let{eventHandler:p,plugins:m,width:g,height:_,backgroundColor:y,debug:b=!1}=f,T=[];m?.elements?.forEach(S=>{S?.parse&&T.push(NM({type:S.type,parse:S.parse}))}),s={animations:m.animations??[],elements:m.elements??[],audio:m.audio??[],parsers:T},i=p,o=KM(p),r=new ml,r.audioStage=t,await r.init({width:g,height:_,backgroundColor:y,preference:"webgl"}),r.debug=b;let E=new le;return E.rect(0,0,g,_),E.fill(y||0),r.stage.addChild(E),r.stage.width=g,r.stage.height=_,r.ticker.add(r.audioStage.tick),d},destroy:()=>{r.audioStage.destroy(),r.destroy()},loadAssets:async f=>{if(!f)throw new Error("assetBufferMap is required");let p={audio:{},font:{},video:{},texture:{}};for(let[g,_]of Object.entries(f)){let y=h(_.type);p[y][g]=_}await Promise.all(Object.entries(p.audio).map(([g,_])=>No.load(g,_.buffer))),await Promise.all(Object.entries(p.font).map(async([g,_])=>{let y=new Blob([_.buffer],{type:_.type}),b=URL.createObjectURL(y),T=new FontFace(g,`url(${b})`);try{await T.load(),document.fonts.add(T)}catch(E){console.error(`Failed to load font ${g}:`,E)}finally{URL.revokeObjectURL(b)}})),l?Object.assign(l.bufferMap,p.texture):(l=OO(p.texture),ur.loader.parsers.length=0,ur.reset(),k.add({name:"advanced-buffer-loader",extension:v.Asset,priority:pe.High,loader:l}),typeof ur.registerPlugin=="function"&&ur.registerPlugin(l));let m=Object.keys(p.texture);return Promise.all(m.map(g=>ur.load(g)))},loadAudioAssets:async f=>Promise.all(f.map(async p=>{let g=await(await fetch(p)).arrayBuffer();return No.load(p,g)})),updatedBackgroundColor:f=>{r.renderer.background.color=f},render:f=>{let p=cy({JSONObject:f.elements,parserPlugins:s.parsers}),m={...f,elements:p};u(r,r.stage,m,i)},parse:f=>{let p=cy({JSONObject:f.elements,parserPlugins:s.parsers});return{...f,elements:p}}};return d},ZM=LO;var HSt=ZM;export{ml as Application,ur as Assets,No as AudioAsset,ms as Emitter,ps as Particle,Gk as animatedSpritePlugin,Bk as containerPlugin,kg as createAnimationPlugin,nB as createAssetBufferManager,Gg as createAudioPlugin,he as createElementPlugin,HSt as default,RP as loadParticlePresets,e2 as particlesPlugin,Ak as rectPlugin,xe as registerParticleBehavior,ci as registerParticlePreset,Tl as registerParticleTexture,$g as renderAudio,bl as renderElements,Rk as sliderPlugin,zk as soundPlugin,Pk as spritePlugin,wk as textPlugin,kk as textRevealingPlugin,Wk as tweenPlugin,Ck as videoPlugin};
|
|
1629
1629
|
/*! Bundled license information:
|
|
1630
1630
|
|
|
1631
1631
|
punycode/punycode.js:
|